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

feat: Implement BundleDataClient and Dataworker #1155

Merged
merged 159 commits into from
Feb 20, 2024
Merged

Conversation

nicholaspai
Copy link
Member

@nicholaspai nicholaspai commented Jan 23, 2024

Summary

  • Implements logic to propose and execute root bundles containing V3 and V3 events. This PR should be backwards compatible and can be deployed today.
  • the way I recommend to tackle reviewing this large PR is to focus on the BundleDataClient logic. This is the most complex bit and has the most branches.

DataworkerUtils

  • We should now invalidate bundle block ranges before we attempt to propose or dispute them if the SpokePool client does not have enough of a lookback to fetch all expired deposits in the latest bundle. See DataworkerUtils.blockRangesAreInvalidForSpokeClients
  • _buildRelayerRefundRoot, _buildPoolRebalanceRoot, _buildSlowFillRoot are all implemented to handle V3 BundleData objects in addition to preserving existing logic. You'll see that the logic is built to be naturally backwards compatible

BundleDataClient

  • Returns new v3 types: bundleFillsV3, bundleDepositsV3, bundleSlowFills, bundleExpiredDeposits, unexecutableV3SlowFills

Unit tests

Unit tests in Dataworker.loadData and Dataworker.buildRoots are illustrative of new logic in BundleDataClient and DataworkerUtils.

Note this PR will only work with across-protocol/sdk#535 as the SDK version
Updated now to v0.21.1

- We should now invalidate bundle block ranges before we attempt to propose or dispute them if the SpokePool client does not have enough of a lookback to fetch all expired deposits in the latest bundle. See `DataworkerUtils.blockRangesAreInvalidForSpokeClients`
- Add algorithm in-comments in BundleDataClient for loading "newly expired" deposits for a bundle
- This PR should be reviewed in tandem with SDK #TODO which has the required SDK changes to make this work
nicholaspai added a commit to across-protocol/sdk that referenced this pull request Jan 23, 2024
…lient

These will be useful for the dataworker functions (beginning to be implemented in across-protocol/relayer#1155 ) that have to deal with expired deposits. We need to be able to know when a deposit is expired (comparing its fill deadline TIMESTAMP with a bundle BLOCK NUMBER), and also whether our spoke pool clients have enough of a lookback to fetch expired deposits for a bundle
src/clients/BundleDataClient.ts Outdated Show resolved Hide resolved
src/clients/BundleDataClient.ts Show resolved Hide resolved
src/dataworker/Dataworker.ts Outdated Show resolved Hide resolved
src/dataworker/DataworkerUtils.ts Outdated Show resolved Hide resolved
@nicholaspai nicholaspai requested a review from pxrl January 24, 2024 15:46
nicholaspai added a commit to across-protocol/sdk that referenced this pull request Jan 29, 2024
These will be useful for the dataworker functions (beginning to be implemented in across-protocol/relayer#1155 ) that have to deal with expired deposits. We need to be able to know when a deposit is expired (comparing its fill deadline TIMESTAMP with a bundle BLOCK NUMBER), and also whether our spoke pool clients have enough of a lookback to fetch expired deposits for a bundle

Signed-off-by: nicholaspai <[email protected]>
@nicholaspai nicholaspai changed the title feat: Add helper methods for dealing with V3 expired-deposit logic feat: Add skeleton for V3 BundleDataClient and Dataworker logic Feb 1, 2024
src/dataworker/PoolRebalanceUtils.ts Outdated Show resolved Hide resolved
src/clients/BundleDataClient.ts Outdated Show resolved Hide resolved
src/dataworker/Dataworker.ts Outdated Show resolved Hide resolved
src/dataworker/Dataworker.ts Outdated Show resolved Hide resolved
src/dataworker/DataworkerUtils.ts Outdated Show resolved Hide resolved
src/dataworker/PoolRebalanceUtils.ts Outdated Show resolved Hide resolved
src/dataworker/PoolRebalanceUtils.ts Outdated Show resolved Hide resolved
src/dataworker/PoolRebalanceUtils.ts Show resolved Hide resolved
src/interfaces/index.ts Outdated Show resolved Hide resolved
src/interfaces/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@pxrl pxrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge effort 👏

Copy link
Contributor

@pxrl pxrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few issues in type narrowing in test.

test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
test/Dataworker.buildRoots.ts Outdated Show resolved Hide resolved
@nicholaspai nicholaspai merged commit 3d61baa into master Feb 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants