From 08b2092540dec48c550f3e4eeff2fd732c0cfd39 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 18 Mar 2018 21:36:16 -0400 Subject: [PATCH] [ semi functional parity <-> geth ] --- ShyftNetwork.json | 42 +++++++++++++++++++ ...--43ec6d0942f7faef069f7f63d0384a27f529b062 | 1 + ...--9e602164c5826ebb5a6b68e4afd9cd466043dc4a | 1 + ...--5bd738164c61fb50eb12e227846cbaef2de965aa | 1 + ...--c04ee4131895f1d0c294d508af65d94060aa42bb | 1 + ...--07d899c4ac0c1725c35c5f816e60273b33a964f7 | 1 + consensus/ethash/consensus.go | 11 +++++ geth.json | 32 ++++++++++++++ params/config.go | 36 ++++++++++++++-- 9 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 ShyftNetwork.json create mode 100644 UTC--2018-03-18T22-35-03.111589431Z--43ec6d0942f7faef069f7f63d0384a27f529b062 create mode 100644 UTC--2018-03-18T22-36-53.786508893Z--9e602164c5826ebb5a6b68e4afd9cd466043dc4a create mode 100644 UTC--2018-03-18T22-37-04.212101982Z--5bd738164c61fb50eb12e227846cbaef2de965aa create mode 100644 UTC--2018-03-18T22-37-12.082606217Z--c04ee4131895f1d0c294d508af65d94060aa42bb create mode 100644 UTC--2018-03-18T22-37-19.650676366Z--07d899c4ac0c1725c35c5f816e60273b33a964f7 create mode 100644 geth.json diff --git a/ShyftNetwork.json b/ShyftNetwork.json new file mode 100644 index 0000000000..9026cd1d6b --- /dev/null +++ b/ShyftNetwork.json @@ -0,0 +1,42 @@ +{ + "config": { + "chainId": 2147483647, + "homesteadBlock": 1, + "eip150Block": 2, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 3, + "eip158Block": 3, + "eip160Block": 5, + "byzantiumBlock": 4, + "shyftNetworkBlock": 1, + "ethash": {} + }, + "nonce": "0x0000000000000042", + "timestamp": "0x5aaef881", + "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x16E6387", + "minGasLimit": "0x16E6387", + "difficulty": "0x000100000", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "07d899c4ac0c1725c35c5f816e60273b33a964f7": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "43ec6d0942f7faef069f7f63d0384a27f529b062": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "5bd738164c61fb50eb12e227846cbaef2de965aa": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "9e602164c5826ebb5a6b68e4afd9cd466043dc4a": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "c04ee4131895f1d0c294d508af65d94060aa42bb": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/UTC--2018-03-18T22-35-03.111589431Z--43ec6d0942f7faef069f7f63d0384a27f529b062 b/UTC--2018-03-18T22-35-03.111589431Z--43ec6d0942f7faef069f7f63d0384a27f529b062 new file mode 100644 index 0000000000..d76fc3f849 --- /dev/null +++ b/UTC--2018-03-18T22-35-03.111589431Z--43ec6d0942f7faef069f7f63d0384a27f529b062 @@ -0,0 +1 @@ +{"address":"43ec6d0942f7faef069f7f63d0384a27f529b062","crypto":{"cipher":"aes-128-ctr","ciphertext":"bb5b6a70c7f36ff5f18326120ae6fe5250a2997fdb286fe43b2c62baf2c71119","cipherparams":{"iv":"07148d733ca5c7b4c619b5a80ecb73c6"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"fb1c0cd412f6a2288a27b3c0833b94e912e704a49d55536b8ed036c660bb56df"},"mac":"d2568c026e76ad619c0dd8fea6f9f7beddf62b40bd3041665e33aebdef839991"},"id":"c754e63f-740a-4f24-9a7a-ccca4cb3ac4d","version":3} \ No newline at end of file diff --git a/UTC--2018-03-18T22-36-53.786508893Z--9e602164c5826ebb5a6b68e4afd9cd466043dc4a b/UTC--2018-03-18T22-36-53.786508893Z--9e602164c5826ebb5a6b68e4afd9cd466043dc4a new file mode 100644 index 0000000000..d96a1fca25 --- /dev/null +++ b/UTC--2018-03-18T22-36-53.786508893Z--9e602164c5826ebb5a6b68e4afd9cd466043dc4a @@ -0,0 +1 @@ +{"address":"9e602164c5826ebb5a6b68e4afd9cd466043dc4a","crypto":{"cipher":"aes-128-ctr","ciphertext":"1d1ff3647765a4455cd86476e3cc9e6a79b5e014a684320fb251a8748f84bf60","cipherparams":{"iv":"991055e24ee6ebec0bb76d704720bc8b"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"097917057607c3b30ada21d39ca7e8d55c458f5a97d40c419823565f986e7c1f"},"mac":"44475022fa0a7cc2cefdb3a51ae0f6a472ed9e5411dc516e6f383492a864e5e6"},"id":"36b81612-c7c8-4a2c-a4d5-2d0679ed0e46","version":3} \ No newline at end of file diff --git a/UTC--2018-03-18T22-37-04.212101982Z--5bd738164c61fb50eb12e227846cbaef2de965aa b/UTC--2018-03-18T22-37-04.212101982Z--5bd738164c61fb50eb12e227846cbaef2de965aa new file mode 100644 index 0000000000..40bc6ee932 --- /dev/null +++ b/UTC--2018-03-18T22-37-04.212101982Z--5bd738164c61fb50eb12e227846cbaef2de965aa @@ -0,0 +1 @@ +{"address":"5bd738164c61fb50eb12e227846cbaef2de965aa","crypto":{"cipher":"aes-128-ctr","ciphertext":"5bfc3b2dc3a7d3bd5665a1c2490f70ee6705f3e0894a5ca468d52b026f1dca7f","cipherparams":{"iv":"6ce967c93c322b4b5f058e76177584f8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"d03a61e5720ef755411b7f63914a1b0fa222d0d3067929ae952fcce42b5e5542"},"mac":"ec1cd523234ac68ac0b9b7904f60f28a2a4c5ad85d65ac53671b705039554ce6"},"id":"d5e14b35-6af9-42a0-b34a-64feb070f6dd","version":3} \ No newline at end of file diff --git a/UTC--2018-03-18T22-37-12.082606217Z--c04ee4131895f1d0c294d508af65d94060aa42bb b/UTC--2018-03-18T22-37-12.082606217Z--c04ee4131895f1d0c294d508af65d94060aa42bb new file mode 100644 index 0000000000..734186afe7 --- /dev/null +++ b/UTC--2018-03-18T22-37-12.082606217Z--c04ee4131895f1d0c294d508af65d94060aa42bb @@ -0,0 +1 @@ +{"address":"c04ee4131895f1d0c294d508af65d94060aa42bb","crypto":{"cipher":"aes-128-ctr","ciphertext":"d16207bbd6d14d7262defe603da31bf8bbaf8cfa061eab473c1d429ce080fa14","cipherparams":{"iv":"5876ca41d684df5a63b0012dd5ea6ee2"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"93fc0647d958d36be99b71b22b0a33256173331d51ddab96e43912461b8c07da"},"mac":"1754344c1155675d3fef9826d39146d9874f6d44471551443ee61a3ca15d6212"},"id":"5623955c-2f64-4b31-860e-305b9994f37f","version":3} \ No newline at end of file diff --git a/UTC--2018-03-18T22-37-19.650676366Z--07d899c4ac0c1725c35c5f816e60273b33a964f7 b/UTC--2018-03-18T22-37-19.650676366Z--07d899c4ac0c1725c35c5f816e60273b33a964f7 new file mode 100644 index 0000000000..7aae392bad --- /dev/null +++ b/UTC--2018-03-18T22-37-19.650676366Z--07d899c4ac0c1725c35c5f816e60273b33a964f7 @@ -0,0 +1 @@ +{"address":"07d899c4ac0c1725c35c5f816e60273b33a964f7","crypto":{"cipher":"aes-128-ctr","ciphertext":"a794e869d1d58f7e8beffb9a4662f452067c5c8d4621d1d2f00cd86e8e210ec2","cipherparams":{"iv":"2bf52331af63a25f38ff4c46e9272317"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"8b6d187e42e43d542256ba19321e70ffdaae4bf71754f2ed6a0f4f1007ca6b92"},"mac":"fbe0af1c2e7a42d19b6a436c943596204a5e95372cc444cbb751111a0b386d72"},"id":"11e0fea9-e0e6-48d1-906a-7006050426b2","version":3} \ No newline at end of file diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 99eec82211..6ffe8740f5 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -40,6 +40,10 @@ var ( ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium maxUncles = 2 // Maximum number of uncles allowed in a single block allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks + //@note: @shyft + ShyftNetworkBlockReward *big.Int = big.NewInt(2.5e+18) // Block reward in wei for successfully mining a block, for the Shyft Network + ShyftMinerBlockReward *big.Int = big.NewInt(2.5e+18) // Block reward in wei for successfully mining a block, for the Shyft Network + ShyftNetworkConduitAddress = common.HexToAddress("9db76b4bbaea76dfda4552b7b9d4e9d43abc55fd") ) // Various error messages to mark blocks invalid. These should be private to @@ -537,6 +541,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header if config.IsByzantium(header.Number) { blockReward = ByzantiumBlockReward } + if (config.IsShyftNetwork(header.Number)) { + blockReward = ShyftMinerBlockReward + } // Accumulate the rewards for the miner and any included uncles reward := new(big.Int).Set(blockReward) r := new(big.Int) @@ -551,4 +558,8 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header reward.Add(reward, r) } state.AddBalance(header.Coinbase, reward) + + if (config.IsShyftNetwork(header.Number)) { + state.AddBalance(ShyftNetworkConduitAddress, ShyftNetworkBlockReward) + } } diff --git a/geth.json b/geth.json new file mode 100644 index 0000000000..fa26f786b2 --- /dev/null +++ b/geth.json @@ -0,0 +1,32 @@ +{ + "config": { + "chainId": 1337, + "homesteadBlock":0, + "eip150Block":0, + "eip155Block":10, + "eip158Block":10, + "eip160Block":10 + }, + "nonce": "0x0000000000000042", + "alloc": { + "0x0000000000000000000000000000000000000001": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000002": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000003": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000004": { + "balance": "1" + } + }, + "timestamp": "0x00", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "extraData": "0x3535353535353535353535353535353535353535353535353535353535353535", + "gasLimit": "0x1000000", + "difficulty": "0x10000", + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000" +} diff --git a/params/config.go b/params/config.go index dc02c7ca37..2599d8c4e7 100644 --- a/params/config.go +++ b/params/config.go @@ -41,6 +41,7 @@ var ( EIP158Block: big.NewInt(2675000), ByzantiumBlock: big.NewInt(4370000), ConstantinopleBlock: nil, + ShyftNetworkBlock: nil, Ethash: new(EthashConfig), } @@ -56,6 +57,7 @@ var ( EIP158Block: big.NewInt(10), ByzantiumBlock: big.NewInt(1700000), ConstantinopleBlock: nil, + ShyftNetworkBlock: nil, Ethash: new(EthashConfig), } @@ -71,27 +73,43 @@ var ( EIP158Block: big.NewInt(3), ByzantiumBlock: big.NewInt(1035301), ConstantinopleBlock: nil, + ShyftNetworkBlock: nil, Clique: &CliqueConfig{ Period: 15, Epoch: 30000, }, } + // ShyftNetworkChainConfig contains the chain parameters to run a node on the Rinkeby test network. + ShyftNetworkChainConfig = &ChainConfig{ + ChainId: big.NewInt(2147483647), + HomesteadBlock: big.NewInt(1), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(2), + EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"), + EIP155Block: big.NewInt(3), + EIP158Block: big.NewInt(3), + ByzantiumBlock: big.NewInt(1035301), + ConstantinopleBlock: nil, + ShyftNetworkBlock: big.NewInt(1), + Ethash: new(EthashConfig), + } // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil} + AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, new(EthashConfig), nil} // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. - AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} + AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}} - TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil} + TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, new(EthashConfig), nil} TestRules = TestChainConfig.Rules(new(big.Int)) ) @@ -117,6 +135,7 @@ type ChainConfig struct { ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium) ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated) + ShyftNetworkBlock *big.Int `json:"shyftNetworkBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated) // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` @@ -163,6 +182,7 @@ func (c *ChainConfig) String() string { c.EIP158Block, c.ByzantiumBlock, c.ConstantinopleBlock, + c.ShyftNetworkBlock, engine, ) } @@ -197,6 +217,10 @@ func (c *ChainConfig) IsConstantinople(num *big.Int) bool { return isForked(c.ConstantinopleBlock, num) } +func (c *ChainConfig) IsShyftNetwork(num *big.Int) bool { + return isForked(c.ShyftNetworkBlock, num) +} + // GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice). // // The returned GasTable's fields shouldn't, under any circumstances, be changed. @@ -260,6 +284,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi if isForkIncompatible(c.ConstantinopleBlock, newcfg.ConstantinopleBlock, head) { return newCompatError("Constantinople fork block", c.ConstantinopleBlock, newcfg.ConstantinopleBlock) } + if isForkIncompatible(c.ShyftNetworkBlock, newcfg.ShyftNetworkBlock, head) { + return newCompatError("ShyftNetwork fork block", c.ShyftNetworkBlock, newcfg.ShyftNetworkBlock) + } return nil } @@ -327,6 +354,7 @@ type Rules struct { ChainId *big.Int IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsByzantium bool + IsShyftNetwork bool } func (c *ChainConfig) Rules(num *big.Int) Rules { @@ -334,5 +362,5 @@ func (c *ChainConfig) Rules(num *big.Int) Rules { if chainId == nil { chainId = new(big.Int) } - return Rules{ChainId: new(big.Int).Set(chainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num)} + return Rules{ChainId: new(big.Int).Set(chainId), IsHomestead: c.IsHomestead(num), IsEIP150: c.IsEIP150(num), IsEIP155: c.IsEIP155(num), IsEIP158: c.IsEIP158(num), IsByzantium: c.IsByzantium(num), IsShyftNetwork: c.IsShyftNetwork(num)} }