Skip to content

Conversation

Pratham1812
Copy link
Contributor

Implemented Manual Deserialization for AccountInfo to Support eth_getAccountInfo RPC

Fixes #2564

Problem

Currently, fetching account information requires multiple RPC calls:

let (nonce, balance, code) = tokio::join!(nonce, balance, code);

This is inefficient when eth_getAccountInfo can provide all data in a single call.

Solution

Implemented manual Deserialize for AccountInfo that:

  • Supports both REVM internal format and RPC response format
  • Auto-computes code_hash when only code is provided (RPC scenario)
  • Maintains backward compatibility with existing serialized data
  • Supports both code_hash and codeHash field names

Field Name Compatibility

The deserializer accepts both naming conventions:

  • code_hash - Rust/REVM internal format (snake_case)
  • codeHash - JSON-RPC standard format

Supported Formats

Current REVM format (backward compatible):

{"balance": "0x1000", "nonce": 42, "code_hash": "0xabc...", "code": "0x608..."}

RPC format (new optimization):

{"balance": "0x1000", "nonce": 42, "code": "0x608..."}

code_hash computed automatically

CamelCase RPC format:

{"balance": "0x1000", "nonce": 42, "codeHash": "0xabc..."}

Copy link

codspeed-hq bot commented Jul 31, 2025

CodSpeed Performance Report

Merging #2830 will not alter performance

Comparing Pratham1812:alpha/rpc (52f8dc4) with main (dfe1fdb)

Summary

✅ 171 untouched benchmarks

@Pratham1812
Copy link
Contributor Author

@mattsse @rakita If you guys could please review this.

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.

Implement manual deserialize for AccountInfo
1 participant