File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ var customGenesisTests = []struct {
75
75
"timestamp" : "0x00",
76
76
"config" : {
77
77
"homesteadBlock" : 314,
78
+ "daoForkBlock" : 141
78
79
},
79
80
}` ,
80
81
query : "eth.getBlock(0).nonce" ,
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import (
33
33
"github.com/ethereum/go-ethereum/event"
34
34
"github.com/ethereum/go-ethereum/logger"
35
35
"github.com/ethereum/go-ethereum/logger/glog"
36
+ "github.com/ethereum/go-ethereum/params"
36
37
"github.com/ethereum/go-ethereum/pow"
37
38
"gopkg.in/fatih/set.v0"
38
39
)
@@ -468,7 +469,14 @@ func (self *worker) commitNewWork() {
468
469
Extra : self .extra ,
469
470
Time : big .NewInt (tstamp ),
470
471
}
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
+ }
472
480
previous := self .current
473
481
// Could potentially happen if starting to mine in an odd state.
474
482
err := self .makeCurrent (parent , header )
Original file line number Diff line number Diff line change 16
16
17
17
package params
18
18
19
- import "math/big"
19
+ import (
20
+ "math/big"
21
+
22
+ "github.com/ethereum/go-ethereum/common"
23
+ )
20
24
21
25
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)
26
33
)
You can’t perform that action at this time.
0 commit comments