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

WEB3-276: feat: Add Account query functionality to Steel #414

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Wollac
Copy link
Contributor

@Wollac Wollac commented Jan 24, 2025

This PR adds the Account struct to enable querying Ethereum account information in both host and guest environments, similar to how Contract works for contract interactions.

Changes

  • Add Account struct with host/guest implementations for querying account info
  • Add documentation and examples showing usage patterns
  • Add integration test demonstrating account queries including bytecode fetching

Usage Example

// Host environment:
let mut env = EthEvmEnv::builder().rpc(url).build().await?;
let account = Account::preflight(address, &mut env);
let info = account.bytecode(true).info().await?;

// Guest environment:
let env = evm_input.into_env();
let account = Account::new(address, &env);
let info = account.bytecode(true).info();

Testing

Added integration test account_info that:

  • Verifies account information matches between preflight and execution
  • Validates balance, nonce, code, and code hash against provider data
  • Tests bytecode fetching functionality

Implementation Notes

  • Follows same pattern as Contract with separate host/guest implementations
  • Uses builder pattern for configuration (e.g., bytecode())
  • Provides both error-handling (try_info()) and panicking (info()) variants

The implementation aims to provide a consistent interface alongside the existing Contract functionality while maintaining the same security and verification guarantees.

Fixes #380, WEB3-276

@Wollac Wollac requested a review from a team as a code owner January 24, 2025 16:14
@github-actions github-actions bot changed the title feat: Add account query support to Steel WEB3-276: feat: Add account query support to Steel Jan 24, 2025
@Wollac Wollac requested review from nategraf and capossele January 24, 2025 16:15
@Wollac Wollac changed the title WEB3-276: feat: Add account query support to Steel WEB3-276: feat: Add Account query functionality to Steel Jan 24, 2025
// limitations under the License.

//! Types related to account queries.
pub use revm::primitives::{AccountInfo, Bytecode};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Steel account query returns the corresponding revm::primitives::AccountInfo. This is a bit closer to the actual (revm) EVM execution, but it does not return the storage root (which is also inaccessible from inside the EVM) and the code is returned as revm::primitives::Bytecode instead of just Bytes. Alternatively, it may be preferable to define and return our own new type:

pub struct AccountInfo {
    pub nonce: u64,
    pub balance: U256,
    pub storage_root: B256,
    pub code_hash: B256,
    pub code: Option<Byte>,
}

@Wollac Wollac requested a review from willemolding January 24, 2025 16:29
@Wollac Wollac force-pushed the feat/account-info branch from 817ba5d to 713385c Compare January 30, 2025 18:15
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 this pull request may close these issues.

[Feature] Ability to prove historical account state (e.g. balance, nonce, codeHash, storageRoot) using Steel
1 participant