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

Getting Multicall chunk failed error for historical block numbers #13

Closed
ashrita-systango opened this issue Apr 8, 2023 · 1 comment

Comments

@ashrita-systango
Copy link

ashrita-systango commented Apr 8, 2023

I have written a function that takes multiple wallet/account address, token address & block number, then it prepares a multicall & call the function. For recent block numbers I get the proper result but for block number which are old like block numbers from 2017 or 2018 it gives below error. If I make the same contract function call via curl with eth_call method it works as expected.

I am getting error till block number 7256659 on ethereum.

Error Message I received:

Node Multicall Service  | multicall chunck failed: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
Node Multicall Service  | multicall chunck failed: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
Node Multicall Service  | multicall chunck failed: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
Node Multicall Service  | {"level":50,"time":1680943876211,"pid":100079,"hostname":"ulap165","err":{"type":"Error","message":"multicall: retries exceeded","stack":"Error: multicall: retries exceeded\n    at Object.<anonymous> (/home/ulap165/workspace/space_and_time/repo/eventx/blockchain-indexing-eventx/eventx_sidecar/multicall/node_modules/@1inch/multicall/multicall.helpers.js:75:15)\n    at Generator.throw (<anonymous>)\n    at rejected (/home/ulap165/workspace/space_and_time/repo/eventx/blockchain-indexing-eventx/eventx_sidecar/multicall/node_modules/tslib/tslib.js:165:69)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"},"msg":"multicall: retries exceeded"}

Sample code that I have written:

const w3 = new Web3()
nodeProviderUrl = ""
const contractAddress = "0x8d035edd8e09c3283463dade67cc0d49d6868063"
const provider = new Web3ProviderConnector(new Web3(nodeProviderUrl));

const gasLimitService = new GasLimitService(provider, contractAddress);
const multiCallService = new MultiCallService(provider, contractAddress);

let gasLimit;
gasLimit = await gasLimitService.calculateGasLimit();

addressMapList = [{"walletAddress": "0x536480A12fa7A2934872448752F864Cd0F9ba796", "tokenAddress": "0xa74476443119a942de498590fe1f2454d7d4ac0d"}]
blockNumber = 4310318

async function tokenBalanceMulticall(addressMapList, blockNumber) {
    const requests = addressMapList.map((addressMap) => {
        return {
            to: addressMap.tokenAddress,
            data: provider.contractEncodeABI(
                [{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}],
                addressMap.tokenAddress,
                'balanceOf',
                [addressMap.walletAddress]
            ),
            gas: 30_000
        };
    });

    const params = {
        maxChunkSize: 5000,
        retriesLimit: 3,
        blockNumber: blockNumber,
        gasBuffer: 100_000
    };

    const response = await multiCallService.callByGasLimit(
        requests,
        gasLimit,
        params
    );
    return response;
}

Curl command for eth_call method:

curl node_provider_url \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"method":"eth_call","params":[{"from":null,"to":"0xa74476443119A942dE498590Fe1f2454d7D4aC0d","data":"0x70a08231000000000000000000000000536480a12fa7a2934872448752f864cd0f9ba796"}, "0x41C52E"],"id":1,"jsonrpc":"2.0"}'
@krboktv
Copy link
Member

krboktv commented Aug 2, 2023

0x8d035edd8e09c3283463dade67cc0d49d6868063

Multicall contract has been deployed at block 12492042
That's why you receive this error

@krboktv krboktv closed this as completed Jun 24, 2024
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

No branches or pull requests

2 participants