Max code size on Kovan (#8067)

* Enable code size limit on kovan

* Fix formatting.
This commit is contained in:
Tomasz Drwięga 2018-03-07 15:11:09 +01:00 committed by Marek Kotewicz
parent f48b09b76e
commit d716bae3d5
14 changed files with 36 additions and 15 deletions

View File

@ -26,6 +26,7 @@
"minGasLimit": "0x1388", "minGasLimit": "0x1388",
"networkID" : "0x1", "networkID" : "0x1",
"maxCodeSize": 24576, "maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip98Transition": "0xffffffffffffffff", "eip98Transition": "0xffffffffffffffff",
"eip140Transition": "0x0", "eip140Transition": "0x0",
"eip211Transition": "0x0", "eip211Transition": "0x0",

View File

@ -26,6 +26,7 @@
"minGasLimit": "0x1388", "minGasLimit": "0x1388",
"networkID" : "0x1", "networkID" : "0x1",
"maxCodeSize": 24576, "maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip98Transition": "0xffffffffffffffff", "eip98Transition": "0xffffffffffffffff",
"eip140Transition": "0x0", "eip140Transition": "0x0",
"eip210Transition": "0x0", "eip210Transition": "0x0",

View File

@ -25,7 +25,8 @@
"eip98Transition": "0x7fffffffffffffff", "eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff", "eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff", "eip155Transition": "0x7fffffffffffffff",
"maxCodeSize": 24576 "maxCodeSize": 24576,
"maxCodeSizeTransition": "0x7fffffffffffffff"
}, },
"genesis": { "genesis": {
"seal": { "seal": {

View File

@ -25,7 +25,8 @@
"eip98Transition": "0x7fffffffffffffff", "eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff", "eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff", "eip155Transition": "0x7fffffffffffffff",
"maxCodeSize": 24576 "maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0"
}, },
"genesis": { "genesis": {
"seal": { "seal": {

View File

@ -152,6 +152,7 @@
"eip98Transition": "0x7fffffffffffff", "eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff", "eip86Transition": "0x7fffffffffffff",
"maxCodeSize": 24576, "maxCodeSize": 24576,
"maxCodeSizeTransition": 2675000,
"eip140Transition": 4370000, "eip140Transition": 4370000,
"eip211Transition": 4370000, "eip211Transition": 4370000,
"eip214Transition": 4370000, "eip214Transition": 4370000,

View File

@ -34,9 +34,11 @@
"networkID" : "0x2A", "networkID" : "0x2A",
"forkBlock": 4297256, "forkBlock": 4297256,
"forkCanonHash": "0x0a66d93c2f727dca618fabaf70c39b37018c73d78b939d8b11efbbd09034778f", "forkCanonHash": "0x0a66d93c2f727dca618fabaf70c39b37018c73d78b939d8b11efbbd09034778f",
"validateReceiptsTransition" : 1000000,
"eip155Transition": 1000000, "eip155Transition": 1000000,
"maxCodeSize": 24576,
"maxCodeSizeTransition": 6500000,
"validateChainIdTransition": 1000000, "validateChainIdTransition": 1000000,
"validateReceiptsTransition" : 1000000,
"eip140Transition": 5067000, "eip140Transition": 5067000,
"eip211Transition": 5067000, "eip211Transition": 5067000,
"eip214Transition": 5067000, "eip214Transition": 5067000,

View File

@ -40,7 +40,8 @@
"eip211Transition":"0x7fffffffffffff", "eip211Transition":"0x7fffffffffffff",
"eip214Transition":"0x7fffffffffffff", "eip214Transition":"0x7fffffffffffff",
"eip658Transition":"0x7fffffffffffff", "eip658Transition":"0x7fffffffffffff",
"maxCodeSize":"0x6000" "maxCodeSize":"0x6000",
"maxCodeSizeTransition": "0x7fffffffffffff"
}, },
"genesis":{ "genesis":{
"seal":{ "seal":{

View File

@ -40,7 +40,8 @@
"eip211Transition":"0x2a", "eip211Transition":"0x2a",
"eip214Transition":"0x2a", "eip214Transition":"0x2a",
"eip658Transition":"0x2a", "eip658Transition":"0x2a",
"maxCodeSize":"0x6000" "maxCodeSize":"0x6000",
"maxCodeSizeTransition": "0x7fffffffffffff"
}, },
"genesis":{ "genesis":{
"seal":{ "seal":{

View File

@ -40,7 +40,8 @@
"eip211Transition":"0x21e88e", "eip211Transition":"0x21e88e",
"eip214Transition":"0x21e88e", "eip214Transition":"0x21e88e",
"eip658Transition":"0x21e88e", "eip658Transition":"0x21e88e",
"maxCodeSize":"0x6000" "maxCodeSize":"0x6000",
"maxCodeSizeTransition": "0x7fffffffffffff"
}, },
"genesis":{ "genesis":{
"seal":{ "seal":{

View File

@ -29,6 +29,7 @@
"forkBlock": 641350, "forkBlock": 641350,
"forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb", "forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb",
"maxCodeSize": 24576, "maxCodeSize": 24576,
"maxCodeSizeTransition": 10,
"eip155Transition": 10, "eip155Transition": 10,
"eip98Transition": "0x7fffffffffffff", "eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff", "eip86Transition": "0x7fffffffffffff",

View File

@ -26,6 +26,7 @@
"minGasLimit": "0x1388", "minGasLimit": "0x1388",
"networkID" : "0x1", "networkID" : "0x1",
"maxCodeSize": 24576, "maxCodeSize": 24576,
"maxCodeSizeTransition": "0",
"eip98Transition": "5", "eip98Transition": "5",
"eip140Transition": "5", "eip140Transition": "5",
"eip211Transition": "5", "eip211Transition": "5",

View File

@ -263,15 +263,9 @@ impl EthereumMachine {
} else if block_number < ext.eip150_transition { } else if block_number < ext.eip150_transition {
Schedule::new_homestead() Schedule::new_homestead()
} else { } else {
// There's no max_code_size transition so we tie it to eip161abc let max_code_size = self.params.max_code_size(block_number);
let max_code_size = if block_number >= ext.eip161abc_transition {
self.params.max_code_size as usize
} else {
usize::max_value()
};
let mut schedule = Schedule::new_post_eip150( let mut schedule = Schedule::new_post_eip150(
max_code_size, max_code_size as _,
block_number >= ext.eip160_transition, block_number >= ext.eip160_transition,
block_number >= ext.eip161abc_transition, block_number >= ext.eip161abc_transition,
block_number >= ext.eip161d_transition block_number >= ext.eip161d_transition

View File

@ -118,6 +118,8 @@ pub struct CommonParams {
pub node_permission_contract: Option<Address>, pub node_permission_contract: Option<Address>,
/// Maximum contract code size that can be deployed. /// Maximum contract code size that can be deployed.
pub max_code_size: u64, 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. /// Transaction permission managing contract address.
pub transaction_permission_contract: Option<Address>, pub transaction_permission_contract: Option<Address>,
} }
@ -125,11 +127,20 @@ pub struct CommonParams {
impl CommonParams { impl CommonParams {
/// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net. /// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net.
pub fn schedule(&self, block_number: u64) -> ::vm::Schedule { 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); self.update_schedule(block_number, &mut schedule);
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. /// Apply common spec config parameters to the schedule.
pub fn update_schedule(&self, block_number: u64, schedule: &mut ::vm::Schedule) { pub fn update_schedule(&self, block_number: u64, schedule: &mut ::vm::Schedule) {
schedule.have_create2 = block_number >= self.eip86_transition; schedule.have_create2 = block_number >= self.eip86_transition;
@ -226,6 +237,7 @@ impl From<ethjson::spec::Params> for CommonParams {
registrar: p.registrar.map_or_else(Address::new, Into::into), registrar: p.registrar.map_or_else(Address::new, Into::into),
node_permission_contract: p.node_permission_contract.map(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: 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), transaction_permission_contract: p.transaction_permission_contract.map(Into::into),
wasm_activation_transition: p.wasm_activation_transition.map_or( wasm_activation_transition: p.wasm_activation_transition.map_or(
BlockNumber::max_value(), BlockNumber::max_value(),

View File

@ -113,6 +113,9 @@ pub struct Params {
/// See main EthashParams docs. /// See main EthashParams docs.
#[serde(rename="maxCodeSize")] #[serde(rename="maxCodeSize")]
pub max_code_size: Option<Uint>, pub max_code_size: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="maxCodeSizeTransition")]
pub max_code_size_transition: Option<Uint>,
/// Transaction permission contract address. /// Transaction permission contract address.
#[serde(rename="transactionPermissionContract")] #[serde(rename="transactionPermissionContract")]
pub transaction_permission_contract: Option<Address>, pub transaction_permission_contract: Option<Address>,