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

perf: load withdrawal tx history by priority #2128

Merged
merged 28 commits into from
Dec 12, 2024
Merged

Conversation

spsjvc
Copy link
Member

@spsjvc spsjvc commented Dec 9, 2024

Summary

Steps to test

@cla-bot cla-bot bot added the cla-signed label Dec 9, 2024
Copy link

vercel bot commented Dec 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
arbitrum-token-bridge ✅ Ready (Inspect) Visit Preview Dec 11, 2024 1:00pm

@@ -41,11 +39,9 @@ export async function fetchTokenWithdrawalsFromEventLogs({
const erc20Bridger = await Erc20Bridger.fromProvider(l2Provider)
const promises: ReturnType<Erc20Bridger['getWithdrawalEvents']>[] = []

const senderNonce = await getNonce(sender, { provider: l2Provider })
Copy link
Member Author

Choose a reason for hiding this comment

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

moved to fetchWithdrawals.ts so we do it just once

Comment on lines -33 to -40
}: {
sender?: string
receiver?: string
fromBlock: BlockTag
toBlock: BlockTag
l2Provider: Provider
l2GatewayAddresses?: string[]
}) {
Copy link
Member Author

Choose a reason for hiding this comment

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

extracted into type FetchTokenWithdrawalsFromEventLogsParams

Copy link
Member Author

Choose a reason for hiding this comment

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

this function will now be used only to keep track of custom custom gateways

@brtkx brtkx self-requested a review December 10, 2024 14:51
@spsjvc spsjvc marked this pull request as ready for review December 10, 2024 15:17
Comment on lines +87 to +96
const ethWithdrawalsFromEventLogs = await fetchETHWithdrawalsFromEventLogs({
receiver,
fromBlock: toBlock + 1,
toBlock: 'latest',
l2Provider: l2Provider
})

await wait(2_000)

const tokenWithdrawalsFromEventLogs =
Copy link
Member Author

Choose a reason for hiding this comment

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

load eth withdrawals before token withdrawals

@@ -0,0 +1,3 @@
export function wait(ms: number) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not super sure about the filename since wait is generic, doesn't have much to do with exponential wait-time, and might be hard to discover later.
Unless we plan on adding a lot more related functions here, I guess just having wait from CommonUtils would suffice?

Copy link
Contributor

Choose a reason for hiding this comment

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

Will be taken up in next PR.

const standardGateway = network.tokenBridge?.childErc20Gateway
const customGateway = network.tokenBridge?.childCustomGateway
const wethGateway = network.tokenBridge?.childWethGateway
const otherGateways = await fetchL2Gateways(provider)
Copy link
Contributor

Choose a reason for hiding this comment

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

Outside the scope of the current PR, but since it touches this code, we might want to rename fetchL2Gateways to a better generic name. Infact I would suggest we don;t need the fetchL2Gateways file anymore and we can move it inside this file only.

The function can be called fetchOtherGateways to better match it's usage.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will be taken up in next PR.

@spsjvc spsjvc changed the title perf: load some parts of tx history sequentially perf: load withdrawal tx history by priority Dec 11, 2024
@spsjvc spsjvc merged commit fe58b57 into master Dec 12, 2024
75 checks passed
@spsjvc spsjvc deleted the perf-sequential-tx-history branch December 12, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants