Skip to content

Conversation

@dylmanning
Copy link
Collaborator

Alchemy is limiting fetching block to ranges of 500. Implemented chunking to adhere to this restriction.

{
    "errorType": "BlockchainConnectionError",
    "errorMessage": "Error scanning migrations: HttpRequestError: HTTP request failed.\n\nStatus: 400\nURL: https://arb-mainnet.g.alchemy.com/v2/oo7P8s9OYuw1zhGb0d8YFv21GodCRQYH\nRequest body: {\"method\":\"eth_getLogs\",\"params\":[{\"address\":\"0xb8b47E61188Cc197F36C48B2298cb05afE4332E1\",\"topics\":[\"0x83428582867423cd1eed24ec91dd589c793b9a477e8d567c2bcb1516be10367a\"],\"fromBlock\":\"0x141502f2\",\"toBlock\":\"0x141504ec\"}]}\n\nDetails: {\"code\":-32600,\"message\":\"You can make eth_getLogs requests with up to a 500 block range. Based on your parameters, this block range should work: [0x141502f2, 0x141504e5]\"}\nVersion: viem@2.22.11",
    "name": "BlockchainConnectionError",
    "stack": [
        "BlockchainConnectionError: Error scanning migrations: HttpRequestError: HTTP request failed.",
        "",
        "Status: 400",
        "URL: https://arb-mainnet.g.alchemy.com/v2/oo7P8s9OYuw1zhGb0d8YFv21GodCRQYH",
        "Request body: {\"method\":\"eth_getLogs\",\"params\":[{\"address\":\"0xb8b47E61188Cc197F36C48B2298cb05afE4332E1\",\"topics\":[\"0x83428582867423cd1eed24ec91dd589c793b9a477e8d567c2bcb1516be10367a\"],\"fromBlock\":\"0x141502f2\",\"toBlock\":\"0x141504ec\"}]}",
        "",
        "Details: {\"code\":-32600,\"message\":\"You can make eth_getLogs requests with up to a 500 block range. Based on your parameters, this block range should work: [0x141502f2, 0x141504e5]\"}",
        "Version: viem@2.22.11",
        "    at t.BlockchainConnectionProvider.scanMigrations (/var/task/index.js:18:658956)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
        "    at async h (/var/task/index.js:18:15860)",
        "    at async t.main (/var/task/index.js:18:15334)",
        "    at async e.handler (/var/task/index.js:18:877096)"
    ]
}

@JoseMiguelHerrera
Copy link
Member

Can't believe they just changed this. How often were you running the lambda function? 5 mins? I guess we could speed it up by 4 to get around this, but chunking is defs the proper solution. Reviewing

Copy link
Member

@JoseMiguelHerrera JoseMiguelHerrera left a comment

Choose a reason for hiding this comment

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

Looks good. I ran a small unit test of the chunking logic and it separates things as expected. Good addition, as it makes us resilient to future block range limits. I guess the only thing that could be added is if the limit could be gotten via API.

@JoseMiguelHerrera JoseMiguelHerrera merged commit 52fc081 into test May 15, 2025
1 check 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.

3 participants