EIP 145: Bitwise shifting instructions in EVM (#8451)
* Add SHL, SHR, SAR opcodes * Add have_bitwise_shifting schedule flag * Add all EIP tests for SHL * Add SHR implementation and tests * Implement SAR and add tests * Add eip145transition config param * Change map_or to map_or_else when possible
This commit is contained in:
@@ -109,6 +109,8 @@ pub struct Schedule {
|
||||
pub have_static_call: bool,
|
||||
/// RETURNDATA and RETURNDATASIZE opcodes enabled.
|
||||
pub have_return_data: bool,
|
||||
/// SHL, SHR, SAR opcodes enabled.
|
||||
pub have_bitwise_shifting: bool,
|
||||
/// Kill basic accounts below this balance if touched.
|
||||
pub kill_dust: CleanDustMode,
|
||||
/// Enable EIP-86 rules
|
||||
@@ -194,6 +196,7 @@ impl Schedule {
|
||||
have_create2: false,
|
||||
have_revert: false,
|
||||
have_return_data: false,
|
||||
have_bitwise_shifting: false,
|
||||
stack_limit: 1024,
|
||||
max_depth: 1024,
|
||||
tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0],
|
||||
@@ -250,6 +253,13 @@ impl Schedule {
|
||||
schedule
|
||||
}
|
||||
|
||||
/// Schedule for the Constantinople fork of the Ethereum main net.
|
||||
pub fn new_constantinople() -> Schedule {
|
||||
let mut schedule = Self::new_byzantium();
|
||||
schedule.have_bitwise_shifting = true;
|
||||
schedule
|
||||
}
|
||||
|
||||
fn new(efcd: bool, hdc: bool, tcg: usize) -> Schedule {
|
||||
Schedule {
|
||||
exceptional_failed_code_deposit: efcd,
|
||||
@@ -257,6 +267,7 @@ impl Schedule {
|
||||
have_create2: false,
|
||||
have_revert: false,
|
||||
have_return_data: false,
|
||||
have_bitwise_shifting: false,
|
||||
stack_limit: 1024,
|
||||
max_depth: 1024,
|
||||
tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0],
|
||||
@@ -328,4 +339,3 @@ fn schedule_evm_assumptions() {
|
||||
assert_eq!(s1.quad_coeff_div, 512);
|
||||
assert_eq!(s2.quad_coeff_div, 512);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,13 @@ impl FakeExt {
|
||||
ext
|
||||
}
|
||||
|
||||
/// New fake externalities with constantinople schedule rules
|
||||
pub fn new_constantinople() -> Self {
|
||||
let mut ext = FakeExt::default();
|
||||
ext.schedule = Schedule::new_constantinople();
|
||||
ext
|
||||
}
|
||||
|
||||
/// Alter fake externalities to allow wasm
|
||||
pub fn with_wasm(mut self) -> Self {
|
||||
self.schedule.wasm = Some(Default::default());
|
||||
|
||||
Reference in New Issue
Block a user