Move more params to the common section. (#6134)

* move common forks and parameters to common params

* port specs over to new format

* fix RPC tests
This commit is contained in:
Robert Habermeier 2017-07-31 12:34:29 +02:00 committed by Gav Wood
parent 9c5ef1f776
commit 003eef982b
55 changed files with 224 additions and 358 deletions

2
Cargo.lock generated
View File

@ -777,7 +777,7 @@ name = "ethjson"
version = "0.1.0"
dependencies = [
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-util 1.8.0",
"ethcore-bigint 0.1.3",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -3,7 +3,6 @@
"engine": {
"authorityRound": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": 1,
"startStep": 2,
"validators": {
@ -17,6 +16,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -3,7 +3,6 @@
"engine": {
"basicAuthority": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"durationLimit": "0x0d",
"validators": {
"list": ["0x9cce34f7ab185c7aba1b7c8140d620b4bda941d6"]
@ -12,6 +11,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0100000",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -4,12 +4,14 @@
"null": null
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x2"
},
"genesis": {
"gasLimitBoundDivisor": "0x0400",
"seal": {
"generic": "0x"
},

View File

@ -4,15 +4,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": 1150000,
"eip150Transition": 2500000,
"eip155Transition": 3000000,
"eip160Transition": 3000000,
"ecip1010PauseTransition": 3000000,
"ecip1010ContinueTransition": 5000000,
@ -24,6 +20,9 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
@ -31,6 +30,8 @@
"chainID": "0x3d",
"forkBlock": "0x1d4c00",
"forkCanonHash": "0x94365e3a8c0b35089c1d1195081fe7489b528a84b22199c916180db8b28ade7f",
"eip155Transition": 3000000,
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},

View File

@ -3,15 +3,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff",
@ -20,12 +16,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff"
"eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -3,15 +3,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
@ -20,12 +16,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffffff",
"eip86Transition": "0x7fffffffffffffff"
"eip86Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -4,19 +4,15 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"difficultyIncrementDivisor": "60",
"durationLimit": "0x3C",
"blockReward": "0x6f05b59d3b200000",
"registrar" : "0x6c221ca53705f3497ec90ca7b84c59ae7382fc21",
"homesteadTransition": "0x30d40",
"difficultyHardforkTransition": "0x59d9",
"difficultyHardforkBoundDivisor": "0x0200",
"bombDefuseTransition": "0x30d40",
"eip150Transition": "0x927C0",
"eip155Transition": "0x927C0",
"eip160Transition": "0x927C0",
"eip161abcTransition": "0x927C0",
"eip161dTransition": "0x927C0"
@ -24,6 +20,9 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x6f05b59d3b200000",
"registrar" : "0x6c221ca53705f3497ec90ca7b84c59ae7382fc21",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
@ -31,7 +30,8 @@
"chainID": "0x2",
"subprotocolName": "exp",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
"eip86Transition": "0x7fffffffffffff",
"eip155Transition": "0x927C0"
},
"genesis": {
"seal": {

View File

@ -4,12 +4,9 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xe3389675d0338462dC76C6f9A3e432550c36A142",
"homesteadTransition": "0x118c30",
"daoHardforkTransition": "0x1d4c00",
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
@ -132,7 +129,6 @@
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
],
"eip150Transition": "0x259518",
"eip155Transition": 2675000,
"eip160Transition": 2675000,
"eip161abcTransition": 2675000,
"eip161dTransition": 2675000,
@ -141,12 +137,17 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xe3389675d0338462dC76C6f9A3e432550c36A142",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"forkBlock": "0x1d4c00",
"forkCanonHash": "0x4985f5ca3d2afbec36529aa96f74de3cc10a2a4a6c44f2157a57d2c6059a11bb",
"eip155Transition": 2675000,
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},

View File

@ -3,12 +3,9 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x118c30",
"daoHardforkTransition": "0x1d4c00",
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
@ -131,7 +128,6 @@
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
],
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
@ -139,12 +135,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
"eip86Transition": "0x7fffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -3,15 +3,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x7fffffffffffffff",
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
@ -19,12 +15,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
"eip86Transition": "0x7fffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -3,15 +3,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
@ -19,12 +15,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
"eip86Transition": "0x7fffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -4,10 +4,7 @@
"engine": {
"authorityRound": {
"params": {
"gasLimitBoundDivisor": "0x400",
"registrar" : "0xfAb104398BBefbd47752E7702D9fE23047E1Bca3",
"stepDuration": "4",
"blockReward": "0x4563918244F40000",
"validators" : {
"list": [
"0x00D6Cc1BA9cf89BD2e58009741f4F7325BAdc0ED",
@ -25,16 +22,19 @@
]
},
"validateScoreTransition": 1000000,
"eip155Transition": 1000000,
"validateStepTransition": 1500000
}
}
},
"params": {
"gasLimitBoundDivisor": "0x400",
"registrar" : "0xfAb104398BBefbd47752E7702D9fE23047E1Bca3",
"blockReward": "0x4563918244F40000",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x2A",
"validateReceiptsTransition" : 1000000
"validateReceiptsTransition" : 1000000,
"eip155Transition": 1000000
},
"genesis": {
"seal": {

View File

@ -3,15 +3,12 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x0",
"eip150Transition": "0x0",
"eip155Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
@ -20,6 +17,9 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
@ -27,7 +27,8 @@
"eip98Transition": "0x0",
"eip86Transition": "0x0",
"eip140Transition": "0x0",
"eip210Transition": "0x0"
"eip210Transition": "0x0",
"eip155Transition": "0x0"
},
"genesis": {
"seal": {

View File

@ -4,15 +4,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar": "0x52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d",
"homesteadTransition": 494000,
"eip150Transition": 1783000,
"eip155Transition": 1915000,
"eip160Transition": 1915000,
"ecip1010PauseTransition": 1915000,
"ecip1010ContinueTransition": 3415000,
@ -23,6 +19,9 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar": "0x52dff57a8a1532e6afb3dc07e2af58bb9eb05b3d",
"accountStartNonce": "0x0100000",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
@ -30,6 +29,8 @@
"chainID": "0x3e",
"forkBlock": "0x1b34d8",
"forkCanonHash": "0xf376243aeff1f256d970714c3de9fd78fa4e63cf63e32a51fe1169e375d98145",
"eip155Transition": 1915000,
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},

View File

@ -3,15 +3,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x08",
"blockReward": "0x14D1120D7B160000",
"registrar": "5e70c0bbcd5636e0f9f9316e9f8633feb64d4050",
"homesteadTransition": "0x7fffffffffffffff",
"eip150Transition": "0x7fffffffffffffff",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
@ -19,12 +15,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x14D1120D7B160000",
"registrar": "5e70c0bbcd5636e0f9f9316e9f8633feb64d4050",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x0400",
"minGasLimit": "125000",
"networkID" : "0x0",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
"eip86Transition": "0x7fffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -4,15 +4,11 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2",
"homesteadTransition": 0,
"eip150Transition": 0,
"eip155Transition": 10,
"eip160Transition": 10,
"eip161abcTransition": 10,
"eip161dTransition": 10,
@ -21,12 +17,17 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar": "0x81a4b044831c4f12ba601adb9274516939e9b8a2",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x3",
"forkBlock": 641350,
"forkCanonHash": "0x8033403e9fe5811a7b6d6b469905915de1c59207ce2172cbcf5d6ff14fa6a2eb",
"eip155Transition": 10,
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
},

View File

@ -3,12 +3,9 @@
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x5",
"daoHardforkTransition": "0x8",
"daoHardforkBeneficiary": "0xbf4ed7b27f1d666546e30d74d50d173d20bca754",
@ -131,7 +128,6 @@
"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
],
"eip150Transition": "0xa",
"eip155Transition": "0x7fffffffffffffff",
"eip160Transition": "0x7fffffffffffffff",
"eip161abcTransition": "0x7fffffffffffffff",
"eip161dTransition": "0x7fffffffffffffff"
@ -139,12 +135,16 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x1",
"eip98Transition": "0x7fffffffffffff",
"eip86Transition": "0x7fffffffffffff"
"eip86Transition": "0x7fffffffffffff",
"eip155Transition": "0x7fffffffffffffff"
},
"genesis": {
"seal": {

View File

@ -1,13 +1,10 @@
{
"name": "DevelopmentChain",
"engine": {
"instantSeal": {
"params": {
"registrar": "0x0000000000000000000000000000000000000005"
}
}
"instantSeal": null
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -4,6 +4,7 @@
"null": null
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -4,6 +4,7 @@
"null": null
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -3,7 +3,6 @@
"engine": {
"tendermint": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"validators" : {
"list": [
"0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1",
@ -18,6 +17,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -3,7 +3,6 @@
"engine": {
"authorityRound": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": 1,
"startStep": 2,
"validators": {
@ -14,6 +13,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -3,7 +3,6 @@
"engine": {
"basicAuthority": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"durationLimit": "0x0d",
"validators": {
"multi": {
@ -15,6 +14,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -12,6 +12,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -47,22 +47,14 @@ mod finality;
/// `AuthorityRound` params.
pub struct AuthorityRoundParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// Time to wait before next block or authority switching.
pub step_duration: Duration,
/// Block reward.
pub block_reward: U256,
/// Namereg contract address.
pub registrar: Address,
/// Starting step,
pub start_step: Option<u64>,
/// Valid validators.
pub validators: Box<ValidatorSet>,
/// Chain score validation transition block.
pub validate_score_transition: u64,
/// Number of first block where EIP-155 rules are validated.
pub eip155_transition: u64,
/// Monotonic step validation transition block.
pub validate_step_transition: u64,
/// Immediate transitions.
@ -72,14 +64,10 @@ pub struct AuthorityRoundParams {
impl From<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams {
fn from(p: ethjson::spec::AuthorityRoundParams) -> Self {
AuthorityRoundParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
step_duration: Duration::from_secs(p.step_duration.into()),
validators: new_validator_set(p.validators),
block_reward: p.block_reward.map_or_else(U256::zero, Into::into),
registrar: p.registrar.map_or_else(Address::new, Into::into),
start_step: p.start_step.map(Into::into),
validate_score_transition: p.validate_score_transition.map_or(0, Into::into),
eip155_transition: p.eip155_transition.map_or(0, Into::into),
validate_step_transition: p.validate_step_transition.map_or(0, Into::into),
immediate_transitions: p.immediate_transitions.unwrap_or(false),
}
@ -214,9 +202,6 @@ impl EpochManager {
/// Engine using `AuthorityRound` proof-of-authority BFT consensus.
pub struct AuthorityRound {
params: CommonParams,
gas_limit_bound_divisor: U256,
block_reward: U256,
registrar: Address,
builtins: BTreeMap<Address, Builtin>,
transition_service: IoService<()>,
step: Arc<Step>,
@ -225,7 +210,6 @@ pub struct AuthorityRound {
signer: RwLock<EngineSigner>,
validators: Box<ValidatorSet>,
validate_score_transition: u64,
eip155_transition: u64,
validate_step_transition: u64,
epoch_manager: Mutex<EpochManager>,
immediate_transitions: bool,
@ -362,9 +346,6 @@ impl AuthorityRound {
let engine = Arc::new(
AuthorityRound {
params: params,
gas_limit_bound_divisor: our_params.gas_limit_bound_divisor,
block_reward: our_params.block_reward,
registrar: our_params.registrar,
builtins: builtins,
transition_service: IoService::<()>::start()?,
step: Arc::new(Step {
@ -377,7 +358,6 @@ impl AuthorityRound {
signer: Default::default(),
validators: our_params.validators,
validate_score_transition: our_params.validate_score_transition,
eip155_transition: our_params.eip155_transition,
validate_step_transition: our_params.validate_step_transition,
epoch_manager: Mutex::new(EpochManager::blank()),
immediate_transitions: our_params.immediate_transitions,
@ -433,7 +413,9 @@ impl Engine for AuthorityRound {
fn params(&self) -> &CommonParams { &self.params }
fn additional_params(&self) -> HashMap<String, String> { hash_map!["registrar".to_owned() => self.registrar.hex()] }
fn additional_params(&self) -> HashMap<String, String> {
hash_map!["registrar".to_owned() => self.params().registrar.hex()]
}
fn builtins(&self) -> &BTreeMap<Address, Builtin> { &self.builtins }
@ -461,7 +443,7 @@ impl Engine for AuthorityRound {
header.set_difficulty(new_difficulty);
header.set_gas_limit({
let gas_limit = parent.gas_limit().clone();
let bound_divisor = self.gas_limit_bound_divisor;
let bound_divisor = self.params().gas_limit_bound_divisor;
if gas_limit < gas_floor_target {
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
} else {
@ -564,7 +546,8 @@ impl Engine for AuthorityRound {
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> {
let fields = block.fields_mut();
// Bestow block reward
let res = fields.state.add_balance(fields.header.author(), &self.block_reward, CleanupMode::NoEmpty)
let reward = self.params().block_reward;
let res = fields.state.add_balance(fields.header.author(), &reward, CleanupMode::NoEmpty)
.map_err(::error::Error::from)
.and_then(|_| fields.state.commit());
// Commit state so that we can actually figure out the state root.
@ -629,7 +612,7 @@ impl Engine for AuthorityRound {
}
}
let gas_limit_divisor = self.gas_limit_bound_divisor;
let gas_limit_divisor = self.params().gas_limit_bound_divisor;
let min_gas = parent.gas_limit().clone() - parent.gas_limit().clone() / gas_limit_divisor;
let max_gas = parent.gas_limit().clone() + parent.gas_limit().clone() / gas_limit_divisor;
if header.gas_limit() <= &min_gas || header.gas_limit() >= &max_gas {
@ -819,7 +802,7 @@ impl Engine for AuthorityRound {
t.check_low_s()?;
if let Some(n) = t.network_id() {
if header.number() >= self.eip155_transition && n != self.params().chain_id {
if header.number() >= self.params().eip155_transition && n != self.params().chain_id {
return Err(TransactionError::InvalidNetworkId.into());
}
}
@ -1014,18 +997,19 @@ mod tests {
fn reports_skipped() {
let last_benign = Arc::new(AtomicUsize::new(0));
let params = AuthorityRoundParams {
gas_limit_bound_divisor: U256::from_str("400").unwrap(),
step_duration: Default::default(),
block_reward: Default::default(),
registrar: Default::default(),
start_step: Some(1),
validators: Box::new(TestSet::new(Default::default(), last_benign.clone())),
validate_score_transition: 0,
validate_step_transition: 0,
eip155_transition: 0,
immediate_transitions: true,
};
let aura = AuthorityRound::new(Default::default(), params, Default::default()).unwrap();
let aura = {
let mut c_params = ::spec::CommonParams::default();
c_params.gas_limit_bound_divisor = 5.into();
AuthorityRound::new(c_params, params, Default::default()).unwrap()
};
let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&1usize).into_vec()]);

View File

@ -35,8 +35,6 @@ use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
/// `BasicAuthority` params.
#[derive(Debug, PartialEq)]
pub struct BasicAuthorityParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// Valid signatories.
pub validators: ethjson::spec::ValidatorSet,
}
@ -44,7 +42,6 @@ pub struct BasicAuthorityParams {
impl From<ethjson::spec::BasicAuthorityParams> for BasicAuthorityParams {
fn from(p: ethjson::spec::BasicAuthorityParams) -> Self {
BasicAuthorityParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
validators: p.validators,
}
}
@ -80,7 +77,6 @@ fn verify_external(header: &Header, validators: &ValidatorSet) -> Result<(), Err
/// Engine using `BasicAuthority`, trivial proof-of-authority consensus.
pub struct BasicAuthority {
params: CommonParams,
gas_limit_bound_divisor: U256,
builtins: BTreeMap<Address, Builtin>,
signer: RwLock<EngineSigner>,
validators: Box<ValidatorSet>,
@ -91,7 +87,6 @@ impl BasicAuthority {
pub fn new(params: CommonParams, our_params: BasicAuthorityParams, builtins: BTreeMap<Address, Builtin>) -> Self {
BasicAuthority {
params: params,
gas_limit_bound_divisor: our_params.gas_limit_bound_divisor,
builtins: builtins,
validators: new_validator_set(our_params.validators),
signer: Default::default(),
@ -119,7 +114,7 @@ impl Engine for BasicAuthority {
header.set_difficulty(parent.difficulty().clone());
header.set_gas_limit({
let gas_limit = parent.gas_limit().clone();
let bound_divisor = self.gas_limit_bound_divisor;
let bound_divisor = self.params().gas_limit_bound_divisor;
if gas_limit < gas_floor_target {
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
} else {
@ -172,7 +167,7 @@ impl Engine for BasicAuthority {
if header.difficulty() != parent.difficulty() {
return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: *parent.difficulty(), found: *header.difficulty() })))
}
let gas_limit_divisor = self.gas_limit_bound_divisor;
let gas_limit_divisor = self.params().gas_limit_bound_divisor;
let min_gas = parent.gas_limit().clone() - parent.gas_limit().clone() / gas_limit_divisor;
let max_gas = parent.gas_limit().clone() + parent.gas_limit().clone() / gas_limit_divisor;
if header.gas_limit() <= &min_gas || header.gas_limit() >= &max_gas {

View File

@ -24,16 +24,14 @@ use block::ExecutedBlock;
/// An engine which does not provide any consensus mechanism, just seals blocks internally.
pub struct InstantSeal {
params: CommonParams,
registrar: Address,
builtins: BTreeMap<Address, Builtin>,
}
impl InstantSeal {
/// Returns new instance of InstantSeal with default VM Factory
pub fn new(params: CommonParams, registrar: Address, builtins: BTreeMap<Address, Builtin>) -> Self {
pub fn new(params: CommonParams, builtins: BTreeMap<Address, Builtin>) -> Self {
InstantSeal {
params: params,
registrar: registrar,
builtins: builtins,
}
}
@ -49,7 +47,7 @@ impl Engine for InstantSeal {
}
fn additional_params(&self) -> HashMap<String, String> {
hash_map!["registrar".to_owned() => self.registrar.hex()]
hash_map!["registrar".to_owned() => self.params().registrar.hex()]
}
fn builtins(&self) -> &BTreeMap<Address, Builtin> {

View File

@ -71,12 +71,9 @@ pub type BlockHash = H256;
/// Engine using `Tendermint` consensus algorithm, suitable for EVM chain.
pub struct Tendermint {
params: CommonParams,
gas_limit_bound_divisor: U256,
builtins: BTreeMap<Address, Builtin>,
step_service: IoService<Step>,
client: RwLock<Option<Weak<EngineClient>>>,
block_reward: U256,
registrar: Address,
/// Blockchain height.
height: AtomicUsize,
/// Consensus view.
@ -166,12 +163,9 @@ impl Tendermint {
let engine = Arc::new(
Tendermint {
params: params,
gas_limit_bound_divisor: our_params.gas_limit_bound_divisor,
builtins: builtins,
client: RwLock::new(None),
step_service: IoService::<Step>::start()?,
block_reward: our_params.block_reward,
registrar: our_params.registrar,
height: AtomicUsize::new(1),
view: AtomicUsize::new(0),
step: RwLock::new(Step::Propose),
@ -446,7 +440,9 @@ impl Engine for Tendermint {
fn params(&self) -> &CommonParams { &self.params }
fn additional_params(&self) -> HashMap<String, String> { hash_map!["registrar".to_owned() => self.registrar.hex()] }
fn additional_params(&self) -> HashMap<String, String> {
hash_map!["registrar".to_owned() => self.params().registrar.hex()]
}
fn builtins(&self) -> &BTreeMap<Address, Builtin> { &self.builtins }
@ -471,7 +467,7 @@ impl Engine for Tendermint {
header.set_difficulty(new_difficulty);
header.set_gas_limit({
let gas_limit = parent.gas_limit().clone();
let bound_divisor = self.gas_limit_bound_divisor;
let bound_divisor = self.params().gas_limit_bound_divisor;
if gas_limit < gas_floor_target {
min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
} else {
@ -545,7 +541,8 @@ impl Engine for Tendermint {
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>{
let fields = block.fields_mut();
// Bestow block reward
let res = fields.state.add_balance(fields.header.author(), &self.block_reward, CleanupMode::NoEmpty)
let reward = self.params().block_reward;
let res = fields.state.add_balance(fields.header.author(), &reward, CleanupMode::NoEmpty)
.map_err(::error::Error::from)
.and_then(|_| fields.state.commit());
// Commit state so that we can actually figure out the state root.
@ -617,7 +614,7 @@ impl Engine for Tendermint {
self.check_above_threshold(origins.len())?
}
let gas_limit_divisor = self.gas_limit_bound_divisor;
let gas_limit_divisor = self.params().gas_limit_bound_divisor;
let min_gas = parent.gas_limit().clone() - parent.gas_limit().clone() / gas_limit_divisor;
let max_gas = parent.gas_limit().clone() + parent.gas_limit().clone() / gas_limit_divisor;
if header.gas_limit() <= &min_gas || header.gas_limit() >= &max_gas {

View File

@ -17,7 +17,6 @@
//! Tendermint specific parameters.
use ethjson;
use util::{U256, Address};
use time::Duration;
use super::super::validator_set::{ValidatorSet, new_validator_set};
use super::super::transition::Timeouts;
@ -25,16 +24,10 @@ use super::Step;
/// `Tendermint` params.
pub struct TendermintParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// List of validators.
pub validators: Box<ValidatorSet>,
/// Timeout durations for different steps.
pub timeouts: TendermintTimeouts,
/// Block reward.
pub block_reward: U256,
/// Namereg contract address.
pub registrar: Address,
}
/// Base timeout of each step in ms.
@ -81,7 +74,6 @@ impl From<ethjson::spec::TendermintParams> for TendermintParams {
fn from(p: ethjson::spec::TendermintParams) -> Self {
let dt = TendermintTimeouts::default();
TendermintParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
validators: new_validator_set(p.validators),
timeouts: TendermintTimeouts {
propose: p.timeout_propose.map_or(dt.propose, to_duration),
@ -89,8 +81,6 @@ impl From<ethjson::spec::TendermintParams> for TendermintParams {
precommit: p.timeout_precommit.map_or(dt.precommit, to_duration),
commit: p.timeout_commit.map_or(dt.commit, to_duration),
},
block_reward: p.block_reward.map_or_else(U256::zero, Into::into),
registrar: p.registrar.map_or_else(Address::new, Into::into),
}
}
}

View File

@ -41,8 +41,6 @@ const SNAPSHOT_BLOCKS: u64 = 30000;
/// Ethash params.
#[derive(Debug, PartialEq)]
pub struct EthashParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// Minimum difficulty.
pub minimum_difficulty: U256,
/// Difficulty bound divisor.
@ -53,10 +51,6 @@ pub struct EthashParams {
pub metropolis_difficulty_increment_divisor: u64,
/// Block duration.
pub duration_limit: u64,
/// Block reward.
pub block_reward: U256,
/// Namereg contract address.
pub registrar: Address,
/// Homestead transition block number.
pub homestead_transition: u64,
/// DAO hard-fork transition block (X).
@ -75,8 +69,6 @@ pub struct EthashParams {
pub eip100b_transition: u64,
/// Number of first block where EIP-150 rules begin.
pub eip150_transition: u64,
/// Number of first block where EIP-155 rules begin.
pub eip155_transition: u64,
/// Number of first block where EIP-160 rules begin.
pub eip160_transition: u64,
/// Number of first block where EIP-161.abc begin.
@ -104,14 +96,11 @@ pub struct EthashParams {
impl From<ethjson::spec::EthashParams> for EthashParams {
fn from(p: ethjson::spec::EthashParams) -> Self {
EthashParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
minimum_difficulty: p.minimum_difficulty.into(),
difficulty_bound_divisor: p.difficulty_bound_divisor.into(),
difficulty_increment_divisor: p.difficulty_increment_divisor.map_or(10, Into::into),
metropolis_difficulty_increment_divisor: p.metropolis_difficulty_increment_divisor.map_or(9, Into::into),
duration_limit: p.duration_limit.map_or(0, Into::into),
block_reward: p.block_reward.into(),
registrar: p.registrar.map_or_else(Address::new, Into::into),
homestead_transition: p.homestead_transition.map_or(0, Into::into),
dao_hardfork_transition: p.dao_hardfork_transition.map_or(u64::max_value(), Into::into),
dao_hardfork_beneficiary: p.dao_hardfork_beneficiary.map_or_else(Address::new, Into::into),
@ -121,7 +110,6 @@ impl From<ethjson::spec::EthashParams> for EthashParams {
bomb_defuse_transition: p.bomb_defuse_transition.map_or(u64::max_value(), Into::into),
eip100b_transition: p.eip100b_transition.map_or(u64::max_value(), Into::into),
eip150_transition: p.eip150_transition.map_or(0, Into::into),
eip155_transition: p.eip155_transition.map_or(0, Into::into),
eip160_transition: p.eip160_transition.map_or(0, Into::into),
eip161abc_transition: p.eip161abc_transition.map_or(0, Into::into),
eip161d_transition: p.eip161d_transition.map_or(u64::max_value(), Into::into),
@ -185,7 +173,7 @@ impl Engine for Arc<Ethash> {
fn seal_fields(&self) -> usize { 2 }
fn params(&self) -> &CommonParams { &self.params }
fn additional_params(&self) -> HashMap<String, String> { hash_map!["registrar".to_owned() => self.ethash_params.registrar.hex()] }
fn additional_params(&self) -> HashMap<String, String> { hash_map!["registrar".to_owned() => self.params().registrar.hex()] }
fn builtins(&self) -> &BTreeMap<Address, Builtin> {
&self.builtins
@ -216,7 +204,7 @@ impl Engine for Arc<Ethash> {
}
fn signing_network_id(&self, env_info: &EnvInfo) -> Option<u64> {
if env_info.number >= self.ethash_params.eip155_transition {
if env_info.number >= self.params().eip155_transition {
Some(self.params().chain_id)
} else {
None
@ -231,7 +219,7 @@ impl Engine for Arc<Ethash> {
}
let gas_limit = {
let gas_limit = parent.gas_limit().clone();
let bound_divisor = self.ethash_params.gas_limit_bound_divisor;
let bound_divisor = self.params().gas_limit_bound_divisor;
let lower_limit = gas_limit - gas_limit / bound_divisor + 1.into();
let upper_limit = gas_limit + gas_limit / bound_divisor - 1.into();
let gas_limit = if gas_limit < gas_floor_target {
@ -284,7 +272,7 @@ impl Engine for Arc<Ethash> {
/// Apply the block reward on finalisation of the block.
/// This assumes that all uncles are valid uncles (i.e. of at least one generation before the current).
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> {
let reward = self.ethash_params.block_reward;
let reward = self.params().block_reward;
let fields = block.fields_mut();
let eras_rounds = self.ethash_params.ecip1017_era_rounds;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, fields.header.number());
@ -387,7 +375,7 @@ impl Engine for Arc<Ethash> {
if header.difficulty() != &expected_difficulty {
return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: expected_difficulty, found: header.difficulty().clone() })))
}
let gas_limit_divisor = self.ethash_params.gas_limit_bound_divisor;
let gas_limit_divisor = self.params().gas_limit_bound_divisor;
let parent_gas_limit = *parent.gas_limit();
let min_gas = parent_gas_limit - parent_gas_limit / gas_limit_divisor;
let max_gas = parent_gas_limit + parent_gas_limit / gas_limit_divisor;
@ -406,7 +394,7 @@ impl Engine for Arc<Ethash> {
}
let check_low_s = header.number() >= self.ethash_params.homestead_transition;
let network_id = if header.number() >= self.ethash_params.eip155_transition { Some(self.params().chain_id) } else { None };
let network_id = if header.number() >= self.params().eip155_transition { Some(self.params().chain_id) } else { None };
t.verify_basic(check_low_s, network_id, false)?;
Ok(())
}
@ -809,36 +797,32 @@ mod tests {
#[test]
fn has_valid_ecip1017_eras_block_reward() {
let ethparams = EthashParams {
// see ethcore/res/ethereum/classic.json
ecip1017_era_rounds: 5000000,
block_reward: U256::from_str("4563918244F40000").unwrap(),
..get_default_ethash_params()
};
let eras_rounds = ethparams.ecip1017_era_rounds;
let reward = ethparams.block_reward;
let eras_rounds = 5000000;
let start_reward: U256 = "4563918244F40000".parse().unwrap();
let block_number = 0;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, block_number);
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, start_reward, block_number);
assert_eq!(0, eras);
assert_eq!(U256::from_str("4563918244F40000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 5000000;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, block_number);
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, start_reward, block_number);
assert_eq!(0, eras);
assert_eq!(U256::from_str("4563918244F40000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 10000000;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, block_number);
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, start_reward, block_number);
assert_eq!(1, eras);
assert_eq!(U256::from_str("3782DACE9D900000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 20000000;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, block_number);
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, start_reward, block_number);
assert_eq!(3, eras);
assert_eq!(U256::from_str("2386F26FC1000000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 80000000;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, block_number);
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, start_reward, block_number);
assert_eq!(15, eras);
assert_eq!(U256::from_str("271000000000000").unwrap(), reward);
}

View File

@ -1112,6 +1112,8 @@ impl MinerService for Miner {
/// Prepare the block and work if the Engine does not seal internally.
fn update_sealing(&self, chain: &MiningBlockChainClient) {
trace!(target: "miner", "update_sealing");
const NO_NEW_CHAIN_WITH_FORKS: &str = "Your chain specification contains one or more hard forks which are required to be \
on by default. Please remove these forks and start your chain again.";
if self.requires_reseal(chain.chain_info().best_block_number) {
// --------------------------------------------------------------------------
@ -1120,6 +1122,14 @@ impl MinerService for Miner {
// --------------------------------------------------------------------------
trace!(target: "miner", "update_sealing: preparing a block");
let (block, original_work_hash) = self.prepare_block(chain);
// refuse to seal the first block of the chain if it contains hard forks
// which should be on by default.
if block.block().fields().header.number() == 1 && self.engine.params().contains_bugfix_hard_fork() {
warn!("{}", NO_NEW_CHAIN_WITH_FORKS);
return;
}
match self.engine.seals_internally() {
Some(true) => {
trace!(target: "miner", "update_sealing: engine indicates internal sealing");
@ -1127,11 +1137,11 @@ impl MinerService for Miner {
trace!(target: "miner", "update_sealing: imported internally sealed block");
}
},
Some(false) => trace!(target: "miner", "update_sealing: engine is not keen to seal internally right now"),
None => {
trace!(target: "miner", "update_sealing: engine does not seal internally, preparing work");
self.prepare_work(block, original_work_hash)
},
_ => trace!(target: "miner", "update_sealing: engine is not keen to seal internally right now")
}
}
}

View File

@ -3,7 +3,6 @@
"engine": {
"authorityRound": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": 1,
"startStep": 0,
"validators": {
@ -17,6 +16,7 @@
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",

View File

@ -39,7 +39,12 @@ use trace::{NoopTracer, NoopVMTracer};
use evm::CallType;
use util::*;
/// Parameters common to all engines.
/// Parameters common to ethereum-like blockchains.
/// NOTE: when adding bugfix hard-fork parameters,
/// add to `contains_bugfix_hard_fork`
///
/// we define a "bugfix" hard fork as any hard fork which
/// you would put on-by-default in a new chain.
#[derive(Debug, PartialEq, Default)]
#[cfg_attr(test, derive(Clone))]
pub struct CommonParams {
@ -59,8 +64,10 @@ pub struct CommonParams {
pub fork_block: Option<(BlockNumber, H256)>,
/// Number of first block where EIP-98 rules begin.
pub eip98_transition: BlockNumber,
/// Number of first block where EIP-155 rules begin.
pub eip155_transition: BlockNumber,
/// Validate block receipts root.
pub validate_receipts_transition: u64,
pub validate_receipts_transition: BlockNumber,
/// Number of first block where EIP-86 (Metropolis) rules begin.
pub eip86_transition: BlockNumber,
/// Number of first block where EIP-140 (Metropolis: REVERT opcode) rules begin.
@ -85,6 +92,12 @@ pub struct CommonParams {
pub remove_dust_contracts: bool,
/// Wasm support
pub wasm: bool,
/// Gas limit bound divisor (how much gas limit can change per block)
pub gas_limit_bound_divisor: U256,
/// Block reward in wei.
pub block_reward: U256,
/// Registrar contract address.
pub registrar: Address,
}
impl CommonParams {
@ -111,6 +124,19 @@ impl CommonParams {
};
}
}
/// Whether these params contain any bug-fix hard forks.
pub fn contains_bugfix_hard_fork(&self) -> bool {
self.eip98_transition != 0 &&
self.eip155_transition != 0 &&
self.validate_receipts_transition != 0 &&
self.eip86_transition != 0 &&
self.eip140_transition != 0 &&
self.eip210_transition != 0 &&
self.eip211_transition != 0 &&
self.eip214_transition != 0 &&
self.dust_protection_transition != 0
}
}
impl From<ethjson::spec::Params> for CommonParams {
@ -124,6 +150,7 @@ impl From<ethjson::spec::Params> for CommonParams {
min_gas_limit: p.min_gas_limit.into(),
fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) { Some((n.into(), h.into())) } else { None },
eip98_transition: p.eip98_transition.map_or(0, Into::into),
eip155_transition: p.eip155_transition.map_or(0, Into::into),
validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into),
eip86_transition: p.eip86_transition.map_or(BlockNumber::max_value(), Into::into),
eip140_transition: p.eip140_transition.map_or(BlockNumber::max_value(), Into::into),
@ -139,6 +166,9 @@ impl From<ethjson::spec::Params> for CommonParams {
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
wasm: p.wasm.unwrap_or(false),
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
block_reward: p.block_reward.map_or_else(U256::zero, Into::into),
registrar: p.registrar.map_or_else(Address::new, Into::into),
}
}
}
@ -242,7 +272,7 @@ impl Spec {
) -> Arc<Engine> {
match engine_spec {
ethjson::spec::Engine::Null => Arc::new(NullEngine::new(params, builtins)),
ethjson::spec::Engine::InstantSeal(instant) => Arc::new(InstantSeal::new(params, instant.params.registrar.map_or_else(Address::new, Into::into), builtins)),
ethjson::spec::Engine::InstantSeal => Arc::new(InstantSeal::new(params, builtins)),
ethjson::spec::Engine::Ethash(ethash) => Arc::new(ethereum::Ethash::new(cache_dir, params, From::from(ethash.params), builtins)),
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(params, From::from(basic_authority.params), builtins)),
ethjson::spec::Engine::AuthorityRound(authority_round) => AuthorityRound::new(params, From::from(authority_round.params), builtins).expect("Failed to start AuthorityRound consensus engine."),

View File

@ -396,14 +396,11 @@ pub fn get_bad_state_dummy_block() -> Bytes {
pub fn get_default_ethash_params() -> EthashParams {
EthashParams {
gas_limit_bound_divisor: U256::from(1024),
minimum_difficulty: U256::from(131072),
difficulty_bound_divisor: U256::from(2048),
difficulty_increment_divisor: 10,
metropolis_difficulty_increment_divisor: 9,
duration_limit: 13,
block_reward: U256::from(0),
registrar: "0000000000000000000000000000000000000001".into(),
homestead_transition: 1150000,
dao_hardfork_transition: u64::max_value(),
dao_hardfork_beneficiary: "0000000000000000000000000000000000000001".into(),
@ -413,7 +410,6 @@ pub fn get_default_ethash_params() -> EthashParams{
bomb_defuse_transition: u64::max_value(),
eip100b_transition: u64::max_value(),
eip150_transition: u64::max_value(),
eip155_transition: u64::max_value(),
eip160_transition: u64::max_value(),
eip161abc_transition: u64::max_value(),
eip161d_transition: u64::max_value(),

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
ethcore-util = { path = "../util" }
ethcore-bigint = { path = "../util/bigint" }
rustc-hex = "1.0"
serde = "1.0"
serde_json = "1.0"

View File

@ -21,7 +21,7 @@ use std::fmt;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Error, Visitor};
use rustc_hex::ToHex;
use util::hash::{H64 as Hash64, H160 as Hash160, H256 as Hash256, H520 as Hash520, H2048 as Hash2048};
use bigint::hash::{H64 as Hash64, H160 as Hash160, H256 as Hash256, H520 as Hash520, H2048 as Hash2048};
macro_rules! impl_hash {
@ -99,7 +99,7 @@ impl_hash!(Bloom, Hash2048);
mod test {
use std::str::FromStr;
use serde_json;
use util::hash;
use bigint::hash;
use hash::H256;
#[test]

View File

@ -17,7 +17,7 @@
extern crate rustc_hex;
extern crate serde;
extern crate serde_json;
extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
#[macro_use] extern crate serde_derive;
pub mod hash;

View File

@ -68,7 +68,7 @@ impl<T> Into<Option<T>> for MaybeEmpty<T> {
mod tests {
use std::str::FromStr;
use serde_json;
use util::hash;
use bigint::hash;
use hash::H256;
use maybe::MaybeEmpty;

View File

@ -50,7 +50,7 @@ mod tests {
use std::collections::BTreeMap;
use serde_json;
use spec::account::Account;
use util::U256;
use bigint::prelude::U256;
use uint::Uint;
use bytes::Bytes;

View File

@ -17,25 +17,16 @@
//! Authority params deserialization.
use uint::Uint;
use hash::Address;
use super::ValidatorSet;
/// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct AuthorityRoundParams {
/// Gas limit divisor.
#[serde(rename="gasLimitBoundDivisor")]
pub gas_limit_bound_divisor: Uint,
/// Block duration.
#[serde(rename="stepDuration")]
pub step_duration: Uint,
/// Valid authorities
pub validators: ValidatorSet,
/// Block reward.
#[serde(rename="blockReward")]
pub block_reward: Option<Uint>,
/// Address of the registrar contract.
pub registrar: Option<Address>,
/// Starting step. Determined automatically if not specified.
/// To be used for testing only.
#[serde(rename="startStep")]
@ -43,9 +34,6 @@ pub struct AuthorityRoundParams {
/// Block at which score validation should start.
#[serde(rename="validateScoreTransition")]
pub validate_score_transition: Option<Uint>,
/// See main AuthorityRoundParams docs.
#[serde(rename="eip155Transition")]
pub eip155_transition: Option<Uint>,
/// Block from which monotonic steps start.
#[serde(rename="validateStepTransition")]
pub validate_step_transition: Option<Uint>,
@ -63,9 +51,8 @@ pub struct AuthorityRound {
#[cfg(test)]
mod tests {
use bigint::prelude::{U256, H160};
use uint::Uint;
use util::U256;
use util::H160;
use serde_json;
use hash::Address;
use spec::validator_set::ValidatorSet;
@ -75,26 +62,19 @@ mod tests {
fn authority_round_deserialization() {
let s = r#"{
"params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": "0x02",
"validators": {
"list" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
},
"blockReward": "0x50",
"startStep" : 24,
"eip155Transition": "0x42",
"validateStepTransition": 150
}
}"#;
let deserialized: AuthorityRound = serde_json::from_str(s).unwrap();
assert_eq!(deserialized.params.gas_limit_bound_divisor, Uint(U256::from(0x0400)));
assert_eq!(deserialized.params.step_duration, Uint(U256::from(0x02)));
assert_eq!(deserialized.params.validators, ValidatorSet::List(vec![Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))]));
assert_eq!(deserialized.params.block_reward, Some(Uint(U256::from(0x50))));
assert!(deserialized.params.registrar.is_none());
assert_eq!(deserialized.params.start_step, Some(Uint(U256::from(24))));
assert_eq!(deserialized.params.eip155_transition, Some(Uint(U256::from(0x42))));
assert_eq!(deserialized.params.immediate_transitions, None);
}
}

View File

@ -22,9 +22,6 @@ use super::ValidatorSet;
/// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct BasicAuthorityParams {
/// Gas limit divisor.
#[serde(rename="gasLimitBoundDivisor")]
pub gas_limit_bound_divisor: Uint,
/// Block duration.
#[serde(rename="durationLimit")]
pub duration_limit: Uint,
@ -43,9 +40,8 @@ pub struct BasicAuthority {
mod tests {
use serde_json;
use uint::Uint;
use util::U256;
use bigint::prelude::{U256, H160};
use hash::Address;
use util::hash::H160;
use spec::basic_authority::BasicAuthority;
use spec::validator_set::ValidatorSet;
@ -53,7 +49,6 @@ mod tests {
fn basic_authority_deserialization() {
let s = r#"{
"params": {
"gasLimitBoundDivisor": "0x0400",
"durationLimit": "0x0d",
"validators" : {
"list": ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
@ -63,7 +58,6 @@ mod tests {
let deserialized: BasicAuthority = serde_json::from_str(s).unwrap();
assert_eq!(deserialized.params.gas_limit_bound_divisor, Uint(U256::from(0x0400)));
assert_eq!(deserialized.params.duration_limit, Uint(U256::from(0x0d)));
let vs = ValidatorSet::List(vec![Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))]);
assert_eq!(deserialized.params.validators, vs);

View File

@ -16,7 +16,7 @@
//! Engine deserialization.
use super::{Ethash, InstantSeal, BasicAuthority, AuthorityRound, Tendermint};
use super::{Ethash, BasicAuthority, AuthorityRound, Tendermint};
/// Engine deserialization.
#[derive(Debug, PartialEq, Deserialize)]
@ -26,7 +26,7 @@ pub enum Engine {
Null,
/// Instantly sealing engine.
#[serde(rename="instantSeal")]
InstantSeal(InstantSeal),
InstantSeal,
/// Ethash engine.
Ethash(Ethash),
/// BasicAuthority engine.
@ -55,23 +55,21 @@ mod tests {
assert_eq!(Engine::Null, deserialized);
let s = r#"{
"instantSeal": { "params": {} }
"instantSeal": null
}"#;
let deserialized: Engine = serde_json::from_str(s).unwrap();
match deserialized {
Engine::InstantSeal(_) => {}, // instant seal is unit tested in its own file.
Engine::InstantSeal => {}, // instant seal is unit tested in its own file.
_ => assert!(false),
};
let s = r#"{
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition" : "0x",
"daoHardforkTransition": "0xffffffffffffffff",
@ -90,7 +88,6 @@ mod tests {
let s = r#"{
"basicAuthority": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"durationLimit": "0x0d",
"validators" : {
"list": ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
@ -107,14 +104,11 @@ mod tests {
let s = r#"{
"authorityRound": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": "0x02",
"validators": {
"list" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
},
"blockReward": "0x50",
"startStep" : 24,
"eip155Transition": "0x42",
"validateStepTransition": 150
}
}
@ -128,11 +122,9 @@ mod tests {
let s = r#"{
"tendermint": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"validators": {
"list": ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
},
"blockReward": "0x50"
}
}
}
}"#;

View File

@ -22,9 +22,6 @@ use hash::Address;
/// Deserializable doppelganger of EthashParams.
#[derive(Debug, PartialEq, Deserialize)]
pub struct EthashParams {
/// See main EthashParams docs.
#[serde(rename="gasLimitBoundDivisor")]
pub gas_limit_bound_divisor: Uint,
/// See main EthashParams docs.
#[serde(rename="minimumDifficulty")]
pub minimum_difficulty: Uint,
@ -40,11 +37,6 @@ pub struct EthashParams {
/// See main EthashParams docs.
#[serde(rename="durationLimit")]
pub duration_limit: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="blockReward")]
pub block_reward: Uint,
/// See main EthashParams docs.
pub registrar: Option<Address>,
/// See main EthashParams docs.
#[serde(rename="homesteadTransition")]
@ -78,10 +70,6 @@ pub struct EthashParams {
#[serde(rename="eip150Transition")]
pub eip150_transition: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="eip155Transition")]
pub eip155_transition: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="eip160Transition")]
pub eip160_transition: Option<Uint>,
@ -136,21 +124,17 @@ pub struct Ethash {
mod tests {
use serde_json;
use uint::Uint;
use util::U256;
use bigint::prelude::{H160, U256};
use hash::Address;
use util::hash::H160;
use spec::ethash::{Ethash, EthashParams};
#[test]
fn ethash_deserialization() {
let s = r#"{
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar": "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0x42",
"daoHardforkTransition": "0x08",
"daoHardforkBeneficiary": "0xabcabcabcabcabcabcabcabcabcabcabcabcabca",
@ -181,7 +165,6 @@ mod tests {
"bombDefuseTransition": "0x41",
"eip100bTransition": "0x42",
"eip150Transition": "0x43",
"eip155Transition": "0x44",
"eip160Transition": "0x45",
"eip161abcTransition": "0x46",
"eip161dTransition": "0x47"
@ -192,14 +175,11 @@ mod tests {
assert_eq!(deserialized, Ethash {
params: EthashParams{
gas_limit_bound_divisor: Uint(U256::from(0x0400)),
minimum_difficulty: Uint(U256::from(0x020000)),
difficulty_bound_divisor: Uint(U256::from(0x0800)),
difficulty_increment_divisor: None,
metropolis_difficulty_increment_divisor: None,
duration_limit: Some(Uint(U256::from(0x0d))),
block_reward: Uint(U256::from(0x4563918244F40000u64)),
registrar: Some(Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))),
homestead_transition: Some(Uint(U256::from(0x42))),
dao_hardfork_transition: Some(Uint(U256::from(0x08))),
dao_hardfork_beneficiary: Some(Address(H160::from("0xabcabcabcabcabcabcabcabcabcabcabcabcabca"))),
@ -230,7 +210,6 @@ mod tests {
bomb_defuse_transition: Some(Uint(U256::from(0x41))),
eip100b_transition: Some(Uint(U256::from(0x42))),
eip150_transition: Some(Uint(U256::from(0x43))),
eip155_transition: Some(Uint(U256::from(0x44))),
eip160_transition: Some(Uint(U256::from(0x45))),
eip161abc_transition: Some(Uint(U256::from(0x46))),
eip161d_transition: Some(Uint(U256::from(0x47))),
@ -250,24 +229,19 @@ mod tests {
fn ethash_deserialization_missing_optionals() {
let s = r#"{
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"blockReward": "0x4563918244F40000"
"minimumDifficulty": "0x020000"
}
}"#;
let deserialized: Ethash = serde_json::from_str(s).unwrap();
assert_eq!(deserialized, Ethash {
params: EthashParams {
gas_limit_bound_divisor: Uint(U256::from(0x0400)),
minimum_difficulty: Uint(U256::from(0x020000)),
difficulty_bound_divisor: Uint(U256::from(0x0800)),
difficulty_increment_divisor: None,
metropolis_difficulty_increment_divisor: None,
duration_limit: None,
block_reward: Uint(U256::from(0x4563918244F40000u64)),
registrar: None,
homestead_transition: None,
dao_hardfork_transition: None,
dao_hardfork_beneficiary: None,
@ -277,7 +251,6 @@ mod tests {
bomb_defuse_transition: None,
eip100b_transition: None,
eip150_transition: None,
eip155_transition: None,
eip160_transition: None,
eip161abc_transition: None,
eip161d_transition: None,

View File

@ -60,10 +60,8 @@ mod tests {
use serde_json;
use bytes::Bytes;
use uint::Uint;
use util::U256;
use bigint::prelude::{U256, H160, H64 as Eth64, H256 as Eth256};
use hash::{H64, H256, Address};
use util::hash::H160;
use util::{H64 as Eth64, H256 as Eth256};
use spec::genesis::Genesis;
use spec::{Ethereum, Seal};
use std::str::FromStr;

View File

@ -1,53 +0,0 @@
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Instant params deserialization.
use hash::Address;
/// Instant params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct InstantSealParams {
/// Address of the registrar contract.
pub registrar: Option<Address>,
}
/// Instant engine deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct InstantSeal {
/// Instant Seal params.
pub params: InstantSealParams,
}
#[cfg(test)]
mod tests {
use serde_json;
use hash::Address;
use util::hash::H160;
use spec::instant_seal::InstantSeal;
#[test]
fn instant_seal_deserialization() {
let s = r#"{
"params": {
"registrar": "0xc6d9d2cd449a754c494264e1809c50e34d64562b"
}
}"#;
let deserialized: InstantSeal = serde_json::from_str(s).unwrap();
assert_eq!(deserialized.params.registrar, Some(Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))));
}
}

View File

@ -26,7 +26,6 @@ pub mod engine;
pub mod state;
pub mod ethash;
pub mod validator_set;
pub mod instant_seal;
pub mod basic_authority;
pub mod authority_round;
pub mod tendermint;
@ -41,7 +40,6 @@ pub use self::engine::Engine;
pub use self::state::State;
pub use self::ethash::{Ethash, EthashParams};
pub use self::validator_set::ValidatorSet;
pub use self::instant_seal::{InstantSeal, InstantSealParams};
pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams};
pub use self::authority_round::{AuthorityRound, AuthorityRoundParams};
pub use self::tendermint::{Tendermint, TendermintParams};

View File

@ -55,6 +55,9 @@ pub struct Params {
#[serde(rename="eip98Transition")]
pub eip98_transition: Option<Uint>,
/// See `CommonParams` docs.
#[serde(rename="eip155Transition")]
pub eip155_transition: Option<Uint>,
/// See `CommonParams` docs.
#[serde(rename="validateReceiptsTransition")]
pub validate_receipts_transition: Option<Uint>,
/// See `CommonParams` docs.
@ -91,13 +94,21 @@ pub struct Params {
pub remove_dust_contracts : Option<bool>,
/// Wasm support flag
pub wasm: Option<bool>,
/// See `CommonParams` docs.
#[serde(rename="gasLimitBoundDivisor")]
pub gas_limit_bound_divisor: Uint,
/// See `CommonParams` docs.
#[serde(rename="blockReward")]
pub block_reward: Option<Uint>,
/// See `CommonParams` docs.
pub registrar: Option<Address>,
}
#[cfg(test)]
mod tests {
use serde_json;
use uint::Uint;
use util::U256;
use bigint::prelude::U256;
use spec::params::Params;
#[test]
@ -108,7 +119,8 @@ mod tests {
"chainID" : "0x15",
"subprotocolName" : "exp",
"minGasLimit": "0x1388",
"accountStartNonce": "0x01"
"accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x20"
}"#;
let deserialized: Params = serde_json::from_str(s).unwrap();
@ -118,5 +130,6 @@ mod tests {
assert_eq!(deserialized.subprotocol_name, Some("exp".to_owned()));
assert_eq!(deserialized.min_gas_limit, Uint(U256::from(0x1388)));
assert_eq!(deserialized.account_start_nonce, Some(Uint(U256::from(0x01))));
assert_eq!(deserialized.gas_limit_bound_divisor, Uint(U256::from(0x20)));
}
}

View File

@ -73,8 +73,7 @@ mod tests {
use hash::*;
use bytes::Bytes;
use uint::Uint;
use util::U256;
use util::{H64 as Eth64, H256 as Eth256, H520 as Eth520};
use bigint::prelude::{U256, H64 as Eth64, H256 as Eth256, H520 as Eth520};
use spec::{Ethereum, AuthorityRoundSeal, TendermintSeal, Seal};
#[test]

View File

@ -61,12 +61,9 @@ mod tests {
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition" : "0x",
"daoHardforkTransition": "0xffffffffffffffff",
"daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000",
@ -81,7 +78,8 @@ mod tests {
"minGasLimit": "0x1388",
"networkID" : "0x2",
"forkBlock": "0xffffffffffffffff",
"forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
"forkCanonHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimitBoundDivisor": "0x20"
},
"genesis": {
"seal": {

View File

@ -17,15 +17,11 @@
//! Tendermint params deserialization.
use uint::Uint;
use hash::Address;
use super::ValidatorSet;
/// Tendermint params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct TendermintParams {
/// Gas limit divisor.
#[serde(rename="gasLimitBoundDivisor")]
pub gas_limit_bound_divisor: Uint,
/// Valid validators.
pub validators: ValidatorSet,
/// Propose step timeout in milliseconds.
@ -40,11 +36,6 @@ pub struct TendermintParams {
/// Commit step timeout in milliseconds.
#[serde(rename="timeoutCommit")]
pub timeout_commit: Option<Uint>,
/// Block reward.
#[serde(rename="blockReward")]
pub block_reward: Option<Uint>,
/// Address of the registrar contract.
pub registrar: Option<Address>,
}
/// Tendermint engine deserialization.
@ -57,10 +48,7 @@ pub struct Tendermint {
#[cfg(test)]
mod tests {
use serde_json;
use uint::Uint;
use util::U256;
use hash::Address;
use util::hash::H160;
use bigint::prelude::H160;
use spec::tendermint::Tendermint;
use spec::validator_set::ValidatorSet;
@ -68,18 +56,14 @@ mod tests {
fn tendermint_deserialization() {
let s = r#"{
"params": {
"gasLimitBoundDivisor": "0x0400",
"validators": {
"list": ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
},
"blockReward": "0x50"
}
}
}"#;
let deserialized: Tendermint = serde_json::from_str(s).unwrap();
assert_eq!(deserialized.params.gas_limit_bound_divisor, Uint(U256::from(0x0400)));
let vs = ValidatorSet::List(vec![Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))]);
assert_eq!(deserialized.params.validators, vs);
assert_eq!(deserialized.params.block_reward, Some(Uint(U256::from(0x50))));
}
}

View File

@ -41,9 +41,8 @@ pub enum ValidatorSet {
mod tests {
use serde_json;
use uint::Uint;
use util::U256;
use bigint::prelude::{H160, U256};
use hash::Address;
use util::hash::H160;
use spec::validator_set::ValidatorSet;
#[test]

View File

@ -20,7 +20,7 @@ use std::fmt;
use std::str::FromStr;
use serde::{Deserialize, Deserializer};
use serde::de::{Error, Visitor};
use util::U256;
use bigint::prelude::U256;
/// Lenient uint json deserialization for test json files.
#[derive(Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
@ -93,7 +93,7 @@ impl<'a> Visitor<'a> for UintVisitor {
#[cfg(test)]
mod test {
use serde_json;
use util::U256;
use bigint::prelude::U256;
use uint::Uint;
#[test]

View File

@ -39,7 +39,7 @@ pub struct Call {
mod tests {
use serde_json;
use vm::Call;
use util::{U256, H160 as Hash160};
use bigint::prelude::{U256, H160 as Hash160};
use uint::Uint;
use hash::Address;
use maybe::MaybeEmpty;

View File

@ -227,12 +227,9 @@ const TRANSACTION_COUNT_SPEC: &'static [u8] = br#"{
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0xffffffffffffffff",
"daoHardforkTransition": "0xffffffffffffffff",
"daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000",
@ -241,6 +238,9 @@ const TRANSACTION_COUNT_SPEC: &'static [u8] = br#"{
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x50000",
@ -275,12 +275,9 @@ const POSITIVE_NONCE_SPEC: &'static [u8] = br#"{
"engine": {
"Ethash": {
"params": {
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"homesteadTransition": "0xffffffffffffffff",
"daoHardforkTransition": "0xffffffffffffffff",
"daoHardforkBeneficiary": "0x0000000000000000000000000000000000000000",
@ -289,6 +286,9 @@ const POSITIVE_NONCE_SPEC: &'static [u8] = br#"{
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"blockReward": "0x4563918244F40000",
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x0100",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x50000",