Skip to content

Commit 682c453

Browse files
committed
[release/1.4.10] cmd/geth, miner, params: special extradata for DAO fork start
(cherry picked from commit 1e24c2e)
1 parent 5c3051e commit 682c453

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

cmd/geth/genesis_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ var customGenesisTests = []struct {
7575
"timestamp" : "0x00",
7676
"config" : {
7777
"homesteadBlock" : 314,
78+
"daoForkBlock" : 141
7879
},
7980
}`,
8081
query: "eth.getBlock(0).nonce",

miner/worker.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/ethereum/go-ethereum/event"
3434
"github.com/ethereum/go-ethereum/logger"
3535
"github.com/ethereum/go-ethereum/logger/glog"
36+
"github.com/ethereum/go-ethereum/params"
3637
"github.com/ethereum/go-ethereum/pow"
3738
"gopkg.in/fatih/set.v0"
3839
)
@@ -468,7 +469,14 @@ func (self *worker) commitNewWork() {
468469
Extra: self.extra,
469470
Time: big.NewInt(tstamp),
470471
}
471-
472+
// If we are doing a DAO hard-fork check whether to override the extra-data or not
473+
if daoBlock := self.config.DAOForkBlock; daoBlock != nil {
474+
// Check whether the block is among the fork extra-override range
475+
limit := new(big.Int).Add(daoBlock, params.DAOForkExtraRange)
476+
if daoBlock.Cmp(header.Number) <= 0 && header.Number.Cmp(limit) < 0 {
477+
header.Extra = common.CopyBytes(params.DAOForkBlockExtra)
478+
}
479+
}
472480
previous := self.current
473481
// Could potentially happen if starting to mine in an odd state.
474482
err := self.makeCurrent(parent, header)

params/util.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616

1717
package params
1818

19-
import "math/big"
19+
import (
20+
"math/big"
21+
22+
"github.com/ethereum/go-ethereum/common"
23+
)
2024

2125
var (
22-
TestNetHomesteadBlock = big.NewInt(494000) // testnet homestead block
23-
MainNetHomesteadBlock = big.NewInt(1150000) // mainnet homestead block
24-
TestNetDAOForkBlock = big.NewInt(8888888) // testnet dao hard-fork block
25-
MainNetDAOForkBlock = big.NewInt(9999999) // mainnet dao hard-fork block
26+
TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block
27+
MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block
28+
29+
TestNetDAOForkBlock = big.NewInt(8888888) // Testnet dao hard-fork block
30+
MainNetDAOForkBlock = big.NewInt(9999999) // Mainnet dao hard-fork block
31+
DAOForkBlockExtra = common.FromHex("0x64616f2d686172642d666f726b") // Block extradata to signel the fork with ("dao-hard-fork")
32+
DAOForkExtraRange = big.NewInt(10) // Number of blocks to override the extradata (prevent no-fork attacks)
2633
)

0 commit comments

Comments
 (0)