Skip to content

Commit

Permalink
perf: remove genesis state from chainspec (#41)
Browse files Browse the repository at this point in the history
RSP does not make use of the genesis state, which is parsed from JSON at
runtime, costing a lot of zkVM cycles.

Switches to manually constructing `ChainSpec` instead.
  • Loading branch information
xJonathanLEI authored Sep 9, 2024
1 parent 2f2f1d9 commit cb3f341
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 830 deletions.
10 changes: 5 additions & 5 deletions crates/executor/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use reth_execution_types::ExecutionOutcome;
use reth_optimism_consensus::validate_block_post_execution as validate_block_post_execution_optimism;
use reth_primitives::{proofs, Block, BlockWithSenders, Bloom, Header, Receipt, Receipts, Request};
use revm::{db::CacheDB, Database};
use revm_primitives::{Address, U256};
use revm_primitives::{address, U256};

/// Chain ID for Ethereum Mainnet.
pub const CHAIN_ID_ETH_MAINNET: u64 = 0x1;
Expand Down Expand Up @@ -178,7 +178,7 @@ impl ClientExecutor {

impl Variant for EthereumVariant {
fn spec() -> ChainSpec {
rsp_primitives::chain_spec::mainnet().unwrap()
rsp_primitives::chain_spec::mainnet()
}

fn execute<DB>(
Expand Down Expand Up @@ -209,7 +209,7 @@ impl Variant for EthereumVariant {

impl Variant for OptimismVariant {
fn spec() -> ChainSpec {
rsp_primitives::chain_spec::op_mainnet().unwrap()
rsp_primitives::chain_spec::op_mainnet()
}

fn execute<DB>(
Expand Down Expand Up @@ -240,7 +240,7 @@ impl Variant for OptimismVariant {

impl Variant for LineaVariant {
fn spec() -> ChainSpec {
rsp_primitives::chain_spec::linea_mainnet().unwrap()
rsp_primitives::chain_spec::linea_mainnet()
}

fn execute<DB>(
Expand Down Expand Up @@ -279,7 +279,7 @@ impl Variant for LineaVariant {
// - address: 20 bytes
// - seal: 65 bytes
// we extract the address from the 32nd to 52nd byte.
let addr = Address::from_slice(&Self::spec().genesis().extra_data[32..52]);
let addr = address!("8f81e2e3f8b46467523463835f965ffe476e1c9e");

// We hijack the beneficiary address here to match the clique consensus.
let mut block = block.clone();
Expand Down
Loading

0 comments on commit cb3f341

Please sign in to comment.