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

[Feature] Support truncated key for JsonStorageKey #1553

Open
mattsse opened this issue Oct 23, 2024 · 0 comments
Open

[Feature] Support truncated key for JsonStorageKey #1553

mattsse opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mattsse
Copy link
Member

mattsse commented Oct 23, 2024

Component

rpc, serde

Describe the feature you would like

pub struct JsonStorageKey(pub B256);

ref https://github.com/ethereum/go-ethereum/blob/a5fe7353cff959d6fcfcdd9593de19056edb9bdb/internal/ethapi/api.go#L741-L744

this exists for backwards compatiblity, which I think we don't need to focus on but if the input is a 32bytes hex string then this should be preserved in the serde roundtrip

this can be solved with a helper enum that is similar to:

/// Either a hash _or_ a block number
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub enum HashOrNumber {
/// The hash
Hash(B256),
/// The number
Number(u64),
}

but with B256,U256, B256 must be decoded first

TODO

  • introduce helper enum
  • replace wrapped value of JsonStorageKey

Additional context

No response

@mattsse mattsse added the enhancement New feature or request label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@mattsse @yash-atreya and others