Skip to content

Commit

Permalink
chore(avm): Gas constants adjustment based on trace rows accounting (#…
Browse files Browse the repository at this point in the history
…10614)

Resolves #10368
  • Loading branch information
jeanmon authored Dec 11, 2024
1 parent a69502c commit fc729ef
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 253 deletions.
112 changes: 56 additions & 56 deletions barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define MAX_L2_TO_L1_MSGS_PER_TX 8
#define MAX_UNENCRYPTED_LOGS_PER_TX 8
#define MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS 3000
#define MAX_L2_GAS_PER_TX_PUBLIC_PORTION 12000000
#define CANONICAL_AUTH_REGISTRY_ADDRESS 1
#define DEPLOYER_CONTRACT_ADDRESS 2
#define REGISTERER_CONTRACT_ADDRESS 3
Expand Down Expand Up @@ -47,7 +46,7 @@
#define TOTAL_FEES_LENGTH 1
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 867
#define AVM_ACCUMULATED_DATA_LENGTH 320
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1008
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1009
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86
#define AVM_PROOF_LENGTH_IN_FIELDS 4155
#define AVM_PUBLIC_COLUMN_MAX_SIZE 1024
Expand Down Expand Up @@ -83,62 +82,63 @@
#define START_EMIT_NULLIFIER_WRITE_OFFSET 208
#define START_EMIT_L2_TO_L1_MSG_WRITE_OFFSET 224
#define START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET 226
#define AVM_ADD_BASE_L2_GAS 32
#define AVM_SUB_BASE_L2_GAS 32
#define AVM_MUL_BASE_L2_GAS 33
#define AVM_DIV_BASE_L2_GAS 43
#define AVM_FDIV_BASE_L2_GAS 32
#define AVM_EQ_BASE_L2_GAS 32
#define AVM_LT_BASE_L2_GAS 64
#define AVM_LTE_BASE_L2_GAS 64
#define AVM_AND_BASE_L2_GAS 33
#define AVM_OR_BASE_L2_GAS 33
#define AVM_XOR_BASE_L2_GAS 33
#define AVM_NOT_BASE_L2_GAS 27
#define AVM_SHL_BASE_L2_GAS 32
#define AVM_SHR_BASE_L2_GAS 32
#define AVM_CAST_BASE_L2_GAS 30
#define AVM_GETENVVAR_BASE_L2_GAS 20
#define AVM_CALLDATACOPY_BASE_L2_GAS 29
#define AVM_RETURNDATASIZE_BASE_L2_GAS 20
#define AVM_RETURNDATACOPY_BASE_L2_GAS 29
#define AVM_JUMP_BASE_L2_GAS 12
#define AVM_JUMPI_BASE_L2_GAS 18
#define AVM_INTERNALCALL_BASE_L2_GAS 18
#define AVM_INTERNALRETURN_BASE_L2_GAS 18
#define AVM_SET_BASE_L2_GAS 18
#define AVM_MOV_BASE_L2_GAS 23
#define AVM_SLOAD_BASE_L2_GAS 1218
#define AVM_SSTORE_BASE_L2_GAS 2642
#define AVM_NOTEHASHEXISTS_BASE_L2_GAS 1226
#define AVM_EMITNOTEHASH_BASE_L2_GAS 2650
#define AVM_NULLIFIEREXISTS_BASE_L2_GAS 2426
#define AVM_EMITNULLIFIER_BASE_L2_GAS 4250
#define AVM_L1TOL2MSGEXISTS_BASE_L2_GAS 1196
#define AVM_GETCONTRACTINSTANCE_BASE_L2_GAS 2448
#define AVM_EMITUNENCRYPTEDLOG_BASE_L2_GAS 18
#define AVM_SENDL2TOL1MSG_BASE_L2_GAS 226
#define AVM_CALL_BASE_L2_GAS 4845
#define AVM_STATICCALL_BASE_L2_GAS 4845
#define AVM_RETURN_BASE_L2_GAS 28
#define AVM_REVERT_BASE_L2_GAS 28
#define AVM_DEBUGLOG_BASE_L2_GAS 12
#define AVM_DEBUGLOG_DYN_L2_GAS 3
#define AVM_POSEIDON2_BASE_L2_GAS 78
#define AVM_SHA256COMPRESSION_BASE_L2_GAS 261
#define AVM_KECCAKF1600_BASE_L2_GAS 300
#define AVM_ECADD_BASE_L2_GAS 62
#define AVM_MSM_BASE_L2_GAS 1000
#define AVM_TORADIXBE_BASE_L2_GAS 46
#define AVM_CALLDATACOPY_DYN_L2_GAS 6
#define AVM_RETURNDATACOPY_DYN_L2_GAS 6
#define AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS 146
#define MAX_L2_GAS_PER_TX_PUBLIC_PORTION 12000000
#define AVM_POSEIDON2_BASE_L2_GAS 36
#define AVM_ADD_BASE_L2_GAS 27
#define AVM_SUB_BASE_L2_GAS 27
#define AVM_MUL_BASE_L2_GAS 27
#define AVM_DIV_BASE_L2_GAS 27
#define AVM_FDIV_BASE_L2_GAS 27
#define AVM_EQ_BASE_L2_GAS 27
#define AVM_LT_BASE_L2_GAS 30
#define AVM_LTE_BASE_L2_GAS 30
#define AVM_AND_BASE_L2_GAS 51
#define AVM_OR_BASE_L2_GAS 51
#define AVM_XOR_BASE_L2_GAS 51
#define AVM_NOT_BASE_L2_GAS 18
#define AVM_SHL_BASE_L2_GAS 27
#define AVM_SHR_BASE_L2_GAS 27
#define AVM_CAST_BASE_L2_GAS 18
#define AVM_GETENVVAR_BASE_L2_GAS 9
#define AVM_CALLDATACOPY_BASE_L2_GAS 24
#define AVM_RETURNDATASIZE_BASE_L2_GAS 9
#define AVM_RETURNDATACOPY_BASE_L2_GAS 24
#define AVM_JUMP_BASE_L2_GAS 3
#define AVM_JUMPI_BASE_L2_GAS 9
#define AVM_INTERNALCALL_BASE_L2_GAS 3
#define AVM_INTERNALRETURN_BASE_L2_GAS 3
#define AVM_SET_BASE_L2_GAS 9
#define AVM_MOV_BASE_L2_GAS 18
#define AVM_SLOAD_BASE_L2_GAS 1458
#define AVM_SSTORE_BASE_L2_GAS 6802
#define AVM_NOTEHASHEXISTS_BASE_L2_GAS 1467
#define AVM_EMITNOTEHASH_BASE_L2_GAS 3913
#define AVM_NULLIFIEREXISTS_BASE_L2_GAS 1467
#define AVM_EMITNULLIFIER_BASE_L2_GAS 5353
#define AVM_L1TOL2MSGEXISTS_BASE_L2_GAS 1431
#define AVM_GETCONTRACTINSTANCE_BASE_L2_GAS 1467
#define AVM_EMITUNENCRYPTEDLOG_BASE_L2_GAS 15
#define AVM_SENDL2TOL1MSG_BASE_L2_GAS 218
#define AVM_CALL_BASE_L2_GAS 2925
#define AVM_STATICCALL_BASE_L2_GAS 2925
#define AVM_RETURN_BASE_L2_GAS 15
#define AVM_REVERT_BASE_L2_GAS 15
#define AVM_DEBUGLOG_BASE_L2_GAS 21
#define AVM_SHA256COMPRESSION_BASE_L2_GAS 114
#define AVM_KECCAKF1600_BASE_L2_GAS 162
#define AVM_ECADD_BASE_L2_GAS 69
#define AVM_MSM_BASE_L2_GAS 36
#define AVM_TORADIXBE_BASE_L2_GAS 24
#define AVM_CALLDATACOPY_DYN_L2_GAS 3
#define AVM_RETURNDATACOPY_DYN_L2_GAS 3
#define AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS 131
#define AVM_CALL_DYN_L2_GAS 4
#define AVM_STATICCALL_DYN_L2_GAS 4
#define AVM_RETURN_DYN_L2_GAS 6
#define AVM_REVERT_DYN_L2_GAS 6
#define AVM_MSM_DYN_L2_GAS 100
#define AVM_TORADIXBE_DYN_L2_GAS 20
#define AVM_RETURN_DYN_L2_GAS 3
#define AVM_REVERT_DYN_L2_GAS 3
#define AVM_DEBUGLOG_DYN_L2_GAS 6
#define AVM_MSM_DYN_L2_GAS 6
#define AVM_TORADIXBE_DYN_L2_GAS 3
#define AVM_SSTORE_BASE_DA_GAS 512
#define AVM_EMITNOTEHASH_BASE_DA_GAS 512
#define AVM_EMITNULLIFIER_BASE_DA_GAS 512
Expand Down
43 changes: 22 additions & 21 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,6 @@ library Constants {
24399338136397901754495080759185489776044879232766421623673792970137;
uint256 internal constant DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE =
14061769416655647708490531650437236735160113654556896985372298487345;
uint256 internal constant DEFAULT_GAS_LIMIT = 1000000000;
uint256 internal constant DEFAULT_TEARDOWN_GAS_LIMIT = 12000000;
uint256 internal constant MAX_L2_GAS_PER_TX_PUBLIC_PORTION = 12000000;
uint256 internal constant DA_BYTES_PER_FIELD = 32;
uint256 internal constant DA_GAS_PER_BYTE = 16;
uint256 internal constant FIXED_DA_GAS = 512;
uint256 internal constant FIXED_L2_GAS = 512;
uint256 internal constant FIXED_AVM_STARTUP_L2_GAS = 20000;
uint256 internal constant L2_GAS_DISTRIBUTED_STORAGE_PREMIUM = 1024;
uint256 internal constant L2_GAS_PER_READ_MERKLE_HASH = 30;
uint256 internal constant L2_GAS_PER_WRITE_MERKLE_HASH = 40;
uint256 internal constant L2_GAS_PER_PUBLIC_DATA_UPDATE = 2624;
uint256 internal constant L2_GAS_PER_NOTE_HASH = 2624;
uint256 internal constant L2_GAS_PER_NULLIFIER = 4224;
uint256 internal constant L2_GAS_PER_PUBLIC_DATA_READ = 1200;
uint256 internal constant L2_GAS_PER_NOTE_HASH_READ_REQUEST = 1200;
uint256 internal constant L2_GAS_PER_NULLIFIER_READ_REQUEST = 2400;
uint256 internal constant L2_GAS_PER_L1_TO_L2_MSG_READ_REQUEST = 1170;
uint256 internal constant L2_GAS_PER_LOG_BYTE = 4;
uint256 internal constant L2_GAS_PER_PRIVATE_LOG = 0;
uint256 internal constant L2_GAS_PER_L2_TO_L1_MSG = 200;
uint256 internal constant MAX_PROTOCOL_CONTRACTS = 7;
uint256 internal constant CANONICAL_AUTH_REGISTRY_ADDRESS = 1;
uint256 internal constant DEPLOYER_CONTRACT_ADDRESS = 2;
Expand Down Expand Up @@ -271,6 +250,28 @@ library Constants {
uint256 internal constant START_EMIT_NULLIFIER_WRITE_OFFSET = 208;
uint256 internal constant START_EMIT_L2_TO_L1_MSG_WRITE_OFFSET = 224;
uint256 internal constant START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 226;
uint256 internal constant DEFAULT_GAS_LIMIT = 1000000000;
uint256 internal constant DEFAULT_TEARDOWN_GAS_LIMIT = 12000000;
uint256 internal constant MAX_L2_GAS_PER_TX_PUBLIC_PORTION = 12000000;
uint256 internal constant MAX_L2_GAS_PER_ENQUEUED_CALL = 12000000;
uint256 internal constant DA_BYTES_PER_FIELD = 32;
uint256 internal constant DA_GAS_PER_BYTE = 16;
uint256 internal constant FIXED_DA_GAS = 512;
uint256 internal constant FIXED_L2_GAS = 512;
uint256 internal constant FIXED_AVM_STARTUP_L2_GAS = 20000;
uint256 internal constant L2_GAS_DISTRIBUTED_STORAGE_PREMIUM = 1024;
uint256 internal constant L2_GAS_PER_READ_MERKLE_HASH = 36;
uint256 internal constant L2_GAS_PER_WRITE_MERKLE_HASH = 36;
uint256 internal constant L2_GAS_PER_PUBLIC_DATA_UPDATE = 6784;
uint256 internal constant L2_GAS_PER_NOTE_HASH = 3904;
uint256 internal constant L2_GAS_PER_NULLIFIER = 5344;
uint256 internal constant L2_GAS_PER_PUBLIC_DATA_READ = 1440;
uint256 internal constant L2_GAS_PER_NOTE_HASH_READ_REQUEST = 1440;
uint256 internal constant L2_GAS_PER_NULLIFIER_READ_REQUEST = 1440;
uint256 internal constant L2_GAS_PER_L1_TO_L2_MSG_READ_REQUEST = 1404;
uint256 internal constant L2_GAS_PER_LOG_BYTE = 4;
uint256 internal constant L2_GAS_PER_PRIVATE_LOG = 0;
uint256 internal constant L2_GAS_PER_L2_TO_L1_MSG = 200;
uint256 internal constant PROOF_TYPE_PLONK = 0;
uint256 internal constant PROOF_TYPE_HONK = 1;
uint256 internal constant PROOF_TYPE_OINK = 2;
Expand Down
Loading

0 comments on commit fc729ef

Please sign in to comment.