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

Fix Aztlan hard fork issues #11347

Merged
merged 8 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ethcore/evm/src/interpreter/gasometer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ fn calculate_eip1283_sstore_gas<Gas: evm::CostType>(schedule: &Schedule, origina
Gas::from(
if current == new {
// 1. If current value equals new value (this is a no-op), 200 gas is deducted.
sorpaas marked this conversation as resolved.
Show resolved Hide resolved
schedule.sload_gas
schedule.sstore_dirty_gas.unwrap_or(schedule.sload_gas)
} else {
// 2. If current value does not equal new value
if original == current {
Expand All @@ -392,7 +392,7 @@ fn calculate_eip1283_sstore_gas<Gas: evm::CostType>(schedule: &Schedule, origina
}
} else {
// 2.2. If original value does not equal current value (this storage slot is dirty), 200 gas is deducted. Apply both of the following clauses.
sorpaas marked this conversation as resolved.
Show resolved Hide resolved
schedule.sload_gas
schedule.sstore_dirty_gas.unwrap_or(schedule.sload_gas)

// 2.2.1. If original value is not 0
// 2.2.1.1. If current value is 0 (also means that new value is not 0), remove 15000 gas from refund counter. We can prove that refund counter will never go below 0.
Expand Down Expand Up @@ -442,11 +442,13 @@ pub fn handle_eip1283_sstore_clears_refund(ext: &mut dyn vm::Ext, original: &U25
// 2.2.2. If original value equals new value (this storage slot is reset)
if original.is_zero() {
// 2.2.2.1. If original value is 0, add 19800 gas to refund counter.
let refund = ext.schedule().sstore_set_gas - ext.schedule().sload_gas;
let refund = ext.schedule().sstore_set_gas
- ext.schedule().sstore_dirty_gas.unwrap_or(ext.schedule().sload_gas);
ext.add_sstore_refund(refund);
} else {
// 2.2.2.2. Otherwise, add 4800 gas to refund counter.
let refund = ext.schedule().sstore_reset_gas - ext.schedule().sload_gas;
let refund = ext.schedule().sstore_reset_gas
- ext.schedule().sstore_dirty_gas.unwrap_or(ext.schedule().sload_gas);
ext.add_sstore_refund(refund);
}
}
Expand Down
7 changes: 6 additions & 1 deletion ethcore/res/ethereum/classic.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
"eip658Transition": "0x85d9a0",
"eip145Transition": "0x921288",
"eip1014Transition": "0x921288",
"eip1052Transition": "0x921288"
"eip1052Transition": "0x921288",
"eip1283Transition": "0x1f67cf",
"eip1344Transition": "0x1f67cf",
"eip1706Transition": "0x1f67cf",
"eip2028Transition": "0x1f67cf",
"eip2200AdvanceTransition": "0x1f67cf"
},
"genesis": {
"seal": {
Expand Down
1 change: 1 addition & 0 deletions ethcore/res/ethereum/kotti.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"eip1344Transition": "0x1f67cf",
"eip1706Transition": "0x1f67cf",
"eip2028Transition": "0x1f67cf",
"eip2200AdvanceTransition": "0x1f67cf",
"gasLimitBoundDivisor": "0x400",
"maxCodeSize": "0x6000",
"maxCodeSizeTransition": "0xaef49",
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/mordor.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"eip1283Transition":"0xbe10b",
"eip1344Transition":"0xbe10b",
"eip1706Transition":"0xbe10b",
"eip2028Transition":"0xbe10b"
"eip2028Transition":"0xbe10b",
"eip2200AdvanceTransition": "0x1f67cf"
},
"genesis":{
"seal":{
Expand Down
9 changes: 9 additions & 0 deletions ethcore/types/src/engines/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ pub struct CommonParams {
pub eip1884_transition: BlockNumber,
/// Number of first block where EIP-2028 rules begin.
pub eip2028_transition: BlockNumber,
/// Number of first block where EIP-2200 advance transition begin.
pub eip2200_advance_transition: BlockNumber,
/// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin.
pub dust_protection_transition: BlockNumber,
/// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled.
Expand Down Expand Up @@ -185,6 +187,9 @@ impl CommonParams {
if block_number >= self.eip2028_transition {
schedule.tx_data_non_zero_gas = 16;
}
if block_number >= self.eip2200_advance_transition {
schedule.sstore_dirty_gas = Some(800);
}
if block_number >= self.eip210_transition {
schedule.blockhash_gas = 800;
}
Expand Down Expand Up @@ -322,6 +327,10 @@ impl From<ethjson::spec::Params> for CommonParams {
BlockNumber::max_value,
Into::into,
),
eip2200_advance_transition: p.eip2200_advance_transition.map_or_else(
BlockNumber::max_value,
Into::into,
),
dust_protection_transition: p.dust_protection_transition.map_or_else(
BlockNumber::max_value,
Into::into,
Expand Down
4 changes: 4 additions & 0 deletions ethcore/vm/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub struct Schedule {
pub sha3_word_gas: usize,
/// Gas price for loading from storage
pub sload_gas: usize,
/// Special gas price for dirty gas of SSTORE, after net gas metering.
pub sstore_dirty_gas: Option<usize>,
/// Gas price for setting new value to storage (`storage==0`, `new!=0`)
pub sstore_set_gas: usize,
/// Gas price for altering value in storage
Expand Down Expand Up @@ -240,6 +242,7 @@ impl Schedule {
sha3_gas: 30,
sha3_word_gas: 6,
sload_gas: 200,
sstore_dirty_gas: None,
sstore_set_gas: 20000,
sstore_reset_gas: 5000,
sstore_refund_gas: 15000,
Expand Down Expand Up @@ -331,6 +334,7 @@ impl Schedule {
sha3_gas: 30,
sha3_word_gas: 6,
sload_gas: 50,
sstore_dirty_gas: None,
sstore_set_gas: 20000,
sstore_reset_gas: 5000,
sstore_refund_gas: 15000,
Expand Down
2 changes: 2 additions & 0 deletions json/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ pub struct Params {
/// See `CommonParams` docs.
pub eip2028_transition: Option<Uint>,
/// See `CommonParams` docs.
pub eip2200_advance_transition: Option<Uint>,
/// See `CommonParams` docs.
pub dust_protection_transition: Option<Uint>,
/// See `CommonParams` docs.
pub nonce_cap_increment: Option<Uint>,
Expand Down