diff --git a/CHANGELOG.md b/CHANGELOG.md index 809742722a2..061f25db68b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## Parity-Ethereum [v2.5.12](https://github.com/paritytech/parity-ethereum/releases/tag/v2.5.12) + +Parity Ethereum v2.5.12-stable is a patch release that adds Istanbul hardfork +block numbers for POA and xDai networks, implements ECIP-1056 and implements +EIP-2384/2387 - Muir Glacier. + +The full list of included changes: +* Enable EIP-2384 for ice age hard fork (#11281) +* ethcore/res: activate agharta on classic 9573000 (#11331) +* Istanbul HF in xDai (2019-12-12) (#11299) +* Istanbul HF in POA Core (2019-12-19) (#11298) +* Istanbul HF in POA Sokol (2019-12-05) (#11282) +* Activate ecip-1061 on kotti and mordor (#11338) +* Enable basic verification of local transactions (#11332) +* Disallow EIP-86 style null signatures for transactions outside tests (#11335) + + ## Parity-Ethereum [v2.5.11](https://github.com/paritytech/parity-ethereum/releases/tag/v2.5.11) Parity Ethereum v2.5.11-stable is an emergency patch release that adds the missing diff --git a/Cargo.lock b/Cargo.lock index f0588ce224e..0be3e4cf95b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2726,7 +2726,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "jni 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", - "parity-ethereum 2.5.11", + "parity-ethereum 2.5.12", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2783,7 +2783,7 @@ dependencies = [ [[package]] name = "parity-ethereum" -version = "2.5.11" +version = "2.5.12" dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2836,7 +2836,7 @@ dependencies = [ "parity-rpc 1.12.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-version 2.5.11", + "parity-version 2.5.12", "parity-whisper 0.1.0", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2982,7 +2982,7 @@ dependencies = [ "parity-crypto 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-version 2.5.11", + "parity-version 2.5.12", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3080,7 +3080,7 @@ dependencies = [ "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.12.0", "parity-path 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-version 2.5.11", + "parity-version 2.5.12", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3090,7 +3090,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "2.5.11" +version = "2.5.12" dependencies = [ "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 56b1cb000dc..9ce76e03220 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ description = "Parity Ethereum client" name = "parity-ethereum" # NOTE Make sure to update util/version/Cargo.toml as well -version = "2.5.11" +version = "2.5.12" license = "GPL-3.0" authors = ["Parity Technologies "] diff --git a/ethcore/res/ethereum/classic.json b/ethcore/res/ethereum/classic.json index 200fa823c47..d598a4ec91f 100644 --- a/ethcore/res/ethereum/classic.json +++ b/ethcore/res/ethereum/classic.json @@ -37,7 +37,10 @@ "eip140Transition": "0x85d9a0", "eip211Transition": "0x85d9a0", "eip214Transition": "0x85d9a0", - "eip658Transition": "0x85d9a0" + "eip658Transition": "0x85d9a0", + "eip145Transition": "0x921288", + "eip1014Transition": "0x921288", + "eip1052Transition": "0x921288" }, "genesis": { "seal": { diff --git a/ethcore/res/ethereum/foundation.json b/ethcore/res/ethereum/foundation.json index 417b6fbe0b3..48550d7df26 100644 --- a/ethcore/res/ethereum/foundation.json +++ b/ethcore/res/ethereum/foundation.json @@ -136,7 +136,8 @@ "eip100bTransition": "0x42ae50", "difficultyBombDelays": { "0x42ae50": "0x2dc6c0", - "0x6f1580": "0x1e8480" + "0x6f1580": "0x1e8480", + "0x8c6180": "0x3d0900" } } } diff --git a/ethcore/res/ethereum/kotti.json b/ethcore/res/ethereum/kotti.json index 7876fe8cd2b..25ba6196185 100644 --- a/ethcore/res/ethereum/kotti.json +++ b/ethcore/res/ethereum/kotti.json @@ -24,6 +24,10 @@ "eip658Transition": "0xaef49", "eip1014Transition": "0x1a064d", "eip1052Transition": "0x1a064d", + "eip1283Transition": "0x1f67cf", + "eip1344Transition": "0x1f67cf", + "eip1706Transition": "0x1f67cf", + "eip2028Transition": "0x1f67cf", "gasLimitBoundDivisor": "0x400", "maxCodeSize": "0x6000", "maxCodeSizeTransition": "0xaef49", @@ -123,7 +127,7 @@ "0xaef49": { "price": { "alt_bn128_const_operations": { "price": 500 }} }, - "0x7fffffffffffff": { + "0x1f67cf": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 150 }} } @@ -138,7 +142,7 @@ "0xaef49": { "price": { "alt_bn128_const_operations": { "price": 40000 }} }, - "0x7fffffffffffff": { + "0x1f67cf": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 6000 }} } @@ -153,7 +157,7 @@ "0xaef49": { "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, - "0x7fffffffffffff": { + "0x1f67cf": { "info": "EIP 1108 transition", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } @@ -161,7 +165,16 @@ } }, "0x0000000000000000000000000000000000000009": { - "balance": "0x1" + "balance": "0x1", + "builtin": { + "name": "blake2_f", + "activate_at": "0x1f67cf", + "pricing": { + "blake2_f": { + "gas_per_round": 1 + } + } + } }, "0x000000000000000000000000000000000000000a": { "balance": "0x1" diff --git a/ethcore/res/ethereum/mordor.json b/ethcore/res/ethereum/mordor.json index ceaa9de6d51..c5ae911f067 100644 --- a/ethcore/res/ethereum/mordor.json +++ b/ethcore/res/ethereum/mordor.json @@ -37,7 +37,11 @@ "eip658Transition":"0x0", "eip145Transition":"0x498bb", "eip1014Transition":"0x498bb", - "eip1052Transition":"0x498bb" + "eip1052Transition":"0x498bb", + "eip1283Transition":"0xbe10b", + "eip1344Transition":"0xbe10b", + "eip1706Transition":"0xbe10b", + "eip2028Transition":"0xbe10b" }, "genesis":{ "seal":{ @@ -59,7 +63,9 @@ "enode://1813e90a0afdd7c1e4892c5376960e3577a9e6c5a4f86fa405a405c7421a4a1608248d77cc90333842f13d8954d82113dec480cfb76b4fef8cb475157cf4d5f2@10.28.224.3:30000", "enode://2b69a3926f36a7748c9021c34050be5e0b64346225e477fe7377070f6289bd363b2be73a06010fd516e6ea3ee90778dd0399bc007bb1281923a79374f842675a@51.15.116.226:30303", "enode://621e28e529146fd501709194885f50540c494f1a2985d1fb4ec8769226b5cb0b0d1a11545926077821474c2767cdd87888ead8a2509a2c9069dd5584e4b1c3b8@10.28.223.8:30000", - "enode://a59e33ccd2b3e52d578f1fbd70c6f9babda2650f0760d6ff3b37742fdcdfdb3defba5d56d315b40c46b70198c7621e63ffa3f987389c7118634b0fefbbdfa7fd@51.15.116.226:30303" + "enode://a59e33ccd2b3e52d578f1fbd70c6f9babda2650f0760d6ff3b37742fdcdfdb3defba5d56d315b40c46b70198c7621e63ffa3f987389c7118634b0fefbbdfa7fd@51.15.116.226:30303", + "enode://f840b007500f50c98ea6f9c9e56dabf4690bbbbb7036d43682c531204341aff8315013547e5bee54117eb22bd3603585ae6bf713d9fa710659533fcab65d5b84@35.238.101.58:30000", + "enode://19eda672030ad5debb98c9069b3e99d12438b96506325d9f3f82d76c5f8ce4942d345f41700a5223900e75ad48e76713b74c1b694d67a10c2112540035922256@35.238.101.58:30000" ], "accounts":{ "0x0000000000000000000000000000000000000001":{ @@ -128,7 +134,7 @@ } } }, - "0x7fffffffffffff":{ + "0xbe10b":{ "info":"EIP 1108 transition", "price":{ "alt_bn128_const_operations":{ @@ -150,7 +156,7 @@ } } }, - "0x7fffffffffffff":{ + "0xbe10b":{ "info":"EIP 1108 transition", "price":{ "alt_bn128_const_operations":{ @@ -173,7 +179,7 @@ } } }, - "0x7fffffffffffff":{ + "0xbe10b":{ "info":"EIP 1108 transition", "price":{ "alt_bn128_pairing":{ @@ -184,6 +190,17 @@ } } } + }, + "0x0000000000000000000000000000000000000009": { + "builtin": { + "name": "blake2_f", + "activate_at": "0xbe10b", + "pricing": { + "blake2_f": { + "gas_per_round": 1 + } + } + } } } } diff --git a/ethcore/res/ethereum/poacore.json b/ethcore/res/ethereum/poacore.json index 379dcd583fa..ecdd04c51fc 100644 --- a/ethcore/res/ethereum/poacore.json +++ b/ethcore/res/ethereum/poacore.json @@ -37,7 +37,12 @@ "eip658Transition": "0x0", "eip145Transition": 8582254, "eip1014Transition": 8582254, - "eip1052Transition": 8582254 + "eip1052Transition": 8582254, + "eip1283Transition": 12598600, + "eip1344Transition": 12598600, + "eip1706Transition": 12598600, + "eip1884Transition": 12598600, + "eip2028Transition": 12598600 }, "genesis": { "seal": { @@ -58,57 +63,89 @@ "enode://96678da10ac83769ab3f63114a41b57b700476c5ac02719b878fa89909a936551bb7609aa09b068bf89903206fa03f23e1b5b9117ca278de304c2570b87dcb27@35.175.15.164:30303" ], "accounts": { - "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x0", "pricing": { "modexp": { "divisor": 20 } } } }, - "0000000000000000000000000000000000000006": { + "0x0000000000000000000000000000000000000005": { + "builtin": { + "name": "modexp", + "pricing": { + "0": { + "price": { + "modexp": { + "divisor": 20 + } + } + } + } + } + }, + "0x0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", "pricing": { "0": { "price": { "alt_bn128_const_operations": { "price": 500 }} }, - "0x7fffffffffffff": { + "12598600": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 150 }} } } } }, - "0000000000000000000000000000000000000007": { + "0x0000000000000000000000000000000000000007": { "builtin": { "name": "alt_bn128_mul", "pricing": { "0": { "price": { "alt_bn128_const_operations": { "price": 40000 }} }, - "0x7fffffffffffff": { + "12598600": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 6000 }} } } } }, - "0000000000000000000000000000000000000008": { + "0x0000000000000000000000000000000000000008": { "builtin": { "name": "alt_bn128_pairing", "pricing": { "0": { "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, - "0x7fffffffffffff": { + "12598600": { "info": "EIP 1108 transition", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } }, + "0x0000000000000000000000000000000000000009": { + "builtin": { + "name": "blake2_f", + "pricing": { + "12598600": { + "info": "EIP 1108 transition", + "price": { + "blake2_f": { + "gas_per_round": 1 + } + } + } + } + } + }, "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { - "linear": { - "base": 3000, - "word": 0 + "0": { + "price": { + "linear": { + "base": 3000, + "word": 0 + } + } } } } @@ -118,9 +155,13 @@ "builtin": { "name": "sha256", "pricing": { - "linear": { - "base": 60, - "word": 12 + "0": { + "price": { + "linear": { + "base": 60, + "word": 12 + } + } } } } @@ -130,9 +171,13 @@ "builtin": { "name": "ripemd160", "pricing": { - "linear": { - "base": 600, - "word": 120 + "0": { + "price": { + "linear": { + "base": 600, + "word": 120 + } + } } } } @@ -142,9 +187,13 @@ "builtin": { "name": "identity", "pricing": { - "linear": { - "base": 15, - "word": 3 + "0": { + "price": { + "linear": { + "base": 15, + "word": 3 + } + } } } } diff --git a/ethcore/res/ethereum/poasokol.json b/ethcore/res/ethereum/poasokol.json index db39c46540f..31fb85c49c7 100644 --- a/ethcore/res/ethereum/poasokol.json +++ b/ethcore/res/ethereum/poasokol.json @@ -42,7 +42,12 @@ "eip1014Transition": 6464300, "eip1052Transition": 6464300, "eip1283Transition": 6464300, - "eip1283DisableTransition": 7026400 + "eip1283DisableTransition": 7026400, + "eip1283ReenableTransition": 12095200, + "eip1344Transition": 12095200, + "eip1706Transition": 12095200, + "eip1884Transition": 12095200, + "eip2028Transition": 12095200 }, "genesis": { "seal": { @@ -55,6 +60,7 @@ "gasLimit": "0x663BE0" }, "nodes": [ + "enode://bdcd6f875583df2bd8094f08ae58c7c2db6ed67795ca8c0e6415a30721d3657291aec9b933d15e17e0b36ad7a76424a1447ddbfc75809a04f7a0ffef5617dd56@3.91.206.172:30303", "enode://8e0af07c86ec36590bb6368e7ad0c45b6dc658f5fb66ec68889a614affddda5e021bd513bcf4fb2fae4a3bbe08cf0de84f037cd58478a89665dfce1ded2595c7@34.236.37.74:30303", "enode://f1a5100a81cb73163ae450c584d06b1f644aa4fad4486c6aeb4c384b343c54bb66c744aa5f133af66ea1b25f0f4a454f04878f3e96ee4cd2390c047396d6357b@209.97.158.4:30303", "enode://0d1e0372f63a3f0b82d66635ea101ecc0f6797788a078805cc933dd93e6a22f7c9fa51ab4e2d21da02d04480ef19f3bbb9a2b41dd1c262085d295a354bb8b0f9@18.217.47.209:30303", @@ -64,7 +70,20 @@ "enode://b022ff70b5fcaf9596ae5efed99a8198b4ae0578ee9d17b733609d803a75cef95d3a2a18e50dca9a7c3b26139f158c59eaf8b5fb8d1d331c9a46934a78acabe8@206.189.76.128:30303" ], "accounts": { - "0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", "activate_at": "0x0", "pricing": { "modexp": { "divisor": 20 } } } }, + "0000000000000000000000000000000000000005": { + "builtin": { + "name": "modexp", + "pricing": { + "0": { + "price": { + "modexp": { + "divisor": 20 + } + } + } + } + } + }, "0000000000000000000000000000000000000006": { "builtin": { "name": "alt_bn128_add", @@ -72,7 +91,7 @@ "0": { "price": { "alt_bn128_const_operations": { "price": 500 }} }, - "0x7fffffffffffff": { + "12095200": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 150 }} } @@ -86,7 +105,7 @@ "0": { "price": { "alt_bn128_const_operations": { "price": 40000 }} }, - "0x7fffffffffffff": { + "12095200": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 6000 }} } @@ -100,21 +119,40 @@ "0": { "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, - "0x7fffffffffffff": { + "12095200": { "info": "EIP 1108 transition", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } }, + "0x0000000000000000000000000000000000000009": { + "builtin": { + "name": "blake2_f", + "pricing": { + "12095200": { + "info": "EIP 1108 transition", + "price": { + "blake2_f": { + "gas_per_round": 1 + } + } + } + } + } + }, "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { - "linear": { - "base": 3000, - "word": 0 + "0": { + "price": { + "linear": { + "base": 3000, + "word": 0 + } + } } } } @@ -124,9 +162,13 @@ "builtin": { "name": "sha256", "pricing": { - "linear": { - "base": 60, - "word": 12 + "0": { + "price": { + "linear": { + "base": 60, + "word": 12 + } + } } } } @@ -136,9 +178,13 @@ "builtin": { "name": "ripemd160", "pricing": { - "linear": { - "base": 600, - "word": 120 + "0": { + "price": { + "linear": { + "base": 600, + "word": 120 + } + } } } } @@ -148,9 +194,13 @@ "builtin": { "name": "identity", "pricing": { - "linear": { - "base": 15, - "word": 3 + "0": { + "price": { + "linear": { + "base": 15, + "word": 3 + } + } } } } diff --git a/ethcore/res/ethereum/ropsten.json b/ethcore/res/ethereum/ropsten.json index cd535241424..477512ec9a4 100644 --- a/ethcore/res/ethereum/ropsten.json +++ b/ethcore/res/ethereum/ropsten.json @@ -16,7 +16,8 @@ "eip100bTransition": "0x19f0a0", "difficultyBombDelays": { "0x19f0a0": "0x2dc6c0", - "0x408b70": "0x1e8480" + "0x408b70": "0x1e8480", + "0x6c993d": "0x3d0900" } } } diff --git a/ethcore/res/ethereum/xdai.json b/ethcore/res/ethereum/xdai.json index ba224d980ad..2da25ca4e6f 100644 --- a/ethcore/res/ethereum/xdai.json +++ b/ethcore/res/ethereum/xdai.json @@ -37,6 +37,11 @@ "eip1052Transition": 1604400, "eip1283Transition": 1604400, "eip1283DisableTransition": 2508800, + "eip1283ReenableTransition": 7298030, + "eip1344Transition": 7298030, + "eip1706Transition": 7298030, + "eip1884Transition": 7298030, + "eip2028Transition": 7298030, "registrar": "0x1ec97dc137f5168af053c24460a1200502e1a9d2" }, "genesis": { @@ -2865,10 +2870,13 @@ "0x0000000000000000000000000000000000000005": { "builtin": { "name": "modexp", - "activate_at": "0x0", "pricing": { - "modexp": { - "divisor": 20 + "0": { + "price": { + "modexp": { + "divisor": 20 + } + } } } } @@ -2880,7 +2888,7 @@ "0": { "price": { "alt_bn128_const_operations": { "price": 500 }} }, - "0x7fffffffffffff": { + "7298030": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 150 }} } @@ -2894,7 +2902,7 @@ "0": { "price": { "alt_bn128_const_operations": { "price": 40000 }} }, - "0x7fffffffffffff": { + "7298030": { "info": "EIP 1108 transition", "price": { "alt_bn128_const_operations": { "price": 6000 }} } @@ -2908,21 +2916,40 @@ "0": { "price": { "alt_bn128_pairing": { "base": 100000, "pair": 80000 }} }, - "0x7fffffffffffff": { + "7298030": { "info": "EIP 1108 transition", "price": { "alt_bn128_pairing": { "base": 45000, "pair": 34000 }} } } } }, + "0x0000000000000000000000000000000000000009": { + "builtin": { + "name": "blake2_f", + "pricing": { + "7298030": { + "info": "EIP 1108 transition", + "price": { + "blake2_f": { + "gas_per_round": 1 + } + } + } + } + } + }, "0x0000000000000000000000000000000000000001": { "balance": "1", "builtin": { "name": "ecrecover", "pricing": { - "linear": { - "base": 3000, - "word": 0 + "0": { + "price": { + "linear": { + "base": 3000, + "word": 0 + } + } } } } @@ -2932,9 +2959,13 @@ "builtin": { "name": "sha256", "pricing": { - "linear": { - "base": 60, - "word": 12 + "0": { + "price": { + "linear": { + "base": 60, + "word": 12 + } + } } } } @@ -2944,9 +2975,13 @@ "builtin": { "name": "ripemd160", "pricing": { - "linear": { - "base": 600, - "word": 120 + "0": { + "price": { + "linear": { + "base": 600, + "word": 120 + } + } } } } @@ -2956,9 +2991,13 @@ "builtin": { "name": "identity", "pricing": { - "linear": { - "base": 15, - "word": 3 + "0": { + "price": { + "linear": { + "base": 15, + "word": 3 + } + } } } } diff --git a/ethcore/src/client/evm_test_client.rs b/ethcore/src/client/evm_test_client.rs index d65e20691e9..be5857b0e16 100644 --- a/ethcore/src/client/evm_test_client.rs +++ b/ethcore/src/client/evm_test_client.rs @@ -245,7 +245,7 @@ impl<'a> EvmTestClient<'a> { ) -> std::result::Result, TransactErr> { let initial_gas = transaction.gas; // Verify transaction - let is_ok = transaction.verify_basic(true, None, false); + let is_ok = transaction.verify_basic(true, None); if let Err(error) = is_ok { return Err( TransactErr{ diff --git a/ethcore/src/machine/impls.rs b/ethcore/src/machine/impls.rs index fca611d4e88..371d088d5f5 100644 --- a/ethcore/src/machine/impls.rs +++ b/ethcore/src/machine/impls.rs @@ -367,7 +367,7 @@ impl EthereumMachine { } else { None }; - t.verify_basic(check_low_s, chain_id, false)?; + t.verify_basic(check_low_s, chain_id)?; Ok(()) } diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 1da323e30cd..815aba6cf4e 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1600,6 +1600,30 @@ mod tests { assert_eq!(miner.prepare_pending_block(&client), BlockPreparationStatus::NotPrepared); } + #[test] + fn should_reject_local_transaction_with_invalid_chain_id() { + let spec = Spec::new_test(); + let miner = Miner::new_for_tests(&spec, None); + let client = TestBlockChainClient::default(); + let chain_id = spec.chain_id(); + + // chain_id + 100500 is invalid + let import = miner.import_claimed_local_transaction( + &client, + PendingTransaction::new(transaction_with_chain_id(chain_id + 10500), None), + false, + ); + assert_eq!(import, Err(transaction::Error::InvalidChainId)); + + // chain_id is valid + let import = miner.import_claimed_local_transaction( + &client, + PendingTransaction::new(transaction_with_chain_id(chain_id), None), + false, + ); + assert_eq!(import, Ok(())); + } + #[test] fn should_prioritize_locals() { let client = TestBlockChainClient::default(); diff --git a/ethcore/src/miner/pool_client.rs b/ethcore/src/miner/pool_client.rs index 93cc0e8cfb4..e6ff3a329c6 100644 --- a/ethcore/src/miner/pool_client.rs +++ b/ethcore/src/miner/pool_client.rs @@ -136,7 +136,12 @@ impl<'a, C: 'a> pool::client::Client for PoolClient<'a, C> where self.chain.transaction_block(TransactionId::Hash(*hash)).is_some() } - fn verify_transaction(&self, tx: UnverifiedTransaction)-> Result { + fn verify_transaction_basic(&self, tx: &UnverifiedTransaction) -> Result<(), transaction::Error> { + self.engine.verify_transaction_basic(tx, &self.best_block_header)?; + Ok(()) + } + + fn verify_transaction(&self, tx: UnverifiedTransaction) -> Result { self.engine.verify_transaction_basic(&tx, &self.best_block_header)?; let tx = self.engine.verify_transaction_unordered(tx, &self.best_block_header)?; diff --git a/ethcore/types/src/transaction/transaction.rs b/ethcore/types/src/transaction/transaction.rs index 439880089e6..8153142ebaa 100644 --- a/ethcore/types/src/transaction/transaction.rs +++ b/ethcore/types/src/transaction/transaction.rs @@ -143,6 +143,7 @@ impl HeapSizeOf for Transaction { } } +#[cfg(any(test, feature = "test-helpers"))] impl From for SignedTransaction { fn from(t: ethjson::state::Transaction) -> Self { let to: Option = t.to.into(); @@ -242,7 +243,10 @@ impl Transaction { } } - /// Add EIP-86 compatible empty signature. + /// Legacy EIP-86 compatible empty signature. + /// This method is used in json tests as well as + /// signature verification tests. + #[cfg(any(test, feature = "test-helpers"))] pub fn null_sign(self, chain_id: u64) -> SignedTransaction { SignedTransaction { transaction: UnverifiedTransaction { @@ -306,7 +310,7 @@ impl rlp::Decodable for UnverifiedTransaction { v: d.val_at(6)?, r: d.val_at(7)?, s: d.val_at(8)?, - hash: hash, + hash, }) } } @@ -323,7 +327,7 @@ impl UnverifiedTransaction { self } - /// Checks is signature is empty. + /// Checks if the signature is empty. pub fn is_unsigned(&self) -> bool { self.r.is_zero() && self.s.is_zero() } @@ -387,17 +391,12 @@ impl UnverifiedTransaction { } /// Verify basic signature params. Does not attempt sender recovery. - pub fn verify_basic(&self, check_low_s: bool, chain_id: Option, allow_empty_signature: bool) -> Result<(), error::Error> { - if check_low_s && !(allow_empty_signature && self.is_unsigned()) { - self.check_low_s()?; - } - // Disallow unsigned transactions in case EIP-86 is disabled. - if !allow_empty_signature && self.is_unsigned() { + pub fn verify_basic(&self, check_low_s: bool, chain_id: Option) -> Result<(), error::Error> { + if self.is_unsigned() { return Err(ethkey::Error::InvalidSignature.into()); } - // EIP-86: Transactions of this form MUST have gasprice = 0, nonce = 0, value = 0, and do NOT increment the nonce of account 0. - if allow_empty_signature && self.is_unsigned() && !(self.gas_price.is_zero() && self.value.is_zero() && self.nonce.is_zero()) { - return Err(ethkey::Error::InvalidSignature.into()) + if check_low_s { + self.check_low_s()?; } match (self.chain_id(), chain_id) { (None, _) => {}, @@ -443,20 +442,15 @@ impl SignedTransaction { /// Try to verify transaction and recover sender. pub fn new(transaction: UnverifiedTransaction) -> Result { if transaction.is_unsigned() { - Ok(SignedTransaction { - transaction: transaction, - sender: UNSIGNED_SENDER, - public: None, - }) - } else { - let public = transaction.recover_public()?; - let sender = public_to_address(&public); - Ok(SignedTransaction { - transaction: transaction, - sender: sender, - public: Some(public), - }) + return Err(ethkey::Error::InvalidSignature); } + let public = transaction.recover_public()?; + let sender = public_to_address(&public); + Ok(SignedTransaction { + transaction, + sender, + public: Some(public), + }) } /// Returns transaction sender. @@ -646,6 +640,25 @@ mod tests { assert_eq!(t.chain_id(), None); } + #[test] + fn should_reject_null_signature() { + use std::str::FromStr; + let t = Transaction { + nonce: U256::zero(), + gas_price: U256::from(10000000000u64), + gas: U256::from(21000), + action: Action::Call(Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap()), + value: U256::from(1), + data: vec![] + }.null_sign(1); + + let res = SignedTransaction::new(t.transaction); + match res { + Err(ethkey::Error::InvalidSignature) => {} + _ => panic!("null signature should be rejected"), + } + } + #[test] fn should_recover_from_chain_specific_signing() { use ethkey::{Random, Generator}; diff --git a/evmbin/Cargo.toml b/evmbin/Cargo.toml index 7605132ef53..626b1315042 100644 --- a/evmbin/Cargo.toml +++ b/evmbin/Cargo.toml @@ -9,7 +9,7 @@ name = "parity-evm" path = "./src/main.rs" [dependencies] -common-types = { path = "../ethcore/types" } +common-types = { path = "../ethcore/types", features = ["test-helpers"] } docopt = "1.0" env_logger = "0.5" ethcore = { path = "../ethcore", features = ["test-helpers", "json-tests", "to-pod-full"] } diff --git a/json/src/spec/builtin.rs b/json/src/spec/builtin.rs index 19ddfc2c635..77b5bcce6fa 100644 --- a/json/src/spec/builtin.rs +++ b/json/src/spec/builtin.rs @@ -203,6 +203,28 @@ mod tests { ]); } + #[test] + fn deserialization_alt_bn128_const_operations() { + let s = r#"{ + "name": "alt_bn128_mul", + "pricing": { + "100500": { + "price": { "alt_bn128_const_operations": { "price": 123 }} + } + } + }"#; + let builtin: Builtin = serde_json::from_str::(s).unwrap().into(); + assert_eq!(builtin.name, "alt_bn128_mul"); + assert_eq!(builtin.pricing, map![ + 100500 => PricingAt { + info: None, + price: Pricing::AltBn128ConstOperations(AltBn128ConstOperations { + price: 123, + }), + } + ]); + } + #[test] fn activate_at() { let s = r#"{ diff --git a/json/src/uint.rs b/json/src/uint.rs index 3f1d02f03e7..4b9ccec6f49 100644 --- a/json/src/uint.rs +++ b/json/src/uint.rs @@ -97,6 +97,7 @@ impl<'a> Visitor<'a> for UintVisitor { } } +/// Deserialize and validate that the value is non-zero pub fn validate_non_zero<'de, D>(d: D) -> Result where D: Deserializer<'de> { let value = Uint::deserialize(d)?; @@ -107,6 +108,7 @@ pub fn validate_non_zero<'de, D>(d: D) -> Result where D: Deseri Ok(value) } +/// Deserialize and validate that the value is non-zero pub fn validate_optional_non_zero<'de, D>(d: D) -> Result, D::Error> where D: Deserializer<'de> { let value: Option = Option::deserialize(d)?; diff --git a/miner/src/pool/client.rs b/miner/src/pool/client.rs index bcd2b968954..1579ba40daa 100644 --- a/miner/src/pool/client.rs +++ b/miner/src/pool/client.rs @@ -50,6 +50,15 @@ pub trait Client: fmt::Debug + Sync { /// Is transaction with given hash already in the blockchain? fn transaction_already_included(&self, hash: &H256) -> bool; + /// Perform basic/cheap transaction verification. + /// + /// This should include all cheap checks that can be done before + /// actually checking the signature, like chain-replay protection. + /// + /// This method is currently used only for verifying local transactions. + fn verify_transaction_basic(&self, t: &transaction::UnverifiedTransaction) + -> Result<(), transaction::Error>; + /// Structurarily verify given transaction. fn verify_transaction(&self, tx: transaction::UnverifiedTransaction) -> Result; diff --git a/miner/src/pool/tests/client.rs b/miner/src/pool/tests/client.rs index 4735fbd64d4..ce927c8e983 100644 --- a/miner/src/pool/tests/client.rs +++ b/miner/src/pool/tests/client.rs @@ -103,6 +103,12 @@ impl pool::client::Client for TestClient { false } + fn verify_transaction_basic(&self, _tx: &UnverifiedTransaction) + -> Result<(), transaction::Error> + { + Ok(()) + } + fn verify_transaction(&self, tx: UnverifiedTransaction) -> Result { diff --git a/miner/src/pool/verifier.rs b/miner/src/pool/verifier.rs index 51232e967af..bd4b50e7363 100644 --- a/miner/src/pool/verifier.rs +++ b/miner/src/pool/verifier.rs @@ -250,7 +250,13 @@ impl txpool::Verifier for Verifier tx, + Transaction::Local(tx) => match self.client.verify_transaction_basic(&**tx) { + Ok(()) => tx, + Err(err) => { + warn!(target: "txqueue", "[{:?}] Rejected local tx {:?}", hash, err); + return Err(err) + } + }, }; // Verify RLP payload diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml index fb8449d5bc8..7a8e32cc8ac 100644 --- a/util/version/Cargo.toml +++ b/util/version/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "parity-version" # NOTE: this value is used for Parity Ethereum version string (via env CARGO_PKG_VERSION) -version = "2.5.11" +version = "2.5.12" authors = ["Parity Technologies "] build = "build.rs"