Skip to content

Commit 557ef50

Browse files
committed
refactor(witness): simplify base fee validation logic in batch guest input
1 parent eac9854 commit 557ef50

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

internal/witness/batch_guest_input.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ func (g *BatchGuestInput) yieldShastaGuestInputs(yield func(*Pair) bool) {
196196
proposalTimestamp := eventData.Proposal.Timestamp
197197
forkTimestamp := shastaForkTimestamp(g.Taiko.ChainSpec)
198198
isGenesisParent := g.Inputs[0].ParentHeader.Number.Uint64() == 0
199-
isFirstShastaProposal := g.Taiko.ChainSpec.activeFork(
200-
g.Inputs[0].ParentHeader.Number.Uint64(),
201-
g.Inputs[0].ParentHeader.Time,
202-
) == SpecID(PacayaHardFork) || isGenesisParent
199+
useInitBaseFee := g.Inputs[0].ParentHeader.Number.Uint64() <= 1
203200

204201
var allBlockTxs []types.Transactions
205202
for idx, dataSource := range g.Taiko.DataSources {
@@ -249,7 +246,7 @@ func (g *BatchGuestInput) yieldShastaGuestInputs(yield func(*Pair) bool) {
249246
if idx == len(g.Taiko.DataSources)-1 {
250247
// Normal source
251248
if decodeErr == nil && validateNormalProposalManifest(g, source, g.Taiko.ProverData.LastAnchorBlockNumber) {
252-
if !validateShastaBlockBaseFee(g.Inputs, isFirstShastaProposal, g.Taiko.L2GrandparentHeader) {
249+
if !validateShastaBlockBaseFee(g.Inputs, useInitBaseFee, g.Taiko.L2GrandparentHeader) {
253250
log.Warn("shasta block base fee is invalid, use default manifest")
254251
timestamp := clampTimestampLowerBound(lastParentBlockTimestamp, proposalTimestamp, forkTimestamp)
255252
coinbase := g.Taiko.BatchProposed.Proposer()
@@ -1231,7 +1228,7 @@ func calcNextShastaBaseFee(
12311228

12321229
func validateShastaBlockBaseFee(
12331230
blockGuestInputs []*SingleGuestInput,
1234-
isFirstShastaProposal bool,
1231+
useInitBaseFee bool,
12351232
l2GrandparentHeader *types.Header,
12361233
) bool {
12371234
if len(blockGuestInputs) == 0 {
@@ -1241,8 +1238,12 @@ func validateShastaBlockBaseFee(
12411238
if firstBaseFee == nil {
12421239
return false
12431240
}
1244-
if isFirstShastaProposal {
1241+
if useInitBaseFee {
12451242
if firstBaseFee.Uint64() != params.ShastaInitialBaseFee {
1243+
log.Warn("shasta block base fee is invalid",
1244+
"expected", params.ShastaInitialBaseFee,
1245+
"found", firstBaseFee.Uint64(),
1246+
)
12461247
return false
12471248
}
12481249
} else {

0 commit comments

Comments
 (0)