@aztec/txe 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a
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/oracle/txe_oracle_top_level_context.d.ts +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +23 -14
- package/dest/rpc_translator.d.ts +4 -4
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +34 -22
- package/dest/state_machine/archiver.d.ts +1 -1
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +2 -0
- package/dest/state_machine/dummy_p2p_client.d.ts +4 -3
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +5 -2
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +14 -9
- package/dest/txe_session.d.ts +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +11 -8
- package/dest/utils/block_creation.d.ts +1 -1
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +3 -1
- package/package.json +15 -15
- package/src/oracle/txe_oracle_top_level_context.ts +52 -17
- package/src/rpc_translator.ts +36 -17
- package/src/state_machine/archiver.ts +2 -0
- package/src/state_machine/dummy_p2p_client.ts +7 -2
- package/src/state_machine/index.ts +24 -9
- package/src/txe_session.ts +13 -14
- package/src/utils/block_creation.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAu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AAO,CAAC,QAAQ,CAAuC;IAEvD,YACU,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,eAAe,EAC7B,aAAa,EACjB,uBAAuB,GACvB,uBAAuB,GACvB,mBAAmB,GACnB,mBAAmB,EACf,aAAa,EAAE,gBAAgB,EAC/B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,EAC7B,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,kBAAkB,EAAE,MAAM,EAChC;IAEJ,OAAa,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,uBAgFtD;IAED;;;;;OAKG;IACH,eAAe,CAAC,YAAY,EAAE,qBAAqB,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuBxG;IAEK,kBAAkB,kBA+CvB;IAEK,iBAAiB,CACrB,eAAe,GAAE,YAA8B,EAC/C,iBAAiB,CAAC,EAAE,WAAW,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CA4D/B;IAEK,gBAAgB,CAAC,eAAe,CAAC,EAAE,YAAY,iBAsBpD;IAEK,iBAAiB,CAAC,eAAe,GAAE,YAA8B,iBAoCtE;IAED,OAAO,CAAC,iBAAiB;YAiBX,gBAAgB;YA6BhB,eAAe;IAS7B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,8BAA8B;CA2CvC"}
|
package/dest/txe_session.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
5
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
-
import { AddressStore, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
7
|
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
8
|
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
9
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
@@ -17,6 +17,7 @@ import { DEFAULT_ADDRESS } from './constants.js';
|
|
|
17
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
18
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
19
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
20
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
20
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
21
22
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
22
23
|
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
@@ -96,7 +97,9 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
96
97
|
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
97
98
|
await contractStore.addContractInstance(instance);
|
|
98
99
|
}
|
|
99
|
-
const
|
|
100
|
+
const archiver = new TXEArchiver(store);
|
|
101
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
102
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
100
103
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
101
104
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
102
105
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
@@ -163,11 +166,11 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
163
166
|
}
|
|
164
167
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
165
168
|
this.exitTopLevelState();
|
|
166
|
-
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
167
169
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
168
170
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
169
171
|
// a single transaction with the effects of what was done in the test.
|
|
170
172
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
173
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
171
174
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
172
175
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
173
176
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
@@ -180,7 +183,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
180
183
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
181
184
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
182
185
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
183
|
-
this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, utilityExecutor, [], [], new HashedValuesCache(), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.
|
|
186
|
+
this.oracleHandler = new PrivateExecutionOracle(Fr.ZERO, new TxContext(this.chainId, this.version, GasSettings.empty()), new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false), anchorBlock, utilityExecutor, [], [], new HashedValuesCache(), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.stateMachine.contractSyncService, this.currentJobId);
|
|
184
187
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
185
188
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
186
189
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -214,14 +217,14 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
214
217
|
}
|
|
215
218
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
216
219
|
this.exitTopLevelState();
|
|
220
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
217
221
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
218
222
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
219
223
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
220
224
|
// be removed from the database.
|
|
221
225
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
222
|
-
await new NoteService(this.noteStore, this.stateMachine.node,
|
|
223
|
-
|
|
224
|
-
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId);
|
|
226
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
227
|
+
this.oracleHandler = new UtilityExecutionOracle(contractAddress, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId);
|
|
225
228
|
this.state = {
|
|
226
229
|
name: 'UTILITY'
|
|
227
230
|
};
|
|
@@ -284,7 +287,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
284
287
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
285
288
|
}
|
|
286
289
|
try {
|
|
287
|
-
const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlock, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.
|
|
290
|
+
const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlock, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.currentJobId);
|
|
288
291
|
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
289
292
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
290
293
|
throw new ExecutionError(err.message, {
|
|
@@ -25,4 +25,4 @@ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations
|
|
|
25
25
|
* @returns The created L2Block with proper archive chaining
|
|
26
26
|
*/
|
|
27
27
|
export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3Vy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B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAiBlB"}
|
|
@@ -49,7 +49,9 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
|
49
49
|
// Get the new archive state after updating
|
|
50
50
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
51
51
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
52
|
-
// L2Block requires checkpointNumber and indexWithinCheckpoint
|
|
52
|
+
// L2Block requires checkpointNumber and indexWithinCheckpoint.
|
|
53
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
54
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
53
55
|
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
54
56
|
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
55
57
|
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.2eb6648a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -61,20 +61,20 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
65
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
66
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
67
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
68
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
69
|
-
"@aztec/constants": "0.0.1-commit.
|
|
70
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
71
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
72
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
73
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
74
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
75
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
76
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
64
|
+
"@aztec/accounts": "0.0.1-commit.2eb6648a",
|
|
65
|
+
"@aztec/archiver": "0.0.1-commit.2eb6648a",
|
|
66
|
+
"@aztec/aztec-node": "0.0.1-commit.2eb6648a",
|
|
67
|
+
"@aztec/aztec.js": "0.0.1-commit.2eb6648a",
|
|
68
|
+
"@aztec/bb-prover": "0.0.1-commit.2eb6648a",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.2eb6648a",
|
|
70
|
+
"@aztec/foundation": "0.0.1-commit.2eb6648a",
|
|
71
|
+
"@aztec/key-store": "0.0.1-commit.2eb6648a",
|
|
72
|
+
"@aztec/kv-store": "0.0.1-commit.2eb6648a",
|
|
73
|
+
"@aztec/protocol-contracts": "0.0.1-commit.2eb6648a",
|
|
74
|
+
"@aztec/pxe": "0.0.1-commit.2eb6648a",
|
|
75
|
+
"@aztec/simulator": "0.0.1-commit.2eb6648a",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.2eb6648a",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.2eb6648a",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
SenderAddressBookStore,
|
|
23
23
|
SenderTaggingStore,
|
|
24
24
|
enrichPublicSimulationError,
|
|
25
|
-
syncState,
|
|
26
25
|
} from '@aztec/pxe/server';
|
|
27
26
|
import {
|
|
28
27
|
ExecutionNoteCache,
|
|
@@ -297,12 +296,24 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
297
296
|
throw new Error(message);
|
|
298
297
|
}
|
|
299
298
|
|
|
299
|
+
// When `from` is the zero address (used when creating a new contract account for example),
|
|
300
|
+
// we disable scope filtering by setting effectiveScopes to undefined. This allows these operations
|
|
301
|
+
// to proceed without requiring keys registered for the zero address.
|
|
302
|
+
const effectiveScopes = from.isZero() ? undefined : [from];
|
|
303
|
+
|
|
300
304
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
301
305
|
const utilityExecutor = async (call: FunctionCall) => {
|
|
302
|
-
await this.executeUtilityCall(call);
|
|
306
|
+
await this.executeUtilityCall(call, effectiveScopes);
|
|
303
307
|
};
|
|
304
308
|
|
|
305
|
-
await
|
|
309
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
310
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
311
|
+
targetContractAddress,
|
|
312
|
+
functionSelector,
|
|
313
|
+
utilityExecutor,
|
|
314
|
+
blockHeader,
|
|
315
|
+
this.jobId,
|
|
316
|
+
);
|
|
306
317
|
|
|
307
318
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
308
319
|
|
|
@@ -314,8 +325,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
314
325
|
|
|
315
326
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
316
327
|
|
|
317
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
318
|
-
|
|
319
328
|
const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
|
|
320
329
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
321
330
|
// In production, the account contract sets the min revertible counter before calling the app function.
|
|
@@ -346,17 +355,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
346
355
|
this.keyStore,
|
|
347
356
|
this.addressStore,
|
|
348
357
|
this.stateMachine.node,
|
|
349
|
-
this.stateMachine.anchorBlockStore,
|
|
350
358
|
this.senderTaggingStore,
|
|
351
359
|
this.recipientTaggingStore,
|
|
352
360
|
this.senderAddressBookStore,
|
|
353
361
|
this.capsuleStore,
|
|
354
362
|
this.privateEventStore,
|
|
363
|
+
this.stateMachine.contractSyncService,
|
|
355
364
|
this.jobId,
|
|
356
365
|
0, // totalPublicArgsCount
|
|
357
366
|
minRevertibleSideEffectCounter, // (start) sideEffectCounter
|
|
358
367
|
undefined, // log
|
|
359
|
-
|
|
368
|
+
effectiveScopes, // scopes
|
|
360
369
|
/**
|
|
361
370
|
* In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
|
|
362
371
|
* contract would perform, including setting senderForTags.
|
|
@@ -415,7 +424,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
415
424
|
|
|
416
425
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
417
426
|
|
|
418
|
-
const
|
|
427
|
+
const bindings = this.logger.getBindings();
|
|
428
|
+
const contractsDB = new PublicContractsDB(
|
|
429
|
+
new TXEPublicContractDataSource(blockNumber, this.contractStore),
|
|
430
|
+
bindings,
|
|
431
|
+
);
|
|
419
432
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
420
433
|
const config = PublicSimulatorConfig.from({
|
|
421
434
|
skipFeeEnforcement: true,
|
|
@@ -428,8 +441,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
428
441
|
globals,
|
|
429
442
|
guardedMerkleTrees,
|
|
430
443
|
contractsDB,
|
|
431
|
-
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config),
|
|
444
|
+
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
|
|
432
445
|
new TestDateProvider(),
|
|
446
|
+
undefined,
|
|
447
|
+
createLogger('simulator:public-processor', bindings),
|
|
433
448
|
);
|
|
434
449
|
|
|
435
450
|
const tx = await Tx.create({
|
|
@@ -526,7 +541,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
526
541
|
|
|
527
542
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
528
543
|
|
|
529
|
-
const
|
|
544
|
+
const bindings2 = this.logger.getBindings();
|
|
545
|
+
const contractsDB = new PublicContractsDB(
|
|
546
|
+
new TXEPublicContractDataSource(blockNumber, this.contractStore),
|
|
547
|
+
bindings2,
|
|
548
|
+
);
|
|
530
549
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
531
550
|
const config = PublicSimulatorConfig.from({
|
|
532
551
|
skipFeeEnforcement: true,
|
|
@@ -535,8 +554,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
535
554
|
collectStatistics: false,
|
|
536
555
|
collectCallMetadata: true,
|
|
537
556
|
});
|
|
538
|
-
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
|
|
539
|
-
const processor = new PublicProcessor(
|
|
557
|
+
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
|
|
558
|
+
const processor = new PublicProcessor(
|
|
559
|
+
globals,
|
|
560
|
+
guardedMerkleTrees,
|
|
561
|
+
contractsDB,
|
|
562
|
+
simulator,
|
|
563
|
+
new TestDateProvider(),
|
|
564
|
+
undefined,
|
|
565
|
+
createLogger('simulator:public-processor', bindings2),
|
|
566
|
+
);
|
|
540
567
|
|
|
541
568
|
// We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
|
|
542
569
|
// kernel init would in this case inject a nullifier with the transaction request hash as a non-revertible
|
|
@@ -646,9 +673,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
646
673
|
}
|
|
647
674
|
|
|
648
675
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
649
|
-
await
|
|
650
|
-
|
|
651
|
-
|
|
676
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
677
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
678
|
+
targetContractAddress,
|
|
679
|
+
functionSelector,
|
|
680
|
+
async call => {
|
|
681
|
+
await this.executeUtilityCall(call);
|
|
682
|
+
},
|
|
683
|
+
blockHeader,
|
|
684
|
+
this.jobId,
|
|
685
|
+
);
|
|
652
686
|
|
|
653
687
|
const call = new FunctionCall(
|
|
654
688
|
artifact.name,
|
|
@@ -664,7 +698,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
664
698
|
return this.executeUtilityCall(call);
|
|
665
699
|
}
|
|
666
700
|
|
|
667
|
-
private async executeUtilityCall(call: FunctionCall): Promise<Fr[]> {
|
|
701
|
+
private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
|
|
668
702
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
669
703
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
670
704
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -687,12 +721,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
687
721
|
this.keyStore,
|
|
688
722
|
this.addressStore,
|
|
689
723
|
this.stateMachine.node,
|
|
690
|
-
this.stateMachine.anchorBlockStore,
|
|
691
724
|
this.recipientTaggingStore,
|
|
692
725
|
this.senderAddressBookStore,
|
|
693
726
|
this.capsuleStore,
|
|
694
727
|
this.privateEventStore,
|
|
695
728
|
this.jobId,
|
|
729
|
+
undefined, // log
|
|
730
|
+
scopes, // scopes - used to filter notes by account
|
|
696
731
|
);
|
|
697
732
|
const acirExecutionResult = await new WASMSimulator()
|
|
698
733
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
package/src/rpc_translator.ts
CHANGED
|
@@ -351,7 +351,7 @@ export class RPCTranslator {
|
|
|
351
351
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
352
352
|
foreignNumberOfElements: ForeignCallSingle,
|
|
353
353
|
) {
|
|
354
|
-
const blockHash = BlockHash
|
|
354
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
355
355
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
356
356
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
357
357
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
@@ -367,7 +367,7 @@ export class RPCTranslator {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
370
|
-
const blockHash = BlockHash
|
|
370
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
371
371
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
372
372
|
|
|
373
373
|
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
|
|
@@ -545,12 +545,23 @@ export class RPCTranslator {
|
|
|
545
545
|
);
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
-
async
|
|
548
|
+
async utilityTryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
549
549
|
const address = addressFromSingle(foreignAddress);
|
|
550
550
|
|
|
551
|
-
const
|
|
551
|
+
const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(address);
|
|
552
552
|
|
|
553
|
-
return
|
|
553
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
554
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
555
|
+
if (result === undefined) {
|
|
556
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
557
|
+
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
|
|
558
|
+
} else {
|
|
559
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
560
|
+
return toForeignCallResult([
|
|
561
|
+
toSingle(new Fr(1)),
|
|
562
|
+
toArray([...result.publicKeys.toFields(), result.partialAddress]),
|
|
563
|
+
]);
|
|
564
|
+
}
|
|
554
565
|
}
|
|
555
566
|
|
|
556
567
|
async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
|
|
@@ -574,7 +585,7 @@ export class RPCTranslator {
|
|
|
574
585
|
}
|
|
575
586
|
|
|
576
587
|
async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
|
|
577
|
-
const blockHash = BlockHash
|
|
588
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
578
589
|
const nullifier = fromSingle(foreignNullifier);
|
|
579
590
|
|
|
580
591
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -641,26 +652,34 @@ export class RPCTranslator {
|
|
|
641
652
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
642
653
|
}
|
|
643
654
|
|
|
644
|
-
async utilityGetNoteHashMembershipWitness(
|
|
645
|
-
|
|
646
|
-
|
|
655
|
+
async utilityGetNoteHashMembershipWitness(
|
|
656
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
657
|
+
foreignNoteHash: ForeignCallSingle,
|
|
658
|
+
) {
|
|
659
|
+
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
660
|
+
const noteHash = fromSingle(foreignNoteHash);
|
|
647
661
|
|
|
648
|
-
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash,
|
|
662
|
+
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
|
|
649
663
|
|
|
650
664
|
if (!witness) {
|
|
651
|
-
throw new Error(`Note hash ${
|
|
665
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
652
666
|
}
|
|
653
667
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
654
668
|
}
|
|
655
669
|
|
|
656
|
-
async
|
|
657
|
-
|
|
658
|
-
|
|
670
|
+
async utilityGetBlockHashMembershipWitness(
|
|
671
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
672
|
+
foreignBlockHash: ForeignCallSingle,
|
|
673
|
+
) {
|
|
674
|
+
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
675
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
659
676
|
|
|
660
|
-
const witness = await this.handlerAsUtility().
|
|
677
|
+
const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
661
678
|
|
|
662
679
|
if (!witness) {
|
|
663
|
-
throw new Error(
|
|
680
|
+
throw new Error(
|
|
681
|
+
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
682
|
+
);
|
|
664
683
|
}
|
|
665
684
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
666
685
|
}
|
|
@@ -669,7 +688,7 @@ export class RPCTranslator {
|
|
|
669
688
|
foreignBlockHash: ForeignCallSingle,
|
|
670
689
|
foreignNullifier: ForeignCallSingle,
|
|
671
690
|
) {
|
|
672
|
-
const blockHash = BlockHash
|
|
691
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
673
692
|
const nullifier = fromSingle(foreignNullifier);
|
|
674
693
|
|
|
675
694
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -59,6 +59,8 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
59
59
|
if (!checkpointedBlock) {
|
|
60
60
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
61
61
|
}
|
|
62
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
63
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
62
64
|
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
63
65
|
if (checkpoint.length === 0) {
|
|
64
66
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
P2PBlockReceivedCallback,
|
|
7
7
|
P2PCheckpointReceivedCallback,
|
|
8
8
|
P2PConfig,
|
|
9
|
+
P2PDuplicateProposalCallback,
|
|
9
10
|
P2PSyncState,
|
|
10
11
|
PeerId,
|
|
11
12
|
ReqRespSubProtocol,
|
|
@@ -133,8 +134,8 @@ export class DummyP2P implements P2P {
|
|
|
133
134
|
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
public
|
|
137
|
-
throw new Error('DummyP2P does not implement "
|
|
137
|
+
public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
138
|
+
throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -206,4 +207,8 @@ export class DummyP2P implements P2P {
|
|
|
206
207
|
|
|
207
208
|
//This is no-op
|
|
208
209
|
public registerThisValidatorAddresses(_address: EthAddress[]): void {}
|
|
210
|
+
|
|
211
|
+
public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
|
|
212
|
+
throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
|
|
213
|
+
}
|
|
209
214
|
}
|
|
@@ -3,8 +3,7 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
|
3
3
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import type
|
|
7
|
-
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
+
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
8
7
|
import { L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
9
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,13 +25,16 @@ export class TXEStateMachine {
|
|
|
26
25
|
public synchronizer: TXESynchronizer,
|
|
27
26
|
public archiver: TXEArchiver,
|
|
28
27
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
|
+
public contractSyncService: ContractSyncService,
|
|
29
29
|
) {}
|
|
30
30
|
|
|
31
|
-
public static async create(
|
|
32
|
-
|
|
31
|
+
public static async create(
|
|
32
|
+
archiver: TXEArchiver,
|
|
33
|
+
anchorBlockStore: AnchorBlockStore,
|
|
34
|
+
contractStore: ContractStore,
|
|
35
|
+
noteStore: NoteStore,
|
|
36
|
+
) {
|
|
33
37
|
const synchronizer = await TXESynchronizer.create();
|
|
34
|
-
const anchorBlockStore = new AnchorBlockStore(db);
|
|
35
|
-
|
|
36
38
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
37
39
|
|
|
38
40
|
const log = createLogger('txe_node');
|
|
@@ -58,11 +60,21 @@ export class TXEStateMachine {
|
|
|
58
60
|
log,
|
|
59
61
|
);
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
const contractSyncService = new ContractSyncService(
|
|
64
|
+
node,
|
|
65
|
+
contractStore,
|
|
66
|
+
noteStore,
|
|
67
|
+
createLogger('txe:contract_sync'),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
public async handleL2Block(block: L2Block) {
|
|
65
|
-
// Create a checkpoint from the block manually
|
|
74
|
+
// Create a checkpoint from the block manually.
|
|
75
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
76
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
77
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
|
|
66
78
|
const checkpoint = new Checkpoint(
|
|
67
79
|
block.archive,
|
|
68
80
|
CheckpointHeader.from({
|
|
@@ -79,7 +91,7 @@ export class TXEStateMachine {
|
|
|
79
91
|
totalManaUsed: block.header.totalManaUsed,
|
|
80
92
|
}),
|
|
81
93
|
[block],
|
|
82
|
-
|
|
94
|
+
checkpointNumber,
|
|
83
95
|
);
|
|
84
96
|
|
|
85
97
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
@@ -91,6 +103,9 @@ export class TXEStateMachine {
|
|
|
91
103
|
),
|
|
92
104
|
[],
|
|
93
105
|
);
|
|
106
|
+
// Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
|
|
107
|
+
this.contractSyncService.wipe();
|
|
108
|
+
|
|
94
109
|
await Promise.all([
|
|
95
110
|
this.synchronizer.handleL2Block(block),
|
|
96
111
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|