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

Support EIP-1898 - geth state-related RPC methods now support specifying block hashes as well as block numbers #285

Closed
BlinkyStitt opened this issue Nov 19, 2019 · 2 comments · Fixed by #345

Comments

@BlinkyStitt
Copy link

I noticed that Geth 1.9.6 added support for specifying block hashes for some methods (ethereum/go-ethereum#19491).

https://eips.ethereum.org/EIPS/eip-1898

In my code, I've been passing the block number through, but passing the block hash through will give consistent answers if a re-org happens in the middle of some calls.

I think functions that have block: Option<BlockNumber> in their args would need to change, but I haven't thought about exactly how yet.

pub fn call(&self, req: CallRequest, block: Option<BlockNumber>) -> CallFuture<Bytes, T::Out> {

@tomusdrw
Copy link
Owner

I guess we could introduce a BlockId enum with Hash and Number variants.

@BlinkyStitt
Copy link
Author

I think that would work. Maybe something like:

enum BlockId {
  Number(BlockNumber),
  /// Block hash and a boolean for requireCanonical
  Hash(H256, bool),
}

But maybe the BlockNumber enum should have Hash(H256, bool) added to it instead? It looks like that would cover all the functions needed. I'm not sure if it covers too much though. The name "BlockNumber" also wouldn't fit as well. I think renaming it to "BlockId" matches the better since it has strings like "latest" and "earliest" in it, too.

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 a pull request may close this issue.

2 participants