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

increase the number of bytes for calldata for L1Messenger #29

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion SystemConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"L1_TX_INTRINSIC_L2_GAS": 167157,
"L1_TX_INTRINSIC_PUBDATA": 88,
"MAX_GAS_PER_TRANSACTION": 80000000,
"BOOTLOADER_MEMORY_FOR_TXS": 485225,
"BOOTLOADER_MEMORY_FOR_TXS": 273132,
"REFUND_GAS": 7343,
"KECCAK_ROUND_COST_GAS": 40,
"SHA256_ROUND_COST_GAS": 7,
Expand Down
13 changes: 4 additions & 9 deletions bootloader/bootloader.yul
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ object "Bootloader" {
ret := {{MAX_GAS_PER_TRANSACTION}}
}

/// @dev The maximum number of pubdata bytes that can be published with one
/// L1 batch
function MAX_PUBDATA_PER_BATCH() -> ret {
ret := {{MAX_PUBDATA_PER_BATCH}}
}

/// @dev The number of L1 gas needed to be spent for
/// L1 byte. While a single pubdata byte costs `16` gas,
/// we demand at least 17 to cover up for the costs of additional
Expand Down Expand Up @@ -346,10 +340,11 @@ object "Bootloader" {
}

/// @dev Slots needed to store L1 Messenger pubdata.
/// There are 3 additional slots needed: one for L1Messengers' function signature,
/// one for such function input (calldata) array offset, one for length of the array
/// @dev Note that are many more these than the maximal pubdata in batch, since
/// it needs to also accomodate uncompressed state diffs that are required for the state diff
/// compression verification.
function OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS() -> ret {
ret := add(ceilDiv(MAX_PUBDATA_PER_BATCH(), 32), 3)
ret := {{OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS}}
}

/// @dev The slot right after the last slot of the L1 Messenger pubdata memory area.
Expand Down
9 changes: 9 additions & 0 deletions scripts/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ let params = {
FORBID_ZERO_GAS_PER_PUBDATA: 1,
SYSTEM_CONTEXT_EXPECTED_CODE_HASH: getSystemContextExpectedHash(),
UPGRADE_SYSTEM_CONTEXT_CALLDATA: upgradeSystemContextCalldata(),
// One of "worst case" scenarios for the number of state diffs in a batch is when 120kb of pubdata is spent
// on repeated writes, that are all zeroed out. In this case, the number of diffs is 120k / 5 = 24k. This means that they will have
// accoomdate 6528000 bytes of calldata for the uncompressed state diffs. Adding 120k on top leaves us with
// roughly 6650000 bytes needed for calldata. 207813 slots are needed to accomodate this amount of data.
// We round up to 208000 slots just in case.
//
// In theory though much more calldata could be used (if for instance 1 byte is used for enum index). It is the responsibility of the
// operator to ensure that it can form the correct calldata for the L1Messenger.
OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_SLOTS: 208000,
...SYSTEM_PARAMS
};

Expand Down