diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-07-08 18:00:37 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-07-15 21:52:55 +0800 |
commit | 1e24c2e4f428c85c2f83272af2696469cb8f5bed (patch) | |
tree | 8939d4ddee2b093f01ed656b1603c8d3efc76706 | |
parent | 9e56811a3773e225bedf6bf0003327ea1aaae040 (diff) | |
download | dexon-1e24c2e4f428c85c2f83272af2696469cb8f5bed.tar.gz dexon-1e24c2e4f428c85c2f83272af2696469cb8f5bed.tar.zst dexon-1e24c2e4f428c85c2f83272af2696469cb8f5bed.zip |
cmd/geth, miner, params: special extradata for DAO fork start
-rw-r--r-- | cmd/geth/genesis_test.go | 1 | ||||
-rw-r--r-- | miner/worker.go | 10 | ||||
-rw-r--r-- | params/util.go | 17 |
3 files changed, 22 insertions, 6 deletions
diff --git a/cmd/geth/genesis_test.go b/cmd/geth/genesis_test.go index 7485d7d89..43d678d89 100644 --- a/cmd/geth/genesis_test.go +++ b/cmd/geth/genesis_test.go @@ -75,6 +75,7 @@ var customGenesisTests = []struct { "timestamp" : "0x00", "config" : { "homesteadBlock" : 314, + "daoForkBlock" : 141 }, }`, query: "eth.getBlock(0).nonce", diff --git a/miner/worker.go b/miner/worker.go index 09cf6b6aa..7197a33ba 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -33,6 +33,7 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" "gopkg.in/fatih/set.v0" ) @@ -468,7 +469,14 @@ func (self *worker) commitNewWork() { Extra: self.extra, Time: big.NewInt(tstamp), } - + // If we are doing a DAO hard-fork check whether to override the extra-data or not + if daoBlock := self.config.DAOForkBlock; daoBlock != nil { + // Check whether the block is among the fork extra-override range + limit := new(big.Int).Add(daoBlock, params.DAOForkExtraRange) + if daoBlock.Cmp(header.Number) <= 0 && header.Number.Cmp(limit) < 0 { + header.Extra = common.CopyBytes(params.DAOForkBlockExtra) + } + } previous := self.current // Could potentially happen if starting to mine in an odd state. err := self.makeCurrent(parent, header) diff --git a/params/util.go b/params/util.go index b76850852..a0c9a3199 100644 --- a/params/util.go +++ b/params/util.go @@ -16,11 +16,18 @@ package params -import "math/big" +import ( + "math/big" + + "github.com/ethereum/go-ethereum/common" +) var ( - TestNetHomesteadBlock = big.NewInt(494000) // testnet homestead block - MainNetHomesteadBlock = big.NewInt(1150000) // mainnet homestead block - TestNetDAOForkBlock = big.NewInt(8888888) // testnet dao hard-fork block - MainNetDAOForkBlock = big.NewInt(9999999) // mainnet dao hard-fork block + TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block + MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block + + TestNetDAOForkBlock = big.NewInt(8888888) // Testnet dao hard-fork block + MainNetDAOForkBlock = big.NewInt(9999999) // Mainnet dao hard-fork block + DAOForkBlockExtra = common.FromHex("0x64616f2d686172642d666f726b") // Block extradata to signel the fork with ("dao-hard-fork") + DAOForkExtraRange = big.NewInt(10) // Number of blocks to override the extradata (prevent no-fork attacks) ) |