Skip to content

Commit

Permalink
chore: impl review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Oct 12, 2023
1 parent a6cf8f9 commit 351bb17
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
10 changes: 9 additions & 1 deletion common/config-parser/src/types/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::{
Args, ValueEnum,
};
use serde::{Deserialize, Serialize};
use strum::IntoEnumIterator;
use strum_macros::EnumIter;

use common_crypto::Secp256k1RecoverablePrivateKey;
Expand Down Expand Up @@ -261,14 +262,21 @@ impl From<HardforkInput> for HardforkInfoInner {
}
}

/// inspired by https://www.wikiwand.com/en/IAU_designated_constellations#List
#[derive(Clone, Debug, Serialize, Deserialize, Copy, ValueEnum, EnumIter, PartialEq, Eq, Hash)]
pub enum HardforkName {
None = 0b0,
/// If this hardfork is activated, chain validators can modify the EVM
/// contract size limit.
Andromeda = 0b1,
}

impl HardforkName {
pub fn all() -> u64 {
HardforkName::Andromeda as u64
let mut res = 0u64;
for name in HardforkName::iter() {
res &= name as u64
}
res
}
}
14 changes: 7 additions & 7 deletions core/run/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use clap::{builder::TypedValueParser as _, Command};
use hasher::HasherKeccak;

use common_config_parser::types::{
spec::{ChainSpec, ChainSpecValueParser, HardforkName, PrivateKeyFileValueParser},
spec::{ChainSpec, ChainSpecValueParser, HardforkName},
Config, ConfigValueParser,
};
use core_executor::{
Expand Down Expand Up @@ -49,22 +49,22 @@ const TESTCASES: &[TestCase] = &[
chain_name: "single_node",
config_file: "config.toml",
chain_spec_file: "specs/single_node/chain-spec.toml",
input_genesis_hash: "0x274c0c52500c3978776d8836b8afe0999a946a010166c12a85a1c45b9cd2c5a2",
genesis_state_root: "0x940458498b6ac368ab17e9ede64d0cc1d321bc4ec835e09a333a4151c7785ea1",
input_genesis_hash: "0x766cd8e7a32f698eb1180cd736bad6d316ebd3c185326bf6be24ef34996f545a",
genesis_state_root: "0x2131e3b9b90adc4c5e2b5136f3789b982029ab43c610cee0b05d8d2759dbdac4",
},
TestCase {
chain_name: "multi_nodes",
config_file: "nodes/node_1.toml",
chain_spec_file: "specs/multi_nodes/chain-spec.toml",
input_genesis_hash: "0x70cc025ae586f054157f6d8a6558c39c359cde0eb4b9acbdf3f31a8e14a6a6fc",
genesis_state_root: "0x9976026c069e8d931d55f93637663e494caae772c2c274ad636de9bc7baf5191",
input_genesis_hash: "0x6e6160ffd1dcbcec8fa57a9a62479a9ace98f53bfd512fe946fe17f50c08def9",
genesis_state_root: "0x754e9d640f31758f44dbdb18b266dcfb87945d96d713f0a28a06bf6dfa665585",
},
TestCase {
chain_name: "multi_nodes_short_epoch_len",
config_file: "nodes/node_1.toml",
chain_spec_file: "specs/multi_nodes_short_epoch_len/chain-spec.toml",
input_genesis_hash: "0x4213963522f2d72fa8b33ab4a8b33d79f0d387999f97f38d5c93d9b047baa743",
genesis_state_root: "0x33a4f19a7d1bca010f6c3f17904e23f099dd2a022e1f1401fbffed27a1919370",
input_genesis_hash: "0x38814e4efa8ec97e659905208d808e5f7118bb039aa7aaee89937dad8bdee756",
genesis_state_root: "0xe2cb19b9ce6655838aa5e280d4f6fb06fcf367d454d4bc1c47f5bfd85d75432e",
},
];

Expand Down
6 changes: 3 additions & 3 deletions protocol/src/types/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ impl RichBlock {
#[cfg(test)]
mod tests {
use crate::types::{
Block, BlockVersion, ConsensusConfig, Header, Hex, Metadata, MetadataVersion, ProposeCount,
RichBlock, ValidatorExtend, H160,
primitive::default_max_contract_limit, Block, BlockVersion, ConsensusConfig, Header, Hex,
Metadata, MetadataVersion, ProposeCount, RichBlock, ValidatorExtend, H160,
};
use std::{
str::FromStr,
Expand Down Expand Up @@ -369,7 +369,7 @@ mod tests {
brake_ratio: 10,
tx_num_limit: 20000,
max_tx_size: 1024,
max_contract_limit: 0x6000
max_contract_limit: default_max_contract_limit()
}
};

Expand Down
4 changes: 2 additions & 2 deletions protocol/src/types/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl From<ConsensusConfigV0> for ConsensusConfig {
brake_ratio: value.brake_ratio,
tx_num_limit: value.tx_num_limit,
max_tx_size: value.max_tx_size,
max_contract_limit: 0x6000,
max_contract_limit: default_max_contract_limit(),
}
}
}
Expand Down Expand Up @@ -401,7 +401,7 @@ pub struct ConsensusConfig {
pub max_contract_limit: u64,
}

fn default_max_contract_limit() -> u64 {
pub fn default_max_contract_limit() -> u64 {
0x6000
}

Expand Down

0 comments on commit 351bb17

Please sign in to comment.