From d716bae3d512aab9fe39827a086196f4627d8d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Mar 2018 15:11:09 +0100 Subject: [PATCH] Max code size on Kovan (#8067) * Enable code size limit on kovan * Fix formatting. --- ethcore/res/ethereum/byzantium_test.json | 1 + ethcore/res/ethereum/constantinople_test.json | 1 + ethcore/res/ethereum/eip150_test.json | 3 ++- ethcore/res/ethereum/eip161_test.json | 3 ++- ethcore/res/ethereum/foundation.json | 1 + ethcore/res/ethereum/kovan.json | 4 +++- ethcore/res/ethereum/mcip3_test.json | 3 ++- ethcore/res/ethereum/mcip6_byz.json | 3 ++- ethcore/res/ethereum/musicoin.json | 3 ++- ethcore/res/ethereum/ropsten.json | 1 + ethcore/res/ethereum/transition_test.json | 1 + ethcore/src/machine.rs | 10 ++-------- ethcore/src/spec/spec.rs | 14 +++++++++++++- json/src/spec/params.rs | 3 +++ 14 files changed, 36 insertions(+), 15 deletions(-) diff --git a/ethcore/res/ethereum/byzantium_test.json b/ethcore/res/ethereum/byzantium_test.json index c267f94da37..40c7e465991 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 7cf3983747d..7b137e86fa0 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 4f3ce9ea301..60157c57168 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 164c3b0c9d8..ac1c0a5d1e3 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 09d04599839..4f6a6c2807d 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 64f1c947ce6..69f7e8b601b 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 098e146e318..d2e5ec8b6bc 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 da40d6882c3..8028e6b1bbb 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 2dcdb6d8f6c..efe81c58821 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 d298abf7dbb..6aad92505d9 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 ca2d77a4fe4..7c18fce4e54 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 b4f7651f86b..f2045b0a143 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 cd3a1f2ac13..1b52ac10f7e 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 53d88255b1d..4a1efe2a7f9 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
,