Skip to content

Commit

Permalink
feat(spec): Holocene activation time for {OP/Base} Sepolia (paradigmx…
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby authored Nov 11, 2024
1 parent 9773635 commit c4f10bd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
29 changes: 25 additions & 4 deletions crates/optimism/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ impl From<Genesis> for OpChainSpec {
(OpHardfork::Ecotone.boxed(), genesis_info.ecotone_time),
(OpHardfork::Fjord.boxed(), genesis_info.fjord_time),
(OpHardfork::Granite.boxed(), genesis_info.granite_time),
(OpHardfork::Holocene.boxed(), genesis_info.holocene_time),
];

let mut time_hardforks = time_hardfork_opts
Expand Down Expand Up @@ -572,7 +573,11 @@ mod tests {
),
(
Head { number: 0, timestamp: 1723478400, ..Default::default() },
ForkId { hash: ForkHash([0x75, 0xde, 0xa4, 0x1e]), next: 0 },
ForkId { hash: ForkHash([0x75, 0xde, 0xa4, 0x1e]), next: 1732201200 },
),
(
Head { number: 0, timestamp: 1732201200, ..Default::default() },
ForkId { hash: ForkHash([0x98, 0x1c, 0x21, 0x69]), next: 0 },
),
],
);
Expand Down Expand Up @@ -639,7 +644,11 @@ mod tests {
),
(
Head { number: 0, timestamp: 1723478400, ..Default::default() },
ForkId { hash: ForkHash([0x5e, 0xdf, 0xa3, 0xb6]), next: 0 },
ForkId { hash: ForkHash([0x5e, 0xdf, 0xa3, 0xb6]), next: 1732201200 },
),
(
Head { number: 0, timestamp: 1732201200, ..Default::default() },
ForkId { hash: ForkHash([0x59, 0x5e, 0x2e, 0x6e]), next: 0 },
),
],
);
Expand Down Expand Up @@ -721,6 +730,7 @@ mod tests {
"ecotoneTime": 40,
"fjordTime": 50,
"graniteTime": 51,
"holoceneTime": 52,
"optimism": {
"eip1559Elasticity": 60,
"eip1559Denominator": 70
Expand All @@ -742,6 +752,8 @@ mod tests {
assert_eq!(actual_fjord_timestamp, Some(serde_json::Value::from(50)).as_ref());
let actual_granite_timestamp = genesis.config.extra_fields.get("graniteTime");
assert_eq!(actual_granite_timestamp, Some(serde_json::Value::from(51)).as_ref());
let actual_holocene_timestamp = genesis.config.extra_fields.get("holoceneTime");
assert_eq!(actual_holocene_timestamp, Some(serde_json::Value::from(52)).as_ref());

let optimism_object = genesis.config.extra_fields.get("optimism").unwrap();
assert_eq!(
Expand All @@ -765,13 +777,15 @@ mod tests {
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Ecotone, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Fjord, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Granite, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Holocene, 0));

assert!(chain_spec.is_fork_active_at_block(OpHardfork::Bedrock, 10));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Regolith, 20));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Canyon, 30));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Ecotone, 40));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Fjord, 50));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Granite, 51));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Holocene, 52));
}

#[test]
Expand All @@ -785,6 +799,7 @@ mod tests {
"ecotoneTime": 40,
"fjordTime": 50,
"graniteTime": 51,
"holoceneTime": 52,
"optimism": {
"eip1559Elasticity": 60,
"eip1559Denominator": 70,
Expand All @@ -807,6 +822,8 @@ mod tests {
assert_eq!(actual_fjord_timestamp, Some(serde_json::Value::from(50)).as_ref());
let actual_granite_timestamp = genesis.config.extra_fields.get("graniteTime");
assert_eq!(actual_granite_timestamp, Some(serde_json::Value::from(51)).as_ref());
let actual_holocene_timestamp = genesis.config.extra_fields.get("holoceneTime");
assert_eq!(actual_holocene_timestamp, Some(serde_json::Value::from(52)).as_ref());

let optimism_object = genesis.config.extra_fields.get("optimism").unwrap();
assert_eq!(
Expand Down Expand Up @@ -837,13 +854,15 @@ mod tests {
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Ecotone, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Fjord, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Granite, 0));
assert!(!chain_spec.is_fork_active_at_timestamp(OpHardfork::Holocene, 0));

assert!(chain_spec.is_fork_active_at_block(OpHardfork::Bedrock, 10));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Regolith, 20));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Canyon, 30));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Ecotone, 40));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Fjord, 50));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Granite, 51));
assert!(chain_spec.is_fork_active_at_timestamp(OpHardfork::Holocene, 52));
}

#[test]
Expand Down Expand Up @@ -955,6 +974,7 @@ mod tests {
(String::from("ecotoneTime"), 0.into()),
(String::from("fjordTime"), 0.into()),
(String::from("graniteTime"), 0.into()),
(String::from("holoceneTime"), 0.into()),
]
.into_iter()
.collect(),
Expand Down Expand Up @@ -988,6 +1008,7 @@ mod tests {
OpHardfork::Ecotone.boxed(),
OpHardfork::Fjord.boxed(),
OpHardfork::Granite.boxed(),
OpHardfork::Holocene.boxed(),
];

