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

Commit

Permalink
Max code size on Kovan (#8067)
Browse files Browse the repository at this point in the history
* Enable code size limit on kovan

* Fix formatting.
  • Loading branch information
tomusdrw committed Mar 16, 2018
1 parent 638f5d1 commit 9c2be19
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 15 deletions.
1 change: 1 addition & 0 deletions ethcore/res/ethereum/byzantium_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"minGasLimit": "0x1388",
"networkID" : "0x1",
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip98Transition": "0xffffffffffffffff",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
Expand Down
1 change: 1 addition & 0 deletions ethcore/res/ethereum/constantinople_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"minGasLimit": "0x1388",
"networkID" : "0x1",
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip98Transition": "0xffffffffffffffff",
"eip140Transition": "0x0",
"eip210Transition": "0x0",
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/eip150_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"maxCodeSize": 24576
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/eip161_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"maxCodeSize": 24576
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0"
},
"genesis": {
"seal": {
Expand Down
1 change: 1 addition & 0 deletions ethcore/res/ethereum/foundation.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff",
"maxCodeSize": 24576,
"maxCodeSizeTransition": 2675000,
"eip140Transition": 4370000,
"eip211Transition": 4370000,
"eip214Transition": 4370000,
Expand Down
4 changes: 3 additions & 1 deletion ethcore/res/ethereum/kovan.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/mcip3_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"eip211Transition":"0x7fffffffffffff",
"eip214Transition":"0x7fffffffffffff",
"eip658Transition":"0x7fffffffffffff",
"maxCodeSize":"0x6000"
"maxCodeSize":"0x6000",
"maxCodeSizeTransition": "0x7fffffffffffff"
},
"genesis":{
"seal":{
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/mcip6_byz.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"eip211Transition":"0x2a",
"eip214Transition":"0x2a",
"eip658Transition":"0x2a",
"maxCodeSize":"0x6000"
"maxCodeSize":"0x6000",
"maxCodeSizeTransition": "0x7fffffffffffff"
},
"genesis":{
"seal":{
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/musicoin.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"eip211Transition":"0x21e88e",
"eip214Transition":"0x21e88e",
"eip658Transition":"0x21e88e",
"maxCodeSize":"0x6000"
"maxCodeSize":"0x6000",
"maxCodeSizeTransition": "0x7fffffffffffff"
},
"genesis":{
"seal":{
Expand Down
1 change: 1 addition & 0 deletions ethcore/res/ethereum/ropsten.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"forkBlock": 641350,
"forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb",
"maxCodeSize": 24576,
"maxCodeSizeTransition": 10,
"eip155Transition": 10,
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff",
Expand Down
1 change: 1 addition & 0 deletions ethcore/res/ethereum/transition_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"minGasLimit": "0x1388",
"networkID" : "0x1",
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0",
"eip98Transition": "5",
"eip140Transition": "5",
"eip211Transition": "5",
Expand Down
10 changes: 2 additions & 8 deletions ethcore/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,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
Expand Down
14 changes: 13 additions & 1 deletion ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,29 @@ pub struct CommonParams {
pub node_permission_contract: Option<Address>,
/// 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<Address>,
}

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;
Expand Down Expand Up @@ -228,6 +239,7 @@ impl From<ethjson::spec::Params> 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(),
Expand Down
3 changes: 3 additions & 0 deletions json/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ pub struct Params {
/// See main EthashParams docs.
#[serde(rename="maxCodeSize")]
pub max_code_size: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="maxCodeSizeTransition")]
pub max_code_size_transition: Option<Uint>,
/// Transaction permission contract address.
#[serde(rename="transactionPermissionContract")]
pub transaction_permission_contract: Option<Address>,
Expand Down

0 comments on commit 9c2be19

Please sign in to comment.