Skip to content

Commit

Permalink
Block building fixes found for large deposit requests set
Browse files Browse the repository at this point in the history
  • Loading branch information
somnathb1 authored and yperbasis committed Nov 20, 2024
1 parent 65e829e commit 8712996
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 @@ -322,6 +322,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 @@ -330,7 +331,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 @@ -20,6 +20,7 @@ import (
"fmt"

libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/log/v3"
"github.com/erigontech/erigon/accounts/abi"
"github.com/erigontech/erigon/core/types"
)
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
Expand Up @@ -17,6 +17,7 @@
package builder

import (
"fmt"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -49,7 +50,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 @@ -491,6 +491,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 @@ -220,9 +220,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 8712996

Please sign in to comment.