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

Implementation of 'Flow Cancel' modifications to Governor calculations #3798

Merged
merged 38 commits into from
Jun 4, 2024

Commits on Jun 4, 2024

  1. Add allow list of tokens, and tests

    - Add an allow list of tokens to be used in the Flow Cancel design
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    4d226c7 View commit details
    Browse the repository at this point in the history
  2. Flow cancel implementation

    Adds an implementation of 'flow canceling' logic into the Governor:
    - There now exists an allow-list of 'flow cancel tokens'
    - When calculating the governor usage for some emitting chain, its usage
      is now decrementing by the sum of all transfers from other chains that
      use flow-canceling tokens and have their destination chain equal to
      emitting chain in question
    - In effect, TrimAndSumValue now calculates the net Usage of a chain
      when flow canceling is taken into account
    - This commit also adds a basic unit test demonstrating flow cancelling
      for a simple case
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    b0479e4 View commit details
    Browse the repository at this point in the history
  3. Add more unit tests for flow cancelling

    1. Add check to ensure that now underflow is possible when the sum of
       flow cancelling transactions is greater than the sum of all transfers
       from the emitter chain
    2. Ensure that the sum of all transfers from an emitter chain does not
       exceed the dailyLimit of a Governor. This is done by testing against
       a specific error message and ensuring that it is returned by the
       program when we force it into this illegal state
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    c660f00 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    7a00310 View commit details
    Browse the repository at this point in the history
  5. remove TODOs

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    801169d View commit details
    Browse the repository at this point in the history
  6. fix incorrect comment

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    03347aa View commit details
    Browse the repository at this point in the history
  7. formatting with goimports

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    e579e59 View commit details
    Browse the repository at this point in the history
  8. Add unit test for sum invariant

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    e466efb View commit details
    Browse the repository at this point in the history
  9. Fix comment on function

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    c2a5bc5 View commit details
    Browse the repository at this point in the history
  10. Cleanup and clarity

    - Remove most of the unused field from the flow cancel token list to
      make it easier to grok
    - Clarify in the source code that the tokens are taken directly from the
      generated mainnet token list
    - Move comments around in the governor code to make them easier to read
    - Make varible name extra verbose and easier to understand
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    a1cc70f View commit details
    Browse the repository at this point in the history
  11. gosimple fixes

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    e5bdb34 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    07f4d77 View commit details
    Browse the repository at this point in the history
  13. Restore comment

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    34282a9 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    40ee150 View commit details
    Browse the repository at this point in the history
  15. Fix governor unit test

    Hard-coded value should be 1, not 2, because we are only summing over
    the emitter chain's transfers
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    256983f View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    b332205 View commit details
    Browse the repository at this point in the history
  17. node: rewrite flow cancel logic

    Use the concept of a 'negative transfer' to represent flow-cancelling.
    This required the following modifications:
    
    - Add wrapped struct around db.Transfer that includes a int64 value for
      negative calcuations. It is used only by the Governor for these
      calculations
    
    `chainEntry` struct
    - modify to use the wrapped struct that includes int64 value
    - Added comments to clarify the purpose of transfers with negative
      values
    
    `tokenEntry` struct
    - modify to use a `flowCancel` boolean that marks whether incoming
      transfers of this asset should reduce the Governor limit for the
      Target chain
    
    `TrimAndSumValue` function
    - Modify to return signed integer
    - ensure it cannot go below 0 (underflow). Instead, negative sums will
      just return 0 to signal that the Governor has no 'usage' in the sense
      of the rate-limiting budget.
    
    In general, calling code and function signatures were modified to accept
    the new transfer type and signed integers instead of unsigned where
    necessary.
    
    This commit also adds validation functions that make it easier to add
    flow cancelling transfers to a chainEntry. It also adds two 'checked
    math' functions in the style of Rust to allow for easier overflow
    checking.
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    eab717b View commit details
    Browse the repository at this point in the history
  18. node: documentation and cleanup

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    88c8940 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    a1b9919 View commit details
    Browse the repository at this point in the history
  20. node: goimports linting

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    aba0cbf View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    2eab92c View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    f39268a View commit details
    Browse the repository at this point in the history
  23. node: Check return value for reloadTransfer

    Also remove commented code from a previous commit
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    63fd38e View commit details
    Browse the repository at this point in the history
  24. node: More happy path checkedadd tests

    also cleanup comments
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    7aa3b8e View commit details
    Browse the repository at this point in the history
  25. node: goimports on governor

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    e99454c View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    1d5c6e1 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    31967f4 View commit details
    Browse the repository at this point in the history
  28. node: Comment flow cancel verification

    - Add a comment to the helper method to mention that the calling code is
      responsible for verifying that a flow cancel asset should actually
      flow cancel. (This is done via the `tokens` property in the Governor
      struct
    - Add comments to calling code mentioning that the verification is
      necessary
    - Modify the unit tests to perform this verification
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    6d8a29c View commit details
    Browse the repository at this point in the history
  29. node: fix ineffassign in unit test

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    28f7a34 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    e941590 View commit details
    Browse the repository at this point in the history
  31. node: fix function comments

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    d33f063 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    7936c03 View commit details
    Browse the repository at this point in the history
  33. node: fix godoc

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    a2796dc View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    4853448 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    30bcf93 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    62512d2 View commit details
    Browse the repository at this point in the history
  37. node: Add flow cancel tokens to devnet and testnet

    Added Solana testnet USDC to the config for devnet and testnet
    Address sourced from Circle docs: https://developers.circle.com/stablecoins/docs/usdc-on-test-networks
    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    32b3cb0 View commit details
    Browse the repository at this point in the history
  38. node: fix incorrect comment

    johnsaigle authored and SEJeff committed Jun 4, 2024
    Configuration menu
    Copy the full SHA
    a02393c View commit details
    Browse the repository at this point in the history