Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
State trie clearing fix (#82)
Browse files Browse the repository at this point in the history
* Fixed commit state trie clearing detail

* Added stc to miner work state committing
  • Loading branch information
austinabell authored Jul 2, 2019
1 parent 91521e7 commit 338747b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func run(ctx *cli.Context) error {
vmdone := time.Since(tstart)

if ctx.GlobalBool(DumpFlag.Name) {
statedb.CommitTo(db, false)
statedb.IntermediateRoot(true)
statedb.CommitTo(db, true)
fmt.Println(string(statedb.Dump([]common.Address{})))
}

Expand Down
4 changes: 2 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"github.com/eth-classic/go-ethereum/pow"
"github.com/eth-classic/go-ethereum/rlp"
"github.com/eth-classic/go-ethereum/trie"
"github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru"
)

var (
Expand Down Expand Up @@ -1655,7 +1655,7 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (res *ChainInsertResult) {
return
}
// Write state changes to database
_, err = bc.stateCache.CommitTo(bc.chainDb, false)
_, err = bc.stateCache.CommitTo(bc.chainDb, bc.config.IsAtlantis(block.Number()))
if err != nil {
res.Error = err
return
Expand Down
2 changes: 1 addition & 1 deletion core/chain_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func GenerateChain(config *ChainConfig, parent *types.Block, db ethdb.Database,
gen(i, b)
}
AccumulateRewards(config, statedb, h, b.uncles)
root, err := statedb.CommitTo(db, false)
root, err := statedb.CommitTo(db, config.IsAtlantis(b.header.Number))
if err != nil {
panic(fmt.Sprintf("state write error: %v", err))
}
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (self *worker) wait() {
}
go self.mux.Post(core.NewMinedBlockEvent{Block: block})
} else {
work.state.CommitTo(self.chainDb, false)
work.state.CommitTo(self.chainDb, work.config.IsAtlantis(block.Number()))
parent := self.chain.GetBlock(block.ParentHash())
if parent == nil {
glog.V(logger.Error).Infoln("Invalid block found during mining")
Expand Down

0 comments on commit 338747b

Please sign in to comment.