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:
@@ -105,6 +105,8 @@ pub struct CommonParams {
|
||||
pub eip211_transition: BlockNumber,
|
||||
/// Number of first block where EIP-214 rules begin.
|
||||
pub eip214_transition: BlockNumber,
|
||||
/// Number of first block where EIP-145 rules begin.
|
||||
pub eip145_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.
|
||||
@@ -152,6 +154,7 @@ impl CommonParams {
|
||||
schedule.have_revert = block_number >= self.eip140_transition;
|
||||
schedule.have_static_call = block_number >= self.eip214_transition;
|
||||
schedule.have_return_data = block_number >= self.eip211_transition;
|
||||
schedule.have_bitwise_shifting = block_number >= self.eip145_transition;
|
||||
if block_number >= self.eip210_transition {
|
||||
schedule.blockhash_gas = 800;
|
||||
}
|
||||
@@ -198,16 +201,16 @@ impl From<ethjson::spec::Params> for CommonParams {
|
||||
eip155_transition: p.eip155_transition.map_or(0, Into::into),
|
||||
validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into),
|
||||
validate_chain_id_transition: p.validate_chain_id_transition.map_or(0, Into::into),
|
||||
eip86_transition: p.eip86_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip86_transition: p.eip86_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
eip140_transition: p.eip140_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip140_transition: p.eip140_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
eip210_transition: p.eip210_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip210_transition: p.eip210_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
eip210_contract_address: p.eip210_contract_address.map_or(0xf0.into(), Into::into),
|
||||
@@ -220,20 +223,24 @@ impl From<ethjson::spec::Params> for CommonParams {
|
||||
Into::into,
|
||||
),
|
||||
eip210_contract_gas: p.eip210_contract_gas.map_or(1000000.into(), Into::into),
|
||||
eip211_transition: p.eip211_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip211_transition: p.eip211_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
eip214_transition: p.eip214_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip145_transition: p.eip145_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
eip658_transition: p.eip658_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip214_transition: p.eip214_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
dust_protection_transition: p.dust_protection_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
eip658_transition: p.eip658_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
dust_protection_transition: p.dust_protection_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into,
|
||||
),
|
||||
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
|
||||
@@ -245,8 +252,8 @@ impl From<ethjson::spec::Params> for CommonParams {
|
||||
max_transaction_size: p.max_transaction_size.map_or(MAX_TRANSACTION_SIZE, Into::into),
|
||||
max_code_size_transition: p.max_code_size_transition.map_or(0, Into::into),
|
||||
transaction_permission_contract: p.transaction_permission_contract.map(Into::into),
|
||||
wasm_activation_transition: p.wasm_activation_transition.map_or(
|
||||
BlockNumber::max_value(),
|
||||
wasm_activation_transition: p.wasm_activation_transition.map_or_else(
|
||||
BlockNumber::max_value,
|
||||
Into::into
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user