diff --git a/Cargo.lock b/Cargo.lock index 5f86bc10cf3..82be76c2f5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,6 +96,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom 0.2.16", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.12" @@ -2940,7 +2951,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" dependencies = [ - "ahash", + "ahash 0.8.12", "ark-ff 0.5.0", "ark-poly", "ark-serialize 0.5.0", @@ -3087,7 +3098,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" dependencies = [ - "ahash", + "ahash 0.8.12", "ark-ff 0.5.0", "ark-serialize 0.5.0", "ark-std 0.5.0", @@ -4825,7 +4836,7 @@ dependencies = [ [[package]] name = "cairo-program-runner-lib" version = "1.2.2" -source = "git+https://github.com/starkware-libs/proving-utils?rev=1e0f8fc#1e0f8fc5b611a448a8fd38365d9d1a46b1a2591d" +source = "git+https://github.com/starkware-libs/proving-utils?tag=v0.14.3-rc-1#c0b937bb19126255fbeeededbcaea4a84ae9f1c0" dependencies = [ "anyhow", "cairo-lang-casm", @@ -5099,12 +5110,12 @@ dependencies = [ [[package]] name = "circuit-cairo-verifier" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ "cairo-air 1.2.2", - "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "indexmap 2.14.0", "itertools 0.12.1", "num-traits", @@ -5130,14 +5141,12 @@ dependencies = [ [[package]] name = "circuit-common" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "indexmap 2.14.0", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "itertools 0.12.1", "rand_chacha 0.3.1", - "serde", "stwo 2.2.0", "stwo-cairo-common 1.2.2", "stwo-constraint-framework 2.2.0", @@ -5146,12 +5155,12 @@ dependencies = [ [[package]] name = "circuit-prover" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ - "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "circuit-verifier", - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "itertools 0.12.1", "num-traits", "rayon", @@ -5178,21 +5187,21 @@ dependencies = [ [[package]] name = "circuit-serialize" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "stwo 2.2.0", ] [[package]] name = "circuit-verifier" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ - "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "indexmap 2.14.0", "itertools 0.12.1", "num-traits", @@ -5216,7 +5225,7 @@ dependencies = [ [[package]] name = "circuits" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ "blake2", "hashbrown 0.17.1", @@ -5244,13 +5253,14 @@ dependencies = [ [[package]] name = "circuits-stark-verifier" version = "0.1.0" -source = "git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181#c99a181518259c1b3b121c2522371748b9acfa03" +source = "git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a#618db0a21e68fdf91db8b839227bf7258a543cf7" dependencies = [ - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "hashbrown 0.17.1", "indexmap 2.14.0", "itertools 0.12.1", "num-traits", + "serde", "stwo 2.2.0", "stwo-constraint-framework 2.2.0", ] @@ -5337,7 +5347,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -5346,7 +5356,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -6349,7 +6359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -7018,6 +7028,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] [[package]] name = "hashbrown" @@ -7031,8 +7044,7 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash", - "allocator-api2", + "ahash 0.8.12", ] [[package]] @@ -7862,7 +7874,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -8107,7 +8119,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978" dependencies = [ - "ahash", + "ahash 0.8.12", "anyhow", "base64 0.21.7", "bytecount", @@ -9004,7 +9016,7 @@ version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25dea7ac8057892855ec285c440160265225438c3c45072613c25a4b26e98ef5" dependencies = [ - "ahash", + "ahash 0.8.12", "portable-atomic", ] @@ -9143,7 +9155,7 @@ checksum = "7760e0e418d9b7e5777c0374009ca4c93861b9066f18cb334a20ce50ab63aa48" dependencies = [ "assert-json-diff", "bytes", - "colored 3.0.0", + "colored 2.2.0", "futures-util", "http 1.3.1", "http-body 1.0.1", @@ -10458,17 +10470,17 @@ dependencies = [ [[package]] name = "privacy-circuit-verify" version = "1.2.2" -source = "git+https://github.com/starkware-libs/proving-utils?rev=1e0f8fc#1e0f8fc5b611a448a8fd38365d9d1a46b1a2591d" +source = "git+https://github.com/starkware-libs/proving-utils?tag=v0.14.3-rc-1#c0b937bb19126255fbeeededbcaea4a84ae9f1c0" dependencies = [ "anyhow", "cairo-air 1.2.2", "cairo-vm", "circuit-cairo-verifier", - "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuit-serialize 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuit-serialize 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "circuit-verifier", - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "clap", "itertools 0.12.1", "log", @@ -10488,19 +10500,19 @@ dependencies = [ [[package]] name = "privacy-prove" version = "1.2.2" -source = "git+https://github.com/starkware-libs/proving-utils?rev=1e0f8fc#1e0f8fc5b611a448a8fd38365d9d1a46b1a2591d" +source = "git+https://github.com/starkware-libs/proving-utils?tag=v0.14.3-rc-1#c0b937bb19126255fbeeededbcaea4a84ae9f1c0" dependencies = [ "anyhow", "cairo-air 1.2.2", "cairo-program-runner-lib", "cairo-vm", "circuit-cairo-verifier", - "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuit-common 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "circuit-prover", - "circuit-serialize 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuit-serialize 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "circuit-verifier", - "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", - "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=c99a181)", + "circuits 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", + "circuits-stark-verifier 0.1.0 (git+https://github.com/starkware-libs/stwo-circuits?rev=618db0a)", "clap", "itertools 0.12.1", "log", @@ -10720,12 +10732,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38" dependencies = [ "cfg-if", - "hashbrown 0.14.5", + "hashbrown 0.12.3", "indoc 1.0.9", "libc", "memoffset 0.9.1", "num-bigint", - "parking_lot 0.12.5", + "parking_lot 0.11.2", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", @@ -10882,7 +10894,7 @@ dependencies = [ "once_cell", "socket2 0.6.1", "tracing", - "windows-sys 0.60.2", + "windows-sys 0.52.0", ] [[package]] @@ -11636,7 +11648,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -11695,7 +11707,7 @@ dependencies = [ "security-framework 3.5.1", "security-framework-sys", "webpki-root-certs 0.26.11", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -13631,7 +13643,7 @@ dependencies = [ "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -14874,7 +14886,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 58484b87a94..439f1bd683f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -335,8 +335,8 @@ phf = "0.11" pretty_assertions = "1.4.0" primitive-types = "0.12.1" privacy-circuit-verify-v0 = { package = "privacy-circuit-verify", git = "https://github.com/starkware-libs/proving-utils", rev = "580135e" } -privacy-circuit-verify-v1 = { package = "privacy-circuit-verify", git = "https://github.com/starkware-libs/proving-utils", rev = "1e0f8fc" } -privacy-prove = { git = "https://github.com/starkware-libs/proving-utils", rev = "1e0f8fc" } +privacy-circuit-verify-v1 = { package = "privacy-circuit-verify", git = "https://github.com/starkware-libs/proving-utils", tag = "v0.14.3-rc-1" } +privacy-prove = { git = "https://github.com/starkware-libs/proving-utils", tag = "v0.14.3-rc-1" } proc-macro2 = "1.0" prometheus-parse = "0.2.4" prost = "0.12.1" diff --git a/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/mod.rs b/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/mod.rs index ed733ec046f..d376ad4230c 100644 --- a/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/mod.rs +++ b/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/mod.rs @@ -5,7 +5,7 @@ //! - `compute_fee_actual`: the base fee for this block, calculated as the median of the most recent //! `fee_proposal` values across `window_size` blocks. //! - `compute_fee_target`: the fee we'd *like* for this block, derived from the STRK/USD oracle -//! quote and a fixed USD-cost target. +//! quote and a configurable USD-cost target. //! - `compute_fee_proposal`: the target, clamped within a fixed multiplicative margin of //! `fee_actual` (so a proposer cannot move the fee too far per round). //! @@ -44,10 +44,6 @@ const FRI_DECIMALS_SCALE: u128 = 10u128.pow(18); /// Denominator for parts-per-thousand calculations in fee_proposal bounds. pub(crate) const PPT_DENOMINATOR: u128 = 1000; -/// Target USD cost per L2 gas unit in atto-USD ($3e-9 = 3_000_000_000 atto-USD). -// TODO(AndrewL): consider moving this to a dynamic config. -pub(crate) const TARGET_ATTO_USD_PER_L2_GAS: u128 = 3_000_000_000; - /// Compute fee_actual for `height` as the median of the `fee_proposal` values /// recorded for heights `[height - window_size, height - 1]`. /// diff --git a/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/test.rs b/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/test.rs index efcaac491f0..10829e2ada4 100644 --- a/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/test.rs +++ b/crates/apollo_consensus_orchestrator/src/dynamic_gas_price/test.rs @@ -1,5 +1,6 @@ use std::collections::BTreeMap; +use apollo_consensus_orchestrator_config::config::DEFAULT_SNIP35_TARGET_ATTO_USD_PER_L2_GAS; use apollo_versioned_constants::VersionedConstants; use rand::{RngExt, SeedableRng}; use rand_chacha::ChaCha8Rng; @@ -13,7 +14,6 @@ use crate::dynamic_gas_price::{ compute_fee_target, FeeProposalInfo, PPT_DENOMINATOR, - TARGET_ATTO_USD_PER_L2_GAS, }; const TEST_FEE_PROPOSAL_WINDOW_SIZE: u64 = 10; @@ -228,7 +228,7 @@ fn test_honest_proposer_always_passes_validation_fuzzed() { let fee_actual_value = rng.random_range(1u128..1_000_000_000_000_000_000); let strk_usd_rate = rng.random_range(1u128..2 * 10u128.pow(18)); let fee_actual = GasPrice(fee_actual_value); - let target = compute_fee_target(TARGET_ATTO_USD_PER_L2_GAS, strk_usd_rate); + let target = compute_fee_target(DEFAULT_SNIP35_TARGET_ATTO_USD_PER_L2_GAS, strk_usd_rate); let oracle_result = if rng.random_bool(0.1) { None } else { target }; let proposal = compute_fee_proposal(oracle_result, fee_actual, margin_ppt); assert!( diff --git a/crates/apollo_consensus_orchestrator/src/metrics.rs b/crates/apollo_consensus_orchestrator/src/metrics.rs index 3e379349f9b..fbae60d2ed7 100644 --- a/crates/apollo_consensus_orchestrator/src/metrics.rs +++ b/crates/apollo_consensus_orchestrator/src/metrics.rs @@ -35,9 +35,10 @@ define_metrics!( // SNIP-35 dynamic gas pricing metrics. // STRK/USD rate metrics are in `apollo_l1_gas_price`. - MetricGauge { SNIP35_FEE_ACTUAL, "snip35_fee_actual", "The current fee_actual (median of recent fee_proposals sliding window)" }, - MetricGauge { SNIP35_FEE_PROPOSAL, "snip35_fee_proposal", "The fee_proposal this node published in the latest block" }, - MetricGauge { SNIP35_FEE_TARGET, "snip35_fee_target", "The fee_target computed from the STRK/USD oracle" }, + MetricGauge { SNIP35_FEE_ACTUAL_FRI, "snip35_fee_actual_fri", "The current fee_actual (median of recent fee_proposals sliding window), in Fri" }, + MetricGauge { SNIP35_FEE_PROPOSAL_FRI, "snip35_fee_proposal_fri", "The fee_proposal this node published in the latest block, in Fri" }, + MetricGauge { SNIP35_FEE_TARGET_FRI, "snip35_fee_target_fri", "The fee_target computed from the STRK/USD oracle, in Fri" }, + MetricGauge { SNIP35_FEE_TARGET_ATTO_USD, "snip35_fee_target_atto_usd", "Configured target USD cost per L2 gas unit, in atto-USD" }, } ); @@ -106,7 +107,8 @@ pub(crate) fn register_metrics() { CONSENSUS_BUILD_PROPOSAL_FAILURE.register(); CONSENSUS_VALIDATE_PROPOSAL_FAILURE.register(); CONSENSUS_PROOF_MANAGER_STORE_LATENCY.register(); - SNIP35_FEE_ACTUAL.register(); - SNIP35_FEE_PROPOSAL.register(); - SNIP35_FEE_TARGET.register(); + SNIP35_FEE_ACTUAL_FRI.register(); + SNIP35_FEE_PROPOSAL_FRI.register(); + SNIP35_FEE_TARGET_FRI.register(); + SNIP35_FEE_TARGET_ATTO_USD.register(); } diff --git a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs index 7b8470614b7..3034c8457a5 100644 --- a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -90,7 +90,6 @@ use crate::dynamic_gas_price::{ compute_fee_target, proposal_commitment_from, FeeProposalInfo, - TARGET_ATTO_USD_PER_L2_GAS, }; use crate::fee_market::{ calculate_next_l2_gas_price_for_fin, @@ -102,9 +101,10 @@ use crate::metrics::{ record_validate_proposal_failure, register_metrics, CONSENSUS_L2_GAS_PRICE, - SNIP35_FEE_ACTUAL, - SNIP35_FEE_PROPOSAL, - SNIP35_FEE_TARGET, + SNIP35_FEE_ACTUAL_FRI, + SNIP35_FEE_PROPOSAL_FRI, + SNIP35_FEE_TARGET_ATTO_USD, + SNIP35_FEE_TARGET_FRI, }; use crate::utils::{ convert_to_sn_api_block_info, @@ -438,27 +438,20 @@ impl SequencerConsensusContext { ) } - /// Compute the proposer's fee_proposal: clamp the oracle's `fee_target` to a margin around - /// `fee_actual`. When `fee_actual` is `None` (window incomplete), freeze at `l2_gas_price`; the - /// validator derives the same fallback so both sides agree. - async fn compute_proposer_fee_proposal( + async fn resolve_fee_target( &self, - fee_actual: Option, timestamp: u64, - ) -> GasPrice { - let Some(fee_actual) = fee_actual else { - warn!("fee_actual unavailable, freezing fee_proposal at l2_gas_price"); - SNIP35_FEE_PROPOSAL.set_lossy(self.l2_gas_price.0); - return self.l2_gas_price; - }; - SNIP35_FEE_ACTUAL.set_lossy(fee_actual.0); - - let fee_target = match self.deps.l1_gas_price_provider.get_strk_to_usd_rate(timestamp).await - { + target_atto_usd_per_l2_gas: u128, + ) -> Option { + if let Some(v) = self.config.dynamic_config.override_l2_gas_price_fri { + SNIP35_FEE_TARGET_FRI.set_lossy(v); + return Some(GasPrice(v)); + } + match self.deps.l1_gas_price_provider.get_strk_to_usd_rate(timestamp).await { Ok(rate) => { - let target = compute_fee_target(TARGET_ATTO_USD_PER_L2_GAS, rate); + let target = compute_fee_target(target_atto_usd_per_l2_gas, rate); match target { - Some(t) => SNIP35_FEE_TARGET.set_lossy(t.0), + Some(t) => SNIP35_FEE_TARGET_FRI.set_lossy(t.0), None => warn!("STRK/USD oracle returned zero rate, freezing fee_proposal"), } target @@ -467,14 +460,34 @@ impl SequencerConsensusContext { warn!("STRK/USD oracle error: {e:?}, freezing fee_proposal"); None } + } + } + + /// Compute the proposer's fee_proposal: clamp the oracle's `fee_target` to a margin around + /// `fee_actual`. When `fee_actual` is `None` (window incomplete), freeze at `l2_gas_price`; the + /// validator derives the same fallback so both sides agree. + async fn compute_proposer_fee_proposal( + &self, + fee_actual: Option, + timestamp: u64, + target_atto_usd_per_l2_gas: u128, + ) -> GasPrice { + SNIP35_FEE_TARGET_ATTO_USD.set_lossy(target_atto_usd_per_l2_gas); + let Some(fee_actual) = fee_actual else { + warn!("fee_actual unavailable, freezing fee_proposal at l2_gas_price"); + SNIP35_FEE_PROPOSAL_FRI.set_lossy(self.l2_gas_price.0); + return self.l2_gas_price; }; + SNIP35_FEE_ACTUAL_FRI.set_lossy(fee_actual.0); + + let fee_target = self.resolve_fee_target(timestamp, target_atto_usd_per_l2_gas).await; let proposal = compute_fee_proposal( fee_target, fee_actual, VersionedConstants::latest_constants().fee_proposal_margin_ppt, ); - SNIP35_FEE_PROPOSAL.set_lossy(proposal.0); + SNIP35_FEE_PROPOSAL_FRI.set_lossy(proposal.0); proposal } @@ -563,6 +576,15 @@ impl SequencerConsensusContext { self.wait_for_block_hash(height).await; } + // The parent block's `fee_proposal_fri` is needed to reconstruct its V0_14_3 commitment + // (`Poseidon(partial_block_hash, fee_proposal_fri)`). It is read from the in-memory + // `fee_proposals_window`, which mirrors `BlockHeaderWithoutHash` storage. `None` means the + // parent is pre-V0_14_3 (or, near genesis, is absent from the window). + let parent_fee_proposal = height + .prev() + .and_then(|parent_height| self.fee_proposals_window.get(&parent_height).copied()) + .flatten(); + if let Err(e) = self .deps .cende_ambassador @@ -588,13 +610,9 @@ impl SequencerConsensusContext { compiled_class_hashes_for_migration: central_objects .compiled_class_hashes_for_migration, proposal_commitment: commitment, - // TODO(AndrewL): plumb the parent block's `fee_proposal_fri` here once - // `central_objects.parent_proposal_commitment` carries it (or read from - // BlockHeaderWithoutHash storage). Today we pass `None`, which means - // pre-V0_14_3 commitments — correct for pre-V0_14_3 deployments only. parent_proposal_commitment: central_objects .parent_proposal_commitment - .map(|c| proposal_commitment_from(c.partial_block_hash, None)), + .map(|c| proposal_commitment_from(c.partial_block_hash, parent_fee_proposal)), recent_block_hashes: self.collect_recent_block_hashes(height).await, }) .await @@ -723,8 +741,13 @@ impl ConsensusContext for SequencerConsensusContext { build_param.height, VersionedConstants::latest_constants().fee_proposal_window_size, ); - let fee_proposal = - self.compute_proposer_fee_proposal(fee_actual, self.deps.clock.unix_now()).await; + let fee_proposal = self + .compute_proposer_fee_proposal( + fee_actual, + self.deps.clock.unix_now(), + self.config.dynamic_config.snip35_target_atto_usd_per_l2_gas, + ) + .await; let round = build_param.round; let args = ProposalBuildArguments { deps: self.deps.clone(), diff --git a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs index 92fe42ae8c3..b1743ab4782 100644 --- a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs +++ b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs @@ -107,6 +107,7 @@ const HEIGHT_1: BlockNumber = BlockNumber(1); // Use heights < 10 to avoid triggering the height-10 block-hash mapping code path (not tested // here). Use non-zero height because height 0 always skips the write without querying the recorder. const HEIGHT_FOR_WRITE_TESTS: BlockNumber = BlockNumber(8); +const TARGET_ATTO_USD_PER_L2_GAS: u128 = 3_000_000_000; const ROUND_0: Round = 0; const ROUND_1: Round = 1; @@ -1685,7 +1686,8 @@ async fn test_compute_proposer_fee_proposal( let mut context = deps.build_context(); context.l2_gas_price = l2_gas_price; - let proposal = context.compute_proposer_fee_proposal(fee_actual, 0).await; + let proposal = + context.compute_proposer_fee_proposal(fee_actual, 0, TARGET_ATTO_USD_PER_L2_GAS).await; assert_eq!(proposal, expected_fee_proposal); } @@ -1725,7 +1727,9 @@ async fn test_compute_proposer_fee_proposal_converges_to_oracle_target() { let h = BlockNumber(height); let fee_actual = compute_fee_actual(&context.fee_proposals_window, h, window_size) .expect("window stays complete across the loop"); - let proposal = context.compute_proposer_fee_proposal(Some(fee_actual), 0).await; + let proposal = context + .compute_proposer_fee_proposal(Some(fee_actual), 0, TARGET_ATTO_USD_PER_L2_GAS) + .await; context.record_fee_proposal(h, Some(proposal)); height += 1; } diff --git a/crates/apollo_consensus_orchestrator_config/src/config.rs b/crates/apollo_consensus_orchestrator_config/src/config.rs index 0cbe2f948c0..1b5d63ec2c1 100644 --- a/crates/apollo_consensus_orchestrator_config/src/config.rs +++ b/crates/apollo_consensus_orchestrator_config/src/config.rs @@ -82,6 +82,9 @@ impl SerializeConfig for CendeConfig { const GWEI_FACTOR: u128 = u128::pow(10, 9); const ETH_FACTOR: u128 = u128::pow(10, 18); +// Default SNIP-35 target USD cost per L2 gas unit: $0.88 per 1e9 L2 gas = 880_000_000 atto-USD. +pub const DEFAULT_SNIP35_TARGET_ATTO_USD_PER_L2_GAS: u128 = 880_000_000; + // This matches the min_gas_price in orchestrator_versioned_constants_0_14_1.json (0x1dcd65000). const MIN_ALLOWED_GAS_PRICE: u128 = 8_000_000_000; @@ -284,6 +287,9 @@ pub struct ContextDynamicConfig { pub l1_data_gas_price_multiplier_ppt: u128, /// This additional gas is added to the L1 gas price. pub l1_gas_tip_wei: u128, + /// SNIP-35 target USD cost per L2 gas unit, in atto-USD ($0.88 per 1e9 L2 gas = 880_000_000 + /// atto-USD). + pub snip35_target_atto_usd_per_l2_gas: u128, /// If given, will override the L2 gas price. pub override_l2_gas_price_fri: Option, /// If given, will override the L1 gas price in FRI. @@ -350,6 +356,13 @@ impl SerializeConfig for ContextDynamicConfig { "This additional gas is added to the L1 gas price.", ParamPrivacyInput::Public, ), + ser_param( + "snip35_target_atto_usd_per_l2_gas", + &self.snip35_target_atto_usd_per_l2_gas, + "SNIP-35 target USD cost per L2 gas unit, in atto-USD ($0.88 per 1e9 L2 gas = \ + 880_000_000 atto-USD).", + ParamPrivacyInput::Public, + ), ser_param( "compare_retrospective_block_hash", &self.compare_retrospective_block_hash, @@ -413,6 +426,7 @@ impl Default for ContextDynamicConfig { max_l1_data_gas_price_wei: ETH_FACTOR, l1_data_gas_price_multiplier_ppt: 135, l1_gas_tip_wei: GWEI_FACTOR, + snip35_target_atto_usd_per_l2_gas: DEFAULT_SNIP35_TARGET_ATTO_USD_PER_L2_GAS, override_l2_gas_price_fri: None, override_l1_gas_price_fri: None, override_l1_data_gas_price_fri: None, diff --git a/crates/apollo_dashboard/resources/dev_grafana.json b/crates/apollo_dashboard/resources/dev_grafana.json index 9300ca7ae62..bc609c1023c 100644 --- a/crates/apollo_dashboard/resources/dev_grafana.json +++ b/crates/apollo_dashboard/resources/dev_grafana.json @@ -402,7 +402,7 @@ "description": "Median of recent fee_proposals over the sliding window, in GFri", "type": "timeseries", "exprs": [ - "snip35_fee_actual{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" + "snip35_fee_actual_fri{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" ], "extra_params": {} }, @@ -411,7 +411,7 @@ "description": "fee_proposal this node published in the latest block, in GFri", "type": "timeseries", "exprs": [ - "snip35_fee_proposal{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" + "snip35_fee_proposal_fri{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" ], "extra_params": {} }, @@ -420,7 +420,16 @@ "description": "fee_target computed from the STRK/USD oracle, in GFri", "type": "timeseries", "exprs": [ - "snip35_fee_target{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" + "snip35_fee_target_fri{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" + ], + "extra_params": {} + }, + { + "title": "Fee Target (USD per 1B L2 gas)", + "description": "Configured target USD cost per 1 billion L2 gas units (raw metric is atto-USD per L2 gas; atto-USD / 1e9 = USD per 1B L2 gas)", + "type": "timeseries", + "exprs": [ + "snip35_fee_target_atto_usd{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"} / 1e9" ], "extra_params": {} }, @@ -1589,6 +1598,15 @@ ], "extra_params": {} }, + { + "title": "L1 Handler Tx Scrape Rate (per minute)", + "description": "Number of unique L1 handler transactions scraped from L1 over the last 1m window", + "type": "timeseries", + "exprs": [ + "increase(l1_message_scraper_l1_handler_tx_count{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\"}[1m])" + ], + "extra_params": {} + }, { "title": "L1 Message Scraper Success Count", "description": "The increase in the number of times the L1 message scraper successfully scraped messages (10m window)", diff --git a/crates/apollo_dashboard/src/panels/consensus.rs b/crates/apollo_dashboard/src/panels/consensus.rs index bc1ffac5880..b1b6cc18278 100644 --- a/crates/apollo_dashboard/src/panels/consensus.rs +++ b/crates/apollo_dashboard/src/panels/consensus.rs @@ -56,9 +56,10 @@ use apollo_consensus_orchestrator::metrics::{ LABEL_BUILD_PROPOSAL_FAILURE_REASON, LABEL_CENDE_FAILURE_REASON, LABEL_VALIDATE_PROPOSAL_FAILURE_REASON, - SNIP35_FEE_ACTUAL, - SNIP35_FEE_PROPOSAL, - SNIP35_FEE_TARGET, + SNIP35_FEE_ACTUAL_FRI, + SNIP35_FEE_PROPOSAL_FRI, + SNIP35_FEE_TARGET_ATTO_USD, + SNIP35_FEE_TARGET_FRI, }; use apollo_l1_gas_price::metrics::{ SNIP35_STRK_USD_ERROR_COUNT, @@ -725,7 +726,7 @@ fn get_panel_snip35_fee_actual() -> Panel { Panel::new( "Fee Actual (GFri)", "Median of recent fee_proposals over the sliding window, in GFri", - format!("{} / 1e9", SNIP35_FEE_ACTUAL.get_name_with_filter()), + format!("{} / 1e9", SNIP35_FEE_ACTUAL_FRI.get_name_with_filter()), PanelType::TimeSeries, ) } @@ -734,7 +735,7 @@ fn get_panel_snip35_fee_proposal() -> Panel { Panel::new( "Fee Proposal (GFri)", "fee_proposal this node published in the latest block, in GFri", - format!("{} / 1e9", SNIP35_FEE_PROPOSAL.get_name_with_filter()), + format!("{} / 1e9", SNIP35_FEE_PROPOSAL_FRI.get_name_with_filter()), PanelType::TimeSeries, ) } @@ -743,7 +744,17 @@ fn get_panel_snip35_fee_target() -> Panel { Panel::new( "Fee Target (GFri)", "fee_target computed from the STRK/USD oracle, in GFri", - format!("{} / 1e9", SNIP35_FEE_TARGET.get_name_with_filter()), + format!("{} / 1e9", SNIP35_FEE_TARGET_FRI.get_name_with_filter()), + PanelType::TimeSeries, + ) +} + +fn get_panel_snip35_fee_target_atto_usd() -> Panel { + Panel::new( + "Fee Target (USD per 1B L2 gas)", + "Configured target USD cost per 1 billion L2 gas units (raw metric is atto-USD per L2 \ + gas; atto-USD / 1e9 = USD per 1B L2 gas)", + format!("{} / 1e9", SNIP35_FEE_TARGET_ATTO_USD.get_name_with_filter()), PanelType::TimeSeries, ) } @@ -799,6 +810,7 @@ pub(crate) fn get_snip35_row() -> Row { get_panel_snip35_fee_actual(), get_panel_snip35_fee_proposal(), get_panel_snip35_fee_target(), + get_panel_snip35_fee_target_atto_usd(), get_panel_snip35_strk_usd_rate(), get_panel_snip35_strk_usd_success_count(), get_panel_snip35_strk_usd_error_count(), diff --git a/crates/apollo_dashboard/src/panels/l1_events.rs b/crates/apollo_dashboard/src/panels/l1_events.rs index 1ce5a4434a1..7780507d9a3 100644 --- a/crates/apollo_dashboard/src/panels/l1_events.rs +++ b/crates/apollo_dashboard/src/panels/l1_events.rs @@ -1,6 +1,7 @@ use apollo_l1_events::metrics::{ L1_MESSAGE_PROVIDER_NUM_PENDING_TXS, L1_MESSAGE_SCRAPER_BASELAYER_ERROR_COUNT, + L1_MESSAGE_SCRAPER_L1_HANDLER_TX_COUNT, L1_MESSAGE_SCRAPER_LAST_SUCCESS_TIMESTAMP_SECONDS, L1_MESSAGE_SCRAPER_LATEST_SCRAPED_BLOCK, L1_MESSAGE_SCRAPER_REORG_DETECTED, @@ -49,6 +50,14 @@ fn get_panel_l1_message_scraper_latest_scraped_block() -> Panel { fn get_panel_l1_events_num_pending_txs() -> Panel { Panel::from_gauge(&L1_MESSAGE_PROVIDER_NUM_PENDING_TXS, PanelType::TimeSeries) } +fn get_panel_l1_message_scraper_l1_handler_tx_rate() -> Panel { + Panel::new( + "L1 Handler Tx Scrape Rate (per minute)", + "Number of unique L1 handler transactions scraped from L1 over the last 1m window", + increase(&L1_MESSAGE_SCRAPER_L1_HANDLER_TX_COUNT, "1m"), + PanelType::TimeSeries, + ) +} fn get_panel_l1_message_scraper_seconds_since_last_successful_scrape() -> Panel { Panel::new( @@ -70,6 +79,7 @@ pub(crate) fn get_l1_events_row() -> Row { get_panel_l1_message_scraper_seconds_since_last_successful_scrape(), get_panel_l1_message_scraper_latest_scraped_block(), get_panel_l1_events_num_pending_txs(), + get_panel_l1_message_scraper_l1_handler_tx_rate(), get_panel_l1_message_scraper_success_count(), get_panel_l1_message_scraper_baselayer_error_count(), get_panel_l1_message_scraper_reorg_detected(), diff --git a/crates/apollo_deployments/resources/app_configs/consensus_manager_config.json b/crates/apollo_deployments/resources/app_configs/consensus_manager_config.json index b565e824236..16d336e489b 100644 --- a/crates/apollo_deployments/resources/app_configs/consensus_manager_config.json +++ b/crates/apollo_deployments/resources/app_configs/consensus_manager_config.json @@ -44,6 +44,7 @@ "consensus_manager_config.context_config.dynamic_config.max_l1_gas_price_wei": 1000000000000, "consensus_manager_config.context_config.dynamic_config.min_l1_data_gas_price_wei": 1, "consensus_manager_config.context_config.dynamic_config.min_l1_gas_price_wei": 1000000000, + "consensus_manager_config.context_config.dynamic_config.snip35_target_atto_usd_per_l2_gas": 880000000, "consensus_manager_config.context_config.static_config.proposal_buffer_size": 512, "consensus_manager_config.context_config.static_config.retrospective_block_hash_retry_interval_millis": 500, "consensus_manager_config.context_config.static_config.validate_proposal_margin_millis": 10000, diff --git a/crates/apollo_deployments/resources/app_configs/l1_events_scraper_config.json b/crates/apollo_deployments/resources/app_configs/l1_events_scraper_config.json index c100bd58859..99ca99f35a1 100644 --- a/crates/apollo_deployments/resources/app_configs/l1_events_scraper_config.json +++ b/crates/apollo_deployments/resources/app_configs/l1_events_scraper_config.json @@ -3,5 +3,5 @@ "l1_events_scraper_config.l1_block_time_seconds": 12.0, "l1_events_scraper_config.polling_interval_seconds": 30, "l1_events_scraper_config.set_provider_historic_height_to_l2_genesis": false, - "l1_events_scraper_config.startup_rewind_time_seconds": 3600 + "l1_events_scraper_config.startup_rewind_time_seconds": 21600 } diff --git a/crates/apollo_deployments/resources/app_configs/replacer_consensus_manager_config.json b/crates/apollo_deployments/resources/app_configs/replacer_consensus_manager_config.json index bab83c9a312..10e371e1759 100644 --- a/crates/apollo_deployments/resources/app_configs/replacer_consensus_manager_config.json +++ b/crates/apollo_deployments/resources/app_configs/replacer_consensus_manager_config.json @@ -49,6 +49,7 @@ "consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri.#is_none": "$$$_CONSENSUS_MANAGER_CONFIG-CONTEXT_CONFIG-DYNAMIC_CONFIG-OVERRIDE_L1_GAS_PRICE_FRI-IS_NONE_$$$", "consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri": "$$$_CONSENSUS_MANAGER_CONFIG-CONTEXT_CONFIG-DYNAMIC_CONFIG-OVERRIDE_L2_GAS_PRICE_FRI_$$$", "consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri.#is_none": "$$$_CONSENSUS_MANAGER_CONFIG-CONTEXT_CONFIG-DYNAMIC_CONFIG-OVERRIDE_L2_GAS_PRICE_FRI-IS_NONE_$$$", + "consensus_manager_config.context_config.dynamic_config.snip35_target_atto_usd_per_l2_gas": 880000000, "consensus_manager_config.context_config.static_config.block_timestamp_window_seconds": 1, "consensus_manager_config.context_config.static_config.build_proposal_time_ratio_for_retrospective_block_hash": 0.7, "consensus_manager_config.context_config.static_config.builder_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", diff --git a/crates/apollo_deployments/resources/app_configs/replacer_l1_events_scraper_config.json b/crates/apollo_deployments/resources/app_configs/replacer_l1_events_scraper_config.json index c100bd58859..99ca99f35a1 100644 --- a/crates/apollo_deployments/resources/app_configs/replacer_l1_events_scraper_config.json +++ b/crates/apollo_deployments/resources/app_configs/replacer_l1_events_scraper_config.json @@ -3,5 +3,5 @@ "l1_events_scraper_config.l1_block_time_seconds": 12.0, "l1_events_scraper_config.polling_interval_seconds": 30, "l1_events_scraper_config.set_provider_historic_height_to_l2_genesis": false, - "l1_events_scraper_config.startup_rewind_time_seconds": 3600 + "l1_events_scraper_config.startup_rewind_time_seconds": 21600 } diff --git a/crates/apollo_integration_tests/resources/proof_flow/proof.bin b/crates/apollo_integration_tests/resources/proof_flow/proof.bin index 8edc208e398..b9f0d422e16 100644 Binary files a/crates/apollo_integration_tests/resources/proof_flow/proof.bin and b/crates/apollo_integration_tests/resources/proof_flow/proof.bin differ diff --git a/crates/apollo_l1_events/src/metrics.rs b/crates/apollo_l1_events/src/metrics.rs index 114fdbec28d..0aa74121f5c 100644 --- a/crates/apollo_l1_events/src/metrics.rs +++ b/crates/apollo_l1_events/src/metrics.rs @@ -14,6 +14,7 @@ define_metrics!( L1EventsProvider => { MetricGauge { L1_MESSAGE_SCRAPER_LATEST_SCRAPED_BLOCK, "l1_message_scraper_latest_scraped_block", "The latest block number that the L1 message scraper has scraped" }, MetricCounter { L1_MESSAGE_SCRAPER_SUCCESS_COUNT, "l1_message_scraper_success_count", "Number of times the L1 message scraper successfully scraped messages and updated the provider", init=0 }, + MetricCounter { L1_MESSAGE_SCRAPER_L1_HANDLER_TX_COUNT, "l1_message_scraper_l1_handler_tx_count", "Number of unique L1 handler transactions scraped from L1 (Full payload stored)", init=0 }, MetricCounter { L1_MESSAGE_SCRAPER_BASELAYER_ERROR_COUNT, "l1_message_scraper_baselayer_error_count", "Number of times the L1 message scraper encountered an error while scraping the base layer", init=0}, MetricCounter { L1_MESSAGE_SCRAPER_REORG_DETECTED, "l1_message_scraper_reorg_detected", "Number of times the L1 message scraper detected a reorganization in the base layer", init=0}, MetricGauge { L1_MESSAGE_SCRAPER_LAST_SUCCESS_TIMESTAMP_SECONDS, "l1_message_scraper_last_success_timestamp_seconds", "Unix timestamp (seconds) of the last successful L1 message scrape" }, @@ -24,6 +25,7 @@ define_metrics!( pub(crate) fn register_scraper_metrics() { L1_MESSAGE_SCRAPER_LATEST_SCRAPED_BLOCK.register(); L1_MESSAGE_SCRAPER_SUCCESS_COUNT.register(); + L1_MESSAGE_SCRAPER_L1_HANDLER_TX_COUNT.register(); L1_MESSAGE_SCRAPER_BASELAYER_ERROR_COUNT.register(); L1_MESSAGE_SCRAPER_REORG_DETECTED.register(); L1_MESSAGE_SCRAPER_LAST_SUCCESS_TIMESTAMP_SECONDS.register(); diff --git a/crates/apollo_l1_events/src/transaction_manager.rs b/crates/apollo_l1_events/src/transaction_manager.rs index 3ea287497f9..74506bb5374 100644 --- a/crates/apollo_l1_events/src/transaction_manager.rs +++ b/crates/apollo_l1_events/src/transaction_manager.rs @@ -9,7 +9,7 @@ use starknet_api::executable_transaction::L1HandlerTransaction; use starknet_api::transaction::TransactionHash; use tracing::{debug, info, warn}; -use crate::metrics::L1_MESSAGE_PROVIDER_NUM_PENDING_TXS; +use crate::metrics::{L1_MESSAGE_PROVIDER_NUM_PENDING_TXS, L1_MESSAGE_SCRAPER_L1_HANDLER_TX_COUNT}; use crate::transaction_record::{ Records, TransactionPayload, @@ -184,6 +184,9 @@ impl TransactionManager { ); } record.tx.set(tx, block_timestamp, scrape_timestamp); + // Counts the HashOnly -> Full transition, regardless of whether the HashOnly + // was just created here or pre-existed from state sync. + L1_MESSAGE_SCRAPER_L1_HANDLER_TX_COUNT.increment(1); } TransactionPayload::Full { tx: _, created_at_block_timestamp: _, scrape_timestamp } => { warn!( diff --git a/crates/apollo_node/resources/config_schema.json b/crates/apollo_node/resources/config_schema.json index 161668f68be..88104a1ef8f 100644 --- a/crates/apollo_node/resources/config_schema.json +++ b/crates/apollo_node/resources/config_schema.json @@ -2729,6 +2729,11 @@ "privacy": "TemporaryValue", "value": true }, + "consensus_manager_config.context_config.dynamic_config.snip35_target_atto_usd_per_l2_gas": { + "description": "SNIP-35 target USD cost per L2 gas unit, in atto-USD ($0.88 per 1e9 L2 gas = 880_000_000 atto-USD).", + "privacy": "Public", + "value": 880000000 + }, "consensus_manager_config.context_config.static_config.behavior_mode": { "description": "Behavior mode: 'starknet' for production, 'echonet' for test/replay mode.", "pointer_target": "behavior_mode", diff --git a/crates/apollo_rpc_execution/src/execution_test.rs b/crates/apollo_rpc_execution/src/execution_test.rs index 732a1fa0058..3ed8bf67312 100644 --- a/crates/apollo_rpc_execution/src/execution_test.rs +++ b/crates/apollo_rpc_execution/src/execution_test.rs @@ -6,6 +6,7 @@ use apollo_storage::test_utils::get_test_storage; use assert_matches::assert_matches; use blockifier::blockifier_versioned_constants::VersionedConstants; use blockifier::execution::call_info::Retdata; +use blockifier::execution::contract_class::TrackedResource; use blockifier::execution::errors::ConstructorEntryPointExecutionError; use blockifier::execution::stack_trace::gen_tx_execution_error_trace; use blockifier::transaction::errors::TransactionExecutionError as BlockifierTransactionExecutionError; @@ -774,6 +775,7 @@ fn simulate_with_query_bit_outputs_same_as_no_query_bit() { // TODO(yair): remove once blockifier arranges the errors. #[test] fn blockifier_error_mapping() { + let strip_vm_frames = VersionedConstants::latest_constants().strip_vm_frames_in_sierra_gas; let child = blockifier::execution::errors::EntryPointExecutionError::RecursionDepthExceeded; let storage_address = contract_address!("0x123"); let class_hash = class_hash!("0x321"); @@ -786,7 +788,7 @@ fn blockifier_error_mapping() { let blockifier_err = BlockifierTransactionExecutionError::ContractConstructorExecutionFailed( ConstructorEntryPointExecutionError::ExecutionError { - error: Box::new(child), + error: Box::new(child.annotated(TrackedResource::CairoSteps, strip_vm_frames)), class_hash, contract_address: storage_address, constructor_selector: None, @@ -803,7 +805,7 @@ fn blockifier_error_mapping() { let child = blockifier::execution::errors::EntryPointExecutionError::RecursionDepthExceeded; let selector = EntryPointSelector(felt!("0x111")); let blockifier_err = BlockifierTransactionExecutionError::ExecutionError { - error: Box::new(child), + error: Box::new(child.annotated(TrackedResource::CairoSteps, strip_vm_frames)), class_hash, storage_address, selector, @@ -819,7 +821,7 @@ fn blockifier_error_mapping() { let child = blockifier::execution::errors::EntryPointExecutionError::RecursionDepthExceeded; let blockifier_err = BlockifierTransactionExecutionError::ValidateTransactionError { - error: Box::new(child), + error: Box::new(child.annotated(TrackedResource::CairoSteps, strip_vm_frames)), class_hash, storage_address, selector, diff --git a/crates/apollo_transaction_converter/resources/example_proof.bin b/crates/apollo_transaction_converter/resources/example_proof.bin index dd9c876fbe0..f4776640a79 100644 Binary files a/crates/apollo_transaction_converter/resources/example_proof.bin and b/crates/apollo_transaction_converter/resources/example_proof.bin differ diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_0.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_0.json index a7373b02a9c..1b319a96455 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_0.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_0.json @@ -121,6 +121,7 @@ "enable_reverts": false, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "100.0.0", "enable_tip": false, "segment_arena_cells": true, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_1.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_1.json index f9c28d6f278..34651a9ddb8 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_1.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_1.json @@ -121,6 +121,7 @@ "enable_reverts": false, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "100.0.0", "enable_tip": false, "segment_arena_cells": true, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_1_1.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_1_1.json index cd9a135da4b..51864dbe274 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_1_1.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_1_1.json @@ -121,6 +121,7 @@ "enable_reverts": false, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "100.0.0", "enable_tip": false, "segment_arena_cells": true, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_2.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_2.json index d39ea928b87..7c9b71b2e1b 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_2.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_2.json @@ -121,6 +121,7 @@ "enable_reverts": false, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "100.0.0", "enable_tip": false, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_2_1.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_2_1.json index b3c012d8983..abfc986a7ea 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_2_1.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_2_1.json @@ -121,6 +121,7 @@ "enable_reverts": false, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "100.0.0", "enable_tip": false, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_3.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_3.json index b3c012d8983..abfc986a7ea 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_3.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_3.json @@ -121,6 +121,7 @@ "enable_reverts": false, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "100.0.0", "enable_tip": false, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_4.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_4.json index 5b8ad7f1e6c..533ebe43681 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_4.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_4.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": false, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_5.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_5.json index 110a58d0d41..38113fc0bf0 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_5.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_5.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": false, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_13_6.json b/crates/blockifier/resources/blockifier_versioned_constants_0_13_6.json index 110a58d0d41..38113fc0bf0 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_13_6.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_13_6.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": false, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_14_0.json b/crates/blockifier/resources/blockifier_versioned_constants_0_14_0.json index 355eb262ade..5da36d6c60f 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_14_0.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_14_0.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": false, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": true, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_14_1.json b/crates/blockifier/resources/blockifier_versioned_constants_0_14_1.json index feef3af988e..ee320231f0a 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_14_1.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_14_1.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": true, "block_casm_hash_v1_declares": true, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": true, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_14_2.json b/crates/blockifier/resources/blockifier_versioned_constants_0_14_2.json index f6d25d949e6..aa52fcec185 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_14_2.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_14_2.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": false, "block_casm_hash_v1_declares": true, + "strip_vm_frames_in_sierra_gas": false, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": true, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_14_3.json b/crates/blockifier/resources/blockifier_versioned_constants_0_14_3.json index df21e397f16..0f5d041f90f 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_14_3.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_14_3.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": true, "block_casm_hash_v1_declares": true, + "strip_vm_frames_in_sierra_gas": true, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": true, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json b/crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json index 4a73db8c833..e29040290c4 100644 --- a/crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json +++ b/crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json @@ -121,6 +121,7 @@ "enable_reverts": true, "enable_casm_hash_migration": true, "block_casm_hash_v1_declares": true, + "strip_vm_frames_in_sierra_gas": true, "min_sierra_version_for_sierra_gas": "1.7.0", "enable_tip": true, "segment_arena_cells": false, diff --git a/crates/blockifier/resources/versioned_constants_diff_regression/0.14.2_0.14.3.txt b/crates/blockifier/resources/versioned_constants_diff_regression/0.14.2_0.14.3.txt index f5579c37191..d6dec765c97 100644 --- a/crates/blockifier/resources/versioned_constants_diff_regression/0.14.2_0.14.3.txt +++ b/crates/blockifier/resources/versioned_constants_diff_regression/0.14.2_0.14.3.txt @@ -6,3 +6,4 @@ ~ /os_resources/execute_syscalls/Sha512ProcessBlock/n_steps: 4737 ~ /os_resources/execute_syscalls/StorageRead/n_steps: 240 ~ /os_resources/execute_syscalls/StorageWrite/n_steps: 599 +~ /strip_vm_frames_in_sierra_gas: true diff --git a/crates/blockifier/src/blockifier_versioned_constants.rs b/crates/blockifier/src/blockifier_versioned_constants.rs index 6db4cd32158..95a46fe3f8b 100644 --- a/crates/blockifier/src/blockifier_versioned_constants.rs +++ b/crates/blockifier/src/blockifier_versioned_constants.rs @@ -89,6 +89,7 @@ pub struct RawVersionedConstants { pub enable_reverts: bool, pub enable_casm_hash_migration: bool, pub block_casm_hash_v1_declares: bool, + pub strip_vm_frames_in_sierra_gas: bool, pub min_sierra_version_for_sierra_gas: SierraVersion, pub enable_tip: bool, pub segment_arena_cells: bool, @@ -290,6 +291,7 @@ pub struct VersionedConstants { pub enable_stateful_compression: bool, pub enable_casm_hash_migration: bool, pub block_casm_hash_v1_declares: bool, + pub strip_vm_frames_in_sierra_gas: bool, pub comprehensive_state_diff: bool, pub block_direct_execute_call: bool, pub ignore_inner_event_resources: bool, @@ -343,6 +345,7 @@ impl From for VersionedConstants { enable_reverts: raw_vc.enable_reverts, enable_casm_hash_migration: raw_vc.enable_casm_hash_migration, block_casm_hash_v1_declares: raw_vc.block_casm_hash_v1_declares, + strip_vm_frames_in_sierra_gas: raw_vc.strip_vm_frames_in_sierra_gas, os_constants: Arc::new(os_constants), vm_resource_fee_cost: Arc::new(raw_vc.vm_resource_fee_cost), enable_tip: raw_vc.enable_tip, diff --git a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs index d01b78a8d53..a75832330fa 100644 --- a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs +++ b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs @@ -17,12 +17,8 @@ use crate::execution::call_info::{CallExecution, CallInfo, ExtendedExecutionReso use crate::execution::contract_class::{CompiledClassV0, TrackedResource}; use crate::execution::deprecated_syscalls::deprecated_syscall_executor::DeprecatedSyscallExecutor; use crate::execution::deprecated_syscalls::hint_processor::DeprecatedSyscallHintProcessor; -use crate::execution::entry_point::{ - EntryPointExecutionContext, - EntryPointExecutionResult, - ExecutableCallEntryPoint, -}; -use crate::execution::errors::{PostExecutionError, PreExecutionError}; +use crate::execution::entry_point::{EntryPointExecutionContext, ExecutableCallEntryPoint}; +use crate::execution::errors::{EntryPointExecutionError, PostExecutionError, PreExecutionError}; use crate::execution::execution_utils::{read_execution_retdata, Args, ReadOnlySegments}; use crate::state::state_api::State; @@ -48,22 +44,25 @@ pub fn execute_entry_point_call( compiled_class: CompiledClassV0, state: &mut dyn State, context: &mut EntryPointExecutionContext, -) -> EntryPointExecutionResult { +) -> Result { let VmExecutionContext { mut runner, mut syscall_handler, initial_syscall_ptr, entry_point_pc } = - initialize_execution_context(&call, compiled_class, state, context)?; + initialize_execution_context(&call, compiled_class, state, context) + .map_err(EntryPointExecutionError::from)?; let (implicit_args, args) = prepare_call_arguments( &call, &mut runner, initial_syscall_ptr, &mut syscall_handler.read_only_segments, - )?; + ) + .map_err(EntryPointExecutionError::from)?; let n_total_args = args.len(); // Execute. run_entry_point(&mut runner, &mut syscall_handler, entry_point_pc, args)?; - Ok(finalize_execution(runner, syscall_handler, call, implicit_args, n_total_args)?) + finalize_execution(runner, syscall_handler, call, implicit_args, n_total_args) + .map_err(EntryPointExecutionError::from) } pub fn initialize_execution_context<'a>( @@ -210,11 +209,11 @@ pub fn run_entry_point( hint_processor: &mut DeprecatedSyscallHintProcessor<'_>, entry_point_pc: usize, args: Args, -) -> EntryPointExecutionResult<()> { +) -> Result<(), EntryPointExecutionError> { let verify_secure = true; let program_segment_size = None; // Infer size from program. let args: Vec<&CairoArg> = args.iter().collect(); - let result = runner + runner .run_from_entrypoint( entry_point_pc, &args, @@ -222,9 +221,7 @@ pub fn run_entry_point( program_segment_size, hint_processor, ) - .map_err(Box::new); - - Ok(result?) + .map_err(|error| EntryPointExecutionError::from(Box::new(error))) } pub fn finalize_execution( diff --git a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs index 49c19c473a5..78cf6fc2c4c 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs @@ -44,8 +44,7 @@ use crate::execution::call_info::{ use crate::execution::common_hints::ExecutionMode; use crate::execution::deprecated_syscalls::hint_processor::DeprecatedSyscallExecutionError; use crate::execution::deprecated_syscalls::DeprecatedSyscallSelector; -use crate::execution::entry_point::{CallEntryPoint, CallType}; -use crate::execution::errors::EntryPointExecutionError; +use crate::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionResult}; use crate::execution::syscalls::hint_processor::EmitEventError; use crate::execution::syscalls::vm_syscall_utils::{SyscallSelector, SyscallUsage}; use crate::state::state_api::StateReader; @@ -691,7 +690,7 @@ fn emit_events( n_emitted_events: &[Felt], keys: &[Felt], data: &[Felt], -) -> Result { +) -> EntryPointExecutionResult { let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let mut state = test_state(&ChainInfo::create_for_testing(), Fee(0), &[(test_contract, 1)]); let calldata = Calldata( diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index 96e3f3af524..49568776a3c 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -88,7 +88,10 @@ use crate::execution::entry_point::{ ConstructorContext, EntryPointExecutionContext, }; -use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; +use crate::execution::errors::{ + AnnotatedEntryPointExecutionError, + ConstructorEntryPointExecutionError, +}; use crate::execution::execution_utils::{ execute_deployment, felt_from_ptr, @@ -114,7 +117,7 @@ pub enum DeprecatedSyscallExecutionError { #[error(transparent)] BaseError(#[from] DeprecatedSyscallExecutorBaseError), #[error(transparent)] - EntryPointExecutionError(#[from] EntryPointExecutionError), + EntryPointExecutionError(#[from] AnnotatedEntryPointExecutionError), #[error(transparent)] ConstructorEntryPointExecutionError(#[from] ConstructorEntryPointExecutionError), #[error("{error}")] diff --git a/crates/blockifier/src/execution/entry_point.rs b/crates/blockifier/src/execution/entry_point.rs index f55bb6af843..a5ad7c4c1bc 100644 --- a/crates/blockifier/src/execution/entry_point.rs +++ b/crates/blockifier/src/execution/entry_point.rs @@ -29,6 +29,7 @@ use crate::execution::call_info::CallInfo; use crate::execution::common_hints::ExecutionMode; use crate::execution::contract_class::{RunnableCompiledClass, TrackedResource}; use crate::execution::errors::{ + AnnotatedEntryPointExecutionError, ConstructorEntryPointExecutionError, EntryPointExecutionError, PreExecutionError, @@ -47,7 +48,7 @@ pub mod test; pub const FAULTY_CLASS_HASH: &str = "0x1A7820094FEAF82D53F53F214B81292D717E7BB9A92BB2488092CD306F3993F"; -pub type EntryPointExecutionResult = Result; +pub type EntryPointExecutionResult = Result; pub type ConstructorEntryPointExecutionResult = Result; /// Holds the the information required to revert the execution of an entry point. @@ -165,16 +166,25 @@ impl CallEntryPoint { remaining_gas: &mut u64, ) -> EntryPointExecutionResult { let tx_context = &context.tx_context; + let strip_vm_frames = context.versioned_constants().strip_vm_frames_in_sierra_gas; let mut decrement_when_dropped = RecursionDepthGuard::new( context.current_recursion_depth.clone(), context.versioned_constants().max_recursion_depth, ); - decrement_when_dropped.try_increment_and_check_depth()?; + decrement_when_dropped + .try_increment_and_check_depth() + .map_err(|e| e.annotated(TrackedResource::CairoSteps, strip_vm_frames))?; // Validate contract is deployed. - let storage_class_hash = state.get_class_hash_at(self.storage_address)?; + let storage_class_hash = state.get_class_hash_at(self.storage_address).map_err(|e| { + EntryPointExecutionError::from(e) + .annotated(TrackedResource::CairoSteps, strip_vm_frames) + })?; if storage_class_hash == ClassHash::default() { - return Err(PreExecutionError::UninitializedStorageAddress(self.storage_address).into()); + return Err(EntryPointExecutionError::from( + PreExecutionError::UninitializedStorageAddress(self.storage_address), + ) + .annotated(TrackedResource::CairoSteps, strip_vm_frames)); } let class_hash = match self.class_hash { @@ -188,11 +198,15 @@ impl CallEntryPoint { Felt::from_hex(FAULTY_CLASS_HASH).expect("A class hash must be a felt."), ) { - return Err(PreExecutionError::FraudAttempt.into()); + return Err(EntryPointExecutionError::from(PreExecutionError::FraudAttempt) + .annotated(TrackedResource::CairoSteps, strip_vm_frames)); } // Add class hash to the call, that will appear in the output (call info). self.class_hash = Some(class_hash); - let compiled_class = state.get_compiled_class(class_hash)?; + let compiled_class = state.get_compiled_class(class_hash).map_err(|e| { + EntryPointExecutionError::from(e) + .annotated(TrackedResource::CairoSteps, strip_vm_frames) + })?; context.revert_infos.0.push(EntryPointRevertInfo::new( self.storage_address, @@ -233,7 +247,11 @@ impl CallEntryPoint { call_info, Cairo1RevertHeader::Execution, ), - }); + } + .annotated( + call_info.tracked_resource, + context.versioned_constants().strip_vm_frames_in_sierra_gas, + )); } } @@ -537,9 +555,15 @@ pub fn execute_constructor_entry_point( calldata: Calldata, remaining_gas: &mut u64, ) -> ConstructorEntryPointExecutionResult { + let strip_vm_frames = context.versioned_constants().strip_vm_frames_in_sierra_gas; // Ensure the class is declared (by reading it). let compiled_class = state.get_compiled_class(ctor_context.class_hash).map_err(|error| { - ConstructorEntryPointExecutionError::new(error.into(), &ctor_context, None) + ConstructorEntryPointExecutionError::new( + EntryPointExecutionError::from(error) + .annotated(TrackedResource::CairoSteps, strip_vm_frames), + &ctor_context, + None, + ) })?; let Some(constructor_selector) = compiled_class.constructor_selector() else { // Contract has no constructor. @@ -616,15 +640,17 @@ pub fn handle_empty_constructor( calldata: Calldata, remaining_gas: u64, ) -> EntryPointExecutionResult { + let current_tracked_resource = compiled_class.get_current_tracked_resource(context); + let strip_vm_frames = context.versioned_constants().strip_vm_frames_in_sierra_gas; // Validate no calldata. if !calldata.0.is_empty() { return Err(EntryPointExecutionError::InvalidExecutionInput { input_descriptor: "constructor_calldata".to_string(), info: "Cannot pass calldata to a contract with no constructor.".to_string(), - }); + } + .annotated(current_tracked_resource, strip_vm_frames)); } - let current_tracked_resource = compiled_class.get_current_tracked_resource(context); let initial_gas = if current_tracked_resource == TrackedResource::CairoSteps { // Override the initial gas with a high value to be consistent with the behavior for the // rest of the CairoSteps mode calls. @@ -664,7 +690,7 @@ impl RecursionDepthGuard { // Tries to increment the current recursion depth and returns an error if the maximum depth // would be exceeded. - fn try_increment_and_check_depth(&mut self) -> EntryPointExecutionResult<()> { + fn try_increment_and_check_depth(&mut self) -> Result<(), EntryPointExecutionError> { *self.current_depth.borrow_mut() += 1; if *self.current_depth.borrow() > self.max_depth { return Err(EntryPointExecutionError::RecursionDepthExceeded); diff --git a/crates/blockifier/src/execution/entry_point_execution.rs b/crates/blockifier/src/execution/entry_point_execution.rs index 625b40c5ea2..d20e7548538 100644 --- a/crates/blockifier/src/execution/entry_point_execution.rs +++ b/crates/blockifier/src/execution/entry_point_execution.rs @@ -25,11 +25,7 @@ use crate::execution::call_info::{ Retdata, }; use crate::execution::contract_class::{CompiledClassV1, EntryPointV1, TrackedResource}; -use crate::execution::entry_point::{ - EntryPointExecutionContext, - EntryPointExecutionResult, - ExecutableCallEntryPoint, -}; +use crate::execution::entry_point::{EntryPointExecutionContext, ExecutableCallEntryPoint}; use crate::execution::errors::{EntryPointExecutionError, PostExecutionError, PreExecutionError}; use crate::execution::execution_utils::{ read_execution_retdata, @@ -110,7 +106,7 @@ pub fn execute_entry_point_call( compiled_class: CompiledClassV1, state: &mut dyn State, context: &mut EntryPointExecutionContext, -) -> EntryPointExecutionResult { +) -> Result { let tracked_resource = *context.tracked_resource_stack.last().expect("Unexpected empty tracked resource."); // Extract information from the context, as it will be passed as a mutable reference. @@ -121,7 +117,8 @@ pub fn execute_entry_point_call( initial_syscall_ptr, entry_point, program_extra_data_length, - } = initialize_execution_context(call, &compiled_class, state, context)?; + } = initialize_execution_context(call, &compiled_class, state, context) + .map_err(EntryPointExecutionError::from)?; let args = prepare_call_arguments( &syscall_handler.base.call, @@ -130,7 +127,8 @@ pub fn execute_entry_point_call( &mut syscall_handler.read_only_segments, &entry_point, entry_point_initial_budget, - )?; + ) + .map_err(EntryPointExecutionError::from)?; let n_total_args = args.len(); @@ -139,13 +137,14 @@ pub fn execute_entry_point_call( let program_segment_size = bytecode_length + program_extra_data_length; run_entry_point(&mut runner, &mut syscall_handler, entry_point, args, program_segment_size)?; - Ok(finalize_execution( + finalize_execution( runner, syscall_handler, n_total_args, program_extra_data_length, tracked_resource, - )?) + ) + .map_err(EntryPointExecutionError::from) } pub fn initialize_execution_context_with_runner_mode<'a>( @@ -314,7 +313,7 @@ pub fn run_entry_point( entry_point: EntryPointV1, args: Args, program_segment_size: usize, -) -> EntryPointExecutionResult<()> { +) -> Result<(), EntryPointExecutionError> { // Note that we run `verify_secure_runner` manually after filling the holes in the rc96 segment. let verify_secure = false; let args: Vec<&CairoArg> = args.iter().collect(); @@ -326,12 +325,13 @@ pub fn run_entry_point( Some(program_segment_size), hint_processor, ) - .map_err(Box::new)?; + .map_err(|error| EntryPointExecutionError::from(Box::new(error)))?; maybe_fill_holes(entry_point, runner)?; - verify_secure_runner(runner, false, Some(program_segment_size)) - .map_err(|error| Box::new(CairoRunError::VirtualMachine(error)))?; + verify_secure_runner(runner, false, Some(program_segment_size)).map_err(|error| { + EntryPointExecutionError::from(Box::new(CairoRunError::VirtualMachine(error))) + })?; Ok(()) } diff --git a/crates/blockifier/src/execution/entry_point_test.rs b/crates/blockifier/src/execution/entry_point_test.rs index 2bcaa968711..2448a4492cd 100644 --- a/crates/blockifier/src/execution/entry_point_test.rs +++ b/crates/blockifier/src/execution/entry_point_test.rs @@ -584,7 +584,9 @@ fn test_call_view_entry_point_non_existing_function() { Calldata(vec![].into()), ); - let EntryPointExecutionError::ExecutionFailed { error_trace } = call_info.unwrap_err() else { + let EntryPointExecutionError::ExecutionFailed { error_trace } = + call_info.unwrap_err().into_unannotated() + else { panic!("Expected ExecutionFailed error"); }; assert_eq!(error_trace.last_retdata.0, vec![ENTRYPOINT_NOT_FOUND_ERROR_FELT]); diff --git a/crates/blockifier/src/execution/errors.rs b/crates/blockifier/src/execution/errors.rs index 6271872156d..83e9d2f24ca 100644 --- a/crates/blockifier/src/execution/errors.rs +++ b/crates/blockifier/src/execution/errors.rs @@ -14,6 +14,7 @@ use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use thiserror::Error; +use crate::execution::contract_class::TrackedResource; use crate::execution::entry_point::ConstructorContext; use crate::execution::stack_trace::Cairo1RevertSummary; #[cfg(feature = "cairo_native")] @@ -116,6 +117,57 @@ pub enum EntryPointExecutionError { TraceError(#[from] TraceError), } +impl EntryPointExecutionError { + /// Tags `self` with the frame's `tracked_resource` and strip policy. + pub fn annotated( + self, + tracked_resource: TrackedResource, + strip_vm_frames_in_sierra_gas: bool, + ) -> AnnotatedEntryPointExecutionError { + AnnotatedEntryPointExecutionError { + inner: Box::new(self), + tracked_resource, + strip_vm_frames_in_sierra_gas, + } + } +} + +/// Annotated `EntryPointExecutionError`: only constructible via +/// `EntryPointExecutionError::annotated` (private fields enforce this), so stack-trace-feeding +/// fields typed `AnnotatedEntryPointExecutionError` statically reject unannotated errors. +#[derive(Debug, Error)] +#[error("{inner}")] +pub struct AnnotatedEntryPointExecutionError { + #[source] + inner: Box, + tracked_resource: TrackedResource, + strip_vm_frames_in_sierra_gas: bool, +} + +impl AnnotatedEntryPointExecutionError { + pub fn unannotated(&self) -> &EntryPointExecutionError { + &self.inner + } + + pub fn into_unannotated(self) -> EntryPointExecutionError { + *self.inner + } + + pub fn tracked_resource(&self) -> TrackedResource { + self.tracked_resource + } + + pub fn strip_vm_frames_in_sierra_gas(&self) -> bool { + self.strip_vm_frames_in_sierra_gas + } + + /// Consumes `self` into `(inner, tracked_resource, strip_vm_frames_in_sierra_gas)`. Lets + /// callers re-wrap a transformed inner error without losing the annotation. + pub fn into_parts(self) -> (EntryPointExecutionError, TrackedResource, bool) { + (*self.inner, self.tracked_resource, self.strip_vm_frames_in_sierra_gas) + } +} + #[derive(Debug, Error)] pub enum ConstructorEntryPointExecutionError { #[error( @@ -124,7 +176,7 @@ pub enum ConstructorEntryPointExecutionError { )] ExecutionError { #[source] - error: Box, + error: Box, class_hash: ClassHash, contract_address: ContractAddress, constructor_selector: Option, @@ -133,7 +185,7 @@ pub enum ConstructorEntryPointExecutionError { impl ConstructorEntryPointExecutionError { pub fn new( - error: EntryPointExecutionError, + error: AnnotatedEntryPointExecutionError, ctor_context: &ConstructorContext, selector: Option, ) -> Self { diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index 593b3aaa71e..231f1b9a936 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -62,6 +62,7 @@ pub fn execute_entry_point_call_wrapper( remaining_gas: &mut u64, ) -> EntryPointExecutionResult { let current_tracked_resource = compiled_class.get_current_tracked_resource(context); + let strip_vm_frames = context.versioned_constants().strip_vm_frames_in_sierra_gas; if current_tracked_resource == TrackedResource::CairoSteps { // Override the initial gas with a high value so it won't limit the run. call.initial_gas = context.versioned_constants().infinite_gas_for_vm_mode(); @@ -82,33 +83,41 @@ pub fn execute_entry_point_call_wrapper( &call_info, Cairo1RevertHeader::Execution, ), - }); + } + .annotated(current_tracked_resource, strip_vm_frames)); } update_remaining_gas(remaining_gas, &call_info); Ok(call_info) } - Err(EntryPointExecutionError::PreExecutionError(err)) - if context.versioned_constants().enable_reverts => - { - let error_code = match err { - PreExecutionError::EntryPointNotFound(_) - | PreExecutionError::NoEntryPointOfTypeFound(_) => ENTRYPOINT_NOT_FOUND_ERROR_FELT, - PreExecutionError::InsufficientEntryPointGas => OUT_OF_GAS_ERROR_FELT, - _ => return Err(err.into()), - }; - Ok(CallInfo { - call: orig_call.into(), - execution: CallExecution { - retdata: Retdata(vec![error_code]), - failed: true, - gas_consumed: 0, - ..CallExecution::default() - }, - tracked_resource: current_tracked_resource, - ..CallInfo::default() - }) - } - Err(err) => Err(err), + Err(err) => match err { + EntryPointExecutionError::PreExecutionError(err) + if context.versioned_constants().enable_reverts => + { + let error_code = match err { + PreExecutionError::EntryPointNotFound(_) + | PreExecutionError::NoEntryPointOfTypeFound(_) => { + ENTRYPOINT_NOT_FOUND_ERROR_FELT + } + PreExecutionError::InsufficientEntryPointGas => OUT_OF_GAS_ERROR_FELT, + _ => { + return Err(EntryPointExecutionError::from(err) + .annotated(current_tracked_resource, strip_vm_frames)); + } + }; + Ok(CallInfo { + call: orig_call.into(), + execution: CallExecution { + retdata: Retdata(vec![error_code]), + failed: true, + gas_consumed: 0, + ..CallExecution::default() + }, + tracked_resource: current_tracked_resource, + ..CallInfo::default() + }) + } + other => Err(other.annotated(current_tracked_resource, strip_vm_frames)), + }, } } @@ -118,7 +127,7 @@ pub fn execute_entry_point_call( compiled_class: RunnableCompiledClass, state: &mut dyn State, context: &mut EntryPointExecutionContext, -) -> EntryPointExecutionResult { +) -> Result { #[cfg(feature = "benchmarking")] let pre_time = std::time::Instant::now(); @@ -322,16 +331,25 @@ pub fn execute_deployment( constructor_calldata: Calldata, remaining_gas: &mut u64, ) -> ConstructorEntryPointExecutionResult { + let strip_vm_frames = context.versioned_constants().strip_vm_frames_in_sierra_gas; // Address allocation in the state is done before calling the constructor, so that it is // visible from it. let deployed_contract_address = ctor_context.storage_address; let current_class_hash = state.get_class_hash_at(deployed_contract_address).map_err(|error| { - ConstructorEntryPointExecutionError::new(error.into(), &ctor_context, None) + ConstructorEntryPointExecutionError::new( + EntryPointExecutionError::from(error) + .annotated(TrackedResource::CairoSteps, strip_vm_frames), + &ctor_context, + None, + ) })?; if current_class_hash != ClassHash::default() { return Err(ConstructorEntryPointExecutionError::new( - StateError::UnavailableContractAddress(deployed_contract_address).into(), + EntryPointExecutionError::from(StateError::UnavailableContractAddress( + deployed_contract_address, + )) + .annotated(TrackedResource::CairoSteps, strip_vm_frames), &ctor_context, None, )); @@ -344,7 +362,14 @@ pub fn execute_deployment( context.n_sent_messages_to_l1, )); state.set_class_hash_at(deployed_contract_address, ctor_context.class_hash).map_err( - |error| ConstructorEntryPointExecutionError::new(error.into(), &ctor_context, None), + |error| { + ConstructorEntryPointExecutionError::new( + EntryPointExecutionError::from(error) + .annotated(TrackedResource::CairoSteps, strip_vm_frames), + &ctor_context, + None, + ) + }, )?; execute_constructor_entry_point( diff --git a/crates/blockifier/src/execution/native/entry_point_execution.rs b/crates/blockifier/src/execution/native/entry_point_execution.rs index 2dbc2cc48d5..8b934339330 100644 --- a/crates/blockifier/src/execution/native/entry_point_execution.rs +++ b/crates/blockifier/src/execution/native/entry_point_execution.rs @@ -11,11 +11,7 @@ use crate::execution::call_info::{ Retdata, }; use crate::execution::contract_class::TrackedResource; -use crate::execution::entry_point::{ - EntryPointExecutionContext, - EntryPointExecutionResult, - ExecutableCallEntryPoint, -}; +use crate::execution::entry_point::{EntryPointExecutionContext, ExecutableCallEntryPoint}; use crate::execution::errors::{EntryPointExecutionError, PostExecutionError, PreExecutionError}; use crate::execution::native::contract_class::NativeCompiledClassV1; use crate::execution::native::syscall_handler::NativeSyscallHandler; @@ -29,8 +25,10 @@ pub fn execute_entry_point_call( compiled_class: NativeCompiledClassV1, state: &mut dyn State, context: &mut EntryPointExecutionContext, -) -> EntryPointExecutionResult { - let entry_point = compiled_class.get_entry_point(&call.type_and_selector())?; +) -> Result { + let entry_point = compiled_class + .get_entry_point(&call.type_and_selector()) + .map_err(EntryPointExecutionError::from)?; let mut syscall_handler: NativeSyscallHandler<'_> = NativeSyscallHandler::new(call, state, context); diff --git a/crates/blockifier/src/execution/native/syscall_handler.rs b/crates/blockifier/src/execution/native/syscall_handler.rs index 02b9d3dd874..1578f8c7c34 100644 --- a/crates/blockifier/src/execution/native/syscall_handler.rs +++ b/crates/blockifier/src/execution/native/syscall_handler.rs @@ -139,9 +139,15 @@ impl<'state> NativeSyscallHandler<'state> { // creating multiple wraps around the same error. This function is meant to prevent that. fn unwrap_native_error(error: SyscallExecutionError) -> SyscallExecutionError { match error { - SyscallExecutionError::EntryPointExecutionError( - EntryPointExecutionError::NativeUnrecoverableError(e), - ) => *e, + SyscallExecutionError::EntryPointExecutionError(annotated) => { + let (inner, tracked_resource, strip) = annotated.into_parts(); + match inner { + EntryPointExecutionError::NativeUnrecoverableError(e) => *e, + other => SyscallExecutionError::EntryPointExecutionError( + other.annotated(tracked_resource, strip), + ), + } + } _ => error, } } diff --git a/crates/blockifier/src/execution/stack_trace.rs b/crates/blockifier/src/execution/stack_trace.rs index 25e74d5c60b..1e483f5d5d4 100644 --- a/crates/blockifier/src/execution/stack_trace.rs +++ b/crates/blockifier/src/execution/stack_trace.rs @@ -10,8 +10,13 @@ use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::execution_utils::format_panic_data; use crate::execution::call_info::{CallInfo, Retdata}; +use crate::execution::contract_class::TrackedResource; use crate::execution::deprecated_syscalls::hint_processor::DeprecatedSyscallExecutionError; -use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; +use crate::execution::errors::{ + AnnotatedEntryPointExecutionError, + ConstructorEntryPointExecutionError, + EntryPointExecutionError, +}; use crate::execution::syscalls::hint_processor::{ SyscallExecutionError, ENTRYPOINT_FAILED_ERROR_FELT, @@ -460,7 +465,7 @@ pub fn gen_tx_execution_error_trace(error: &TransactionExecutionError) -> ErrorS /// Generate error stack from top-level entry point execution error. fn gen_error_trace_from_entry_point_error( header: ErrorStackHeader, - error: &EntryPointExecutionError, + error: &AnnotatedEntryPointExecutionError, storage_address: &ContractAddress, class_hash: &ClassHash, entry_point_selector: Option<&EntryPointSelector>, @@ -486,16 +491,19 @@ fn extract_cairo_run_error_into_stack_trace( error_stack: &mut ErrorStack, depth: usize, error: &CairoRunError, + omit_vm_frame: bool, ) { if let CairoRunError::VmException(vm_exception) = error { - error_stack.push( - VmExceptionFrame { - pc: vm_exception.pc, - error_attr_value: vm_exception.error_attr_value.clone(), - traceback: vm_exception.traceback.clone(), - } - .into(), - ); + if !omit_vm_frame { + error_stack.push( + VmExceptionFrame { + pc: vm_exception.pc, + error_attr_value: vm_exception.error_attr_value.clone(), + traceback: vm_exception.traceback.clone(), + } + .into(), + ); + } extract_virtual_machine_error_into_stack_trace(error_stack, depth, &vm_exception.inner_exc); } else { error_stack.push(error.to_string().into()); @@ -703,11 +711,22 @@ fn extract_deprecated_syscall_execution_error_into_stack_trace( fn extract_entry_point_execution_error_into_stack_trace( error_stack: &mut ErrorStack, depth: usize, - entry_point_error: &EntryPointExecutionError, + entry_point_error: &AnnotatedEntryPointExecutionError, ) { - match entry_point_error { + let inner = entry_point_error.unannotated(); + match inner { EntryPointExecutionError::CairoRunError(cairo_run_error) => { - extract_cairo_run_error_into_stack_trace(error_stack, depth, cairo_run_error) + // Omit the cairo-vm PC/traceback only for SierraGas frames at versions where the + // strip policy is on — makes the revert reason invariant across execution + // backends. Cairo 0 (CairoSteps) always emits; it has no native counterpart. + let omit_vm_frame = entry_point_error.strip_vm_frames_in_sierra_gas() + && entry_point_error.tracked_resource() == TrackedResource::SierraGas; + extract_cairo_run_error_into_stack_trace( + error_stack, + depth, + cairo_run_error, + omit_vm_frame, + ) } #[cfg(feature = "cairo_native")] EntryPointExecutionError::NativeUnrecoverableError(error) => { @@ -716,6 +735,6 @@ fn extract_entry_point_execution_error_into_stack_trace( EntryPointExecutionError::ExecutionFailed { error_trace } => { error_stack.push(error_trace.clone().into()) } - _ => error_stack.push(format!("{entry_point_error}\n").into()), + _ => error_stack.push(format!("{inner}\n").into()), } } diff --git a/crates/blockifier/src/execution/stack_trace_regression/test_contract_ctor_frame_stack_trace_cairo1_casm.txt b/crates/blockifier/src/execution/stack_trace_regression/test_contract_ctor_frame_stack_trace_cairo1_casm.txt index 1930dbf0bf5..c37b5dcaf2f 100644 --- a/crates/blockifier/src/execution/stack_trace_regression/test_contract_ctor_frame_stack_trace_cairo1_casm.txt +++ b/crates/blockifier/src/execution/stack_trace_regression/test_contract_ctor_frame_stack_trace_cairo1_casm.txt @@ -1,8 +1,6 @@ Transaction execution has failed: 0: Error in the called contract (contract address: 0x00000000000000000000000000000000000000000000000000000000c0020000, class hash: 0x0000000000000000000000000000000000000000000000000000000080020000, selector: 0x015d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad): -Error at pc=0:443: 1: Error in the called contract (contract address: 0x00000000000000000000000000000000000000000000000000000000c0020000, class hash: 0x0000000000000000000000000000000000000000000000000000000080020000, selector: 0x02730079d734ee55315f4f141eaed376bddd8c2133523d223a344c5604e0f7f8): -Error at pc=0:818: 2: Error in the contract class constructor (contract address: 0x0103ee82605273496eed8d9141c5b3ad967baa08be63aa5bc49ffae5eae454cc, class hash: 0x0000000000000000000000000000000000000000000000000000000080040000, selector: 0x028ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194): Execution failed. Failure reason: Error in contract (contract address: 0x0103ee82605273496eed8d9141c5b3ad967baa08be63aa5bc49ffae5eae454cc, class hash: 0x0000000000000000000000000000000000000000000000000000000080040000, selector: 0x028ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194): diff --git a/crates/blockifier/src/execution/stack_trace_test.rs b/crates/blockifier/src/execution/stack_trace_test.rs index 14fd35c14e8..f9e1af01b11 100644 --- a/crates/blockifier/src/execution/stack_trace_test.rs +++ b/crates/blockifier/src/execution/stack_trace_test.rs @@ -2,6 +2,10 @@ use assert_matches::assert_matches; use blockifier_test_utils::cairo_versions::{CairoVersion, RunnableCairo1}; use blockifier_test_utils::calldata::create_calldata; use blockifier_test_utils::contracts::FeatureContract; +use cairo_vm::types::relocatable::Relocatable; +use cairo_vm::vm::errors::cairo_run_errors::CairoRunError; +use cairo_vm::vm::errors::vm_errors::VirtualMachineError; +use cairo_vm::vm::errors::vm_exception::VmException; use expect_test::expect_file; use pretty_assertions::assert_eq; use regex::Regex; @@ -32,15 +36,17 @@ use starknet_api::transaction::fields::{ ValidResourceBounds, }; use starknet_api::transaction::TransactionVersion; -use starknet_api::{calldata, felt, invoke_tx_args}; +use starknet_api::{calldata, class_hash, contract_address, felt, invoke_tx_args}; use starknet_types_core::felt::Felt; use crate::context::{BlockContext, ChainInfo}; use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; +use crate::execution::contract_class::TrackedResource; use crate::execution::entry_point::CallEntryPoint; use crate::execution::errors::EntryPointExecutionError; use crate::execution::stack_trace::{ extract_trailing_cairo1_revert_trace, + gen_tx_execution_error_trace, Cairo1RevertHeader, Cairo1RevertSummary, MIN_CAIRO1_FRAME_LENGTH, @@ -51,6 +57,7 @@ use crate::test_utils::initial_test_state::{fund_account, test_state}; use crate::test_utils::test_templates::cairo_version; use crate::test_utils::BALANCE; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; +use crate::transaction::errors::TransactionExecutionError; use crate::transaction::objects::TransactionInfoCreator; use crate::transaction::test_utils::{ block_context, @@ -843,6 +850,71 @@ Error in contract (contract address: {expected_address:#066x}, class hash: {:#06 ); } +/// Drives the deploy-faulty-ctor flow once on the given Cairo 1 backend and returns the +/// rendered revert text. Same setup as `test_contract_ctor_frame_stack_trace` (Cairo1 cases), +/// extracted so the cross-backend equality test below can run both backends in one process. +#[cfg(feature = "cairo_native")] +fn render_faulty_ctor_revert( + block_context: &BlockContext, + default_all_resource_bounds: ValidResourceBounds, + runnable: RunnableCairo1, +) -> String { + let cairo_version = CairoVersion::Cairo1(runnable); + let chain_info = &block_context.chain_info; + let account = FeatureContract::AccountWithoutValidations(cairo_version); + let faulty_ctor = FeatureContract::FaultyAccount(cairo_version); + let state = &mut test_state(chain_info, BALANCE, &[(account, 1), (faulty_ctor, 0)]); + let account_address = account.get_instance_address(0); + let faulty_class_hash = faulty_ctor.get_class_hash(); + + let invoke_deploy_tx = invoke_tx_with_default_flags(invoke_tx_args! { + sender_address: account_address, + signature: TransactionSignature(vec![felt!(INVALID)].into()), + calldata: create_calldata( + account_address, + DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME, + &[ + faulty_class_hash.0, + felt!(7_u8), // salt + felt!(1_u8), // ctor args length + felt!(FELT_TRUE), // validate_constructor: true → fail + ] + ), + resource_bounds: default_all_resource_bounds, + nonce: Nonce(felt!(0_u8)), + }); + invoke_deploy_tx.execute(state, block_context).unwrap().revert_error.unwrap().to_string() +} + +/// At v0.14.3+ (strip policy on), the same Cairo 1 flow must produce a byte-identical revert +/// string regardless of execution backend — this is what makes `receipt_commitment` invariant +/// under cairo-native vs cairo-vm CASM. Pre-patch (origin/main-v0.14.3), this assertion would +/// fail: CASM emitted `Error at pc=0:443:` / `Error at pc=0:797:` lines under the outer two +/// frames that native never produced, see the historical diff of +/// `test_contract_ctor_frame_stack_trace_cairo1_casm.txt`. +#[cfg(feature = "cairo_native")] +#[rstest] +fn test_revert_text_is_backend_invariant_for_sierra_gas( + block_context: BlockContext, + default_all_resource_bounds: ValidResourceBounds, +) { + let casm_revert = render_faulty_ctor_revert( + &block_context, + default_all_resource_bounds, + RunnableCairo1::Casm, + ); + let native_revert = render_faulty_ctor_revert( + &block_context, + default_all_resource_bounds, + RunnableCairo1::Native, + ); + assert_eq!( + casm_revert, native_revert, + "Cairo 1 revert text must be backend-invariant at v0.14.3+; CASM and Native \ + diverged.\nCASM:\n{casm_revert}\n\nNative:\n{native_revert}" + ); +} + #[test] fn test_min_cairo1_frame_length() { let failure_hex = "0xdeadbeef"; @@ -1081,3 +1153,92 @@ fn test_cairo1_stack_extraction_not_failure_fallback() { if stack.is_empty() && last_retdata == expected_retdata ); } + +/// Build a synthetic `EntryPointExecutionError::CairoRunError(VmException)` to feed into the +/// formatter. The exact PC/traceback strings are arbitrary; the test asserts on whether the +/// `Error at pc=` block survives the formatter, not on its contents. +fn synthetic_vm_exception_error() -> EntryPointExecutionError { + let vm_exception = VmException { + pc: Relocatable { segment_index: 0, offset: 42 }, + inst_location: None, + inner_exc: VirtualMachineError::Unexpected, + error_attr_value: None, + traceback: Some( + "Cairo traceback (most recent call last):\nUnknown location (pc=0:7)\n".to_string(), + ), + }; + EntryPointExecutionError::CairoRunError(Box::new(CairoRunError::VmException(vm_exception))) +} + +/// Wraps a synthetic CairoRunError as the top-level error of a `TransactionExecutionError` +/// with the given `(tracked_resource, strip_vm_frames_in_sierra_gas)` annotation. Returns +/// the formatted revert string. +fn render_revert_for(tracked_resource: TrackedResource, strip: bool) -> String { + let top_error = synthetic_vm_exception_error().annotated(tracked_resource, strip); + let tx_error = TransactionExecutionError::ExecutionError { + error: Box::new(top_error), + class_hash: class_hash!("0xabc"), + storage_address: contract_address!("0x123"), + selector: EntryPointSelector(felt!("0xdef")), + }; + gen_tx_execution_error_trace(&tx_error).to_string() +} + +/// SierraGas frame at a protocol version where the policy is active (v0.14.3+): the formatter +/// MUST omit the `Error at pc=` / `Cairo traceback` block, so the revert reason is identical +/// whether the contract ran via cairo-vm CASM or cairo-native. +#[test] +fn test_sierra_gas_frame_omits_vm_exception_block_when_strip_enabled() { + let rendered = render_revert_for(TrackedResource::SierraGas, true); + assert!( + !rendered.contains("Error at pc="), + "with strip enabled, SierraGas-mode revert must not include `Error at pc=` (got: \ + {rendered:?})" + ); + assert!( + !rendered.contains("Cairo traceback"), + "with strip enabled, SierraGas-mode revert must not include `Cairo traceback` (got: \ + {rendered:?})" + ); + // The frame preamble must still be present. + assert!( + rendered.contains("Error in the called contract"), + "frame preamble missing (got: {rendered:?})" + ); +} + +/// SierraGas frame at a protocol version where the policy is OFF (pre-v0.14.3): the formatter +/// MUST keep the legacy `Error at pc=` / `Cairo traceback` block, so we replay historical +/// blocks with byte-identical receipts. Replaying old blocks would break otherwise. +#[test] +fn test_sierra_gas_frame_keeps_vm_exception_block_when_strip_disabled() { + let rendered = render_revert_for(TrackedResource::SierraGas, false); + assert!( + rendered.contains("Error at pc=0:42:"), + "with strip disabled, SierraGas-mode revert must include `Error at pc=` (got: \ + {rendered:?})" + ); + assert!( + rendered.contains("Cairo traceback (most recent call last):"), + "with strip disabled, SierraGas-mode revert must include `Cairo traceback` (got: \ + {rendered:?})" + ); +} + +/// CairoSteps frame (Cairo 0): the formatter MUST emit the `Error at pc=` block regardless of +/// the strip policy, since Cairo 0 has no alternative execution backend and the PC + traceback +/// are useful debug information that nothing else carries. +#[rstest] +fn test_cairo_steps_frame_keeps_vm_exception_block_under_either_policy( + #[values(true, false)] strip: bool, +) { + let rendered = render_revert_for(TrackedResource::CairoSteps, strip); + assert!( + rendered.contains("Error at pc=0:42:"), + "CairoSteps-mode revert (strip={strip}) must include `Error at pc=` (got: {rendered:?})" + ); + assert!( + rendered.contains("Cairo traceback (most recent call last):"), + "CairoSteps-mode revert (strip={strip}) must include `Cairo traceback` (got: {rendered:?})" + ); +} diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index 55e90a16abb..2d8c26f0c78 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -36,7 +36,10 @@ use crate::execution::entry_point::{ EntryPointExecutionContext, ExecutableCallEntryPoint, }; -use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; +use crate::execution::errors::{ + AnnotatedEntryPointExecutionError, + ConstructorEntryPointExecutionError, +}; use crate::execution::execution_utils::{ felt_from_ptr, felt_range_from_ptr, @@ -97,7 +100,7 @@ pub enum SyscallExecutionError { #[error(transparent)] ConstructorEntryPointExecutionError(#[from] ConstructorEntryPointExecutionError), #[error(transparent)] - EntryPointExecutionError(#[from] EntryPointExecutionError), + EntryPointExecutionError(#[from] AnnotatedEntryPointExecutionError), #[error("{error}")] CallContractExecutionError { class_hash: ClassHash, diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs index 165fc85e902..96ac1e622b1 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs @@ -14,8 +14,7 @@ use test_case::test_case; use crate::blockifier_versioned_constants::VersionedConstants; use crate::context::ChainInfo; use crate::execution::call_info::{CallInfo, OrderedEvent}; -use crate::execution::entry_point::CallEntryPoint; -use crate::execution::errors::EntryPointExecutionError; +use crate::execution::entry_point::{CallEntryPoint, EntryPointExecutionResult}; use crate::execution::syscalls::hint_processor::EmitEventError; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{trivial_external_entry_point_new, BALANCE}; @@ -145,7 +144,7 @@ fn emit_events( n_emitted_events: &[Felt], keys: &[Felt], data: &[Felt], -) -> Result { +) -> EntryPointExecutionResult { let chain_info = &ChainInfo::create_for_testing(); let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1)]); let calldata = Calldata( diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index c2af0ebf95b..801d529539e 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -243,7 +243,7 @@ macro_rules! check_entry_point_execution_error { use cairo_vm::vm::errors::vm_exception::VmException; use $crate::execution::errors::EntryPointExecutionError; - match $error { + match $error.unannotated() { EntryPointExecutionError::CairoRunError(boxed_error) => { if let CairoRunError::VmException(VmException { inner_exc, .. }) = &*(boxed_error.as_ref()) diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index da3ae89ce7e..c5c2e42acaf 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -11,7 +11,10 @@ use thiserror::Error; use crate::bouncer::BouncerWeights; use crate::execution::call_info::Retdata; -use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; +use crate::execution::errors::{ + AnnotatedEntryPointExecutionError, + ConstructorEntryPointExecutionError, +}; use crate::execution::stack_trace::{gen_tx_execution_error_trace, Cairo1RevertSummary}; use crate::fee::fee_checks::FeeCheckError; use crate::state::errors::StateError; @@ -40,7 +43,7 @@ pub enum TransactionFeeError { #[error("Cairo resource names must be contained in fee cost dict.")] CairoResourcesNotContainedInFeeCosts, #[error(transparent)] - ExecuteFeeTransferError(#[from] EntryPointExecutionError), + ExecuteFeeTransferError(#[from] AnnotatedEntryPointExecutionError), #[error("Actual fee ({}) exceeded max fee ({}).", actual_fee.0, max_fee.0)] FeeTransferError { max_fee: Fee, actual_fee: Fee }, #[error("Actual fee ({}) exceeded paid fee on L1 ({}).", actual_fee.0, paid_fee.0)] @@ -82,7 +85,7 @@ pub enum TransactionExecutionError { DeclareTransactionError { class_hash: ClassHash }, #[error("{}", gen_tx_execution_error_trace(self))] ExecutionError { - error: Box, + error: Box, class_hash: ClassHash, storage_address: ContractAddress, selector: EntryPointSelector, @@ -117,7 +120,7 @@ pub enum TransactionExecutionError { TransactionTooLarge { max_capacity: Box, tx_size: Box }, #[error("{}", gen_tx_execution_error_trace(self))] ValidateTransactionError { - error: Box, + error: Box, class_hash: ClassHash, storage_address: ContractAddress, selector: EntryPointSelector, diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 2dbe04f1d3f..dd1c8e33030 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -2332,7 +2332,7 @@ fn test_deploy_account_tx( TransactionExecutionError::ContractConstructorExecutionFailed( ConstructorEntryPointExecutionError::ExecutionError { error, .. } ) - if matches!(*error, EntryPointExecutionError::StateError( + if matches!(error.unannotated(), EntryPointExecutionError::StateError( StateError::UnavailableContractAddress(_) )) ); @@ -2371,9 +2371,9 @@ fn test_fail_deploy_account_undeclared_class_hash( ConstructorEntryPointExecutionError::ExecutionError { error, .. } ) if matches!( - *error, + error.unannotated(), EntryPointExecutionError::StateError(StateError::UndeclaredClassHash(class_hash)) - if class_hash == undeclared_hash + if *class_hash == undeclared_hash ) ); } @@ -2386,22 +2386,22 @@ fn check_native_validate_error( ) { let syscall_error = match error { TransactionExecutionError::ValidateTransactionError { error: boxed_error, .. } => { - match *boxed_error { + match (*boxed_error).into_unannotated() { EntryPointExecutionError::NativeUnrecoverableError(boxed_syscall_error) => { assert!(!validate_constructor); boxed_syscall_error } - _ => panic!("Unexpected error: {boxed_error:?}"), + other => panic!("Unexpected error: {other:?}"), } } TransactionExecutionError::ContractConstructorExecutionFailed( ConstructorEntryPointExecutionError::ExecutionError { error: boxed_error, .. }, - ) => match *boxed_error { + ) => match (*boxed_error).into_unannotated() { EntryPointExecutionError::NativeUnrecoverableError(boxed_syscall_error) => { assert!(validate_constructor); boxed_syscall_error } - _ => panic!("Unexpected error: {boxed_error:?}"), + other => panic!("Unexpected error: {other:?}"), }, _ => panic!("Unexpected error: {:?}", &error), }; diff --git a/crates/blockifier_reexecution/block_numbers_for_reexecution.json b/crates/blockifier_reexecution/block_numbers_for_reexecution.json index a1412ef2fd9..3e9c2cdcd8a 100644 --- a/crates/blockifier_reexecution/block_numbers_for_reexecution.json +++ b/crates/blockifier_reexecution/block_numbers_for_reexecution.json @@ -10,6 +10,7 @@ "0.13.6": 1743490, "0.14.0": 2509604, "0.14.1": 4448394, + "0.14.1_sierra_gas_revert": 6481044, "0.14.2_with_proof_facts": 9023035, "first_0.13.5_rpc_v0_8": 1400000, "second_0.13.5_rpc_v0_8": 1450000, diff --git a/crates/blockifier_reexecution/src/state_reader/offline_state_reader_test.rs b/crates/blockifier_reexecution/src/state_reader/offline_state_reader_test.rs index 2a57a8e5904..2de65b3042b 100644 --- a/crates/blockifier_reexecution/src/state_reader/offline_state_reader_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/offline_state_reader_test.rs @@ -39,6 +39,7 @@ fn reexecute_block_for_testing(block_number: u64) { #[case::v_0_13_6(1743490)] #[case::v_0_14_0(2509604)] #[case::v_0_14_1(4448394)] +#[case::v_0_14_1_sierra_gas_revert(6481044)] #[case::v_0_14_2_with_proof_facts(9023035)] #[case::first_v_0_13_5_rpc_v8(1400000)] #[case::second_v_0_13_5_rpc_v8(1450000)] diff --git a/crates/blockifier_test_utils/resources/feature_contracts/cairo1/cende_test_contract.cairo b/crates/blockifier_test_utils/resources/feature_contracts/cairo1/cende_test_contract.cairo new file mode 100644 index 00000000000..d344a626234 --- /dev/null +++ b/crates/blockifier_test_utils/resources/feature_contracts/cairo1/cende_test_contract.cairo @@ -0,0 +1,125 @@ +// Dedicated feature contract for the cende blob regression test +// (`central_systest_blobs::cende_blob_regression_test::test_make_data`). +// +// The cende test declares and deploys this contract, then exercises it to produce +// the block that is captured into `preconfirmed_block.json` and the blob stored in +// the `apollo-central-systest-blobs` GCS bucket. Using a dedicated contract here +// decouples those goldens from the shared `test_contract`: future changes to +// `test_contract` (the kitchen sink) do NOT churn cende anymore. +// +// New entry points needed by the cende test should be added HERE, not to +// `test_contract`. The functions below are minimal verbatim copies of the +// `test_contract` entry points that the cende test currently invokes. + +#[starknet::contract] +mod CendeTestContract { + use starknet::storage_access::{ + storage_address_from_base_and_offset, storage_base_address_from_felt252, + }; + use starknet::{ + ContractAddress, StorageAddress, storage_read_syscall, storage_write_syscall, syscalls, + }; + use starknet::SyscallResultTrait; + + #[storage] + struct Storage { + my_storage_var: felt252, + } + + #[constructor] + fn constructor(ref self: ContractState, arg1: felt252, arg2: felt252) -> felt252 { + self.my_storage_var.write(arg1 + arg2); + arg1 + } + + #[external(v0)] + fn test_storage_write(ref self: ContractState, address: felt252, value: felt252) { + let domain_address = 0_u32; // Only address_domain 0 is currently supported. + let storage_address = storage_address_from_base_and_offset( + storage_base_address_from_felt252(address), 0_u8, + ); + storage_write_syscall(domain_address, storage_address, value).unwrap_syscall(); + } + + #[external(v0)] + fn test_increment( + ref self: ContractState, ref arg: felt252, arg1: felt252, arg2: felt252, + ) -> felt252 { + let x = self.my_storage_var.read(); + self.my_storage_var.write(x + 1); + x + 1 + } + + #[external(v0)] + fn test_storage_read_write( + self: @ContractState, address: StorageAddress, value: felt252, + ) -> felt252 { + let address_domain = 0; + syscalls::storage_write_syscall(address_domain, address, value).unwrap_syscall(); + syscalls::storage_read_syscall(address_domain, address).unwrap_syscall() + } + + #[external(v0)] + fn write_and_revert(self: @ContractState, address: StorageAddress, value: felt252) { + let address_domain = 0; + syscalls::storage_write_syscall(address_domain, address, value).unwrap_syscall(); + assert(1 == 0, 'Panic for revert'); + } + + #[external(v0)] + #[raw_output] + fn test_call_contract( + self: @ContractState, + contract_address: ContractAddress, + entry_point_selector: felt252, + calldata: Array, + ) -> Span { + syscalls::call_contract_syscall(contract_address, entry_point_selector, calldata.span()) + .unwrap_syscall() + } + + #[external(v0)] + fn write_1(ref self: ContractState, key: StorageAddress) { + let address_domain = 0; + syscalls::storage_write_syscall(address_domain, key, 1).unwrap_syscall(); + // Emit a dummy event and send a dummy L1 message (should be reverted by caller panic). + let dummy_span = array![0].span(); + syscalls::emit_event_syscall(dummy_span, dummy_span).unwrap_syscall(); + syscalls::send_message_to_l1_syscall(17.try_into().unwrap(), dummy_span).unwrap_syscall(); + } + + // call_write_rewrite_panic: calls write_1, then writes storage cell to 2, then panics. + #[external(v0)] + fn call_write_rewrite_panic( + ref self: ContractState, contract_address: ContractAddress, key: StorageAddress, + ) { + // Call write_1 which writes 1 to the storage cell. + let calldata = array![key.into()]; + syscalls::call_contract_syscall(contract_address, selector!("write_1"), calldata.span()) + .unwrap_syscall(); + // Now write 2 to the same storage cell + let address_domain = 0; + syscalls::storage_write_syscall(address_domain, key, 2).unwrap_syscall(); + // Panic to trigger revert + core::panic_with_felt252('call_write_rewrite_panic'); + } + + // catch_write_revert_panic: calls call_write_rewrite_panic and catches/ignores the revert, + // then reads the storage cell to confirm the revert undid the inner writes. + #[external(v0)] + fn catch_write_revert_panic( + ref self: ContractState, contract_address: ContractAddress, key: StorageAddress, + ) -> felt252 { + // Call call_write_rewrite_panic which will revert. + let calldata = array![contract_address.into(), key.into()]; + match syscalls::call_contract_syscall( + contract_address, selector!("call_write_rewrite_panic"), calldata.span(), + ) { + Result::Ok(_) => core::panic_with_felt252('expected_fail'), + Result::Err(_) => {} // Ignore the revert + } + // Read the storage value - should be 0 (original) not 1 (write_1's write) + let address_domain = 0; + syscalls::storage_read_syscall(address_domain, key).unwrap_syscall() + } +} diff --git a/crates/blockifier_test_utils/src/contracts.rs b/crates/blockifier_test_utils/src/contracts.rs index dd3a1ab2f79..78f301c5a61 100644 --- a/crates/blockifier_test_utils/src/contracts.rs +++ b/crates/blockifier_test_utils/src/contracts.rs @@ -77,6 +77,7 @@ const FUZZ_TEST2_BASE: u32 = 20 * CLASS_HASH_BASE; const FUZZ_TEST_ORCHESTRATOR_BASE: u32 = 21 * CLASS_HASH_BASE; const ACCOUNT_WITH_REAL_VALIDATE_BASE: u32 = 22 * CLASS_HASH_BASE; const OS_RESOURCES_TEST_CONTRACT_BASE: u32 = 23 * CLASS_HASH_BASE; +const CENDE_TEST_CONTRACT_BASE: u32 = 24 * CLASS_HASH_BASE; // Contract names. const ACCOUNT_LONG_VALIDATE_NAME: &str = "account_with_long_validate"; @@ -101,6 +102,7 @@ const FUZZ_TEST2_NAME: &str = "fuzz_revert_2"; const FUZZ_TEST_ORCHESTRATOR_NAME: &str = "fuzz_revert_orchestrator"; const ACCOUNT_WITH_REAL_VALIDATE_NAME: &str = "account_with_real_validate"; const OS_RESOURCES_TEST_CONTRACT_NAME: &str = "os_resources_test_contract"; +const CENDE_TEST_CONTRACT_NAME: &str = "cende_test_contract"; // ERC20 contract is in a unique location. const ERC20_CAIRO0_CONTRACT_SOURCE_PATH: &str = "./resources/ERC20/ERC20_Cairo0/ERC20_without_some_syscalls/ERC20/ERC20.cairo"; @@ -144,6 +146,7 @@ pub enum FeatureContract { FuzzTestOrchestrator(RunnableCairo1), AccountWithRealValidate(RunnableCairo1), OsResourcesTest(RunnableCairo1), + CendeTest(RunnableCairo1), } impl FeatureContract { @@ -171,7 +174,8 @@ impl FeatureContract { | Self::FuzzTest2(runnable_version) | Self::FuzzTestOrchestrator(runnable_version) | Self::AccountWithRealValidate(runnable_version) - | Self::OsResourcesTest(runnable_version) => CairoVersion::Cairo1(*runnable_version), + | Self::OsResourcesTest(runnable_version) + | Self::CendeTest(runnable_version) => CairoVersion::Cairo1(*runnable_version), } } @@ -192,7 +196,8 @@ impl FeatureContract { | Self::FuzzTest2(rv) | Self::FuzzTestOrchestrator(rv) | Self::AccountWithRealValidate(rv) - | Self::OsResourcesTest(rv) => match version { + | Self::OsResourcesTest(rv) + | Self::CendeTest(rv) => match version { CairoVersion::Cairo0 => panic!("{self:?} must be Cairo1"), CairoVersion::Cairo1(runnable) => *rv = runnable, }, @@ -335,6 +340,7 @@ impl FeatureContract { Self::FuzzTestOrchestrator(_) => FUZZ_TEST_ORCHESTRATOR_BASE, Self::AccountWithRealValidate(_) => ACCOUNT_WITH_REAL_VALIDATE_BASE, Self::OsResourcesTest(_) => OS_RESOURCES_TEST_CONTRACT_BASE, + Self::CendeTest(_) => CENDE_TEST_CONTRACT_BASE, } } @@ -370,6 +376,7 @@ impl FeatureContract { Self::FuzzTestOrchestrator(_) => FUZZ_TEST_ORCHESTRATOR_NAME, Self::AccountWithRealValidate(_) => ACCOUNT_WITH_REAL_VALIDATE_NAME, Self::OsResourcesTest(_) => OS_RESOURCES_TEST_CONTRACT_NAME, + Self::CendeTest(_) => CENDE_TEST_CONTRACT_NAME, Self::ERC20(_) => unreachable!(), } } @@ -481,7 +488,8 @@ impl FeatureContract { | FeatureContract::FuzzTest2(_) | FeatureContract::FuzzTestOrchestrator(_) | FeatureContract::AccountWithRealValidate(_) - | FeatureContract::OsResourcesTest(_) => None, + | FeatureContract::OsResourcesTest(_) + | FeatureContract::CendeTest(_) => None, FeatureContract::ERC20(_) | FeatureContract::Experimental => unreachable!(), }; cairo0_compile(self.get_source_path(), extra_arg, false) @@ -531,7 +539,8 @@ impl FeatureContract { | Self::FuzzTest2(_) | Self::FuzzTestOrchestrator(_) | Self::AccountWithRealValidate(_) - | Self::OsResourcesTest(_) => { + | Self::OsResourcesTest(_) + | Self::CendeTest(_) => { #[cfg(not(feature = "cairo_native"))] { vec![*self] diff --git a/crates/central_systest_blobs/resources/blob_file_generation b/crates/central_systest_blobs/resources/blob_file_generation index 368f89ceef1..d99e90eb967 100644 --- a/crates/central_systest_blobs/resources/blob_file_generation +++ b/crates/central_systest_blobs/resources/blob_file_generation @@ -1 +1 @@ -28 \ No newline at end of file +29 \ No newline at end of file diff --git a/crates/central_systest_blobs/resources/preconfirmed_block.json b/crates/central_systest_blobs/resources/preconfirmed_block.json index 58535255ff3..94c8428f602 100644 --- a/crates/central_systest_blobs/resources/preconfirmed_block.json +++ b/crates/central_systest_blobs/resources/preconfirmed_block.json @@ -56,7 +56,7 @@ }, "execution_status": "SUCCEEDED", "l2_to_l1_messages": [], - "transaction_hash": "0x659008c3fe8f10af5a7881fa9024d2f714a45f4e3369ab47c8ad39d96f3690b", + "transaction_hash": "0x29253f69c9f9302f0244a058beaa8010bb939fd36c2c98fdb6999e9efa07085", "transaction_index": 0 } ], @@ -74,11 +74,11 @@ "0x6c6a50ee425e9ff35846be376051b8cdbdc1aadc6c954209fe3fd247a571b33": [ { "key": "0x2cbac7495ce24b399327e9282b09d029b1dd772b24b7e8dcd0467fedab5af58", - "value": "0xffffffffffffffffffffffff95c528a3" + "value": "0xfffffffffffffffffffffffff98b7ba3" }, { "key": "0x723973208639b7839ce298f7ffea61e3f9533872defd7abdb91023db4658812", - "value": "0x6a3ad75c" + "value": "0x674845c" } ] } @@ -89,10 +89,10 @@ "account_deployment_data": [], "calldata": [ "0x1", - "0x5cb08f4c5cd70a6b487f883404366d20e7c2805f05081c58c3686d607bfecf9", + "0x43299b38c95de8c24688ff488d375450de78981a4687d495603db8450c4e444", "0x4ea6d2b84c4aea3baab8c031143fcd1fdf95debad5f888784f8db17e1c17f4", "0x2", - "0x37fcf093db894fd16d1a28974e5f73ef150117630132d320f5dce4bb98ce8f4", + "0x2dcde596c118a8c9016ce29e5fc592b285018c772966ade1f3077d8dd6e5bca", "0x2000" ], "fee_data_availability_mode": 0, @@ -116,11 +116,11 @@ }, "sender_address": "0x3d3759cf036b96f8105f40dcf3fe0c209be3419154aa458d03336ad0443ce81", "signature": [ - "0x54fc0a6205b9264b01087ec2dfd5cd18214adf615c6f6e6fc1b1eaa5b440d4a", - "0x297bab83d4745c30bc642161e89b323ce34281e0b1ce0dbff831354cbe3c2b9" + "0x747d3bc3bc45bf165a867f1b3a6c1037faa712995dbb2a3960e3b27b54b1579", + "0xff4f43df4e2a3ceed86d14b6746294c3dbff3322466ae0b2280ad3b4d9d056" ], "tip": "0x0", - "transaction_hash": "0x659008c3fe8f10af5a7881fa9024d2f714a45f4e3369ab47c8ad39d96f3690b", + "transaction_hash": "0x29253f69c9f9302f0244a058beaa8010bb939fd36c2c98fdb6999e9efa07085", "type": "INVOKE_FUNCTION", "version": "0x3" } diff --git a/crates/central_systest_blobs/src/cende_blob_regression_test.rs b/crates/central_systest_blobs/src/cende_blob_regression_test.rs index f02d9ada1bc..6728c96fd0c 100644 --- a/crates/central_systest_blobs/src/cende_blob_regression_test.rs +++ b/crates/central_systest_blobs/src/cende_blob_regression_test.rs @@ -858,7 +858,9 @@ async fn test_make_data() { // (to ensure the preconfirmed block is not empty). let erc20_contract = FeatureContract::ERC20(CairoVersion::Cairo1(RunnableCairo1::Casm)); let account_with_real_validate = FeatureContract::AccountWithRealValidate(RunnableCairo1::Casm); - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); + // Use the cende-dedicated feature contract so additions to the shared `test_contract` + // do not churn this regression's `preconfirmed_block.json` and GCS blob. + let test_contract = FeatureContract::CendeTest(RunnableCairo1::Casm); blob_factory.make_declare_tx(erc20_contract, None); blob_factory.close_block().await; blob_factory.make_declare_tx(account_with_real_validate, None); diff --git a/crates/starknet_proof_verifier/resources/regression_test/0.14.3/example_proof.bin b/crates/starknet_proof_verifier/resources/regression_test/0.14.3/example_proof.bin index dd9c876fbe0..f4776640a79 100644 Binary files a/crates/starknet_proof_verifier/resources/regression_test/0.14.3/example_proof.bin and b/crates/starknet_proof_verifier/resources/regression_test/0.14.3/example_proof.bin differ diff --git a/crates/starknet_transaction_prover/Dockerfile b/crates/starknet_transaction_prover/Dockerfile index c8658c80129..ccfdc742fa7 100644 --- a/crates/starknet_transaction_prover/Dockerfile +++ b/crates/starknet_transaction_prover/Dockerfile @@ -51,6 +51,15 @@ ENV RUSTUP_HOME=/var/tmp/rust ENV CARGO_HOME=${RUSTUP_HOME} ENV PATH="${RUSTUP_HOME}/bin:${PATH}" +# Override the workspace .cargo/config.toml's `rustc-wrapper = "sccache"` for this self-contained +# image build. With sccache active, the final link fails on linux/arm64 with undefined `blst_*` +# symbols from libckzg.a — same failure mode as mozilla/sccache#2359 (reported on x86_64). The +# likely cause is sccache's wrapping of cc-rs assembly compilation, a path added in sccache 0.13 +# via #2545 with known follow-up bugs (#2253, #2556). blst's build.rs feeds `assembly.S` through +# cc-rs, and the wrapped invocation silently produces objects without the native symbols. amd64 +# builds in this pipeline currently avoid the bug; the safe move is to bypass the wrapper here. +ENV RUSTC_WRAPPER="" + # Use the crate-level rust-toolchain.toml (nightly). COPY crates/starknet_transaction_prover/rust-toolchain.toml rust-toolchain.toml @@ -59,7 +68,6 @@ COPY crates/starknet_transaction_prover/rust-toolchain.toml rust-toolchain.toml RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none \ && rustup toolchain install \ && cargo install --locked cargo-chef \ - && RUSTC_WRAPPER="" cargo install --locked sccache --version 0.14.0 \ && rm rust-toolchain.toml # Create Python venv and install cairo-lang (required for compiling Starknet OS). diff --git a/deployments/monitoring/deploy_local_stack.sh b/deployments/monitoring/deploy_local_stack.sh index 3d087451da7..7d9e0fd0b64 100755 --- a/deployments/monitoring/deploy_local_stack.sh +++ b/deployments/monitoring/deploy_local_stack.sh @@ -12,6 +12,21 @@ export SEQUENCER_MONITORING_PORT=${SEQUENCER_MONITORING_PORT:-8082} export SEQUENCER_CONFIG_PATH=${SEQUENCER_CONFIG_PATH:-/config/node_0/config.json} export SEQUENCER_ROOT_DIR=${SEQUENCER_ROOT_DIR:-$(git -C "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")" rev-parse --show-toplevel)} +# Exchange-rate oracle source. When PRAGMA_API_KEY is set, point the node at the real Pragma +# oracle so eth_to_strk (L1 gas price conversion) and strk_to_usd (SNIP-35 fee_target) track live +# rates; otherwise fall back to the dummy constant-rate oracle (see docker-compose.yml +# config_injector). This affects the local stack only; the integration-test harness stays on the +# dummy so CI remains hermetic. +export PRAGMA_ETH_STRK_URL=${PRAGMA_ETH_STRK_URL:-https://api.production.pragma.build/node/v1/data/eth/strk} +export PRAGMA_STRK_USD_URL=${PRAGMA_STRK_USD_URL:-https://api.production.pragma.build/node/v1/data/strk/usd} +if [ -n "${PRAGMA_API_KEY:-}" ]; then + export ETH_STRK_ORACLE_URL_HEADERS="${PRAGMA_ETH_STRK_URL},x-api-key^${PRAGMA_API_KEY}" + export STRK_USD_ORACLE_URL_HEADERS="${PRAGMA_STRK_USD_URL},x-api-key^${PRAGMA_API_KEY}" + echo "Exchange-rate oracle: Pragma (eth/strk + strk/usd)" +else + echo "Exchange-rate oracle: dummy (set PRAGMA_API_KEY to use the real Pragma oracle)" +fi + monitoring_dir=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")") export monitoring_dir diff --git a/deployments/monitoring/local/docker-compose.yml b/deployments/monitoring/local/docker-compose.yml index ddd097fd209..96274fd9772 100644 --- a/deployments/monitoring/local/docker-compose.yml +++ b/deployments/monitoring/local/docker-compose.yml @@ -77,7 +77,10 @@ services: "cp /config/node_0/node_integration_test_config_changes.json ${SEQUENCER_CONFIG_PATH} \ echo 'Injecting config changes...' && \ jq '.\"recorder_url\" = \"http://dummy_recorder:8080\"' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ - jq '.\"l1_gas_price_provider_config.eth_to_strk_oracle_config.url_header_list\" = \"http://dummy_exchange_rate_oracle:9000/eth_to_strk_oracle\"' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ + jq '.\"l1_gas_price_provider_config.eth_to_strk_oracle_config.url_header_list\" = \"${ETH_STRK_ORACLE_URL_HEADERS:-http://dummy_exchange_rate_oracle:9000/eth_to_strk_oracle}\"' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ + jq '.\"l1_gas_price_provider_config.eth_to_strk_oracle_config.lag_interval_seconds\" = ${ETH_STRK_ORACLE_LAG_SECONDS:-60}' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ + jq '.\"l1_gas_price_provider_config.strk_to_usd_oracle_config.url_header_list\" = \"${STRK_USD_ORACLE_URL_HEADERS:-http://dummy_exchange_rate_oracle:9000/eth_to_strk_oracle}\"' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ + jq '.\"l1_gas_price_provider_config.strk_to_usd_oracle_config.lag_interval_seconds\" = ${STRK_USD_ORACLE_LAG_SECONDS:-60}' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ jq '.\"http_server_config.static_config.ip\" = \"0.0.0.0\"' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ jq '.\"http_server_config.static_config.port\" = ${SEQUENCER_HTTP_PORT}' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ jq '.\"monitoring_endpoint_config.port\" = ${SEQUENCER_MONITORING_PORT}' ${SEQUENCER_CONFIG_PATH} | sponge ${SEQUENCER_CONFIG_PATH} && \ diff --git a/deployments/sequencer/configs/overlays/hybrid/common/common.yaml b/deployments/sequencer/configs/overlays/hybrid/common/common.yaml new file mode 100644 index 00000000000..ef9a095d781 --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/common.yaml @@ -0,0 +1,58 @@ +image: + repository: ghcr.io/starkware-libs/sequencer/sequencer + imagePullPolicy: IfNotPresent + +config: + sequencerConfig: + eth_fee_token_address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' + monitoring_endpoint_config.port: 8082 + strk_fee_token_address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d' + versioned_constants_overrides.#is_none: true + versioned_constants_overrides.max_n_events: 1000 + +service: + ports: + - name: monitoring-endpoint + port: 8082 + targetPort: 8082 + protocol: TCP + +startupProbe: + enabled: true + path: /monitoring/alive + successThreshold: 1 + failureThreshold: 30 + periodSeconds: 5 + timeoutSeconds: 2 + +readinessProbe: + enabled: true + path: /monitoring/ready + successThreshold: 2 + failureThreshold: 3 + periodSeconds: 5 + timeoutSeconds: 2 + +livenessProbe: + enabled: true + path: /monitoring/alive + successThreshold: 1 + failureThreshold: 5 + periodSeconds: 10 + timeoutSeconds: 3 + +gcpPodMonitoring: + enabled: true + spec: + endpoints: + - port: 8082 + path: /monitoring/metrics + interval: 10s + +env: +- name: RUST_LOG + value: debug +- name: RUST_BACKTRACE + value: full +- name: NO_COLOR + value: '1' diff --git a/deployments/sequencer/configs/overlays/hybrid/common/services/committer.yaml b/deployments/sequencer/configs/overlays/hybrid/common/services/committer.yaml new file mode 100644 index 00000000000..d1c984607b9 --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/services/committer.yaml @@ -0,0 +1,18 @@ +name: committer +config: + configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_committer.json + sequencerConfig: + committer_config.verify_state_diff_hash: true + components.batcher.port: 55000 + components.batcher.url: sequencer-core-service + components.committer.port: 55013 + components.committer.url: sequencer-committer-service + +service: + enabled: true + type: ClusterIP + ports: + - name: committer + port: 55013 + targetPort: 55013 + protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/common/services/core.yaml b/deployments/sequencer/configs/overlays/hybrid/common/services/core.yaml new file mode 100644 index 00000000000..805c8e56c5b --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/services/core.yaml @@ -0,0 +1,91 @@ +name: core +config: + configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_core.json + sequencerConfig: + batcher_config.dynamic_config.proposer_idle_detection_delay_millis: 2000 + batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.n_events: 5000 + batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.receipt_l2_gas: 5800000000 + batcher_config.static_config.storage_reader_server_static_config.port: 55011 + class_manager_config.static_config.class_manager_config.max_compiled_contract_class_object_size: 4089446 + class_manager_config.static_config.class_storage_config.storage_reader_server_static_config.port: 55210 + consensus_manager_config.consensus_manager_config.dynamic_config.require_virtual_proposer_vote: false + consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.base: 9.1 + consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.max: 9.1 + consensus_manager_config.context_config.dynamic_config.build_proposal_margin_millis: 1000 + consensus_manager_config.context_config.dynamic_config.compare_retrospective_block_hash: true + consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate: 0 + consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate.#is_none: true + consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri: 0 + consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri.#is_none: true + consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri: 0 + consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri.#is_none: true + consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri: 0 + consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri.#is_none: true + consensus_manager_config.network_config.port: 53080 + consensus_manager_config.staking_manager_config.dynamic_config.override_committee: '' + consensus_manager_config.staking_manager_config.dynamic_config.override_committee.#is_none: true + components.batcher.port: 55000 + components.batcher.url: sequencer-core-service + components.class_manager.port: 55001 + components.class_manager.url: sequencer-core-service + components.committer.port: 55013 + components.committer.url: sequencer-committer-service + components.l1_events_provider.port: 55004 + components.l1_events_provider.url: sequencer-l1-service + components.l1_gas_price_provider.port: 55003 + components.l1_gas_price_provider.url: sequencer-l1-service + components.mempool.port: 55006 + components.mempool.url: sequencer-mempool-service + components.proof_manager.port: 55012 + components.proof_manager.url: sequencer-core-service + components.sierra_compiler.port: 55007 + components.sierra_compiler.url: sequencer-sierracompiler-service + components.signature_manager.port: 55008 + components.signature_manager.url: sequencer-core-service + components.state_sync.port: 55009 + components.state_sync.url: sequencer-core-service + state_sync_config.static_config.p2p_sync_client_config.#is_none: true + state_sync_config.static_config.rpc_config.port: 8090 + state_sync_config.static_config.storage_reader_server_static_config.port: 55014 +service: + ports: + - name: batcher + port: 55000 + targetPort: 55000 + protocol: TCP + - name: batcher-storage-reader + port: 55011 + targetPort: 55011 + protocol: TCP + - name: class-manager + port: 55001 + targetPort: 55001 + protocol: TCP + - name: class-manager-storage-reader + port: 55210 + targetPort: 55210 + protocol: TCP + - name: consensus-p2p + port: 53080 + targetPort: 53080 + protocol: TCP + - name: proof-manager + port: 55012 + targetPort: 55012 + protocol: TCP + - name: signature-manager + port: 55008 + targetPort: 55008 + protocol: TCP + - name: state-sync-network + port: 55010 + targetPort: 55010 + protocol: TCP + - name: state-sync-rpc + port: 55009 + targetPort: 55009 + protocol: TCP + - name: state-sync-storage-reader + port: 55014 + targetPort: 55014 + protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/common/services/gateway.yaml b/deployments/sequencer/configs/overlays/hybrid/common/services/gateway.yaml new file mode 100644 index 00000000000..a1f0af46212 --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/services/gateway.yaml @@ -0,0 +1,33 @@ +name: gateway +config: + configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_gateway.json + sequencerConfig: + gateway_config.static_config.authorized_declarer_accounts: '' + gateway_config.static_config.authorized_declarer_accounts.#is_none: true + gateway_config.static_config.stateful_tx_validator_config.max_allowed_nonce_gap: 200 + gateway_config.static_config.stateless_tx_validator_config.max_contract_bytecode_size: 81920 + components.class_manager.port: 55001 + components.class_manager.url: sequencer-core-service + components.gateway.port: 55002 + components.gateway.url: sequencer-gateway-service + components.mempool.port: 55006 + components.mempool.url: sequencer-mempool-service + components.proof_manager.port: 55012 + components.proof_manager.url: sequencer-core-service + components.state_sync.port: 55009 + components.state_sync.url: sequencer-core-service + gateway_config.static_config.stateless_tx_validator_config.min_gas_price: 8000000000 + http_server_config.static_config.port: 8080 + +service: + enabled: true + type: ClusterIP + ports: + - name: gateway + port: 55002 + targetPort: 55002 + protocol: TCP + - name: http-server + port: 8080 + targetPort: 8080 + protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/common/services/l1.yaml b/deployments/sequencer/configs/overlays/hybrid/common/services/l1.yaml new file mode 100644 index 00000000000..b9ef49a8b61 --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/services/l1.yaml @@ -0,0 +1,29 @@ +name: l1 +config: + configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_l1.json + sequencerConfig: + components.batcher.port: 55000 + components.batcher.url: sequencer-core-service + components.l1_events_provider.port: 55004 + components.l1_events_provider.url: sequencer-l1-service + components.l1_gas_price_provider.port: 55003 + components.l1_gas_price_provider.url: sequencer-l1-service + components.state_sync.port: 55009 + components.state_sync.url: sequencer-core-service + +service: + enabled: true + type: ClusterIP + ports: + - name: l1-endpoint-monitoring + port: 55005 + targetPort: 55005 + protocol: TCP + - name: l1-gas-price-provider + port: 55003 + targetPort: 55003 + protocol: TCP + - name: l1-provider + port: 55004 + targetPort: 55004 + protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/common/services/mempool.yaml b/deployments/sequencer/configs/overlays/hybrid/common/services/mempool.yaml new file mode 100644 index 00000000000..fea8c590104 --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/services/mempool.yaml @@ -0,0 +1,24 @@ +name: mempool +config: + configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_mempool.json + sequencerConfig: + components.class_manager.port: 55001 + components.class_manager.url: sequencer-core-service + components.gateway.port: 55002 + components.gateway.url: sequencer-gateway-service + components.mempool.port: 55006 + components.mempool.url: sequencer-mempool-service + components.proof_manager.port: 55012 + components.proof_manager.url: sequencer-core-service + mempool_config.dynamic_config.transaction_ttl: 300 + mempool_p2p_config.network_config.port: 53200 +service: + ports: + - name: mempool + port: 55006 + targetPort: 55006 + protocol: TCP + - name: mempool-p2p-config + port: 53200 + targetPort: 53200 + protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/common/services/sierra-compiler.yaml b/deployments/sequencer/configs/overlays/hybrid/common/services/sierra-compiler.yaml new file mode 100644 index 00000000000..888bda840fa --- /dev/null +++ b/deployments/sequencer/configs/overlays/hybrid/common/services/sierra-compiler.yaml @@ -0,0 +1,16 @@ +name: sierracompiler +config: + configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_sierra_compiler.json + sequencerConfig: + components.sierra_compiler.port: 55007 + components.sierra_compiler.url: sequencer-sierracompiler-service + sierra_compiler_config.max_bytecode_size: 81920 + +service: + enabled: true + type: ClusterIP + ports: + - name: sierra-compiler + port: 55007 + targetPort: 55007 + protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/common.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/common.yaml index bcf70daa243..5a9f0e3bfd6 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/common.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/common.yaml @@ -1,23 +1,11 @@ +include: configs/overlays/hybrid/common/common.yaml + image: - repository: ghcr.io/starkware-libs/sequencer/sequencer tag: APOLLO-0.14.2-RC.6 - imagePullPolicy: IfNotPresent config: sequencerConfig: chain_id: SN_MAIN - eth_fee_token_address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' native_classes_whitelist: '["0x054c5afe61ed27be53b1e4dec5707209a9fcabdb14712fb800fbc60439090115"]' recorder_url: http://starknet-mainnet.cende-recorder-proxy.starknet.io/ starknet_url: https://feeder.alpha-mainnet.starknet.io/ - strk_fee_token_address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d' - versioned_constants_overrides.#is_none: true - versioned_constants_overrides.max_n_events: 1000 - -env: -- name: RUST_LOG - value: debug -- name: RUST_BACKTRACE - value: full -- name: NO_COLOR - value: '1' diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/committer.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/committer.yaml index cb53cc72cf4..89dc0b85b63 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/committer.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/committer.yaml @@ -1,18 +1,5 @@ +include: configs/overlays/hybrid/common/services/committer.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_committer.json sequencerConfig: committer_config.storage_config.cache_size: 50000000 - committer_config.verify_state_diff_hash: true - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.committer.port: 55013 - components.committer.url: sequencer-committer-service - -service: - enabled: true - type: ClusterIP - ports: - - name: committer - port: 55013 - targetPort: 55013 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/core.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/core.yaml index ed47660031a..8c4afe7f9a3 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/core.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/core.yaml @@ -1,61 +1,17 @@ +include: configs/overlays/hybrid/common/services/core.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_core.json sequencerConfig: - batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.n_events: 5000 - batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.receipt_l2_gas: 5800000000 batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.state_diff_size: 5000 batcher_config.static_config.block_builder_config.execute_config.n_workers: 12 batcher_config.dynamic_config.n_concurrent_txs: 100 - batcher_config.dynamic_config.proposer_idle_detection_delay_millis: 2000 batcher_config.static_config.first_block_with_partial_block_hash.#is_none: false batcher_config.static_config.first_block_with_partial_block_hash.block_hash: '0x12889b177c93baa28b5ee3afc80cb6f4836adac086af4bef25ae1ac762e8a62' batcher_config.static_config.first_block_with_partial_block_hash.block_number: 671813 batcher_config.static_config.first_block_with_partial_block_hash.parent_block_hash: '0x1e68b0d22b14688dc97afa3006a53cf4e62ebcb02102e80f55e8b48f9a28b97' - batcher_config.static_config.storage_reader_server_static_config.port: 55011 - class_manager_config.static_config.class_manager_config.max_compiled_contract_class_object_size: 4089446 - class_manager_config.static_config.class_storage_config.storage_reader_server_static_config.port: 55210 - consensus_manager_config.consensus_manager_config.dynamic_config.require_virtual_proposer_vote: false - consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.base: 9.1 - consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.max: 9.1 - consensus_manager_config.context_config.dynamic_config.build_proposal_margin_millis: 1000 - consensus_manager_config.context_config.dynamic_config.compare_retrospective_block_hash: true consensus_manager_config.context_config.dynamic_config.min_l2_gas_price_per_height: '8269292:27400000000,8742344:30100000000' - consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate: 0 - consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri.#is_none: true - consensus_manager_config.network_config.port: 53080 consensus_manager_config.staking_manager_config.dynamic_config.default_committee: 0,10:0x64,1,0x1,true;0x65,1,0x1,true;0x66,1,0x1,true;0x67,1,0x1,true;0x68,1,0x1,true - consensus_manager_config.staking_manager_config.dynamic_config.override_committee: '' - consensus_manager_config.staking_manager_config.dynamic_config.override_committee.#is_none: true - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.committer.port: 55013 - components.committer.url: sequencer-committer-service - components.l1_events_provider.port: 55004 - components.l1_events_provider.url: sequencer-l1-service - components.l1_gas_price_provider.port: 55003 - components.l1_gas_price_provider.url: sequencer-l1-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - components.sierra_compiler.port: 55007 - components.sierra_compiler.url: sequencer-sierracompiler-service - components.signature_manager.port: 55008 - components.signature_manager.url: sequencer-core-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service state_sync_config.static_config.central_sync_client_config.#is_none: false state_sync_config.static_config.central_sync_client_config.sync_config.store_sierras_and_casms_block_threshold: 103129 state_sync_config.static_config.network_config.#is_none: false state_sync_config.static_config.network_config.port: 55010 - state_sync_config.static_config.p2p_sync_client_config.#is_none: true - state_sync_config.static_config.rpc_config.port: 8090 - state_sync_config.static_config.storage_reader_server_static_config.port: 55012 diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/gateway.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/gateway.yaml index c2a1d060beb..e9d1d4e65ef 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/gateway.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/gateway.yaml @@ -1,31 +1,5 @@ +include: configs/overlays/hybrid/common/services/gateway.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_gateway.json sequencerConfig: - gateway_config.static_config.authorized_declarer_accounts: '' - gateway_config.static_config.authorized_declarer_accounts.#is_none: true - gateway_config.static_config.stateful_tx_validator_config.max_allowed_nonce_gap: 200 - gateway_config.static_config.stateless_tx_validator_config.max_contract_bytecode_size: 81920 - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.gateway.port: 55002 - components.gateway.url: sequencer-gateway-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service - gateway_config.static_config.stateless_tx_validator_config.min_gas_price: 8000000000 - -service: - enabled: true - type: ClusterIP - ports: - - name: gateway - port: 55002 - targetPort: 55002 - protocol: TCP - - name: http-server - port: 8080 - targetPort: 8080 - protocol: TCP + gateway_config.static_config.proof_archive_writer_config.bucket_name: starkware-starknet-mainnet diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/l1.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/l1.yaml index d646f4b695c..88aee859e0f 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/l1.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/l1.yaml @@ -1,32 +1,8 @@ +include: configs/overlays/hybrid/common/services/l1.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_l1.json sequencerConfig: base_layer_config.bpo1_start_block_number: 23973546 base_layer_config.bpo2_start_block_number: 24168146 base_layer_config.fusaka_no_bpo_start_block_number: 23934586 base_layer_config.starknet_contract_address: '0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4' - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.l1_events_provider.port: 55004 - components.l1_events_provider.url: sequencer-l1-service - components.l1_gas_price_provider.port: 55003 - components.l1_gas_price_provider.url: sequencer-l1-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service - -service: - enabled: true - type: ClusterIP - ports: - - name: l1-endpoint-monitoring - port: 55005 - targetPort: 55005 - protocol: TCP - - name: l1-gas-price-provider - port: 55003 - targetPort: 55003 - protocol: TCP - - name: l1-provider - port: 55004 - targetPort: 55004 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/mempool.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/mempool.yaml index 990eb0ecb19..79a5a1417cf 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/mempool.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/mempool.yaml @@ -1,12 +1 @@ -config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_mempool.json - sequencerConfig: - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.gateway.port: 55002 - components.gateway.url: sequencer-gateway-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - mempool_config.dynamic_config.transaction_ttl: 300 +include: configs/overlays/hybrid/common/services/mempool.yaml diff --git a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/sierra-compiler.yaml b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/sierra-compiler.yaml index a7420e56962..f8594a62a64 100644 --- a/deployments/sequencer/configs/overlays/hybrid/mainnet/services/sierra-compiler.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/mainnet/services/sierra-compiler.yaml @@ -1,16 +1,5 @@ +include: configs/overlays/hybrid/common/services/sierra-compiler.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_sierra_compiler.json sequencerConfig: sierra_compiler_config.audited_libfuncs_only: true - components.sierra_compiler.port: 55007 - components.sierra_compiler.url: sequencer-sierracompiler-service - sierra_compiler_config.max_bytecode_size: 81920 - -service: - enabled: true - type: ClusterIP - ports: - - name: sierra-compiler - port: 55007 - targetPort: 55007 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/common.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/common.yaml index ae2c7881419..08e9fbd4739 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/common.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/common.yaml @@ -1,23 +1,11 @@ +include: configs/overlays/hybrid/common/common.yaml + image: - repository: ghcr.io/starkware-libs/sequencer/sequencer tag: APOLLO-0.14.2-RC.5 - imagePullPolicy: IfNotPresent config: sequencerConfig: chain_id: SN_SEPOLIA - eth_fee_token_address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' native_classes_whitelist: All recorder_url: http://starknet-sepolia-alpha.cende-recorder-proxy.starknet.io/ starknet_url: https://feeder.alpha-sepolia.starknet.io/ - strk_fee_token_address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d' - versioned_constants_overrides.#is_none: true - versioned_constants_overrides.max_n_events: 1000 - -env: -- name: RUST_LOG - value: debug -- name: RUST_BACKTRACE - value: full -- name: NO_COLOR - value: '1' diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/committer.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/committer.yaml index 75eaa366de1..a63aedfd67c 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/committer.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/committer.yaml @@ -1,18 +1,5 @@ +include: configs/overlays/hybrid/common/services/committer.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_committer.json sequencerConfig: committer_config.storage_config.cache_size: 10000000 - committer_config.verify_state_diff_hash: true - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.committer.port: 55013 - components.committer.url: sequencer-committer-service - -service: - enabled: true - type: ClusterIP - ports: - - name: committer - port: 55013 - targetPort: 55013 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/core.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/core.yaml index b5891ec3d57..fd3e9f2ce1a 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/core.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/core.yaml @@ -1,61 +1,17 @@ +include: configs/overlays/hybrid/common/services/core.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_core.json sequencerConfig: batcher_config.dynamic_config.n_concurrent_txs: 8 - batcher_config.dynamic_config.proposer_idle_detection_delay_millis: 2000 - batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.n_events: 5000 - batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.receipt_l2_gas: 5800000000 batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.state_diff_size: 5000 batcher_config.static_config.block_builder_config.execute_config.n_workers: 5 batcher_config.static_config.first_block_with_partial_block_hash.#is_none: false batcher_config.static_config.first_block_with_partial_block_hash.block_hash: '0x578b4e2f34e4da24e7482de643b4e3435fa7e34770cdb8d71002bb19e415ffa' batcher_config.static_config.first_block_with_partial_block_hash.block_number: 86311 batcher_config.static_config.first_block_with_partial_block_hash.parent_block_hash: '0x5c980ea7747167d2ae98fa7ef7d62f52243e924c453b4934045443d977458d3' - batcher_config.static_config.storage_reader_server_static_config.port: 55011 - class_manager_config.static_config.class_manager_config.max_compiled_contract_class_object_size: 4089446 - class_manager_config.static_config.class_storage_config.storage_reader_server_static_config.port: 55210 - consensus_manager_config.consensus_manager_config.dynamic_config.require_virtual_proposer_vote: false - consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.base: 9.1 - consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.max: 9.1 - consensus_manager_config.context_config.dynamic_config.build_proposal_margin_millis: 1000 - consensus_manager_config.context_config.dynamic_config.compare_retrospective_block_hash: true consensus_manager_config.context_config.dynamic_config.min_l2_gas_price_per_height: '' - consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate: 0 - consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri.#is_none: true - consensus_manager_config.network_config.port: 53080 consensus_manager_config.staking_manager_config.dynamic_config.default_committee: 0,10:0x64,1,0x1,true;0x65,1,0x1,true;0x66,1,0x1,true;0x67,1,0x1,true;0x68,1,0x1,true - consensus_manager_config.staking_manager_config.dynamic_config.override_committee: '' - consensus_manager_config.staking_manager_config.dynamic_config.override_committee.#is_none: true - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.committer.port: 55013 - components.committer.url: sequencer-committer-service - components.l1_events_provider.port: 55004 - components.l1_events_provider.url: sequencer-l1-service - components.l1_gas_price_provider.port: 55003 - components.l1_gas_price_provider.url: sequencer-l1-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - components.sierra_compiler.port: 55007 - components.sierra_compiler.url: sequencer-sierracompiler-service - components.signature_manager.port: 55008 - components.signature_manager.url: sequencer-core-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service state_sync_config.static_config.central_sync_client_config.#is_none: false state_sync_config.static_config.central_sync_client_config.sync_config.store_sierras_and_casms_block_threshold: 0 state_sync_config.static_config.network_config.#is_none: true state_sync_config.static_config.network_config.port: 55010 - state_sync_config.static_config.p2p_sync_client_config.#is_none: true - state_sync_config.static_config.rpc_config.port: 8090 - state_sync_config.static_config.storage_reader_server_static_config.port: 55012 diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/gateway.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/gateway.yaml index c2a1d060beb..591e51079ef 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/gateway.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/gateway.yaml @@ -1,31 +1,5 @@ +include: configs/overlays/hybrid/common/services/gateway.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_gateway.json sequencerConfig: - gateway_config.static_config.authorized_declarer_accounts: '' - gateway_config.static_config.authorized_declarer_accounts.#is_none: true - gateway_config.static_config.stateful_tx_validator_config.max_allowed_nonce_gap: 200 - gateway_config.static_config.stateless_tx_validator_config.max_contract_bytecode_size: 81920 - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.gateway.port: 55002 - components.gateway.url: sequencer-gateway-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service - gateway_config.static_config.stateless_tx_validator_config.min_gas_price: 8000000000 - -service: - enabled: true - type: ClusterIP - ports: - - name: gateway - port: 55002 - targetPort: 55002 - protocol: TCP - - name: http-server - port: 8080 - targetPort: 8080 - protocol: TCP + gateway_config.static_config.proof_archive_writer_config.bucket_name: starkware-starknet-alpha diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/l1.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/l1.yaml index 5b6c7a123de..f02a0f7a6bc 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/l1.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/l1.yaml @@ -1,32 +1,8 @@ +include: configs/overlays/hybrid/common/services/l1.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_l1.json sequencerConfig: base_layer_config.bpo1_start_block_number: 9456501 base_layer_config.bpo2_start_block_number: 9504747 base_layer_config.fusaka_no_bpo_start_block_number: 9408577 base_layer_config.starknet_contract_address: '0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057' - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.l1_events_provider.port: 55004 - components.l1_events_provider.url: sequencer-l1-service - components.l1_gas_price_provider.port: 55003 - components.l1_gas_price_provider.url: sequencer-l1-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service - -service: - enabled: true - type: ClusterIP - ports: - - name: l1-endpoint-monitoring - port: 55005 - targetPort: 55005 - protocol: TCP - - name: l1-gas-price-provider - port: 55003 - targetPort: 55003 - protocol: TCP - - name: l1-provider - port: 55004 - targetPort: 55004 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/mempool.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/mempool.yaml index 990eb0ecb19..79a5a1417cf 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/mempool.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/mempool.yaml @@ -1,12 +1 @@ -config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_mempool.json - sequencerConfig: - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.gateway.port: 55002 - components.gateway.url: sequencer-gateway-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - mempool_config.dynamic_config.transaction_ttl: 300 +include: configs/overlays/hybrid/common/services/mempool.yaml diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/sierra-compiler.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/sierra-compiler.yaml index a7420e56962..f8594a62a64 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/sierra-compiler.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-alpha/services/sierra-compiler.yaml @@ -1,16 +1,5 @@ +include: configs/overlays/hybrid/common/services/sierra-compiler.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_sierra_compiler.json sequencerConfig: sierra_compiler_config.audited_libfuncs_only: true - components.sierra_compiler.port: 55007 - components.sierra_compiler.url: sequencer-sierracompiler-service - sierra_compiler_config.max_bytecode_size: 81920 - -service: - enabled: true - type: ClusterIP - ports: - - name: sierra-compiler - port: 55007 - targetPort: 55007 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/common.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/common.yaml index 2688e0ea946..766dfa09fb9 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/common.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/common.yaml @@ -1,23 +1,11 @@ +include: configs/overlays/hybrid/common/common.yaml + image: - repository: ghcr.io/starkware-libs/sequencer/sequencer tag: APOLLO-0.14.2-RC.7 - imagePullPolicy: IfNotPresent config: sequencerConfig: chain_id: SN_INTEGRATION_SEPOLIA - eth_fee_token_address: '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7' native_classes_whitelist: All recorder_url: http://starknet-sepolia-integration.cende-recorder-proxy.starknet.io/ starknet_url: https://feeder.integration-sepolia.starknet.io/ - strk_fee_token_address: '0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d' - versioned_constants_overrides.#is_none: true - versioned_constants_overrides.max_n_events: 1000 - -env: -- name: RUST_LOG - value: debug -- name: RUST_BACKTRACE - value: full -- name: NO_COLOR - value: '1' diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/committer.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/committer.yaml index 75eaa366de1..a63aedfd67c 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/committer.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/committer.yaml @@ -1,18 +1,5 @@ +include: configs/overlays/hybrid/common/services/committer.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_committer.json sequencerConfig: committer_config.storage_config.cache_size: 10000000 - committer_config.verify_state_diff_hash: true - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.committer.port: 55013 - components.committer.url: sequencer-committer-service - -service: - enabled: true - type: ClusterIP - ports: - - name: committer - port: 55013 - targetPort: 55013 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/core.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/core.yaml index cf0c41e6b42..14a99072ab8 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/core.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/core.yaml @@ -1,61 +1,17 @@ +include: configs/overlays/hybrid/common/services/core.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_core.json sequencerConfig: batcher_config.dynamic_config.n_concurrent_txs: 100 - batcher_config.dynamic_config.proposer_idle_detection_delay_millis: 2000 - batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.n_events: 5000 - batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.receipt_l2_gas: 5800000000 batcher_config.static_config.block_builder_config.bouncer_config.block_max_capacity.state_diff_size: 4000 batcher_config.static_config.block_builder_config.execute_config.n_workers: 1 batcher_config.static_config.first_block_with_partial_block_hash.#is_none: false batcher_config.static_config.first_block_with_partial_block_hash.block_hash: '0x1ea2a9cfa3df5297d58c0a04d09d276bc68d40fe64701305bbe2ed8f417e869' batcher_config.static_config.first_block_with_partial_block_hash.block_number: 35748 batcher_config.static_config.first_block_with_partial_block_hash.parent_block_hash: '0x77140bef51bbb4d1932f17cc5081825ff18465a1df4440ca0429a4fa80f1dc5' - batcher_config.static_config.storage_reader_server_static_config.port: 55011 - class_manager_config.static_config.class_manager_config.max_compiled_contract_class_object_size: 4089446 - class_manager_config.static_config.class_storage_config.storage_reader_server_static_config.port: 55210 - consensus_manager_config.consensus_manager_config.dynamic_config.require_virtual_proposer_vote: false - consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.base: 9.1 - consensus_manager_config.consensus_manager_config.dynamic_config.timeouts.proposal.max: 9.1 - consensus_manager_config.context_config.dynamic_config.build_proposal_margin_millis: 1000 - consensus_manager_config.context_config.dynamic_config.compare_retrospective_block_hash: true consensus_manager_config.context_config.dynamic_config.min_l2_gas_price_per_height: '' - consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate: 0 - consensus_manager_config.context_config.dynamic_config.override_eth_to_fri_rate.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l1_data_gas_price_fri.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l1_gas_price_fri.#is_none: true - consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri: 0 - consensus_manager_config.context_config.dynamic_config.override_l2_gas_price_fri.#is_none: true - consensus_manager_config.network_config.port: 53080 consensus_manager_config.staking_manager_config.dynamic_config.default_committee: 0,10:0x64,1,0x1,true;0x65,1,0x1,true;0x66,1,0x1,true - consensus_manager_config.staking_manager_config.dynamic_config.override_committee: '' - consensus_manager_config.staking_manager_config.dynamic_config.override_committee.#is_none: true - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.committer.port: 55013 - components.committer.url: sequencer-committer-service - components.l1_events_provider.port: 55004 - components.l1_events_provider.url: sequencer-l1-service - components.l1_gas_price_provider.port: 55003 - components.l1_gas_price_provider.url: sequencer-l1-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - components.sierra_compiler.port: 55007 - components.sierra_compiler.url: sequencer-sierracompiler-service - components.signature_manager.port: 55008 - components.signature_manager.url: sequencer-core-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service state_sync_config.static_config.central_sync_client_config.#is_none: false state_sync_config.static_config.central_sync_client_config.sync_config.store_sierras_and_casms_block_threshold: 0 state_sync_config.static_config.network_config.#is_none: true state_sync_config.static_config.network_config.port: 55010 - state_sync_config.static_config.p2p_sync_client_config.#is_none: true - state_sync_config.static_config.rpc_config.port: 8090 - state_sync_config.static_config.storage_reader_server_static_config.port: 55012 diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/gateway.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/gateway.yaml index c2a1d060beb..f3211b62c29 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/gateway.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/gateway.yaml @@ -1,31 +1,5 @@ +include: configs/overlays/hybrid/common/services/gateway.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_gateway.json sequencerConfig: - gateway_config.static_config.authorized_declarer_accounts: '' - gateway_config.static_config.authorized_declarer_accounts.#is_none: true - gateway_config.static_config.stateful_tx_validator_config.max_allowed_nonce_gap: 200 - gateway_config.static_config.stateless_tx_validator_config.max_contract_bytecode_size: 81920 - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.gateway.port: 55002 - components.gateway.url: sequencer-gateway-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service - gateway_config.static_config.stateless_tx_validator_config.min_gas_price: 8000000000 - -service: - enabled: true - type: ClusterIP - ports: - - name: gateway - port: 55002 - targetPort: 55002 - protocol: TCP - - name: http-server - port: 8080 - targetPort: 8080 - protocol: TCP + gateway_config.static_config.proof_archive_writer_config.bucket_name: starkware-starknet-integration diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/l1.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/l1.yaml index 479dc180330..add18c59d72 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/l1.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/l1.yaml @@ -1,32 +1,8 @@ +include: configs/overlays/hybrid/common/services/l1.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_l1.json sequencerConfig: base_layer_config.bpo1_start_block_number: 9456501 base_layer_config.bpo2_start_block_number: 9504747 base_layer_config.fusaka_no_bpo_start_block_number: 9408577 base_layer_config.starknet_contract_address: '0x4737c0c1B4D5b1A687B42610DdabEE781152359c' - components.batcher.port: 55000 - components.batcher.url: sequencer-core-service - components.l1_events_provider.port: 55004 - components.l1_events_provider.url: sequencer-l1-service - components.l1_gas_price_provider.port: 55003 - components.l1_gas_price_provider.url: sequencer-l1-service - components.state_sync.port: 55009 - components.state_sync.url: sequencer-core-service - -service: - enabled: true - type: ClusterIP - ports: - - name: l1-endpoint-monitoring - port: 55005 - targetPort: 55005 - protocol: TCP - - name: l1-gas-price-provider - port: 55003 - targetPort: 55003 - protocol: TCP - - name: l1-provider - port: 55004 - targetPort: 55004 - protocol: TCP diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/mempool.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/mempool.yaml index 990eb0ecb19..79a5a1417cf 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/mempool.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/mempool.yaml @@ -1,12 +1 @@ -config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_mempool.json - sequencerConfig: - components.class_manager.port: 55001 - components.class_manager.url: sequencer-core-service - components.gateway.port: 55002 - components.gateway.url: sequencer-gateway-service - components.mempool.port: 55006 - components.mempool.url: sequencer-mempool-service - components.proof_manager.port: 55012 - components.proof_manager.url: sequencer-core-service - mempool_config.dynamic_config.transaction_ttl: 300 +include: configs/overlays/hybrid/common/services/mempool.yaml diff --git a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/sierra-compiler.yaml b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/sierra-compiler.yaml index b1546a97802..d17c4e49f0d 100644 --- a/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/sierra-compiler.yaml +++ b/deployments/sequencer/configs/overlays/hybrid/sepolia-integration/services/sierra-compiler.yaml @@ -1,16 +1,5 @@ +include: configs/overlays/hybrid/common/services/sierra-compiler.yaml + config: - configList: crates/apollo_deployments/resources/services/hybrid/replacer_deployment_sierra_compiler.json sequencerConfig: sierra_compiler_config.audited_libfuncs_only: false - components.sierra_compiler.port: 55007 - components.sierra_compiler.url: sequencer-sierracompiler-service - sierra_compiler_config.max_bytecode_size: 81920 - -service: - enabled: true - type: ClusterIP - ports: - - name: sierra-compiler - port: 55007 - targetPort: 55007 - protocol: TCP diff --git a/deployments/sequencer/src/config/merger.py b/deployments/sequencer/src/config/merger.py index 12be87995af..586818e3f52 100644 --- a/deployments/sequencer/src/config/merger.py +++ b/deployments/sequencer/src/config/merger.py @@ -1,7 +1,6 @@ from copy import deepcopy from pathlib import Path -import yaml from rich.markup import escape as escape_markup from src.config.loaders import DeploymentConfigLoader from src.config.overlay import ( @@ -29,14 +28,19 @@ def _flatten_dict_to_paths(d: dict, prefix: str = "") -> set[str]: return out -def _load_common_yaml(path: str) -> dict | None: - """Load and validate common.yaml; return dict or None if file missing/invalid.""" +def _load_common_yaml(path: str, config_base_dir: str | None = None) -> dict | None: + """Load and validate common.yaml; return dict or None if file missing/invalid. Supports include:.""" p = Path(path) if not p.is_file(): return None - with open(p, "r", encoding="utf-8") as f: - raw = yaml.safe_load(f) or {} - validated = CommonConfig.model_validate(raw) + loader = DeploymentConfigLoader( + configs_dir_path=str(p.parent), + config_base_dir=config_base_dir or str(p.parent), + ) + merged = loader._load_one_file_with_includes(p) + if not merged: + return None + validated = CommonConfig.model_validate(merged) return validated.model_dump(mode="python", exclude_unset=True, exclude_none=True) @@ -150,7 +154,9 @@ def merge_configs( # --- Load layout configs --- layout_common = ( - _load_common_yaml(layout_common_config_path) if layout_common_config_path else None + _load_common_yaml(layout_common_config_path, config_base_dir) + if layout_common_config_path + else None ) layout_loader = DeploymentConfigLoader( configs_dir_path=layout_services_config_dir_path, @@ -182,7 +188,7 @@ def merge_configs( service_path_to_overlays[key].append(overlay_name) merged_services = apply_services_overlay_strict(merged_services, overlay_services) if overlay_common_path: - overlay_common = _load_common_yaml(overlay_common_path) + overlay_common = _load_common_yaml(overlay_common_path, config_base_dir) if overlay_common is not None: for key_path in _flatten_dict_to_paths(overlay_common): if key_path not in common_path_to_overlays: