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

Add wasmDisableTransition spec option #11879

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 18 additions & 3 deletions ethcore/machine/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ mod tests {

let mut info = EnvInfo::default();

// 100 > 10
// 200 (wasmDisableTransition) > 100 > 10 (wasmActivationTransition)
info.number = 100;

// Network with wasm activated at block 10
Expand All @@ -2301,19 +2301,34 @@ mod tests {
// Transaction successfully returned sender
assert_eq!(output[..], sender[..]);

// 1 < 10
// 1 < 10 (wasmActivationTransition)
info.number = 1;

let mut output = [0u8; 20];
let FinalizationResult { gas_left: result, return_data, .. } = {
let schedule = machine.schedule(info.number);
let mut ex = Executive::new(&mut state, &info, &machine, &schedule);
ex.call(params, &mut Substate::new(), &mut NoopTracer, &mut NoopVMTracer).unwrap()
ex.call(params.clone(), &mut Substate::new(), &mut NoopTracer, &mut NoopVMTracer).unwrap()
};
(&mut output[..((cmp::min(20, return_data.len())))]).copy_from_slice(&return_data[..(cmp::min(20, return_data.len()))]);

assert_eq!(result, U256::from(20025));
// Since transaction errored due to wasm was not activated, result is just empty
assert_eq!(output[..], [0u8; 20][..]);

// 200 == wasmDisableTransition
info.number = 200;

let mut output = [0u8; 20];
let FinalizationResult { gas_left: result, return_data, .. } = {
let schedule = machine.schedule(info.number);
let mut ex = Executive::new(&mut state, &info, &machine, &schedule);
ex.call(params, &mut Substate::new(), &mut NoopTracer, &mut NoopVMTracer).unwrap()
};
(&mut output[..((cmp::min(20, return_data.len())))]).copy_from_slice(&return_data[..(cmp::min(20, return_data.len()))]);

assert_eq!(result, U256::from(20025));
// Since transaction errored due to wasm was deactivated, result is just empty
assert_eq!(output[..], [0u8; 20][..]);
}
}
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/test-specs/kovan_wasm_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"eip211Transition": 5067000,
"eip214Transition": 5067000,
"eip658Transition": 5067000,
"wasmActivationTransition": 10
"wasmActivationTransition": 10,
"wasmDisableTransition": 200
},
"genesis": {
"seal": {
Expand Down
1 change: 1 addition & 0 deletions ethcore/spec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ impl Spec {
params.eip2315_transition,
params.dust_protection_transition,
params.wasm_activation_transition,
params.wasm_disable_transition,
params.kip4_transition,
params.kip6_transition,
params.max_code_size_transition,
Expand Down
8 changes: 7 additions & 1 deletion ethcore/types/src/engines/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ pub struct CommonParams {
pub remove_dust_contracts: bool,
/// Wasm activation blocknumber, if any disabled initially.
pub wasm_activation_transition: BlockNumber,
/// Wasm deactivation blocknumber, if enabled.
pub wasm_disable_transition: BlockNumber,
/// Wasm account version, activated after `wasm_activation_transition`. If this field is defined, do not use code
/// prefix to determine VM to execute.
pub wasm_version: Option<U256>,
Expand Down Expand Up @@ -208,7 +210,7 @@ impl CommonParams {
false => vm::CleanDustMode::BasicOnly,
};
}
if block_number >= self.wasm_activation_transition {
if block_number >= self.wasm_activation_transition && block_number < self.wasm_disable_transition {
let mut wasm = vm::WasmCosts::default();
if block_number >= self.kip4_transition {
wasm.have_create2 = true;
Expand Down Expand Up @@ -367,6 +369,10 @@ impl From<ethjson::spec::Params> for CommonParams {
BlockNumber::max_value,
Into::into
),
wasm_disable_transition: p.wasm_disable_transition.map_or_else(
BlockNumber::max_value,
Into::into
),
wasm_version: p.wasm_version.map(Into::into),
kip4_transition: p.kip4_transition.map_or_else(
BlockNumber::max_value,
Expand Down
6 changes: 5 additions & 1 deletion json/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ pub struct Params {
pub transaction_permission_contract_transition: Option<Uint>,
/// Wasm activation block height, if not activated from start.
pub wasm_activation_transition: Option<Uint>,
/// Wasm deactivation block height, if activated.
pub wasm_disable_transition: Option<Uint>,
/// Define a separate wasm version instead of using the prefix.
pub wasm_version: Option<Uint>,
/// KIP4 activiation block height.
Expand All @@ -163,7 +165,8 @@ mod tests {
"accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x20",
"maxCodeSize": "0x1000",
"wasmActivationTransition": "0x1010"
"wasmActivationTransition": "0x1010",
"wasmDisableTransition": "0x2010"
}"#;

let deserialized: Params = serde_json::from_str(s).unwrap();
Expand All @@ -176,6 +179,7 @@ mod tests {
assert_eq!(deserialized.gas_limit_bound_divisor, Uint(U256::from(0x20)));
assert_eq!(deserialized.max_code_size, Some(Uint(U256::from(0x1000))));
assert_eq!(deserialized.wasm_activation_transition, Some(Uint(U256::from(0x1010))));
assert_eq!(deserialized.wasm_disable_transition, Some(Uint(U256::from(0x2010))));
}

#[test]
Expand Down