Skip to main content

Constants

Draft

All of these constants are subject to change, pending benchmarking, optimizations, and general protocol changes.

Tree Constants

See also: state.

Tree Epochs

Note: we might introduce tree epochs, which will reduce the height of each epoch's tree, and means we don't need to estimate future network state growth in advance.

NameValueDescription
ARCHIVE_TREE_HEIGHT27Prudent justification: 1 block/min * 200 years ~= 2^27 blocks
NOTE_HASH_TREE_HEIGHT39Prudent justification: 10 tx/s * 8 notes/tx * 200 years.
NULLIFIER_TREE_HEIGHT42Prudent justification: [Number of notes 2 (to allow a huge buffer for initialization nullifiers and other nullifier usage)] + [ 2 Estimated number of contracts (to allow a huge buffer for contract class & instance nullifiers) ]. An estimate for the number of contracts ever to be deployed is debatable.
PUBLIC_DATA_TREE_HEIGHT39Prudent justification: 10 tx/s * 8 storage slots/tx * 200 years.
L1_TO_L2_MESSAGE_TREE33Prudent justification: 10 tx/s * 10% of txs consuming a message * 200 years.
PRIVATE_FUNCTION_TREE_HEIGHT5Note: this means a smart contract can only declare 2 ** 5 = 32 private functions.

For all trees, an empty leaf has value 0.

For all indexed merkle trees, the 0th leaf is the "zero predecessor leaf" with leaf preimage { value: 0, next_index: 0, next_value: 0}.

Circuit Constants

danger

Note: "per call" values might be much more flexible, once the data bus is introduced. These numbers are finger-in-the-air estimates of values that might be possible with the data bus. Benchmarking will be needed.

The statically-sized nature the kernel & rollup circuits will restrict the quantity of 'side effects' that a single call or transaction can create.

Per Call

NameValueDescription
RETURN_VALUES_LENGTH4
MAX_NEW_NOTE_HASHES_PER_CALL128
MAX_NEW_NULLIFIERS_PER_CALL128
MAX_NEW_L2_TO_L1_MSGS_PER_CALL4
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL128
MAX_PUBLIC_DATA_READS_PER_CALL128
MAX_UNENCRYPTED_LOG_HASHES_PER_CALL128
MAX_ENCRYPTED_LOG_HASHES_PER_CALL128
MAX_ENCRYPTED_NOTE_PREIMAGE_HASHES_PER_CALL128
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL128
MAX_NULLIFIER_READ_REQUESTS_PER_CALL128
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_CALL1TODO: we shouldn't need this, given the reset circuit.
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL32
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL32

Per Tx

NameValueDescription
MAX_NEW_NOTE_HASHES_PER_TX128
MAX_NEW_NULLIFIERS_PER_TX128
MAX_NEW_L2_TO_L1_MSGS_PER_TX16
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX16
MAX_PUBLIC_DATA_READS_PER_TX16
MAX_UNENCRYPTED_LOG_HASHES_PER_TX128
MAX_ENCRYPTED_LOG_HASHES_PER_TX128
MAX_ENCRYPTED_NOTE_PREIMAGE_HASHES_PER_TX128
MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX4
MAX_NOTE_HASH_READ_REQUESTS_PER_TX128TODO: we shouldn't need this, given the reset circuit.
MAX_NULLIFIER_KEY_VALIDATION_REQUESTS_PER_TX4TODO: we shouldn't need this, given the reset circuit.
MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX32
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX32

Block constants

Genesis Constants

Genesis Addresses

danger

TODO: consider whether these addresses should be 'nice', small values, or whether these addresses should be derived in the same way as all other addresses (but with a deployer_address of 0x00).

TODO: some of these contracts will be baked into genesis. Some of them might need to be deployed as part of the first network 'upgrade', and so might end up being removed from this section. This is still being discussed.

NameValueDescription
Space reserved for precompile addresses
CONTRACT_CLASS_REGISTERER_ADDRESS0x10000See here
CONTRACT_INSTANCE_DEPLOYER_ADDRESS0x10001See here
FEE_JUICE_ADDRESS0x10002TODO: consider at what stage this should be deployed.

Genesis Archive Tree

The 0th leaf of the archive tree will be hard-coded at genesis to be an empty collection of state trees and an empty previous header.

Genesis Nullifiers

NameValueDescription
The zero predecessor leaf.TODONeeded to make an indexed merkle tree work.
The zero predecessor leaf index.0Needed to make an indexed merkle tree work.
GENESIS_NULLIFIER_LEAF_INDEX_OF_CLASS_ID_NULLIFIER_OF_CONTRACT_CLASS_REGISTERER1See here.
GENESIS_NULLIFIER_LEAF_INDEX_OF_DEPLOYMENT_NULLIFIER_OF_CONTRACT_CLASS_REGISTERER2See here.
GENESIS_NULLIFIER_LEAF_INDEX_OF_CLASS_ID_NULLIFIER_OF_CONTRACT_INSTANCE_DEPLOYER3See here.
GENESIS_NULLIFIER_LEAF_INDEX_OF_DEPLOYMENT_NULLIFIER_OF_CONTRACT_INSTANCE_DEPLOYER4See here.
GENESIS_NULLIFIER_LEAF_INDEX_OF_CLASS_ID_NULLIFIER_OF_FEE_JUICE_CONTRACT5See here.
GENESIS_NULLIFIER_LEAF_INDEX_OF_DEPLOYMENT_NULLIFIER_OF_FEE_JUICE_CONTRACT6See here.
danger

TODO: hard-code the actual nullifier values, once the code has been frozen.

These verbose names are designed to get more specific from left to right.

Precompile Constants

See the precompiles section.