Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
sync with upstream for shanghai changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vimpunk committed Mar 28, 2023
1 parent 169af74 commit 15d2bab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
18 changes: 17 additions & 1 deletion ethjson/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ pub enum ForkSpec {
Istanbul,
/// Berlin (#12,244,000, 2021-04-15)
Berlin,
/// London (To be announced)
/// London (12,965,000, 2021-08-05)
London,
/// Paris - The Merge (15,537,394, 2022-09-15)
Merge,
/// Shanghai (To be announced)
Shanghai,

/// Byzantium transition test-net
EIP158ToByzantiumAt5,
/// Homestead transition test-net
Expand All @@ -58,6 +63,17 @@ pub enum ForkSpec {
ConstantinopleFixToIstanbulAt5,
}

impl ForkSpec {
/// Returns true if the fork is at or after the merge.
pub fn is_eth2(&self) -> bool {
// NOTE: Include new forks in this match arm.
matches!(
*self,
ForkSpec::London | ForkSpec::Merge | ForkSpec::Shanghai
)
}
}

/// Spec deserialization.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
Expand Down
16 changes: 13 additions & 3 deletions jsontests/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ impl JsonPrecompile {
}
// precompiles for London and Berlin are the same
ForkSpec::London => Self::precompile(&ForkSpec::Berlin),
// TODO: true?
// precompiles for Merge and Berlin are the same
ForkSpec::Merge => Self::precompile(&ForkSpec::Berlin),
// precompiles for Shanghai and Berlin are the same
ForkSpec::Shanghai => Self::precompile(&ForkSpec::Berlin),
_ => None,
}
}
Expand Down Expand Up @@ -287,9 +292,11 @@ fn test_run(name: &str, test: Test) {
}
}


let actual_fee = executor.fee(vicinity.gas_price);
let mniner_reward = if let ForkSpec::London = spec {
// see EIP-1559
// Forks after London burn miner rewards and thus have different gas fee
// calculation (see EIP-1559)
let miner_reward = if spec.is_eth2() {
let max_priority_fee_per_gas = test.0.transaction.max_priority_fee_per_gas();
let max_fee_per_gas = test.0.transaction.max_fee_per_gas();
let base_fee_per_gas = vicinity.block_base_fee_per_gas;
Expand All @@ -299,11 +306,14 @@ fn test_run(name: &str, test: Test) {
} else {
actual_fee
};

executor
.state_mut()
.deposit(vicinity.block_coinbase, mniner_reward);
.deposit(vicinity.block_coinbase, miner_reward);
executor.state_mut().deposit(caller, total_fee - actual_fee);

let (values, logs) = executor.into_state().deconstruct();

backend.apply(values, logs, delete_empty);
}

Expand Down

0 comments on commit 15d2bab

Please sign in to comment.