Description
👋 Hi Geth team! The web3py team is looking to support the state override parameter in eth_call
and we're running into some unexpected behavior. It looks like @rjl493456442 implemented this in #19917. Please see details below!
System information
Geth version: v1.10.1
OS & Version: OSX
Expected behaviour
When using the state override argument for eth_call
, I expect that a change to the Solidity code will return the expected result. See steps to reproduce below.
Actual behaviour
It looks like some bytecode is returned instead of the expected int, but haven't been able to figure out what the bytecode represents.
Steps to reproduce the behaviour
Following the example in the docs here leads to the expected behavior. I'm using curl with Rinkeby on Infura.
Working as expected:
pragma solidity ^0.5.10;
contract CheckpointOracle {
mapping(address => bool) admins;
address[] adminList;
uint64 sectionIndex;
uint height;
bytes32 hash;
uint sectionSize;
uint processConfirms;
uint threshold;
function VotingThreshold() public view returns (uint) {
return threshold;
}
}
bytecode (from Remix): 6080604052348015600f57600080fd5b5060888061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b600060075490509056fea265627a7a72315820c20a98eb83e0fa5a4f0c05d6f392484e4d8009ccacdedd0c6884c53210f8ab5f64736f6c63430005110032
function hash (from Remix): 0be5b6ba
> curl --data '{"method":"eth_call","params":[{"to":"0xebe8efa441b9302a0d7eaecc277c09d20d684540","data":"0x0be5b6ba"}, "latest", {"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {"code":"0x6080604052348015600f57600080fd5b5060888061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b600060075490509056fea265627a7a72315820c20a98eb83e0fa5a4f0c05d6f392484e4d8009ccacdedd0c6884c53210f8ab5f64736f6c63430005110032"}}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://rinkeby.infura.io/v3/$INFURA_API_KEY
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000002"}
which is correct.
However, changing the Solidity code to:
pragma solidity ^0.5.10;
contract CheckpointOracle {
mapping(address => bool) admins;
address[] adminList;
uint64 sectionIndex;
uint height;
bytes32 hash;
uint sectionSize;
uint processConfirms;
uint threshold;
function VotingThreshold() public pure returns (uint) {
return 42;
}
}
bytecode (from Remix): 6080604052348015600f57600080fd5b5060878061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000602a90509056fea265627a7a723158209dca50efe62375ee4d60d5d21ee28edd70e2afa4558b9f8560778158274c9eed64736f6c63430005110032
function hash (from Remix): 0be5b6ba
Then:
> curl --data '{"method":"eth_call","params":[{"to":"0xebe8efa441b9302a0d7eaecc277c09d20d684540","data":"0x0be5b6ba"}, "latest", {"0xebe8efa441b9302a0d7eaecc277c09d20d684540": {"code":"6080604052348015600f57600080fd5b5060878061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000602a90509056fea265627a7a723158209dca50efe62375ee4d60d5d21ee28edd70e2afa4558b9f8560778158274c9eed64736f6c63430005110032"}}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://rinkeby.infura.io/v3/$INFURA_API_KEY
{"jsonrpc":"2.0","id":1,"result":"0x6080604052348015600f57600080fd5b506004361060285760003560e01c80630be5b6ba14602d575b600080fd5b60336049565b6040518082815260200191505060405180910390f35b6000602a90509056fea265627a7a723158209dca50efe62375ee4d60d5d21ee28edd70e2afa4558b9f8560778158274c9eed64736f6c63430005110032"}
I expect result to return 42 after decoding.
It's also worth noting that neither Remix nor py-solc-x generates the same bytecode from the Solidity contract source shown in the docs.
I'm not sure if this is a bug or a documentation issue or a decoding issue on our end.
Thanks!