core, params, tests: add DAO hard-fork balance moves
This commit is contained in:
parent
7f00e8c033
commit
461cdb593b
@ -74,9 +74,9 @@ 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, r, skipTests)
|
||||
err = tests.RunBlockTestWithReader(params.MainNetHomesteadBlock, params.MainNetDAOForkBlock, r, skipTests)
|
||||
case "st", "state", "statetest", "statetests":
|
||||
rs := tests.RuleSet{HomesteadBlock: params.MainNetHomesteadBlock}
|
||||
rs := tests.RuleSet{HomesteadBlock: params.MainNetHomesteadBlock, DAOForkBlock: params.MainNetDAOForkBlock, DAOForkSupport: true}
|
||||
err = tests.RunStateTestWithReader(rs, r, skipTests)
|
||||
case "tx", "transactiontest", "transactiontests":
|
||||
err = tests.RunTransactionTestsWithReader(r, skipTests)
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/logger/glog"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -65,7 +66,11 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||
allLogs vm.Logs
|
||||
gp = new(GasPool).AddGas(block.GasLimit())
|
||||
)
|
||||
|
||||
// Mutate the statedb 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() {
|
||||
statedb.StartRecord(tx.Hash(), block.Hash(), i)
|
||||
receipt, logs, _, err := ApplyTransaction(p.config, p.bc, gp, statedb, header, tx, totalUsedGas, cfg)
|
||||
@ -129,3 +134,19 @@ func AccumulateRewards(statedb *state.StateDB, header *types.Header, uncles []*t
|
||||
}
|
||||
statedb.AddBalance(header.Coinbase, reward)
|
||||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +490,11 @@ func (self *worker) commitNewWork() {
|
||||
glog.V(logger.Info).Infoln("Could not create new env for mining, retrying on next block.")
|
||||
return
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
|
||||
/* //approach 1
|
||||
transactions := self.eth.TxPool().GetTransactions()
|
||||
|
108
params/dao_list.go
Normal file
108
params/dao_list.go
Normal file
@ -0,0 +1,108 @@
|
||||
// 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"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
// 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":"0x304a554a310c7e546dfe434669c62820b7d83490",
|
||||
"balance":"30328a3f333ac2fb5f509",
|
||||
"extraBalance":"9184e72a000",
|
||||
"extraBalanceAccount":"0x914d1b8b43e92723e64fd0a06f5bdb8dd9b10c79"
|
||||
},
|
||||
{
|
||||
"address":"0xfe24cdd8648121a43a7c86d289be4dd2951ed49f",
|
||||
"balance":"ea0b1bdc78f500a43",
|
||||
"extraBalance":"0",
|
||||
"extraBalanceAccount":"0x17802f43a0137c506ba92291391a8a8f207f487d"
|
||||
},
|
||||
{
|
||||
"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":"0xaccc230e8a6e5be9160b8cdf2864dd2a001c28b6",
|
||||
"balance":"14d0944eb3be947a8",
|
||||
"extraBalance":"0",
|
||||
"extraBalanceAccount":"0x2b3455ec7fedf16e646268bf88846bd7a2319bb2"
|
||||
},
|
||||
{
|
||||
"address":"0x4613f3bca5c44ea06337a9e439fbc6d42e501d0a",
|
||||
"balance":"275eaa8345ced6523a8",
|
||||
"extraBalance":"0",
|
||||
"extraBalanceAccount":"0xd343b217de44030afaa275f54d31a9317c7f441e"
|
||||
},
|
||||
{
|
||||
"address":"0x84ef4b2357079cd7a7c69fd7a37cd0609a679106",
|
||||
"balance":"4accfbf922fd046baa05",
|
||||
"extraBalance":"0",
|
||||
"extraBalanceAccount":"0xda2fef9e4a3230988ff17df2165440f37e8b1708"
|
||||
},
|
||||
{
|
||||
"address":"0xf4c64518ea10f995918a454158c6b61407ea345c",
|
||||
"balance":"38d275b0ed7862ba4f13",
|
||||
"extraBalance":"0",
|
||||
"extraBalanceAccount":"0x7602b46df5390e432ef1c307d4f2c9ff6d65cc97"
|
||||
},
|
||||
{
|
||||
"address":"0xbb9bc244d798123fde783fcc1c72d3bb8c189413",
|
||||
"balance":"1",
|
||||
"extraBalance":"49097c66ae78c50e4d3c",
|
||||
"extraBalanceAccount":"0x807640a13483f8ac783c557fcdf27be11ea4ac7a"
|
||||
}
|
||||
]
|
||||
`
|
@ -30,4 +30,5 @@ var (
|
||||
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)
|
||||
DAORefundContract = common.HexToAddress("0x0000000000000000000000000000000000000000") // Address of the refund contract to send DAO balances to
|
||||
)
|
||||
|
@ -20,66 +20,69 @@ import (
|
||||
"math/big"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
func TestBcValidBlockTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcValidBlockTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcUncleHeaderValidityTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcUncleHeaderValiditiy.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcUncleTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcUncleTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcForkUncleTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcForkUncle.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcInvalidHeaderTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcInvalidHeaderTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcInvalidRLPTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcInvalidRLPTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcRPCAPITests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcRPC_API_Test.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcForkBlockTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcForkBlockTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcForkStress(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcForkStressTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -89,21 +92,21 @@ func TestBcTotalDifficulty(t *testing.T) {
|
||||
// skip because these will fail due to selfish mining fix
|
||||
t.Skip()
|
||||
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcTotalDifficultyTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcWallet(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcWalletTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcGasPricer(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcGasPricerTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcGasPricerTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -111,7 +114,7 @@ func TestBcGasPricer(t *testing.T) {
|
||||
|
||||
// TODO: iterate over files once we got more than a few
|
||||
func TestBcRandom(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "RandomTests/bl201507071825GO.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "RandomTests/bl201507071825GO.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -121,14 +124,14 @@ func TestBcMultiChain(t *testing.T) {
|
||||
// skip due to selfish mining
|
||||
t.Skip()
|
||||
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcMultiChainTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBcState(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(1000000), filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(1000000), nil, filepath.Join(blockTestDir, "bcStateTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -136,77 +139,89 @@ func TestBcState(t *testing.T) {
|
||||
|
||||
// Homestead tests
|
||||
func TestHomesteadBcValidBlockTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcValidBlockTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcUncleHeaderValidityTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcUncleHeaderValiditiy.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcUncleTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcUncleTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcInvalidHeaderTests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcInvalidHeaderTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcRPCAPITests(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcRPC_API_Test.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcForkStress(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcForkStressTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcTotalDifficulty(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcTotalDifficultyTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcWallet(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcWalletTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcGasPricer(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcGasPricerTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcMultiChain(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcMultiChainTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHomesteadBcState(t *testing.T) {
|
||||
err := RunBlockTest(big.NewInt(0), filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests)
|
||||
err := RunBlockTest(big.NewInt(0), nil, filepath.Join(blockTestDir, "Homestead", "bcStateTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// DAO hard-fork tests
|
||||
func TestDAOBcTheDao(t *testing.T) {
|
||||
// Temporarilly override the hard-fork specs
|
||||
defer func(old common.Address) { params.DAORefundContract = old }(params.DAORefundContract)
|
||||
params.DAORefundContract = common.HexToAddress("0xabcabcabcabcabcabcabcabcabcabcabcabcabca")
|
||||
|
||||
err := RunBlockTest(big.NewInt(5), big.NewInt(8), filepath.Join(blockTestDir, "TestNetwork", "bcTheDaoTest.json"), BlockSkipTests)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ type btTransaction struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
func RunBlockTestWithReader(homesteadBlock *big.Int, r io.Reader, skipTests []string) error {
|
||||
func RunBlockTestWithReader(homesteadBlock, daoForkBlock *big.Int, r io.Reader, skipTests []string) error {
|
||||
btjs := make(map[string]*btJSON)
|
||||
if err := readJson(r, &btjs); err != nil {
|
||||
return err
|
||||
@ -114,13 +114,13 @@ func RunBlockTestWithReader(homesteadBlock *big.Int, r io.Reader, skipTests []st
|
||||
return err
|
||||
}
|
||||
|
||||
if err := runBlockTests(homesteadBlock, bt, skipTests); err != nil {
|
||||
if err := runBlockTests(homesteadBlock, daoForkBlock, bt, skipTests); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunBlockTest(homesteadBlock *big.Int, file string, skipTests []string) error {
|
||||
func RunBlockTest(homesteadBlock, daoForkBlock *big.Int, file string, skipTests []string) error {
|
||||
btjs := make(map[string]*btJSON)
|
||||
if err := readJsonFile(file, &btjs); err != nil {
|
||||
return err
|
||||
@ -130,13 +130,13 @@ func RunBlockTest(homesteadBlock *big.Int, file string, skipTests []string) erro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := runBlockTests(homesteadBlock, bt, skipTests); err != nil {
|
||||
if err := runBlockTests(homesteadBlock, daoForkBlock, bt, skipTests); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runBlockTests(homesteadBlock *big.Int, bt map[string]*BlockTest, skipTests []string) error {
|
||||
func runBlockTests(homesteadBlock, daoForkBlock *big.Int, bt map[string]*BlockTest, skipTests []string) error {
|
||||
skipTest := make(map[string]bool, len(skipTests))
|
||||
for _, name := range skipTests {
|
||||
skipTest[name] = true
|
||||
@ -148,7 +148,7 @@ func runBlockTests(homesteadBlock *big.Int, bt map[string]*BlockTest, skipTests
|
||||
continue
|
||||
}
|
||||
// test the block
|
||||
if err := runBlockTest(homesteadBlock, test); err != nil {
|
||||
if err := runBlockTest(homesteadBlock, daoForkBlock, test); err != nil {
|
||||
return fmt.Errorf("%s: %v", name, err)
|
||||
}
|
||||
glog.Infoln("Block test passed: ", name)
|
||||
@ -157,7 +157,7 @@ func runBlockTests(homesteadBlock *big.Int, bt map[string]*BlockTest, skipTests
|
||||
return nil
|
||||
}
|
||||
|
||||
func runBlockTest(homesteadBlock *big.Int, test *BlockTest) error {
|
||||
func runBlockTest(homesteadBlock, daoForkBlock *big.Int, test *BlockTest) error {
|
||||
// import pre accounts & construct test genesis block & state root
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
if _, err := test.InsertPreState(db); err != nil {
|
||||
@ -169,7 +169,7 @@ func runBlockTest(homesteadBlock *big.Int, test *BlockTest) error {
|
||||
core.WriteCanonicalHash(db, test.Genesis.Hash(), test.Genesis.NumberU64())
|
||||
core.WriteHeadBlockHash(db, test.Genesis.Hash())
|
||||
evmux := new(event.TypeMux)
|
||||
config := &core.ChainConfig{HomesteadBlock: homesteadBlock}
|
||||
config := &core.ChainConfig{HomesteadBlock: homesteadBlock, DAOForkBlock: daoForkBlock, DAOForkSupport: true}
|
||||
chain, err := core.NewBlockChain(db, config, ethash.NewShared(), evmux)
|
||||
if err != nil {
|
||||
return err
|
||||
|
1818
tests/files/BlockchainTests/TestNetwork/bcTheDaoTest.json
Normal file
1818
tests/files/BlockchainTests/TestNetwork/bcTheDaoTest.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -141,6 +141,8 @@ type VmTest struct {
|
||||
|
||||
type RuleSet struct {
|
||||
HomesteadBlock *big.Int
|
||||
DAOForkBlock *big.Int
|
||||
DAOForkSupport bool
|
||||
}
|
||||
|
||||
func (r RuleSet) IsHomestead(n *big.Int) bool {
|
||||
|
@ -241,7 +241,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, vm.Logs,
|
||||
|
||||
caller := state.GetOrNewStateObject(from)
|
||||
|
||||
vmenv := NewEnvFromMap(RuleSet{params.MainNetHomesteadBlock}, state, env, exec)
|
||||
vmenv := NewEnvFromMap(RuleSet{params.MainNetHomesteadBlock, params.MainNetDAOForkBlock, true}, state, env, exec)
|
||||
vmenv.vmTest = true
|
||||
vmenv.skipTransfer = true
|
||||
vmenv.initial = true
|
||||
|
Loading…
Reference in New Issue
Block a user