@aztec/stdlib 3.0.0-nightly.20251007 → 3.0.0-nightly.20251008
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/avm/avm.d.ts +62 -78
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +8 -22
- package/dest/avm/avm_circuit_public_inputs.d.ts +19 -6
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.js +12 -11
- package/dest/avm/avm_proving_request.d.ts +49 -40
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.d.ts +3 -0
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +5 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/proving-job.d.ts +49 -40
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +1 -1
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -2
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/nullifier_read_request_hints.d.ts +4 -3
- package/dest/kernel/hints/nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/private_call_data.d.ts +4 -24
- package/dest/kernel/private_call_data.d.ts.map +1 -1
- package/dest/kernel/private_call_data.js +4 -16
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +3 -3
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +3 -3
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts +5 -4
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_circuit_private_inputs.js +7 -6
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +1 -1
- package/dest/p2p/block_proposal.d.ts +2 -0
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/rollup/block_constant_data.d.ts +4 -4
- package/dest/rollup/block_constant_data.d.ts.map +1 -1
- package/dest/rollup/block_constant_data.js +4 -4
- package/dest/rollup/checkpoint_constant_data.d.ts +4 -4
- package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.js +4 -4
- package/dest/rollup/epoch_constant_data.d.ts +4 -4
- package/dest/rollup/epoch_constant_data.d.ts.map +1 -1
- package/dest/rollup/epoch_constant_data.js +5 -5
- package/dest/tests/factories.d.ts +5 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +11 -10
- package/dest/tests/mocks.d.ts +2 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +2 -2
- package/dest/trees/index.d.ts +0 -1
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +0 -1
- package/dest/tx/index.d.ts +2 -0
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +2 -0
- package/dest/tx/private_tx_constant_data.d.ts +60 -0
- package/dest/tx/private_tx_constant_data.d.ts.map +1 -0
- package/dest/tx/private_tx_constant_data.js +69 -0
- package/dest/tx/protocol_contracts.d.ts +29 -0
- package/dest/tx/protocol_contracts.d.ts.map +1 -0
- package/dest/tx/protocol_contracts.js +49 -0
- package/dest/tx/tx_constant_data.d.ts +5 -37
- package/dest/tx/tx_constant_data.d.ts.map +1 -1
- package/dest/tx/tx_constant_data.js +8 -17
- package/dest/tx/validator/error_texts.d.ts +1 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +1 -1
- package/dest/versioning/versioning.d.ts +2 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +8 -8
- package/package.json +8 -8
- package/src/avm/avm.ts +13 -24
- package/src/avm/avm_circuit_public_inputs.ts +11 -10
- package/src/interfaces/configs.ts +3 -0
- package/src/interfaces/validator.ts +1 -1
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +3 -2
- package/src/kernel/hints/nullifier_read_request_hints.ts +3 -3
- package/src/kernel/private_call_data.ts +2 -21
- package/src/kernel/private_kernel_circuit_public_inputs.ts +4 -4
- package/src/kernel/private_kernel_init_circuit_private_inputs.ts +5 -4
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +1 -1
- package/src/p2p/block_proposal.ts +2 -0
- package/src/rollup/block_constant_data.ts +3 -3
- package/src/rollup/checkpoint_constant_data.ts +3 -3
- package/src/rollup/epoch_constant_data.ts +3 -9
- package/src/tests/factories.ts +12 -19
- package/src/tests/mocks.ts +3 -3
- package/src/trees/index.ts +0 -1
- package/src/tx/index.ts +2 -0
- package/src/tx/private_tx_constant_data.ts +94 -0
- package/src/tx/protocol_contracts.ts +70 -0
- package/src/tx/tx_constant_data.ts +6 -19
- package/src/tx/validator/error_texts.ts +1 -1
- package/src/versioning/versioning.ts +10 -10
- package/dest/trees/protocol_contract_leaf.d.ts +0 -84
- package/dest/trees/protocol_contract_leaf.d.ts.map +0 -1
- package/dest/trees/protocol_contract_leaf.js +0 -100
- package/src/trees/protocol_contract_leaf.ts +0 -128
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
} from '../kernel/private_to_avm_accumulated_data.js';
|
|
17
17
|
import { PublicCallRequest, PublicCallRequestArrayLengths } from '../kernel/public_call_request.js';
|
|
18
18
|
import { GlobalVariables } from '../tx/global_variables.js';
|
|
19
|
+
import { ProtocolContracts } from '../tx/protocol_contracts.js';
|
|
19
20
|
import { TreeSnapshots } from '../tx/tree_snapshots.js';
|
|
20
21
|
import { AvmAccumulatedData, AvmAccumulatedDataArrayLengths } from './avm_accumulated_data.js';
|
|
21
22
|
import { serializeWithMessagePack } from './message_pack.js';
|
|
@@ -27,7 +28,7 @@ export class AvmCircuitPublicInputs {
|
|
|
27
28
|
///////////////////////////////////
|
|
28
29
|
// Inputs.
|
|
29
30
|
public globalVariables: GlobalVariables,
|
|
30
|
-
public
|
|
31
|
+
public protocolContracts: ProtocolContracts,
|
|
31
32
|
public startTreeSnapshots: TreeSnapshots,
|
|
32
33
|
public startGasUsed: Gas,
|
|
33
34
|
public gasSettings: GasSettings,
|
|
@@ -56,7 +57,7 @@ export class AvmCircuitPublicInputs {
|
|
|
56
57
|
return z
|
|
57
58
|
.object({
|
|
58
59
|
globalVariables: GlobalVariables.schema,
|
|
59
|
-
|
|
60
|
+
protocolContracts: ProtocolContracts.schema,
|
|
60
61
|
startTreeSnapshots: TreeSnapshots.schema,
|
|
61
62
|
startGasUsed: Gas.schema,
|
|
62
63
|
gasSettings: GasSettings.schema,
|
|
@@ -81,7 +82,7 @@ export class AvmCircuitPublicInputs {
|
|
|
81
82
|
.transform(
|
|
82
83
|
({
|
|
83
84
|
globalVariables,
|
|
84
|
-
|
|
85
|
+
protocolContracts,
|
|
85
86
|
startTreeSnapshots,
|
|
86
87
|
startGasUsed,
|
|
87
88
|
gasSettings,
|
|
@@ -105,7 +106,7 @@ export class AvmCircuitPublicInputs {
|
|
|
105
106
|
}) =>
|
|
106
107
|
new AvmCircuitPublicInputs(
|
|
107
108
|
globalVariables,
|
|
108
|
-
|
|
109
|
+
protocolContracts,
|
|
109
110
|
startTreeSnapshots,
|
|
110
111
|
startGasUsed,
|
|
111
112
|
gasSettings,
|
|
@@ -134,7 +135,7 @@ export class AvmCircuitPublicInputs {
|
|
|
134
135
|
const reader = BufferReader.asReader(buffer);
|
|
135
136
|
return new AvmCircuitPublicInputs(
|
|
136
137
|
reader.readObject(GlobalVariables),
|
|
137
|
-
reader.readObject(
|
|
138
|
+
reader.readObject(ProtocolContracts),
|
|
138
139
|
reader.readObject(TreeSnapshots),
|
|
139
140
|
reader.readObject(Gas),
|
|
140
141
|
reader.readObject(GasSettings),
|
|
@@ -161,7 +162,7 @@ export class AvmCircuitPublicInputs {
|
|
|
161
162
|
toBuffer() {
|
|
162
163
|
return serializeToBuffer(
|
|
163
164
|
this.globalVariables,
|
|
164
|
-
this.
|
|
165
|
+
this.protocolContracts,
|
|
165
166
|
this.startTreeSnapshots,
|
|
166
167
|
this.startGasUsed,
|
|
167
168
|
this.gasSettings,
|
|
@@ -197,7 +198,7 @@ export class AvmCircuitPublicInputs {
|
|
|
197
198
|
const reader = FieldReader.asReader(fields);
|
|
198
199
|
return new AvmCircuitPublicInputs(
|
|
199
200
|
GlobalVariables.fromFields(reader),
|
|
200
|
-
|
|
201
|
+
ProtocolContracts.fromFields(reader),
|
|
201
202
|
TreeSnapshots.fromFields(reader),
|
|
202
203
|
Gas.fromFields(reader),
|
|
203
204
|
GasSettings.fromFields(reader),
|
|
@@ -224,7 +225,7 @@ export class AvmCircuitPublicInputs {
|
|
|
224
225
|
toFields() {
|
|
225
226
|
return [
|
|
226
227
|
...this.globalVariables.toFields(),
|
|
227
|
-
this.
|
|
228
|
+
...this.protocolContracts.toFields(),
|
|
228
229
|
...this.startTreeSnapshots.toFields(),
|
|
229
230
|
...this.startGasUsed.toFields(),
|
|
230
231
|
...this.gasSettings.toFields(),
|
|
@@ -251,7 +252,7 @@ export class AvmCircuitPublicInputs {
|
|
|
251
252
|
static empty() {
|
|
252
253
|
return new AvmCircuitPublicInputs(
|
|
253
254
|
GlobalVariables.empty(),
|
|
254
|
-
|
|
255
|
+
ProtocolContracts.empty(),
|
|
255
256
|
TreeSnapshots.empty(),
|
|
256
257
|
Gas.empty(),
|
|
257
258
|
GasSettings.empty(),
|
|
@@ -282,7 +283,7 @@ export class AvmCircuitPublicInputs {
|
|
|
282
283
|
[inspect.custom]() {
|
|
283
284
|
return `AvmCircuitPublicInputs {
|
|
284
285
|
globalVariables: ${inspect(this.globalVariables)},
|
|
285
|
-
|
|
286
|
+
protocolContracts: ${inspect(this.protocolContracts)},
|
|
286
287
|
startTreeSnapshots: ${inspect(this.startTreeSnapshots)},
|
|
287
288
|
startGasUsed: ${inspect(this.startGasUsed)},
|
|
288
289
|
gasSettings: ${inspect(this.gasSettings)},
|
|
@@ -52,6 +52,8 @@ export interface SequencerConfig {
|
|
|
52
52
|
skipCollectingAttestations?: boolean;
|
|
53
53
|
/** Do not invalidate the previous block if invalid when we are the proposer (for testing only) */
|
|
54
54
|
skipInvalidateBlockAsProposer?: boolean;
|
|
55
|
+
/** Broadcast invalid block proposals with corrupted state (for testing only) */
|
|
56
|
+
broadcastInvalidBlockProposal?: boolean;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export const SequencerConfigSchema = z.object({
|
|
@@ -75,4 +77,5 @@ export const SequencerConfigSchema = z.object({
|
|
|
75
77
|
skipCollectingAttestations: z.boolean().optional(),
|
|
76
78
|
secondsBeforeInvalidatingBlockAsCommitteeMember: z.number(),
|
|
77
79
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
|
|
80
|
+
broadcastInvalidBlockProposal: z.boolean().optional(),
|
|
78
81
|
}) satisfies ZodFor<SequencerConfig>;
|
|
@@ -43,7 +43,7 @@ export interface ValidatorClientConfig {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export type ValidatorClientFullConfig = ValidatorClientConfig &
|
|
46
|
-
Pick<SequencerConfig, 'txPublicSetupAllowList'> &
|
|
46
|
+
Pick<SequencerConfig, 'txPublicSetupAllowList' | 'broadcastInvalidBlockProposal'> &
|
|
47
47
|
Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty'>;
|
|
48
48
|
|
|
49
49
|
export const ValidatorClientConfigSchema = z.object({
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
type NULLIFIER_TREE_HEIGHT,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
6
|
import type { Fr } from '@aztec/foundation/fields';
|
|
7
|
-
import {
|
|
7
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
8
8
|
|
|
9
9
|
import { siloNullifier } from '../../hash/hash.js';
|
|
10
|
+
import type { NullifierLeafPreimage } from '../../trees/nullifier_leaf.js';
|
|
10
11
|
import type { ClaimedLengthArray } from '../claimed_length_array.js';
|
|
11
12
|
import type { ScopedNullifier } from '../nullifier.js';
|
|
12
13
|
import { NullifierReadRequestHintsBuilder } from './nullifier_read_request_hints.js';
|
|
@@ -24,7 +25,7 @@ export function isValidNullifierReadRequest(readRequest: ScopedReadRequest, null
|
|
|
24
25
|
|
|
25
26
|
interface NullifierMembershipWitnessWithPreimage {
|
|
26
27
|
membershipWitness: MembershipWitness<typeof NULLIFIER_TREE_HEIGHT>;
|
|
27
|
-
leafPreimage:
|
|
28
|
+
leafPreimage: NullifierLeafPreimage;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export function getNullifierReadRequestResetActions(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_NULLIFIER_READ_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
3
|
import type { BufferReader } from '@aztec/foundation/serialize';
|
|
4
|
-
import type { MembershipWitness
|
|
4
|
+
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
6
6
|
import { NullifierLeafPreimage } from '../../trees/index.js';
|
|
7
7
|
import { PendingReadHint, ReadRequestAction, ReadRequestResetHints, SettledReadHint } from './read_request_hints.js';
|
|
@@ -11,7 +11,7 @@ export type NullifierReadRequestHints<PENDING extends number, SETTLED extends nu
|
|
|
11
11
|
PENDING,
|
|
12
12
|
SETTLED,
|
|
13
13
|
typeof NULLIFIER_TREE_HEIGHT,
|
|
14
|
-
|
|
14
|
+
NullifierLeafPreimage
|
|
15
15
|
>;
|
|
16
16
|
|
|
17
17
|
export function nullifierReadRequestHintsFromBuffer<PENDING extends number, SETTLED extends number>(
|
|
@@ -64,7 +64,7 @@ export class NullifierReadRequestHintsBuilder<PENDING extends number, SETTLED ex
|
|
|
64
64
|
addSettledReadRequest(
|
|
65
65
|
readRequestIndex: number,
|
|
66
66
|
membershipWitness: MembershipWitness<typeof NULLIFIER_TREE_HEIGHT>,
|
|
67
|
-
leafPreimage:
|
|
67
|
+
leafPreimage: NullifierLeafPreimage,
|
|
68
68
|
) {
|
|
69
69
|
if (this.numSettledReadHints === this.maxSettled) {
|
|
70
70
|
throw new Error('Cannot add more settled read request.');
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FUNCTION_TREE_HEIGHT,
|
|
3
|
-
PROTOCOL_CONTRACT_TREE_HEIGHT,
|
|
4
|
-
PUBLIC_DATA_TREE_HEIGHT,
|
|
5
|
-
UPDATES_VALUE_SIZE,
|
|
6
|
-
} from '@aztec/constants';
|
|
1
|
+
import { FUNCTION_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, UPDATES_VALUE_SIZE } from '@aztec/constants';
|
|
7
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
8
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
4
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
@@ -11,7 +6,7 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
11
6
|
|
|
12
7
|
import { DelayedPublicMutableValues } from '../delayed_public_mutable/delayed_public_mutable_values.js';
|
|
13
8
|
import { PublicKeys } from '../keys/public_keys.js';
|
|
14
|
-
import {
|
|
9
|
+
import { PublicDataTreeLeafPreimage } from '../trees/index.js';
|
|
15
10
|
import { VerificationKeyAsFields } from '../vks/verification_key.js';
|
|
16
11
|
import { PrivateCircuitPublicInputs } from './private_circuit_public_inputs.js';
|
|
17
12
|
|
|
@@ -94,16 +89,6 @@ export class PrivateVerificationKeyHints {
|
|
|
94
89
|
* The membership witness for the function leaf corresponding to the function being invoked.
|
|
95
90
|
*/
|
|
96
91
|
public functionLeafMembershipWitness: MembershipWitness<typeof FUNCTION_TREE_HEIGHT>,
|
|
97
|
-
/**
|
|
98
|
-
* The membership witness for the protocolContractLeaf.
|
|
99
|
-
*/
|
|
100
|
-
public protocolContractMembershipWitness: MembershipWitness<typeof PROTOCOL_CONTRACT_TREE_HEIGHT>,
|
|
101
|
-
/**
|
|
102
|
-
* The leaf of the protocol contract tree, of either:
|
|
103
|
-
* The protocol contract being called.
|
|
104
|
-
* The low leaf showing that the address of the contract being called is not in the tree.
|
|
105
|
-
*/
|
|
106
|
-
public protocolContractLeaf: ProtocolContractLeafPreimage,
|
|
107
92
|
|
|
108
93
|
public updatedClassIdHints: UpdatedClassIdHints,
|
|
109
94
|
) {}
|
|
@@ -120,8 +105,6 @@ export class PrivateVerificationKeyHints {
|
|
|
120
105
|
fields.publicKeys,
|
|
121
106
|
fields.saltedInitializationHash,
|
|
122
107
|
fields.functionLeafMembershipWitness,
|
|
123
|
-
fields.protocolContractMembershipWitness,
|
|
124
|
-
fields.protocolContractLeaf,
|
|
125
108
|
fields.updatedClassIdHints,
|
|
126
109
|
] as const;
|
|
127
110
|
}
|
|
@@ -151,8 +134,6 @@ export class PrivateVerificationKeyHints {
|
|
|
151
134
|
reader.readObject(PublicKeys),
|
|
152
135
|
reader.readObject(Fr),
|
|
153
136
|
reader.readObject(MembershipWitness.deserializer(FUNCTION_TREE_HEIGHT)),
|
|
154
|
-
reader.readObject(MembershipWitness.deserializer(PROTOCOL_CONTRACT_TREE_HEIGHT)),
|
|
155
|
-
reader.readObject(ProtocolContractLeafPreimage),
|
|
156
137
|
reader.readObject(UpdatedClassIdHints),
|
|
157
138
|
);
|
|
158
139
|
}
|
|
@@ -3,7 +3,7 @@ import { bufferSchemaFor } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
4
|
|
|
5
5
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { PrivateTxConstantData } from '../tx/private_tx_constant_data.js';
|
|
7
7
|
import type { UInt64 } from '../types/shared.js';
|
|
8
8
|
import { PrivateAccumulatedData } from './private_accumulated_data.js';
|
|
9
9
|
import { PrivateValidationRequests } from './private_validation_requests.js';
|
|
@@ -17,7 +17,7 @@ export class PrivateKernelCircuitPublicInputs {
|
|
|
17
17
|
/**
|
|
18
18
|
* Data which is not modified by the circuits.
|
|
19
19
|
*/
|
|
20
|
-
public constants:
|
|
20
|
+
public constants: PrivateTxConstantData,
|
|
21
21
|
/**
|
|
22
22
|
* The side effect counter that non-revertible side effects are all beneath.
|
|
23
23
|
*/
|
|
@@ -82,7 +82,7 @@ export class PrivateKernelCircuitPublicInputs {
|
|
|
82
82
|
static fromBuffer(buffer: Buffer | BufferReader): PrivateKernelCircuitPublicInputs {
|
|
83
83
|
const reader = BufferReader.asReader(buffer);
|
|
84
84
|
return new PrivateKernelCircuitPublicInputs(
|
|
85
|
-
reader.readObject(
|
|
85
|
+
reader.readObject(PrivateTxConstantData),
|
|
86
86
|
reader.readObject(Fr),
|
|
87
87
|
reader.readObject(PrivateValidationRequests),
|
|
88
88
|
reader.readObject(PrivateAccumulatedData),
|
|
@@ -96,7 +96,7 @@ export class PrivateKernelCircuitPublicInputs {
|
|
|
96
96
|
|
|
97
97
|
static empty() {
|
|
98
98
|
return new PrivateKernelCircuitPublicInputs(
|
|
99
|
-
|
|
99
|
+
PrivateTxConstantData.empty(),
|
|
100
100
|
Fr.zero(),
|
|
101
101
|
PrivateValidationRequests.empty(),
|
|
102
102
|
PrivateAccumulatedData.empty(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
3
|
|
|
4
|
+
import { ProtocolContracts } from '../tx/protocol_contracts.js';
|
|
4
5
|
import { TxRequest } from '../tx/tx_request.js';
|
|
5
6
|
import { PrivateCallData } from './private_call_data.js';
|
|
6
7
|
|
|
@@ -18,9 +19,9 @@ export class PrivateKernelInitCircuitPrivateInputs {
|
|
|
18
19
|
*/
|
|
19
20
|
public vkTreeRoot: Fr,
|
|
20
21
|
/**
|
|
21
|
-
* The
|
|
22
|
+
* The protocol contracts.
|
|
22
23
|
*/
|
|
23
|
-
public
|
|
24
|
+
public protocolContracts: ProtocolContracts,
|
|
24
25
|
/**
|
|
25
26
|
* Private calldata corresponding to this iteration of the kernel.
|
|
26
27
|
*/
|
|
@@ -43,7 +44,7 @@ export class PrivateKernelInitCircuitPrivateInputs {
|
|
|
43
44
|
return serializeToBuffer(
|
|
44
45
|
this.txRequest,
|
|
45
46
|
this.vkTreeRoot,
|
|
46
|
-
this.
|
|
47
|
+
this.protocolContracts,
|
|
47
48
|
this.privateCall,
|
|
48
49
|
this.firstNullifierHint,
|
|
49
50
|
);
|
|
@@ -59,7 +60,7 @@ export class PrivateKernelInitCircuitPrivateInputs {
|
|
|
59
60
|
return new PrivateKernelInitCircuitPrivateInputs(
|
|
60
61
|
reader.readObject(TxRequest),
|
|
61
62
|
Fr.fromBuffer(reader),
|
|
62
|
-
|
|
63
|
+
reader.readObject(ProtocolContracts),
|
|
63
64
|
reader.readObject(PrivateCallData),
|
|
64
65
|
reader.readBoolean(),
|
|
65
66
|
Fr.fromBuffer(reader),
|
|
@@ -173,7 +173,7 @@ export class PrivateKernelTailCircuitPublicInputs {
|
|
|
173
173
|
this.constants.anchorBlockHeader,
|
|
174
174
|
this.constants.txContext,
|
|
175
175
|
this.constants.vkTreeRoot,
|
|
176
|
-
this.constants.
|
|
176
|
+
this.constants.protocolContractsHash,
|
|
177
177
|
);
|
|
178
178
|
return new PrivateToRollupKernelCircuitPublicInputs(
|
|
179
179
|
constants,
|
|
@@ -26,6 +26,8 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
26
26
|
|
|
27
27
|
export type BlockProposalOptions = {
|
|
28
28
|
publishFullTxs: boolean;
|
|
29
|
+
/** Whether to generate an invalid block proposal for broadcasting. Use only for testing. */
|
|
30
|
+
broadcastInvalidBlockProposal?: boolean;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -21,8 +21,8 @@ export class BlockConstantData {
|
|
|
21
21
|
public l1ToL2TreeSnapshot: AppendOnlyTreeSnapshot,
|
|
22
22
|
/** Root of the verification key tree. */
|
|
23
23
|
public vkTreeRoot: Fr,
|
|
24
|
-
/**
|
|
25
|
-
public
|
|
24
|
+
/** Hash of the protocol contracts list. */
|
|
25
|
+
public protocolContractsHash: Fr,
|
|
26
26
|
/** Global variables for the block. */
|
|
27
27
|
public globalVariables: GlobalVariables,
|
|
28
28
|
/** Identifier of the prover. */
|
|
@@ -50,7 +50,7 @@ export class BlockConstantData {
|
|
|
50
50
|
fields.lastArchive,
|
|
51
51
|
fields.l1ToL2TreeSnapshot,
|
|
52
52
|
fields.vkTreeRoot,
|
|
53
|
-
fields.
|
|
53
|
+
fields.protocolContractsHash,
|
|
54
54
|
fields.globalVariables,
|
|
55
55
|
fields.proverId,
|
|
56
56
|
] as const;
|
|
@@ -17,8 +17,8 @@ export class CheckpointConstantData {
|
|
|
17
17
|
public version: Fr,
|
|
18
18
|
/** Root of the verification key tree. */
|
|
19
19
|
public vkTreeRoot: Fr,
|
|
20
|
-
/**
|
|
21
|
-
public
|
|
20
|
+
/** Hash of the protocol contracts list. */
|
|
21
|
+
public protocolContractsHash: Fr,
|
|
22
22
|
/** Identifier of the prover. */
|
|
23
23
|
public proverId: Fr,
|
|
24
24
|
/** Slot number of the checkpoint. */
|
|
@@ -40,7 +40,7 @@ export class CheckpointConstantData {
|
|
|
40
40
|
fields.chainId,
|
|
41
41
|
fields.version,
|
|
42
42
|
fields.vkTreeRoot,
|
|
43
|
-
fields.
|
|
43
|
+
fields.protocolContractsHash,
|
|
44
44
|
fields.proverId,
|
|
45
45
|
fields.slotNumber,
|
|
46
46
|
fields.coinbase,
|
|
@@ -20,9 +20,9 @@ export class EpochConstantData {
|
|
|
20
20
|
*/
|
|
21
21
|
public vkTreeRoot: Fr,
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Hash of the protocol contracts list.
|
|
24
24
|
*/
|
|
25
|
-
public
|
|
25
|
+
public protocolContractsHash: Fr,
|
|
26
26
|
/**
|
|
27
27
|
* Identifier of the prover of the epoch.
|
|
28
28
|
*/
|
|
@@ -34,13 +34,7 @@ export class EpochConstantData {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
static getFields(fields: FieldsOf<EpochConstantData>) {
|
|
37
|
-
return [
|
|
38
|
-
fields.chainId,
|
|
39
|
-
fields.version,
|
|
40
|
-
fields.vkTreeRoot,
|
|
41
|
-
fields.protocolContractTreeRoot,
|
|
42
|
-
fields.proverId,
|
|
43
|
-
] as const;
|
|
37
|
+
return [fields.chainId, fields.version, fields.vkTreeRoot, fields.protocolContractsHash, fields.proverId] as const;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
toFields(): Fr[] {
|
package/src/tests/factories.ts
CHANGED
|
@@ -68,7 +68,6 @@ import {
|
|
|
68
68
|
AvmGetLeafValueHint,
|
|
69
69
|
AvmGetPreviousValueIndexHint,
|
|
70
70
|
AvmGetSiblingPathHint,
|
|
71
|
-
AvmProtocolContractAddressHint,
|
|
72
71
|
AvmRevertCheckpointHint,
|
|
73
72
|
AvmSequentialInsertHintNullifierTree,
|
|
74
73
|
AvmSequentialInsertHintPublicDataTree,
|
|
@@ -160,6 +159,7 @@ import { FunctionData } from '../tx/function_data.js';
|
|
|
160
159
|
import { GlobalVariables } from '../tx/global_variables.js';
|
|
161
160
|
import { PartialStateReference } from '../tx/partial_state_reference.js';
|
|
162
161
|
import { makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '../tx/processed_tx.js';
|
|
162
|
+
import { ProtocolContracts } from '../tx/protocol_contracts.js';
|
|
163
163
|
import { PublicCallRequestWithCalldata } from '../tx/public_call_request_with_calldata.js';
|
|
164
164
|
import { StateReference } from '../tx/state_reference.js';
|
|
165
165
|
import { TreeSnapshots } from '../tx/tree_snapshots.js';
|
|
@@ -420,6 +420,10 @@ export function makePublicTubePublicInputs(seed = 1) {
|
|
|
420
420
|
return new PublicTubePublicInputs(makePrivateToPublicKernelCircuitPublicInputs(seed), fr(seed + 0x1000));
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
export function makeProtocolContracts(seed = 1) {
|
|
424
|
+
return new ProtocolContracts(makeTuple(MAX_PROTOCOL_CONTRACTS, makeAztecAddress, seed));
|
|
425
|
+
}
|
|
426
|
+
|
|
423
427
|
/**
|
|
424
428
|
* Creates arbitrary public kernel circuit public inputs.
|
|
425
429
|
* @param seed - The seed to use for generating the kernel circuit public inputs.
|
|
@@ -441,7 +445,7 @@ export function makePrivateToRollupKernelCircuitPublicInputs(
|
|
|
441
445
|
function makeAvmCircuitPublicInputs(seed = 1) {
|
|
442
446
|
return new AvmCircuitPublicInputs(
|
|
443
447
|
makeGlobalVariables(seed),
|
|
444
|
-
|
|
448
|
+
makeProtocolContracts(seed + 0x100),
|
|
445
449
|
makeTreeSnapshots(seed + 0x10),
|
|
446
450
|
makeGas(seed + 0x20),
|
|
447
451
|
makeGasSettings(),
|
|
@@ -1429,13 +1433,6 @@ export async function makeAvmTxHint(seed = 0): Promise<AvmTxHint> {
|
|
|
1429
1433
|
);
|
|
1430
1434
|
}
|
|
1431
1435
|
|
|
1432
|
-
export function makeAvmProtocolContractDerivedAddressesHint(seed = 0): AvmProtocolContractAddressHint {
|
|
1433
|
-
return new AvmProtocolContractAddressHint(
|
|
1434
|
-
/*canonicalAddress=*/ new AztecAddress(new Fr(seed + 1)),
|
|
1435
|
-
/*derivedAddress=*/ new AztecAddress(new Fr(seed + 0x1001)),
|
|
1436
|
-
);
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
1436
|
/**
|
|
1440
1437
|
* Creates arbitrary AvmExecutionHints.
|
|
1441
1438
|
* @param seed - The seed to use for generating the hints.
|
|
@@ -1452,11 +1449,7 @@ export async function makeAvmExecutionHints(
|
|
|
1452
1449
|
const fields = {
|
|
1453
1450
|
globalVariables: makeGlobalVariables(seed + 0x4000),
|
|
1454
1451
|
tx: await makeAvmTxHint(seed + 0x4100),
|
|
1455
|
-
|
|
1456
|
-
MAX_PROTOCOL_CONTRACTS,
|
|
1457
|
-
makeAvmProtocolContractDerivedAddressesHint,
|
|
1458
|
-
seed + 0x4600,
|
|
1459
|
-
),
|
|
1452
|
+
protocolContracts: new ProtocolContracts(makeTuple(MAX_PROTOCOL_CONTRACTS, makeAztecAddress, seed + 0x4600)),
|
|
1460
1453
|
contractInstances: makeArray(baseLength + 2, makeAvmContractInstanceHint, seed + 0x4700),
|
|
1461
1454
|
contractClasses: makeArray(baseLength + 5, makeAvmContractClassHint, seed + 0x4900),
|
|
1462
1455
|
bytecodeCommitments: await makeArrayAsync(baseLength + 5, makeAvmBytecodeCommitmentHint, seed + 0x4900),
|
|
@@ -1490,7 +1483,7 @@ export async function makeAvmExecutionHints(
|
|
|
1490
1483
|
return new AvmExecutionHints(
|
|
1491
1484
|
fields.globalVariables,
|
|
1492
1485
|
fields.tx,
|
|
1493
|
-
fields.
|
|
1486
|
+
fields.protocolContracts,
|
|
1494
1487
|
fields.contractInstances,
|
|
1495
1488
|
fields.contractClasses,
|
|
1496
1489
|
fields.bytecodeCommitments,
|
|
@@ -1546,7 +1539,7 @@ export async function makeBloatedProcessedTx({
|
|
|
1546
1539
|
version = Fr.ZERO,
|
|
1547
1540
|
gasSettings = GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) }),
|
|
1548
1541
|
vkTreeRoot = Fr.ZERO,
|
|
1549
|
-
|
|
1542
|
+
protocolContracts = makeProtocolContracts(seed + 0x100),
|
|
1550
1543
|
globalVariables = GlobalVariables.empty(),
|
|
1551
1544
|
newL1ToL2Snapshot = AppendOnlyTreeSnapshot.empty(),
|
|
1552
1545
|
feePayer,
|
|
@@ -1562,7 +1555,7 @@ export async function makeBloatedProcessedTx({
|
|
|
1562
1555
|
vkTreeRoot?: Fr;
|
|
1563
1556
|
globalVariables?: GlobalVariables;
|
|
1564
1557
|
newL1ToL2Snapshot?: AppendOnlyTreeSnapshot;
|
|
1565
|
-
|
|
1558
|
+
protocolContracts?: ProtocolContracts;
|
|
1566
1559
|
feePayer?: AztecAddress;
|
|
1567
1560
|
feePaymentPublicDataWrite?: PublicDataWrite;
|
|
1568
1561
|
privateOnly?: boolean;
|
|
@@ -1577,7 +1570,7 @@ export async function makeBloatedProcessedTx({
|
|
|
1577
1570
|
txConstantData.txContext.version = version;
|
|
1578
1571
|
txConstantData.txContext.gasSettings = gasSettings;
|
|
1579
1572
|
txConstantData.vkTreeRoot = vkTreeRoot;
|
|
1580
|
-
txConstantData.
|
|
1573
|
+
txConstantData.protocolContractsHash = await protocolContracts.hash();
|
|
1581
1574
|
|
|
1582
1575
|
const tx = !privateOnly
|
|
1583
1576
|
? await mockTx(seed, { feePayer })
|
|
@@ -1616,7 +1609,7 @@ export async function makeBloatedProcessedTx({
|
|
|
1616
1609
|
// Create avm output.
|
|
1617
1610
|
const avmOutput = AvmCircuitPublicInputs.empty();
|
|
1618
1611
|
// Assign data from hints.
|
|
1619
|
-
avmOutput.
|
|
1612
|
+
avmOutput.protocolContracts = protocolContracts;
|
|
1620
1613
|
avmOutput.startTreeSnapshots.l1ToL2MessageTree = newL1ToL2Snapshot;
|
|
1621
1614
|
avmOutput.endTreeSnapshots.l1ToL2MessageTree = newL1ToL2Snapshot;
|
|
1622
1615
|
// Assign data from private.
|
package/src/tests/mocks.ts
CHANGED
|
@@ -87,7 +87,7 @@ export const mockTx = async (
|
|
|
87
87
|
chainId = Fr.ZERO,
|
|
88
88
|
version = Fr.ZERO,
|
|
89
89
|
vkTreeRoot = Fr.ZERO,
|
|
90
|
-
|
|
90
|
+
protocolContractsHash = Fr.ZERO,
|
|
91
91
|
}: {
|
|
92
92
|
numberOfNonRevertiblePublicCallRequests?: number;
|
|
93
93
|
numberOfRevertiblePublicCallRequests?: number;
|
|
@@ -100,7 +100,7 @@ export const mockTx = async (
|
|
|
100
100
|
chainId?: Fr;
|
|
101
101
|
version?: Fr;
|
|
102
102
|
vkTreeRoot?: Fr;
|
|
103
|
-
|
|
103
|
+
protocolContractsHash?: Fr;
|
|
104
104
|
} = {},
|
|
105
105
|
) => {
|
|
106
106
|
const totalPublicCallRequests =
|
|
@@ -118,7 +118,7 @@ export const mockTx = async (
|
|
|
118
118
|
data.constants.txContext.chainId = chainId;
|
|
119
119
|
data.constants.txContext.version = version;
|
|
120
120
|
data.constants.vkTreeRoot = vkTreeRoot;
|
|
121
|
-
data.constants.
|
|
121
|
+
data.constants.protocolContractsHash = protocolContractsHash;
|
|
122
122
|
|
|
123
123
|
// Set includeByTimestamp to the maximum allowed duration from the current time.
|
|
124
124
|
data.includeByTimestamp = BigInt(Math.floor(Date.now() / 1000) + MAX_INCLUDE_BY_TIMESTAMP_DURATION);
|
package/src/trees/index.ts
CHANGED
package/src/tx/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './state_reference.js';
|
|
|
6
6
|
export * from './partial_state_reference.js';
|
|
7
7
|
export * from './function_data.js';
|
|
8
8
|
export * from './tree_snapshots.js';
|
|
9
|
+
export * from './private_tx_constant_data.js';
|
|
9
10
|
export * from './tx_constant_data.js';
|
|
10
11
|
export * from './tx_context.js';
|
|
11
12
|
export * from './tx_request.js';
|
|
@@ -29,3 +30,4 @@ export * from './hashed_values.js';
|
|
|
29
30
|
export * from './indexed_tx_effect.js';
|
|
30
31
|
export * from './offchain_effect.js';
|
|
31
32
|
export * from './profiling.js';
|
|
33
|
+
export * from './protocol_contracts.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { TX_CONSTANT_DATA_LENGTH } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
|
|
4
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
|
+
|
|
6
|
+
import { BlockHeader } from './block_header.js';
|
|
7
|
+
import { ProtocolContracts } from './protocol_contracts.js';
|
|
8
|
+
import { TxContext } from './tx_context.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Data that is constant/not modified by neither of the kernels.
|
|
12
|
+
*/
|
|
13
|
+
export class PrivateTxConstantData {
|
|
14
|
+
constructor(
|
|
15
|
+
/** Header of a block whose state is used during execution (not the block the transaction is included in). */
|
|
16
|
+
public anchorBlockHeader: BlockHeader,
|
|
17
|
+
/**
|
|
18
|
+
* Context of the transaction.
|
|
19
|
+
*
|
|
20
|
+
* Note: `chainId` and `version` in txContext are not redundant to the values in
|
|
21
|
+
* self.anchor_block_header.global_variables because they can be different in case of a protocol upgrade. In such
|
|
22
|
+
* a situation we could be using header from a block before the upgrade took place but be using the updated
|
|
23
|
+
* protocol to execute and prove the transaction.
|
|
24
|
+
*/
|
|
25
|
+
public txContext: TxContext,
|
|
26
|
+
/**
|
|
27
|
+
* Root of the vk tree for the protocol circuits.
|
|
28
|
+
*/
|
|
29
|
+
public vkTreeRoot: Fr,
|
|
30
|
+
/**
|
|
31
|
+
* List of protocol contracts.
|
|
32
|
+
*/
|
|
33
|
+
public protocolContracts: ProtocolContracts,
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
static from(fields: FieldsOf<PrivateTxConstantData>) {
|
|
37
|
+
return new PrivateTxConstantData(...PrivateTxConstantData.getFields(fields));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static getFields(fields: FieldsOf<PrivateTxConstantData>) {
|
|
41
|
+
return [fields.anchorBlockHeader, fields.txContext, fields.vkTreeRoot, fields.protocolContracts] as const;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static fromFields(fields: Fr[] | FieldReader): PrivateTxConstantData {
|
|
45
|
+
const reader = FieldReader.asReader(fields);
|
|
46
|
+
return new PrivateTxConstantData(
|
|
47
|
+
reader.readObject(BlockHeader),
|
|
48
|
+
reader.readObject(TxContext),
|
|
49
|
+
reader.readField(),
|
|
50
|
+
reader.readObject(ProtocolContracts),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
toFields(): Fr[] {
|
|
55
|
+
const fields = serializeToFields(...PrivateTxConstantData.getFields(this));
|
|
56
|
+
if (fields.length !== TX_CONSTANT_DATA_LENGTH) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Invalid number of fields for PrivateTxConstantData. Expected ${TX_CONSTANT_DATA_LENGTH}, got ${fields.length}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return fields;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static fromBuffer(buffer: Buffer | BufferReader): PrivateTxConstantData {
|
|
65
|
+
const reader = BufferReader.asReader(buffer);
|
|
66
|
+
return new PrivateTxConstantData(
|
|
67
|
+
reader.readObject(BlockHeader),
|
|
68
|
+
reader.readObject(TxContext),
|
|
69
|
+
Fr.fromBuffer(reader),
|
|
70
|
+
reader.readObject(ProtocolContracts),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
toBuffer() {
|
|
75
|
+
return serializeToBuffer(...PrivateTxConstantData.getFields(this));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static empty() {
|
|
79
|
+
return new PrivateTxConstantData(BlockHeader.empty(), TxContext.empty(), Fr.ZERO, ProtocolContracts.empty());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getSize() {
|
|
83
|
+
return (
|
|
84
|
+
this.anchorBlockHeader.getSize() +
|
|
85
|
+
this.txContext.getSize() +
|
|
86
|
+
this.vkTreeRoot.size +
|
|
87
|
+
this.protocolContracts.getSize()
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
clone(): PrivateTxConstantData {
|
|
92
|
+
return PrivateTxConstantData.fromBuffer(this.toBuffer());
|
|
93
|
+
}
|
|
94
|
+
}
|