diff --git a/consensus/misc/dao.go b/consensus/misc/dao.go index b80c1b833a..32932b9bb8 100644 --- a/consensus/misc/dao.go +++ b/consensus/misc/dao.go @@ -19,12 +19,12 @@ package misc import ( "bytes" "errors" - "math/big" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/params/forks" ) var ( @@ -46,18 +46,21 @@ var ( // with the fork specific extra-data set. // - if the node is pro-fork, require blocks in the specific range to have the // unique extra-data set. -func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error { +func VerifyDAOHeaderExtraData(config *params.Config2, header *types.Header) error { // Short circuit validation if the node doesn't care about the DAO fork - if config.DAOForkBlock == nil { + if !config.Scheduled(forks.DAO) { return nil } + // Make sure the block is within the fork's modified extra-data range - limit := new(big.Int).Add(config.DAOForkBlock, params.DAOForkExtraRange) - if header.Number.Cmp(config.DAOForkBlock) < 0 || header.Number.Cmp(limit) >= 0 { + activation, _ := config.Activation(forks.DAO) + limit := activation + uint64(params.DAOForkExtraRange) + if header.Number.Uint64() < activation || header.Number.Uint64() >= limit { return nil } + // Depending on whether we support or oppose the fork, validate the extra-data contents - if config.DAOForkSupport { + if params.Get[params.DAOForkSupport](config) { if !bytes.Equal(header.Extra, params.DAOForkBlockExtra) { return ErrBadProDAOExtra } diff --git a/params/dao.go b/params/dao.go index da3c8dfc99..b6c476fbc1 100644 --- a/params/dao.go +++ b/params/dao.go @@ -17,8 +17,6 @@ package params import ( - "math/big" - "github.com/ethereum/go-ethereum/common" ) @@ -29,7 +27,7 @@ var DAOForkBlockExtra = common.FromHex("0x64616f2d686172642d666f726b") // DAOForkExtraRange is the number of consecutive blocks from the DAO fork point // to override the extra-data in to prevent no-fork attacks. -var DAOForkExtraRange = big.NewInt(10) +var DAOForkExtraRange = uint64(10) // DAORefundContract is the address of the refund contract to send DAO balances to. var DAORefundContract = common.HexToAddress("0xbf4ed7b27f1d666546e30d74d50d173d20bca754")