Remove all references to the DAO hard fork

This commit is contained in:
Julian Yap 2016-12-02 22:13:40 -10:00
parent 0623c74136
commit c0ef263663
22 changed files with 19 additions and 10101 deletions

File diff suppressed because one or more lines are too long

View file

@ -74,12 +74,12 @@ func runTestWithReader(test string, r io.Reader) error {
var err error
switch strings.ToLower(test) {
case "bk", "block", "blocktest", "blockchaintest", "blocktests", "blockchaintests":
err = tests.RunBlockTestWithReader(params.MainNetHomesteadBlock, params.MainNetDAOForkBlock, params.MainNetHomesteadGasRepriceBlock, r, skipTests)
err = tests.RunBlockTestWithReader(params.MainNetHomesteadBlock, params.MainNetHomesteadGasRepriceBlock, r, skipTests)
case "st", "state", "statetest", "statetests":
rs := &params.ChainConfig{HomesteadBlock: params.MainNetHomesteadBlock, DAOForkBlock: params.MainNetDAOForkBlock, DAOForkSupport: true, EIP150Block: params.MainNetHomesteadGasRepriceBlock}
rs := &params.ChainConfig{HomesteadBlock: params.MainNetHomesteadBlock, EIP150Block: params.MainNetHomesteadGasRepriceBlock}
err = tests.RunStateTestWithReader(rs, r, skipTests)
case "tx", "transactiontest", "transactiontests":
rs := &params.ChainConfig{HomesteadBlock: params.MainNetHomesteadBlock, DAOForkBlock: params.MainNetDAOForkBlock, DAOForkSupport: true, EIP150Block: params.MainNetHomesteadGasRepriceBlock}
rs := &params.ChainConfig{HomesteadBlock: params.MainNetHomesteadBlock, EIP150Block: params.MainNetHomesteadGasRepriceBlock}
err = tests.RunTransactionTestsWithReader(rs, r, skipTests)
case "vm", "vmtest", "vmtests":
err = tests.RunVmTestWithReader(r, skipTests)

View file

@ -74,9 +74,7 @@ var customGenesisTests = []struct {
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"config" : {
"homesteadBlock" : 314,
"daoForkBlock" : 141,
"daoForkSupport" : true
"homesteadBlock" : 314
},
}`,
query: "eth.getBlock(0).nonce",

View file

@ -878,9 +878,6 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
} else {
// Homestead fork
config.HomesteadBlock = params.MainNetHomesteadBlock
// DAO fork
config.DAOForkBlock = params.MainNetDAOForkBlock
config.DAOForkSupport = true
// DoS reprice fork
config.EIP150Block = params.MainNetHomesteadGasRepriceBlock

View file

@ -247,10 +247,6 @@ func ValidateHeader(config *params.ChainConfig, pow pow.PoW, header *types.Heade
return &BlockNonceErr{header.Number, header.Hash(), header.Nonce.Uint64()}
}
}
// If all checks passed, validate the extra-data field for hard forks
if err := ValidateDAOHeaderExtraData(config, header); err != nil {
return err
}
if !uncle && config.EIP150Block != nil && config.EIP150Block.Cmp(header.Number) == 0 {
if config.EIP150Hash != (common.Hash{}) && config.EIP150Hash != header.Hash() {
return ValidationError("Homestead gas reprice fork hash mismatch: have 0x%x, want 0x%x", header.Hash(), config.EIP150Hash)

View file

@ -38,8 +38,6 @@ import (
func MakeChainConfig() *params.ChainConfig {
return &params.ChainConfig{
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
}
}
@ -189,17 +187,6 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, db ethdb.Dat
if config == nil {
config = MakeChainConfig()
}
if daoBlock := config.DAOForkBlock; daoBlock != nil {
limit := new(big.Int).Add(daoBlock, params.DAOForkExtraRange)
if h.Number.Cmp(daoBlock) >= 0 && h.Number.Cmp(limit) < 0 {
if config.DAOForkSupport {
h.Extra = common.CopyBytes(params.DAOForkBlockExtra)
}
}
}
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(h.Number) == 0 {
ApplyDAOHardFork(statedb)
}
// Execute any user modifications to the block and finalize it
if gen != nil {
gen(i, b)

View file

@ -1,74 +0,0 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package core
import (
"bytes"
"math/big"
"github.com/ubiq/go-ubiq/core/state"
"github.com/ubiq/go-ubiq/core/types"
"github.com/ubiq/go-ubiq/params"
)
// ValidateDAOHeaderExtraData validates the extra-data field of a block header to
// ensure it conforms to DAO hard-fork rules.
//
// DAO hard-fork extension to the header validity:
// a) if the node is no-fork, do not accept blocks in the [fork, fork+10) range
// with the fork specific extra-data set
// b) if the node is pro-fork, require blocks in the specific range to have the
// unique extra-data set.
func ValidateDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error {
// Short circuit validation if the node doesn't care about the DAO fork
if config.DAOForkBlock == nil {
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 {
return nil
}
// Depending whether we support or oppose the fork, validate the extra-data contents
if config.DAOForkSupport {
if bytes.Compare(header.Extra, params.DAOForkBlockExtra) != 0 {
return ValidationError("DAO pro-fork bad block extra-data: 0x%x", header.Extra)
}
} else {
if bytes.Compare(header.Extra, params.DAOForkBlockExtra) == 0 {
return ValidationError("DAO no-fork bad block extra-data: 0x%x", header.Extra)
}
}
// All ok, header has the same extra-data we expect
return nil
}
// ApplyDAOHardFork modifies the state database according to the DAO hard-fork
// rules, transferring all balances of a set of DAO accounts to a single refund
// contract.
func ApplyDAOHardFork(statedb *state.StateDB) {
// Retrieve the contract to refund balances into
refund := statedb.GetOrNewStateObject(params.DAORefundContract)
// Move every DAO account and extra-balance account funds into the refund contract
for _, addr := range params.DAODrainList {
if account := statedb.GetStateObject(addr); account != nil {
refund.AddBalance(account.Balance())
account.SetBalance(new(big.Int))
}
}
}

View file

@ -1,132 +0,0 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package core
import (
"math/big"
"testing"
"github.com/ubiq/go-ubiq/ethdb"
"github.com/ubiq/go-ubiq/event"
"github.com/ubiq/go-ubiq/params"
)
// Tests that DAO-fork enabled clients can properly filter out fork-commencing
// blocks based on their extradata fields.
func TestDAOForkRangeExtradata(t *testing.T) {
forkBlock := big.NewInt(32)
// Generate a common prefix for both pro-forkers and non-forkers
db, _ := ethdb.NewMemDatabase()
genesis := WriteGenesisBlockForTesting(db)
prefix, _ := GenerateChain(params.TestChainConfig, genesis, db, int(forkBlock.Int64()-1), func(i int, gen *BlockGen) {})
// Create the concurrent, conflicting two nodes
proDb, _ := ethdb.NewMemDatabase()
WriteGenesisBlockForTesting(proDb)
proConf := &params.ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: true}
proBc, _ := NewBlockChain(proDb, proConf, new(FakePow), new(event.TypeMux))
conDb, _ := ethdb.NewMemDatabase()
WriteGenesisBlockForTesting(conDb)
conConf := &params.ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: false}
conBc, _ := NewBlockChain(conDb, conConf, new(FakePow), new(event.TypeMux))
if _, err := proBc.InsertChain(prefix); err != nil {
t.Fatalf("pro-fork: failed to import chain prefix: %v", err)
}
if _, err := conBc.InsertChain(prefix); err != nil {
t.Fatalf("con-fork: failed to import chain prefix: %v", err)
}
// Try to expand both pro-fork and non-fork chains iteratively with other camp's blocks
for i := int64(0); i < params.DAOForkExtraRange.Int64(); i++ {
// Create a pro-fork block, and try to feed into the no-fork chain
db, _ = ethdb.NewMemDatabase()
WriteGenesisBlockForTesting(db)
bc, _ := NewBlockChain(db, conConf, new(FakePow), new(event.TypeMux))
blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().NumberU64()+1))
for j := 0; j < len(blocks)/2; j++ {
blocks[j], blocks[len(blocks)-1-j] = blocks[len(blocks)-1-j], blocks[j]
}
if _, err := bc.InsertChain(blocks); err != nil {
t.Fatalf("failed to import contra-fork chain for expansion: %v", err)
}
blocks, _ = GenerateChain(proConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
if _, err := conBc.InsertChain(blocks); err == nil {
t.Fatalf("contra-fork chain accepted pro-fork block: %v", blocks[0])
}
// Create a proper no-fork block for the contra-forker
blocks, _ = GenerateChain(conConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
if _, err := conBc.InsertChain(blocks); err != nil {
t.Fatalf("contra-fork chain didn't accepted no-fork block: %v", err)
}
// Create a no-fork block, and try to feed into the pro-fork chain
db, _ = ethdb.NewMemDatabase()
WriteGenesisBlockForTesting(db)
bc, _ = NewBlockChain(db, proConf, new(FakePow), new(event.TypeMux))
blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().NumberU64()+1))
for j := 0; j < len(blocks)/2; j++ {
blocks[j], blocks[len(blocks)-1-j] = blocks[len(blocks)-1-j], blocks[j]
}
if _, err := bc.InsertChain(blocks); err != nil {
t.Fatalf("failed to import pro-fork chain for expansion: %v", err)
}
blocks, _ = GenerateChain(conConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
if _, err := proBc.InsertChain(blocks); err == nil {
t.Fatalf("pro-fork chain accepted contra-fork block: %v", blocks[0])
}
// Create a proper pro-fork block for the pro-forker
blocks, _ = GenerateChain(proConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
if _, err := proBc.InsertChain(blocks); err != nil {
t.Fatalf("pro-fork chain didn't accepted pro-fork block: %v", err)
}
}
// Verify that contra-forkers accept pro-fork extra-datas after forking finishes
db, _ = ethdb.NewMemDatabase()
WriteGenesisBlockForTesting(db)
bc, _ := NewBlockChain(db, conConf, new(FakePow), new(event.TypeMux))
blocks := conBc.GetBlocksFromHash(conBc.CurrentBlock().Hash(), int(conBc.CurrentBlock().NumberU64()+1))
for j := 0; j < len(blocks)/2; j++ {
blocks[j], blocks[len(blocks)-1-j] = blocks[len(blocks)-1-j], blocks[j]
}
if _, err := bc.InsertChain(blocks); err != nil {
t.Fatalf("failed to import contra-fork chain for expansion: %v", err)
}
blocks, _ = GenerateChain(proConf, conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
if _, err := conBc.InsertChain(blocks); err != nil {
t.Fatalf("contra-fork chain didn't accept pro-fork block post-fork: %v", err)
}
// Verify that pro-forkers accept contra-fork extra-datas after forking finishes
db, _ = ethdb.NewMemDatabase()
WriteGenesisBlockForTesting(db)
bc, _ = NewBlockChain(db, proConf, new(FakePow), new(event.TypeMux))
blocks = proBc.GetBlocksFromHash(proBc.CurrentBlock().Hash(), int(proBc.CurrentBlock().NumberU64()+1))
for j := 0; j < len(blocks)/2; j++ {
blocks[j], blocks[len(blocks)-1-j] = blocks[len(blocks)-1-j], blocks[j]
}
if _, err := bc.InsertChain(blocks); err != nil {
t.Fatalf("failed to import pro-fork chain for expansion: %v", err)
}
blocks, _ = GenerateChain(conConf, proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) {})
if _, err := proBc.InsertChain(blocks); err != nil {
t.Fatalf("pro-fork chain didn't accept contra-fork block post-fork: %v", err)
}
}

View file

@ -66,10 +66,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
allLogs vm.Logs
gp = new(GasPool).AddGas(block.GasLimit())
)
// Mutate the the block and state according to any hard-fork specs
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
ApplyDAOHardFork(statedb)
}
// Iterate over and process the individual transactions
for i, tx := range block.Transactions() {
//fmt.Println("tx:", i)

View file

@ -60,8 +60,6 @@ func setDefaults(cfg *Config) {
cfg.ChainConfig = &params.ChainConfig{
ChainId: big.NewInt(1),
HomesteadBlock: new(big.Int),
DAOForkBlock: new(big.Int),
DAOForkSupport: false,
EIP150Block: new(big.Int),
EIP155Block: new(big.Int),
EIP158Block: new(big.Int),

View file

@ -47,10 +47,6 @@ const (
estHeaderRlpSize = 500 // Approximate size of an RLP encoded block header
)
var (
daoChallengeTimeout = 15 * time.Second // Time allowance for a node to reply to the DAO handshake challenge
)
// errIncompatibleConfig is returned if the requested protocols and configs are
// not compatible (low protocol version restrictions and high requirements).
var errIncompatibleConfig = errors.New("incompatible configuration")
@ -287,25 +283,6 @@ func (pm *ProtocolManager) handle(p *peer) error {
// after this will be sent via broadcasts.
pm.syncTransactions(p)
// If we're DAO hard-fork aware, validate any remote peer with regard to the hard-fork
if daoBlock := pm.chainconfig.DAOForkBlock; daoBlock != nil {
// Request the peer's DAO fork header for extra-data validation
if err := p.RequestHeadersByNumber(daoBlock.Uint64(), 1, 0, false); err != nil {
return err
}
// Start a timer to disconnect if the peer doesn't reply in time
p.forkDrop = time.AfterFunc(daoChallengeTimeout, func() {
glog.V(logger.Debug).Infof("%v: timed out DAO fork-check, dropping", p)
pm.removePeer(p.id)
})
// Make sure it's cleaned up if the peer dies off
defer func() {
if p.forkDrop != nil {
p.forkDrop.Stop()
p.forkDrop = nil
}
}()
}
// main loop. handle incoming messages.
for {
if err := pm.handleMsg(p); err != nil {
@ -419,46 +396,8 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
if err := msg.Decode(&headers); err != nil {
return errResp(ErrDecode, "msg %v: %v", msg, err)
}
// If no headers were received, but we're expending a DAO fork check, maybe it's that
if len(headers) == 0 && p.forkDrop != nil {
// Possibly an empty reply to the fork header checks, sanity check TDs
verifyDAO := true
// If we already have a DAO header, we can check the peer's TD against it. If
// the peer's ahead of this, it too must have a reply to the DAO check
if daoHeader := pm.blockchain.GetHeaderByNumber(pm.chainconfig.DAOForkBlock.Uint64()); daoHeader != nil {
if _, td := p.Head(); td.Cmp(pm.blockchain.GetTd(daoHeader.Hash(), daoHeader.Number.Uint64())) >= 0 {
verifyDAO = false
}
}
// If we're seemingly on the same chain, disable the drop timer
if verifyDAO {
glog.V(logger.Debug).Infof("%v: seems to be on the same side of the DAO fork", p)
p.forkDrop.Stop()
p.forkDrop = nil
return nil
}
}
// Filter out any explicitly requested headers, deliver the rest to the downloader
filter := len(headers) == 1
if filter {
// If it's a potential DAO fork check, validate against the rules
if p.forkDrop != nil && pm.chainconfig.DAOForkBlock.Cmp(headers[0].Number) == 0 {
// Disable the fork drop timer
p.forkDrop.Stop()
p.forkDrop = nil
// Validate the header and either drop the peer or continue
if err := core.ValidateDAOHeaderExtraData(pm.chainconfig, headers[0]); err != nil {
glog.V(logger.Debug).Infof("%v: verified to be on the other side of the DAO fork, dropping", p)
return err
}
glog.V(logger.Debug).Infof("%v: verified to be on the same side of the DAO fork", p)
return nil
}
// Irrelevant of the fork checks, send the header to the fetcher just in case
headers = pm.fetcher.FilterHeaders(headers, time.Now())
}
if len(headers) > 0 || !filter {
err := pm.downloader.DeliverHeaders(p.id, headers)
if err != nil {

View file

@ -446,74 +446,3 @@ func testGetReceipt(t *testing.T, protocol int) {
}
}
// Tests that post eth protocol handshake, DAO fork-enabled clients also execute
// a DAO "challenge" verifying each others' DAO fork headers to ensure they're on
// compatible chains.
func TestDAOChallengeNoVsNo(t *testing.T) { testDAOChallenge(t, false, false, false) }
func TestDAOChallengeNoVsPro(t *testing.T) { testDAOChallenge(t, false, true, false) }
func TestDAOChallengeProVsNo(t *testing.T) { testDAOChallenge(t, true, false, false) }
func TestDAOChallengeProVsPro(t *testing.T) { testDAOChallenge(t, true, true, false) }
func TestDAOChallengeNoVsTimeout(t *testing.T) { testDAOChallenge(t, false, false, true) }
func TestDAOChallengeProVsTimeout(t *testing.T) { testDAOChallenge(t, true, true, true) }
func testDAOChallenge(t *testing.T, localForked, remoteForked bool, timeout bool) {
// Reduce the DAO handshake challenge timeout
if timeout {
defer func(old time.Duration) { daoChallengeTimeout = old }(daoChallengeTimeout)
daoChallengeTimeout = 500 * time.Millisecond
}
// Create a DAO aware protocol manager
var (
evmux = new(event.TypeMux)
pow = new(core.FakePow)
db, _ = ethdb.NewMemDatabase()
genesis = core.WriteGenesisBlockForTesting(db)
config = &params.ChainConfig{DAOForkBlock: big.NewInt(1), DAOForkSupport: localForked}
blockchain, _ = core.NewBlockChain(db, config, pow, evmux)
)
pm, err := NewProtocolManager(config, false, NetworkId, 1000, evmux, new(testTxPool), pow, blockchain, db)
if err != nil {
t.Fatalf("failed to start test protocol manager: %v", err)
}
pm.Start()
defer pm.Stop()
// Connect a new peer and check that we receive the DAO challenge
peer, _ := newTestPeer("peer", eth63, pm, true)
defer peer.close()
challenge := &getBlockHeadersData{
Origin: hashOrNumber{Number: config.DAOForkBlock.Uint64()},
Amount: 1,
Skip: 0,
Reverse: false,
}
if err := p2p.ExpectMsg(peer.app, GetBlockHeadersMsg, challenge); err != nil {
t.Fatalf("challenge mismatch: %v", err)
}
// Create a block to reply to the challenge if no timeout is simualted
if !timeout {
blocks, _ := core.GenerateChain(&params.ChainConfig{}, genesis, db, 1, func(i int, block *core.BlockGen) {
if remoteForked {
block.SetExtra(params.DAOForkBlockExtra)
}
})
if err := p2p.Send(peer.app, BlockHeadersMsg, []*types.Header{blocks[0].Header()}); err != nil {
t.Fatalf("failed to answer challenge: %v", err)
}
time.Sleep(100 * time.Millisecond) // Sleep to avoid the verification racing with the drops
} else {
// Otherwise wait until the test timeout passes
time.Sleep(daoChallengeTimeout + 500*time.Millisecond)
}
// Verify that depending on fork side, the remote peer is maintained or dropped
if localForked == remoteForked && !timeout {
if peers := pm.peers.Len(); peers != 1 {
t.Fatalf("peer count mismatch: have %d, want %d", peers, 1)
}
} else {
if peers := pm.peers.Len(); peers != 0 {
t.Fatalf("peer count mismatch: have %d, want %d", peers, 0)
}
}
}

View file

@ -22,6 +22,7 @@ import (
"sync/atomic"
"time"
"github.com/hashicorp/golang-lru"
"github.com/ubiq/go-ubiq/common"
"github.com/ubiq/go-ubiq/core"
"github.com/ubiq/go-ubiq/core/types"
@ -32,7 +33,6 @@ import (
"github.com/ubiq/go-ubiq/params"
"github.com/ubiq/go-ubiq/pow"
"github.com/ubiq/go-ubiq/rlp"
"github.com/hashicorp/golang-lru"
"golang.org/x/net/context"
)
@ -106,17 +106,10 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, pow pow.PoW, mux
if bc.genesisBlock.Hash() == (common.Hash{212, 229, 103, 64, 248, 118, 174, 248, 192, 16, 184, 106, 64, 213, 245, 103, 69, 161, 24, 208, 144, 106, 52, 230, 154, 236, 140, 13, 177, 203, 143, 163}) {
// add trusted CHT
if config.DAOForkSupport {
WriteTrustedCht(bc.chainDb, TrustedCht{
Number: 637,
Root: common.HexToHash("01e408d9b1942f05dba1a879f3eaafe34d219edaeb8223fecf1244cc023d3e23"),
})
} else {
WriteTrustedCht(bc.chainDb, TrustedCht{
Number: 523,
Root: common.HexToHash("c035076523faf514038f619715de404a65398c51899b5dccca9c05b00bc79315"),
})
}
glog.V(logger.Info).Infoln("Added trusted CHT for mainnet")
} else {
if bc.genesisBlock.Hash() == (common.Hash{12, 215, 134, 162, 66, 93, 22, 241, 82, 198, 88, 49, 108, 66, 62, 108, 225, 24, 30, 21, 195, 41, 88, 38, 215, 201, 144, 76, 186, 156, 227, 3}) {

View file

@ -17,7 +17,6 @@
package miner
import (
"bytes"
"fmt"
"math/big"
"sync"
@ -494,19 +493,6 @@ func (self *worker) commitNewWork() {
Extra: self.extra,
Time: big.NewInt(tstamp),
}
// If we are care about TheDAO 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 header.Number.Cmp(daoBlock) >= 0 && header.Number.Cmp(limit) < 0 {
// Depending whether we support or oppose the fork, override differently
if self.config.DAOForkSupport {
header.Extra = common.CopyBytes(params.DAOForkBlockExtra)
} else if bytes.Compare(header.Extra, params.DAOForkBlockExtra) == 0 {
header.Extra = []byte{} // If miner opposes, don't let it use the reserved extra-data
}
}
}
previous := self.current
// Could potentially happen if starting to mine in an odd state.
err := self.makeCurrent(parent, header)
@ -516,9 +502,6 @@ func (self *worker) commitNewWork() {
}
// Create the current work task and check any fork transitions needed
work := self.current
if self.config.DAOForkSupport && self.config.DAOForkBlock != nil && self.config.DAOForkBlock.Cmp(header.Number) == 0 {
core.ApplyDAOHardFork(work.state)
}
txs := types.NewTransactionsByPriceAndNonce(self.eth.TxPool().Pending())
work.commitTransactions(self.mux, txs, self.gasPrice, self.chain)

View file

@ -134,8 +134,6 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) {
ChainConfig: &params.ChainConfig{
ChainId: big.NewInt(config.EthereumChainConfig.ChainID),
HomesteadBlock: big.NewInt(config.EthereumChainConfig.HomesteadBlock),
DAOForkBlock: big.NewInt(config.EthereumChainConfig.DAOForkBlock),
DAOForkSupport: config.EthereumChainConfig.DAOForkSupport,
EIP150Block: big.NewInt(config.EthereumChainConfig.EIP150Block),
EIP150Hash: config.EthereumChainConfig.EIP150Hash.hash,
EIP155Block: big.NewInt(config.EthereumChainConfig.EIP155Block),

View file

@ -29,8 +29,6 @@ func MainnetChainConfig() *ChainConfig {
return &ChainConfig{
ChainID: params.MainNetChainID.Int64(),
HomesteadBlock: params.MainNetHomesteadBlock.Int64(),
DAOForkBlock: params.MainNetDAOForkBlock.Int64(),
DAOForkSupport: true,
EIP150Block: params.MainNetHomesteadGasRepriceBlock.Int64(),
EIP150Hash: Hash{params.MainNetHomesteadGasRepriceHash},
EIP155Block: params.MainNetSpuriousDragon.Int64(),
@ -49,8 +47,6 @@ func TestnetChainConfig() *ChainConfig {
return &ChainConfig{
ChainID: params.TestNetChainID.Int64(),
HomesteadBlock: params.TestNetHomesteadBlock.Int64(),
DAOForkBlock: 0,
DAOForkSupport: true,
EIP150Block: params.TestNetHomesteadGasRepriceBlock.Int64(),
EIP150Hash: Hash{params.TestNetHomesteadGasRepriceHash},
EIP155Block: params.TestNetSpuriousDragon.Int64(),
@ -67,8 +63,6 @@ func TestnetGenesis() string {
type ChainConfig struct {
ChainID int64 // Chain ID for replay protection
HomesteadBlock int64 // Homestead switch block
DAOForkBlock int64 // TheDAO hard-fork switch block
DAOForkSupport bool // Whether the nodes supports or opposes the DAO hard-fork
EIP150Block int64 // Homestead gas reprice switch block
EIP150Hash Hash // Homestead gas reprice switch block hash
EIP155Block int64 // Replay protection switch block

View file

@ -27,8 +27,6 @@ import (
var MainnetChainConfig = &ChainConfig{
ChainId: MainNetChainID,
HomesteadBlock: MainNetHomesteadBlock,
DAOForkBlock: MainNetDAOForkBlock,
DAOForkSupport: true,
EIP150Block: MainNetHomesteadGasRepriceBlock,
EIP150Hash: MainNetHomesteadGasRepriceHash,
EIP155Block: MainNetSpuriousDragon,
@ -39,8 +37,6 @@ var MainnetChainConfig = &ChainConfig{
var TestnetChainConfig = &ChainConfig{
ChainId: big.NewInt(3),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
EIP155Block: big.NewInt(10),
@ -56,8 +52,6 @@ type ChainConfig struct {
ChainId *big.Int `json:"chainId"` // Chain id identifies the current chain and is used for replay protection
HomesteadBlock *big.Int `json:"homesteadBlock"` // Homestead switch block (nil = no fork, 0 = already homestead)
DAOForkBlock *big.Int `json:"daoForkBlock"` // TheDAO hard-fork switch block (nil = no fork)
DAOForkSupport bool `json:"daoForkSupport"` // Whether the nodes supports or opposes the DAO hard-fork
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
EIP150Block *big.Int `json:"eip150Block"` // EIP150 HF block (nil = no fork)
@ -69,11 +63,9 @@ type ChainConfig struct {
// String implements the Stringer interface.
func (c *ChainConfig) String() string {
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v}",
return fmt.Sprintf("{ChainID: %v Homestead: %v EIP150: %v EIP155: %v EIP158: %v}",
c.ChainId,
c.HomesteadBlock,
c.DAOForkBlock,
c.DAOForkSupport,
c.EIP150Block,
c.EIP155Block,
c.EIP158Block,
@ -81,7 +73,7 @@ func (c *ChainConfig) String() string {
}
var (
TestChainConfig = &ChainConfig{big.NewInt(1), new(big.Int), new(big.Int), true, new(big.Int), common.Hash{}, new(big.Int), new(big.Int)}
TestChainConfig = &ChainConfig{big.NewInt(1), new(big.Int), new(big.Int), common.Hash{}, new(big.Int), new(big.Int)}
TestRules = TestChainConfig.Rules(new(big.Int))
)

View file

@ -1,418 +0,0 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package params
import (
"encoding/json"
"fmt"
"math/big"
"github.com/ubiq/go-ubiq/common"
)
// TestNetDAOForkBlock is the block number where the DAO hard-fork commences on
// the Ethereum test network. It's enforced nil since it was decided not to do a
// testnet transition.
var TestNetDAOForkBlock *big.Int
// MainNetDAOForkBlock is the block number where the DAO hard-fork commences on
// the Ethereum main network.
var MainNetDAOForkBlock = big.NewInt(1920000)
// DAOForkBlockExtra is the block header extra-data field to set for the DAO fork
// point and a number of consecutive blocks to allow fast/light syncers to correctly
// pick the side they want ("dao-hard-fork").
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)
// DAORefundContract is the address of the refund contract to send DAO balances to.
var DAORefundContract = common.HexToAddress("0xbf4ed7b27f1d666546e30d74d50d173d20bca754")
// DAODrainList is the list of accounts whose full balances will be moved into a
// refund contract at the beginning of the dao-fork block.
var DAODrainList []common.Address
func init() {
// Parse the list of DAO accounts to drain
var list []map[string]string
if err := json.Unmarshal([]byte(daoDrainListJSON), &list); err != nil {
panic(fmt.Errorf("Failed to parse DAO drain list: %v", err))
}
// Collect all the accounts that need draining
for _, dao := range list {
DAODrainList = append(DAODrainList, common.HexToAddress(dao["address"]))
DAODrainList = append(DAODrainList, common.HexToAddress(dao["extraBalanceAccount"]))
}
}
// daoDrainListJSON is the JSON encoded list of accounts whose full balances will
// be moved into a refund contract at the beginning of the dao-fork block.
const daoDrainListJSON = `
[
{
"address":"0xd4fe7bc31cedb7bfb8a345f31e668033056b2728",
"balance":"186cc8bfaefb7be",
"extraBalance":"0",
"extraBalanceAccount":"0xb3fb0e5aba0e20e5c49d252dfd30e102b171a425"
},
{
"address":"0x2c19c7f9ae8b751e37aeb2d93a699722395ae18f",
"balance":"b14e8feab1ff435",
"extraBalance":"0",
"extraBalanceAccount":"0xecd135fa4f61a655311e86238c92adcd779555d2"
},
{
"address":"0x1975bd06d486162d5dc297798dfc41edd5d160a7",
"balance":"359d26614cb5070c77",
"extraBalance":"0",
"extraBalanceAccount":"0xa3acf3a1e16b1d7c315e23510fdd7847b48234f6"
},
{
"address":"0x319f70bab6845585f412ec7724b744fec6095c85",
"balance":"6e075cd846d2cb1d42",
"extraBalance":"13d34fd41b545b81",
"extraBalanceAccount":"0x06706dd3f2c9abf0a21ddcc6941d9b86f0596936"
},
{
"address":"0x5c8536898fbb74fc7445814902fd08422eac56d0",
"balance":"b1e5593558008fd78",
"extraBalance":"0",
"extraBalanceAccount":"0x6966ab0d485353095148a2155858910e0965b6f9"
},
{
"address":"0x779543a0491a837ca36ce8c635d6154e3c4911a6",
"balance":"392eaa20d1aad59a4c",
"extraBalance":"426938826a96c9",
"extraBalanceAccount":"0x2a5ed960395e2a49b1c758cef4aa15213cfd874c"
},
{
"address":"0x5c6e67ccd5849c0d29219c4f95f1a7a93b3f5dc5",
"balance":"2875d22b29793d4ba7",
"extraBalance":"0",
"extraBalanceAccount":"0x9c50426be05db97f5d64fc54bf89eff947f0a321"
},
{
"address":"0x200450f06520bdd6c527622a273333384d870efb",
"balance":"43c341d9f96954c049",
"extraBalance":"0",
"extraBalanceAccount":"0xbe8539bfe837b67d1282b2b1d61c3f723966f049"
},
{
"address":"0x6b0c4d41ba9ab8d8cfb5d379c69a612f2ced8ecb",
"balance":"75251057154d70fa816",
"extraBalance":"0",
"extraBalanceAccount":"0xf1385fb24aad0cd7432824085e42aff90886fef5"
},
{
"address":"0xd1ac8b1ef1b69ff51d1d401a476e7e612414f091",
"balance":"392409769296cf67f36",
"extraBalance":"0",
"extraBalanceAccount":"0x8163e7fb499e90f8544ea62bbf80d21cd26d9efd"
},
{
"address":"0x51e0ddd9998364a2eb38588679f0d2c42653e4a6",
"balance":"8ac72eccbf4e8083",
"extraBalance":"0",
"extraBalanceAccount":"0x627a0a960c079c21c34f7612d5d230e01b4ad4c7"
},
{
"address":"0xf0b1aa0eb660754448a7937c022e30aa692fe0c5",
"balance":"82289c3bb3e8c98799",
"extraBalance":"0",
"extraBalanceAccount":"0x24c4d950dfd4dd1902bbed3508144a54542bba94"
},
{
"address":"0x9f27daea7aca0aa0446220b98d028715e3bc803d",
"balance":"56bc29049ebed40fd",
"extraBalance":"0",
"extraBalanceAccount":"0xa5dc5acd6a7968a4554d89d65e59b7fd3bff0f90"
},
{
"address":"0xd9aef3a1e38a39c16b31d1ace71bca8ef58d315b",
"balance":"56bc7d3ff79110524",
"extraBalance":"0",
"extraBalanceAccount":"0x63ed5a272de2f6d968408b4acb9024f4cc208ebf"
},
{
"address":"0x6f6704e5a10332af6672e50b3d9754dc460dfa4d",
"balance":"23b651bd48cbc70cc",
"extraBalance":"0",
"extraBalanceAccount":"0x77ca7b50b6cd7e2f3fa008e24ab793fd56cb15f6"
},
{
"address":"0x492ea3bb0f3315521c31f273e565b868fc090f17",
"balance":"13ea6d4fee651dd7c9",
"extraBalance":"0",
"extraBalanceAccount":"0x0ff30d6de14a8224aa97b78aea5388d1c51c1f00"
},
{
"address":"0x9ea779f907f0b315b364b0cfc39a0fde5b02a416",
"balance":"35ac471a3836ae7de5a",
"extraBalance":"0",
"extraBalanceAccount":"0xceaeb481747ca6c540a000c1f3641f8cef161fa7"
},
{
"address":"0xcc34673c6c40e791051898567a1222daf90be287",
"balance":"d529c0b76b7aa0",
"extraBalance":"0",
"extraBalanceAccount":"0x579a80d909f346fbfb1189493f521d7f48d52238"
},
{
"address":"0xe308bd1ac5fda103967359b2712dd89deffb7973",
"balance":"5cd9e7df3a8e5cdd3",
"extraBalance":"0",
"extraBalanceAccount":"0x4cb31628079fb14e4bc3cd5e30c2f7489b00960c"
},
{
"address":"0xac1ecab32727358dba8962a0f3b261731aad9723",
"balance":"2c8442fe35363313b93",
"extraBalance":"0",
"extraBalanceAccount":"0x4fd6ace747f06ece9c49699c7cabc62d02211f75"
},
{
"address":"0x440c59b325d2997a134c2c7c60a8c61611212bad",
"balance":"e77583a3958130e53",
"extraBalance":"0",
"extraBalanceAccount":"0x4486a3d68fac6967006d7a517b889fd3f98c102b"
},
{
"address":"0x9c15b54878ba618f494b38f0ae7443db6af648ba",
"balance":"1f0b6ade348ca998",
"extraBalance":"0",
"extraBalanceAccount":"0x27b137a85656544b1ccb5a0f2e561a5703c6a68f"
},
{
"address":"0x21c7fdb9ed8d291d79ffd82eb2c4356ec0d81241",
"balance":"61725880736659",
"extraBalance":"0",
"extraBalanceAccount":"0x23b75c2f6791eef49c69684db4c6c1f93bf49a50"
},
{
"address":"0x1ca6abd14d30affe533b24d7a21bff4c2d5e1f3b",
"balance":"42948d8dc7ddbc22d",
"extraBalance":"0",
"extraBalanceAccount":"0xb9637156d330c0d605a791f1c31ba5890582fe1c"
},
{
"address":"0x6131c42fa982e56929107413a9d526fd99405560",
"balance":"7306683851d1eafbfa",
"extraBalance":"0",
"extraBalanceAccount":"0x1591fc0f688c81fbeb17f5426a162a7024d430c2"
},
{
"address":"0x542a9515200d14b68e934e9830d91645a980dd7a",
"balance":"2a8457d0d8432e21d0c",
"extraBalance":"0",
"extraBalanceAccount":"0xc4bbd073882dd2add2424cf47d35213405b01324"
},
{
"address":"0x782495b7b3355efb2833d56ecb34dc22ad7dfcc4",
"balance":"d8d7391feaeaa8cdb",
"extraBalance":"0",
"extraBalanceAccount":"0x58b95c9a9d5d26825e70a82b6adb139d3fd829eb"
},
{
"address":"0x3ba4d81db016dc2890c81f3acec2454bff5aada5",
"balance":"1",
"extraBalance":"0",
"extraBalanceAccount":"0xb52042c8ca3f8aa246fa79c3feaa3d959347c0ab"
},
{
"address":"0xe4ae1efdfc53b73893af49113d8694a057b9c0d1",
"balance":"456397665fa74041",
"extraBalance":"0",
"extraBalanceAccount":"0x3c02a7bc0391e86d91b7d144e61c2c01a25a79c5"
},
{
"address":"0x0737a6b837f97f46ebade41b9bc3e1c509c85c53",
"balance":"6324dcb7126ecbef",
"extraBalance":"0",
"extraBalanceAccount":"0x97f43a37f595ab5dd318fb46e7a155eae057317a"
},
{
"address":"0x52c5317c848ba20c7504cb2c8052abd1fde29d03",
"balance":"6c3419b0705c01cd0d",
"extraBalance":"0",
"extraBalanceAccount":"0x4863226780fe7c0356454236d3b1c8792785748d"
},
{
"address":"0x5d2b2e6fcbe3b11d26b525e085ff818dae332479",
"balance":"456397665fa74041",
"extraBalance":"0",
"extraBalanceAccount":"0x5f9f3392e9f62f63b8eac0beb55541fc8627f42c"
},
{
"address":"0x057b56736d32b86616a10f619859c6cd6f59092a",
"balance":"232c025bb44b46",
"extraBalance":"0",
"extraBalanceAccount":"0x9aa008f65de0b923a2a4f02012ad034a5e2e2192"
},
{
"address":"0x304a554a310c7e546dfe434669c62820b7d83490",
"balance":"3034f5ca7d45e17df199b",
"extraBalance":"f7d15162c44e97b6e",
"extraBalanceAccount":"0x914d1b8b43e92723e64fd0a06f5bdb8dd9b10c79"
},
{
"address":"0x4deb0033bb26bc534b197e61d19e0733e5679784",
"balance":"4417e96ed796591e09",
"extraBalance":"0",
"extraBalanceAccount":"0x07f5c1e1bc2c93e0402f23341973a0e043f7bf8a"
},
{
"address":"0x35a051a0010aba705c9008d7a7eff6fb88f6ea7b",
"balance":"d3ff7771412bbcc9",
"extraBalance":"0",
"extraBalanceAccount":"0x4fa802324e929786dbda3b8820dc7834e9134a2a"
},
{
"address":"0x9da397b9e80755301a3b32173283a91c0ef6c87e",
"balance":"32ae324c233816b4c2",
"extraBalance":"0",
"extraBalanceAccount":"0x8d9edb3054ce5c5774a420ac37ebae0ac02343c6"
},
{
"address":"0x0101f3be8ebb4bbd39a2e3b9a3639d4259832fd9",
"balance":"1e530695b705f037c6",
"extraBalance":"0",
"extraBalanceAccount":"0x5dc28b15dffed94048d73806ce4b7a4612a1d48f"
},
{
"address":"0xbcf899e6c7d9d5a215ab1e3444c86806fa854c76",
"balance":"68013bad5b4b1133fc5",
"extraBalance":"0",
"extraBalanceAccount":"0x12e626b0eebfe86a56d633b9864e389b45dcb260"
},
{
"address":"0xa2f1ccba9395d7fcb155bba8bc92db9bafaeade7",
"balance":"456397665fa74041",
"extraBalance":"0",
"extraBalanceAccount":"0xec8e57756626fdc07c63ad2eafbd28d08e7b0ca5"
},
{
"address":"0xd164b088bd9108b60d0ca3751da4bceb207b0782",
"balance":"3635ce47fabaaa336e",
"extraBalance":"0",
"extraBalanceAccount":"0x6231b6d0d5e77fe001c2a460bd9584fee60d409b"
},
{
"address":"0x1cba23d343a983e9b5cfd19496b9a9701ada385f",
"balance":"f3abd9906c170a",
"extraBalance":"0",
"extraBalanceAccount":"0xa82f360a8d3455c5c41366975bde739c37bfeb8a"
},
{
"address":"0x9fcd2deaff372a39cc679d5c5e4de7bafb0b1339",
"balance":"4c6679d9d9b95a4e08",
"extraBalance":"0",
"extraBalanceAccount":"0x005f5cee7a43331d5a3d3eec71305925a62f34b6"
},
{
"address":"0x0e0da70933f4c7849fc0d203f5d1d43b9ae4532d",
"balance":"40f622936475de31849",
"extraBalance":"671e1bbabded39754",
"extraBalanceAccount":"0xd131637d5275fd1a68a3200f4ad25c71a2a9522e"
},
{
"address":"0xbc07118b9ac290e4622f5e77a0853539789effbe",
"balance":"1316ccfa4a35db5e58f",
"extraBalance":"0",
"extraBalanceAccount":"0x47e7aa56d6bdf3f36be34619660de61275420af8"
},
{
"address":"0xacd87e28b0c9d1254e868b81cba4cc20d9a32225",
"balance":"b3ad6bb72000bab9f",
"extraBalance":"0",
"extraBalanceAccount":"0xadf80daec7ba8dcf15392f1ac611fff65d94f880"
},
{
"address":"0x5524c55fb03cf21f549444ccbecb664d0acad706",
"balance":"16f2da372a5c8a70967",
"extraBalance":"0",
"extraBalanceAccount":"0x40b803a9abce16f50f36a77ba41180eb90023925"
},
{
"address":"0xfe24cdd8648121a43a7c86d289be4dd2951ed49f",
"balance":"ea0b1bdc78f500a43",
"extraBalance":"0",
"extraBalanceAccount":"0x17802f43a0137c506ba92291391a8a8f207f487d"
},
{
"address":"0x253488078a4edf4d6f42f113d1e62836a942cf1a",
"balance":"3060e3aed135cc80",
"extraBalance":"0",
"extraBalanceAccount":"0x86af3e9626fce1957c82e88cbf04ddf3a2ed7915"
},
{
"address":"0xb136707642a4ea12fb4bae820f03d2562ebff487",
"balance":"6050bdeb3354b5c98adc3",
"extraBalance":"0",
"extraBalanceAccount":"0xdbe9b615a3ae8709af8b93336ce9b477e4ac0940"
},
{
"address":"0xf14c14075d6c4ed84b86798af0956deef67365b5",
"balance":"1d77844e94c25ba2",
"extraBalance":"0",
"extraBalanceAccount":"0xca544e5c4687d109611d0f8f928b53a25af72448"
},
{
"address":"0xaeeb8ff27288bdabc0fa5ebb731b6f409507516c",
"balance":"2e93a72de4fc5ec0ed",
"extraBalance":"0",
"extraBalanceAccount":"0xcbb9d3703e651b0d496cdefb8b92c25aeb2171f7"
},
{
"address":"0x6d87578288b6cb5549d5076a207456a1f6a63dc0",
"balance":"1afd340799e48c18",
"extraBalance":"0",
"extraBalanceAccount":"0xb2c6f0dfbb716ac562e2d85d6cb2f8d5ee87603e"
},
{
"address":"0xaccc230e8a6e5be9160b8cdf2864dd2a001c28b6",
"balance":"14d0944eb3be947a8",
"extraBalance":"0",
"extraBalanceAccount":"0x2b3455ec7fedf16e646268bf88846bd7a2319bb2"
},
{
"address":"0x4613f3bca5c44ea06337a9e439fbc6d42e501d0a",
"balance":"6202b236a200e365eba",
"extraBalance":"11979be9020f03ec4ec",
"extraBalanceAccount":"0xd343b217de44030afaa275f54d31a9317c7f441e"
},
{
"address":"0x84ef4b2357079cd7a7c69fd7a37cd0609a679106",
"balance":"7ed634ebbba531901e07",
"extraBalance":"f9c5eff28cb08720c85",
"extraBalanceAccount":"0xda2fef9e4a3230988ff17df2165440f37e8b1708"
},
{
"address":"0xf4c64518ea10f995918a454158c6b61407ea345c",
"balance":"39152e15508a96ff894a",
"extraBalance":"14041ca908bcc185c8",
"extraBalanceAccount":"0x7602b46df5390e432ef1c307d4f2c9ff6d65cc97"
},
{
"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
"balance":"1",
"extraBalance":"5553ebc",
"extraBalanceAccount":"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
}
]
`

View file

@ -212,14 +212,6 @@ func TestHomesteadBcState(t *testing.T) {
}
}
// DAO hard-fork tests
func TestDAOBcTheDao(t *testing.T) {
err := RunBlockTest(big.NewInt(5), big.NewInt(8), nil, filepath.Join(blockTestDir, "TestNetwork", "bcTheDaoTest.json"), BlockSkipTests)
if err != nil {
t.Fatal(err)
}
}
func TestEIP150Bc(t *testing.T) {
err := RunBlockTest(big.NewInt(0), big.NewInt(8), big.NewInt(10), filepath.Join(blockTestDir, "TestNetwork", "bcEIP150Test.json"), BlockSkipTests)
if err != nil {

View file

@ -105,7 +105,7 @@ type btTransaction struct {
Value string
}
func RunBlockTestWithReader(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, r io.Reader, skipTests []string) error {
func RunBlockTestWithReader(homesteadBlock, gasPriceFork *big.Int, r io.Reader, skipTests []string) error {
btjs := make(map[string]*btJSON)
if err := readJson(r, &btjs); err != nil {
return err
@ -116,13 +116,13 @@ func RunBlockTestWithReader(homesteadBlock, daoForkBlock, gasPriceFork *big.Int,
return err
}
if err := runBlockTests(homesteadBlock, daoForkBlock, gasPriceFork, bt, skipTests); err != nil {
if err := runBlockTests(homesteadBlock, gasPriceFork, bt, skipTests); err != nil {
return err
}
return nil
}
func RunBlockTest(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, file string, skipTests []string) error {
func RunBlockTest(homesteadBlock, gasPriceFork *big.Int, file string, skipTests []string) error {
btjs := make(map[string]*btJSON)
if err := readJsonFile(file, &btjs); err != nil {
return err
@ -132,13 +132,13 @@ func RunBlockTest(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, file stri
if err != nil {
return err
}
if err := runBlockTests(homesteadBlock, daoForkBlock, gasPriceFork, bt, skipTests); err != nil {
if err := runBlockTests(homesteadBlock, gasPriceFork, bt, skipTests); err != nil {
return err
}
return nil
}
func runBlockTests(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, bt map[string]*BlockTest, skipTests []string) error {
func runBlockTests(homesteadBlock, gasPriceFork *big.Int, bt map[string]*BlockTest, skipTests []string) error {
skipTest := make(map[string]bool, len(skipTests))
for _, name := range skipTests {
skipTest[name] = true
@ -150,7 +150,7 @@ func runBlockTests(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, bt map[s
continue
}
// test the block
if err := runBlockTest(homesteadBlock, daoForkBlock, gasPriceFork, test); err != nil {
if err := runBlockTest(homesteadBlock, gasPriceFork, test); err != nil {
return fmt.Errorf("%s: %v", name, err)
}
glog.Infoln("Block test passed: ", name)
@ -159,7 +159,7 @@ func runBlockTests(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, bt map[s
return nil
}
func runBlockTest(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, test *BlockTest) error {
func runBlockTest(homesteadBlock, gasPriceFork *big.Int, test *BlockTest) error {
// import pre accounts & construct test genesis block & state root
db, _ := ethdb.NewMemDatabase()
if _, err := test.InsertPreState(db); err != nil {
@ -171,7 +171,7 @@ func runBlockTest(homesteadBlock, daoForkBlock, gasPriceFork *big.Int, test *Blo
core.WriteCanonicalHash(db, test.Genesis.Hash(), test.Genesis.NumberU64())
core.WriteHeadBlockHash(db, test.Genesis.Hash())
evmux := new(event.TypeMux)
config := &params.ChainConfig{HomesteadBlock: homesteadBlock, DAOForkBlock: daoForkBlock, DAOForkSupport: true, EIP150Block: gasPriceFork}
config := &params.ChainConfig{HomesteadBlock: homesteadBlock, EIP150Block: gasPriceFork}
chain, err := core.NewBlockChain(db, config, ethash.NewShared(), evmux)
if err != nil {
return err

File diff suppressed because it is too large Load diff

View file

@ -227,8 +227,6 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, vm.Logs,
chainConfig := &params.ChainConfig{
HomesteadBlock: params.MainNetHomesteadBlock,
DAOForkBlock: params.MainNetDAOForkBlock,
DAOForkSupport: true,
}
vmenv := NewEnvFromMap(chainConfig, state, env, exec)
vmenv.vmTest = true