From 31b754e14bd5416f5a62a4633b46a21add90a1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Wed, 24 May 2023 14:22:54 +0200 Subject: [PATCH] Fix transaction DA cost under-estimation (#332) * fix tx DA cost under-estimation * bump version --------- Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- params/version.go | 8 ++++---- rollup/fees/rollup_fee.go | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/params/version.go b/params/version.go index fba8c3a42d..9c9e0b65cd 100644 --- a/params/version.go +++ b/params/version.go @@ -22,10 +22,10 @@ import ( ) const ( - VersionMajor = 3 // Major version component of the current release - VersionMinor = 3 // Minor version component of the current release - VersionPatch = 1 // Patch version component of the current release - VersionMeta = "alpha" // Version metadata to append to the version string + VersionMajor = 4 // Major version component of the current release + VersionMinor = 0 // Minor version component of the current release + VersionPatch = 0 // Patch version component of the current release + VersionMeta = "sepolia" // Version metadata to append to the version string ) // Version holds the textual version string. diff --git a/rollup/fees/rollup_fee.go b/rollup/fees/rollup_fee.go index 32c8439b52..dd2a726f05 100644 --- a/rollup/fees/rollup_fee.go +++ b/rollup/fees/rollup_fee.go @@ -17,6 +17,15 @@ var ( // transaction to the L1 fee calculation routine. The signature is accounted // for externally errTransactionSigned = errors.New("transaction is signed") + + // txExtraDataBytes is the number of bytes that we commit to L1 in addition + // to the RLP-encoded unsigned transaction. Note that these are all assumed + // to be non-zero. + // - tx length prefix: 4 bytes + // - sig.r: 32 bytes + 1 byte rlp prefix + // - sig.s: 32 bytes + 1 byte rlp prefix + // - sig.v: 3 bytes + 1 byte rlp prefix + txExtraDataBytes = uint64(74) ) // Message represents the interface of a message. @@ -115,7 +124,7 @@ func CalculateL1Fee(data []byte, overhead, l1GasPrice *big.Int, scalar *big.Int) func CalculateL1GasUsed(data []byte, overhead *big.Int) *big.Int { zeroes, ones := zeroesAndOnes(data) zeroesGas := zeroes * params.TxDataZeroGas - onesGas := (ones + 68) * params.TxDataNonZeroGasEIP2028 + onesGas := (ones + txExtraDataBytes) * params.TxDataNonZeroGasEIP2028 l1Gas := new(big.Int).SetUint64(zeroesGas + onesGas) return new(big.Int).Add(l1Gas, overhead) }