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: batch request contract for fetching multiple token balance #36

Merged
merged 4 commits into from
Aug 2, 2024

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Jul 31, 2024

🤖 Linear

Closes ZKS-138

Description

Copy link

linear bot commented Jul 31, 2024

ZKS-75 L1 TVL

Create a Batch contract to query token balances from SharedBridge

Get the top 30 list of token addresses and tickers by USD holdings on shared bridge from etherscan.

Measure how many token balance request can be made until fail or revert.
ex:

  • use 20 tokens
  • use 100 tokens
  • use 1000 tokens

and validate boundaries

BridgeHub address: 0x303a465B659cBB0ab36eE643eA362c509EEb5213

SharedBridge address: 0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB

AC:

  • Batch contract implemented
  • unit tests for batch contract
  • EvmProvider batchRequest() method used
  • Unit tests for L1MetricsService

Comment on lines 34 to 38
// We're using vm.etch to place the creation code at a deterministic address.
vm.etch(_deploymentAddress, creationCode);

// simulate deployment
(bool success, bytes memory result) = _deploymentAddress.call("");
Copy link
Member

Choose a reason for hiding this comment

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

wow, didn't know this trick!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Claude-AI gave me a hand jaja 😅

Comment on lines 52 to 53
vm.mockCall(address(_tokenA), abi.encodeWithSelector(IERC20.balanceOf.selector), abi.encode(_initialBalanceA));
vm.mockCall(address(_tokenB), abi.encodeWithSelector(IERC20.balanceOf.selector), abi.encode(_initialBalanceB));
Copy link
Member

Choose a reason for hiding this comment

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

no need to mock here right?

tokenAddresses[0] = address(_tokenA);
tokenAddresses[1] = address(_tokenB);

bytes memory creationCode = getBytecode(_target, tokenAddresses);
Copy link
Member

Choose a reason for hiding this comment

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

there's another one like this..

Suggested change
bytes memory creationCode = getBytecode(_target, tokenAddresses);
bytes memory creationCode = _getBytecode(_target, tokenAddresses);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

Copy link

linear bot commented Aug 1, 2024

ZKS-138 Batch Contract implementation

Create a Batch contract to query token balances from SharedBridge

Use Foundry for testing the contract

@0xnigir1 0xnigir1 marked this pull request as ready for review August 1, 2024 13:45
@0xnigir1 0xnigir1 requested a review from wei3erHase August 1, 2024 13:45
@0xkenj1 0xkenj1 requested review from 0xkenj1 and 0xyaco August 1, 2024 16:15
Copy link
Collaborator

@0xkenj1 0xkenj1 left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

Oooh some Solidity action over here 👀

Copy link
Member

@wei3erHase wei3erHase left a comment

Choose a reason for hiding this comment

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

lgtm!

@0xnigir1 0xnigir1 merged commit d6e1dab into dev Aug 2, 2024
6 checks passed
@0xnigir1 0xnigir1 deleted the feat/l1-tvl-batch-contract branch August 2, 2024 14:35
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.

4 participants