Skip to content

Commit ecc71f5

Browse files
authored
fix(taiko-client): update highestUnsafeL2PayloadBlockID if reorging via POST /preconfBlocks (#19490)
1 parent 10e6770 commit ecc71f5

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

packages/taiko-client/driver/preconf_blocks/api.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,9 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
166166

167167
header := headers[0]
168168

169-
// If the block number is greater than the highest unsafe L2 payload block ID,
170-
// update the highest unsafe L2 payload block ID.
171-
if header.Number.Uint64() > s.highestUnsafeL2PayloadBlockID {
172-
s.updateHighestUnsafeL2Payload(header.Number.Uint64())
173-
}
169+
// always update the highest unsafe L2 payload block ID.
170+
// its either higher than the existing one, or we reorged.
171+
s.updateHighestUnsafeL2Payload(header.Number.Uint64())
174172

175173
// Propagate the preconfirmation block to the P2P network, if the current server
176174
// connects to the P2P network.

packages/taiko-client/driver/preconf_blocks/server.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ func (s *PreconfBlockAPIServer) TryImportingPayload(
942942
if err != nil && !errors.Is(err, ethereum.NotFound) {
943943
return false, fmt.Errorf("failed to fetch header by hash: %w", err)
944944
}
945+
945946
if header != nil {
946947
if header.Hash() == msg.ExecutionPayload.BlockHash {
947948
log.Info(
@@ -1004,11 +1005,18 @@ func (s *PreconfBlockAPIServer) TryImportingPayload(
10041005

10051006
// updateHighestUnsafeL2Payload updates the highest unsafe L2 payload block ID.
10061007
func (s *PreconfBlockAPIServer) updateHighestUnsafeL2Payload(blockID uint64) {
1007-
log.Info(
1008-
"Updating highest unsafe L2 payload block ID",
1009-
"blockID", blockID,
1010-
"currentHighestUnsafeL2PayloadBlockID", s.highestUnsafeL2PayloadBlockID,
1011-
)
1008+
if blockID > s.highestUnsafeL2PayloadBlockID {
1009+
log.Info(
1010+
"Updating highest unsafe L2 payload block ID",
1011+
"blockID", blockID,
1012+
"currentHighestUnsafeL2PayloadBlockID", s.highestUnsafeL2PayloadBlockID,
1013+
)
1014+
} else {
1015+
log.Info("Reorging highest unsafe L2 payload blockID",
1016+
"blockID", blockID,
1017+
"currentHighestUnsafeL2PayloadBlockID", s.highestUnsafeL2PayloadBlockID,
1018+
)
1019+
}
10121020
s.highestUnsafeL2PayloadBlockID = blockID
10131021
}
10141022

0 commit comments

Comments
 (0)