Skip to content

Commit 0d597e5

Browse files
meyer9refcell
andauthored
feat: ensure requests array empty post-Isthmus (#478)
* feat: ensure requests array empty post-Isthmus * Add IsIsthmus to block config * Remove unnecessary isthmus check * Reword fix --------- Co-authored-by: refcell <[email protected]>
1 parent 03e95db commit 0d597e5

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

beacon/engine/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,16 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
297297
withdrawalsRoot = &h
298298
}
299299

300+
isthmusEnabled := bType.IsIsthmus(data.Timestamp)
300301
var requestsHash *common.Hash
301302
if requests != nil {
303+
if isthmusEnabled && len(requests) > 0 {
304+
return nil, fmt.Errorf("requests should be empty for Isthmus blocks")
305+
}
302306
h := types.CalcRequestsHash(requests)
303307
requestsHash = &h
308+
} else if isthmusEnabled {
309+
return nil, fmt.Errorf("requests must be an empty array for Isthmus blocks")
304310
}
305311

306312
header := &types.Header{

core/types/block.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ type extblock struct {
251251

252252
type BlockType interface {
253253
HasOptimismWithdrawalsRoot(blkTime uint64) bool
254+
IsIsthmus(blkTime uint64) bool
254255
}
255256

256257
// NewBlock creates a new block. The input data is copied, changes to header and to the

core/types/block_config.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package types
22

33
type BlockConfig struct {
4-
CustomWithdrawalsRoot bool
4+
IsIsthmusEnabled bool
55
}
66

77
func (bc *BlockConfig) HasOptimismWithdrawalsRoot(blockTime uint64) bool {
8-
return bc.CustomWithdrawalsRoot
8+
return bc.IsIsthmusEnabled
9+
}
10+
11+
func (bc *BlockConfig) IsIsthmus(blockTime uint64) bool {
12+
return bc.IsIsthmusEnabled
913
}
1014

1115
var (
12-
DefaultBlockConfig = &BlockConfig{CustomWithdrawalsRoot: false}
13-
IsthmusBlockConfig = &BlockConfig{CustomWithdrawalsRoot: true}
16+
DefaultBlockConfig = &BlockConfig{IsIsthmusEnabled: false}
17+
IsthmusBlockConfig = &BlockConfig{IsIsthmusEnabled: true}
1418
)

0 commit comments

Comments
 (0)