Skip to content

Commit

Permalink
Fix transaction DA cost under-estimation (ethereum#332)
Browse files Browse the repository at this point in the history
* fix tx DA cost under-estimation

* bump version

---------

Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
  • Loading branch information
Thegaram and HAOYUatHZ committed May 24, 2023
1 parent 060815e commit 31b754e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions params/version.go
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion rollup/fees/rollup_fee.go
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 31b754e

Please sign in to comment.