Skip to content

Commit

Permalink
bump public constants (#1316)
Browse files Browse the repository at this point in the history
# Description
Increase constants for public read/write!
Closes #1290 

# Checklist:

- [ ] I have reviewed my diff in github, line by line.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to the issue(s) that it resolves.
- [ ] There are no unexpected formatting changes, superfluous debug
logs, or commented-out code.
- [ ] The branch has been merged or rebased against the head of its
merge target.
- [ ] I'm happy for the PR to be merged at the reviewer's next
convenience.

---------

Co-authored-by: LHerskind <[email protected]>
  • Loading branch information
rahul-kothari and LHerskind authored Aug 2, 2023
1 parent 61665b9 commit d71fbcb
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 36 deletions.
10 changes: 5 additions & 5 deletions circuits/cpp/src/aztec3/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4;
constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4;
constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4;
constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 4;
constexpr size_t MAX_PUBLIC_DATA_READS_PER_CALL = 4;
constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 8;
constexpr size_t MAX_PUBLIC_DATA_READS_PER_CALL = 8;
constexpr size_t MAX_READ_REQUESTS_PER_CALL = 4;


Expand All @@ -56,8 +56,8 @@ constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_C
constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8;
constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8;
constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2;
constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4;
constexpr size_t MAX_PUBLIC_DATA_READS_PER_TX = 4;
constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 8;
constexpr size_t MAX_PUBLIC_DATA_READS_PER_TX = 8;
constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1;
constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4;
constexpr size_t MAX_READ_REQUESTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_READ_REQUESTS_PER_CALL;
Expand Down Expand Up @@ -243,7 +243,7 @@ constexpr size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH =
2 + RETURN_VALUES_LENGTH + // + 1 for args_hash + 1 call_context.hash
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL +
MAX_NEW_COMMITMENTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL +
NUM_FIELDS_PER_SHA256 + // unencrypted_logs_hash
NUM_FIELDS_PER_SHA256 + // unencrypted_logs_hash (being represented by NUM_FIELDS_PER_SHA256)
3; // unencrypted_log_preimages_length + historic_public_data_tree_root + prover_address


Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/src/core/libraries/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ library Constants {
// TODO(962): Make this constant consistent across the codebase.
uint256 internal constant COMMITMENTS_PER_TX = 16;
uint256 internal constant NULLIFIERS_PER_TX = 16;
uint256 internal constant PUBLIC_DATA_WRITES_PER_TX = 4;
uint256 internal constant PUBLIC_DATA_WRITES_PER_TX = 8;
uint256 internal constant CONTRACTS_PER_TX = 1;
uint256 internal constant L2_TO_L1_MSGS_PER_TX = 2;
uint256 internal constant L1_TO_L2_MSGS_PER_BASE_ROLLUP = 16;
Expand Down
18 changes: 9 additions & 9 deletions l1-contracts/test/Decoder.t.sol

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions yarn-project/circuits.js/src/cbind/circuits.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ interface MsgpackCombinedAccumulatedData {
unencrypted_log_preimages_length: Buffer;
new_contracts: Tuple<MsgpackNewContractData, 1>;
optionally_revealed_data: Tuple<MsgpackOptionallyRevealedData, 4>;
public_data_update_requests: Tuple<MsgpackPublicDataUpdateRequest, 4>;
public_data_reads: Tuple<MsgpackPublicDataRead, 4>;
public_data_update_requests: Tuple<MsgpackPublicDataUpdateRequest, 8>;
public_data_reads: Tuple<MsgpackPublicDataRead, 8>;
}

export function toCombinedAccumulatedData(o: MsgpackCombinedAccumulatedData): CombinedAccumulatedData {
Expand Down Expand Up @@ -1179,8 +1179,8 @@ interface MsgpackPublicCircuitPublicInputs {
call_context: MsgpackCallContext;
args_hash: Buffer;
return_values: Tuple<Buffer, 4>;
contract_storage_update_requests: Tuple<MsgpackContractStorageUpdateRequest, 4>;
contract_storage_reads: Tuple<MsgpackContractStorageRead, 4>;
contract_storage_update_requests: Tuple<MsgpackContractStorageUpdateRequest, 8>;
contract_storage_reads: Tuple<MsgpackContractStorageRead, 8>;
public_call_stack: Tuple<Buffer, 4>;
new_commitments: Tuple<Buffer, 4>;
new_nullifiers: Tuple<Buffer, 4>;
Expand Down
12 changes: 6 additions & 6 deletions yarn-project/circuits.js/src/cbind/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ export const MAX_NEW_NULLIFIERS_PER_CALL = 4;
export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4;
export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4;
export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 4;
export const MAX_PUBLIC_DATA_READS_PER_CALL = 4;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 8;
export const MAX_PUBLIC_DATA_READS_PER_CALL = 8;
export const MAX_READ_REQUESTS_PER_CALL = 4;
export const MAX_NEW_COMMITMENTS_PER_TX = 16;
export const MAX_NEW_NULLIFIERS_PER_TX = 16;
export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8;
export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8;
export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4;
export const MAX_PUBLIC_DATA_READS_PER_TX = 4;
export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 8;
export const MAX_PUBLIC_DATA_READS_PER_TX = 8;
export const MAX_NEW_CONTRACTS_PER_TX = 1;
export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4;
export const MAX_READ_REQUESTS_PER_TX = 16;
Expand Down Expand Up @@ -60,11 +60,11 @@ export const CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 56;
export const CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3;
export const CONTRACT_STORAGE_READ_LENGTH = 2;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 55;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 75;
export const GET_NOTES_ORACLE_RETURN_LENGTH = 86;
export const EMPTY_NULLIFIED_COMMITMENT = 1000000;
export const CALL_PRIVATE_FUNCTION_RETURN_SIZE = 62;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 33;
export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 41;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 46;
export enum GeneratorIndex {
COMMITMENT = 1,
Expand Down
10 changes: 8 additions & 2 deletions yarn-project/circuits.js/src/kernel/public_kernel.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { CircuitError, MAX_PUBLIC_DATA_READS_PER_TX, makeTuple, simulatePublicKernelCircuit } from '../index.js';
import {
CircuitError,
MAX_PUBLIC_DATA_READS_PER_CALL,
MAX_PUBLIC_DATA_READS_PER_TX,
makeTuple,
simulatePublicKernelCircuit,
} from '../index.js';
import { makePublicDataRead, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js';

describe('kernel/public_kernel', () => {
Expand Down Expand Up @@ -34,7 +40,7 @@ describe('kernel/public_kernel', () => {
await expect(simulatePublicKernelCircuit(input)).rejects.toThrow(
new CircuitError(
7009,
`public_kernel_circuit: too many public data reads in one tx - array_push: capacity exceeded. Limit: 4
`public_kernel_circuit: too many public data reads in one tx - array_push: capacity exceeded. Limit: ${MAX_PUBLIC_DATA_READS_PER_CALL}
Refer to https://docs.aztec.network/aztec/protocol/errors for more information.`,
),
);
Expand Down
Loading

0 comments on commit d71fbcb

Please sign in to comment.