Merge branch 'master' into split

This commit is contained in:
debris 2017-07-31 16:19:59 +02:00
commit 81b57ceddb
59 changed files with 427 additions and 426 deletions

2
Cargo.lock generated
View File

@ -787,7 +787,7 @@ name = "ethjson"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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 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)", "serde_derive 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -49,22 +49,14 @@ mod finality;
/// `AuthorityRound` params. /// `AuthorityRound` params.
pub struct AuthorityRoundParams { pub struct AuthorityRoundParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// Time to wait before next block or authority switching. /// Time to wait before next block or authority switching.
pub step_duration: Duration, pub step_duration: Duration,
/// Block reward.
pub block_reward: U256,
/// Namereg contract address.
pub registrar: Address,
/// Starting step, /// Starting step,
pub start_step: Option<u64>, pub start_step: Option<u64>,
/// Valid validators. /// Valid validators.
pub validators: Box<ValidatorSet>, pub validators: Box<ValidatorSet>,
/// Chain score validation transition block. /// Chain score validation transition block.
pub validate_score_transition: u64, pub validate_score_transition: u64,
/// Number of first block where EIP-155 rules are validated.
pub eip155_transition: u64,
/// Monotonic step validation transition block. /// Monotonic step validation transition block.
pub validate_step_transition: u64, pub validate_step_transition: u64,
/// Immediate transitions. /// Immediate transitions.
@ -74,14 +66,10 @@ pub struct AuthorityRoundParams {
impl From<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams { impl From<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams {
fn from(p: ethjson::spec::AuthorityRoundParams) -> Self { fn from(p: ethjson::spec::AuthorityRoundParams) -> Self {
AuthorityRoundParams { AuthorityRoundParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
step_duration: Duration::from_secs(p.step_duration.into()), step_duration: Duration::from_secs(p.step_duration.into()),
validators: new_validator_set(p.validators), 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), start_step: p.start_step.map(Into::into),
validate_score_transition: p.validate_score_transition.map_or(0, 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), validate_step_transition: p.validate_step_transition.map_or(0, Into::into),
immediate_transitions: p.immediate_transitions.unwrap_or(false), immediate_transitions: p.immediate_transitions.unwrap_or(false),
} }
@ -216,9 +204,6 @@ impl EpochManager {
/// Engine using `AuthorityRound` proof-of-authority BFT consensus. /// Engine using `AuthorityRound` proof-of-authority BFT consensus.
pub struct AuthorityRound { pub struct AuthorityRound {
params: CommonParams, params: CommonParams,
gas_limit_bound_divisor: U256,
block_reward: U256,
registrar: Address,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
transition_service: IoService<()>, transition_service: IoService<()>,
step: Arc<Step>, step: Arc<Step>,
@ -227,7 +212,6 @@ pub struct AuthorityRound {
signer: RwLock<EngineSigner>, signer: RwLock<EngineSigner>,
validators: Box<ValidatorSet>, validators: Box<ValidatorSet>,
validate_score_transition: u64, validate_score_transition: u64,
eip155_transition: u64,
validate_step_transition: u64, validate_step_transition: u64,
epoch_manager: Mutex<EpochManager>, epoch_manager: Mutex<EpochManager>,
immediate_transitions: bool, immediate_transitions: bool,
@ -364,9 +348,6 @@ impl AuthorityRound {
let engine = Arc::new( let engine = Arc::new(
AuthorityRound { AuthorityRound {
params: params, params: params,
gas_limit_bound_divisor: our_params.gas_limit_bound_divisor,
block_reward: our_params.block_reward,
registrar: our_params.registrar,
builtins: builtins, builtins: builtins,
transition_service: IoService::<()>::start()?, transition_service: IoService::<()>::start()?,
step: Arc::new(Step { step: Arc::new(Step {
@ -379,7 +360,6 @@ impl AuthorityRound {
signer: Default::default(), signer: Default::default(),
validators: our_params.validators, validators: our_params.validators,
validate_score_transition: our_params.validate_score_transition, validate_score_transition: our_params.validate_score_transition,
eip155_transition: our_params.eip155_transition,
validate_step_transition: our_params.validate_step_transition, validate_step_transition: our_params.validate_step_transition,
epoch_manager: Mutex::new(EpochManager::blank()), epoch_manager: Mutex::new(EpochManager::blank()),
immediate_transitions: our_params.immediate_transitions, immediate_transitions: our_params.immediate_transitions,
@ -435,7 +415,9 @@ impl Engine for AuthorityRound {
fn params(&self) -> &CommonParams { &self.params } 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 } fn builtins(&self) -> &BTreeMap<Address, Builtin> { &self.builtins }
@ -463,7 +445,7 @@ impl Engine for AuthorityRound {
header.set_difficulty(new_difficulty); header.set_difficulty(new_difficulty);
header.set_gas_limit({ header.set_gas_limit({
let gas_limit = parent.gas_limit().clone(); 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 { if gas_limit < gas_floor_target {
cmp::min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into()) cmp::min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
} else { } else {
@ -566,7 +548,8 @@ impl Engine for AuthorityRound {
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> { fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error> {
let fields = block.fields_mut(); let fields = block.fields_mut();
// Bestow block reward // 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) .map_err(::error::Error::from)
.and_then(|_| fields.state.commit()); .and_then(|_| fields.state.commit());
// Commit state so that we can actually figure out the state root. // Commit state so that we can actually figure out the state root.
@ -631,7 +614,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 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; 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 { if header.gas_limit() <= &min_gas || header.gas_limit() >= &max_gas {
@ -821,7 +804,7 @@ impl Engine for AuthorityRound {
t.check_low_s()?; t.check_low_s()?;
if let Some(n) = t.network_id() { 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()); return Err(TransactionError::InvalidNetworkId.into());
} }
} }
@ -1017,18 +1000,19 @@ mod tests {
fn reports_skipped() { fn reports_skipped() {
let last_benign = Arc::new(AtomicUsize::new(0)); let last_benign = Arc::new(AtomicUsize::new(0));
let params = AuthorityRoundParams { let params = AuthorityRoundParams {
gas_limit_bound_divisor: "400".parse::<U256>().unwrap(),
step_duration: Default::default(), step_duration: Default::default(),
block_reward: Default::default(),
registrar: Default::default(),
start_step: Some(1), start_step: Some(1),
validators: Box::new(TestSet::new(Default::default(), last_benign.clone())), validators: Box::new(TestSet::new(Default::default(), last_benign.clone())),
validate_score_transition: 0, validate_score_transition: 0,
validate_step_transition: 0, validate_step_transition: 0,
eip155_transition: 0,
immediate_transitions: true, 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(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&1usize).into_vec()]); parent_header.set_seal(vec![encode(&1usize).into_vec()]);

View File

@ -37,8 +37,6 @@ use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
/// `BasicAuthority` params. /// `BasicAuthority` params.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct BasicAuthorityParams { pub struct BasicAuthorityParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// Valid signatories. /// Valid signatories.
pub validators: ethjson::spec::ValidatorSet, pub validators: ethjson::spec::ValidatorSet,
} }
@ -46,7 +44,6 @@ pub struct BasicAuthorityParams {
impl From<ethjson::spec::BasicAuthorityParams> for BasicAuthorityParams { impl From<ethjson::spec::BasicAuthorityParams> for BasicAuthorityParams {
fn from(p: ethjson::spec::BasicAuthorityParams) -> Self { fn from(p: ethjson::spec::BasicAuthorityParams) -> Self {
BasicAuthorityParams { BasicAuthorityParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
validators: p.validators, validators: p.validators,
} }
} }
@ -82,7 +79,6 @@ fn verify_external(header: &Header, validators: &ValidatorSet) -> Result<(), Err
/// Engine using `BasicAuthority`, trivial proof-of-authority consensus. /// Engine using `BasicAuthority`, trivial proof-of-authority consensus.
pub struct BasicAuthority { pub struct BasicAuthority {
params: CommonParams, params: CommonParams,
gas_limit_bound_divisor: U256,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
signer: RwLock<EngineSigner>, signer: RwLock<EngineSigner>,
validators: Box<ValidatorSet>, validators: Box<ValidatorSet>,
@ -93,7 +89,6 @@ impl BasicAuthority {
pub fn new(params: CommonParams, our_params: BasicAuthorityParams, builtins: BTreeMap<Address, Builtin>) -> Self { pub fn new(params: CommonParams, our_params: BasicAuthorityParams, builtins: BTreeMap<Address, Builtin>) -> Self {
BasicAuthority { BasicAuthority {
params: params, params: params,
gas_limit_bound_divisor: our_params.gas_limit_bound_divisor,
builtins: builtins, builtins: builtins,
validators: new_validator_set(our_params.validators), validators: new_validator_set(our_params.validators),
signer: Default::default(), signer: Default::default(),
@ -121,7 +116,7 @@ impl Engine for BasicAuthority {
header.set_difficulty(parent.difficulty().clone()); header.set_difficulty(parent.difficulty().clone());
header.set_gas_limit({ header.set_gas_limit({
let gas_limit = parent.gas_limit().clone(); 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 { if gas_limit < gas_floor_target {
cmp::min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into()) cmp::min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
} else { } else {
@ -174,7 +169,7 @@ impl Engine for BasicAuthority {
if header.difficulty() != parent.difficulty() { if header.difficulty() != parent.difficulty() {
return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: *parent.difficulty(), found: *header.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 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; 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 { 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. /// An engine which does not provide any consensus mechanism, just seals blocks internally.
pub struct InstantSeal { pub struct InstantSeal {
params: CommonParams, params: CommonParams,
registrar: Address,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
} }
impl InstantSeal { impl InstantSeal {
/// Returns new instance of InstantSeal with default VM Factory /// 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 { InstantSeal {
params: params, params: params,
registrar: registrar,
builtins: builtins, builtins: builtins,
} }
} }
@ -49,7 +47,7 @@ impl Engine for InstantSeal {
} }
fn additional_params(&self) -> HashMap<String, String> { 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> { fn builtins(&self) -> &BTreeMap<Address, Builtin> {

View File

@ -73,12 +73,9 @@ pub type BlockHash = H256;
/// Engine using `Tendermint` consensus algorithm, suitable for EVM chain. /// Engine using `Tendermint` consensus algorithm, suitable for EVM chain.
pub struct Tendermint { pub struct Tendermint {
params: CommonParams, params: CommonParams,
gas_limit_bound_divisor: U256,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
step_service: IoService<Step>, step_service: IoService<Step>,
client: RwLock<Option<Weak<EngineClient>>>, client: RwLock<Option<Weak<EngineClient>>>,
block_reward: U256,
registrar: Address,
/// Blockchain height. /// Blockchain height.
height: AtomicUsize, height: AtomicUsize,
/// Consensus view. /// Consensus view.
@ -168,12 +165,9 @@ impl Tendermint {
let engine = Arc::new( let engine = Arc::new(
Tendermint { Tendermint {
params: params, params: params,
gas_limit_bound_divisor: our_params.gas_limit_bound_divisor,
builtins: builtins, builtins: builtins,
client: RwLock::new(None), client: RwLock::new(None),
step_service: IoService::<Step>::start()?, step_service: IoService::<Step>::start()?,
block_reward: our_params.block_reward,
registrar: our_params.registrar,
height: AtomicUsize::new(1), height: AtomicUsize::new(1),
view: AtomicUsize::new(0), view: AtomicUsize::new(0),
step: RwLock::new(Step::Propose), step: RwLock::new(Step::Propose),
@ -448,7 +442,9 @@ impl Engine for Tendermint {
fn params(&self) -> &CommonParams { &self.params } 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 } fn builtins(&self) -> &BTreeMap<Address, Builtin> { &self.builtins }
@ -473,7 +469,7 @@ impl Engine for Tendermint {
header.set_difficulty(new_difficulty); header.set_difficulty(new_difficulty);
header.set_gas_limit({ header.set_gas_limit({
let gas_limit = parent.gas_limit().clone(); 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 { if gas_limit < gas_floor_target {
cmp::min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into()) cmp::min(gas_floor_target, gas_limit + gas_limit / bound_divisor - 1.into())
} else { } else {
@ -547,7 +543,8 @@ impl Engine for Tendermint {
fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>{ fn on_close_block(&self, block: &mut ExecutedBlock) -> Result<(), Error>{
let fields = block.fields_mut(); let fields = block.fields_mut();
// Bestow block reward // 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) .map_err(::error::Error::from)
.and_then(|_| fields.state.commit()); .and_then(|_| fields.state.commit());
// Commit state so that we can actually figure out the state root. // Commit state so that we can actually figure out the state root.
@ -619,7 +616,7 @@ impl Engine for Tendermint {
self.check_above_threshold(origins.len())? 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 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; 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 { if header.gas_limit() <= &min_gas || header.gas_limit() >= &max_gas {

View File

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

@ -44,8 +44,6 @@ const SNAPSHOT_BLOCKS: u64 = 30000;
/// Ethash params. /// Ethash params.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct EthashParams { pub struct EthashParams {
/// Gas limit divisor.
pub gas_limit_bound_divisor: U256,
/// Minimum difficulty. /// Minimum difficulty.
pub minimum_difficulty: U256, pub minimum_difficulty: U256,
/// Difficulty bound divisor. /// Difficulty bound divisor.
@ -56,10 +54,6 @@ pub struct EthashParams {
pub metropolis_difficulty_increment_divisor: u64, pub metropolis_difficulty_increment_divisor: u64,
/// Block duration. /// Block duration.
pub duration_limit: u64, pub duration_limit: u64,
/// Block reward.
pub block_reward: U256,
/// Namereg contract address.
pub registrar: Address,
/// Homestead transition block number. /// Homestead transition block number.
pub homestead_transition: u64, pub homestead_transition: u64,
/// DAO hard-fork transition block (X). /// DAO hard-fork transition block (X).
@ -78,8 +72,6 @@ pub struct EthashParams {
pub eip100b_transition: u64, pub eip100b_transition: u64,
/// Number of first block where EIP-150 rules begin. /// Number of first block where EIP-150 rules begin.
pub eip150_transition: u64, 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. /// Number of first block where EIP-160 rules begin.
pub eip160_transition: u64, pub eip160_transition: u64,
/// Number of first block where EIP-161.abc begin. /// Number of first block where EIP-161.abc begin.
@ -107,14 +99,11 @@ pub struct EthashParams {
impl From<ethjson::spec::EthashParams> for EthashParams { impl From<ethjson::spec::EthashParams> for EthashParams {
fn from(p: ethjson::spec::EthashParams) -> Self { fn from(p: ethjson::spec::EthashParams) -> Self {
EthashParams { EthashParams {
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
minimum_difficulty: p.minimum_difficulty.into(), minimum_difficulty: p.minimum_difficulty.into(),
difficulty_bound_divisor: p.difficulty_bound_divisor.into(), difficulty_bound_divisor: p.difficulty_bound_divisor.into(),
difficulty_increment_divisor: p.difficulty_increment_divisor.map_or(10, Into::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), metropolis_difficulty_increment_divisor: p.metropolis_difficulty_increment_divisor.map_or(9, Into::into),
duration_limit: p.duration_limit.map_or(0, 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), 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_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), dao_hardfork_beneficiary: p.dao_hardfork_beneficiary.map_or_else(Address::new, Into::into),
@ -124,7 +113,6 @@ impl From<ethjson::spec::EthashParams> for EthashParams {
bomb_defuse_transition: p.bomb_defuse_transition.map_or(u64::max_value(), Into::into), 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), eip100b_transition: p.eip100b_transition.map_or(u64::max_value(), Into::into),
eip150_transition: p.eip150_transition.map_or(0, 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), eip160_transition: p.eip160_transition.map_or(0, Into::into),
eip161abc_transition: p.eip161abc_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), eip161d_transition: p.eip161d_transition.map_or(u64::max_value(), Into::into),
@ -188,7 +176,7 @@ impl Engine for Arc<Ethash> {
fn seal_fields(&self) -> usize { 2 } fn seal_fields(&self) -> usize { 2 }
fn params(&self) -> &CommonParams { &self.params } 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> { fn builtins(&self) -> &BTreeMap<Address, Builtin> {
&self.builtins &self.builtins
@ -219,7 +207,7 @@ impl Engine for Arc<Ethash> {
} }
fn signing_network_id(&self, env_info: &EnvInfo) -> Option<u64> { 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) Some(self.params().chain_id)
} else { } else {
None None
@ -234,7 +222,7 @@ impl Engine for Arc<Ethash> {
} }
let gas_limit = { let gas_limit = {
let gas_limit = parent.gas_limit().clone(); 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 lower_limit = gas_limit - gas_limit / bound_divisor + 1.into();
let upper_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 { let gas_limit = if gas_limit < gas_floor_target {
@ -287,7 +275,7 @@ impl Engine for Arc<Ethash> {
/// Apply the block reward on finalisation of the block. /// 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). /// 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> { 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 fields = block.fields_mut();
let eras_rounds = self.ethash_params.ecip1017_era_rounds; let eras_rounds = self.ethash_params.ecip1017_era_rounds;
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, fields.header.number()); let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, fields.header.number());
@ -390,7 +378,7 @@ impl Engine for Arc<Ethash> {
if header.difficulty() != &expected_difficulty { if header.difficulty() != &expected_difficulty {
return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: expected_difficulty, found: header.difficulty().clone() }))) 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 parent_gas_limit = *parent.gas_limit();
let min_gas = parent_gas_limit - parent_gas_limit / gas_limit_divisor; let min_gas = parent_gas_limit - parent_gas_limit / gas_limit_divisor;
let max_gas = parent_gas_limit + parent_gas_limit / gas_limit_divisor; let max_gas = parent_gas_limit + parent_gas_limit / gas_limit_divisor;
@ -409,7 +397,7 @@ impl Engine for Arc<Ethash> {
} }
let check_low_s = header.number() >= self.ethash_params.homestead_transition; 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)?; t.verify_basic(check_low_s, network_id, false)?;
Ok(()) Ok(())
} }
@ -815,36 +803,32 @@ mod tests {
#[test] #[test]
fn has_valid_ecip1017_eras_block_reward() { fn has_valid_ecip1017_eras_block_reward() {
let ethparams = EthashParams { let eras_rounds = 5000000;
// see ethcore/res/ethereum/classic.json
ecip1017_era_rounds: 5000000, let start_reward: U256 = "4563918244F40000".parse().unwrap();
block_reward: U256::from_str("4563918244F40000").unwrap(),
..get_default_ethash_params()
};
let eras_rounds = ethparams.ecip1017_era_rounds;
let reward = ethparams.block_reward;
let block_number = 0; 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!(0, eras);
assert_eq!(U256::from_str("4563918244F40000").unwrap(), reward); assert_eq!(U256::from_str("4563918244F40000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 5000000; 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!(0, eras);
assert_eq!(U256::from_str("4563918244F40000").unwrap(), reward); assert_eq!(U256::from_str("4563918244F40000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 10000000; 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!(1, eras);
assert_eq!(U256::from_str("3782DACE9D900000").unwrap(), reward); assert_eq!(U256::from_str("3782DACE9D900000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 20000000; 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!(3, eras);
assert_eq!(U256::from_str("2386F26FC1000000").unwrap(), reward); assert_eq!(U256::from_str("2386F26FC1000000").unwrap(), reward);
let reward = ethparams.block_reward;
let block_number = 80000000; 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!(15, eras);
assert_eq!(U256::from_str("271000000000000").unwrap(), reward); assert_eq!(U256::from_str("271000000000000").unwrap(), reward);
} }

View File

@ -1114,6 +1114,8 @@ impl MinerService for Miner {
/// Prepare the block and work if the Engine does not seal internally. /// Prepare the block and work if the Engine does not seal internally.
fn update_sealing(&self, chain: &MiningBlockChainClient) { fn update_sealing(&self, chain: &MiningBlockChainClient) {
trace!(target: "miner", "update_sealing"); 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) { if self.requires_reseal(chain.chain_info().best_block_number) {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -1122,6 +1124,14 @@ impl MinerService for Miner {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
trace!(target: "miner", "update_sealing: preparing a block"); trace!(target: "miner", "update_sealing: preparing a block");
let (block, original_work_hash) = self.prepare_block(chain); 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() { match self.engine.seals_internally() {
Some(true) => { Some(true) => {
trace!(target: "miner", "update_sealing: engine indicates internal sealing"); trace!(target: "miner", "update_sealing: engine indicates internal sealing");
@ -1129,11 +1139,11 @@ impl MinerService for Miner {
trace!(target: "miner", "update_sealing: imported internally sealed block"); 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 => { None => {
trace!(target: "miner", "update_sealing: engine does not seal internally, preparing work"); trace!(target: "miner", "update_sealing: engine does not seal internally, preparing work");
self.prepare_work(block, original_work_hash) 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": { "engine": {
"authorityRound": { "authorityRound": {
"params": { "params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": 1, "stepDuration": 1,
"startStep": 0, "startStep": 0,
"validators": { "validators": {
@ -17,6 +16,7 @@
} }
}, },
"params": { "params": {
"gasLimitBoundDivisor": "0x0400",
"accountStartNonce": "0x0", "accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20", "maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388", "minGasLimit": "0x1388",

View File

@ -43,7 +43,12 @@ use trace::{NoopTracer, NoopVMTracer};
use evm::CallType; use evm::CallType;
use util::*; 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)] #[derive(Debug, PartialEq, Default)]
#[cfg_attr(test, derive(Clone))] #[cfg_attr(test, derive(Clone))]
pub struct CommonParams { pub struct CommonParams {
@ -63,8 +68,10 @@ pub struct CommonParams {
pub fork_block: Option<(BlockNumber, H256)>, pub fork_block: Option<(BlockNumber, H256)>,
/// Number of first block where EIP-98 rules begin. /// Number of first block where EIP-98 rules begin.
pub eip98_transition: BlockNumber, pub eip98_transition: BlockNumber,
/// Number of first block where EIP-155 rules begin.
pub eip155_transition: BlockNumber,
/// Validate block receipts root. /// Validate block receipts root.
pub validate_receipts_transition: u64, pub validate_receipts_transition: BlockNumber,
/// Number of first block where EIP-86 (Metropolis) rules begin. /// Number of first block where EIP-86 (Metropolis) rules begin.
pub eip86_transition: BlockNumber, pub eip86_transition: BlockNumber,
/// Number of first block where EIP-140 (Metropolis: REVERT opcode) rules begin. /// Number of first block where EIP-140 (Metropolis: REVERT opcode) rules begin.
@ -89,6 +96,12 @@ pub struct CommonParams {
pub remove_dust_contracts: bool, pub remove_dust_contracts: bool,
/// Wasm support /// Wasm support
pub wasm: bool, 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 { impl CommonParams {
@ -115,6 +128,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 { impl From<ethjson::spec::Params> for CommonParams {
@ -128,6 +154,7 @@ impl From<ethjson::spec::Params> for CommonParams {
min_gas_limit: p.min_gas_limit.into(), 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 }, 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), 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), validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into),
eip86_transition: p.eip86_transition.map_or(BlockNumber::max_value(), 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), eip140_transition: p.eip140_transition.map_or(BlockNumber::max_value(), Into::into),
@ -143,6 +170,9 @@ impl From<ethjson::spec::Params> for CommonParams {
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into), nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false), remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
wasm: p.wasm.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),
} }
} }
} }
@ -246,7 +276,7 @@ impl Spec {
) -> Arc<Engine> { ) -> Arc<Engine> {
match engine_spec { match engine_spec {
ethjson::spec::Engine::Null => Arc::new(NullEngine::new(params, builtins)), 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::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::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."), 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,16 +396,13 @@ pub fn get_bad_state_dummy_block() -> Bytes {
create_test_block(&block_header) create_test_block(&block_header)
} }
pub fn get_default_ethash_params() -> EthashParams{ pub fn get_default_ethash_params() -> EthashParams {
EthashParams { EthashParams {
gas_limit_bound_divisor: U256::from(1024),
minimum_difficulty: U256::from(131072), minimum_difficulty: U256::from(131072),
difficulty_bound_divisor: U256::from(2048), difficulty_bound_divisor: U256::from(2048),
difficulty_increment_divisor: 10, difficulty_increment_divisor: 10,
metropolis_difficulty_increment_divisor: 9, metropolis_difficulty_increment_divisor: 9,
duration_limit: 13, duration_limit: 13,
block_reward: U256::from(0),
registrar: "0000000000000000000000000000000000000001".into(),
homestead_transition: 1150000, homestead_transition: 1150000,
dao_hardfork_transition: u64::max_value(), dao_hardfork_transition: u64::max_value(),
dao_hardfork_beneficiary: "0000000000000000000000000000000000000001".into(), dao_hardfork_beneficiary: "0000000000000000000000000000000000000001".into(),
@ -415,7 +412,6 @@ pub fn get_default_ethash_params() -> EthashParams{
bomb_defuse_transition: u64::max_value(), bomb_defuse_transition: u64::max_value(),
eip100b_transition: u64::max_value(), eip100b_transition: u64::max_value(),
eip150_transition: u64::max_value(), eip150_transition: u64::max_value(),
eip155_transition: u64::max_value(),
eip160_transition: u64::max_value(), eip160_transition: u64::max_value(),
eip161abc_transition: u64::max_value(), eip161abc_transition: u64::max_value(),
eip161d_transition: u64::max_value(), eip161d_transition: u64::max_value(),

View File

@ -14,58 +14,78 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
export default class Personal { export default class Shh {
constructor (transport) { constructor (transport) {
this._transport = transport; this._transport = transport;
} }
addToGroup (identity) { info () {
return this._transport return this._transport
.execute('shh_addToGroup', identity); .execute('shh_info');
} }
getFilterChanges (filterId) { newKeyPair () {
return this._transport return this._transport
.execute('shh_getFilterChanges', filterId); .execute('shh_newKeyPair');
} }
getMessages (filterId) { addPrivateKey (privKey) {
return this._transport return this._transport
.execute('shh_getMessages', filterId); .execute('shh_addPrivateKey', privKey);
} }
hasIdentity (identity) { newSymKey () {
return this._transport return this._transport
.execute('shh_hasIdentity', identity); .execute('shh_newSymKey');
} }
newFilter (options) { getPublicKey (identity) {
return this._transport return this._transport
.execute('shh_newFilter', options); .execute('shh_getPublicKey', identity);
} }
newGroup () { getPrivateKey (identity) {
return this._transport return this._transport
.execute('shh_newGroup'); .execute('shh_getPrivateKey', identity);
} }
newIdentity () { getSymKey (identity) {
return this._transport return this._transport
.execute('shh_newIdentity'); .execute('shh_getSymKey', identity);
} }
post (options) { deleteKey (identity) {
return this._transport return this._transport
.execute('shh_post', options); .execute('shh_deleteKey', identity);
} }
uninstallFilter (filterId) { post (messageObj) {
return this._transport return this._transport
.execute('shh_uninstallFilter', filterId); .execute('shh_post', messageObj);
} }
version () { newMessageFilter (filterObj) {
return this._transport return this._transport
.execute('shh_version'); .execute('shh_newMessageFilter', filterObj);
}
getFilterMessages (filterId) {
return this._transport
.execute('shh_getFilterMessages', filterId);
}
deleteMessageFilter (filterId) {
return this._transport
.execute('shh_deleteMessageFilter', filterId);
}
subscribe (filterObj, callback) {
return this._transport
.subscribe('shh', callback, filterObj);
}
unsubscribe (subscriptionId) {
return this._transport
.unsubscribe(subscriptionId);
} }
} }

View File

@ -29,7 +29,7 @@ export default class Ws extends JsonRpcBase {
this._url = url; this._url = url;
this._token = token; this._token = token;
this._messages = {}; this._messages = {};
this._subscriptions = { 'eth_subscription': [], 'parity_subscription': [] }; this._subscriptions = { 'eth_subscription': [], 'parity_subscription': [], 'shh_subscription': [] };
this._sessionHash = null; this._sessionHash = null;
this._connecting = false; this._connecting = false;

View File

@ -14,21 +14,37 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { Data, Quantity } from '../types'; import { Data, Quantity, Float } from '../types';
export default { export default {
version: { info: {
nodoc: 'Not present in Rust code',
desc: 'Returns the current whisper protocol version.', desc: 'Returns the current whisper protocol version.',
params: [], params: [],
returns: { returns: {
type: String, type: Object,
desc: 'The current whisper protocol version' desc: 'The current whisper protocol version',
details: {
minPow: {
type: Float,
desc: 'required PoW threshold for a message to be accepted into the local pool, or null if there is empty space in the pool.'
},
messages: {
type: Quantity,
desc: 'Number of messages in the pool.'
},
memory: {
type: Quantity,
desc: 'Amount of memory used by messages in the pool.'
},
targetMemory: {
type: Quantity,
desc: 'Target amount of memory for the pool.'
}
}
} }
}, },
post: { post: {
nodoc: 'Not present in Rust code',
desc: 'Sends a whisper message.', desc: 'Sends a whisper message.',
params: [ params: [
{ {
@ -63,79 +79,122 @@ export default {
} }
}, },
newIdentity: { newKeyPair: {
nodoc: 'Not present in Rust code', desc: 'Generate a new key pair (identity) for asymmetric encryption.',
desc: 'Creates new whisper identity in the client.',
params: [], params: [],
returns: { returns: {
type: Data, type: Data,
desc: '60 Bytes - the address of the new identiy' desc: '32 Bytes - the address of the new identiy'
} }
}, },
hasIdentity: { addPrivateKey: {
nodoc: 'Not present in Rust code', desc: 'Import a private key to use for asymmetric decryption.',
desc: 'Checks if the client hold the private keys for a given identity.',
params: [ params: [
{ {
type: Data, type: Data,
desc: '60 Bytes - The identity address to check' desc: '32 Bytes - The private key to import'
} }
], ],
returns: { returns: {
type: Boolean, type: Data,
desc: '`true` if the client holds the privatekey for that identity, otherwise `false`' desc: '`32 Bytes` A unique identity to refer to this keypair by.'
} }
}, },
newGroup: { newSymKey: {
nodoc: 'Not present in Rust code', desc: 'Generate a key pair(identity) for symmetric encryption.',
desc: '(?)',
params: [], params: [],
returns: { returns: {
type: Data, desc: '60 Bytes - the address of the new group. (?)' type: Data,
desc: '32 Bytes - the address of the new identiy'
} }
}, },
addToGroup: { getPublicKey: {
nodoc: 'Not present in Rust code', desc: 'Get the public key associated with an asymmetric identity.',
desc: '(?)',
params: [ params: [
{ {
type: Data, type: Data,
desc: '60 Bytes - The identity address to add to a group (?)' desc: '32 Bytes - The identity to fetch the public key for.'
} }
], ],
returns: { returns: {
type: Boolean, type: Data,
desc: '`true` if the identity was successfully added to the group, otherwise `false` (?)' desc: '`64 Bytes` - The public key of the asymmetric identity.'
} }
}, },
newFilter: { getPrivateKey: {
nodoc: 'Not present in Rust code', desc: 'Get the private key associated with an asymmetric identity.',
desc: 'Creates filter to notify, when client receives whisper message matching the filter options.', params: [
{
type: Data,
desc: '32 Bytes - The identity to fetch the private key for.'
}
],
returns: {
type: Data,
desc: '`32 Bytes` - The private key of the asymmetric identity.'
}
},
getSymKey: {
desc: 'Get the key associated with a symmetric identity.',
params: [
{
type: Data,
desc: '`32 Bytes` - The identity to fetch the key for.'
}
],
returns: {
type: Data,
desc: '`64 Bytes` - The key of the asymmetric identity.'
}
},
deleteKey: {
desc: 'Delete the key or key pair denoted by the given identity.',
params: [
{
type: Data,
desc: '`32 Bytes` - The identity to remove.'
}
],
returns: {
type: Data,
desc: '`true` on successful removal, `false` on unkown identity'
}
},
newMessageFilter: {
desc: 'Create a new polled filter for messages.',
params: [ params: [
{ {
type: Object, desc: 'The filter options:', type: Object, desc: 'The filter options:',
details: { details: {
to: { decryptWith: {
type: Data, desc: '60 Bytes - Identity of the receiver. *When present it will try to decrypt any incoming message if the client holds the private key to this identity.*', type: Data,
desc: '`32 bytes` - Identity of key used for description. null if listening for broadcasts.'
},
from: {
type: Data, desc: '`32 Bytes` - if present, only accept messages signed by this key.',
optional: true optional: true
}, },
topics: { topics: {
type: Array, desc: 'Array of `Data` topics which the incoming message\'s topics should match. You can use the following combinations' type: Array,
desc: 'Array of `Data`. Only accept messages matching these topics. Should be non-empty.'
} }
} }
} }
], ],
returns: { returns: {
type: Quantity, type: Data,
desc: 'The newly created filter' desc: '`32 bytes` - Unique identity for this filter.'
} }
}, },
uninstallFilter: { getFilterMesssages: {
nodoc: 'Not present in Rust code', nodoc: 'Not present in Rust code',
desc: 'Uninstalls a filter with given id. Should always be called when watch is no longer needed.\nAdditonally Filters timeout when they aren\'t requested with [shh_getFilterChanges](#shh_getfilterchanges) for a period of time.', desc: 'Uninstalls a filter with given id. Should always be called when watch is no longer needed.\nAdditonally Filters timeout when they aren\'t requested with [shh_getFilterChanges](#shh_getfilterchanges) for a period of time.',
params: [ params: [
@ -150,30 +209,83 @@ export default {
} }
}, },
getFilterChanges: { getFilterMessages: {
nodoc: 'Not present in Rust code',
desc: 'Polling method for whisper filters. Returns new messages since the last call of this method.\n**Note** calling the [shh_getMessages](#shh_getmessages) method, will reset the buffer for this method, so that you won\'t receive duplicate messages.', desc: 'Polling method for whisper filters. Returns new messages since the last call of this method.\n**Note** calling the [shh_getMessages](#shh_getmessages) method, will reset the buffer for this method, so that you won\'t receive duplicate messages.',
params: [ params: [
{ {
type: Quantity, type: Data,
desc: 'The filter id' desc: '`32 bytes` - Unique identity to fetch changes for.'
} }
], ],
returns: { returns: {
type: Array, type: Array,
desc: 'Array of messages received since last poll' desc: 'Array of `messages` received since last poll',
details: {
from: {
type: Data,
desc: '`64 bytes` - Public key that signed this message or null'
},
recipient: {
type: Data,
desc: '`32 bytes` - local identity which decrypted this message, or null if broadcast.'
},
ttl: {
type: Quantity,
desc: 'time to live of the message in seconds.'
},
topics: {
type: Array,
desc: 'Array of `Data` - Topics which matched the filter'
},
timestamp: {
type: Quantity,
desc: 'Unix timestamp of the message'
},
payload: {
type: Data,
desc: 'The message body'
},
padding: {
type: Data,
desc: 'Optional padding which was decoded.'
}
}
} }
}, },
getMessages: { deleteMessageFilter: {
nodoc: 'Not present in Rust code', desc: 'Delete a message filter by identifier',
desc: 'Get all messages matching a filter. Unlike `shh_getFilterChanges` this returns all messages.',
params: [ params: [
{ {
type: Quantity, type: Data,
desc: 'The filter id' desc: '`32 bytes` - The identity of the filter to delete.'
} }
], ],
returns: 'See [shh_getFilterChanges](#shh_getfilterchanges)' returns: {
type: Boolean,
desc: '`true` on deletion, `false` on unrecognized ID.'
}
},
subscribe: {
desc: 'Open a subscription to a filter.',
params: [{
type: Data,
desc: 'See [shh_newMessageFilter](#shh_newmessagefilter)'
}],
returns: {
type: Quantity,
desc: 'Unique subscription identifier'
}
},
unsubscribe: {
desc: 'Close a subscribed filter',
params: [{
type: Quantity,
desc: 'Unique subscription identifier'
}],
returns: {
type: Boolean,
desc: '`true` on success, `false` on unkown subscription ID.'
}
} }
}; };

View File

@ -22,6 +22,8 @@ export class Hash {}
export class Integer {} export class Integer {}
export class Float {}
export class Quantity {} export class Quantity {}
export class BlockNumber { export class BlockNumber {

View File

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

View File

@ -21,7 +21,7 @@ use std::fmt;
use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::{Error, Visitor}; use serde::de::{Error, Visitor};
use rustc_hex::ToHex; 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 { macro_rules! impl_hash {
@ -99,7 +99,7 @@ impl_hash!(Bloom, Hash2048);
mod test { mod test {
use std::str::FromStr; use std::str::FromStr;
use serde_json; use serde_json;
use util::hash; use bigint::hash;
use hash::H256; use hash::H256;
#[test] #[test]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,10 +60,8 @@ mod tests {
use serde_json; use serde_json;
use bytes::Bytes; use bytes::Bytes;
use uint::Uint; use uint::Uint;
use util::U256; use bigint::prelude::{U256, H160, H64 as Eth64, H256 as Eth256};
use hash::{H64, H256, Address}; use hash::{H64, H256, Address};
use util::hash::H160;
use util::{H64 as Eth64, H256 as Eth256};
use spec::genesis::Genesis; use spec::genesis::Genesis;
use spec::{Ethereum, Seal}; use spec::{Ethereum, Seal};
use std::str::FromStr; 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 state;
pub mod ethash; pub mod ethash;
pub mod validator_set; pub mod validator_set;
pub mod instant_seal;
pub mod basic_authority; pub mod basic_authority;
pub mod authority_round; pub mod authority_round;
pub mod tendermint; pub mod tendermint;
@ -41,7 +40,6 @@ pub use self::engine::Engine;
pub use self::state::State; pub use self::state::State;
pub use self::ethash::{Ethash, EthashParams}; pub use self::ethash::{Ethash, EthashParams};
pub use self::validator_set::ValidatorSet; pub use self::validator_set::ValidatorSet;
pub use self::instant_seal::{InstantSeal, InstantSealParams};
pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams}; pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams};
pub use self::authority_round::{AuthorityRound, AuthorityRoundParams}; pub use self::authority_round::{AuthorityRound, AuthorityRoundParams};
pub use self::tendermint::{Tendermint, TendermintParams}; pub use self::tendermint::{Tendermint, TendermintParams};

View File

@ -55,6 +55,9 @@ pub struct Params {
#[serde(rename="eip98Transition")] #[serde(rename="eip98Transition")]
pub eip98_transition: Option<Uint>, pub eip98_transition: Option<Uint>,
/// See `CommonParams` docs. /// See `CommonParams` docs.
#[serde(rename="eip155Transition")]
pub eip155_transition: Option<Uint>,
/// See `CommonParams` docs.
#[serde(rename="validateReceiptsTransition")] #[serde(rename="validateReceiptsTransition")]
pub validate_receipts_transition: Option<Uint>, pub validate_receipts_transition: Option<Uint>,
/// See `CommonParams` docs. /// See `CommonParams` docs.
@ -91,13 +94,21 @@ pub struct Params {
pub remove_dust_contracts : Option<bool>, pub remove_dust_contracts : Option<bool>,
/// Wasm support flag /// Wasm support flag
pub wasm: Option<bool>, 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)] #[cfg(test)]
mod tests { mod tests {
use serde_json; use serde_json;
use uint::Uint; use uint::Uint;
use util::U256; use bigint::prelude::U256;
use spec::params::Params; use spec::params::Params;
#[test] #[test]
@ -108,7 +119,8 @@ mod tests {
"chainID" : "0x15", "chainID" : "0x15",
"subprotocolName" : "exp", "subprotocolName" : "exp",
"minGasLimit": "0x1388", "minGasLimit": "0x1388",
"accountStartNonce": "0x01" "accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x20"
}"#; }"#;
let deserialized: Params = serde_json::from_str(s).unwrap(); 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.subprotocol_name, Some("exp".to_owned()));
assert_eq!(deserialized.min_gas_limit, Uint(U256::from(0x1388))); assert_eq!(deserialized.min_gas_limit, Uint(U256::from(0x1388)));
assert_eq!(deserialized.account_start_nonce, Some(Uint(U256::from(0x01)))); 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 hash::*;
use bytes::Bytes; use bytes::Bytes;
use uint::Uint; use uint::Uint;
use util::U256; use bigint::prelude::{U256, H64 as Eth64, H256 as Eth256, H520 as Eth520};
use util::{H64 as Eth64, H256 as Eth256, H520 as Eth520};
use spec::{Ethereum, AuthorityRoundSeal, TendermintSeal, Seal}; use spec::{Ethereum, AuthorityRoundSeal, TendermintSeal, Seal};
#[test] #[test]

View File

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

View File

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

View File

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

View File

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

View File

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