Documentation ¶
Index ¶
Constants ¶
const TxGasPrice uint64 = feeScalar + (feeScalar / 2)
TxGasPrice is a constant that determines the result of `eth_gasPrice` It is scaled upwards by 50% tx.gasPrice is hard coded to 1500 * wei and all transactions must set that gas price.
Variables ¶
var BigTenThousand = new(big.Int).SetUint64(tenThousand)
var BigTxGasPrice = new(big.Int).SetUint64(TxGasPrice)
BigTxGasPrice is the L2GasPrice as type big.Int
Functions ¶
func DecodeL2GasLimit ¶
DecodeL2GasLimit decodes the L2 gas limit from an encoded L2 gas limit
func DecodeL2GasLimitU64 ¶
func EncodeTxGasLimit ¶
EncodeTxGasLimit computes the `tx.gasLimit` based on the L1/L2 gas prices and the L2 gas limit. The L2 gas limit is encoded inside of the lower order bits of the number like so: [ | l2GasLimit ]
[ tx.gaslimit ]
The lower order bits must be large enough to fit the L2 gas limit, so 10**8 is chosen. If higher order bits collide with any bits from the L2 gas limit, the L2 gas limit will not be able to be decoded. An explicit design goal of this scheme was to make the L2 gas limit be human readable. The entire number is interpreted as the gas limit when computing the fee, so increasing the L2 Gas limit will increase the fee paid. The calculation is: l1GasLimit = zero_count(data) * 4 + non_zero_count(data) * 16 + overhead roundedL2GasLimit = ceilmod(l2GasLimit, 10_000) l1Fee = l1GasPrice * l1GasLimit l2Fee = l2GasPrice * roundedL2GasLimit sum = l1Fee + l2Fee scaled = sum / scalar rounded = ceilmod(scaled, tenThousand) roundedScaledL2GasLimit = roundedL2GasLimit / tenThousand result = rounded + roundedScaledL2GasLimit Note that for simplicity purposes, only the calldata is passed into this function when in reality the RLP encoded transaction should be. The additional cost is added to the overhead constant to prevent the need to RLP encode transactions during calls to `eth_estimateGas`
Types ¶
This section is empty.