Skip to content

Commit

Permalink
beacon: fix checks for withdrawalsRoot and withdrawals list
Browse files Browse the repository at this point in the history
  • Loading branch information
vdamle committed Dec 3, 2024
1 parent 78017c9 commit 064ff6c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions beacon/engine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
// ExecutableData before withdrawals are enabled by marshaling
// Withdrawals as the json null value.
var withdrawalsRoot *common.Hash
if config.IsOptimismIsthmus(data.Timestamp) && data.WithdrawalsRoot != nil {
if data.Withdrawals == nil || len(data.Withdrawals) != 0 {
return nil, fmt.Errorf("attribute WithdrawalsRoot was set. Expecting non-nil empty withdrawals list, but got %v", data.Withdrawals)
}
h := *data.WithdrawalsRoot // copy, avoid any sharing of memory
withdrawalsRoot = &h
} else if data.Withdrawals != nil {
if config.IsOptimismIsthmus(data.Timestamp) && data.WithdrawalsRoot == nil {
return nil, fmt.Errorf("attribute WithdrawalsRoot is required for Isthmus blocks")
}
if data.Withdrawals != nil {
h := types.DeriveSha(types.Withdrawals(data.Withdrawals), trie.NewStackTrie(nil))
withdrawalsRoot = &h
} else if data.WithdrawalsRoot != nil {
h := *data.WithdrawalsRoot // copy, avoid any sharing of memory
withdrawalsRoot = &h
}
// Compute requestsHash if any requests are non-nil.
var (
Expand Down

0 comments on commit 064ff6c

Please sign in to comment.