Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 249 additions & 0 deletions crates/scroll/alloy/evm/src/block/galileo_v2.rs

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions crates/scroll/alloy/evm/src/block/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod curie;
pub mod feynman;
pub mod galileo_v2;

pub use receipt_builder::{ReceiptBuilderCtx, ScrollReceiptBuilder};
mod receipt_builder;
Expand All @@ -8,6 +9,7 @@ use crate::{
block::{
curie::{apply_curie_hard_fork, L1_GAS_PRICE_ORACLE_ADDRESS},
feynman::apply_feynman_hard_fork,
galileo_v2::apply_galileo_v2_hard_fork,
},
system_caller::ScrollSystemCaller,
FromTxWithCompressionInfo, ScrollDefaultPrecompilesFactory, ScrollEvm, ScrollEvmFactory,
Expand Down Expand Up @@ -192,6 +194,20 @@ where
};
}

// apply gas oracle predeploy upgrade at GalileoV2 transition block.
#[allow(clippy::collapsible_if)]
if self
.spec
.scroll_fork_activation(ScrollHardfork::GalileoV2)
.active_at_timestamp(self.evm.block().timestamp().to())
{
if let Err(err) = apply_galileo_v2_hard_fork(self.evm.db_mut()) {
return Err(BlockExecutionError::msg(format!(
"error occurred at GalileoV2 fork: {err:?}"
)));
};
}

// apply eip-2935.
self.system_caller.apply_blockhashes_contract_call(self.ctx.parent_hash, &mut self.evm)?;

Expand Down
4 changes: 2 additions & 2 deletions crates/scroll/alloy/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

mod block;
pub use block::{
curie, feynman, EvmExt, ReceiptBuilderCtx, ScrollBlockExecutionCtx, ScrollBlockExecutor,
ScrollBlockExecutorFactory, ScrollReceiptBuilder, ScrollTxCompressionInfo,
curie, feynman, galileo_v2, EvmExt, ReceiptBuilderCtx, ScrollBlockExecutionCtx,
ScrollBlockExecutor, ScrollBlockExecutorFactory, ScrollReceiptBuilder, ScrollTxCompressionInfo,
ScrollTxCompressionInfos,
};

Expand Down
8 changes: 8 additions & 0 deletions crates/scroll/alloy/evm/src/tx/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ mod tests {
assert_eq!(ratio, U256::from(1_298_578_199u64)); // 1.3x
assert_eq!(size, 422);

// galileo-mismatch
// https://scrollscan.com/tx/0x773daae3ac1d31cf0ac76dc25504fe76ad5458c7df9578161898b73bd8039c90
let bytes = bytes!("0xf901ae8265f68301d52c8307040d94c9c35e593842c3d5e71304b2291e204583226e2a80b90144412658e5000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000fe0000000000000000000000000000000000000000020027004f00a500d100d500d900dd00ed00fd530000000000000000000000000000000000000406efdbff2a14a7c8e15944d1f4a48f9f95f663a4005300903c813df550a32d4a9d42010d057386429ad2328ed906efdbff2a14a7c8e15944d1f4a48f9f95f663a4530000000000000000000000000000000000000414ffa10b2019d6eb63140ef4b5026c7e049936bfeb00a900bdfeec4e40c170ef3736dc9a29389fb8cd7ed12409ae7bb52a3614ac5b66389d8873a8cb9f45f817c500a900bd000500010000000000000000000000000000187abb94380e0000000000000000000000092f2a085c00000083104ec3a0e3c466f58aa6edab61bd5f2bab117804d6f3cf125a815e53c161c02df8209d09a0267df663ab1cb9a5c85441df5051a7a03623b946a87ff42af694fc21e40f34fb");
let ratio = compute_compression_ratio(&bytes);
let size = compute_compressed_size(&bytes);
assert_eq!(ratio, U256::from(1_438_538_205u64)); // 1.4x
assert_eq!(size, 301);

Ok(())
}
}
10 changes: 8 additions & 2 deletions crates/scroll/alloy/hardforks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ hardfork!(
Feynman,
/// Galileo <https://docs.scroll.io/en/technology/overview/scroll-upgrades/galileo-upgrade/>
Galileo,
/// GalileoV2 <https://docs.scroll.io/en/technology/overview/scroll-upgrades/galileo-upgrade/>
GalileoV2,
}
);

