Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if err != nil {
return fmt.Errorf("failed to calculate L1 data fee, err: %w", err)
}
// Reject transactions that require the max data fee amount.
// This can only happen if the L1 gas oracle is updated incorrectly.
if l1DataFee.Cmp(fees.MaxL1DataFee()) >= 0 {
return errors.New("invalid transaction: invalid L1 data fee")
}
// Transactor should have enough funds to cover the costs
// cost == L1 data fee + V + GP * GL
if b := pool.currentState.GetBalance(from); b.Cmp(new(big.Int).Add(tx.Cost(), l1DataFee)) < 0 {
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 8 // Minor version component of the current release
VersionPatch = 54 // Patch version component of the current release
VersionPatch = 55 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

Expand Down
11 changes: 9 additions & 2 deletions rollup/fees/rollup_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ var (
// to be non-zero.
// - tx length prefix: 4 bytes
txExtraDataBytes = uint64(4)

// L1 data fee cap.
l1DataFeeCap = new(big.Int).SetUint64(math.MaxUint64)
)

func MaxL1DataFee() *big.Int {
return new(big.Int).Set(l1DataFeeCap)
}

// Message represents the interface of a message.
// It should be a subset of the methods found on
// types.Message
Expand Down Expand Up @@ -248,8 +255,8 @@ func CalculateL1DataFee(tx *types.Transaction, state StateDB, config *params.Cha

// ensure l1DataFee fits into uint64 for circuit compatibility
// (note: in practice this value should never be this big)
if !l1DataFee.IsUint64() {
l1DataFee.SetUint64(math.MaxUint64)
if l1DataFee.Cmp(l1DataFeeCap) > 0 {
l1DataFee = new(big.Int).Set(l1DataFeeCap)
}

return l1DataFee, nil
Expand Down
Loading