From 0bfcbd81a4b3d9bd93d8fe86c5d8852774066656 Mon Sep 17 00:00:00 2001 From: mohiiit Date: Thu, 9 Oct 2025 19:47:59 +0530 Subject: [PATCH 01/10] fix: for the reexecute --- Cargo.lock | 30 ++++++++++-------------------- Cargo.toml | 9 +++++++-- crates/rpc/src/executor.rs | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b503b9947..f4d8f409ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,8 +792,7 @@ checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "apollo_compilation_utils" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e46083be9ce864f2adf57b095fe9cd6bc9e665665e3e7272ed95fc47c58593" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_infra_utils", "cairo-lang-sierra 2.12.0-dev.1", @@ -811,8 +810,7 @@ dependencies = [ [[package]] name = "apollo_compile_to_native" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1ac19d63f36f543c447a8d75b0c032a34e2ca71706501918d7923eaef1c8e" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_compilation_utils", "apollo_compile_to_native_types", @@ -825,8 +823,7 @@ dependencies = [ [[package]] name = "apollo_compile_to_native_types" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389c8e9ea0c68822b179c75ac3aae646b101c390d01095d993e1ae41287d41d5" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_config", "serde", @@ -836,8 +833,7 @@ dependencies = [ [[package]] name = "apollo_config" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63c97b0be7573c6e0191c8b34776c64ed1bb621148f7d14d14fef4422d630a4" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_infra_utils", "clap", @@ -855,8 +851,7 @@ dependencies = [ [[package]] name = "apollo_infra_utils" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171220821a924e7c170341fc564553163488a17496194ea5f7d2039f294bc2e4" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_proc_macros", "assert-json-diff", @@ -874,8 +869,7 @@ dependencies = [ [[package]] name = "apollo_metrics" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eddd44db0a445e928fd4e78641587ef33e4391f186418089511998a90c2f1f2e" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "indexmap 2.11.0", "metrics 0.24.2", @@ -887,8 +881,7 @@ dependencies = [ [[package]] name = "apollo_proc_macros" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7989de6d0cf43a44d6c69c20f183e23af6959fc2be53f65554e4efaf8e6cb5b" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "lazy_static", "proc-macro2", @@ -1965,8 +1958,7 @@ dependencies = [ [[package]] name = "blockifier" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63be42f5ff48f7f9065b8b03d137fece1cc153c7aefcffb267abd5abd6e4e09a" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "anyhow", "apollo_compilation_utils", @@ -2013,8 +2005,7 @@ dependencies = [ [[package]] name = "blockifier_test_utils" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feefdfee072986f1203ee7f04a3b81e7c354ce45242a726299b56f91dcba0859" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_infra_utils", "cairo-lang-starknet-classes", @@ -10946,8 +10937,7 @@ dependencies = [ [[package]] name = "starknet_api" version = "0.15.0-rc.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8aab893c06cdba387b8ef61a079ae0ccdcb926d6ecca11107f536d788e62a8" +source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" dependencies = [ "apollo_infra_utils", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 691a2bfeba..96efe1bbee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,11 @@ axum = "0.8.4" base64 = "0.22.1" bincode = "2.0.1" bitvec = "1.0.1" -blockifier = { version = "0.15.0-rc.4", features = ["node_api", "reexecution"] } +# c53a10ee235bc993c507fa52109309aa2e8b12c3 +#blockifier = { version = "0.15.0-rc.4", features = ["node_api", "reexecution"] } +blockifier = { git = "https://github.com/karnotxyz/sequencer", rev = "c53a10ee235bc993c507fa52109309aa2e8b12c3", features = [ + "node_api", "reexecution" +] } bloomfilter = "1.0.16" bytes = "1.4.0" cached = "0.44.0" @@ -126,7 +130,8 @@ smallvec = "1.15.1" # This one needs to match the version used by blockifier starknet-types-core = "=0.1.8" # This one needs to match the version used by blockifier -starknet_api = "0.15.0-rc.4" +#starknet_api = "0.15.0-rc.4" +starknet_api = { git = "https://github.com/karnotxyz/sequencer", rev = "c53a10ee235bc993c507fa52109309aa2e8b12c3"} syn = "1.0" tempfile = "3.8" test-log = { version = "0.2.12", features = ["trace"] } diff --git a/crates/rpc/src/executor.rs b/crates/rpc/src/executor.rs index 88f9e76b97..873b94f7ea 100644 --- a/crates/rpc/src/executor.rs +++ b/crates/rpc/src/executor.rs @@ -366,7 +366,7 @@ pub fn compose_executor_transaction( class_info, paid_fee_on_l1, deployed_address, - pathfinder_executor::AccountTransactionExecutionFlags::default(), + pathfinder_executor::AccountTransactionExecutionFlags{ only_query: false, charge_fee: false, validate: true, strict_nonce_check: true }, )?; Ok(tx) From 5bd4a3dfa6c7ca806cd5c46509bbc3f4ef664d59 Mon Sep 17 00:00:00 2001 From: mohiiit Date: Fri, 17 Oct 2025 16:18:54 +0530 Subject: [PATCH 02/10] moving to official blockifier release --- Cargo.lock | 30 ++++++++++++++++++++---------- Cargo.toml | 12 ++++++------ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4d8f409ab..5b503b9947 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,7 +792,8 @@ checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "apollo_compilation_utils" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88e46083be9ce864f2adf57b095fe9cd6bc9e665665e3e7272ed95fc47c58593" dependencies = [ "apollo_infra_utils", "cairo-lang-sierra 2.12.0-dev.1", @@ -810,7 +811,8 @@ dependencies = [ [[package]] name = "apollo_compile_to_native" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1ac19d63f36f543c447a8d75b0c032a34e2ca71706501918d7923eaef1c8e" dependencies = [ "apollo_compilation_utils", "apollo_compile_to_native_types", @@ -823,7 +825,8 @@ dependencies = [ [[package]] name = "apollo_compile_to_native_types" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389c8e9ea0c68822b179c75ac3aae646b101c390d01095d993e1ae41287d41d5" dependencies = [ "apollo_config", "serde", @@ -833,7 +836,8 @@ dependencies = [ [[package]] name = "apollo_config" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63c97b0be7573c6e0191c8b34776c64ed1bb621148f7d14d14fef4422d630a4" dependencies = [ "apollo_infra_utils", "clap", @@ -851,7 +855,8 @@ dependencies = [ [[package]] name = "apollo_infra_utils" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171220821a924e7c170341fc564553163488a17496194ea5f7d2039f294bc2e4" dependencies = [ "apollo_proc_macros", "assert-json-diff", @@ -869,7 +874,8 @@ dependencies = [ [[package]] name = "apollo_metrics" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd44db0a445e928fd4e78641587ef33e4391f186418089511998a90c2f1f2e" dependencies = [ "indexmap 2.11.0", "metrics 0.24.2", @@ -881,7 +887,8 @@ dependencies = [ [[package]] name = "apollo_proc_macros" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7989de6d0cf43a44d6c69c20f183e23af6959fc2be53f65554e4efaf8e6cb5b" dependencies = [ "lazy_static", "proc-macro2", @@ -1958,7 +1965,8 @@ dependencies = [ [[package]] name = "blockifier" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63be42f5ff48f7f9065b8b03d137fece1cc153c7aefcffb267abd5abd6e4e09a" dependencies = [ "anyhow", "apollo_compilation_utils", @@ -2005,7 +2013,8 @@ dependencies = [ [[package]] name = "blockifier_test_utils" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feefdfee072986f1203ee7f04a3b81e7c354ce45242a726299b56f91dcba0859" dependencies = [ "apollo_infra_utils", "cairo-lang-starknet-classes", @@ -10937,7 +10946,8 @@ dependencies = [ [[package]] name = "starknet_api" version = "0.15.0-rc.4" -source = "git+https://github.com/karnotxyz/sequencer?rev=c53a10ee235bc993c507fa52109309aa2e8b12c3#c53a10ee235bc993c507fa52109309aa2e8b12c3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8aab893c06cdba387b8ef61a079ae0ccdcb926d6ecca11107f536d788e62a8" dependencies = [ "apollo_infra_utils", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 96efe1bbee..2131481aff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,10 +53,10 @@ base64 = "0.22.1" bincode = "2.0.1" bitvec = "1.0.1" # c53a10ee235bc993c507fa52109309aa2e8b12c3 -#blockifier = { version = "0.15.0-rc.4", features = ["node_api", "reexecution"] } -blockifier = { git = "https://github.com/karnotxyz/sequencer", rev = "c53a10ee235bc993c507fa52109309aa2e8b12c3", features = [ - "node_api", "reexecution" -] } +blockifier = { version = "0.15.0-rc.4", features = ["node_api", "reexecution"] } +# blockifier = { git = "https://github.com/karnotxyz/sequencer", rev = "c53a10ee235bc993c507fa52109309aa2e8b12c3", features = [ +# "node_api", "reexecution" +# ] } bloomfilter = "1.0.16" bytes = "1.4.0" cached = "0.44.0" @@ -130,8 +130,8 @@ smallvec = "1.15.1" # This one needs to match the version used by blockifier starknet-types-core = "=0.1.8" # This one needs to match the version used by blockifier -#starknet_api = "0.15.0-rc.4" -starknet_api = { git = "https://github.com/karnotxyz/sequencer", rev = "c53a10ee235bc993c507fa52109309aa2e8b12c3"} +starknet_api = "0.15.0-rc.4" +# starknet_api = { git = "https://github.com/karnotxyz/sequencer", rev = "c53a10ee235bc993c507fa52109309aa2e8b12c3"} syn = "1.0" tempfile = "3.8" test-log = { version = "0.2.12", features = ["trace"] } From 43891515a757c3913eaf298d937e047452b92e8c Mon Sep 17 00:00:00 2001 From: Mehul Chauhan Date: Tue, 4 Nov 2025 18:58:47 +0530 Subject: [PATCH 03/10] fix l3 flag --- crates/common/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 1190058e8d..52986a0283 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -342,6 +342,12 @@ impl Dummy for EthereumAddress { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub enum SettlementLayerAddress { + Ethereum(EthereumAddress), + Starknet(ContractAddress), +} + #[derive(Debug, thiserror::Error)] #[error("expected slice length of 16 or less, got {0}")] pub struct FromSliceError(usize); From 85684c4453db519157fe42703c96b5772444c50c Mon Sep 17 00:00:00 2001 From: Mehul Chauhan Date: Tue, 4 Nov 2025 19:04:41 +0530 Subject: [PATCH 04/10] fix flag --- crates/consensus-fetcher/src/lib.rs | 4 ++ crates/executor/src/block.rs | 11 ++++++ crates/executor/src/execution_state.rs | 9 ++++- crates/pathfinder/examples/re_execute.rs | 1 + crates/pathfinder/src/bin/pathfinder/main.rs | 15 ++++++-- crates/pathfinder/src/config.rs | 20 ++++++++-- crates/pathfinder/src/validator.rs | 38 +++++++++++++++++-- crates/rpc/src/context.rs | 4 ++ crates/rpc/src/method/call.rs | 1 + crates/rpc/src/method/estimate_fee.rs | 1 + crates/rpc/src/method/estimate_message_fee.rs | 1 + crates/rpc/src/method/fetch_proposers.rs | 2 +- crates/rpc/src/method/fetch_validators.rs | 1 + .../rpc/src/method/simulate_transactions.rs | 1 + .../src/method/trace_block_transactions.rs | 1 + crates/rpc/src/method/trace_transaction.rs | 1 + 16 files changed, 99 insertions(+), 12 deletions(-) diff --git a/crates/consensus-fetcher/src/lib.rs b/crates/consensus-fetcher/src/lib.rs index 95a2099ff1..b5afdf975d 100644 --- a/crates/consensus-fetcher/src/lib.rs +++ b/crates/consensus-fetcher/src/lib.rs @@ -123,6 +123,7 @@ fn get_proposer_contract_address( pub fn get_validators_at_height( storage: &Storage, chain_id: ChainId, + is_l3: bool, height: u64, ) -> Result, ConsensusFetcherError> { let mut db_conn = storage @@ -146,6 +147,7 @@ pub fn get_validators_at_height( // Create execution state for call let execution_state = ExecutionState::simulation( chain_id, + is_l3, header, None, // No pending state for this call L1BlobDataAvailability::Disabled, @@ -182,6 +184,7 @@ pub fn get_validators_at_height( pub fn get_proposers_at_height( storage: &Storage, chain_id: ChainId, + is_l3: bool, height: u64, ) -> Result, ConsensusFetcherError> { let mut db_conn = storage @@ -205,6 +208,7 @@ pub fn get_proposers_at_height( // Create execution state for call let execution_state = ExecutionState::simulation( chain_id, + is_l3, header, None, // No pending state for this call L1BlobDataAvailability::Disabled, diff --git a/crates/executor/src/block.rs b/crates/executor/src/block.rs index 4177a8bc47..839a1939b4 100644 --- a/crates/executor/src/block.rs +++ b/crates/executor/src/block.rs @@ -32,6 +32,7 @@ type ReceiptAndEvents = (Receipt, Vec); impl BlockExecutor { pub fn new( chain_id: ChainId, + is_l3: bool, block_info: BlockInfo, eth_fee_address: ContractAddress, strk_fee_address: ContractAddress, @@ -39,6 +40,7 @@ impl BlockExecutor { ) -> anyhow::Result { let execution_state = ExecutionState::validation( chain_id, + is_l3, block_info, None, Default::default(), @@ -67,6 +69,7 @@ impl BlockExecutor { /// the final state of a previous executor pub fn new_with_initial_state( chain_id: ChainId, + is_l3: bool, block_info: BlockInfo, eth_fee_address: ContractAddress, strk_fee_address: ContractAddress, @@ -75,6 +78,7 @@ impl BlockExecutor { ) -> anyhow::Result { let execution_state = ExecutionState::validation( chain_id, + is_l3, block_info, None, Default::default(), @@ -505,6 +509,7 @@ mod tests { // Execute them all in a single executor let mut single_executor = BlockExecutor::new( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -527,6 +532,7 @@ mod tests { // Execute batch 1 let mut executor1 = BlockExecutor::new( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -542,6 +548,7 @@ mod tests { // Execute batch 2 with state from batch 1 let mut executor2 = BlockExecutor::new_with_initial_state( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -558,6 +565,7 @@ mod tests { // Execute batch 3 with state from batch 2 let mut executor3 = BlockExecutor::new_with_initial_state( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -616,6 +624,7 @@ mod tests { // Single executor execution let mut single_executor = BlockExecutor::new( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -643,6 +652,7 @@ mod tests { let mut current_executor = BlockExecutor::new( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -655,6 +665,7 @@ mod tests { for batch in batches.into_iter() { current_executor = BlockExecutor::new( chain_id, + false, block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, diff --git a/crates/executor/src/execution_state.rs b/crates/executor/src/execution_state.rs index bcfbd3a544..a009570020 100644 --- a/crates/executor/src/execution_state.rs +++ b/crates/executor/src/execution_state.rs @@ -166,6 +166,7 @@ pub struct ExecutionState { eth_fee_address: ContractAddress, strk_fee_address: ContractAddress, native_class_cache: Option, + is_l3: bool, } pub fn create_executor( @@ -320,7 +321,7 @@ impl ExecutionState { strk_fee_token_address, eth_fee_token_address, }, - is_l3: false, + is_l3: self.is_l3, }) } @@ -401,6 +402,7 @@ impl ExecutionState { #[allow(clippy::too_many_arguments)] pub fn trace( chain_id: ChainId, + is_l3: bool, header: BlockHeader, pending_state: Option>, versioned_constants_map: VersionedConstantsMap, @@ -418,12 +420,14 @@ impl ExecutionState { eth_fee_address, strk_fee_address, native_class_cache, + is_l3, } } #[allow(clippy::too_many_arguments)] pub fn simulation( chain_id: ChainId, + is_l3: bool, header: BlockHeader, pending_state: Option>, l1_blob_data_availability: L1BlobDataAvailability, @@ -442,12 +446,14 @@ impl ExecutionState { eth_fee_address, strk_fee_address, native_class_cache, + is_l3, } } #[allow(clippy::too_many_arguments)] pub fn validation( chain_id: ChainId, + is_l3: bool, block_info: BlockInfo, pending_state: Option>, versioned_constants_map: VersionedConstantsMap, @@ -465,6 +471,7 @@ impl ExecutionState { eth_fee_address, strk_fee_address, native_class_cache, + is_l3, } } } diff --git a/crates/pathfinder/examples/re_execute.rs b/crates/pathfinder/examples/re_execute.rs index ed2da15d99..91f1eca6ae 100644 --- a/crates/pathfinder/examples/re_execute.rs +++ b/crates/pathfinder/examples/re_execute.rs @@ -148,6 +148,7 @@ fn execute( let execution_state = ExecutionState::trace( chain_id, + false, work.header.clone(), None, Default::default(), diff --git a/crates/pathfinder/src/bin/pathfinder/main.rs b/crates/pathfinder/src/bin/pathfinder/main.rs index 313a871b9e..8181684e0b 100644 --- a/crates/pathfinder/src/bin/pathfinder/main.rs +++ b/crates/pathfinder/src/bin/pathfinder/main.rs @@ -247,6 +247,7 @@ Hint: This is usually caused by exceeding the file descriptor limit of your syst execution_storage, sync_state.clone(), pathfinder_context.network_id, + pathfinder_context.is_l3, pathfinder_context.contract_addresses, pathfinder_context.gateway.clone(), rx_pending.clone(), @@ -736,6 +737,7 @@ If you are trying to connect to a custom Starknet on another Ethereum network, p struct PathfinderContext { network: Chain, network_id: ChainId, + is_l3: bool, gateway: starknet_gateway_client::Client, database: PathBuf, contract_addresses: EthContractAddresses, @@ -767,6 +769,7 @@ mod pathfinder_context { NetworkConfig::Mainnet => Self { network: Chain::Mainnet, network_id: ChainId::MAINNET, + is_l3: false, gateway: GatewayClient::mainnet(gateway_timeout).with_api_key(api_key), database: data_directory.join("mainnet.sqlite"), contract_addresses: EthContractAddresses::new_known(core_addr::MAINNET), @@ -774,6 +777,7 @@ mod pathfinder_context { NetworkConfig::SepoliaTestnet => Self { network: Chain::SepoliaTestnet, network_id: ChainId::SEPOLIA_TESTNET, + is_l3: false, gateway: GatewayClient::sepolia_testnet(gateway_timeout).with_api_key(api_key), database: data_directory.join("testnet-sepolia.sqlite"), contract_addresses: EthContractAddresses::new_known(core_addr::SEPOLIA_TESTNET), @@ -781,6 +785,7 @@ mod pathfinder_context { NetworkConfig::SepoliaIntegration => Self { network: Chain::SepoliaIntegration, network_id: ChainId::SEPOLIA_INTEGRATION, + is_l3: false, gateway: GatewayClient::sepolia_integration(gateway_timeout) .with_api_key(api_key), database: data_directory.join("integration-sepolia.sqlite"), @@ -792,10 +797,12 @@ mod pathfinder_context { gateway, feeder_gateway, chain_id, + is_l3, } => Self::configure_custom( gateway, feeder_gateway, chain_id, + is_l3, data_directory, api_key, gateway_timeout, @@ -815,6 +822,7 @@ mod pathfinder_context { gateway: Url, feeder: Url, chain_id: String, + is_l3: bool, data_directory: &Path, api_key: Option, gateway_timeout: Duration, @@ -833,6 +841,8 @@ mod pathfinder_context { .eth_contract_addresses() .await .context("Downloading starknet L1 address from gateway for proxy check")?; + + let l1_core_address = reply_contract_addresses.starknet.0; let contract_addresses = EthContractAddresses::new_custom( l1_core_address, @@ -856,6 +866,7 @@ mod pathfinder_context { let context = Self { network, network_id, + is_l3, gateway, database: data_directory.join("custom.sqlite"), contract_addresses, @@ -902,9 +913,7 @@ async fn verify_database( if let Some(database_genesis) = db_genesis { use pathfinder_common::consts::{ - MAINNET_GENESIS_HASH, - SEPOLIA_INTEGRATION_GENESIS_HASH, - SEPOLIA_TESTNET_GENESIS_HASH, + MAINNET_GENESIS_HASH, SEPOLIA_INTEGRATION_GENESIS_HASH, SEPOLIA_TESTNET_GENESIS_HASH, }; let db_network = match database_genesis { diff --git a/crates/pathfinder/src/config.rs b/crates/pathfinder/src/config.rs index 8c5192c9f9..06167b00fa 100644 --- a/crates/pathfinder/src/config.rs +++ b/crates/pathfinder/src/config.rs @@ -562,6 +562,15 @@ Note that 'custom' requires also setting the --gateway-url and --feeder-gateway- required_if_eq("network", Network::Custom) )] chain_id: Option, + + #[arg( + long = "is-l3", + long_help = "Set if the network is an L3 network", + env = "PATHFINDER_IS_L3", + required_if_eq("network", Network::Custom) + )] + is_l3: Option, + #[arg( long = "feeder-gateway-url", value_name = "URL", @@ -881,6 +890,7 @@ pub enum NetworkConfig { gateway: Url, feeder_gateway: Url, chain_id: String, + is_l3: bool, }, } @@ -923,22 +933,24 @@ impl NetworkConfig { args.gateway, args.feeder_gateway, args.chain_id, + args.is_l3, ) { - (None, None, None, None) => return None, - (Some(Custom), Some(gateway), Some(feeder_gateway), Some(chain_id)) => { + (None, None, None, None, None) => return None, + (Some(Custom), Some(gateway), Some(feeder_gateway), Some(chain_id), Some(is_l3)) => { NetworkConfig::Custom { gateway, feeder_gateway, chain_id, + is_l3, } } - (Some(Custom), _, _, _) => { + (Some(Custom), _, _, _, _) => { unreachable!("`--network custom` requirements are handled by clap derive") } // Handle non-custom variants in an inner match so that the compiler will force // us to handle a new network variants explicitly. Otherwise we end up with a // catch-all arm that would swallow new variants silently. - (Some(non_custom), None, None, None) => match non_custom { + (Some(non_custom), None, None, None, None) => match non_custom { Mainnet => NetworkConfig::Mainnet, SepoliaTestnet => NetworkConfig::SepoliaTestnet, SepoliaIntegration => NetworkConfig::SepoliaIntegration, diff --git a/crates/pathfinder/src/validator.rs b/crates/pathfinder/src/validator.rs index 08fcabe55c..ccf121b191 100644 --- a/crates/pathfinder/src/validator.rs +++ b/crates/pathfinder/src/validator.rs @@ -46,11 +46,22 @@ use crate::state::block_hash::{ calculate_transaction_commitment, }; +/// Determines is_l3 from ChainId. +/// For known networks (Mainnet, Sepolia, SepoliaIntegration), is_l3 is always false. +/// For custom networks, this should be passed explicitly from network config. +fn is_l3_from_chain_id(chain_id: ChainId) -> bool { + match chain_id { + ChainId::MAINNET | ChainId::SEPOLIA_TESTNET | ChainId::SEPOLIA_INTEGRATION => false, + _ => false, // Default to false for unknown/custom networks, should be passed explicitly + } +} + pub fn new( chain_id: ChainId, proposal_init: ProposalInit, ) -> anyhow::Result { - ValidatorBlockInfoStage::new(chain_id, proposal_init) + let is_l3 = is_l3_from_chain_id(chain_id); + ValidatorBlockInfoStage::new(chain_id, is_l3, proposal_init) } /// Validates the basic block metadata and proposal information before any @@ -58,17 +69,20 @@ pub fn new( #[derive(Debug)] pub struct ValidatorBlockInfoStage { chain_id: ChainId, + is_l3: bool, proposal_height: BlockNumber, } impl ValidatorBlockInfoStage { pub fn new( chain_id: ChainId, + is_l3: bool, proposal_init: ProposalInit, ) -> anyhow::Result { // TODO(validator) how can we validate the proposal init? Ok(ValidatorBlockInfoStage { chain_id, + is_l3, proposal_height: BlockNumber::new(proposal_init.block_number) .context("ProposalInit height exceeds i64::MAX")?, }) @@ -89,6 +103,7 @@ impl ValidatorBlockInfoStage { let Self { chain_id, + is_l3, proposal_height, } = self; @@ -135,9 +150,10 @@ impl ValidatorBlockInfoStage { Ok(ValidatorTransactionBatchStage { chain_id, + is_l3, block_info, expected_block_header: None, - block_executor: LazyBlockExecutor::new(chain_id, block_info, storage.clone()), + block_executor: LazyBlockExecutor::new(chain_id, is_l3, block_info, storage.clone()), transactions: Vec::new(), receipts: Vec::new(), events: Vec::new(), @@ -152,6 +168,7 @@ impl ValidatorBlockInfoStage { /// Executes transactions and manages the block execution state. pub struct ValidatorTransactionBatchStage { chain_id: ChainId, + is_l3: bool, block_info: pathfinder_executor::types::BlockInfo, expected_block_header: Option, block_executor: LazyBlockExecutor, @@ -173,6 +190,7 @@ enum LazyBlockExecutor { /// on first use. Uninitialized { chain_id: ChainId, + is_l3: bool, block_info: Box, storage: Storage, }, @@ -189,11 +207,13 @@ enum LazyBlockExecutor { impl LazyBlockExecutor { fn new( chain_id: ChainId, + is_l3: bool, block_info: pathfinder_executor::types::BlockInfo, storage: Storage, ) -> Self { LazyBlockExecutor::Uninitialized { chain_id, + is_l3, block_info: Box::new(block_info), storage, } @@ -206,6 +226,7 @@ impl LazyBlockExecutor { let this = std::mem::replace(self, Self::Initializing); let LazyBlockExecutor::Uninitialized { chain_id, + is_l3, block_info, storage, } = this @@ -216,6 +237,7 @@ impl LazyBlockExecutor { let db_conn = storage.connection().context("Create database connection")?; let be = BlockExecutor::new( chain_id, + is_l3, *block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -245,16 +267,24 @@ impl LazyBlockExecutor { impl ValidatorTransactionBatchStage { /// Create a new ValidatorTransactionBatchStage + /// + /// Note: This method is primarily used in tests. For production code, use + /// `ValidatorBlockInfoStage::validate_consensus_block_info` which properly + /// passes `is_l3` from the network config. pub fn new( chain_id: ChainId, block_info: pathfinder_executor::types::BlockInfo, storage: Storage, ) -> anyhow::Result { + // For tests and when called directly, determine is_l3 from chain_id + // (returns false for known networks, false for custom by default) + let is_l3 = is_l3_from_chain_id(chain_id); Ok(ValidatorTransactionBatchStage { chain_id, + is_l3, block_info, expected_block_header: None, - block_executor: LazyBlockExecutor::new(chain_id, block_info, storage.clone()), + block_executor: LazyBlockExecutor::new(chain_id, is_l3, block_info, storage.clone()), transactions: Vec::new(), receipts: Vec::new(), events: Vec::new(), @@ -321,6 +351,7 @@ impl ValidatorTransactionBatchStage { // First batch - start from initial state BlockExecutor::new( self.chain_id, + self.is_l3, self.block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, @@ -337,6 +368,7 @@ impl ValidatorTransactionBatchStage { let previous_state = last_executor.get_final_state()?; BlockExecutor::new_with_initial_state( self.chain_id, + self.is_l3, self.block_info, ETH_FEE_TOKEN_ADDRESS, STRK_FEE_TOKEN_ADDRESS, diff --git a/crates/rpc/src/context.rs b/crates/rpc/src/context.rs index 71223aa8cb..53caa03c00 100644 --- a/crates/rpc/src/context.rs +++ b/crates/rpc/src/context.rs @@ -86,6 +86,7 @@ pub struct RpcContext { pub sync_status: Arc, pub submission_tracker: SubmittedTransactionTracker, pub chain_id: ChainId, + pub is_l3: bool, pub contract_addresses: EthContractAddresses, pub sequencer: SequencerClient, pub websocket: Option, @@ -103,6 +104,7 @@ impl RpcContext { execution_storage: Storage, sync_status: Arc, chain_id: ChainId, + is_l3: bool, contract_addresses: EthContractAddresses, sequencer: SequencerClient, pending_data: tokio_watch::Receiver, @@ -127,6 +129,7 @@ impl RpcContext { sync_status, submission_tracker, chain_id, + is_l3, contract_addresses, pending_data: pending_watcher, sequencer, @@ -250,6 +253,7 @@ impl RpcContext { storage, sync_state, chain_id, + false, EthContractAddresses::new_known(core_contract_address), sequencer.disable_retry_for_tests(), rx, diff --git a/crates/rpc/src/method/call.rs b/crates/rpc/src/method/call.rs index 17a26314a3..c4f908bb2a 100644 --- a/crates/rpc/src/method/call.rs +++ b/crates/rpc/src/method/call.rs @@ -162,6 +162,7 @@ pub async fn call( let state = ExecutionState::simulation( context.chain_id, + context.is_l3, header, pending, L1BlobDataAvailability::Disabled, diff --git a/crates/rpc/src/method/estimate_fee.rs b/crates/rpc/src/method/estimate_fee.rs index 0649dcd3f9..8f1278993f 100644 --- a/crates/rpc/src/method/estimate_fee.rs +++ b/crates/rpc/src/method/estimate_fee.rs @@ -107,6 +107,7 @@ pub async fn estimate_fee( let state = ExecutionState::simulation( context.chain_id, + context.is_l3, header, pending, L1BlobDataAvailability::Enabled, diff --git a/crates/rpc/src/method/estimate_message_fee.rs b/crates/rpc/src/method/estimate_message_fee.rs index ccff853381..2dc8741e50 100644 --- a/crates/rpc/src/method/estimate_message_fee.rs +++ b/crates/rpc/src/method/estimate_message_fee.rs @@ -111,6 +111,7 @@ pub async fn estimate_message_fee( let state = ExecutionState::simulation( context.chain_id, + context.is_l3, header, pending, L1BlobDataAvailability::Enabled, diff --git a/crates/rpc/src/method/fetch_proposers.rs b/crates/rpc/src/method/fetch_proposers.rs index eb9a3b1e1f..c910463cdd 100644 --- a/crates/rpc/src/method/fetch_proposers.rs +++ b/crates/rpc/src/method/fetch_proposers.rs @@ -106,7 +106,7 @@ pub async fn fetch_proposers( let span = tracing::Span::current(); let proposers = util::task::spawn_blocking(move |_| { let _g = span.enter(); - consensus_fetcher::get_proposers_at_height(&context.storage, context.chain_id, input.height) + consensus_fetcher::get_proposers_at_height(&context.storage, context.chain_id, context.is_l3, input.height) }) .await .context("Database read panic or shutting down")? diff --git a/crates/rpc/src/method/fetch_validators.rs b/crates/rpc/src/method/fetch_validators.rs index ed18b2d2ef..77851fafcf 100644 --- a/crates/rpc/src/method/fetch_validators.rs +++ b/crates/rpc/src/method/fetch_validators.rs @@ -109,6 +109,7 @@ pub async fn fetch_validators( consensus_fetcher::get_validators_at_height( &context.storage, context.chain_id, + context.is_l3, input.height, ) }) diff --git a/crates/rpc/src/method/simulate_transactions.rs b/crates/rpc/src/method/simulate_transactions.rs index 2557a38328..213ca197ec 100644 --- a/crates/rpc/src/method/simulate_transactions.rs +++ b/crates/rpc/src/method/simulate_transactions.rs @@ -109,6 +109,7 @@ pub async fn simulate_transactions( let state = pathfinder_executor::ExecutionState::simulation( context.chain_id, + context.is_l3, header, pending, pathfinder_executor::L1BlobDataAvailability::Enabled, diff --git a/crates/rpc/src/method/trace_block_transactions.rs b/crates/rpc/src/method/trace_block_transactions.rs index d51cb9fe86..a4c38c97b1 100644 --- a/crates/rpc/src/method/trace_block_transactions.rs +++ b/crates/rpc/src/method/trace_block_transactions.rs @@ -139,6 +139,7 @@ pub async fn trace_block_transactions( let hash = header.hash; let state = pathfinder_executor::ExecutionState::trace( context.chain_id, + context.is_l3, header, None, context.config.versioned_constants_map, diff --git a/crates/rpc/src/method/trace_transaction.rs b/crates/rpc/src/method/trace_transaction.rs index cd57713ba5..fec56b3a8c 100644 --- a/crates/rpc/src/method/trace_transaction.rs +++ b/crates/rpc/src/method/trace_transaction.rs @@ -170,6 +170,7 @@ pub async fn trace_transaction( let hash = header.hash; let state = pathfinder_executor::ExecutionState::trace( context.chain_id, + context.is_l3, header, None, context.config.versioned_constants_map, From c9930d53f78454dcb8c0c5a72ffacd42d4218ad3 Mon Sep 17 00:00:00 2001 From: Mehul Chauhan Date: Tue, 4 Nov 2025 19:39:07 +0530 Subject: [PATCH 05/10] fix l3 parsing part --- crates/gateway-types/src/reply.rs | 8 +-- crates/pathfinder/src/bin/pathfinder/main.rs | 22 +++++- crates/rpc/src/context.rs | 2 +- crates/serde/src/lib.rs | 73 +++++++++++++++++++- 4 files changed, 97 insertions(+), 8 deletions(-) diff --git a/crates/gateway-types/src/reply.rs b/crates/gateway-types/src/reply.rs index 9ca648a7c2..95c080177d 100644 --- a/crates/gateway-types/src/reply.rs +++ b/crates/gateway-types/src/reply.rs @@ -1,7 +1,7 @@ //! Structures used for deserializing replies from Starkware's sequencer REST //! API. -use pathfinder_common::prelude::*; -use pathfinder_serde::{EthereumAddressAsHexStr, GasPriceAsHexStr}; +use pathfinder_common::{SettlementLayerAddress, prelude::*}; +use pathfinder_serde::{GasPriceAsHexStr, SettlementLayerAddressAsHexStr}; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DisplayFromStr}; pub use transaction::DataAvailabilityMode; @@ -2220,8 +2220,8 @@ pub mod state_update { #[derive(Clone, Debug, Deserialize)] pub struct EthContractAddresses { #[serde(rename = "Starknet")] - #[serde_as(as = "EthereumAddressAsHexStr")] - pub starknet: EthereumAddress, + #[serde_as(as = "SettlementLayerAddressAsHexStr")] + pub starknet: SettlementLayerAddress, pub strk_l2_token_address: Option, diff --git a/crates/pathfinder/src/bin/pathfinder/main.rs b/crates/pathfinder/src/bin/pathfinder/main.rs index 8181684e0b..d94c1aaa07 100644 --- a/crates/pathfinder/src/bin/pathfinder/main.rs +++ b/crates/pathfinder/src/bin/pathfinder/main.rs @@ -749,7 +749,7 @@ mod pathfinder_context { use std::time::Duration; use anyhow::Context; - use pathfinder_common::{Chain, ChainId}; + use pathfinder_common::{Chain, ChainId, SettlementLayerAddress}; use pathfinder_ethereum::core_addr; use pathfinder_rpc::context::EthContractAddresses; use reqwest::Url; @@ -842,8 +842,26 @@ mod pathfinder_context { .await .context("Downloading starknet L1 address from gateway for proxy check")?; + let l1_core_address = if is_l3 { + // For L3 networks, assert we got Starknet variant (ContractAddress) + match reply_contract_addresses.starknet { + SettlementLayerAddress::Starknet(_contract_address) => { + primitive_types::H160::zero() + } + SettlementLayerAddress::Ethereum(_) => { + anyhow::bail!("L3 networks should have ContractAddress (Starknet variant) in starknet field, but got EthereumAddress (Ethereum variant)"); + } + } + } else { + // For L2 networks, assert we got Ethereum variant (EthereumAddress) + match reply_contract_addresses.starknet { + SettlementLayerAddress::Starknet(_) => { + anyhow::bail!("L2 networks should have EthereumAddress (Ethereum variant) in starknet field, but got ContractAddress (Starknet variant)"); + } + SettlementLayerAddress::Ethereum(address) => address.0, + } + }; - let l1_core_address = reply_contract_addresses.starknet.0; let contract_addresses = EthContractAddresses::new_custom( l1_core_address, reply_contract_addresses.eth_l2_token_address, diff --git a/crates/rpc/src/context.rs b/crates/rpc/src/context.rs index 53caa03c00..fa5acd4945 100644 --- a/crates/rpc/src/context.rs +++ b/crates/rpc/src/context.rs @@ -1,7 +1,7 @@ use std::num::{NonZeroU64, NonZeroUsize}; use std::sync::Arc; -use pathfinder_common::{contract_address, ChainId, ConsensusInfo, ContractAddress}; +use pathfinder_common::{ChainId, ConsensusInfo, ContractAddress, EthereumAddress, SettlementLayerAddress, contract_address}; use pathfinder_ethereum::EthereumClient; use pathfinder_executor::{NativeClassCache, TraceCache, VersionedConstantsMap}; use pathfinder_storage::Storage; diff --git a/crates/serde/src/lib.rs b/crates/serde/src/lib.rs index fd063d98a3..8b72054558 100644 --- a/crates/serde/src/lib.rs +++ b/crates/serde/src/lib.rs @@ -5,7 +5,7 @@ use std::borrow::Cow; use std::str::FromStr; use num_bigint::BigUint; -use pathfinder_common::prelude::*; +use pathfinder_common::{SettlementLayerAddress, prelude::*}; use pathfinder_crypto::{Felt, HexParseError, OverflowError}; use primitive_types::{H160, H256, U256}; use serde::de::Visitor; @@ -88,6 +88,77 @@ impl<'de> DeserializeAs<'de, EthereumAddress> for EthereumAddressAsHexStr { } } +pub struct SettlementLayerAddressAsHexStr; + +impl SerializeAs for SettlementLayerAddressAsHexStr { + fn serialize_as(source: &SettlementLayerAddress, serializer: S) -> Result + where + S: serde::Serializer { + match source { + SettlementLayerAddress::Ethereum(address) => { + EthereumAddressAsHexStr::serialize_as(address, serializer) + }, + SettlementLayerAddress::Starknet(address) => { + // ContractAddress is a Felt, serialize as 64-char hex string + let bytes = address.0.to_be_bytes(); + // ContractAddress is "0x" + 64 digits + let mut buf = [0u8; 2 + 64]; + let s = bytes_as_hex_str(&bytes, &mut buf); + serializer.serialize_str(s) + } + } + } +} + +impl<'de> DeserializeAs<'de, SettlementLayerAddress> for SettlementLayerAddressAsHexStr { + fn deserialize_as(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct SettlementLayerAddressVisitor; + + impl Visitor<'_> for SettlementLayerAddressVisitor { + type Value = SettlementLayerAddress; + + fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str("a hex string of 40 digits (Ethereum) or 41-64 digits (Starknet) with an optional '0x' prefix") + } + + fn visit_str(self, v: &str) -> Result + where + E: serde::de::Error, + { + + let hex_str = v.strip_prefix("0x").unwrap_or(v); + let hex_len = hex_str.len(); + + if hex_len <= 40 { + // Ethereum address: 20 bytes = 40 hex digits + let bytes = bytes_from_hex_str::<{ H160::len_bytes() }>(hex_str) + .map_err(serde::de::Error::custom)?; + Ok(SettlementLayerAddress::Ethereum(EthereumAddress(H160::from(bytes)))) + } else if hex_len <= 64 { + // Starknet ContractAddress: 32 bytes = 64 hex digits + let bytes = bytes_from_hex_str::<32>(hex_str) + .map_err(serde::de::Error::custom)?; + let felt = Felt::from_be_bytes(bytes) + .map_err(|e| serde::de::Error::custom(format!("Felt overflow: {}", e)))?; + Ok(SettlementLayerAddress::Starknet(ContractAddress(felt))) + } else { + Err(serde::de::Error::custom(format!( + "hex string too long: expected at most 64 digits (with optional '0x' prefix), got {}", + hex_len + ))) + } + } + } + + deserializer.deserialize_str(SettlementLayerAddressVisitor) + } +} + + + pub struct H256AsNoLeadingZerosHexStr; impl SerializeAs for H256AsNoLeadingZerosHexStr { From 539604d1fe32922eab36049ff0cf8d519d43466f Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Thu, 6 Nov 2025 23:12:57 +0530 Subject: [PATCH 06/10] dynamic charge fee check --- crates/rpc/src/executor.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/crates/rpc/src/executor.rs b/crates/rpc/src/executor.rs index 873b94f7ea..1b7156c7c0 100644 --- a/crates/rpc/src/executor.rs +++ b/crates/rpc/src/executor.rs @@ -5,12 +5,10 @@ use pathfinder_executor::types::to_starknet_api_transaction; use pathfinder_executor::{ClassInfo, IntoStarkFelt}; use starknet_api::contract_class::SierraVersion; use starknet_api::core::PatriciaKey; -use starknet_api::transaction::fields::Fee; +use starknet_api::transaction::fields::{Fee, ValidResourceBounds}; use crate::types::request::{ - BroadcastedDeployAccountTransaction, - BroadcastedInvokeTransaction, - BroadcastedTransaction, + BroadcastedDeployAccountTransaction, BroadcastedInvokeTransaction, BroadcastedTransaction, }; pub enum ExecutionStateError { @@ -359,6 +357,21 @@ pub fn compose_executor_transaction( tracing::trace!(%tx_hash, "Converting transaction"); let transaction = to_starknet_api_transaction(transaction.variant.clone())?; + let mut charge_fee = true; + if let Some(resource_bounds) = transaction.resource_bounds() { + match resource_bounds { + ValidResourceBounds::AllResources(all_resources) => { + if all_resources.l2_gas.max_amount.0 == 0 { + charge_fee = false; + } + } + ValidResourceBounds::L1Gas(l1_gas) => { + if l1_gas.max_amount.0 == 0 { + charge_fee = false; + } + } + } + } let tx = pathfinder_executor::Transaction::from_api( transaction, @@ -366,7 +379,12 @@ pub fn compose_executor_transaction( class_info, paid_fee_on_l1, deployed_address, - pathfinder_executor::AccountTransactionExecutionFlags{ only_query: false, charge_fee: false, validate: true, strict_nonce_check: true }, + pathfinder_executor::AccountTransactionExecutionFlags { + only_query: false, + charge_fee, + validate: true, + strict_nonce_check: true, + }, )?; Ok(tx) From f58abfe7b2364e87575ec1a9a9e9725da12a00a1 Mon Sep 17 00:00:00 2001 From: apoorvsadana <95699312+apoorvsadana@users.noreply.github.com> Date: Fri, 7 Nov 2025 01:10:16 +0530 Subject: [PATCH 07/10] fixes --- crates/rpc/src/executor.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/rpc/src/executor.rs b/crates/rpc/src/executor.rs index 1b7156c7c0..a58b395739 100644 --- a/crates/rpc/src/executor.rs +++ b/crates/rpc/src/executor.rs @@ -1,6 +1,7 @@ use anyhow::Context; use pathfinder_common::transaction::TransactionVariant; -use pathfinder_common::{BlockNumber, ChainId, StarknetVersion}; +use pathfinder_common::{BlockNumber, ChainId, StarknetVersion, TransactionVersion}; +use pathfinder_crypto::Felt; use pathfinder_executor::types::to_starknet_api_transaction; use pathfinder_executor::{ClassInfo, IntoStarkFelt}; use starknet_api::contract_class::SierraVersion; @@ -358,7 +359,10 @@ pub fn compose_executor_transaction( let transaction = to_starknet_api_transaction(transaction.variant.clone())?; let mut charge_fee = true; - if let Some(resource_bounds) = transaction.resource_bounds() { + if transaction.version().0 == starknet_types_core::felt::Felt::ZERO { + // Only used during bootstrapper v1 bootstrapping + charge_fee = false; + } else if let Some(resource_bounds) = transaction.resource_bounds() { match resource_bounds { ValidResourceBounds::AllResources(all_resources) => { if all_resources.l2_gas.max_amount.0 == 0 { From b357434511bc87f80f36fbc6bec500e6d4631436 Mon Sep 17 00:00:00 2001 From: byteZorvin Date: Fri, 14 Nov 2025 16:03:01 +0530 Subject: [PATCH 08/10] fix comments --- crates/pathfinder/src/bin/pathfinder/main.rs | 3 +++ crates/pathfinder/src/config.rs | 3 ++- crates/pathfinder/src/validator.rs | 14 ++------------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/crates/pathfinder/src/bin/pathfinder/main.rs b/crates/pathfinder/src/bin/pathfinder/main.rs index d94c1aaa07..bf12051f6e 100644 --- a/crates/pathfinder/src/bin/pathfinder/main.rs +++ b/crates/pathfinder/src/bin/pathfinder/main.rs @@ -846,6 +846,9 @@ mod pathfinder_context { // For L3 networks, assert we got Starknet variant (ContractAddress) match reply_contract_addresses.starknet { SettlementLayerAddress::Starknet(_contract_address) => { + // TODO(mehul): This is a placeholder return. L1 syncing for L3 networks would + // require significant changes that are not prioritized for pathfinder. + // Returning 0 address as a dummy return primitive_types::H160::zero() } SettlementLayerAddress::Ethereum(_) => { diff --git a/crates/pathfinder/src/config.rs b/crates/pathfinder/src/config.rs index 06167b00fa..06fd1155df 100644 --- a/crates/pathfinder/src/config.rs +++ b/crates/pathfinder/src/config.rs @@ -567,7 +567,8 @@ Note that 'custom' requires also setting the --gateway-url and --feeder-gateway- long = "is-l3", long_help = "Set if the network is an L3 network", env = "PATHFINDER_IS_L3", - required_if_eq("network", Network::Custom) + required_if_eq("network", Network::Custom), + default_value = "false" )] is_l3: Option, diff --git a/crates/pathfinder/src/validator.rs b/crates/pathfinder/src/validator.rs index ccf121b191..b867feae35 100644 --- a/crates/pathfinder/src/validator.rs +++ b/crates/pathfinder/src/validator.rs @@ -46,21 +46,11 @@ use crate::state::block_hash::{ calculate_transaction_commitment, }; -/// Determines is_l3 from ChainId. -/// For known networks (Mainnet, Sepolia, SepoliaIntegration), is_l3 is always false. -/// For custom networks, this should be passed explicitly from network config. -fn is_l3_from_chain_id(chain_id: ChainId) -> bool { - match chain_id { - ChainId::MAINNET | ChainId::SEPOLIA_TESTNET | ChainId::SEPOLIA_INTEGRATION => false, - _ => false, // Default to false for unknown/custom networks, should be passed explicitly - } -} - pub fn new( chain_id: ChainId, proposal_init: ProposalInit, ) -> anyhow::Result { - let is_l3 = is_l3_from_chain_id(chain_id); + let is_l3 = false; ValidatorBlockInfoStage::new(chain_id, is_l3, proposal_init) } @@ -278,7 +268,7 @@ impl ValidatorTransactionBatchStage { ) -> anyhow::Result { // For tests and when called directly, determine is_l3 from chain_id // (returns false for known networks, false for custom by default) - let is_l3 = is_l3_from_chain_id(chain_id); + let is_l3 = false; Ok(ValidatorTransactionBatchStage { chain_id, is_l3, From 6e8fb8edae4daa6dd961db6696111fa60396cb02 Mon Sep 17 00:00:00 2001 From: byteZorvin Date: Fri, 14 Nov 2025 23:03:42 +0530 Subject: [PATCH 09/10] Enhance SettlementLayerAddress handling by implementing Dummy trait and updating transaction module to use SettlementLayerAddress for from_address serialization. --- crates/common/src/lib.rs | 13 ++++++++++++- crates/gateway-types/src/reply.rs | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 52986a0283..4eb7565337 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -8,7 +8,7 @@ use std::ops::Rem; use std::str::FromStr; use anyhow::Context; -use fake::Dummy; +use fake::{Dummy, Fake, Faker}; use pathfinder_crypto::hash::HashChain; use pathfinder_crypto::Felt; use primitive_types::H160; @@ -348,6 +348,17 @@ pub enum SettlementLayerAddress { Starknet(ContractAddress), } +impl Dummy for SettlementLayerAddress { + fn dummy_with_rng(_: &T, rng: &mut R) -> Self { + if rng.gen_bool(0.5) { + Self::Ethereum(EthereumAddress(H160::random_using(rng))) + } else { + Self::Starknet(Faker.fake_with_rng(rng)) + } + } +} + + #[derive(Debug, thiserror::Error)] #[error("expected slice length of 16 or less, got {0}")] pub struct FromSliceError(usize); diff --git a/crates/gateway-types/src/reply.rs b/crates/gateway-types/src/reply.rs index 95c080177d..76c5368589 100644 --- a/crates/gateway-types/src/reply.rs +++ b/crates/gateway-types/src/reply.rs @@ -269,12 +269,12 @@ pub mod transaction_status { /// Types used when deserializing L2 transaction related data. pub mod transaction { use fake::{Dummy, Fake, Faker}; - use pathfinder_common::prelude::*; + use pathfinder_common::{SettlementLayerAddress, prelude::*}; use pathfinder_crypto::Felt; use pathfinder_serde::{ CallParamAsDecimalStr, ConstructorParamAsDecimalStr, - EthereumAddressAsHexStr, + SettlementLayerAddressAsHexStr, L1ToL2MessagePayloadElemAsDecimalStr, L2ToL1MessagePayloadElemAsDecimalStr, ResourceAmountAsHexStr, @@ -535,8 +535,8 @@ pub mod transaction { #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] pub struct L1ToL2Message { - #[serde_as(as = "EthereumAddressAsHexStr")] - pub from_address: EthereumAddress, + #[serde_as(as = "SettlementLayerAddressAsHexStr")] + pub from_address: SettlementLayerAddress, #[serde_as(as = "Vec")] pub payload: Vec, pub selector: EntryPoint, From 2f8cd11e7dbee46c33d47ea0a26995f11c6b763f Mon Sep 17 00:00:00 2001 From: Mehul Chauhan Date: Fri, 14 Nov 2025 23:25:04 +0530 Subject: [PATCH 10/10] Update crates/pathfinder/src/bin/pathfinder/main.rs Co-authored-by: Mohit Dhattarwal <48082542+Mohiiit@users.noreply.github.com> --- crates/pathfinder/src/bin/pathfinder/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/pathfinder/src/bin/pathfinder/main.rs b/crates/pathfinder/src/bin/pathfinder/main.rs index bf12051f6e..9f5f3d6757 100644 --- a/crates/pathfinder/src/bin/pathfinder/main.rs +++ b/crates/pathfinder/src/bin/pathfinder/main.rs @@ -846,7 +846,7 @@ mod pathfinder_context { // For L3 networks, assert we got Starknet variant (ContractAddress) match reply_contract_addresses.starknet { SettlementLayerAddress::Starknet(_contract_address) => { - // TODO(mehul): This is a placeholder return. L1 syncing for L3 networks would + // TODO(mehul 14/11/2025): This is a placeholder return. L1 syncing for L3 networks would // require significant changes that are not prioritized for pathfinder. // Returning 0 address as a dummy return primitive_types::H160::zero()