forked from cerc-io/plugeth
cmd/geth, miner, params: special extradata for DAO fork start
This commit is contained in:
parent
9e56811a37
commit
1e24c2e4f4
@ -75,6 +75,7 @@ var customGenesisTests = []struct {
|
|||||||
"timestamp" : "0x00",
|
"timestamp" : "0x00",
|
||||||
"config" : {
|
"config" : {
|
||||||
"homesteadBlock" : 314,
|
"homesteadBlock" : 314,
|
||||||
|
"daoForkBlock" : 141
|
||||||
},
|
},
|
||||||
}`,
|
}`,
|
||||||
query: "eth.getBlock(0).nonce",
|
query: "eth.getBlock(0).nonce",
|
||||||
|
@ -33,6 +33,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"github.com/ethereum/go-ethereum/logger/glog"
|
"github.com/ethereum/go-ethereum/logger/glog"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/pow"
|
"github.com/ethereum/go-ethereum/pow"
|
||||||
"gopkg.in/fatih/set.v0"
|
"gopkg.in/fatih/set.v0"
|
||||||
)
|
)
|
||||||
@ -468,7 +469,14 @@ func (self *worker) commitNewWork() {
|
|||||||
Extra: self.extra,
|
Extra: self.extra,
|
||||||
Time: big.NewInt(tstamp),
|
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
|
previous := self.current
|
||||||
// Could potentially happen if starting to mine in an odd state.
|
// Could potentially happen if starting to mine in an odd state.
|
||||||
err := self.makeCurrent(parent, header)
|
err := self.makeCurrent(parent, header)
|
||||||
|
@ -16,11 +16,18 @@
|
|||||||
|
|
||||||
package params
|
package params
|
||||||
|
|
||||||
import "math/big"
|
import (
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
TestNetHomesteadBlock = big.NewInt(494000) // testnet homestead block
|
TestNetHomesteadBlock = big.NewInt(494000) // Testnet homestead block
|
||||||
MainNetHomesteadBlock = big.NewInt(1150000) // mainnet 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
|
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)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user