diff --git a/ethcore/res/ethereum/byzantium_test.json b/ethcore/res/ethereum/byzantium_test.json index c267f94da..40c7e4659 100644 --- a/ethcore/res/ethereum/byzantium_test.json +++ b/ethcore/res/ethereum/byzantium_test.json @@ -26,6 +26,7 @@ "minGasLimit": "0x1388", "networkID" : "0x1", "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x0", "eip98Transition": "0xffffffffffffffff", "eip140Transition": "0x0", "eip211Transition": "0x0", diff --git a/ethcore/res/ethereum/constantinople_test.json b/ethcore/res/ethereum/constantinople_test.json index 7cf398374..7b137e86f 100644 --- a/ethcore/res/ethereum/constantinople_test.json +++ b/ethcore/res/ethereum/constantinople_test.json @@ -26,6 +26,7 @@ "minGasLimit": "0x1388", "networkID" : "0x1", "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x0", "eip98Transition": "0xffffffffffffffff", "eip140Transition": "0x0", "eip210Transition": "0x0", diff --git a/ethcore/res/ethereum/eip150_test.json b/ethcore/res/ethereum/eip150_test.json index 4f3ce9ea3..60157c571 100644 --- a/ethcore/res/ethereum/eip150_test.json +++ b/ethcore/res/ethereum/eip150_test.json @@ -25,7 +25,8 @@ "eip98Transition": "0x7fffffffffffffff", "eip86Transition": "0x7fffffffffffffff", "eip155Transition": "0x7fffffffffffffff", - "maxCodeSize": 24576 + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x7fffffffffffffff" }, "genesis": { "seal": { diff --git a/ethcore/res/ethereum/eip161_test.json b/ethcore/res/ethereum/eip161_test.json index 164c3b0c9..ac1c0a5d1 100644 --- a/ethcore/res/ethereum/eip161_test.json +++ b/ethcore/res/ethereum/eip161_test.json @@ -25,7 +25,8 @@ "eip98Transition": "0x7fffffffffffffff", "eip86Transition": "0x7fffffffffffffff", "eip155Transition": "0x7fffffffffffffff", - "maxCodeSize": 24576 + "maxCodeSize": 24576, + "maxCodeSizeTransition": "0x0" }, "genesis": { "seal": { diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index 09d045998..4f6a6c280 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -152,6 +152,7 @@ "eip98Transition": "0x7fffffffffffff", "eip86Transition": "0x7fffffffffffff", "maxCodeSize": 24576, + "maxCodeSizeTransition": 2675000, "eip140Transition": 4370000, "eip211Transition": 4370000, "eip214Transition": 4370000, diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index 64f1c947c..69f7e8b60 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -34,9 +34,11 @@ "networkID" : "0x2A", "forkBlock": 4297256, "forkCanonHash": "0x0a66d93c2f727dca618fabaf70c39b37018c73d78b939d8b11efbbd09034778f", - "validateReceiptsTransition" : 1000000, "eip155Transition": 1000000, + "maxCodeSize": 24576, + "maxCodeSizeTransition": 6500000, "validateChainIdTransition": 1000000, + "validateReceiptsTransition" : 1000000, "eip140Transition": 5067000, "eip211Transition": 5067000, "eip214Transition": 5067000, diff --git a/ethcore/res/ethereum/mcip3_test.json b/ethcore/res/ethereum/mcip3_test.json index 098e146e3..d2e5ec8b6 100644 --- a/ethcore/res/ethereum/mcip3_test.json +++ b/ethcore/res/ethereum/mcip3_test.json @@ -40,7 +40,8 @@ "eip211Transition":"0x7fffffffffffff", "eip214Transition":"0x7fffffffffffff", "eip658Transition":"0x7fffffffffffff", - "maxCodeSize":"0x6000" + "maxCodeSize":"0x6000", + "maxCodeSizeTransition": "0x7fffffffffffff" }, "genesis":{ "seal":{ diff --git a/ethcore/res/ethereum/mcip6_byz.json b/ethcore/res/ethereum/mcip6_byz.json index da40d6882..8028e6b1b 100644 --- a/ethcore/res/ethereum/mcip6_byz.json +++ b/ethcore/res/ethereum/mcip6_byz.json @@ -40,7 +40,8 @@ "eip211Transition":"0x2a", "eip214Transition":"0x2a", "eip658Transition":"0x2a", - "maxCodeSize":"0x6000" + "maxCodeSize":"0x6000", + "maxCodeSizeTransition": "0x7fffffffffffff" }, "genesis":{ "seal":{ diff --git a/ethcore/res/ethereum/musicoin.json b/ethcore/res/ethereum/musicoin.json index 2dcdb6d8f..efe81c588 100644 --- a/ethcore/res/ethereum/musicoin.json +++ b/ethcore/res/ethereum/musicoin.json @@ -40,7 +40,8 @@ "eip211Transition":"0x21e88e", "eip214Transition":"0x21e88e", "eip658Transition":"0x21e88e", - "maxCodeSize":"0x6000" + "maxCodeSize":"0x6000", + "maxCodeSizeTransition": "0x7fffffffffffff" }, "genesis":{ "seal":{ diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index d298abf7d..6aad92505 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -29,6 +29,7 @@ "forkBlock": 641350, "forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb", "maxCodeSize": 24576, + "maxCodeSizeTransition": 10, "eip155Transition": 10, "eip98Transition": "0x7fffffffffffff", "eip86Transition": "0x7fffffffffffff", diff --git a/ethcore/res/ethereum/transition_test.json b/ethcore/res/ethereum/transition_test.json index ca2d77a4f..7c18fce4e 100644 --- a/ethcore/res/ethereum/transition_test.json +++ b/ethcore/res/ethereum/transition_test.json @@ -26,6 +26,7 @@ "minGasLimit": "0x1388", "networkID" : "0x1", "maxCodeSize": 24576, + "maxCodeSizeTransition": "0", "eip98Transition": "5", "eip140Transition": "5", "eip211Transition": "5", diff --git a/ethcore/src/machine.rs b/ethcore/src/machine.rs index b4f7651f8..f2045b0a1 100644 --- a/ethcore/src/machine.rs +++ b/ethcore/src/machine.rs @@ -263,15 +263,9 @@ impl EthereumMachine { } else if block_number < ext.eip150_transition { Schedule::new_homestead() } else { - // There's no max_code_size transition so we tie it to eip161abc - let max_code_size = if block_number >= ext.eip161abc_transition { - self.params.max_code_size as usize - } else { - usize::max_value() - }; - + let max_code_size = self.params.max_code_size(block_number); let mut schedule = Schedule::new_post_eip150( - max_code_size, + max_code_size as _, block_number >= ext.eip160_transition, block_number >= ext.eip161abc_transition, block_number >= ext.eip161d_transition diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index cd3a1f2ac..1b52ac10f 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -118,6 +118,8 @@ pub struct CommonParams { pub node_permission_contract: Option
, /// Maximum contract code size that can be deployed. pub max_code_size: u64, + /// Number of first block where max code size limit is active. + pub max_code_size_transition: BlockNumber, /// Transaction permission managing contract address. pub transaction_permission_contract: Option
, } @@ -125,11 +127,20 @@ pub struct CommonParams { impl CommonParams { /// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net. pub fn schedule(&self, block_number: u64) -> ::vm::Schedule { - let mut schedule = ::vm::Schedule::new_post_eip150(self.max_code_size as _, true, true, true); + let mut schedule = ::vm::Schedule::new_post_eip150(self.max_code_size(block_number) as _, true, true, true); self.update_schedule(block_number, &mut schedule); schedule } + /// Returns max code size at given block. + pub fn max_code_size(&self, block_number: u64) -> u64 { + if block_number >= self.max_code_size_transition { + self.max_code_size + } else { + u64::max_value() + } + } + /// Apply common spec config parameters to the schedule. pub fn update_schedule(&self, block_number: u64, schedule: &mut ::vm::Schedule) { schedule.have_create2 = block_number >= self.eip86_transition; @@ -226,6 +237,7 @@ impl From for CommonParams { registrar: p.registrar.map_or_else(Address::new, Into::into), node_permission_contract: p.node_permission_contract.map(Into::into), max_code_size: p.max_code_size.map_or(u64::max_value(), 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(), diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index 53d88255b..4a1efe2a7 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -113,6 +113,9 @@ pub struct Params { /// See main EthashParams docs. #[serde(rename="maxCodeSize")] pub max_code_size: Option, + /// See main EthashParams docs. + #[serde(rename="maxCodeSizeTransition")] + pub max_code_size_transition: Option, /// Transaction permission contract address. #[serde(rename="transactionPermissionContract")] pub transaction_permission_contract: Option
,