Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Enhance testing for the short term fee model #95

Open
wants to merge 1 commit into
base: sb-short-term-fee-model
Choose a base branch
from
Open
Changes from all commits
Commits
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
48 changes: 48 additions & 0 deletions bootloader/tests/bootloader/bootloader_test.yul
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,51 @@ function TEST_simple_transaction() {
let innerTxDataOffset := add(txDataOffset, 0x20)
testing_assertEq(getGasPerPubdataByteLimit(innerTxDataOffset), 0xc350, "Invalid pubdata limit")
}

function TEST_getTransactionUpfrontOverhead() {
// For very large transactions it should be proportional to the memory,
// but for small ones, the transaction slots are more important

let smallTxOverhead := getTransactionUpfrontOverhead(32)
let largeTxOverhead := getTransactionUpfrontOverhead(1000000)

testing_assertEq(smallTxOverhead, TX_SLOT_OVERHEAD_GAS(), "Invalid small tx overhead")
testing_assertEq(largeTxOverhead, mul(1000000, MEMORY_OVERHEAD_GAS()), "Invalid small tx overhead")
}

function TEST_getFeeParams_HighPubdataPrice() {
// Under very large L1 gas price, the L2 base fee will start rising to ensure the
// boundary on the gasLimit

// 15k gwei L1 pubdata price
let veryHighL1PubdataPrice := 15000000000000
// 0.1 gwei L2 base fee
let l2GasPrice := 100000000

let baseFee, gasPricePerPubdata := getFeeParams(
veryHighL1PubdataPrice,
// 0.1 gwei L2 base fee
l2GasPrice
)

testing_assertEq(baseFee, div(veryHighL1PubdataPrice, MAX_L2_GAS_PER_PUBDATA()), "Invalid base fee")
testing_assertEq(gasPricePerPubdata, MAX_L2_GAS_PER_PUBDATA(), "Invalid gasPricePerPubdata")
}

function TEST_getFeeParams_LowPubdataPrice() {
// Under low to medium pubdata price, the baseFee is equal to the fair gas price,
// while the gas per pubdata pubdata is derived by strict division

// 0.2 gwei L1 pubdata price
let veryLowL1GasPrice := 200000000
// 0.1 gwei L2 base fee
let l2GasPrice := 100000000

let baseFee, gasPricePerPubdata := getFeeParams(
veryLowL1GasPrice,
l2GasPrice
)

testing_assertEq(baseFee, l2GasPrice, "Invalid base fee")
testing_assertEq(gasPricePerPubdata, div(veryLowL1GasPrice, l2GasPrice), "Invalid gasPricePerPubdata")
}
Loading