Skip to content

Commit

Permalink
Two fixes 1) Fix getBlock - it never actually pulled in transactions …
Browse files Browse the repository at this point in the history
…2) fix nil pointer possible deref (#14188)

* Fix getBlock - it never actually pulled in transactions

* exit with error if base fee is nil
  • Loading branch information
fxfactorial authored and alcueca committed Feb 7, 2025
1 parent 94b4c66 commit 656233b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions op-service/eth/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ func BlockAsPayload(bl *types.Block, config *params.ChainConfig) (*ExecutionPayl
}
opaqueTxs[i] = otx
}
if baseFee == nil {
return nil, fmt.Errorf("base fee was nil")
}

payload := &ExecutionPayload{
ParentHash: bl.ParentHash(),
Expand Down
22 changes: 19 additions & 3 deletions op-wheel/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,28 @@ type RPCBlock struct {
}

func getBlock(ctx context.Context, client client.RPC, method string, tag string) (*types.Block, error) {
var bl *RPCBlock
err := client.CallContext(ctx, &bl, method, tag, true)
var raw json.RawMessage
err := client.CallContext(ctx, &raw, method, tag, true)
if err != nil {
return nil, err
}
return types.NewBlockWithHeader(&bl.Header).WithBody(types.Body{Transactions: bl.Transactions}), nil

var head *types.Header
if err := json.Unmarshal(raw, &head); err != nil {
return nil, err
}

type rpcBlock struct {
Hash common.Hash `json:"hash"`
Transactions []*types.Transaction `json:"transactions"`
}

var body *rpcBlock
if err := json.Unmarshal(raw, &body); err != nil {
return nil, err
}

return types.NewBlockWithHeader(head).WithBody(types.Body{Transactions: body.Transactions}), nil
}

func getHeader(ctx context.Context, client client.RPC, method string, tag string) (*types.Header, error) {
Expand Down

0 comments on commit 656233b

Please sign in to comment.