Skip to content

Commit ada7647

Browse files
core: faster block insertion post merge
1 parent b81fce6 commit ada7647

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

core/blockchain.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,29 +1359,6 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
13591359
prev.Hash().Bytes()[:4], i, block.NumberU64(), block.Hash().Bytes()[:4], block.ParentHash().Bytes()[:4])
13601360
}
13611361
}
1362-
if chain[len(chain)-1].Difficulty().Cmp(common.Big0) == 0 {
1363-
start := 0
1364-
for i := 0; i < len(chain); i++ {
1365-
if chain[i].Difficulty().Cmp(common.Big0) != 0 {
1366-
start++
1367-
}
1368-
}
1369-
if start != 0 {
1370-
newChain := types.Blocks(chain[0:start])
1371-
if in, err := bc.insertChain(newChain, true, true); err != nil {
1372-
return in, err
1373-
}
1374-
}
1375-
for i := start; i < len(chain); i++ {
1376-
conf := bc.GetVMConfig()
1377-
conf.RandomOpcode = true
1378-
bc.SetVMConfig(*conf)
1379-
if err := bc.InsertBlockWithoutSetHead(chain[i]); err != nil {
1380-
return len(chain), err
1381-
}
1382-
}
1383-
return len(chain), nil
1384-
}
13851362
// Pre-checks passed, start the full block imports
13861363
if !bc.chainmu.TryLock() {
13871364
return 0, errChainStopped

eth/catalyst/api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ func (api *ConsensusAPI) ExecutePayloadV1(params ExecutableDataV1) (ExecutePaylo
260260
}
261261
return ExecutePayloadResponse{Status: VALID.Status, LatestValidHash: block.Hash()}, nil
262262
}
263+
if api.eth.BlockChain().GetBlockByHash(params.BlockHash) != nil {
264+
log.Info("Ignoring already processed block", "number", params.Number, "hash", params.BlockHash)
265+
return ExecutePayloadResponse{Status: VALID.Status, LatestValidHash: block.Hash()}, nil
266+
}
263267
if !api.eth.BlockChain().HasBlock(block.ParentHash(), block.NumberU64()-1) {
264268

265269
//TODO (MariusVanDerWijden) reenable once sync is merged
@@ -437,6 +441,8 @@ func ExecutableDataToBlock(params ExecutableDataV1) (*types.Block, error) {
437441
}
438442
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */)
439443
if block.Hash() != params.BlockHash {
444+
log.Warn("Invalid Payload", "ParentHash", header.ParentHash, "UncleHash", header.UncleHash, "Coinbase", header.Coinbase, "Root", header.Root, "TxHash", header.TxHash, "ReceiptHash", header.ReceiptHash, "Bloom", header.Bloom, "Difficulty", header.Difficulty, "Number", header.Number, "GasLimit", header.GasLimit, "GasUsed", header.GasUsed, "Time", header.Time, "BaseFee", header.BaseFee, "Extra", header.Extra, "MixDigest", header.MixDigest)
445+
log.Warn("PayloadParams", "ParentHash", params.ParentHash, "Coinbase", params.FeeRecipient, "Root", params.StateRoot, "ReceiptHash", params.ReceiptsRoot, "Bloom", params.LogsBloom, "Number", params.Number, "GasLimit", params.GasLimit, "GasUsed", params.GasUsed, "Time", params.Timestamp, "BaseFee", params.BaseFeePerGas, "Extra", params.ExtraData, "MixDigest", params.Random)
440446
return nil, fmt.Errorf("blockhash mismatch, want %x, got %x", params.BlockHash, block.Hash())
441447
}
442448
return block, nil

0 commit comments

Comments
 (0)