Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
bing bong
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Nov 1, 2023
1 parent 25f11a7 commit 7fa7794
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions eth/core/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,39 @@ func (bc *blockchain) InsertGenesisBlock(block *types.Block) error {
if block.NumberU64() != 0 {
return errors.New("not the genesis block")
}
return bc.InsertBlockWithoutSetHead(block)
_, err := bc.WriteBlockAndSetHead(block, nil, nil, nil, true)
return err
}

// InsertBlockWithoutSetHead inserts a block into the blockchain without setting the head.
// For now, it is a huge lie. It does infact set the head.
func (bc *blockchain) InsertBlockWithoutSetHead(block *types.Block) error {
// Validate that we are about to insert a valid block.
if block.NumberU64() > 0 {
if err := bc.validator.ValidateBody(block); err != nil {
log.Error("invalid block body", "err", err)
return err
}
if err := bc.validator.ValidateBody(block); err != nil {
log.Error("invalid block body", "err", err)
return err
}

// Process the incoming EVM block.
receipts, logs, _, err := bc.processor.Process(block, bc.statedb, *bc.vmConfig)
receipts, logs, usedGas, err := bc.processor.Process(block, bc.statedb, *bc.vmConfig)
if err != nil {
log.Error("failed to process block", "num", block.NumberU64())
return err
}

// ValidateState validates the statedb post block processing.
if err = bc.validator.ValidateState(block, bc.statedb, receipts, usedGas); err != nil {
log.Error("invalid state after processing block", "num", block.NumberU64())
return err
}

// We can just immediately finalize the block. It's okay in this context.
var status core.WriteStatus
if status, err = bc.WriteBlockAndSetHead(
if _, err = bc.WriteBlockAndSetHead(
block, receipts, logs, nil, true); err != nil {
log.Error("failed to write block", "num", block.NumberU64())
return err
}

// todo use status for something
_ = status

return err
}

Expand Down

0 comments on commit 7fa7794

Please sign in to comment.