|
|
|
@ -1221,9 +1221,9 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, [] |
|
|
|
|
|
|
|
|
|
parent := it.previous() |
|
|
|
|
if parent == nil { |
|
|
|
|
parent = bc.GetBlock(block.ParentHash(), block.NumberU64()-1) |
|
|
|
|
parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1) |
|
|
|
|
} |
|
|
|
|
state, err := state.New(parent.Root(), bc.stateCache) |
|
|
|
|
state, err := state.New(parent.Root, bc.stateCache) |
|
|
|
|
if err != nil { |
|
|
|
|
return it.index, events, coalescedLogs, err |
|
|
|
|
} |
|
|
|
@ -1236,7 +1236,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, [] |
|
|
|
|
return it.index, events, coalescedLogs, err |
|
|
|
|
} |
|
|
|
|
// Validate the state using the default validator
|
|
|
|
|
if err := bc.Validator().ValidateState(block, parent, state, receipts, usedGas); err != nil { |
|
|
|
|
if err := bc.Validator().ValidateState(block, state, receipts, usedGas); err != nil { |
|
|
|
|
bc.reportBlock(block, receipts, err) |
|
|
|
|
return it.index, events, coalescedLogs, err |
|
|
|
|
} |
|
|
|
@ -1368,7 +1368,7 @@ func (bc *BlockChain) insertSidechain(block *types.Block, it *insertIterator) (i |
|
|
|
|
// blocks to regenerate the required state
|
|
|
|
|
localTd := bc.GetTd(current.Hash(), current.NumberU64()) |
|
|
|
|
if localTd.Cmp(externTd) > 0 { |
|
|
|
|
log.Info("Sidechain written to disk", "start", it.first().NumberU64(), "end", it.previous().NumberU64(), "sidetd", externTd, "localtd", localTd) |
|
|
|
|
log.Info("Sidechain written to disk", "start", it.first().NumberU64(), "end", it.previous().Number, "sidetd", externTd, "localtd", localTd) |
|
|
|
|
return it.index, nil, nil, err |
|
|
|
|
} |
|
|
|
|
// Gather all the sidechain hashes (full blocks may be memory heavy)
|
|
|
|
@ -1376,7 +1376,7 @@ func (bc *BlockChain) insertSidechain(block *types.Block, it *insertIterator) (i |
|
|
|
|
hashes []common.Hash |
|
|
|
|
numbers []uint64 |
|
|
|
|
) |
|
|
|
|
parent := bc.GetHeader(it.previous().Hash(), it.previous().NumberU64()) |
|
|
|
|
parent := it.previous() |
|
|
|
|
for parent != nil && !bc.HasState(parent.Root) { |
|
|
|
|
hashes = append(hashes, parent.Hash()) |
|
|
|
|
numbers = append(numbers, parent.Number.Uint64()) |
|
|
|
|