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>
This commit is contained in:
Péter Garamvölgyi 2023-05-24 14:22:54 +02:00 committed by GitHub
parent 060815e901
commit 31b754e14b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View file

@ -22,10 +22,10 @@ import (
) )
const ( const (
VersionMajor = 3 // Major version component of the current release VersionMajor = 4 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release VersionMinor = 0 // Minor version component of the current release
VersionPatch = 1 // Patch version component of the current release VersionPatch = 0 // Patch version component of the current release
VersionMeta = "alpha" // Version metadata to append to the version string VersionMeta = "sepolia" // Version metadata to append to the version string
) )
// Version holds the textual version string. // Version holds the textual version string.

View file

@ -17,6 +17,15 @@ var (
// transaction to the L1 fee calculation routine. The signature is accounted // transaction to the L1 fee calculation routine. The signature is accounted
// for externally // for externally
errTransactionSigned = errors.New("transaction is signed") 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. // 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 { func CalculateL1GasUsed(data []byte, overhead *big.Int) *big.Int {
zeroes, ones := zeroesAndOnes(data) zeroes, ones := zeroesAndOnes(data)
zeroesGas := zeroes * params.TxDataZeroGas zeroesGas := zeroes * params.TxDataZeroGas
onesGas := (ones + 68) * params.TxDataNonZeroGasEIP2028 onesGas := (ones + txExtraDataBytes) * params.TxDataNonZeroGasEIP2028
l1Gas := new(big.Int).SetUint64(zeroesGas + onesGas) l1Gas := new(big.Int).SetUint64(zeroesGas + onesGas)
return new(big.Int).Add(l1Gas, overhead) return new(big.Int).Add(l1Gas, overhead)
} }