Skip to content

Commit 1aea7c7

Browse files
committed
feat: reject txs with max l1 data fee
1 parent 5148229 commit 1aea7c7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

core/tx_pool.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
842842
if err != nil {
843843
return fmt.Errorf("failed to calculate L1 data fee, err: %w", err)
844844
}
845+
// Reject transactions that require the max data fee amount.
846+
// This can only happen if the L1 gas oracle is updated incorrectly.
847+
if l1DataFee.Cmp(fees.MaxL1DataFee) >= 0 {
848+
return errors.New("invalid transaction: invalid L1 data fee")
849+
}
845850
// Transactor should have enough funds to cover the costs
846851
// cost == L1 data fee + V + GP * GL
847852
if b := pool.currentState.GetBalance(from); b.Cmp(new(big.Int).Add(tx.Cost(), l1DataFee)) < 0 {

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 54 // Patch version component of the current release
27+
VersionPatch = 55 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/fees/rollup_fee.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ var (
2020
// to be non-zero.
2121
// - tx length prefix: 4 bytes
2222
txExtraDataBytes = uint64(4)
23+
24+
// L1 data fee cap.
25+
MaxL1DataFee = new(big.Int).SetUint64(math.MaxUint64)
2326
)
2427

2528
// Message represents the interface of a message.
@@ -248,8 +251,8 @@ func CalculateL1DataFee(tx *types.Transaction, state StateDB, config *params.Cha
248251

249252
// ensure l1DataFee fits into uint64 for circuit compatibility
250253
// (note: in practice this value should never be this big)
251-
if !l1DataFee.IsUint64() {
252-
l1DataFee.SetUint64(math.MaxUint64)
254+
if l1DataFee.Cmp(MaxL1DataFee) > 0 {
255+
l1DataFee.Set(MaxL1DataFee)
253256
}
254257

255258
return l1DataFee, nil

0 commit comments

Comments
 (0)