Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@
#define AVM_TORADIXBE_DYN_L2_GAS 3
#define AVM_BITWISE_DYN_L2_GAS 3
#define AVM_EMITPUBLICLOG_DYN_L2_GAS 3
#define AVM_EMITNOTEHASH_BASE_DA_GAS 512
#define AVM_EMITNULLIFIER_BASE_DA_GAS 512
#define AVM_SENDL2TOL1MSG_BASE_DA_GAS 512
#define AVM_EMITPUBLICLOG_BASE_DA_GAS 1024
#define AVM_EMITPUBLICLOG_DYN_DA_GAS 512
#define AVM_SSTORE_DYN_DA_GAS 1024
#define AVM_EMITNOTEHASH_BASE_DA_GAS 32
#define AVM_EMITNULLIFIER_BASE_DA_GAS 32
#define AVM_SENDL2TOL1MSG_BASE_DA_GAS 32
#define AVM_EMITPUBLICLOG_BASE_DA_GAS 64
#define AVM_EMITPUBLICLOG_DYN_DA_GAS 32
#define AVM_SSTORE_DYN_DA_GAS 64
#define AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_HEIGHT 6
#define AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_INITIAL_ROOT \
"0x2870b93163d4fd6ada360fe48ee1e8e8e69308af34cdfaeffacbbe5929e2466d"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AvmHardCodedVKAndHash {
using FF = bb::curve::BN254::ScalarField;

// Precomputed VK hash (hash of all commitments below).
static FF vk_hash() { return FF(uint256_t("0x1f47e68404e58fcde864ff61573d61acab5832efb230f9a32ae68044d31dfd19")); }
static FF vk_hash() { return FF(uint256_t("0x02296b934ced1a5cdacae120d2032d88a119bdb0738d4c4f3ada4f5a831a5153")); }

static constexpr std::array<Commitment, NUM_PRECOMPUTED_ENTITIES> get_all()
{
Expand Down Expand Up @@ -59,13 +59,13 @@ class AvmHardCodedVKAndHash {
uint256_t(
"0x09f2eef32136799118634a108531dc248506d5f58f64885575b245865b56d48e")), // precomputed_exec_opcode
Commitment(
uint256_t("0x0188169f0225c14e925347c4f9f192d191b2ab6ca2fbc1d0453f48af5d9c667b"),
uint256_t("0x09bd44905d676585d8c7a91c8ba8fd6b1b598326cb80b95e80b4b39703c7e2c8"),
uint256_t(
"0x25b997de6f92af3ea3b409b41437fea01980b344a12fabc6b833656f26d6e954")), // precomputed_exec_opcode_base_da_gas
"0x1bec3a67476715f88745bc09b1ea57859c8fe809fae4376efab6ba773ea7f6d4")), // precomputed_exec_opcode_base_da_gas
Commitment(
uint256_t("0x1ddbbb27c627edafce021d5f332867ac9234c6f507442633bff9a5dbb4d02803"),
uint256_t("0x0f5b3fee86f9815eb0be052412de7f2a4c82f678604ba9e161c4412529810057"),
uint256_t(
"0x10fda7a2360b21bbfbb1e815377adc0fa869bbcb4a46b29c31ae017893fdfb0d")), // precomputed_exec_opcode_dynamic_da_gas
"0x1ad065dec1d51664807b4d551d0eb8abe0b061b8380dde6d662e2df36a1f85c8")), // precomputed_exec_opcode_dynamic_da_gas
Commitment(
uint256_t("0x06c03e425e92d09aa8243220a0968b4d7d00c89e541a2b6095920883a8a6fa72"),
uint256_t(
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use types::{
abis::{gas::Gas, kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs},
constants::{
AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS,
DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS,
L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH,
L2_GAS_PER_NULLIFIER, L2_GAS_PER_PRIVATE_LOG,
DA_GAS_PER_FIELD, FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG,
L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, L2_GAS_PER_PRIVATE_LOG,
},
traits::Empty,
};
Expand Down Expand Up @@ -88,7 +87,7 @@ pub fn meter_gas_used(public_inputs: PrivateKernelCircuitPublicInputs, is_for_pu
public_inputs.constants.tx_context.gas_settings.teardown_gas_limits
};

let metered_da_gas = metered_da_fields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let metered_da_gas = metered_da_fields * DA_GAS_PER_FIELD;

Gas::tx_overhead() + Gas::new(metered_da_gas, metered_l2_gas) + teardown_gas
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ use super::TestBuilder;
use types::{
abis::gas::Gas,
constants::{
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE,
L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH,
L2_GAS_PER_NULLIFIER, L2_GAS_PER_PRIVATE_LOG, MAX_CONTRACT_CLASS_LOGS_PER_TX,
MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX,
MAX_PRIVATE_LOGS_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS,
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, DA_GAS_PER_FIELD, L2_GAS_PER_CONTRACT_CLASS_LOG,
L2_GAS_PER_L2_TO_L1_MSG, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER, L2_GAS_PER_PRIVATE_LOG,
MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX,
MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS,
},
};

/// A minimum (private) tx initialized in the TestBuilder contains a protocol nullifier, which must exist in every tx.
fn get_minimum_private_tx_gas_used() -> Gas {
let nullifier_gas_used =
Gas { da_gas: DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE, l2_gas: L2_GAS_PER_NULLIFIER };
let nullifier_gas_used = Gas { da_gas: DA_GAS_PER_FIELD, l2_gas: L2_GAS_PER_NULLIFIER };
Gas::tx_overhead() + nullifier_gas_used
}

Expand All @@ -30,7 +28,7 @@ fn with_note_hashes() {

builder.previous_kernel.append_siloed_note_hashes(3);

let da_gas = 3 * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = 3 * DA_GAS_PER_FIELD;
let l2_gas = 3 * L2_GAS_PER_NOTE_HASH;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_private_tx_gas_used();

Expand All @@ -44,7 +42,7 @@ fn with_nullifiers() {

builder.previous_kernel.append_siloed_nullifiers(5);

let da_gas = 5 * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = 5 * DA_GAS_PER_FIELD;
let l2_gas = 5 * L2_GAS_PER_NULLIFIER;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_private_tx_gas_used();

Expand All @@ -58,7 +56,7 @@ fn with_l2_to_l1_msgs() {

builder.previous_kernel.append_l2_to_l1_msgs(3);

let da_gas = 3 * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = 3 * DA_GAS_PER_FIELD;
let l2_gas = 3 * L2_GAS_PER_L2_TO_L1_MSG;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_private_tx_gas_used();

Expand All @@ -74,8 +72,7 @@ fn with_private_logs() {
builder.previous_kernel.append_siloed_private_logs_with_lengths([2, 5, 1, 7]);

let da_gas = (2 + 5 + 1 + 7 + 4) // +4 for the length field of each private log.
* DA_BYTES_PER_FIELD
* DA_GAS_PER_BYTE;
* DA_GAS_PER_FIELD;
let l2_gas = 4 * L2_GAS_PER_PRIVATE_LOG;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_private_tx_gas_used();

Expand All @@ -90,8 +87,7 @@ fn with_contract_class_logs() {
builder.previous_kernel.append_contract_class_logs_with_lengths([11]);

let da_gas = (11 + 1) // +1 for the contract address.
* DA_BYTES_PER_FIELD
* DA_GAS_PER_BYTE;
* DA_GAS_PER_FIELD;
let l2_gas = 1 * L2_GAS_PER_CONTRACT_CLASS_LOG;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_private_tx_gas_used();

Expand All @@ -108,19 +104,19 @@ fn full_side_effects() {
// Note hashes.
builder.previous_kernel.append_siloed_note_hashes(MAX_NOTE_HASHES_PER_TX);
expected_gas_used += Gas {
da_gas: MAX_NOTE_HASHES_PER_TX * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE,
da_gas: MAX_NOTE_HASHES_PER_TX * DA_GAS_PER_FIELD,
l2_gas: MAX_NOTE_HASHES_PER_TX * L2_GAS_PER_NOTE_HASH,
};
// Nullifiers.
builder.previous_kernel.append_siloed_nullifiers(MAX_NULLIFIERS_PER_TX - 1); // -1 for the pre-added protocol nullifier.
expected_gas_used += Gas {
da_gas: MAX_NULLIFIERS_PER_TX * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE,
da_gas: MAX_NULLIFIERS_PER_TX * DA_GAS_PER_FIELD,
l2_gas: MAX_NULLIFIERS_PER_TX * L2_GAS_PER_NULLIFIER,
};
// L2 to L1 messages.
builder.previous_kernel.append_l2_to_l1_msgs(MAX_L2_TO_L1_MSGS_PER_TX);
expected_gas_used += Gas {
da_gas: MAX_L2_TO_L1_MSGS_PER_TX * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE,
da_gas: MAX_L2_TO_L1_MSGS_PER_TX * DA_GAS_PER_FIELD,
l2_gas: MAX_L2_TO_L1_MSGS_PER_TX * L2_GAS_PER_L2_TO_L1_MSG,
};
// Private logs.
Expand All @@ -130,8 +126,7 @@ fn full_side_effects() {
expected_gas_used += Gas {
da_gas: (PRIVATE_LOG_SIZE_IN_FIELDS + 1) // +1 for the length field.
* MAX_PRIVATE_LOGS_PER_TX
* DA_BYTES_PER_FIELD
* DA_GAS_PER_BYTE,
* DA_GAS_PER_FIELD,
l2_gas: MAX_PRIVATE_LOGS_PER_TX * L2_GAS_PER_PRIVATE_LOG,
};
// Contract class logs.
Expand All @@ -143,8 +138,7 @@ fn full_side_effects() {
expected_gas_used += Gas {
da_gas: (CONTRACT_CLASS_LOG_SIZE_IN_FIELDS + 1) // +1 for the contract address.
* MAX_CONTRACT_CLASS_LOGS_PER_TX
* DA_BYTES_PER_FIELD
* DA_GAS_PER_BYTE,
* DA_GAS_PER_FIELD,
l2_gas: MAX_CONTRACT_CLASS_LOGS_PER_TX * L2_GAS_PER_CONTRACT_CLASS_LOG,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ use types::{
abis::gas::Gas,
constants::{
AVM_EMITNOTEHASH_BASE_L2_GAS, AVM_EMITNULLIFIER_BASE_L2_GAS, AVM_SENDL2TOL1MSG_BASE_L2_GAS,
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE,
FIXED_AVM_STARTUP_L2_GAS, L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_PRIVATE_LOG,
MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX,
MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX,
PRIVATE_LOG_SIZE_IN_FIELDS,
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, DA_GAS_PER_FIELD, FIXED_AVM_STARTUP_L2_GAS,
L2_GAS_PER_CONTRACT_CLASS_LOG, L2_GAS_PER_PRIVATE_LOG, MAX_CONTRACT_CLASS_LOGS_PER_TX,
MAX_ENQUEUED_CALLS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX,
MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS,
},
};

Expand All @@ -16,7 +15,7 @@ use types::{
/// - a public call request, that's what makes it a "public" tx.
fn get_minimum_public_tx_gas_used() -> Gas {
let nullifier_gas_used =
Gas { da_gas: DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE, l2_gas: AVM_EMITNULLIFIER_BASE_L2_GAS };
Gas { da_gas: DA_GAS_PER_FIELD, l2_gas: AVM_EMITNULLIFIER_BASE_L2_GAS };
let public_call_gas_used = Gas { da_gas: 0, l2_gas: FIXED_AVM_STARTUP_L2_GAS };
Gas::tx_overhead() + nullifier_gas_used + public_call_gas_used
}
Expand Down Expand Up @@ -75,7 +74,7 @@ fn with_note_hashes() {

let num_note_hashes = 2 /* non-revertible */
+ 3 /* revertible */;
let da_gas = num_note_hashes * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_note_hashes * DA_GAS_PER_FIELD;
let l2_gas = num_note_hashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_public_tx_gas_used();

Expand All @@ -93,7 +92,7 @@ fn with_nullifiers() {

let num_nullifiers = 2 /* non-revertible */
+ 3 /* revertible */;
let da_gas = num_nullifiers * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_nullifiers * DA_GAS_PER_FIELD;
let l2_gas = num_nullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_public_tx_gas_used();

Expand All @@ -111,7 +110,7 @@ fn with_l2_to_l1_msgs() {

let num_msgs = 2 /* non-revertible */
+ 3 /* revertible */;
let da_gas = num_msgs * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_msgs * DA_GAS_PER_FIELD;
let l2_gas = num_msgs * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_public_tx_gas_used();

Expand All @@ -133,7 +132,7 @@ fn with_private_logs() {
let num_private_logs = 2 /* non-revertible */
+ 3 /* revertible */;
let num_fields = 4 + 3 + 2 + 6 + 1 + num_private_logs; // +num_private_logs for the length field of each private log.
let da_gas = num_fields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_fields * DA_GAS_PER_FIELD;
let l2_gas = num_private_logs * L2_GAS_PER_PRIVATE_LOG;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_public_tx_gas_used();

Expand All @@ -149,7 +148,7 @@ fn with_non_revertible_contract_class_logs() {

let num_logs = 1;
let num_fields = 12 + 1; // +1 for the contract address.
let da_gas = num_fields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_fields * DA_GAS_PER_FIELD;
let l2_gas = num_logs * L2_GAS_PER_CONTRACT_CLASS_LOG;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_public_tx_gas_used();

Expand All @@ -166,7 +165,7 @@ fn with_revertible_contract_class_logs() {

let num_logs = 1;
let num_fields = 12 + 1; // +1 for the contract address.
let da_gas = num_fields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_fields * DA_GAS_PER_FIELD;
let l2_gas = num_logs * L2_GAS_PER_CONTRACT_CLASS_LOG;
let expected_gas_used = Gas::new(da_gas, l2_gas) + get_minimum_public_tx_gas_used();

Expand Down Expand Up @@ -230,7 +229,7 @@ fn full_side_effects() {
+ MAX_L2_TO_L1_MSGS_PER_TX
+ (PRIVATE_LOG_SIZE_IN_FIELDS + 1) * MAX_PRIVATE_LOGS_PER_TX // +1 for the length field of each private log.
+ (CONTRACT_CLASS_LOG_SIZE_IN_FIELDS + 1) * MAX_CONTRACT_CLASS_LOGS_PER_TX; // +1 for the contract address.
let da_gas = num_da_fields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
let da_gas = num_da_fields * DA_GAS_PER_FIELD;
let l2_gas = MAX_NOTE_HASHES_PER_TX * AVM_EMITNOTEHASH_BASE_L2_GAS
+ MAX_NULLIFIERS_PER_TX * AVM_EMITNULLIFIER_BASE_L2_GAS
+ MAX_L2_TO_L1_MSGS_PER_TX * AVM_SENDL2TOL1MSG_BASE_L2_GAS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,10 @@ pub global AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED: u32 = 1000;
pub global AVM_MAX_PROCESSABLE_L2_GAS: u32 = 6_000_000; // Arbitrary.

pub global DA_BYTES_PER_FIELD: u32 = 32;
pub global DA_GAS_PER_BYTE: u32 = 16; // TODO: Explain this, might be arbitrary? maybe make it one? and sync it wit the tx overhead constants?
// pays for preamble information in TX Effects
pub global FIXED_DA_GAS: u32 = 512;
pub global DA_GAS_PER_BYTE: u32 = 1; // Arbitrary.
pub global DA_GAS_PER_FIELD: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
// A tx always emits 3 fields: tx_start_marker, tx_hash, and tx_fee.
pub global FIXED_DA_GAS: u32 = 3 * DA_GAS_PER_FIELD;
// TODO: take into account the cost of executing and proving the rollup circuits (if they can be attributed to this tx... eg the tx base rollup, half a tx merge).
// We need a test suite to demonstrate these measurements
// pays for fixed tx costs like validation, and updating state roots
Expand All @@ -1047,7 +1048,7 @@ pub global FIXED_L2_GAS: u32 = 512;
pub global FIXED_AVM_STARTUP_L2_GAS: u32 = 20_000;

pub global MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT: u32 =
BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB * DA_GAS_PER_FIELD;

// For gas estimation, we use the theoretical maximum amounts.
// Since we split in teardown and total, teardown has the theoretical maximum and total is that times 2.
Expand All @@ -1065,7 +1066,7 @@ pub global GAS_ESTIMATION_DA_GAS_LIMIT: u32 =
// TODO: consider moving to typescript
pub global DEFAULT_TEARDOWN_L2_GAS_LIMIT: u32 = 1_000_000; // Arbitrary default number.
pub global DEFAULT_L2_GAS_LIMIT: u32 = AVM_MAX_PROCESSABLE_L2_GAS; // Arbitrary default number.
pub global DEFAULT_TEARDOWN_DA_GAS_LIMIT: u32 = 1_000_000; // Arbitrary default number.
pub global DEFAULT_TEARDOWN_DA_GAS_LIMIT: u32 = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT / 2; // Arbitrary default number.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this limit chosen? (I see it's labelled as arbitrary, but why restrict it to half of the DEFAULT_DA_GAS_LIMIT?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we reduced the gas per byte by 16, so the MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT has changed from 12,582,912 to 786,432. And the original hardcoded limit 1_000_000 exceeded the max of the entire checkpoint, which broke one of the tests that setup the mock data assuming the tx used up its limit (the DEFAULT_TEARDOWN_DA_GAS_LIMIT).

Making it half of the entire checkpoint limit so we won't have to update the hardcoded value if we ever change the constant again. And in reality, users should use the result from simulation to set the limits, instead of using the default values.

pub global DEFAULT_DA_GAS_LIMIT: u32 = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT; // Arbitrary default number.

// Some tree insertions incur an additional cost associated with
Expand Down Expand Up @@ -1156,16 +1157,16 @@ pub global AVM_BITWISE_DYN_L2_GAS: u32 = 3; // One row per byte
pub global AVM_EMITPUBLICLOG_DYN_L2_GAS: u32 = 3;

// Base DA Gas
pub global AVM_EMITNOTEHASH_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
pub global AVM_EMITNULLIFIER_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
pub global AVM_SENDL2TOL1MSG_BASE_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
pub global AVM_EMITPUBLICLOG_BASE_DA_GAS: u32 = 2 * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE; // length and address
pub global AVM_EMITNOTEHASH_BASE_DA_GAS: u32 = DA_GAS_PER_FIELD;
pub global AVM_EMITNULLIFIER_BASE_DA_GAS: u32 = DA_GAS_PER_FIELD;
pub global AVM_SENDL2TOL1MSG_BASE_DA_GAS: u32 = DA_GAS_PER_FIELD;
pub global AVM_EMITPUBLICLOG_BASE_DA_GAS: u32 = 2 * DA_GAS_PER_FIELD; // length and address

// Dynamic DA Gas
// a single increment here corresponds to an entire additional field (hence x32 bytes per field)
pub global AVM_EMITPUBLICLOG_DYN_DA_GAS: u32 = DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
pub global AVM_EMITPUBLICLOG_DYN_DA_GAS: u32 = DA_GAS_PER_FIELD;
// Gets multiplied by 1 if actually publishing, 0 if not. 2 because of it being (slot, value) pair
pub global AVM_SSTORE_DYN_DA_GAS: u32 = 2 * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
pub global AVM_SSTORE_DYN_DA_GAS: u32 = 2 * DA_GAS_PER_FIELD;

// BLOB PREFIXES
// Used when decoding blobs of tightly packed effects
Expand Down
27 changes: 14 additions & 13 deletions yarn-project/constants/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,19 +387,20 @@ export const AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED = 16400;
export const AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED = 1000;
export const AVM_MAX_PROCESSABLE_L2_GAS = 6000000;
export const DA_BYTES_PER_FIELD = 32;
export const DA_GAS_PER_BYTE = 16;
export const FIXED_DA_GAS = 512;
export const DA_GAS_PER_BYTE = 1;
export const DA_GAS_PER_FIELD = 32;
export const FIXED_DA_GAS = 96;
export const FIXED_L2_GAS = 512;
export const FIXED_AVM_STARTUP_L2_GAS = 20000;
export const MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT = 12582912;
export const MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT = 786432;
export const GAS_ESTIMATION_TEARDOWN_L2_GAS_LIMIT = 6000000;
export const GAS_ESTIMATION_L2_GAS_LIMIT = 12000000;
export const GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT = 12582912;
export const GAS_ESTIMATION_DA_GAS_LIMIT = 25165824;
export const GAS_ESTIMATION_TEARDOWN_DA_GAS_LIMIT = 786432;
export const GAS_ESTIMATION_DA_GAS_LIMIT = 1572864;
export const DEFAULT_TEARDOWN_L2_GAS_LIMIT = 1000000;
export const DEFAULT_L2_GAS_LIMIT = 6000000;
export const DEFAULT_TEARDOWN_DA_GAS_LIMIT = 1000000;
export const DEFAULT_DA_GAS_LIMIT = 12582912;
export const DEFAULT_TEARDOWN_DA_GAS_LIMIT = 393216;
export const DEFAULT_DA_GAS_LIMIT = 786432;
export const L2_GAS_DISTRIBUTED_STORAGE_PREMIUM = 1024;
export const AVM_PC_SIZE_IN_BITS = 32;
export const AVM_MAX_OPERANDS = 7;
Expand Down Expand Up @@ -463,12 +464,12 @@ export const AVM_RETURNDATACOPY_DYN_L2_GAS = 3;
export const AVM_TORADIXBE_DYN_L2_GAS = 3;
export const AVM_BITWISE_DYN_L2_GAS = 3;
export const AVM_EMITPUBLICLOG_DYN_L2_GAS = 3;
export const AVM_EMITNOTEHASH_BASE_DA_GAS = 512;
export const AVM_EMITNULLIFIER_BASE_DA_GAS = 512;
export const AVM_SENDL2TOL1MSG_BASE_DA_GAS = 512;
export const AVM_EMITPUBLICLOG_BASE_DA_GAS = 1024;
export const AVM_EMITPUBLICLOG_DYN_DA_GAS = 512;
export const AVM_SSTORE_DYN_DA_GAS = 1024;
export const AVM_EMITNOTEHASH_BASE_DA_GAS = 32;
export const AVM_EMITNULLIFIER_BASE_DA_GAS = 32;
export const AVM_SENDL2TOL1MSG_BASE_DA_GAS = 32;
export const AVM_EMITPUBLICLOG_BASE_DA_GAS = 64;
export const AVM_EMITPUBLICLOG_DYN_DA_GAS = 32;
export const AVM_SSTORE_DYN_DA_GAS = 64;
export const TX_START_PREFIX = 2624615704;
export const BLOCK_END_PREFIX = 3951939007;
export const CHECKPOINT_END_PREFIX = 2355328067;
Expand Down
Loading
Loading