@aztec/txe 0.0.1-commit.f295ac2 → 0.0.1-commit.f2ce05ee
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/interfaces.d.ts +3 -3
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +6 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts +2 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +33 -14
- package/dest/rpc_translator.d.ts +15 -9
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +63 -39
- package/dest/state_machine/archiver.d.ts +2 -2
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +7 -6
- 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 +7 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +30 -16
- package/dest/state_machine/mock_epoch_cache.d.ts +8 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +9 -6
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/txe_session.d.ts +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +14 -10
- package/dest/utils/block_creation.d.ts +5 -5
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +7 -5
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +2 -2
- package/src/oracle/txe_oracle_public_context.ts +8 -10
- package/src/oracle/txe_oracle_top_level_context.ts +63 -26
- package/src/rpc_translator.ts +65 -37
- package/src/state_machine/archiver.ts +6 -8
- package/src/state_machine/dummy_p2p_client.ts +7 -2
- package/src/state_machine/index.ts +48 -19
- package/src/state_machine/mock_epoch_cache.ts +10 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +22 -15
- package/src/utils/block_creation.ts +8 -6
package/dest/txe_session.d.ts
CHANGED
|
@@ -72,4 +72,4 @@ export declare class TXESession implements TXESessionStateHandler {
|
|
|
72
72
|
private utilityExecutorForContractSync;
|
|
73
73
|
}
|
|
74
74
|
export {};
|
|
75
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
75
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3Nlc3Npb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy90eGVfc2Vzc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUNsRSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFNUMsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNsRSxPQUFPLEVBQ0wsWUFBWSxFQUVaLFlBQVksRUFDWixjQUFjLEVBRWQsU0FBUyxFQUNULGlCQUFpQixFQUNqQixxQkFBcUIsRUFDckIsc0JBQXNCLEVBQ3RCLGtCQUFrQixFQUNuQixNQUFNLG1CQUFtQixDQUFDO0FBQzNCLE9BQU8sRUFJTCxLQUFLLHVCQUF1QixFQUM1QixLQUFLLHVCQU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tZQWlCWCxnQkFBZ0I7WUE2QmhCLGVBQWU7SUFTN0IsT0FBTyxDQUFDLGtCQUFrQjtJQU0xQixPQUFPLENBQUMsOEJBQThCO0NBMkN2QyJ9
|
|
@@ -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,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,YAAY,
|
|
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,uBAAuB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,YAAY,EAEZ,YAAY,EACZ,cAAc,EAEd,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAI7B,MAAM,sBAAsB,CAAC;AAW9B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAO5D,OAAO,KAAK,EAAE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B,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';
|
|
@@ -75,7 +76,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
75
76
|
const addressStore = new AddressStore(store);
|
|
76
77
|
const privateEventStore = new PrivateEventStore(store);
|
|
77
78
|
const contractStore = new TXEContractStore(store);
|
|
78
|
-
const noteStore =
|
|
79
|
+
const noteStore = new NoteStore(store);
|
|
79
80
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
80
81
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
81
82
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -88,14 +89,17 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
88
89
|
capsuleStore,
|
|
89
90
|
senderTaggingStore,
|
|
90
91
|
recipientTaggingStore,
|
|
91
|
-
privateEventStore
|
|
92
|
+
privateEventStore,
|
|
93
|
+
noteStore
|
|
92
94
|
]);
|
|
93
95
|
// Register protocol contracts.
|
|
94
96
|
for (const { contractClass, instance, artifact } of protocolContracts){
|
|
95
97
|
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
96
98
|
await contractStore.addContractInstance(instance);
|
|
97
99
|
}
|
|
98
|
-
const
|
|
100
|
+
const archiver = new TXEArchiver(store);
|
|
101
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
102
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
99
103
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
100
104
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
101
105
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
@@ -162,11 +166,11 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
162
166
|
}
|
|
163
167
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
164
168
|
this.exitTopLevelState();
|
|
165
|
-
await new NoteService(this.noteStore, this.stateMachine.node, this.stateMachine.anchorBlockStore).syncNoteNullifiers(contractAddress);
|
|
166
169
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
167
170
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
168
171
|
// a single transaction with the effects of what was done in the test.
|
|
169
172
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
173
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress);
|
|
170
174
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
171
175
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
172
176
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
@@ -179,7 +183,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
179
183
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
180
184
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
181
185
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
182
|
-
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);
|
|
183
187
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
184
188
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
185
189
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -213,14 +217,14 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
213
217
|
}
|
|
214
218
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
215
219
|
this.exitTopLevelState();
|
|
220
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
216
221
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
217
222
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
218
223
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
219
224
|
// be removed from the database.
|
|
220
225
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
221
|
-
await new NoteService(this.noteStore, this.stateMachine.node, this.
|
|
222
|
-
|
|
223
|
-
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);
|
|
224
228
|
this.state = {
|
|
225
229
|
name: 'UTILITY'
|
|
226
230
|
};
|
|
@@ -283,7 +287,7 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
283
287
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
284
288
|
}
|
|
285
289
|
try {
|
|
286
|
-
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);
|
|
287
291
|
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
288
292
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
289
293
|
throw new ExecutionError(err.message, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import {
|
|
3
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
4
4
|
import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
5
5
|
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
6
6
|
/**
|
|
@@ -12,7 +12,7 @@ export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): F
|
|
|
12
12
|
export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
|
|
13
13
|
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
|
|
14
14
|
/**
|
|
15
|
-
* Creates an
|
|
15
|
+
* Creates an L2Block with proper archive chaining.
|
|
16
16
|
* This function:
|
|
17
17
|
* 1. Gets the current archive state as lastArchive for the header
|
|
18
18
|
* 2. Creates the block header
|
|
@@ -22,7 +22,7 @@ export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations
|
|
|
22
22
|
* @param worldTrees - The world trees to read/write from
|
|
23
23
|
* @param globalVariables - Global variables for the block
|
|
24
24
|
* @param txEffects - Transaction effects to include in the block
|
|
25
|
-
* @returns The created
|
|
25
|
+
* @returns The created L2Block with proper archive chaining
|
|
26
26
|
*/
|
|
27
|
-
export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
27
|
+
export declare function makeTXEBlock(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables, txEffects: TxEffect[]): Promise<L2Block>;
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUEyQyxNQUFNLGlDQUFpQyxDQUFDO0FBRXZHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQVEsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEQsT0FBTyxFQUF3QyxLQUFLLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDM0csT0FBTyxFQUFFLFdBQVcsRUFBRSxlQUFlLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUU7Ozs7R0FJRztBQUNILHdCQUFnQiwyQkFBMkIsQ0FBQyxXQUFXLEVBQUUsV0FBVyxHQUFHLEVBQUUsQ0FFeEU7QUFFRCx3QkFBc0IsNEJBQTRCLENBQ2hELFFBQVEsRUFBRSxRQUFRLEVBQ2xCLFVBQVUsRUFBRSx5QkFBeUIsR0FDcEMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWtCZjtBQUVELHdCQUFzQixrQkFBa0IsQ0FDdEMsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxlQUFlLEVBQUUsZUFBZSxHQUMvQixPQUFPLENBQUMsV0FBVyxDQUFDLENBWXRCO0FBRUQ7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLFlBQVksQ0FDaEMsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxlQUFlLEVBQUUsZUFBZSxFQUNoQyxTQUFTLEVBQUUsUUFBUSxFQUFFLEdBQ3BCLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FpQmxCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAA2C,MAAM,iCAAiC,CAAC;AAEvG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAQ,
|
|
1
|
+
{"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAA2C,MAAM,iCAAiC,CAAC;AAEvG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAQ,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,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"}
|
|
@@ -2,7 +2,7 @@ import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT
|
|
|
2
2
|
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
-
import { Body,
|
|
5
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
6
6
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
7
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
8
|
/**
|
|
@@ -31,7 +31,7 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Creates an
|
|
34
|
+
* Creates an L2Block with proper archive chaining.
|
|
35
35
|
* This function:
|
|
36
36
|
* 1. Gets the current archive state as lastArchive for the header
|
|
37
37
|
* 2. Creates the block header
|
|
@@ -41,7 +41,7 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
|
41
41
|
* @param worldTrees - The world trees to read/write from
|
|
42
42
|
* @param globalVariables - Global variables for the block
|
|
43
43
|
* @param txEffects - Transaction effects to include in the block
|
|
44
|
-
* @returns The created
|
|
44
|
+
* @returns The created L2Block with proper archive chaining
|
|
45
45
|
*/ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
|
|
46
46
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
47
47
|
// Update the archive tree with this block's header hash
|
|
@@ -49,8 +49,10 @@ 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
|
-
//
|
|
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
|
-
return new
|
|
57
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
56
58
|
}
|
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.f2ce05ee",
|
|
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.f2ce05ee",
|
|
65
|
+
"@aztec/archiver": "0.0.1-commit.f2ce05ee",
|
|
66
|
+
"@aztec/aztec-node": "0.0.1-commit.f2ce05ee",
|
|
67
|
+
"@aztec/aztec.js": "0.0.1-commit.f2ce05ee",
|
|
68
|
+
"@aztec/bb-prover": "0.0.1-commit.f2ce05ee",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.f2ce05ee",
|
|
70
|
+
"@aztec/foundation": "0.0.1-commit.f2ce05ee",
|
|
71
|
+
"@aztec/key-store": "0.0.1-commit.f2ce05ee",
|
|
72
|
+
"@aztec/kv-store": "0.0.1-commit.f2ce05ee",
|
|
73
|
+
"@aztec/protocol-contracts": "0.0.1-commit.f2ce05ee",
|
|
74
|
+
"@aztec/pxe": "0.0.1-commit.f2ce05ee",
|
|
75
|
+
"@aztec/simulator": "0.0.1-commit.f2ce05ee",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.f2ce05ee",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.f2ce05ee",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/oracle/interfaces.ts
CHANGED
|
@@ -33,9 +33,9 @@ export interface IAvmExecutionOracle {
|
|
|
33
33
|
avmOpcodeVersion(): Promise<Fr>;
|
|
34
34
|
avmOpcodeEmitNullifier(nullifier: Fr): Promise<void>;
|
|
35
35
|
avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
|
|
36
|
-
avmOpcodeNullifierExists(
|
|
36
|
+
avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean>;
|
|
37
37
|
avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
38
|
-
avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
|
|
38
|
+
avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type {
|
|
6
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
8
8
|
import {
|
|
9
9
|
MerkleTreeId,
|
|
@@ -78,13 +78,11 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
78
78
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
async avmOpcodeNullifierExists(
|
|
82
|
-
const nullifier = await siloNullifier(targetAddress, innerNullifier!);
|
|
83
|
-
|
|
81
|
+
async avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
84
82
|
const treeIndex = (
|
|
85
|
-
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
83
|
+
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
86
84
|
)[0];
|
|
87
|
-
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(
|
|
85
|
+
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
|
|
88
86
|
|
|
89
87
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
90
88
|
}
|
|
@@ -101,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
101
99
|
]);
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
|
|
105
|
-
const leafSlot = await computePublicDataTreeLeafSlot(
|
|
102
|
+
async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
103
|
+
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
106
104
|
|
|
107
105
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
108
106
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
@@ -119,12 +117,12 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
119
117
|
)) as PublicDataTreeLeafPreimage
|
|
120
118
|
).leaf.value;
|
|
121
119
|
|
|
122
|
-
this.logger.debug('AVM storage read', { slot, value });
|
|
120
|
+
this.logger.debug('AVM storage read', { slot, contractAddress, value });
|
|
123
121
|
|
|
124
122
|
return value;
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
async close(): Promise<
|
|
125
|
+
async close(): Promise<L2Block> {
|
|
128
126
|
this.logger.debug('Exiting Public Context, building block with collected side effects', {
|
|
129
127
|
blockNumber: this.globalVariables.blockNumber,
|
|
130
128
|
});
|
|
@@ -131,13 +131,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
utilityDebugLog(level: number, message: string, fields: Fr[]): void {
|
|
134
|
+
utilityDebugLog(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
135
|
if (!LogLevels[level]) {
|
|
136
136
|
throw new Error(`Invalid debug log level: ${level}`);
|
|
137
137
|
}
|
|
138
138
|
const levelName = LogLevels[level];
|
|
139
139
|
|
|
140
140
|
this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
|
|
141
|
+
return Promise.resolve();
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
txeGetDefaultAddress(): AztecAddress {
|
|
@@ -296,12 +297,24 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
296
297
|
throw new Error(message);
|
|
297
298
|
}
|
|
298
299
|
|
|
300
|
+
// When `from` is the zero address (used when creating a new contract account for example),
|
|
301
|
+
// we disable scope filtering by setting effectiveScopes to undefined. This allows these operations
|
|
302
|
+
// to proceed without requiring keys registered for the zero address.
|
|
303
|
+
const effectiveScopes = from.isZero() ? undefined : [from];
|
|
304
|
+
|
|
299
305
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
300
306
|
const utilityExecutor = async (call: FunctionCall) => {
|
|
301
|
-
await this.executeUtilityCall(call);
|
|
307
|
+
await this.executeUtilityCall(call, effectiveScopes);
|
|
302
308
|
};
|
|
303
309
|
|
|
304
|
-
await this.
|
|
310
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
311
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
312
|
+
targetContractAddress,
|
|
313
|
+
functionSelector,
|
|
314
|
+
utilityExecutor,
|
|
315
|
+
blockHeader,
|
|
316
|
+
this.jobId,
|
|
317
|
+
);
|
|
305
318
|
|
|
306
319
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
307
320
|
|
|
@@ -313,8 +326,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
313
326
|
|
|
314
327
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
315
328
|
|
|
316
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
317
|
-
|
|
318
329
|
const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
|
|
319
330
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
320
331
|
// In production, the account contract sets the min revertible counter before calling the app function.
|
|
@@ -345,17 +356,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
345
356
|
this.keyStore,
|
|
346
357
|
this.addressStore,
|
|
347
358
|
this.stateMachine.node,
|
|
348
|
-
this.stateMachine.anchorBlockStore,
|
|
349
359
|
this.senderTaggingStore,
|
|
350
360
|
this.recipientTaggingStore,
|
|
351
361
|
this.senderAddressBookStore,
|
|
352
362
|
this.capsuleStore,
|
|
353
363
|
this.privateEventStore,
|
|
364
|
+
this.stateMachine.contractSyncService,
|
|
354
365
|
this.jobId,
|
|
355
366
|
0, // totalPublicArgsCount
|
|
356
367
|
minRevertibleSideEffectCounter, // (start) sideEffectCounter
|
|
357
368
|
undefined, // log
|
|
358
|
-
|
|
369
|
+
effectiveScopes, // scopes
|
|
359
370
|
/**
|
|
360
371
|
* In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
|
|
361
372
|
* contract would perform, including setting senderForTags.
|
|
@@ -401,7 +412,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
401
412
|
// We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
|
|
402
413
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
403
414
|
result,
|
|
404
|
-
this.contractStore,
|
|
415
|
+
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
405
416
|
minRevertibleSideEffectCounter,
|
|
406
417
|
);
|
|
407
418
|
|
|
@@ -414,7 +425,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
414
425
|
|
|
415
426
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
416
427
|
|
|
417
|
-
const
|
|
428
|
+
const bindings = this.logger.getBindings();
|
|
429
|
+
const contractsDB = new PublicContractsDB(
|
|
430
|
+
new TXEPublicContractDataSource(blockNumber, this.contractStore),
|
|
431
|
+
bindings,
|
|
432
|
+
);
|
|
418
433
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
419
434
|
const config = PublicSimulatorConfig.from({
|
|
420
435
|
skipFeeEnforcement: true,
|
|
@@ -427,8 +442,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
427
442
|
globals,
|
|
428
443
|
guardedMerkleTrees,
|
|
429
444
|
contractsDB,
|
|
430
|
-
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config),
|
|
445
|
+
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
|
|
431
446
|
new TestDateProvider(),
|
|
447
|
+
undefined,
|
|
448
|
+
createLogger('simulator:public-processor', bindings),
|
|
432
449
|
);
|
|
433
450
|
|
|
434
451
|
const tx = await Tx.create({
|
|
@@ -525,7 +542,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
525
542
|
|
|
526
543
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
527
544
|
|
|
528
|
-
const
|
|
545
|
+
const bindings2 = this.logger.getBindings();
|
|
546
|
+
const contractsDB = new PublicContractsDB(
|
|
547
|
+
new TXEPublicContractDataSource(blockNumber, this.contractStore),
|
|
548
|
+
bindings2,
|
|
549
|
+
);
|
|
529
550
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
530
551
|
const config = PublicSimulatorConfig.from({
|
|
531
552
|
skipFeeEnforcement: true,
|
|
@@ -534,8 +555,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
534
555
|
collectStatistics: false,
|
|
535
556
|
collectCallMetadata: true,
|
|
536
557
|
});
|
|
537
|
-
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
|
|
538
|
-
const processor = new PublicProcessor(
|
|
558
|
+
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
|
|
559
|
+
const processor = new PublicProcessor(
|
|
560
|
+
globals,
|
|
561
|
+
guardedMerkleTrees,
|
|
562
|
+
contractsDB,
|
|
563
|
+
simulator,
|
|
564
|
+
new TestDateProvider(),
|
|
565
|
+
undefined,
|
|
566
|
+
createLogger('simulator:public-processor', bindings2),
|
|
567
|
+
);
|
|
539
568
|
|
|
540
569
|
// We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
|
|
541
570
|
// kernel init would in this case inject a nullifier with the transaction request hash as a non-revertible
|
|
@@ -645,25 +674,32 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
645
674
|
}
|
|
646
675
|
|
|
647
676
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
648
|
-
await this.
|
|
649
|
-
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
const call = new FunctionCall(
|
|
653
|
-
artifact.name,
|
|
677
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
678
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
654
679
|
targetContractAddress,
|
|
655
680
|
functionSelector,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
681
|
+
async call => {
|
|
682
|
+
await this.executeUtilityCall(call);
|
|
683
|
+
},
|
|
684
|
+
blockHeader,
|
|
685
|
+
this.jobId,
|
|
661
686
|
);
|
|
662
687
|
|
|
688
|
+
const call = FunctionCall.from({
|
|
689
|
+
name: artifact.name,
|
|
690
|
+
to: targetContractAddress,
|
|
691
|
+
selector: functionSelector,
|
|
692
|
+
type: FunctionType.UTILITY,
|
|
693
|
+
hideMsgSender: false,
|
|
694
|
+
isStatic: false,
|
|
695
|
+
args,
|
|
696
|
+
returnTypes: [],
|
|
697
|
+
});
|
|
698
|
+
|
|
663
699
|
return this.executeUtilityCall(call);
|
|
664
700
|
}
|
|
665
701
|
|
|
666
|
-
private async executeUtilityCall(call: FunctionCall): Promise<Fr[]> {
|
|
702
|
+
private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
|
|
667
703
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
668
704
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
669
705
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -686,12 +722,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
686
722
|
this.keyStore,
|
|
687
723
|
this.addressStore,
|
|
688
724
|
this.stateMachine.node,
|
|
689
|
-
this.stateMachine.anchorBlockStore,
|
|
690
725
|
this.recipientTaggingStore,
|
|
691
726
|
this.senderAddressBookStore,
|
|
692
727
|
this.capsuleStore,
|
|
693
728
|
this.privateEventStore,
|
|
694
729
|
this.jobId,
|
|
730
|
+
undefined, // log
|
|
731
|
+
scopes, // scopes - used to filter notes by account
|
|
695
732
|
);
|
|
696
733
|
const acirExecutionResult = await new WASMSimulator()
|
|
697
734
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|