Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LockingCap Refactor Integration #2672

Merged
merged 40 commits into from
Aug 21, 2024

Commits on Aug 20, 2024

  1. LockingCapConstants Refactor

    Following with the Bridge refactors, it is now time to refactor and remove the locking cap business logic from the Bridge.
    
    Create its package lockingcap with a Support, StorageProvider, and Constants classes. Since it will have its classes should remove from the variable names, lockingCap, to avoid being redundant.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    c6c88e1 View commit details
    Browse the repository at this point in the history
  2. Create LockingCapStorageIndexKey Enum

    Create the package lockingcap with an enum to hold the storage index key for locking cap value.
    
    Create a new enum LockingCapStorageIndexKey to contain the index key for the locking cap value in storage, remove it from BridgeStorageIndexKey, remove the. _KEY suffix, and rename to LOCKING_CAP.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    1c9b2bf View commit details
    Browse the repository at this point in the history
  3. Locking Cap Storage Provider Interface

    Create an interface LockingCapStorageProvider under co.rsk.peg.lockingcap package. Include the signature of the methods mentioned above. Rename saveLockingCap to simply save
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    83c93be View commit details
    Browse the repository at this point in the history
  4. LockingCapSupport Interface

    Create a new interface LockingCapSupport under the co.rsk.peg.lockingcap package. Copy the signature and javadoc for the methods: getLockingCap and increaseLockingCap.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    06f541e View commit details
    Browse the repository at this point in the history
  5. LockingCapConstants Test

    Following the Bridge refactors, we already migrated the LockingCapConstants to their classes to break the high coupling LockingCap had with the Bridge objects, however, it’s missing add coverage, so we need to create Unit Tests to get reliability that your new code doesn't break existing functionality when a change is made to the application.
    
    Create Unit Tests for all methods in LockingCapConstants
    Create Test Cases for all Networks such as MainNet, TestNet, and RegTest.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    07901e6 View commit details
    Browse the repository at this point in the history
  6. Adding An Optional To Return Value getLockingCap() Method

    Adding An Optional To Return Value getLockingCap() Method
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    de22bfd View commit details
    Browse the repository at this point in the history
  7. Removing Arrays.stream From increaseAuthorizedKeys Variable

    Removing Arrays.stream From increaseAuthorizedKeys Variable and replacing it with Collections.unmodifiableList(Stream.of()
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    86bd490 View commit details
    Browse the repository at this point in the history
  8. Create LockingCapConstants in BridgeConstants

    Following with the Bridge refactors, it is now time to refactor and remove locking cap logic from BridgeSupport class. Create LockingCapConstants in BridgeConstants.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    bfe4e85 View commit details
    Browse the repository at this point in the history
  9. Add LockingCapSupport To BridgeSupportBuilder

    Following with the Bridge refactors, it is now time to refactor and remove locking cap logic from Bridge objects to LockingCap objects. This time we need to add Locking Cap logic to BridgeSupportBuilder class. Add WhitelistSupport to BridgeSupportBuilder business logic.
    
    Rebasing Changes With Integration Branch
    
    Rebasing Changes With Integration Branch
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    686541a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    f78079d View commit details
    Browse the repository at this point in the history
  11. Fixing Issue When lockingCap Is Optional.empty()

    - To avoid an NoSuchElementException trying to get the value from Optional.get() when is Optional.empty(), use orElse(null) method.
    
    Assigning a value to an instance variable
    
    - Assigning a value to an instance variable instead of return and after that assign.
    
    Improving readiness, readability and maintainability
    
    - Instead of enclosing in an IF a block of code, we ensure we have the RSKIP134 to execute the rest of the code.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    82f85ba View commit details
    Browse the repository at this point in the history
  12. LockingCapSupport Implementation

    After LockingCapSupport interface has been created, it is time to implement it. Create a new class LockingCapSupportImpl under co.rsk.peg.lockingcap package that implements the methods defined in LockingCapSupport interface. Take the implementation from BridgeSupport class, and move to this new class.
    
    Adapting implementation to stop using Optional and activation as an input at a Support level
    
    Getting back Optional since there's a case when we need to handle a null value
    
    Improving indentation
    
    Avoiding Null Pointer Exception
    
    - If it doesn't exist Locking Cap value, it must return false since RSKIP134 is not active.
    
    Assigning a value from an Optional to a new variable
    
    Rollback the changes on BridgeSupport
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    7baf0ed View commit details
    Browse the repository at this point in the history
  13. Add LockingCapSupport Creation To BridgeSupportFactory

    Update BridgeSupportFactory to create an instance of LockingCapSupport and pass it to BridgeSupport constructor.
    
    Fix code smells
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    04afe10 View commit details
    Browse the repository at this point in the history
  14. Adapt BridgeSupport Methods for LockingCap Refactor

    After LockingCapSupport interface has been created, we’re going to use it on BridgeSupport. Adapt LockingCap methods in BridgeSupport.Use new interface created, LockingCapSupport, under co.rsk.peg.lockingcap package to create LockingCap behavior.
    
    Rebase Code Smell
    
    Removing Optional from getLockingCap() Method at a LockingCapSupport Level
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    7b7001f View commit details
    Browse the repository at this point in the history
  15. Removing activations as an input in save() method at a LockingCapSupp…

    …ort level
    
    Getting back Optional since there's a case when we need to handle a null value and adapting verifyLockDoesNotSurpassLockingCap to use getLockingCap() from LockingCapSupport
    
    Removing IF statement related to activation and adding a new validation to improve Readiness and Maintainability
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    0c2e40b View commit details
    Browse the repository at this point in the history
  16. Fix LockingCapTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix LockingCapTest class, and improve if possible.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    cf8fa26 View commit details
    Browse the repository at this point in the history
  17. Fix BridgeSupportAddSignatureTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix BridgeSupportAddSignatureTest class.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    f11ba1c View commit details
    Browse the repository at this point in the history
  18. Fix BridgeSupportIT after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix BridgeSupportIT class.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    d7d6600 View commit details
    Browse the repository at this point in the history
  19. Fix BridgeSupportRegisterBtcTransactionTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix BridgeSupportRegisterBtcTransactionTest class.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    47aa343 View commit details
    Browse the repository at this point in the history
  20. Fix BridgeStorageProviderTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix BridgeStorageProviderTest class.
    Get rid of LockingCap test methods.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    1b498d3 View commit details
    Browse the repository at this point in the history
  21. Fix BridgeSupportTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix the BridgeSupportTest class.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    fb27e23 View commit details
    Browse the repository at this point in the history
  22. Fix PowpegMigrationTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix the PowpegMigrationTest class.
    Get rid of setting the LockingCap since it is not mandatory in the test. From now on, the test will use the LockingCap default value, i.e., the LockingCapConstants.initialValue().
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    26a9bc3 View commit details
    Browse the repository at this point in the history
  23. Fix BridgeSupportTest after LockingCap refactor

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. After refactoring, showed up different issues in the tests and it is time to fix them.
    
    Fix the BridgeSupportTest class.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    f90d21c View commit details
    Browse the repository at this point in the history
  24. Add Coverage To LockingCapStorageProviderImpl

    Following the Bridge refactors, we already migrated the LockingCap objects to their classes to break the high coupling LockingCap had with the Bridge objects, however, it’s missing add coverage, so we need to create Unit Tests to get reliability that your new code doesn't break existing functionality when a change is made to the application.
    
    - Create tests for LockingCapStorageProviderImpl.
    
    Keep Came Case In the Test Names
    
    Adding a blank line at the end of the file
    
    Getting Readiness To the Code
    
    Adding A New Test Case
    
    Improving Method Names
    
    Improving Variable Name
    
    Improving Method Names And Expected Variable Names
    
    Improving Method Names
    
    Improving Method Names
    
    Moving from place Papyrus200 tests
    
    Improving Comments
    
    Improving Assertions
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    f24a93c View commit details
    Browse the repository at this point in the history
  25. Improving getLockingCap Method

    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    b3e385a View commit details
    Browse the repository at this point in the history
  26. Add Coverage To LockingCapSupportImpl

    Following the Bridge refactors, we already migrated the LockingCapConstants to their classes to break the high coupling LockingCap had with the Bridge objects, however, it’s missing add coverage, so we need to create Unit Tests to get reliability that your new code doesn't break existing functionality when a change is made to the application.
    
    - Create Unit Tests for all methods in LockingCapSupportImpl.
    - Apply different tests for all scenarios.
    
    Activate the wasabi100 Fork to activate and deactivate RSKIPs necessaries in the Test
    
    Changing Method Name
    
    Changing Method Name
    
    Changing Method Names
    
    Keep Camel Case In Test Names
    
    Removing Blank Line
    
    Improving Name Method
    
    Improving Name Method
    
    Improving Name Method
    
    Improving Name Method
    
    Improving Name Method
    
    Adding A Blank Line
    
    Improving Variable Name
    
    Improving Method Names
    
    Use getLockingCap method from LockingCapSupport in Save Tests
    
    Improving Variable Name to maxLockingCapVoteValueAllowed
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    1560a6d View commit details
    Browse the repository at this point in the history
  27. Add Coverage To LockingCap-Related Methods In BridgeSupport

    Following the Bridge refactors, we already migrated the LockingCapConstants to their classes to break the high coupling LockingCap had with the Bridge objects, however, it’s missing add coverage, so we need to create Unit Tests to get reliability that your new code doesn't break existing functionality when a change is made to the application.
    
    - Create Unit Tests for all methods LockingCap-related in BridgeSupport.
    
    Setting private modifier to a constant variable
    
    Adding New Test Case
    
    - Adding new getLockingCap_whenLockingCapIsEmpty_ReturnNull test case.
    
    Keep Camel Case In Test Names
    
    Improving assertion to avoid compare instance but values
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    3daa991 View commit details
    Browse the repository at this point in the history
  28. Fix BridgeSupportFlyoverTest after LockingCap refactor

    Fix registerBtcTransaction_after_RSKIP134_activation_sends_above_lockingcap test
    
    Rollback imports and moved `bridgeSupportBuilder.withLockingCapSupport` to the end before the build
    nathanieliov authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    7d216bf View commit details
    Browse the repository at this point in the history
  29. Zero - Negative LockingCap Value Business Logic

    Following the Bridge refactors, we already migrated the LockingCap processes to their classes to break the high coupling LockingCap had with the Bridge objects. Please move the business logic related to the zero-negative LockingCap value from Bridge.java to LockingCapSupportImpl.java. This way, decouple the process and get all LockingCap business logic, in the LockingCapSupport object.
    
    Adding log for Zero - Negative LockingCap Value
    
    Refactoring increaseLockingCap tests in BridgeTest
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    5137774 View commit details
    Browse the repository at this point in the history
  30. Adding a new Customized LockingCapIllegalArgumentException

    - Using in LockingCap objects LockingCapIllegalArgumentException.
    - In Bridge objects VMException.
    
    Created INCREASE_LOCKING_CAP_LOG_TAG constant to avoid String repetition
    
    Bank line to improve readability
    
    When No Arguments Test Case, replaced encodeSignature with encodeArguments method
    
    Created a message string to avoid repetition
    
    Avoiding String Repetition
    
    Removed Unused Import
    
    Improving Log Message
    
    Improving Log Message for maxLockingCapVoteValueAllowed Case
    
    Improving Exception Handling for increaseLockingCap in Bridge objects
    
    Use ActivationConfigsForTest.all() instead of papyrus200()
    
    - Use ActivationConfigsForTest.all() instead of papyrus200() since it's not needed a specific fork in the most of the test cases
    
    Improving Logger Messages
    
    Improving Logger Messages
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    ac81aa0 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    03f82e5 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    8e74bfe View commit details
    Browse the repository at this point in the history
  33. Improving LockingCapTest nested class in BridgeSupportTest

    Get rid of getInstance in BridgeRegTestConstants
    
    Left the changes on LockingCapTest as it was early
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    622ee18 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    e53f0f6 View commit details
    Browse the repository at this point in the history
  35. Add Coverage in BridgeConstants

    Add coverage for getFeePerKbConstants, getWhitelistConstants, and getFederationConstants in BridgeConstants.
    
    Use wildcard imports
    
    Get rid of assertEquals in new Unit Tests
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    523432d View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    947656b View commit details
    Browse the repository at this point in the history
  37. LockingCap Integration Test

    Following the Bridge refactors, we already migrated the LockingCapConstants to their classes to break the high coupling LockingCap had with the Bridge objects, however, it’s missing add coverage, so we need to create Unit Tests to get reliability that your new code doesn't break existing functionality when a change is made to the application.
    
    Create the Integration Test for the whole process related to LockingCap.
    wilmerrootstock authored and marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    96df961 View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    1b9b7dc View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    c04b77f View commit details
    Browse the repository at this point in the history
  40. Remove unthrown exceptions from method signatures

    Remove unused import
    marcos-iov committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    35e5a8d View commit details
    Browse the repository at this point in the history