-
Notifications
You must be signed in to change notification settings - Fork 0
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: use multicall getEthBalance #46
Conversation
ZKS-147 Promises optimizations
Check places where Promise.all or Multicall might be beneficial to reduce the delay of performing sequential requests/multiple RPC calls
|
@@ -144,14 +149,19 @@ export class L1MetricsService { | |||
args: [this.sharedBridge.address], | |||
} as const; | |||
}), | |||
{ | |||
address: multicall3EthereumAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets extract this value from chain, lets make sure that exist also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
} as const); | ||
} else { | ||
const [erc20Balances, ethBalance] = await Promise.all([ | ||
this.evmProviderService.multicall({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont understand this ser, correct me if iam wrong but if you dont have multicall3Address
u cant call .multical({...})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah you're right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same doubt as @0xkenj1, after that seems good to go 👌 👌
balances = await Promise.all([ | ||
...addresses.map((tokenAddress) => | ||
this.evmProviderService.readContract(tokenAddress, erc20Abi, "balanceOf", [ | ||
this.sharedBridge.address, | ||
]), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any possibility to have one of these calls being throttled by the RPC node err'ing with a 429
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could but the current amount of tokens is not an issue from what i tested with llama rpc, there's the fine line between adding the pagination overhead when making multiple RPC requests too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a very edgy case that practically wont exist, however we are gona be having 429 when calling multiple methods, but we expect to tackle that issue with caching and viem fallback client
balances = await Promise.all([ | ||
...addresses.map((tokenAddress) => | ||
this.evmProviderService.readContract(tokenAddress, erc20Abi, "balanceOf", [ | ||
this.sharedBridge.address, | ||
]), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a very edgy case that practically wont exist, however we are gona be having 429 when calling multiple methods, but we expect to tackle that issue with caching and viem fallback client
🤖 Linear
Closes ZKS-147
Description
Use Multicall
getEthBalance
function to fetch Shared Bridge eth balance in the samemulticall
call