[Beta] Backports (#7945)

* ECIP 1041 - Remove Difficulty Bomb (#7905)

Enable difficulty bomb defusion at block:
 - 5900000 on Ethereum Classic mainnet,
 - 2300000 on morden testnet.

Reference:
https://github.com/ethereumproject/ECIPs/blob/master/ECIPs/ECIP-1041.md

* spec: Validate required divisor fields are not 0 (#7933)

* Add validate_non_zero function

It's used to validate that a Spec's uint field used as a divisor is not zero.

* Add deserialize_with to gas_limit_bound_divisor

Prevents panics due to divide-by-zero on the gas_limit_bound_divisor
field.

* Add deserialize_with to difficulty_bound_divisor

Prevents panics due to divide-by-zero on the difficulty_bound_divisor
field.

* Add validate_optional_non_zero function

Used to validate Option<Uint> divisor fields.

* Use deserialize_with on optional divisor fields.

* Add #[serde(default)] attribute to divisor fields

When using `#[serde(deserialize_with)]`, `#[serde(default)]` must be specified so that missing
fields can be deserialized with the deserializer for `None`.

* Kovan WASM fork code (#7849)

* kovan fork code

* introduce ethcore level vm_factory and let it fail

* fix json tests

* wasmcosts as option

* review changes

* wasm costs in parser

* fix evm tests

* review fixes

* fix test

* remove redundant json field
This commit is contained in:
André Silva
2018-02-19 15:05:21 +00:00
committed by Rando
parent 3bfb2fa1aa
commit 804ddfe31e
32 changed files with 402 additions and 169 deletions

View File

@@ -16,7 +16,7 @@
//! Spec params deserialization.
use uint::Uint;
use uint::{self, Uint};
use hash::{H256, Address};
use bytes::Bytes;
@@ -98,10 +98,9 @@ pub struct Params {
pub nonce_cap_increment: Option<Uint>,
/// See `CommonParams` docs.
pub remove_dust_contracts : Option<bool>,
/// Wasm support flag
pub wasm: Option<bool>,
/// See `CommonParams` docs.
#[serde(rename="gasLimitBoundDivisor")]
#[serde(deserialize_with="uint::validate_non_zero")]
pub gas_limit_bound_divisor: Uint,
/// See `CommonParams` docs.
pub registrar: Option<Address>,
@@ -117,6 +116,9 @@ pub struct Params {
/// Transaction permission contract address.
#[serde(rename="transactionPermissionContract")]
pub transaction_permission_contract: Option<Address>,
/// Wasm activation block height, if not activated from start
#[serde(rename="wasmActivationTransition")]
pub wasm_activation_transition: Option<Uint>,
}
#[cfg(test)]
@@ -136,7 +138,8 @@ mod tests {
"minGasLimit": "0x1388",
"accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x20",
"maxCodeSize": "0x1000"
"maxCodeSize": "0x1000",
"wasmActivationTransition": "0x1010"
}"#;
let deserialized: Params = serde_json::from_str(s).unwrap();
@@ -148,5 +151,23 @@ mod tests {
assert_eq!(deserialized.account_start_nonce, Some(Uint(U256::from(0x01))));
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))));
}
#[test]
#[should_panic(expected = "a non-zero value")]
fn test_zero_value_divisor() {
let s = r#"{
"maximumExtraDataSize": "0x20",
"networkID" : "0x1",
"chainID" : "0x15",
"subprotocolName" : "exp",
"minGasLimit": "0x1388",
"accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x0",
"maxCodeSize": "0x1000"
}"#;
let _deserialized: Params = serde_json::from_str(s).unwrap();
}
}