Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the conformance tests after my refactoring #83

Merged
merged 1 commit into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,10 @@ func execToBlock(block int) {
blocks = types.Blocks{}
}
}
tds := bc.GetTrieDbState()
tds, err := bc.GetTrieDbState()
if err != nil {
panic(err)
}
root := tds.LastRoot()
fmt.Printf("Root hash: %x\n", root)
fmt.Printf("Last block root hash: %x\n", lastBlock.Root())
Expand Down
12 changes: 7 additions & 5 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,22 @@ func (bc *BlockChain) EnableReceipts(er bool) {
bc.enableReceipts = er
}

func (bc *BlockChain) GetTrieDbState() *state.TrieDbState {
func (bc *BlockChain) GetTrieDbState() (*state.TrieDbState, error) {
if bc.trieDbState == nil {
currentBlockNr := bc.CurrentBlock().NumberU64()
log.Info("Creating IntraBlockState from latest state", "block", currentBlockNr)
var err error
bc.trieDbState, err = state.NewTrieDbState(bc.CurrentBlock().Header().Root, bc.db, currentBlockNr)
if err != nil {
panic(err)
return nil, err
}
bc.trieDbState.SetNoHistory(bc.noHistory)
bc.trieDbState.SetResolveReads(bc.resolveReads)
if err := bc.trieDbState.Rebuild(); err != nil {
panic(err)
return nil, err
}
}
return bc.trieDbState
return bc.trieDbState, nil
}

func (bc *BlockChain) getProcInterrupt() bool {
Expand Down Expand Up @@ -1272,7 +1272,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
readBlockNr := parentNumber
var root common.Hash
if bc.trieDbState == nil {
bc.GetTrieDbState()
if _, err = bc.GetTrieDbState(); err != nil {
return k, events, coalescedLogs, err
}
}
root = bc.trieDbState.LastRoot()
var parentRoot common.Hash
Expand Down
5 changes: 4 additions & 1 deletion eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,10 @@ func (pm *ProtocolManager) handleFirehoseMsg(p *firehosePeer) error {
block := pm.blockchain.GetBlockByHash(blockHash)
if block != nil {
// TODO [yperbasis] The concurrency, stupid!
tds := pm.blockchain.GetTrieDbState()
tds, err := pm.blockchain.GetTrieDbState()
if err != nil {
return err
}
tr := tds.AccountTrie()

// Gather nodes until the fetch or network limit is reached
Expand Down