From 6060e098c929792f455d7f580ed91e914d28cf3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 7 Jul 2016 16:04:34 +0300 Subject: cmd, core, eth, params: implement flags to control dao fork blocks --- core/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/config.go b/core/config.go index 81ca76aa3..d557ae5a4 100644 --- a/core/config.go +++ b/core/config.go @@ -31,7 +31,8 @@ var ChainConfigNotFoundErr = errors.New("ChainConfig not found") // general conf // that any network, identified by its genesis block, can have its own // set of configuration options. type ChainConfig struct { - HomesteadBlock *big.Int // homestead switch block + HomesteadBlock *big.Int `json:"homesteadBlock"` // homestead switch block (0 = already homestead) + DAOForkBlock *big.Int `json:"daoForkBlock"` // TheDAO hard-fork block (nil = no fork) VmConfig vm.Config `json:"-"` } @@ -41,6 +42,5 @@ func (c *ChainConfig) IsHomestead(num *big.Int) bool { if num == nil { return false } - return num.Cmp(c.HomesteadBlock) >= 0 } -- cgit v1.2.3 From 9e56811a3773e225bedf6bf0003327ea1aaae040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 8 Jul 2016 11:43:36 +0300 Subject: core: gracefully handle missing homestead block config --- core/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/config.go b/core/config.go index d557ae5a4..d04b00e9c 100644 --- a/core/config.go +++ b/core/config.go @@ -39,7 +39,7 @@ type ChainConfig struct { // IsHomestead returns whether num is either equal to the homestead block or greater. func (c *ChainConfig) IsHomestead(num *big.Int) bool { - if num == nil { + if c.HomesteadBlock == nil || num == nil { return false } return num.Cmp(c.HomesteadBlock) >= 0 -- cgit v1.2.3 From a87089fd2dc08a69a4a4f1ef93db9a2871d819a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 8 Jul 2016 18:48:17 +0300 Subject: cmd, core, miner: add extradata validation to consensus rules --- core/block_validator.go | 21 +++++++++ core/block_validator_test.go | 105 +++++++++++++++++++++++++++++++++++++++++++ core/config.go | 5 ++- 3 files changed, 129 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/block_validator.go b/core/block_validator.go index c3f959324..73d581328 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -17,6 +17,7 @@ package core import ( + "bytes" "fmt" "math/big" "time" @@ -247,6 +248,26 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare return &BlockNonceErr{header.Number, header.Hash(), header.Nonce.Uint64()} } } + // 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. + if daoBlock := 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 { + // Depending whether we support or oppose the fork, verrift 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) + } + } + } + } return nil } diff --git a/core/block_validator_test.go b/core/block_validator_test.go index c6daf9e7f..5320c3f8d 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -27,6 +27,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow/ezp" ) @@ -92,3 +93,107 @@ func TestPutReceipt(t *testing.T) { t.Error("expected to get 1 receipt, got none.") } } + +// 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(genesis, db, int(forkBlock.Int64()-1), func(i int, gen *BlockGen) {}) + + // Create the concurrent, conflicting two nodes + proDb, _ := ethdb.NewMemDatabase() + WriteGenesisBlockForTesting(proDb) + proBc, _ := NewBlockChain(proDb, &ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: true}, new(FakePow), new(event.TypeMux)) + + conDb, _ := ethdb.NewMemDatabase() + WriteGenesisBlockForTesting(conDb) + conBc, _ := NewBlockChain(conDb, &ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: false}, 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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) { gen.SetExtra(params.DAOForkBlockExtra) }) + 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(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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(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(proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) { gen.SetExtra(params.DAOForkBlockExtra) }) + 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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) { gen.SetExtra(params.DAOForkBlockExtra) }) + 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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(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) + } +} diff --git a/core/config.go b/core/config.go index d04b00e9c..c0d065a57 100644 --- a/core/config.go +++ b/core/config.go @@ -31,8 +31,9 @@ var ChainConfigNotFoundErr = errors.New("ChainConfig not found") // general conf // that any network, identified by its genesis block, can have its own // set of configuration options. type ChainConfig struct { - HomesteadBlock *big.Int `json:"homesteadBlock"` // homestead switch block (0 = already homestead) - DAOForkBlock *big.Int `json:"daoForkBlock"` // TheDAO hard-fork block (nil = no fork) + 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 VmConfig vm.Config `json:"-"` } -- cgit v1.2.3 From 7f00e8c0331bf13739e749bab88bf9006ca02f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 8 Jul 2016 20:59:11 +0300 Subject: core, eth: enforce network split post DAO hard-fork --- core/block_validator.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core') diff --git a/core/block_validator.go b/core/block_validator.go index 73d581328..3b597310e 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -248,6 +248,13 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare return &BlockNonceErr{header.Number, header.Hash(), header.Nonce.Uint64()} } } + // If all checks passed, validate the extra-data field for hard forks + return ValidateHeaderExtraData(config, header) +} + +// ValidateHeaderExtraData validates the extra-data field of a block header to +// ensure it conforms to hard-fork rules. +func ValidateHeaderExtraData(config *ChainConfig, header *types.Header) error { // 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 -- cgit v1.2.3 From 461cdb593b9e5bd9ae9ac35c68809a3a29290dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 11 Jul 2016 13:55:11 +0300 Subject: core, params, tests: add DAO hard-fork balance moves --- core/state_processor.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/state_processor.go b/core/state_processor.go index 95b3057bb..a9c2d1e18 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -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)) + } + } +} -- cgit v1.2.3 From 3291235711082759cd7b70253c02150a80d57011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 14 Jul 2016 18:17:03 +0300 Subject: accounts, core, eth: pass chain config for chain maker to test DAO --- core/bench_test.go | 2 +- core/block_validator_test.go | 105 ---------------------------------- core/blockchain_test.go | 16 +++--- core/chain_makers.go | 28 ++++++++- core/chain_makers_test.go | 2 +- core/chain_pow_test.go | 6 +- core/dao_test.go | 132 +++++++++++++++++++++++++++++++++++++++++++ core/database_util_test.go | 2 +- core/state_processor.go | 2 +- 9 files changed, 172 insertions(+), 123 deletions(-) create mode 100644 core/dao_test.go (limited to 'core') diff --git a/core/bench_test.go b/core/bench_test.go index c6029499a..344e7e3c5 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -163,7 +163,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { // Generate a chain of b.N blocks using the supplied block // generator function. genesis := WriteGenesisBlockForTesting(db, GenesisAccount{benchRootAddr, benchRootFunds}) - chain, _ := GenerateChain(genesis, db, b.N, gen) + chain, _ := GenerateChain(nil, genesis, db, b.N, gen) // Time the insertion of the new chain. // State and blocks are stored in the same DB. diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 5320c3f8d..c6daf9e7f 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -27,7 +27,6 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow/ezp" ) @@ -93,107 +92,3 @@ func TestPutReceipt(t *testing.T) { t.Error("expected to get 1 receipt, got none.") } } - -// 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(genesis, db, int(forkBlock.Int64()-1), func(i int, gen *BlockGen) {}) - - // Create the concurrent, conflicting two nodes - proDb, _ := ethdb.NewMemDatabase() - WriteGenesisBlockForTesting(proDb) - proBc, _ := NewBlockChain(proDb, &ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: true}, new(FakePow), new(event.TypeMux)) - - conDb, _ := ethdb.NewMemDatabase() - WriteGenesisBlockForTesting(conDb) - conBc, _ := NewBlockChain(conDb, &ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: false}, 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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) { gen.SetExtra(params.DAOForkBlockExtra) }) - 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(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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(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(proBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) { gen.SetExtra(params.DAOForkBlockExtra) }) - 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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(conBc.CurrentBlock(), db, 1, func(i int, gen *BlockGen) { gen.SetExtra(params.DAOForkBlockExtra) }) - 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, &ChainConfig{HomesteadBlock: big.NewInt(0)}, 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(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) - } -} diff --git a/core/blockchain_test.go b/core/blockchain_test.go index a26fe4a1b..c3e4d352d 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -712,7 +712,7 @@ func TestFastVsFullChains(t *testing.T) { funds = big.NewInt(1000000000) genesis = GenesisBlockForTesting(gendb, address, funds) ) - blocks, receipts := GenerateChain(genesis, gendb, 1024, func(i int, block *BlockGen) { + blocks, receipts := GenerateChain(nil, genesis, gendb, 1024, func(i int, block *BlockGen) { block.SetCoinbase(common.Address{0x00}) // If the block number is multiple of 3, send a few bonus transactions to the miner @@ -795,7 +795,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) { genesis = GenesisBlockForTesting(gendb, address, funds) ) height := uint64(1024) - blocks, receipts := GenerateChain(genesis, gendb, int(height), nil) + blocks, receipts := GenerateChain(nil, genesis, gendb, int(height), nil) // Configure a subchain to roll back remove := []common.Hash{} @@ -895,7 +895,7 @@ func TestChainTxReorgs(t *testing.T) { // - futureAdd: transaction added after the reorg has already finished var pastAdd, freshAdd, futureAdd *types.Transaction - chain, _ := GenerateChain(genesis, db, 3, func(i int, gen *BlockGen) { + chain, _ := GenerateChain(nil, genesis, db, 3, func(i int, gen *BlockGen) { switch i { case 0: pastDrop, _ = types.NewTransaction(gen.TxNonce(addr2), addr2, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(key2) @@ -920,7 +920,7 @@ func TestChainTxReorgs(t *testing.T) { } // overwrite the old chain - chain, _ = GenerateChain(genesis, db, 5, func(i int, gen *BlockGen) { + chain, _ = GenerateChain(nil, genesis, db, 5, func(i int, gen *BlockGen) { switch i { case 0: pastAdd, _ = types.NewTransaction(gen.TxNonce(addr3), addr3, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(key3) @@ -990,7 +990,7 @@ func TestLogReorgs(t *testing.T) { blockchain, _ := NewBlockChain(db, testChainConfig(), FakePow{}, evmux) subs := evmux.Subscribe(RemovedLogsEvent{}) - chain, _ := GenerateChain(genesis, db, 2, func(i int, gen *BlockGen) { + chain, _ := GenerateChain(nil, genesis, db, 2, func(i int, gen *BlockGen) { if i == 1 { tx, err := types.NewContractCreation(gen.TxNonce(addr1), new(big.Int), big.NewInt(1000000), new(big.Int), code).SignECDSA(key1) if err != nil { @@ -1003,7 +1003,7 @@ func TestLogReorgs(t *testing.T) { t.Fatalf("failed to insert chain: %v", err) } - chain, _ = GenerateChain(genesis, db, 3, func(i int, gen *BlockGen) {}) + chain, _ = GenerateChain(nil, genesis, db, 3, func(i int, gen *BlockGen) {}) if _, err := blockchain.InsertChain(chain); err != nil { t.Fatalf("failed to insert forked chain: %v", err) } @@ -1025,12 +1025,12 @@ func TestReorgSideEvent(t *testing.T) { evmux := &event.TypeMux{} blockchain, _ := NewBlockChain(db, testChainConfig(), FakePow{}, evmux) - chain, _ := GenerateChain(genesis, db, 3, func(i int, gen *BlockGen) {}) + chain, _ := GenerateChain(nil, genesis, db, 3, func(i int, gen *BlockGen) {}) if _, err := blockchain.InsertChain(chain); err != nil { t.Fatalf("failed to insert chain: %v", err) } - replacementBlocks, _ := GenerateChain(genesis, db, 4, func(i int, gen *BlockGen) { + replacementBlocks, _ := GenerateChain(nil, genesis, db, 4, func(i int, gen *BlockGen) { tx, err := types.NewContractCreation(gen.TxNonce(addr1), new(big.Int), big.NewInt(1000000), new(big.Int), nil).SignECDSA(key1) if i == 2 { gen.OffsetTime(-1) diff --git a/core/chain_makers.go b/core/chain_makers.go index ef0ac66d1..0b9a5f75d 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -26,6 +26,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" ) @@ -35,7 +36,11 @@ import ( // MakeChainConfig returns a new ChainConfig with the ethereum default chain settings. func MakeChainConfig() *ChainConfig { - return &ChainConfig{HomesteadBlock: big.NewInt(0)} + return &ChainConfig{ + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + } } // FakePow is a non-validating proof of work implementation. @@ -173,10 +178,27 @@ func (b *BlockGen) OffsetTime(seconds int64) { // Blocks created by GenerateChain do not contain valid proof of work // values. Inserting them into BlockChain requires use of FakePow or // a similar non-validating proof of work implementation. -func GenerateChain(parent *types.Block, db ethdb.Database, n int, gen func(int, *BlockGen)) ([]*types.Block, []types.Receipts) { +func GenerateChain(config *ChainConfig, parent *types.Block, db ethdb.Database, n int, gen func(int, *BlockGen)) ([]*types.Block, []types.Receipts) { blocks, receipts := make(types.Blocks, n), make([]types.Receipts, n) genblock := func(i int, h *types.Header, statedb *state.StateDB) (*types.Block, types.Receipts) { b := &BlockGen{parent: parent, i: i, chain: blocks, header: h, statedb: statedb} + + // Mutate the state and block according to any hard-fork specs + 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) } @@ -261,7 +283,7 @@ func makeHeaderChain(parent *types.Header, n int, db ethdb.Database, seed int) [ // makeBlockChain creates a deterministic chain of blocks rooted at parent. func makeBlockChain(parent *types.Block, n int, db ethdb.Database, seed int) []*types.Block { - blocks, _ := GenerateChain(parent, db, n, func(i int, b *BlockGen) { + blocks, _ := GenerateChain(nil, parent, db, n, func(i int, b *BlockGen) { b.SetCoinbase(common.Address{0: byte(seed), 19: byte(i)}) }) return blocks diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index 32c3efe8d..f52b09ad9 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -47,7 +47,7 @@ func ExampleGenerateChain() { // This call generates a chain of 5 blocks. The function runs for // each block and adds different features to gen based on the // block index. - chain, _ := GenerateChain(genesis, db, 5, func(i int, gen *BlockGen) { + chain, _ := GenerateChain(nil, genesis, db, 5, func(i int, gen *BlockGen) { switch i { case 0: // In block 1, addr1 sends addr2 some ether. diff --git a/core/chain_pow_test.go b/core/chain_pow_test.go index d2b0bd144..2e26c8211 100644 --- a/core/chain_pow_test.go +++ b/core/chain_pow_test.go @@ -60,7 +60,7 @@ func TestPowVerification(t *testing.T) { var ( testdb, _ = ethdb.NewMemDatabase() genesis = GenesisBlockForTesting(testdb, common.Address{}, new(big.Int)) - blocks, _ = GenerateChain(genesis, testdb, 8, nil) + blocks, _ = GenerateChain(nil, genesis, testdb, 8, nil) ) headers := make([]*types.Header, len(blocks)) for i, block := range blocks { @@ -115,7 +115,7 @@ func testPowConcurrentVerification(t *testing.T, threads int) { var ( testdb, _ = ethdb.NewMemDatabase() genesis = GenesisBlockForTesting(testdb, common.Address{}, new(big.Int)) - blocks, _ = GenerateChain(genesis, testdb, 8, nil) + blocks, _ = GenerateChain(nil, genesis, testdb, 8, nil) ) headers := make([]*types.Header, len(blocks)) for i, block := range blocks { @@ -186,7 +186,7 @@ func testPowConcurrentAbortion(t *testing.T, threads int) { var ( testdb, _ = ethdb.NewMemDatabase() genesis = GenesisBlockForTesting(testdb, common.Address{}, new(big.Int)) - blocks, _ = GenerateChain(genesis, testdb, 1024, nil) + blocks, _ = GenerateChain(nil, genesis, testdb, 1024, nil) ) headers := make([]*types.Header, len(blocks)) for i, block := range blocks { diff --git a/core/dao_test.go b/core/dao_test.go new file mode 100644 index 000000000..0830b1231 --- /dev/null +++ b/core/dao_test.go @@ -0,0 +1,132 @@ +// 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 . + +package core + +import ( + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/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(nil, genesis, db, int(forkBlock.Int64()-1), func(i int, gen *BlockGen) {}) + + // Create the concurrent, conflicting two nodes + proDb, _ := ethdb.NewMemDatabase() + WriteGenesisBlockForTesting(proDb) + proConf := &ChainConfig{HomesteadBlock: big.NewInt(0), DAOForkBlock: forkBlock, DAOForkSupport: true} + proBc, _ := NewBlockChain(proDb, proConf, new(FakePow), new(event.TypeMux)) + + conDb, _ := ethdb.NewMemDatabase() + WriteGenesisBlockForTesting(conDb) + conConf := &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) + } +} diff --git a/core/database_util_test.go b/core/database_util_test.go index 6c19f78c8..280270ac8 100644 --- a/core/database_util_test.go +++ b/core/database_util_test.go @@ -561,7 +561,7 @@ func TestMipmapChain(t *testing.T) { defer db.Close() genesis := WriteGenesisBlockForTesting(db, GenesisAccount{addr, big.NewInt(1000000)}) - chain, receipts := GenerateChain(genesis, db, 1010, func(i int, gen *BlockGen) { + chain, receipts := GenerateChain(nil, genesis, db, 1010, func(i int, gen *BlockGen) { var receipts types.Receipts switch i { case 1: diff --git a/core/state_processor.go b/core/state_processor.go index a9c2d1e18..6a418a62d 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -66,7 +66,7 @@ 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 + // 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) } -- cgit v1.2.3 From 2c2e389b778b490fcaf14d9cc45a750647ca5c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 14 Jul 2016 11:22:58 +0300 Subject: cmd, core, eth, miner, params, tests: finalize the DAO fork --- core/block_validator.go | 29 +------------------ core/dao.go | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ core/state_processor.go | 17 ------------ 3 files changed, 75 insertions(+), 45 deletions(-) create mode 100644 core/dao.go (limited to 'core') diff --git a/core/block_validator.go b/core/block_validator.go index 3b597310e..e5bc6178b 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -17,7 +17,6 @@ package core import ( - "bytes" "fmt" "math/big" "time" @@ -249,33 +248,7 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare } } // If all checks passed, validate the extra-data field for hard forks - return ValidateHeaderExtraData(config, header) -} - -// ValidateHeaderExtraData validates the extra-data field of a block header to -// ensure it conforms to hard-fork rules. -func ValidateHeaderExtraData(config *ChainConfig, header *types.Header) error { - // 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. - if daoBlock := 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 { - // Depending whether we support or oppose the fork, verrift 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) - } - } - } - } - return nil + return ValidateDAOHeaderExtraData(config, header) } // CalcDifficulty is the difficulty adjustment algorithm. It returns diff --git a/core/dao.go b/core/dao.go new file mode 100644 index 000000000..e315c9884 --- /dev/null +++ b/core/dao.go @@ -0,0 +1,74 @@ +// 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 . + +package core + +import ( + "bytes" + "math/big" + + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/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 *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)) + } + } +} diff --git a/core/state_processor.go b/core/state_processor.go index 6a418a62d..fd8e9762e 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -25,7 +25,6 @@ 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 ( @@ -134,19 +133,3 @@ 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)) - } - } -} -- cgit v1.2.3