Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3d50dd1
Change l1DataFee to rollupFee for Feynman
ranchalp Jun 7, 2025
98f41d7
Update CommitScalarSlot to ExecScalarSlot
ranchalp Jun 7, 2025
90bd9f4
Rename l1DataFee to rollupFee
ranchalp Jun 9, 2025
49574cb
Scale compression ratio to match scalars precision
ranchalp Jun 9, 2025
685e4ba
Use l1DataFee and commitScalar instead of rollupFee and execScalar
ranchalp Jun 10, 2025
b221a0c
Merge branch 'develop' into l1data-to-rollupfee
ranchalp Jun 10, 2025
a39317a
Merge branch 'develop' into l1data-to-rollupfee
ranchalp Jun 11, 2025
ce2498e
Use blocktime not blocknumber
ranchalp Jun 11, 2025
2b061e4
Add unit test
ranchalp Jun 11, 2025
c3c5595
Clarify test comment
ranchalp Jun 11, 2025
61af023
feat(feynman): upgrade gas oracle predeploy
Thegaram Jun 24, 2025
080cbf3
Merge branch 'develop' into l1data-to-rollupfee
colinlyguo Jun 24, 2025
93f9920
Merge branch 'feat-feynman-gas-oracle' into l1data-to-rollupfee
colinlyguo Jun 24, 2025
393d6c1
address comments
Jun 24, 2025
b93d2c1
revert renaming CalculateL1DataFee to CalculateRollupFee
Jun 24, 2025
9808365
simplify EstimateL1DataFeeForMessage
Jun 24, 2025
3156b02
address comments
Jun 24, 2025
5039d30
add a comment based on pr reviews
Jun 24, 2025
7d7a9b6
update formula
Jun 24, 2025
a36f63c
tweaks
Jun 24, 2025
b621be4
tweak comments
Jun 25, 2025
872ccf5
Estimate compression ratio at rollupFee for Feynman (#1197)
ranchalp Jun 25, 2025
1fbe3ea
refactoring
Jun 25, 2025
8df47a2
Merge branch 'develop' into l1data-to-rollupfee
Thegaram Jun 25, 2025
dd262c1
remove incorrect merge artifact
Thegaram Jun 25, 2025
bd7f658
error handling
Jun 25, 2025
ee255a4
update da-codec commit
Jun 25, 2025
bad7cac
update da-codec commit
Jun 26, 2025
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 params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,11 @@ func (c *ChainConfig) IsEuclidV2(now uint64) bool {
return isForkedTime(now, c.EuclidV2Time)
}

// IsFeynman returns whether num is either equal to the Feynman fork block or greater.
func (c *ChainConfig) IsFeynman(num *big.Int) bool {
return false // placeholder
}

// IsTerminalPoWBlock returns whether the given block is the last block of PoW stage.
func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *big.Int) bool {
if c.TerminalTotalDifficulty == nil {
Expand Down
46 changes: 41 additions & 5 deletions rollup/fees/rollup_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ func EstimateL1DataFeeForMessage(msg Message, baseFee *big.Int, config *params.C

gpoState := readGPOStorageSlots(rcfg.L1GasPriceOracleAddress, state)

var l1DataFee *big.Int
var rollupFee *big.Int

if !config.IsCurie(blockNumber) {
l1DataFee = calculateEncodedL1DataFee(raw, gpoState.overhead, gpoState.l1BaseFee, gpoState.scalar)
rollupFee = calculateEncodedL1DataFee(raw, gpoState.overhead, gpoState.l1BaseFee, gpoState.scalar)
} else if !config.IsFeynman(blockNumber) {
rollupFee = calculateEncodedL1DataFeeCurie(raw, gpoState.l1BaseFee, gpoState.l1BlobBaseFee, gpoState.commitScalar, gpoState.blobScalar)
} else {
l1DataFee = calculateEncodedL1DataFeeCurie(raw, gpoState.l1BaseFee, gpoState.l1BlobBaseFee, gpoState.commitScalar, gpoState.blobScalar)
rollupFee = calculateEncodedL1DataFeeFeynman(raw, gpoState.l1BaseFee, gpoState.l1BlobBaseFee, gpoState.commitScalar, gpoState.blobScalar)
}

return l1DataFee, nil
return rollupFee, nil
}

// asUnsignedTx turns a Message into a types.Transaction
Expand Down Expand Up @@ -193,6 +195,38 @@ func calculateEncodedL1DataFeeCurie(data []byte, l1BaseFee *big.Int, l1BlobBaseF
return l1DataFee
}

// calculateEncodedL1DataFeeFeynman computes the L1 fee for an RLP-encoded tx, post Feynman
func calculateEncodedL1DataFeeFeynman(
data []byte,
l1BaseFee *big.Int,
l1BlobBaseFee *big.Int,
execScalar *big.Int,
blobScalar *big.Int,
) *big.Int {
// tx size (RLP-encoded)
txSize := big.NewInt(int64(len(data)))

// compression_ratio(tx) = 1 (placeholder, scaled to match scalars precision)
compressionRatio := big.NewInt(rcfg.Precision.Int64())

// compute gas components
execGas := new(big.Int).Mul(execScalar, l1BaseFee)
blobGas := new(big.Int).Mul(blobScalar, l1BlobBaseFee)

// fee per byte = execGas + blobGas
feePerByte := new(big.Int).Add(execGas, blobGas)

// l1DataFee = compression_ratio * tx_size * feePerByte
l1DataFee := new(big.Int).Mul(compressionRatio, txSize)
l1DataFee.Mul(l1DataFee, feePerByte)

// Divide by rcfg.Precision (once for ratio, once for scalar)
l1DataFee.Div(l1DataFee, rcfg.Precision)
l1DataFee.Div(l1DataFee, rcfg.Precision)

return l1DataFee
}

// calculateL1GasUsed computes the L1 gas used based on the calldata and
// constant sized overhead. The overhead can be decreased as the cost of the
// batch submission goes down via contract optimizations. This will not overflow
Expand Down Expand Up @@ -242,8 +276,10 @@ func CalculateL1DataFee(tx *types.Transaction, state StateDB, config *params.Cha

if !config.IsCurie(blockNumber) {
l1DataFee = calculateEncodedL1DataFee(raw, gpoState.overhead, gpoState.l1BaseFee, gpoState.scalar)
} else {
} else if !config.IsFeynman(blockNumber) {
l1DataFee = calculateEncodedL1DataFeeCurie(raw, gpoState.l1BaseFee, gpoState.l1BlobBaseFee, gpoState.commitScalar, gpoState.blobScalar)
} else {
l1DataFee = calculateEncodedL1DataFeeFeynman(raw, gpoState.l1BaseFee, gpoState.l1BlobBaseFee, gpoState.commitScalar, gpoState.blobScalar)
}

// ensure l1DataFee fits into uint64 for circuit compatibility
Expand Down
Loading