Skip to content

Commit

Permalink
Block building fixes found for large deposit requests set (#12804)
Browse files Browse the repository at this point in the history
- Add requests sidecar to Seal func
- Additional logging for better debugging on live networks
- Fix issue with requests in getPayload API
  • Loading branch information
somnathb1 authored Nov 20, 2024
1 parent f475cc4 commit 2148546
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion consensus/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func (s *Merge) verifyHeader(chain consensus.ChainHeaderReader, header, parent *
func (s *Merge) Seal(chain consensus.ChainHeaderReader, blockWithReceipts *types.BlockWithReceipts, results chan<- *types.BlockWithReceipts, stop <-chan struct{}) error {
block := blockWithReceipts.Block
receipts := blockWithReceipts.Receipts
requests := blockWithReceipts.Requests
if !misc.IsPoSHeader(block.HeaderNoCopy()) {
return s.eth1Engine.Seal(chain, blockWithReceipts, results, stop)
}
Expand All @@ -305,7 +306,7 @@ func (s *Merge) Seal(chain consensus.ChainHeaderReader, blockWithReceipts *types
header.Nonce = ProofOfStakeNonce

select {
case results <- &types.BlockWithReceipts{Block: block.WithSeal(header), Receipts: receipts}:
case results <- &types.BlockWithReceipts{Block: block.WithSeal(header), Receipts: receipts, Requests: requests}:
default:
log.Warn("Sealing result is not read", "sealhash", block.Hash())
}
Expand Down
4 changes: 4 additions & 0 deletions consensus/misc/eip6110.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/accounts/abi"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/log/v3"
)

const (
Expand Down Expand Up @@ -71,6 +72,9 @@ func unpackDepositLog(data []byte) ([]byte, error) {
// ParseDepositLogs extracts the EIP-6110 deposit values from logs emitted by
// BeaconDepositContract and returns a FlatRequest object ptr
func ParseDepositLogs(logs []*types.Log, depositContractAddress libcommon.Address) (*types.FlatRequest, error) {
if depositContractAddress == (libcommon.Address{}) {
log.Warn("Error in ParseDepositLogs - depositContractAddress is 0x0")
}
reqData := make([]byte, 0, len(logs)*types.DepositRequestDataLen)
for _, l := range logs {
if l.Address == depositContractAddress {
Expand Down
7 changes: 6 additions & 1 deletion turbo/builder/block_builder.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package builder

import (
"fmt"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -33,7 +34,11 @@ func NewBlockBuilder(build BlockBuilderFunc, param *core.BlockBuilderParameters)
log.Warn("Failed to build a block", "err", err)
} else {
block := result.Block
log.Info("Built block", "hash", block.Hash(), "height", block.NumberU64(), "txs", len(block.Transactions()), "gas used %", 100*float64(block.GasUsed())/float64(block.GasLimit()), "time", time.Since(t))
reqLenStr := "nil"
if len(result.Requests) == 3 {
reqLenStr = fmt.Sprint("Deposit Requests", len(result.Requests[0].RequestData), "Withdrawal Requests", len(result.Requests[1].RequestData), "Consolidation Requests", len(result.Requests[2].RequestData))
}
log.Info("Built block", "hash", block.Hash(), "height", block.NumberU64(), "txs", len(block.Transactions()), "executionRequests", len(result.Requests), "Requests", reqLenStr, "gas used %", 100*float64(block.GasUsed())/float64(block.GasLimit()), "time", time.Since(t))
}

builder.syncCond.L.Lock()
Expand Down
3 changes: 3 additions & 0 deletions turbo/engineapi/engine_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ func (s *EngineServer) getPayload(ctx context.Context, payloadId uint64, version
var executionRequests []hexutility.Bytes
if version >= clparams.ElectraVersion {
executionRequests = make([]hexutility.Bytes, len(types.KnownRequestTypes))
if len(data.Requests.Requests) != 3 {
s.logger.Warn("Error in getPayload - data.Requests.Requests len not 3")
}
for i := 0; i < len(types.KnownRequestTypes); i++ {
if len(data.Requests.Requests) < i+1 || data.Requests.Requests[i] == nil {
executionRequests[i] = make(hexutility.Bytes, 0)
Expand Down
4 changes: 3 additions & 1 deletion turbo/execution/eth1/block_building.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ func (e *EthereumExecutionModule) GetAssembledBlock(ctx context.Context, req *ex
requests := make([][]byte, len(types.KnownRequestTypes))
if len(blockWithReceipts.Requests) == len(types.KnownRequestTypes) {
for i, r := range blockWithReceipts.Requests {
requests[i] = r.RequestData
requests[i] = make([]byte, 0)
requests[i] = append(requests[i], r.RequestData...)
}
} else {
e.logger.Error("Requests len SHOULD BE", "equal to", len(types.KnownRequestTypes), "got", len(blockWithReceipts.Requests))
for i := 0; i < len(types.KnownRequestTypes); i++ {
requests[i] = make([]byte, 0)
}
Expand Down

0 comments on commit 2148546

Please sign in to comment.