impl ScrollHardfork {
/// Scroll mainnet list of hardforks.
pub const fn scroll_mainnet() -> [(Self, ForkCondition); 9] {
pub const fn scroll_mainnet() -> [(Self, ForkCondition); 10] {
[
(Self::Archimedes, ForkCondition::Block(0)),
(Self::Bernoulli, ForkCondition::Block(5220340)),
Expand All @@ -40,11 +42,12 @@ impl ScrollHardfork {
(Self::EuclidV2, ForkCondition::Timestamp(1745305200)),
(Self::Feynman, ForkCondition::Timestamp(1755576000)),
(Self::Galileo, ForkCondition::Timestamp(u64::MAX)),
(Self::GalileoV2, ForkCondition::Timestamp(u64::MAX)),
]
}

/// Scroll sepolia list of hardforks.
pub const fn scroll_sepolia() -> [(Self, ForkCondition); 9] {
pub const fn scroll_sepolia() -> [(Self, ForkCondition); 10] {
[
(Self::Archimedes, ForkCondition::Block(0)),
(Self::Bernoulli, ForkCondition::Block(3747132)),
Expand All @@ -55,6 +58,7 @@ impl ScrollHardfork {
(Self::EuclidV2, ForkCondition::Timestamp(1741852800)),
(Self::Feynman, ForkCondition::Timestamp(1753167600)),
(Self::Galileo, ForkCondition::Timestamp(1764054000)),
(Self::GalileoV2, ForkCondition::Timestamp(u64::MAX)),
]
}
}
Expand All @@ -75,6 +79,7 @@ mod tests {
"eUClidv2",
"FEYnmaN",
"gaLiLEo",
"gaLiLEov2",
];
let expected_hardforks = [
ScrollHardfork::Bernoulli,
Expand All @@ -85,6 +90,7 @@ mod tests {
ScrollHardfork::EuclidV2,
ScrollHardfork::Feynman,
ScrollHardfork::Galileo,
ScrollHardfork::GalileoV2,
];

let hardforks: Vec<ScrollHardfork> =
Expand Down
6 changes: 6 additions & 0 deletions crates/scroll/alloy/hardforks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ pub trait ScrollHardforks: EthereumHardforks {
fn is_galileo_active_at_timestamp(&self, timestamp: u64) -> bool {
self.scroll_fork_activation(ScrollHardfork::Galileo).active_at_timestamp(timestamp)
}

/// Returns `true` if [`GalileoV2`](ScrollHardfork::GalileoV2) is active at given block
/// timestamp.
fn is_galileo_v2_active_at_timestamp(&self, timestamp: u64) -> bool {
self.scroll_fork_activation(ScrollHardfork::GalileoV2).active_at_timestamp(timestamp)
}
}

/// A type allowing to configure activation [`ForkCondition`]s for a given list of
Expand Down
8 changes: 7 additions & 1 deletion crates/scroll/chainspec/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub struct ScrollHardforkInfo {
pub feynman_time: Option<u64>,
/// galileo hardfork timestamp
pub galileo_time: Option<u64>,
/// galileoV2 hardfork timestamp
pub galileo_v2_time: Option<u64>,
}

impl ScrollHardforkInfo {
Expand Down Expand Up @@ -190,7 +192,8 @@ mod tests {
"darwinTime": 0,
"euclidTime": 11,
"feynmanTime": 100,
"galileoTime": 110
"galileoTime": 110,
"galileoV2Time": 120
}
"#;

Expand All @@ -209,6 +212,7 @@ mod tests {
euclid_v2_time: None,
feynman_time: Some(100),
galileo_time: Some(110),
galileo_v2_time: Some(120),
}
);
}
Expand All @@ -224,6 +228,7 @@ mod tests {
"euclidTime": 11,
"feynmanTime": 100,
"galileoTime": 110,
"galileoV2Time": 120,
"scroll": {
"feeVaultAddress": "0x5300000000000000000000000000000000000005",
"maxTxPayloadBytesPerBlock": 122880,
Expand Down Expand Up @@ -253,6 +258,7 @@ mod tests {
euclid_v2_time: None,
feynman_time: Some(100),
galileo_time: Some(110),
galileo_v2_time: Some(120),
}),
scroll_chain_config: ScrollChainConfig {
fee_vault_address: Some(address!("5300000000000000000000000000000000000005")),
Expand Down
14 changes: 14 additions & 0 deletions crates/scroll/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ impl ScrollChainSpecBuilder {
self
}

/// Enable `GalileoV2` at genesis
pub fn galileo_v2_activated(mut self) -> Self {
self = self.feynman_activated();
self.inner = self.inner.with_fork(ScrollHardfork::GalileoV2, ForkCondition::Timestamp(0));
self
}

/// Build the resulting [`ScrollChainSpec`].
///
/// # Panics
Expand Down Expand Up @@ -446,6 +453,7 @@ impl From<Genesis> for ScrollChainSpec {
(ScrollHardfork::EuclidV2.boxed(), hard_fork_info.euclid_v2_time),
(ScrollHardfork::Feynman.boxed(), hard_fork_info.feynman_time),
(ScrollHardfork::Galileo.boxed(), hard_fork_info.galileo_time),
(ScrollHardfork::GalileoV2.boxed(), hard_fork_info.galileo_v2_time),
];

let mut time_hardforks = time_hardfork_opts
Expand Down Expand Up @@ -765,6 +773,8 @@ mod tests {
assert_eq!(actual_feynman_timestamp, Some(serde_json::Value::from(34)).as_ref());
let actual_galileo_timestamp = genesis.config.extra_fields.get("galileoTime");
assert_eq!(actual_galileo_timestamp, Some(serde_json::Value::from(35)).as_ref());
let actual_galileo_v2_timestamp = genesis.config.extra_fields.get("galileoV2Time");
assert_eq!(actual_galileo_v2_timestamp, Some(serde_json::Value::from(36)).as_ref());

let scroll_object = genesis.config.extra_fields.get("scroll").unwrap();
assert_eq!(
Expand Down Expand Up @@ -793,6 +803,7 @@ mod tests {
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::EuclidV2, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Feynman, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Galileo, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(ScrollHardfork::GalileoV2, 0));

assert!(chain_spec.is_fork_active_at_block(ScrollHardfork::Bernoulli, 10));
assert!(chain_spec.is_fork_active_at_block(ScrollHardfork::Curie, 20));
Expand All @@ -802,6 +813,7 @@ mod tests {
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::EuclidV2, 33));
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Feynman, 34));
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::Galileo, 35));
assert!(chain_spec.is_fork_active_at_timestamp(ScrollHardfork::GalileoV2, 36));
}

#[test]
Expand Down Expand Up @@ -830,6 +842,7 @@ mod tests {
(String::from("darwinV2Time"), 0.into()),
(String::from("feynmanTime"), 0.into()),
(String::from("galileoTime"), 0.into()),
(String::from("galileoV2Time"), 0.into()),
(
String::from("scroll"),
serde_json::json!({
Expand Down Expand Up @@ -874,6 +887,7 @@ mod tests {
ScrollHardfork::DarwinV2.boxed(),
ScrollHardfork::Feynman.boxed(),
ScrollHardfork::Galileo.boxed(),
ScrollHardfork::GalileoV2.boxed(),
];

assert!(expected_hardforks
Expand Down
33 changes: 31 additions & 2 deletions crates/scroll/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mod tests {
L1_GAS_PRICE_ORACLE_ADDRESS,
},
feynman::{IS_FEYNMAN_SLOT, PENALTY_FACTOR_SLOT, PENALTY_THRESHOLD_SLOT},
galileo_v2::IS_GALILEO_SLOT,
ScrollBlockExecutionCtx, ScrollBlockExecutor, ScrollEvm, ScrollTxCompressionInfos,
};
use scroll_alloy_hardforks::ScrollHardforks;
Expand Down Expand Up @@ -231,7 +232,21 @@ mod tests {

// determine l1 gas oracle storage
let l1_gas_oracle_storage =
if strategy.spec().is_feynman_active_at_timestamp(block_timestamp) {
if strategy.spec().is_galileo_v2_active_at_timestamp(block_timestamp) {
vec![
(L1_BLOB_BASE_FEE_SLOT, U256::from(1000)),
(OVER_HEAD_SLOT, U256::from(1000)),
(SCALAR_SLOT, U256::from(1000)),
(L1_BLOB_BASE_FEE_SLOT, U256::from(10000)),
(COMMIT_SCALAR_SLOT, U256::from(1000)),
(BLOB_SCALAR_SLOT, U256::from(10000)),
(IS_CURIE_SLOT, U256::from(1)),
(PENALTY_THRESHOLD_SLOT, U256::from(1_000_000_000u64)),
(PENALTY_FACTOR_SLOT, U256::from(1_000_000_000u64)),
(IS_FEYNMAN_SLOT, U256::from(1)),
(IS_GALILEO_SLOT, U256::from(1)),
]
} else if strategy.spec().is_feynman_active_at_timestamp(block_timestamp) {
vec![
(L1_BLOB_BASE_FEE_SLOT, U256::from(1000)),
(OVER_HEAD_SLOT, U256::from(1000)),
Expand Down Expand Up @@ -304,7 +319,21 @@ mod tests {

// determine l1 gas oracle storage
let l1_gas_oracle_storage =
if strategy.spec().is_feynman_active_at_timestamp(block_timestamp) {
if strategy.spec().is_galileo_v2_active_at_timestamp(block_timestamp) {
vec![
(L1_BLOB_BASE_FEE_SLOT, U256::from(1000)),
(OVER_HEAD_SLOT, U256::from(1000)),
(SCALAR_SLOT, U256::from(1000)),
(L1_BLOB_BASE_FEE_SLOT, U256::from(10000)),
(COMMIT_SCALAR_SLOT, U256::from(1000)),
(BLOB_SCALAR_SLOT, U256::from(10000)),
(IS_CURIE_SLOT, U256::from(1)),
(PENALTY_THRESHOLD_SLOT, U256::from(2_000_000_000u64)), // penalty if <2x
(PENALTY_FACTOR_SLOT, U256::from(10_000_000_000u64)), // 10x penalty
(IS_FEYNMAN_SLOT, U256::from(1)),
(IS_GALILEO_SLOT, U256::from(1)),
]
} else if strategy.spec().is_feynman_active_at_timestamp(block_timestamp) {
vec![
(L1_BLOB_BASE_FEE_SLOT, U256::from(1000)),
(OVER_HEAD_SLOT, U256::from(1000)),
Expand Down
5 changes: 5 additions & 0 deletions crates/scroll/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ pub fn spec_id_at_timestamp_and_number(
chain_spec: impl ScrollHardforks,
) -> ScrollSpecId {
if chain_spec
.scroll_fork_activation(ScrollHardfork::GalileoV2)
.active_at_timestamp_or_number(timestamp, number)
{
ScrollSpecId::GALILEO
} else if chain_spec
.scroll_fork_activation(ScrollHardfork::Galileo)
.active_at_timestamp_or_number(timestamp, number)
{
Expand Down
Loading