@aztec/pxe 0.55.1 → 0.57.0
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/bin/index.js +0 -0
- package/dest/database/deferred_note_dao.d.ts +6 -2
- package/dest/database/deferred_note_dao.d.ts.map +1 -1
- package/dest/database/deferred_note_dao.js +8 -5
- package/dest/database/incoming_note_dao.d.ts +3 -1
- package/dest/database/incoming_note_dao.d.ts.map +1 -1
- package/dest/database/incoming_note_dao.js +5 -1
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +3 -2
- package/dest/database/outgoing_note_dao.d.ts +3 -1
- package/dest/database/outgoing_note_dao.d.ts.map +1 -1
- package/dest/database/outgoing_note_dao.js +5 -1
- package/dest/kernel_oracle/index.d.ts +1 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +260 -0
- package/dest/kernel_prover/hints/index.d.ts +1 -2
- package/dest/kernel_prover/hints/index.d.ts.map +1 -1
- package/dest/kernel_prover/hints/index.js +2 -3
- package/dest/kernel_prover/kernel_prover.d.ts +2 -4
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +26 -25
- package/dest/kernel_prover/test/test_circuit_prover.d.ts +2 -3
- package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/kernel_prover/test/test_circuit_prover.js +8 -11
- package/dest/note_processor/note_processor.d.ts.map +1 -1
- package/dest/note_processor/note_processor.js +13 -15
- package/dest/note_processor/utils/add_nullable_field_to_payload.d.ts +12 -0
- package/dest/note_processor/utils/add_nullable_field_to_payload.d.ts.map +1 -0
- package/dest/note_processor/utils/add_nullable_field_to_payload.js +46 -0
- package/dest/note_processor/utils/brute_force_note_info.d.ts +26 -0
- package/dest/note_processor/utils/brute_force_note_info.d.ts.map +1 -0
- package/dest/note_processor/utils/brute_force_note_info.js +52 -0
- package/dest/note_processor/utils/index.d.ts +3 -0
- package/dest/note_processor/utils/index.d.ts.map +1 -0
- package/dest/note_processor/utils/index.js +2 -0
- package/dest/note_processor/{produce_note_dao.d.ts → utils/produce_note_daos.d.ts} +12 -8
- package/dest/note_processor/utils/produce_note_daos.d.ts.map +1 -0
- package/dest/note_processor/utils/produce_note_daos.js +53 -0
- package/dest/note_processor/utils/produce_note_daos_for_key.d.ts +9 -0
- package/dest/note_processor/utils/produce_note_daos_for_key.d.ts.map +1 -0
- package/dest/note_processor/utils/produce_note_daos_for_key.js +80 -0
- package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
- package/dest/pxe_http/pxe_http_server.js +12 -4
- package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/create_pxe_service.js +1 -3
- package/dest/pxe_service/pxe_service.d.ts +8 -8
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +39 -56
- package/package.json +17 -14
- package/src/database/deferred_note_dao.ts +5 -1
- package/src/database/incoming_note_dao.ts +24 -1
- package/src/database/kv_pxe_database.ts +3 -1
- package/src/database/outgoing_note_dao.ts +23 -1
- package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +467 -0
- package/src/kernel_prover/hints/index.ts +1 -2
- package/src/kernel_prover/kernel_prover.ts +53 -76
- package/src/kernel_prover/test/test_circuit_prover.ts +11 -15
- package/src/note_processor/note_processor.ts +30 -21
- package/src/note_processor/utils/add_nullable_field_to_payload.ts +67 -0
- package/src/note_processor/utils/brute_force_note_info.ts +82 -0
- package/src/note_processor/utils/index.ts +2 -0
- package/src/note_processor/utils/produce_note_daos.ts +114 -0
- package/src/note_processor/utils/produce_note_daos_for_key.ts +157 -0
- package/src/pxe_http/pxe_http_server.ts +18 -3
- package/src/pxe_service/create_pxe_service.ts +0 -2
- package/src/pxe_service/pxe_service.ts +61 -100
- package/dest/kernel_prover/hints/build_private_kernel_reset_hints.d.ts +0 -5
- package/dest/kernel_prover/hints/build_private_kernel_reset_hints.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_hints.js +0 -90
- package/dest/kernel_prover/hints/needs_reset.d.ts +0 -5
- package/dest/kernel_prover/hints/needs_reset.d.ts.map +0 -1
- package/dest/kernel_prover/hints/needs_reset.js +0 -38
- package/dest/note_processor/produce_note_dao.d.ts.map +0 -1
- package/dest/note_processor/produce_note_dao.js +0 -131
- package/src/kernel_prover/hints/build_private_kernel_reset_hints.ts +0 -249
- package/src/kernel_prover/hints/needs_reset.ts +0 -54
- package/src/note_processor/produce_note_dao.ts +0 -235
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { type L1NotePayload, type TxHash, UnencryptedTxL2Logs } from '@aztec/circuit-types';
|
|
2
|
+
import { Fr, type PublicKey } from '@aztec/circuits.js';
|
|
3
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
4
|
+
import { type AcirSimulator, ContractNotFoundError } from '@aztec/simulator';
|
|
5
|
+
|
|
6
|
+
import { DeferredNoteDao } from '../../database/deferred_note_dao.js';
|
|
7
|
+
import { type PxeDatabase } from '../../database/pxe_database.js';
|
|
8
|
+
import { addNullableFieldsToPayload } from './add_nullable_field_to_payload.js';
|
|
9
|
+
import { type NoteInfo, bruteForceNoteInfo } from './brute_force_note_info.js';
|
|
10
|
+
|
|
11
|
+
export async function produceNoteDaosForKey<T>(
|
|
12
|
+
simulator: AcirSimulator,
|
|
13
|
+
db: PxeDatabase,
|
|
14
|
+
pkM: PublicKey,
|
|
15
|
+
payload: L1NotePayload,
|
|
16
|
+
txHash: TxHash,
|
|
17
|
+
noteHashes: Fr[],
|
|
18
|
+
dataStartIndexForTx: number,
|
|
19
|
+
excludedIndices: Set<number>,
|
|
20
|
+
logger: Logger,
|
|
21
|
+
unencryptedLogs: UnencryptedTxL2Logs,
|
|
22
|
+
daoConstructor: (payload: L1NotePayload, noteInfo: NoteInfo, dataStartIndexForTx: number, pkM: PublicKey) => T,
|
|
23
|
+
): Promise<[T | undefined, DeferredNoteDao | undefined]> {
|
|
24
|
+
let noteDao: T | undefined;
|
|
25
|
+
let deferredNoteDao: DeferredNoteDao | undefined;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const noteInfo = await bruteForceNoteInfo(
|
|
29
|
+
simulator,
|
|
30
|
+
noteHashes,
|
|
31
|
+
txHash,
|
|
32
|
+
payload,
|
|
33
|
+
excludedIndices,
|
|
34
|
+
true, // For incoming we compute a nullifier (recipient of incoming is the party that nullifies).
|
|
35
|
+
);
|
|
36
|
+
excludedIndices?.add(noteInfo.noteHashIndex);
|
|
37
|
+
|
|
38
|
+
noteDao = daoConstructor(payload, noteInfo, dataStartIndexForTx, pkM);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (e instanceof ContractNotFoundError) {
|
|
41
|
+
logger.warn(e.message);
|
|
42
|
+
|
|
43
|
+
deferredNoteDao = new DeferredNoteDao(
|
|
44
|
+
pkM,
|
|
45
|
+
payload.note,
|
|
46
|
+
payload.contractAddress,
|
|
47
|
+
payload.storageSlot,
|
|
48
|
+
payload.noteTypeId,
|
|
49
|
+
txHash,
|
|
50
|
+
noteHashes,
|
|
51
|
+
dataStartIndexForTx,
|
|
52
|
+
unencryptedLogs,
|
|
53
|
+
);
|
|
54
|
+
} else if (
|
|
55
|
+
(e as any).message.includes('failed to solve blackbox function: embedded_curve_add') ||
|
|
56
|
+
(e as any).message.includes('Could not find key prefix.')
|
|
57
|
+
) {
|
|
58
|
+
// TODO(#8769): This branch is a temporary partial notes delivery solution that should be eventually replaced.
|
|
59
|
+
// Both error messages above occur only when we are dealing with a partial note and are thrown when calling
|
|
60
|
+
// `note.compute_note_hash()` or `note.compute_nullifier_without_context()`
|
|
61
|
+
// in `compute_note_hash_and_optionally_a_nullifier` function. It occurs with partial notes because in the
|
|
62
|
+
// partial flow we receive a note log of a note that is missing some fields here and then we try to compute
|
|
63
|
+
// the note hash with MSM while some of the fields are zeroed out (or get a nsk for zero npk_m_hash).
|
|
64
|
+
noteDao = await handlePartialNote(
|
|
65
|
+
simulator,
|
|
66
|
+
db,
|
|
67
|
+
pkM,
|
|
68
|
+
payload,
|
|
69
|
+
txHash,
|
|
70
|
+
noteHashes,
|
|
71
|
+
dataStartIndexForTx,
|
|
72
|
+
excludedIndices,
|
|
73
|
+
logger,
|
|
74
|
+
unencryptedLogs,
|
|
75
|
+
daoConstructor,
|
|
76
|
+
);
|
|
77
|
+
} else {
|
|
78
|
+
logger.error(`Could not process note because of "${e}". Discarding note...`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return [noteDao, deferredNoteDao];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function handlePartialNote<T>(
|
|
86
|
+
simulator: AcirSimulator,
|
|
87
|
+
db: PxeDatabase,
|
|
88
|
+
pkM: PublicKey,
|
|
89
|
+
payload: L1NotePayload,
|
|
90
|
+
txHash: TxHash,
|
|
91
|
+
noteHashes: Fr[],
|
|
92
|
+
dataStartIndexForTx: number,
|
|
93
|
+
excludedIndices: Set<number>,
|
|
94
|
+
logger: Logger,
|
|
95
|
+
unencryptedLogs: UnencryptedTxL2Logs,
|
|
96
|
+
daoConstructor: (payload: L1NotePayload, noteInfo: NoteInfo, dataStartIndexForTx: number, pkM: PublicKey) => T,
|
|
97
|
+
): Promise<T | undefined> {
|
|
98
|
+
let noteDao: T | undefined;
|
|
99
|
+
|
|
100
|
+
for (const functionLogs of unencryptedLogs.functionLogs) {
|
|
101
|
+
for (const log of functionLogs.logs) {
|
|
102
|
+
const { data } = log;
|
|
103
|
+
// It is the expectation that partial notes will have the corresponding unencrypted log be multiple
|
|
104
|
+
// of Fr.SIZE_IN_BYTES as the nullable fields should be simply concatenated.
|
|
105
|
+
if (data.length % Fr.SIZE_IN_BYTES === 0) {
|
|
106
|
+
const nullableFields = [];
|
|
107
|
+
for (let i = 0; i < data.length; i += Fr.SIZE_IN_BYTES) {
|
|
108
|
+
const chunk = data.subarray(i, i + Fr.SIZE_IN_BYTES);
|
|
109
|
+
nullableFields.push(Fr.fromBuffer(chunk));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// We insert the nullable fields into the note and then we try to produce the note dao again
|
|
113
|
+
const payloadWithNullableFields = await addNullableFieldsToPayload(db, payload, nullableFields);
|
|
114
|
+
|
|
115
|
+
let deferredNoteDao: DeferredNoteDao | undefined;
|
|
116
|
+
try {
|
|
117
|
+
[noteDao, deferredNoteDao] = await produceNoteDaosForKey(
|
|
118
|
+
simulator,
|
|
119
|
+
db,
|
|
120
|
+
pkM,
|
|
121
|
+
payloadWithNullableFields,
|
|
122
|
+
txHash,
|
|
123
|
+
noteHashes,
|
|
124
|
+
dataStartIndexForTx,
|
|
125
|
+
excludedIndices,
|
|
126
|
+
logger,
|
|
127
|
+
UnencryptedTxL2Logs.empty(), // We set unencrypted logs to empty to prevent infinite recursion.
|
|
128
|
+
daoConstructor,
|
|
129
|
+
);
|
|
130
|
+
} catch (e) {
|
|
131
|
+
// We ignore the key prefix error because that is expected to be triggered when an incorrect value
|
|
132
|
+
// is inserted at the position of `npk_m_hash`. This happens commonly because we are brute forcing
|
|
133
|
+
// the unencrypted logs.
|
|
134
|
+
if (!(e as any).message.includes('Could not find key prefix.')) {
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (deferredNoteDao) {
|
|
140
|
+
// This should not happen as we should first get contract not found error before the blackbox func error.
|
|
141
|
+
throw new Error('Partial notes should never be deferred.');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (noteDao) {
|
|
145
|
+
// We managed to complete the partial note so we terminate the search.
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!noteDao) {
|
|
153
|
+
logger.error(`Partial note note found. Discarding note...`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return noteDao;
|
|
157
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthWitness,
|
|
3
3
|
CompleteAddress,
|
|
4
|
+
CountedNoteLog,
|
|
5
|
+
CountedPublicExecutionRequest,
|
|
6
|
+
EncryptedL2Log,
|
|
7
|
+
EncryptedL2NoteLog,
|
|
4
8
|
EncryptedNoteL2BlockL2Logs,
|
|
5
9
|
ExtendedNote,
|
|
6
10
|
ExtendedUnencryptedL2Log,
|
|
@@ -9,17 +13,20 @@ import {
|
|
|
9
13
|
Note,
|
|
10
14
|
NullifierMembershipWitness,
|
|
11
15
|
type PXE,
|
|
16
|
+
PrivateExecutionResult,
|
|
12
17
|
SiblingPath,
|
|
13
|
-
SimulatedTx,
|
|
14
18
|
Tx,
|
|
15
19
|
TxEffect,
|
|
16
20
|
TxExecutionRequest,
|
|
17
21
|
TxHash,
|
|
22
|
+
TxProvingResult,
|
|
18
23
|
TxReceipt,
|
|
24
|
+
TxSimulationResult,
|
|
19
25
|
UnencryptedL2BlockL2Logs,
|
|
26
|
+
UnencryptedL2Log,
|
|
20
27
|
UniqueNote,
|
|
21
28
|
} from '@aztec/circuit-types';
|
|
22
|
-
import { FunctionSelector } from '@aztec/circuits.js';
|
|
29
|
+
import { FunctionSelector, PrivateCallStackItem } from '@aztec/circuits.js';
|
|
23
30
|
import { NoteSelector } from '@aztec/foundation/abi';
|
|
24
31
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
25
32
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
@@ -59,9 +66,17 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
|
|
|
59
66
|
},
|
|
60
67
|
{
|
|
61
68
|
EncryptedNoteL2BlockL2Logs,
|
|
69
|
+
EncryptedL2NoteLog,
|
|
70
|
+
EncryptedL2Log,
|
|
71
|
+
UnencryptedL2Log,
|
|
62
72
|
NoteSelector,
|
|
63
73
|
NullifierMembershipWitness,
|
|
64
|
-
|
|
74
|
+
TxSimulationResult,
|
|
75
|
+
TxProvingResult,
|
|
76
|
+
PrivateExecutionResult,
|
|
77
|
+
PrivateCallStackItem,
|
|
78
|
+
CountedPublicExecutionRequest,
|
|
79
|
+
CountedNoteLog,
|
|
65
80
|
Tx,
|
|
66
81
|
TxReceipt,
|
|
67
82
|
UnencryptedL2BlockL2Logs,
|
|
@@ -8,7 +8,6 @@ import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registr
|
|
|
8
8
|
import { getCanonicalClassRegisterer } from '@aztec/protocol-contracts/class-registerer';
|
|
9
9
|
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
10
10
|
import { getCanonicalInstanceDeployer } from '@aztec/protocol-contracts/instance-deployer';
|
|
11
|
-
import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
|
|
12
11
|
import { getCanonicalMultiCallEntrypointContract } from '@aztec/protocol-contracts/multi-call-entrypoint';
|
|
13
12
|
import { getCanonicalRouter } from '@aztec/protocol-contracts/router';
|
|
14
13
|
|
|
@@ -51,7 +50,6 @@ export async function createPXEService(
|
|
|
51
50
|
getCanonicalInstanceDeployer(),
|
|
52
51
|
getCanonicalMultiCallEntrypointContract(),
|
|
53
52
|
getCanonicalFeeJuice(),
|
|
54
|
-
getCanonicalKeyRegistry(),
|
|
55
53
|
getCanonicalAuthRegistry(),
|
|
56
54
|
getCanonicalRouter(),
|
|
57
55
|
]) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AuthWitness,
|
|
3
3
|
type AztecNode,
|
|
4
|
-
EncryptedNoteTxL2Logs,
|
|
5
|
-
EncryptedTxL2Logs,
|
|
6
4
|
type EventMetadata,
|
|
7
5
|
EventType,
|
|
8
6
|
type ExtendedNote,
|
|
@@ -16,59 +14,53 @@ import {
|
|
|
16
14
|
type OutgoingNotesFilter,
|
|
17
15
|
type PXE,
|
|
18
16
|
type PXEInfo,
|
|
17
|
+
type PrivateExecutionResult,
|
|
19
18
|
type PrivateKernelProver,
|
|
19
|
+
type PrivateKernelSimulateOutput,
|
|
20
|
+
PrivateSimulationResult,
|
|
21
|
+
type PublicSimulationOutput,
|
|
20
22
|
type SiblingPath,
|
|
21
|
-
SimulatedTx,
|
|
22
23
|
SimulationError,
|
|
23
|
-
|
|
24
|
-
Tx,
|
|
24
|
+
type Tx,
|
|
25
25
|
type TxEffect,
|
|
26
26
|
type TxExecutionRequest,
|
|
27
27
|
type TxHash,
|
|
28
|
+
TxProvingResult,
|
|
28
29
|
type TxReceipt,
|
|
29
|
-
|
|
30
|
+
TxSimulationResult,
|
|
30
31
|
UniqueNote,
|
|
31
32
|
getNonNullifiedL1ToL2MessageWitness,
|
|
32
33
|
isNoirCallStackUnresolved,
|
|
33
34
|
} from '@aztec/circuit-types';
|
|
35
|
+
import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
|
|
34
36
|
import {
|
|
35
37
|
AztecAddress,
|
|
36
38
|
type CompleteAddress,
|
|
37
39
|
type L1_TO_L2_MSG_TREE_HEIGHT,
|
|
40
|
+
PUBLIC_DISPATCH_SELECTOR,
|
|
38
41
|
type PartialAddress,
|
|
42
|
+
type PrivateKernelTailCircuitPublicInputs,
|
|
39
43
|
computeContractAddressFromInstance,
|
|
40
44
|
computeContractClassId,
|
|
41
45
|
getContractClassFromArtifact,
|
|
42
46
|
} from '@aztec/circuits.js';
|
|
43
47
|
import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash';
|
|
44
48
|
import {
|
|
49
|
+
type AbiDecoded,
|
|
45
50
|
type ContractArtifact,
|
|
46
|
-
type DecodedReturn,
|
|
47
51
|
EventSelector,
|
|
48
52
|
FunctionSelector,
|
|
49
53
|
encodeArguments,
|
|
50
54
|
} from '@aztec/foundation/abi';
|
|
51
|
-
import {
|
|
55
|
+
import { Fr, type Point } from '@aztec/foundation/fields';
|
|
52
56
|
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
53
57
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
54
58
|
import { type KeyStore } from '@aztec/key-store';
|
|
55
59
|
import { ClassRegistererAddress } from '@aztec/protocol-contracts/class-registerer';
|
|
56
60
|
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
57
61
|
import { getCanonicalInstanceDeployer } from '@aztec/protocol-contracts/instance-deployer';
|
|
58
|
-
import { getCanonicalKeyRegistryAddress } from '@aztec/protocol-contracts/key-registry';
|
|
59
62
|
import { getCanonicalMultiCallEntrypointAddress } from '@aztec/protocol-contracts/multi-call-entrypoint';
|
|
60
|
-
import {
|
|
61
|
-
type AcirSimulator,
|
|
62
|
-
type ExecutionResult,
|
|
63
|
-
accumulateReturnValues,
|
|
64
|
-
collectEnqueuedPublicFunctionCalls,
|
|
65
|
-
collectPublicTeardownFunctionCall,
|
|
66
|
-
collectSortedEncryptedLogs,
|
|
67
|
-
collectSortedNoteEncryptedLogs,
|
|
68
|
-
collectSortedUnencryptedLogs,
|
|
69
|
-
resolveAssertionMessage,
|
|
70
|
-
resolveOpcodeLocations,
|
|
71
|
-
} from '@aztec/simulator';
|
|
63
|
+
import { type AcirSimulator, resolveAssertionMessage, resolveOpcodeLocations } from '@aztec/simulator';
|
|
72
64
|
import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
73
65
|
import { type NodeInfo } from '@aztec/types/interfaces';
|
|
74
66
|
|
|
@@ -176,10 +168,6 @@ export class PXEService implements PXE {
|
|
|
176
168
|
return this.db.getAuthWitness(messageHash);
|
|
177
169
|
}
|
|
178
170
|
|
|
179
|
-
async rotateNskM(account: AztecAddress, secretKey: Fq): Promise<void> {
|
|
180
|
-
await this.keyStore.rotateMasterNullifierKey(account, secretKey);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
171
|
public addCapsule(capsule: Fr[]) {
|
|
184
172
|
return this.db.addCapsule(capsule);
|
|
185
173
|
}
|
|
@@ -312,8 +300,6 @@ export class PXEService implements PXE {
|
|
|
312
300
|
public async getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]> {
|
|
313
301
|
const noteDaos = await this.db.getIncomingNotes(filter);
|
|
314
302
|
|
|
315
|
-
// TODO(#6531): Refactor --> This type conversion is ugly but I decided to keep it this way for now because
|
|
316
|
-
// key rotation will affect this
|
|
317
303
|
const extendedNotes = noteDaos.map(async dao => {
|
|
318
304
|
let owner = filter.owner;
|
|
319
305
|
if (owner === undefined) {
|
|
@@ -341,8 +327,6 @@ export class PXEService implements PXE {
|
|
|
341
327
|
public async getOutgoingNotes(filter: OutgoingNotesFilter): Promise<UniqueNote[]> {
|
|
342
328
|
const noteDaos = await this.db.getOutgoingNotes(filter);
|
|
343
329
|
|
|
344
|
-
// TODO(#6532): Refactor --> This type conversion is ugly but I decided to keep it this way for now because
|
|
345
|
-
// key rotation will affect this
|
|
346
330
|
const extendedNotes = noteDaos.map(async dao => {
|
|
347
331
|
let owner = filter.owner;
|
|
348
332
|
if (owner === undefined) {
|
|
@@ -518,13 +502,21 @@ export class PXEService implements PXE {
|
|
|
518
502
|
return await this.node.getBlock(blockNumber);
|
|
519
503
|
}
|
|
520
504
|
|
|
521
|
-
|
|
505
|
+
async #simulateKernels(
|
|
506
|
+
txRequest: TxExecutionRequest,
|
|
507
|
+
privateExecutionResult: PrivateExecutionResult,
|
|
508
|
+
): Promise<PrivateKernelTailCircuitPublicInputs> {
|
|
509
|
+
const result = await this.#prove(txRequest, new TestPrivateKernelProver(), privateExecutionResult);
|
|
510
|
+
return result.publicInputs;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
public proveTx(
|
|
514
|
+
txRequest: TxExecutionRequest,
|
|
515
|
+
privateExecutionResult: PrivateExecutionResult,
|
|
516
|
+
): Promise<TxProvingResult> {
|
|
522
517
|
return this.jobQueue.put(async () => {
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
simulatedTx.publicOutput = await this.#simulatePublicCalls(simulatedTx.tx);
|
|
526
|
-
}
|
|
527
|
-
return simulatedTx.tx;
|
|
518
|
+
const { publicInputs, clientIvcProof } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult);
|
|
519
|
+
return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!);
|
|
528
520
|
});
|
|
529
521
|
}
|
|
530
522
|
|
|
@@ -535,15 +527,19 @@ export class PXEService implements PXE {
|
|
|
535
527
|
msgSender: AztecAddress | undefined = undefined,
|
|
536
528
|
skipTxValidation: boolean = false,
|
|
537
529
|
scopes?: AztecAddress[],
|
|
538
|
-
): Promise<
|
|
530
|
+
): Promise<TxSimulationResult> {
|
|
539
531
|
return await this.jobQueue.put(async () => {
|
|
540
|
-
const
|
|
532
|
+
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
|
|
533
|
+
const publicInputs = await this.#simulateKernels(txRequest, privateExecutionResult);
|
|
534
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
535
|
+
const simulatedTx = privateSimulationResult.toSimulatedTx();
|
|
536
|
+
let publicOutput: PublicSimulationOutput | undefined;
|
|
541
537
|
if (simulatePublic) {
|
|
542
|
-
|
|
538
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx);
|
|
543
539
|
}
|
|
544
540
|
|
|
545
541
|
if (!skipTxValidation) {
|
|
546
|
-
if (!(await this.node.isValidTx(simulatedTx
|
|
542
|
+
if (!(await this.node.isValidTx(simulatedTx, true))) {
|
|
547
543
|
throw new Error('The simulated transaction is unable to be added to state and is invalid.');
|
|
548
544
|
}
|
|
549
545
|
}
|
|
@@ -553,9 +549,9 @@ export class PXEService implements PXE {
|
|
|
553
549
|
// Meaning that it will not necessarily have produced a nullifier (and thus have no TxHash)
|
|
554
550
|
// If we log, the `getTxHash` function will throw.
|
|
555
551
|
if (!msgSender) {
|
|
556
|
-
this.log.info(`Executed local simulation for ${simulatedTx.
|
|
552
|
+
this.log.info(`Executed local simulation for ${simulatedTx.getTxHash()}`);
|
|
557
553
|
}
|
|
558
|
-
return
|
|
554
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput);
|
|
559
555
|
});
|
|
560
556
|
}
|
|
561
557
|
|
|
@@ -576,7 +572,7 @@ export class PXEService implements PXE {
|
|
|
576
572
|
to: AztecAddress,
|
|
577
573
|
_from?: AztecAddress,
|
|
578
574
|
scopes?: AztecAddress[],
|
|
579
|
-
): Promise<
|
|
575
|
+
): Promise<AbiDecoded> {
|
|
580
576
|
// all simulations must be serialized w.r.t. the synchronizer
|
|
581
577
|
return await this.jobQueue.put(async () => {
|
|
582
578
|
// TODO - Should check if `from` has the permission to call the view function.
|
|
@@ -667,7 +663,6 @@ export class PXEService implements PXE {
|
|
|
667
663
|
classRegisterer: ClassRegistererAddress,
|
|
668
664
|
feeJuice: getCanonicalFeeJuice().address,
|
|
669
665
|
instanceDeployer: getCanonicalInstanceDeployer().address,
|
|
670
|
-
keyRegistry: getCanonicalKeyRegistryAddress(),
|
|
671
666
|
multiCallEntrypoint: getCanonicalMultiCallEntrypointAddress(),
|
|
672
667
|
},
|
|
673
668
|
});
|
|
@@ -696,11 +691,11 @@ export class PXEService implements PXE {
|
|
|
696
691
|
};
|
|
697
692
|
}
|
|
698
693
|
|
|
699
|
-
async #
|
|
694
|
+
async #executePrivate(
|
|
700
695
|
txRequest: TxExecutionRequest,
|
|
701
696
|
msgSender?: AztecAddress,
|
|
702
697
|
scopes?: AztecAddress[],
|
|
703
|
-
): Promise<
|
|
698
|
+
): Promise<PrivateExecutionResult> {
|
|
704
699
|
// TODO - Pause syncing while simulating.
|
|
705
700
|
|
|
706
701
|
const { contractAddress, functionArtifact } = await this.#getSimulationParameters(txRequest);
|
|
@@ -758,9 +753,13 @@ export class PXEService implements PXE {
|
|
|
758
753
|
if (err instanceof SimulationError) {
|
|
759
754
|
const callStack = err.getCallStack();
|
|
760
755
|
const originalFailingFunction = callStack[callStack.length - 1];
|
|
756
|
+
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Properly fix this.
|
|
757
|
+
// To be able to resolve the assertion message, we need to use the information from the public dispatch function,
|
|
758
|
+
// no matter what the call stack selector points to (since we've modified it to point to the target function).
|
|
759
|
+
// We should remove this because the AVM (or public protocol) shouldn't be aware of the public dispatch calling convention.
|
|
761
760
|
const debugInfo = await this.contractDataOracle.getFunctionDebugMetadata(
|
|
762
761
|
originalFailingFunction.contractAddress,
|
|
763
|
-
|
|
762
|
+
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
764
763
|
);
|
|
765
764
|
const noirCallStack = err.getNoirCallStack();
|
|
766
765
|
if (debugInfo) {
|
|
@@ -803,40 +802,15 @@ export class PXEService implements PXE {
|
|
|
803
802
|
* A private transaction object containing the proof, public inputs, and encrypted logs.
|
|
804
803
|
* The return values of the private execution
|
|
805
804
|
*/
|
|
806
|
-
async #
|
|
805
|
+
async #prove(
|
|
807
806
|
txExecutionRequest: TxExecutionRequest,
|
|
808
807
|
proofCreator: PrivateKernelProver,
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
): Promise<SimulatedTx> {
|
|
812
|
-
// Get values that allow us to reconstruct the block hash
|
|
813
|
-
const executionResult = await this.#simulate(txExecutionRequest, msgSender, scopes);
|
|
814
|
-
|
|
808
|
+
privateExecutionResult: PrivateExecutionResult,
|
|
809
|
+
): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
815
810
|
const kernelOracle = new KernelOracle(this.contractDataOracle, this.keyStore, this.node);
|
|
816
811
|
const kernelProver = new KernelProver(kernelOracle, proofCreator);
|
|
817
812
|
this.log.debug(`Executing kernel prover...`);
|
|
818
|
-
|
|
819
|
-
txExecutionRequest.toTxRequest(),
|
|
820
|
-
executionResult,
|
|
821
|
-
);
|
|
822
|
-
|
|
823
|
-
const noteEncryptedLogs = new EncryptedNoteTxL2Logs([collectSortedNoteEncryptedLogs(executionResult)]);
|
|
824
|
-
const unencryptedLogs = new UnencryptedTxL2Logs([collectSortedUnencryptedLogs(executionResult)]);
|
|
825
|
-
const encryptedLogs = new EncryptedTxL2Logs([collectSortedEncryptedLogs(executionResult)]);
|
|
826
|
-
const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(executionResult);
|
|
827
|
-
const teardownPublicFunction = collectPublicTeardownFunctionCall(executionResult);
|
|
828
|
-
|
|
829
|
-
const tx = new Tx(
|
|
830
|
-
publicInputs,
|
|
831
|
-
clientIvcProof!,
|
|
832
|
-
noteEncryptedLogs,
|
|
833
|
-
encryptedLogs,
|
|
834
|
-
unencryptedLogs,
|
|
835
|
-
enqueuedPublicFunctions,
|
|
836
|
-
teardownPublicFunction,
|
|
837
|
-
);
|
|
838
|
-
|
|
839
|
-
return new SimulatedTx(tx, accumulateReturnValues(executionResult));
|
|
813
|
+
return await kernelProver.prove(txExecutionRequest.toTxRequest(), privateExecutionResult);
|
|
840
814
|
}
|
|
841
815
|
|
|
842
816
|
/**
|
|
@@ -888,7 +862,7 @@ export class PXEService implements PXE {
|
|
|
888
862
|
return Promise.resolve(this.synchronizer.getSyncStatus());
|
|
889
863
|
}
|
|
890
864
|
|
|
891
|
-
public getSyncStats() {
|
|
865
|
+
public getSyncStats(): Promise<{ [address: string]: NoteProcessorStats }> {
|
|
892
866
|
return Promise.resolve(this.synchronizer.getSyncStats());
|
|
893
867
|
}
|
|
894
868
|
|
|
@@ -953,11 +927,10 @@ export class PXEService implements PXE {
|
|
|
953
927
|
|
|
954
928
|
const visibleEvents = encryptedLogs.flatMap(encryptedLog => {
|
|
955
929
|
for (const sk of vsks) {
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
return [decryptedLog];
|
|
930
|
+
const decryptedEvent =
|
|
931
|
+
L1EventPayload.decryptAsIncoming(encryptedLog, sk) ?? L1EventPayload.decryptAsOutgoing(encryptedLog, sk);
|
|
932
|
+
if (decryptedEvent !== undefined) {
|
|
933
|
+
return [decryptedEvent];
|
|
961
934
|
}
|
|
962
935
|
}
|
|
963
936
|
|
|
@@ -966,25 +939,19 @@ export class PXEService implements PXE {
|
|
|
966
939
|
|
|
967
940
|
const decodedEvents = visibleEvents
|
|
968
941
|
.map(visibleEvent => {
|
|
969
|
-
if (visibleEvent
|
|
942
|
+
if (visibleEvent === undefined) {
|
|
970
943
|
return undefined;
|
|
971
944
|
}
|
|
972
|
-
if (!visibleEvent.
|
|
945
|
+
if (!visibleEvent.eventTypeId.equals(eventMetadata.eventSelector)) {
|
|
973
946
|
return undefined;
|
|
974
947
|
}
|
|
975
|
-
if (visibleEvent.
|
|
948
|
+
if (visibleEvent.event.items.length !== eventMetadata.fieldNames.length) {
|
|
976
949
|
throw new Error(
|
|
977
|
-
'Something is weird here, we have matching
|
|
950
|
+
'Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length',
|
|
978
951
|
);
|
|
979
952
|
}
|
|
980
953
|
|
|
981
|
-
return eventMetadata.
|
|
982
|
-
(acc, curr, i) => ({
|
|
983
|
-
...acc,
|
|
984
|
-
[curr]: visibleEvent.payload.event.items[i],
|
|
985
|
-
}),
|
|
986
|
-
{} as T,
|
|
987
|
-
);
|
|
954
|
+
return eventMetadata.decode(visibleEvent);
|
|
988
955
|
})
|
|
989
956
|
.filter(visibleEvent => visibleEvent !== undefined) as T[];
|
|
990
957
|
|
|
@@ -1011,17 +978,11 @@ export class PXEService implements PXE {
|
|
|
1011
978
|
|
|
1012
979
|
if (unencryptedLogBuf.byteLength !== eventMetadata.fieldNames.length * 32 + 32) {
|
|
1013
980
|
throw new Error(
|
|
1014
|
-
'Something is weird here, we have matching
|
|
981
|
+
'Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length',
|
|
1015
982
|
);
|
|
1016
983
|
}
|
|
1017
984
|
|
|
1018
|
-
return eventMetadata.
|
|
1019
|
-
(acc, curr, i) => ({
|
|
1020
|
-
...acc,
|
|
1021
|
-
[curr]: new Fr(unencryptedLogBuf.subarray(i * 32, i * 32 + 32)),
|
|
1022
|
-
}),
|
|
1023
|
-
{} as T,
|
|
1024
|
-
);
|
|
985
|
+
return eventMetadata.decode(unencryptedLog.log);
|
|
1025
986
|
})
|
|
1026
987
|
.filter(unencryptedLog => unencryptedLog !== undefined) as T[];
|
|
1027
988
|
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type PrivateKernelData, type PrivateKernelResetCircuitPrivateInputsVariants } from '@aztec/circuits.js';
|
|
2
|
-
import type { ExecutionResult } from '@aztec/simulator';
|
|
3
|
-
import { type ProvingDataOracle } from '../proving_data_oracle.js';
|
|
4
|
-
export declare function buildPrivateKernelResetInputs(executionStack: ExecutionResult[], previousKernelData: PrivateKernelData, noteHashLeafIndexMap: Map<bigint, bigint>, noteHashNullifierCounterMap: Map<number, number>, validationRequestsSplitCounter: number, shouldSilo: boolean, oracle: ProvingDataOracle): Promise<PrivateKernelResetCircuitPrivateInputsVariants>;
|
|
5
|
-
//# sourceMappingURL=build_private_kernel_reset_hints.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build_private_kernel_reset_hints.d.ts","sourceRoot":"","sources":["../../../src/kernel_prover/hints/build_private_kernel_reset_hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,iBAAiB,EAEtB,KAAK,8CAA8C,EAYpD,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAyDnE,wBAAsB,6BAA6B,CACjD,cAAc,EAAE,eAAe,EAAE,EACjC,kBAAkB,EAAE,iBAAiB,EACrC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,8BAA8B,EAAE,MAAM,EACtC,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,iBAAiB,2DA+H1B"}
|