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

setting block number is not effecting the request #99

Open
HadiEsna opened this issue Jul 11, 2024 · 3 comments
Open

setting block number is not effecting the request #99

HadiEsna opened this issue Jul 11, 2024 · 3 comments

Comments

@HadiEsna
Copy link
Contributor

The Problem
When I try to change the block number of the request, it doesn't effect the result at all
I were able to fix it by changing the way we feed the blocknumber in the contract call. (please take look at here
Can you check if I'm doing sth wrong or it's a bug with library. I can create a PR too if it's needed.

Code to replicate

    let calls: any = [];
calls.push({
      reference: "CHAINLINK-PRICE" ,
      contractAddress: 0x13e3Ee699D1909E989722E753853AE30b17e08c5,
      abi: oracleABI, // chainlink oracle abi (copy it from [here](https://optimistic.etherscan.io/address/0x13e3Ee699D1909E989722E753853AE30b17e08c5#code)
      calls: [{ reference: feed, methodName: "latestRoundData", methodParameters: [] }],
    });
    let data = await multicall
      .call(calls, {
        blockNumber: 121357248, // around 30 days ago (Jun-13-2024)
      })
      .catch((e: any) => {
        console.log("error", e);
        return {};
      });
          console.log("data2", BigInt(data.results["CHAINLINK-PRICE"].callsReturnContext[0].returnValues[3].hex).toString());  // update timestamp (which shows now, not 30 days ago)
          console.log("block number", data.blockNumber);
    
@radisa-bogdanovic
Copy link

radisa-bogdanovic commented Jul 15, 2024

I had a similar issue with Arbitrum One or Arbitrum Nova, I'm not sure wich one exactly. Request was eth_getBalance. It always returned the latest block but also returned different result balances (i guessed based of the number of the block). I tested the closest block to check if it returned a valid result, and it did. What I did was to include the block from the request into the result table, along with its timestamp and everything else. If it's returning the correct data, you might want to implement a workaround like I did.

@HadiEsna
Copy link
Contributor Author

How did you solve the issue? (apart from including the output in the result table)

@radisa-bogdanovic
Copy link

Hmm, i didn't actualy fix it in the libary and i dont know how to do that 2 be honest. I just create workaround. So basicaly if i need blockNumber or timeStamp of requested data i just call getBlock(121357248) method from web3 and get data for that block. I test balances in time 1 year ago, 1 month ago, 1 day ago and many more and for the latest he return correct data for the latest balance or closest block to them. For oldest data i dont find a way to compare them but i see difference between them and i workaround with theory that only blockNumber in 'response' is incorrect. in my case that solve a problem wich i had.

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