Skip to content

Commit 871daf2

Browse files
committed
add galileo fee test
1 parent 97cb53e commit 871daf2

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

crates/scroll/alloy/hardforks/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#[cfg(not(feature = "std"))]
55
extern crate alloc as std;
66

7-
use alloy_hardforks::{EthereumHardfork, EthereumHardforks, ForkCondition};
7+
pub use alloy_hardforks::ForkCondition;
8+
use alloy_hardforks::{EthereumHardfork, EthereumHardforks};
89
use std::vec::Vec;
910

1011
pub use hardfork::ScrollHardfork;

crates/scroll/evm/src/execute.rs

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mod tests {
8282
gas_price_oracle::*,
8383
ScrollBlockExecutionCtx, ScrollBlockExecutor, ScrollEvm, ScrollTxCompressionInfos,
8484
};
85-
use scroll_alloy_hardforks::ScrollHardforks;
85+
use scroll_alloy_hardforks::{ForkCondition, ScrollHardfork, ScrollHardforks};
8686

8787
const BLOCK_GAS_LIMIT: u64 = 10_000_000;
8888
const SCROLL_CHAIN_ID: u64 = 534352;
@@ -91,6 +91,7 @@ mod tests {
9191
const EUCLID_V2_BLOCK_NUMBER: u64 = 14907015;
9292
const EUCLID_V2_BLOCK_TIMESTAMP: u64 = 1745305200;
9393
const FEYNMAN_BLOCK_TIMESTAMP: u64 = 1755576000;
94+
const GALILEO_BLOCK_TIMESTAMP: u64 = 1755576001; // TODO(thegaram): update to actual timestamp
9495

9596
fn state() -> State<EmptyDBTyped<Infallible>> {
9697
let db = EmptyDBTyped::<Infallible>::new();
@@ -106,8 +107,10 @@ mod tests {
106107
ScrollRethReceiptBuilder,
107108
Arc<ScrollChainSpec>,
108109
> {
109-
let chain_spec =
110-
Arc::new(ScrollChainSpecBuilder::scroll_mainnet().build(ScrollChainConfig::mainnet()));
110+
// build chain spec based on mainnet config, with some fork overrides
111+
let spec_builder = ScrollChainSpecBuilder::scroll_mainnet()
112+
.with_fork(ScrollHardfork::Galileo, ForkCondition::Timestamp(GALILEO_BLOCK_TIMESTAMP));
113+
let chain_spec = Arc::new(spec_builder.build(ScrollChainConfig::mainnet()));
111114
let evm_config = ScrollEvmConfig::scroll(chain_spec.clone());
112115

113116
let evm =
@@ -223,7 +226,7 @@ mod tests {
223226

224227
// determine l1 gas oracle storage
225228
let l1_gas_oracle_storage =
226-
if strategy.spec().is_galileo_v2_active_at_timestamp(block_timestamp) {
229+
if strategy.spec().is_galileo_active_at_timestamp(block_timestamp) {
227230
vec![
228231
(GPO_L1_BLOB_BASE_FEE_SLOT, U256::from(1000)),
229232
(GPO_OVERHEAD_SLOT, U256::from(1000)),
@@ -233,9 +236,9 @@ mod tests {
233236
(GPO_BLOB_SCALAR_SLOT, U256::from(10000)),
234237
(GPO_IS_CURIE_SLOT, U256::from(1)),
235238
(GPO_PENALTY_THRESHOLD_SLOT, U256::from(1_000_000_000u64)),
236-
(GPO_PENALTY_FACTOR_SLOT, U256::from(1_000_000_000u64)),
239+
(GPO_PENALTY_FACTOR_SLOT, U256::from(5u64)), // apply high penalty
237240
(GPO_IS_FEYNMAN_SLOT, U256::from(1)),
238-
(GPO_IS_GALILEO_SLOT, U256::from(1)),
241+
(GPO_IS_GALILEO_SLOT, U256::from(0)), // only activated in `GalileoV2`
239242
]
240243
} else if strategy.spec().is_feynman_active_at_timestamp(block_timestamp) {
241244
vec![
@@ -310,7 +313,7 @@ mod tests {
310313

311314
// determine l1 gas oracle storage
312315
let l1_gas_oracle_storage =
313-
if strategy.spec().is_galileo_v2_active_at_timestamp(block_timestamp) {
316+
if strategy.spec().is_galileo_active_at_timestamp(block_timestamp) {
314317
vec![
315318
(GPO_L1_BLOB_BASE_FEE_SLOT, U256::from(1000)),
316319
(GPO_OVERHEAD_SLOT, U256::from(1000)),
@@ -320,9 +323,10 @@ mod tests {
320323
(GPO_BLOB_SCALAR_SLOT, U256::from(10000)),
321324
(GPO_IS_CURIE_SLOT, U256::from(1)),
322325
(GPO_PENALTY_THRESHOLD_SLOT, U256::from(2_000_000_000u64)), // penalty if <2x
323-
(GPO_PENALTY_FACTOR_SLOT, U256::from(10_000_000_000u64)), // 10x penalty
326+
(GPO_PENALTY_FACTOR_SLOT, U256::from(5u64)), /* apply high
327+
* penalty */
324328
(GPO_IS_FEYNMAN_SLOT, U256::from(1)),
325-
(GPO_IS_GALILEO_SLOT, U256::from(1)),
329+
(GPO_IS_GALILEO_SLOT, U256::from(0)), // only activated in `GalileoV2`
326330
]
327331
} else if strategy.spec().is_feynman_active_at_timestamp(block_timestamp) {
328332
vec![
@@ -519,6 +523,20 @@ mod tests {
519523
Ok(())
520524
}
521525

526+
#[test]
527+
fn test_execute_transaction_l1_message_galileo_fork() -> eyre::Result<()> {
528+
// Execute L1 message on galileo block
529+
let expected_l1_fee = U256::ZERO;
530+
execute_transaction(
531+
ScrollTxType::L1Message,
532+
CURIE_BLOCK_NUMBER + 1,
533+
GALILEO_BLOCK_TIMESTAMP,
534+
expected_l1_fee,
535+
None,
536+
)?;
537+
Ok(())
538+
}
539+
522540
#[test]
523541
fn test_execute_transactions_legacy_curie_fork() -> eyre::Result<()> {
524542
// Execute legacy transaction on curie block
@@ -555,6 +573,20 @@ mod tests {
555573
Ok(())
556574
}
557575

576+
#[test]
577+
fn test_execute_transactions_legacy_galileo_fork() -> eyre::Result<()> {
578+
// Execute legacy transaction on galileo block
579+
let expected_l1_fee = U256::from(182);
580+
execute_transaction(
581+
ScrollTxType::Legacy,
582+
CURIE_BLOCK_NUMBER + 1,
583+
GALILEO_BLOCK_TIMESTAMP,
584+
expected_l1_fee,
585+
None,
586+
)?;
587+
Ok(())
588+
}
589+
558590
#[test]
559591
fn test_execute_transactions_eip2930_curie_fork() -> eyre::Result<()> {
560592
// Execute eip2930 transaction on curie block

0 commit comments

Comments
 (0)