From 4be73e7cb477d4e1a169f5b2cca1e3e9176f64ef Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Thu, 1 Aug 2024 13:12:44 +0500 Subject: [PATCH 1/7] marketplace upgrade type --- data/genesis/demo.toml | 7 +++++ sequencer/src/genesis.rs | 43 ++++++++++++++++++++++++++--- types/src/v0/impls/header.rs | 20 ++++++-------- types/src/v0/impls/state.rs | 6 ++-- types/src/v0/v0_1/instance_state.rs | 7 ++++- 5 files changed, 62 insertions(+), 21 deletions(-) diff --git a/data/genesis/demo.toml b/data/genesis/demo.toml index 3493200e6..23d80dd1a 100644 --- a/data/genesis/demo.toml +++ b/data/genesis/demo.toml @@ -22,3 +22,10 @@ base_fee = '1 wei' max_block_size = '1mb' fee_recipient = '0x0000000000000000000000000000000000000000' fee_contract = '0xa15bb66138824a1c7167f5e85b957d04dd34e468' + +[[upgrade]] +version = "0.4" +start_proposing_view = 5 +stop_proposing_view = 15 + +[upgrade.marketplace] \ No newline at end of file diff --git a/sequencer/src/genesis.rs b/sequencer/src/genesis.rs index fc5440cc1..6350f1a9f 100644 --- a/sequencer/src/genesis.rs +++ b/sequencer/src/genesis.rs @@ -56,10 +56,8 @@ impl Genesis { let upgrades: Vec<&Upgrade> = self.upgrades.values().collect(); for upgrade in upgrades { - match upgrade.upgrade_type { - UpgradeType::ChainConfig { chain_config } => { - base_fee = std::cmp::max(chain_config.base_fee, base_fee); - } + if let UpgradeType::ChainConfig { chain_config } = upgrade.upgrade_type { + base_fee = std::cmp::max(chain_config.base_fee, base_fee); } } @@ -571,4 +569,41 @@ mod test { toml::from_str::(&toml).unwrap_err(); } + + #[test] + fn test_marketplace_upgrade_toml() { + let toml = toml! { + [stake_table] + capacity = 10 + + [chain_config] + chain_id = 12345 + max_block_size = 30000 + base_fee = 1 + fee_recipient = "0x0000000000000000000000000000000000000000" + fee_contract = "0x0000000000000000000000000000000000000000" + + [header] + timestamp = 123456 + + [accounts] + "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f" = 100000 + "0x0000000000000000000000000000000000000000" = 42 + + [l1_finalized] + number = 64 + timestamp = "0x123def" + hash = "0x80f5dd11f2bdda2814cb1ad94ef30a47de02cf28ad68c89e104c00c4e51bb7a5" + + [[upgrade]] + version = "0.4" + start_proposing_view = 1 + stop_proposing_view = 10 + + [upgrade.marketplace] + } + .to_string(); + + toml::from_str::(&toml).unwrap(); + } } diff --git a/types/src/v0/impls/header.rs b/types/src/v0/impls/header.rs index 070c7607e..2e16ed22b 100644 --- a/types/src/v0/impls/header.rs +++ b/types/src/v0/impls/header.rs @@ -784,13 +784,11 @@ impl BlockHeader for Header { let mut validated_state = parent_state.clone(); let chain_config = if version > instance_state.current_version { - match instance_state - .upgrades - .get(&version) - .map(|upgrade| match upgrade.upgrade_type { + match instance_state.upgrades.get(&version) { + Some(upgrade) => match upgrade.upgrade_type { UpgradeType::ChainConfig { chain_config } => chain_config, - }) { - Some(cf) => cf, + _ => Header::get_chain_config(&validated_state, instance_state).await, + }, None => Header::get_chain_config(&validated_state, instance_state).await, } } else { @@ -903,13 +901,11 @@ impl BlockHeader for Header { let mut validated_state = parent_state.clone(); let chain_config = if version > instance_state.current_version { - match instance_state - .upgrades - .get(&version) - .map(|upgrade| match upgrade.upgrade_type { + match instance_state.upgrades.get(&version) { + Some(upgrade) => match upgrade.upgrade_type { UpgradeType::ChainConfig { chain_config } => chain_config, - }) { - Some(cf) => cf, + _ => Header::get_chain_config(&validated_state, instance_state).await, + }, None => Header::get_chain_config(&validated_state, instance_state).await, } } else { diff --git a/types/src/v0/impls/state.rs b/types/src/v0/impls/state.rs index 76e64107c..ea2bfe2f2 100644 --- a/types/src/v0/impls/state.rs +++ b/types/src/v0/impls/state.rs @@ -470,10 +470,8 @@ impl ValidatedState { return; }; - match upgrade.upgrade_type { - UpgradeType::ChainConfig { chain_config } => { - self.chain_config = chain_config.into(); - } + if let UpgradeType::ChainConfig { chain_config } = upgrade.upgrade_type { + self.chain_config = chain_config.into(); } } diff --git a/types/src/v0/v0_1/instance_state.rs b/types/src/v0/v0_1/instance_state.rs index 2d2333fb2..f8604ec60 100644 --- a/types/src/v0/v0_1/instance_state.rs +++ b/types/src/v0/v0_1/instance_state.rs @@ -5,14 +5,19 @@ use crate::{v0_3::ChainConfig, Timestamp}; /// Represents the specific type of upgrade. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -#[serde(untagged)] #[serde(rename_all = "snake_case")] +#[serde(untagged)] pub enum UpgradeType { // Note: Wrapping this in a tuple variant causes deserialization to fail because // the 'chain_config' name is also provided in the TOML input. ChainConfig { chain_config: ChainConfig }, + // todo (ab): use empty variant and fix serialization + Marketplace { marketplace: Marketplace }, } +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct Marketplace {} + /// Represents an upgrade based on time (unix timestamp). #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct TimeBasedUpgrade { From 545bcbc9718d1a643949bb994a31da1d0d873628 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 14 Aug 2024 00:43:38 +0500 Subject: [PATCH 2/7] fix version in toml file --- data/genesis/demo.toml | 2 +- types/src/v0/v0_1/instance_state.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/genesis/demo.toml b/data/genesis/demo.toml index 23d80dd1a..05e195666 100644 --- a/data/genesis/demo.toml +++ b/data/genesis/demo.toml @@ -24,7 +24,7 @@ fee_recipient = '0x0000000000000000000000000000000000000000' fee_contract = '0xa15bb66138824a1c7167f5e85b957d04dd34e468' [[upgrade]] -version = "0.4" +version = "0.3" start_proposing_view = 5 stop_proposing_view = 15 diff --git a/types/src/v0/v0_1/instance_state.rs b/types/src/v0/v0_1/instance_state.rs index f8604ec60..312260b2b 100644 --- a/types/src/v0/v0_1/instance_state.rs +++ b/types/src/v0/v0_1/instance_state.rs @@ -11,7 +11,7 @@ pub enum UpgradeType { // Note: Wrapping this in a tuple variant causes deserialization to fail because // the 'chain_config' name is also provided in the TOML input. ChainConfig { chain_config: ChainConfig }, - // todo (ab): use empty variant and fix serialization + // todo (ab): use empty Marketplace { marketplace: Marketplace }, } From 91ab69ce66faa7f2296039fa7af710bd6264e013 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 14 Aug 2024 00:59:32 +0500 Subject: [PATCH 3/7] use empty variant for marketplace --- types/src/v0/v0_1/instance_state.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/types/src/v0/v0_1/instance_state.rs b/types/src/v0/v0_1/instance_state.rs index 312260b2b..dd370aeef 100644 --- a/types/src/v0/v0_1/instance_state.rs +++ b/types/src/v0/v0_1/instance_state.rs @@ -11,13 +11,9 @@ pub enum UpgradeType { // Note: Wrapping this in a tuple variant causes deserialization to fail because // the 'chain_config' name is also provided in the TOML input. ChainConfig { chain_config: ChainConfig }, - // todo (ab): use empty - Marketplace { marketplace: Marketplace }, + Marketplace {}, } -#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] -pub struct Marketplace {} - /// Represents an upgrade based on time (unix timestamp). #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] pub struct TimeBasedUpgrade { From e6cf990068e51b538a31eb1062116622998b3d75 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 14 Aug 2024 18:00:34 +0500 Subject: [PATCH 4/7] rename chainconfig upgrade type to feeupgrade --- data/genesis/demo.toml | 4 +++- sequencer/src/api.rs | 2 +- sequencer/src/genesis.rs | 10 ++++++---- types/src/v0/impls/header.rs | 4 ++-- types/src/v0/impls/state.rs | 5 +++-- types/src/v0/v0_1/instance_state.rs | 3 +-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/data/genesis/demo.toml b/data/genesis/demo.toml index 05e195666..a850d8799 100644 --- a/data/genesis/demo.toml +++ b/data/genesis/demo.toml @@ -16,7 +16,9 @@ version = "0.2" start_proposing_view = 5 stop_proposing_view = 15 -[upgrade.chain_config] +[upgrade.fee_upgrade] + +[upgrade.fee_upgrade.chain_config] chain_id = 999999999 base_fee = '1 wei' max_block_size = '1mb' diff --git a/sequencer/src/api.rs b/sequencer/src/api.rs index 4afad8c10..34b0c6294 100644 --- a/sequencer/src/api.rs +++ b/sequencer/src/api.rs @@ -1473,7 +1473,7 @@ mod test { ::Upgrade::VERSION, Upgrade { mode, - upgrade_type: UpgradeType::ChainConfig { + upgrade_type: UpgradeType::FeeUpgrade { chain_config: chain_config_upgrade, }, }, diff --git a/sequencer/src/genesis.rs b/sequencer/src/genesis.rs index 6350f1a9f..7429058d4 100644 --- a/sequencer/src/genesis.rs +++ b/sequencer/src/genesis.rs @@ -56,7 +56,7 @@ impl Genesis { let upgrades: Vec<&Upgrade> = self.upgrades.values().collect(); for upgrade in upgrades { - if let UpgradeType::ChainConfig { chain_config } = upgrade.upgrade_type { + if let UpgradeType::FeeUpgrade { chain_config } = upgrade.upgrade_type { base_fee = std::cmp::max(chain_config.base_fee, base_fee); } } @@ -430,7 +430,9 @@ mod test { start_proposing_view = 1 stop_proposing_view = 15 - [upgrade.chain_config] + [upgrade.fee_upgrade] + + [upgrade.fee_upgrade.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 @@ -452,7 +454,7 @@ mod test { start_proposing_view: 1, stop_proposing_view: 15, }), - upgrade_type: UpgradeType::ChainConfig { + upgrade_type: UpgradeType::FeeUpgrade { chain_config: genesis.chain_config, }, }; @@ -516,7 +518,7 @@ mod test { stop_proposing_time: Timestamp::from_string("2024-01-02T00:00:00Z".to_string()) .unwrap(), }), - upgrade_type: UpgradeType::ChainConfig { + upgrade_type: UpgradeType::FeeUpgrade { chain_config: genesis.chain_config, }, }; diff --git a/types/src/v0/impls/header.rs b/types/src/v0/impls/header.rs index 8f9257b1e..a9c4c584e 100644 --- a/types/src/v0/impls/header.rs +++ b/types/src/v0/impls/header.rs @@ -749,7 +749,7 @@ impl BlockHeader for Header { let chain_config = if version > instance_state.current_version { match instance_state.upgrades.get(&version) { Some(upgrade) => match upgrade.upgrade_type { - UpgradeType::ChainConfig { chain_config } => chain_config, + UpgradeType::FeeUpgrade { chain_config } => chain_config, _ => Header::get_chain_config(&validated_state, instance_state).await, }, None => Header::get_chain_config(&validated_state, instance_state).await, @@ -866,7 +866,7 @@ impl BlockHeader for Header { let chain_config = if version > instance_state.current_version { match instance_state.upgrades.get(&version) { Some(upgrade) => match upgrade.upgrade_type { - UpgradeType::ChainConfig { chain_config } => chain_config, + UpgradeType::FeeUpgrade { chain_config } => chain_config, _ => Header::get_chain_config(&validated_state, instance_state).await, }, None => Header::get_chain_config(&validated_state, instance_state).await, diff --git a/types/src/v0/impls/state.rs b/types/src/v0/impls/state.rs index ed08c7af4..f907b190f 100644 --- a/types/src/v0/impls/state.rs +++ b/types/src/v0/impls/state.rs @@ -510,7 +510,7 @@ impl ValidatedState { return; }; - if let UpgradeType::ChainConfig { chain_config } = upgrade.upgrade_type { + if let UpgradeType::FeeUpgrade { chain_config } = upgrade.upgrade_type { self.chain_config = chain_config.into(); } } @@ -792,6 +792,7 @@ mod test { use hotshot_types::{traits::signature_key::BuilderSignatureKey, vid::vid_scheme}; use jf_vid::VidScheme; use sequencer_utils::ser::FromStringOrInteger; + use tracing::debug; use super::*; use crate::{ @@ -1063,7 +1064,7 @@ mod test { let metadata = parent.block_header().metadata(); let vid_commitment = parent.payload_commitment(); - dbg!(header.version()); + debug!("{:?}", header.version()); let key_pair = EthKeyPair::random(); let account = key_pair.fee_account(); diff --git a/types/src/v0/v0_1/instance_state.rs b/types/src/v0/v0_1/instance_state.rs index dd370aeef..e7563c78d 100644 --- a/types/src/v0/v0_1/instance_state.rs +++ b/types/src/v0/v0_1/instance_state.rs @@ -6,11 +6,10 @@ use crate::{v0_3::ChainConfig, Timestamp}; /// Represents the specific type of upgrade. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] -#[serde(untagged)] pub enum UpgradeType { // Note: Wrapping this in a tuple variant causes deserialization to fail because // the 'chain_config' name is also provided in the TOML input. - ChainConfig { chain_config: ChainConfig }, + FeeUpgrade { chain_config: ChainConfig }, Marketplace {}, } From 8d7de783c6752073cd6468bf873d727fc0c53756 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 14 Aug 2024 18:17:03 +0500 Subject: [PATCH 5/7] fix tests and update doc --- doc/upgrades.md | 23 +++++++++----- sequencer/src/api.rs | 10 +++--- sequencer/src/genesis.rs | 68 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 83 insertions(+), 18 deletions(-) diff --git a/doc/upgrades.md b/doc/upgrades.md index 75a65dfba..072086d6f 100644 --- a/doc/upgrades.md +++ b/doc/upgrades.md @@ -85,25 +85,34 @@ TOML file. For an example with upgrades enabled, refer to [`data/genesis/demo.to ```toml [[upgrade]] version = "0.2" -view = 5 -propose_window = 10 +start_proposing_view = 5 +stop_proposing_view = 15 -[upgrade.chain_config] +[upgrade.fee_upgrade] + +[upgrade.fee_upgrade.chain_config] chain_id = 999999999 -base_fee = '2 wei' +base_fee = '1 wei' max_block_size = '1mb' fee_recipient = '0x0000000000000000000000000000000000000000' fee_contract = '0xa15bb66138824a1c7167f5e85b957d04dd34e468' + +[[upgrade]] +version = "0.3" +start_proposing_view = 5 +stop_proposing_view = 15 + +[upgrade.marketplace] ``` In the TOML configuration example above, the `upgrade` section defines an array of tables, each specifying upgrade parameters: - **Version:** the new version after an upgrade is successful. -- **View:** Represents the `start_proposing_view` value at which the upgrade is proposed. -- **Propose Window:** Refers to the view window between `start_proposing_view` and `stop_proposing_view`. +- **start_proposing_view:** Represents the `start_proposing_view` value at which the upgrade is proposed. +- **stop_proposing_view:** Refers to the view at which the proposing an upgrade has stopped. -The `upgrade.chain_config` table contains the complete set of chain config parameters, which can be used, for example, +The `upgrade.fee_upgrade.chain_config` table contains the complete set of chain config parameters, which can be used, for example, to enable protocol fees or modify other parameters. ## Fee upgrade diff --git a/sequencer/src/api.rs b/sequencer/src/api.rs index 34b0c6294..71ae15cc5 100644 --- a/sequencer/src/api.rs +++ b/sequencer/src/api.rs @@ -1431,10 +1431,10 @@ mod test { } #[async_std::test] - async fn test_chain_config_upgrade_view_based() { + async fn test_fee_upgrade_view_based() { setup_test(); - test_chain_config_upgrade_helper(UpgradeMode::View(ViewBasedUpgrade { + test_fee_upgrade_helper(UpgradeMode::View(ViewBasedUpgrade { start_voting_view: None, stop_voting_view: None, start_proposing_view: 1, @@ -1444,11 +1444,11 @@ mod test { } #[async_std::test] - async fn test_chain_config_upgrade_time_based() { + async fn test_fee_upgrade_time_based() { setup_test(); let now = OffsetDateTime::now_utc().unix_timestamp() as u64; - test_chain_config_upgrade_helper(UpgradeMode::Time(TimeBasedUpgrade { + test_fee_upgrade_helper(UpgradeMode::Time(TimeBasedUpgrade { start_proposing_time: Timestamp::from_integer(now).unwrap(), stop_proposing_time: Timestamp::from_integer(now + 500).unwrap(), start_voting_time: None, @@ -1457,7 +1457,7 @@ mod test { .await; } - async fn test_chain_config_upgrade_helper(mode: UpgradeMode) { + async fn test_fee_upgrade_helper(mode: UpgradeMode) { let port = pick_unused_port().expect("No ports free"); let anvil = Anvil::new().spawn(); let l1 = anvil.endpoint().parse().unwrap(); diff --git a/sequencer/src/genesis.rs b/sequencer/src/genesis.rs index 7429058d4..fd305cac8 100644 --- a/sequencer/src/genesis.rs +++ b/sequencer/src/genesis.rs @@ -399,7 +399,7 @@ mod test { } #[test] - fn test_genesis_toml_upgrade_view_mode() { + fn test_genesis_toml_fee_upgrade_view_mode() { // without optional fields // with view settings let toml = toml! { @@ -463,7 +463,7 @@ mod test { } #[test] - fn test_genesis_toml_upgrade_time_mode() { + fn test_genesis_toml_fee_upgrade_time_mode() { // without optional fields // with time settings let toml = toml! { @@ -494,7 +494,9 @@ mod test { start_proposing_time = "2024-01-01T00:00:00Z" stop_proposing_time = "2024-01-02T00:00:00Z" - [upgrade.chain_config] + [upgrade.fee_upgrade] + + [upgrade.fee_upgrade.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 @@ -527,7 +529,7 @@ mod test { } #[test] - fn test_genesis_toml_upgrade_view_and_time_mode() { + fn test_genesis_toml_fee_upgrade_view_and_time_mode() { // set both time and view parameters // this should err let toml = toml! { @@ -560,7 +562,9 @@ mod test { start_proposing_time = 1 stop_proposing_time = 10 - [upgrade.chain_config] + [upgrade.fee_upgrade] + + [upgrade.fee_upgrade.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 @@ -597,12 +601,64 @@ mod test { timestamp = "0x123def" hash = "0x80f5dd11f2bdda2814cb1ad94ef30a47de02cf28ad68c89e104c00c4e51bb7a5" + + [[upgrade]] + version = "0.3" + start_proposing_view = 1 + stop_proposing_view = 10 + + [upgrade.marketplace] + } + .to_string(); + + toml::from_str::(&toml).unwrap(); + } + + #[test] + fn test_marketplace_and_fee_upgrade_toml() { + let toml = toml! { + [stake_table] + capacity = 10 + + [chain_config] + chain_id = 12345 + max_block_size = 30000 + base_fee = 1 + fee_recipient = "0x0000000000000000000000000000000000000000" + fee_contract = "0x0000000000000000000000000000000000000000" + + [header] + timestamp = 123456 + + [accounts] + "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f" = 100000 + "0x0000000000000000000000000000000000000000" = 42 + + [l1_finalized] + number = 64 + timestamp = "0x123def" + hash = "0x80f5dd11f2bdda2814cb1ad94ef30a47de02cf28ad68c89e104c00c4e51bb7a5" + [[upgrade]] - version = "0.4" + version = "0.3" start_proposing_view = 1 stop_proposing_view = 10 [upgrade.marketplace] + + [[upgrade]] + version = "0.2" + start_proposing_view = 1 + stop_proposing_view = 15 + + [upgrade.fee_upgrade] + + [upgrade.fee_upgrade.chain_config] + chain_id = 12345 + max_block_size = 30000 + base_fee = 1 + fee_recipient = "0x0000000000000000000000000000000000000000" + fee_contract = "0x0000000000000000000000000000000000000000" } .to_string(); From 2a0f40760a0b30b129b7a1306ae9a828555cfb6d Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 14 Aug 2024 18:56:54 +0500 Subject: [PATCH 6/7] rename fee_upgrade to fee --- data/genesis/demo.toml | 4 ++-- doc/upgrades.md | 10 +++++----- sequencer/src/api.rs | 2 +- sequencer/src/genesis.rs | 22 +++++++++++----------- types/src/v0/impls/header.rs | 4 ++-- types/src/v0/impls/state.rs | 2 +- types/src/v0/v0_1/instance_state.rs | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/data/genesis/demo.toml b/data/genesis/demo.toml index a850d8799..00a6b60ef 100644 --- a/data/genesis/demo.toml +++ b/data/genesis/demo.toml @@ -16,9 +16,9 @@ version = "0.2" start_proposing_view = 5 stop_proposing_view = 15 -[upgrade.fee_upgrade] +[upgrade.fee] -[upgrade.fee_upgrade.chain_config] +[upgrade.fee.chain_config] chain_id = 999999999 base_fee = '1 wei' max_block_size = '1mb' diff --git a/doc/upgrades.md b/doc/upgrades.md index 072086d6f..72811804a 100644 --- a/doc/upgrades.md +++ b/doc/upgrades.md @@ -88,9 +88,9 @@ version = "0.2" start_proposing_view = 5 stop_proposing_view = 15 -[upgrade.fee_upgrade] +[upgrade.fee] -[upgrade.fee_upgrade.chain_config] +[upgrade.fee.chain_config] chain_id = 999999999 base_fee = '1 wei' max_block_size = '1mb' @@ -106,13 +106,13 @@ stop_proposing_view = 15 ``` In the TOML configuration example above, the `upgrade` section defines an array of tables, each specifying upgrade -parameters: +parameters - **Version:** the new version after an upgrade is successful. - **start_proposing_view:** Represents the `start_proposing_view` value at which the upgrade is proposed. -- **stop_proposing_view:** Refers to the view at which the proposing an upgrade has stopped. +- **stop_proposing_view:** Refers to the view view after which the node stops proposing an upgrade. -The `upgrade.fee_upgrade.chain_config` table contains the complete set of chain config parameters, which can be used, for example, +The `upgrade.fee.chain_config` table contains the complete set of chain config parameters, which can be used, for example, to enable protocol fees or modify other parameters. ## Fee upgrade diff --git a/sequencer/src/api.rs b/sequencer/src/api.rs index 5eb475abe..5f1a2098a 100644 --- a/sequencer/src/api.rs +++ b/sequencer/src/api.rs @@ -1497,7 +1497,7 @@ mod test { ::Upgrade::VERSION, Upgrade { mode, - upgrade_type: UpgradeType::FeeUpgrade { + upgrade_type: UpgradeType::Fee { chain_config: chain_config_upgrade, }, }, diff --git a/sequencer/src/genesis.rs b/sequencer/src/genesis.rs index fd305cac8..254b746eb 100644 --- a/sequencer/src/genesis.rs +++ b/sequencer/src/genesis.rs @@ -56,7 +56,7 @@ impl Genesis { let upgrades: Vec<&Upgrade> = self.upgrades.values().collect(); for upgrade in upgrades { - if let UpgradeType::FeeUpgrade { chain_config } = upgrade.upgrade_type { + if let UpgradeType::Fee { chain_config } = upgrade.upgrade_type { base_fee = std::cmp::max(chain_config.base_fee, base_fee); } } @@ -430,9 +430,9 @@ mod test { start_proposing_view = 1 stop_proposing_view = 15 - [upgrade.fee_upgrade] + [upgrade.fee] - [upgrade.fee_upgrade.chain_config] + [upgrade.fee.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 @@ -454,7 +454,7 @@ mod test { start_proposing_view: 1, stop_proposing_view: 15, }), - upgrade_type: UpgradeType::FeeUpgrade { + upgrade_type: UpgradeType::Fee { chain_config: genesis.chain_config, }, }; @@ -494,9 +494,9 @@ mod test { start_proposing_time = "2024-01-01T00:00:00Z" stop_proposing_time = "2024-01-02T00:00:00Z" - [upgrade.fee_upgrade] + [upgrade.fee] - [upgrade.fee_upgrade.chain_config] + [upgrade.fee.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 @@ -520,7 +520,7 @@ mod test { stop_proposing_time: Timestamp::from_string("2024-01-02T00:00:00Z".to_string()) .unwrap(), }), - upgrade_type: UpgradeType::FeeUpgrade { + upgrade_type: UpgradeType::Fee { chain_config: genesis.chain_config, }, }; @@ -562,9 +562,9 @@ mod test { start_proposing_time = 1 stop_proposing_time = 10 - [upgrade.fee_upgrade] + [upgrade.fee] - [upgrade.fee_upgrade.chain_config] + [upgrade.fee.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 @@ -651,9 +651,9 @@ mod test { start_proposing_view = 1 stop_proposing_view = 15 - [upgrade.fee_upgrade] + [upgrade.fee] - [upgrade.fee_upgrade.chain_config] + [upgrade.fee.chain_config] chain_id = 12345 max_block_size = 30000 base_fee = 1 diff --git a/types/src/v0/impls/header.rs b/types/src/v0/impls/header.rs index de0be5af7..ad427d6b2 100644 --- a/types/src/v0/impls/header.rs +++ b/types/src/v0/impls/header.rs @@ -750,7 +750,7 @@ impl BlockHeader for Header { let chain_config = if version > instance_state.current_version { match instance_state.upgrades.get(&version) { Some(upgrade) => match upgrade.upgrade_type { - UpgradeType::FeeUpgrade { chain_config } => chain_config, + UpgradeType::Fee { chain_config } => chain_config, _ => Header::get_chain_config(&validated_state, instance_state).await, }, None => Header::get_chain_config(&validated_state, instance_state).await, @@ -867,7 +867,7 @@ impl BlockHeader for Header { let chain_config = if version > instance_state.current_version { match instance_state.upgrades.get(&version) { Some(upgrade) => match upgrade.upgrade_type { - UpgradeType::FeeUpgrade { chain_config } => chain_config, + UpgradeType::Fee { chain_config } => chain_config, _ => Header::get_chain_config(&validated_state, instance_state).await, }, None => Header::get_chain_config(&validated_state, instance_state).await, diff --git a/types/src/v0/impls/state.rs b/types/src/v0/impls/state.rs index f907b190f..cabaad45f 100644 --- a/types/src/v0/impls/state.rs +++ b/types/src/v0/impls/state.rs @@ -510,7 +510,7 @@ impl ValidatedState { return; }; - if let UpgradeType::FeeUpgrade { chain_config } = upgrade.upgrade_type { + if let UpgradeType::Fee { chain_config } = upgrade.upgrade_type { self.chain_config = chain_config.into(); } } diff --git a/types/src/v0/v0_1/instance_state.rs b/types/src/v0/v0_1/instance_state.rs index e7563c78d..b0e929da1 100644 --- a/types/src/v0/v0_1/instance_state.rs +++ b/types/src/v0/v0_1/instance_state.rs @@ -9,7 +9,7 @@ use crate::{v0_3::ChainConfig, Timestamp}; pub enum UpgradeType { // Note: Wrapping this in a tuple variant causes deserialization to fail because // the 'chain_config' name is also provided in the TOML input. - FeeUpgrade { chain_config: ChainConfig }, + Fee { chain_config: ChainConfig }, Marketplace {}, } From b1c0a47816603796fb50d60aaada3c9817b3b560 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 14 Aug 2024 18:58:41 +0500 Subject: [PATCH 7/7] remove comment --- types/src/v0/v0_1/instance_state.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/src/v0/v0_1/instance_state.rs b/types/src/v0/v0_1/instance_state.rs index b0e929da1..8d381c217 100644 --- a/types/src/v0/v0_1/instance_state.rs +++ b/types/src/v0/v0_1/instance_state.rs @@ -7,8 +7,6 @@ use crate::{v0_3::ChainConfig, Timestamp}; #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub enum UpgradeType { - // Note: Wrapping this in a tuple variant causes deserialization to fail because - // the 'chain_config' name is also provided in the TOML input. Fee { chain_config: ChainConfig }, Marketplace {}, }