assert!(expected_hardforks
Expand Down Expand Up @@ -1036,7 +1057,7 @@ mod tests {
}

#[test]
fn test_get_base_fee_holocene_nonce_not_set() {
fn test_get_base_fee_holocene_extra_data_not_set() {
let op_chain_spec = holocene_chainspec();
let parent = Header {
base_fee_per_gas: Some(1),
Expand All @@ -1058,7 +1079,7 @@ mod tests {
}

#[test]
fn test_get_base_fee_holocene_nonce_set() {
fn test_get_base_fee_holocene_extra_data_set() {
let op_chain_spec = holocene_chainspec();
let parent = Header {
base_fee_per_gas: Some(1),
Expand Down
8 changes: 6 additions & 2 deletions crates/optimism/hardforks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl OpHardfork {
Self::Ecotone => Some(1708534800),
Self::Fjord => Some(1716998400),
Self::Granite => Some(1723478400),
Self::Holocene => None,
Self::Holocene => Some(1732201200),
},
)
}
Expand Down Expand Up @@ -257,6 +257,7 @@ impl OpHardfork {
(Self::Ecotone.boxed(), ForkCondition::Timestamp(1708534800)),
(Self::Fjord.boxed(), ForkCondition::Timestamp(1716998400)),
(Self::Granite.boxed(), ForkCondition::Timestamp(1723478400)),
(Self::Holocene.boxed(), ForkCondition::Timestamp(1732201200)),
])
}

Expand Down Expand Up @@ -288,6 +289,7 @@ impl OpHardfork {
(Self::Ecotone.boxed(), ForkCondition::Timestamp(1708534800)),
(Self::Fjord.boxed(), ForkCondition::Timestamp(1716998400)),
(Self::Granite.boxed(), ForkCondition::Timestamp(1723478400)),
(Self::Holocene.boxed(), ForkCondition::Timestamp(1732201200)),
])
}

Expand Down Expand Up @@ -354,14 +356,16 @@ mod tests {

#[test]
fn check_op_hardfork_from_str() {
let hardfork_str = ["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe"];
let hardfork_str =
["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE"];
let expected_hardforks = [
OpHardfork::Bedrock,
OpHardfork::Regolith,
OpHardfork::Canyon,
OpHardfork::Ecotone,
OpHardfork::Fjord,
OpHardfork::Granite,
OpHardfork::Holocene,
];

let hardforks: Vec<OpHardfork> =
Expand Down
28 changes: 12 additions & 16 deletions crates/optimism/node/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,12 @@ mod test {
use crate::engine;
use alloy_primitives::{b64, Address, B256, B64};
use alloy_rpc_types_engine::PayloadAttributes;
use reth_chainspec::ForkCondition;
use reth_optimism_chainspec::BASE_SEPOLIA;

use super::*;

fn get_chainspec(is_holocene: bool) -> Arc<OpChainSpec> {
let mut hardforks = OpHardfork::base_sepolia();
if is_holocene {
hardforks.insert(OpHardfork::Holocene.boxed(), ForkCondition::Timestamp(1800000000));
}
fn get_chainspec() -> Arc<OpChainSpec> {
let hardforks = OpHardfork::base_sepolia();
Arc::new(OpChainSpec {
inner: ChainSpec {
chain: BASE_SEPOLIA.inner.chain,
Expand Down Expand Up @@ -217,8 +213,8 @@ mod test {

#[test]
fn test_well_formed_attributes_pre_holocene() {
let validator = OpEngineValidator::new(get_chainspec(false));
let attributes = get_attributes(None, 1799999999);
let validator = OpEngineValidator::new(get_chainspec());
let attributes = get_attributes(None, 1732201199);

let result = <engine::OpEngineValidator as reth_node_builder::EngineValidator<
OpEngineTypes,
Expand All @@ -230,8 +226,8 @@ mod test {

#[test]
fn test_well_formed_attributes_holocene_no_eip1559_params() {
let validator = OpEngineValidator::new(get_chainspec(true));
let attributes = get_attributes(None, 1800000000);
let validator = OpEngineValidator::new(get_chainspec());
let attributes = get_attributes(None, 1732201200);

let result = <engine::OpEngineValidator as reth_node_builder::EngineValidator<
OpEngineTypes,
Expand All @@ -243,8 +239,8 @@ mod test {

#[test]
fn test_well_formed_attributes_holocene_eip1559_params_zero_denominator() {
let validator = OpEngineValidator::new(get_chainspec(true));
let attributes = get_attributes(Some(b64!("0000000000000008")), 1800000000);
let validator = OpEngineValidator::new(get_chainspec());
let attributes = get_attributes(Some(b64!("0000000000000008")), 1732201200);

let result = <engine::OpEngineValidator as reth_node_builder::EngineValidator<
OpEngineTypes,
Expand All @@ -256,8 +252,8 @@ mod test {

#[test]
fn test_well_formed_attributes_holocene_valid() {
let validator = OpEngineValidator::new(get_chainspec(true));
let attributes = get_attributes(Some(b64!("0000000800000008")), 1800000000);
let validator = OpEngineValidator::new(get_chainspec());
let attributes = get_attributes(Some(b64!("0000000800000008")), 1732201200);

let result = <engine::OpEngineValidator as reth_node_builder::EngineValidator<
OpEngineTypes,
Expand All @@ -269,8 +265,8 @@ mod test {

#[test]
fn test_well_formed_attributes_holocene_valid_all_zero() {
let validator = OpEngineValidator::new(get_chainspec(true));
let attributes = get_attributes(Some(b64!("0000000000000000")), 1800000000);
let validator = OpEngineValidator::new(get_chainspec());
let attributes = get_attributes(Some(b64!("0000000000000000")), 1732201200);

let result = <engine::OpEngineValidator as reth_node_builder::EngineValidator<
OpEngineTypes,
Expand Down

0 comments on commit c4f10bd

Please sign in to comment.