Skip to content

Commit

Permalink
add Berlin variant to EvmConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
saibatizoku committed Oct 26, 2021
1 parent 312e78d commit a6f6dc6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions chain-impl-mockchain/src/config.rs
Expand Up @@ -126,13 +126,16 @@ pub struct EvmConfigParams {
pub enum EvmConfig {
/// Configuration for the `Istanbul` fork.
Istanbul = 0,
/// Configuration for the `Berlin` fork.
Berlin = 1,
}

#[cfg(feature = "evm")]
impl From<EvmConfig> for Config {
fn from(other: EvmConfig) -> Config {
match other {
EvmConfig::Istanbul => Config::istanbul(),
EvmConfig::Berlin => Config::berlin(),
}
}
}
Expand All @@ -141,7 +144,7 @@ impl From<EvmConfig> for Config {
impl Default for EvmConfigParams {
fn default() -> Self {
EvmConfigParams {
config: EvmConfig::Istanbul,
config: EvmConfig::Berlin,
environment: Environment {
gas_price: Default::default(),
origin: Default::default(),
Expand Down Expand Up @@ -846,9 +849,12 @@ impl ConfigParamVariant for EvmConfigParams {

fn from_payload(payload: &[u8]) -> Result<Self, Error> {
let mut rb = ReadBuf::from(payload);
// Read Config

// Read EvmConfig and match hard fork variant
use EvmConfig::*;
let config = match rb.get_u8()? {
n if n == EvmConfig::Istanbul as u8 => EvmConfig::Istanbul,
n if n == Istanbul as u8 => Istanbul,
n if n == Berlin as u8 => Berlin,
_ => return Err(Error::InvalidTag),
};

Expand Down Expand Up @@ -1018,7 +1024,7 @@ mod test {
impl Arbitrary for EvmConfigParams {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
Self {
config: EvmConfig::Istanbul,
config: EvmConfig::Berlin,
environment: Environment {
gas_price: u64::arbitrary(g).into(),
origin: Origin::random(),
Expand Down

0 comments on commit a6f6dc6

Please sign in to comment.