@aztec/txe 5.0.0-private.20260319 → 5.0.0-rc.2
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/AuthRegistry-URXCCPYF.js +3 -0
- package/dest/AuthRegistry-URXCCPYF.js.map +7 -0
- package/dest/ContractClassRegistry-5RDBM6TC.js +3 -0
- package/dest/ContractClassRegistry-5RDBM6TC.js.map +7 -0
- package/dest/ContractInstanceRegistry-GCR4G4D7.js +3 -0
- package/dest/ContractInstanceRegistry-GCR4G4D7.js.map +7 -0
- package/dest/FeeJuice-O3KOSZO5.js +3 -0
- package/dest/FeeJuice-O3KOSZO5.js.map +7 -0
- package/dest/HandshakeRegistry-TXSMHMNY.js +3 -0
- package/dest/HandshakeRegistry-TXSMHMNY.js.map +7 -0
- package/dest/MultiCallEntrypoint-P4FSRXAD.js +3 -0
- package/dest/MultiCallEntrypoint-P4FSRXAD.js.map +7 -0
- package/dest/SchnorrAccount-AQZX7ROU.js +3 -0
- package/dest/SchnorrAccount-AQZX7ROU.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-KMX2H3J6.js +3 -0
- package/dest/SchnorrInitializerlessAccount-KMX2H3J6.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +61 -0
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/bin/oracle_test_server.d.ts +3 -0
- package/dest/bin/oracle_test_server.d.ts.map +1 -0
- package/dest/bin/oracle_test_server.js +41 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-I6DL4FT2.js +304 -0
- package/dest/chunk-I6DL4FT2.js.map +7 -0
- package/dest/chunk-IAO54JS2.js +266 -0
- package/dest/chunk-IAO54JS2.js.map +7 -0
- package/dest/constants.d.ts +5 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +9 -1
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +286 -0
- package/dest/index.d.ts +51 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +70 -190
- package/dest/metafile.json +39364 -0
- package/dest/msgpackr_fr_extension.d.ts +2 -0
- package/dest/msgpackr_fr_extension.d.ts.map +1 -0
- package/dest/msgpackr_fr_extension.js +21 -0
- package/dest/oracle/interfaces.d.ts +38 -8
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/default_fixtures.d.ts +9 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/default_fixtures.js +164 -0
- package/dest/oracle/test-resolver/index.d.ts +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +32 -0
- package/dest/oracle/test-resolver/resolver.d.ts +48 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +144 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +26 -2
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +43 -1
- package/dest/oracle/txe_oracle_registry.d.ts +167 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +715 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +42 -17
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +205 -70
- package/dest/oracle/txe_oracle_version.d.ts +17 -0
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_version.js +14 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
- package/dest/oracle/txe_private_execution_oracle.js +15 -0
- package/dest/rpc_server.d.ts +14 -0
- package/dest/rpc_server.d.ts.map +1 -0
- package/dest/rpc_server.js +78 -0
- package/dest/rpc_translator.d.ts +111 -233
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +759 -636
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +4 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +24 -14
- package/dest/state_machine/dummy_p2p_client.d.ts +15 -7
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +22 -4
- package/dest/state_machine/global_variable_builder.d.ts +10 -6
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +8 -5
- package/dest/state_machine/index.d.ts +9 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +45 -12
- package/dest/state_machine/mock_epoch_cache.d.ts +1 -2
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +0 -3
- package/dest/state_machine/synchronizer.d.ts +3 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +4 -3
- package/dest/txe_session.d.ts +89 -20
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +289 -64
- package/dest/utils/block_creation.d.ts +2 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +2 -2
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +7 -2
- package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/{util → utils}/txe_account_store.d.ts +1 -1
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.d.ts +37 -0
- package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.js +161 -0
- package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
- package/dest/{util → utils}/txe_public_contract_data_source.js +1 -3
- package/dest/worker.bundle.js +3 -0
- package/dest/worker.bundle.js.map +7 -0
- package/dest/worker.d.ts +2 -0
- package/dest/worker.d.ts.map +1 -0
- package/dest/worker.js +92 -0
- package/package.json +38 -21
- package/src/bin/check_txe_oracle_version.ts +70 -0
- package/src/bin/index.ts +11 -2
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +11 -1
- package/src/dispatcher_pool.ts +317 -0
- package/src/index.ts +97 -227
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +35 -7
- package/src/oracle/test-resolver/default_fixtures.ts +226 -0
- package/src/oracle/test-resolver/index.ts +44 -0
- package/src/oracle/test-resolver/resolver.ts +198 -0
- package/src/oracle/txe_oracle_public_context.ts +60 -0
- package/src/oracle/txe_oracle_registry.ts +494 -0
- package/src/oracle/txe_oracle_top_level_context.ts +245 -81
- package/src/oracle/txe_oracle_version.ts +17 -0
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +845 -905
- package/src/state_machine/archiver.ts +37 -16
- package/src/state_machine/dummy_p2p_client.ts +40 -11
- package/src/state_machine/global_variable_builder.ts +12 -11
- package/src/state_machine/index.ts +44 -30
- package/src/state_machine/mock_epoch_cache.ts +0 -4
- package/src/state_machine/synchronizer.ts +4 -3
- package/src/txe_session.ts +496 -80
- package/src/utils/block_creation.ts +2 -1
- package/src/{util → utils}/encoding.ts +8 -2
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/{util → utils}/txe_public_contract_data_source.ts +0 -2
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -720
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_store.d.ts.map +0 -1
- package/dest/util/txe_public_contract_data_source.d.ts +0 -20
- package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/dest/{util → utils}/txe_account_store.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
- /package/src/{util → utils}/txe_account_store.ts +0 -0
package/dest/txe_session.js
CHANGED
|
@@ -2,31 +2,42 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { KeyStore } from '@aztec/key-store';
|
|
5
|
-
import {
|
|
6
|
-
import { AddressStore, AnchorBlockStore, CapsuleStore,
|
|
7
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache,
|
|
5
|
+
import { openEphemeralStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleService, CapsuleStore, FactService, FactStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderTaggingStore, TaggingSecretSourcesStore, composeHooks } from '@aztec/pxe/server';
|
|
7
|
+
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, TransientArrayService, UtilityExecutionOracle, buildACIRCallback } from '@aztec/pxe/simulator';
|
|
8
8
|
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
|
+
import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-registry/constants';
|
|
9
10
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
10
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import { GasSettings } from '@aztec/stdlib/gas';
|
|
12
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
13
13
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
14
|
-
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
14
|
+
import { CallContext, OFFCHAIN_MESSAGE_IDENTIFIER, TxContext } from '@aztec/stdlib/tx';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
-
import { DEFAULT_ADDRESS } from './constants.js';
|
|
16
|
+
import { DEFAULT_ADDRESS, MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY, MAX_OFFCHAIN_EFFECT_LEN } 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
|
-
import {
|
|
19
|
+
import { TXE_ORACLE_VERSION_MAJOR, TXE_ORACLE_VERSION_MINOR } from './oracle/txe_oracle_version.js';
|
|
20
|
+
import { TXEPrivateExecutionOracle } from './oracle/txe_private_execution_oracle.js';
|
|
21
|
+
import { RPCTranslator, UnavailableOracleError } from './rpc_translator.js';
|
|
20
22
|
import { TXEArchiver } from './state_machine/archiver.js';
|
|
21
23
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
22
|
-
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
23
24
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
24
25
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
26
|
+
import { TXEAccountStore } from './utils/txe_account_store.js';
|
|
27
|
+
function emptyLastCallState() {
|
|
28
|
+
return {
|
|
29
|
+
offchainEffects: [],
|
|
30
|
+
queried: false,
|
|
31
|
+
txHash: Fr.ZERO,
|
|
32
|
+
anchorBlockTimestamp: 0n
|
|
33
|
+
};
|
|
34
|
+
}
|
|
25
35
|
/**
|
|
26
36
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
27
37
|
* state, etc., independent of all other tests running in parallel.
|
|
28
38
|
*/ export class TXESession {
|
|
29
39
|
logger;
|
|
40
|
+
sessionStore;
|
|
30
41
|
stateMachine;
|
|
31
42
|
oracleHandler;
|
|
32
43
|
contractStore;
|
|
@@ -36,19 +47,27 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
36
47
|
accountStore;
|
|
37
48
|
senderTaggingStore;
|
|
38
49
|
recipientTaggingStore;
|
|
39
|
-
|
|
50
|
+
taggingSecretSourcesStore;
|
|
40
51
|
capsuleStore;
|
|
52
|
+
factStore;
|
|
41
53
|
privateEventStore;
|
|
42
54
|
jobCoordinator;
|
|
43
55
|
currentJobId;
|
|
44
56
|
chainId;
|
|
45
57
|
version;
|
|
46
58
|
nextBlockTimestamp;
|
|
47
|
-
|
|
59
|
+
artifactResolver;
|
|
60
|
+
rootPath;
|
|
61
|
+
packageName;
|
|
48
62
|
state;
|
|
49
63
|
authwits;
|
|
50
|
-
|
|
64
|
+
taggingSecretStrategy;
|
|
65
|
+
lastCallInfo;
|
|
66
|
+
txeOracleVersion;
|
|
67
|
+
disposed;
|
|
68
|
+
constructor(logger, sessionStore, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, taggingSecretSourcesStore, capsuleStore, factStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp, artifactResolver, rootPath, packageName){
|
|
51
69
|
this.logger = logger;
|
|
70
|
+
this.sessionStore = sessionStore;
|
|
52
71
|
this.stateMachine = stateMachine;
|
|
53
72
|
this.oracleHandler = oracleHandler;
|
|
54
73
|
this.contractStore = contractStore;
|
|
@@ -58,35 +77,65 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
58
77
|
this.accountStore = accountStore;
|
|
59
78
|
this.senderTaggingStore = senderTaggingStore;
|
|
60
79
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
61
|
-
this.
|
|
80
|
+
this.taggingSecretSourcesStore = taggingSecretSourcesStore;
|
|
62
81
|
this.capsuleStore = capsuleStore;
|
|
82
|
+
this.factStore = factStore;
|
|
63
83
|
this.privateEventStore = privateEventStore;
|
|
64
84
|
this.jobCoordinator = jobCoordinator;
|
|
65
85
|
this.currentJobId = currentJobId;
|
|
66
86
|
this.chainId = chainId;
|
|
67
87
|
this.version = version;
|
|
68
88
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
69
|
-
this.
|
|
89
|
+
this.artifactResolver = artifactResolver;
|
|
90
|
+
this.rootPath = rootPath;
|
|
91
|
+
this.packageName = packageName;
|
|
70
92
|
this.state = {
|
|
71
93
|
name: 'TOP_LEVEL'
|
|
72
94
|
};
|
|
73
95
|
this.authwits = new Map();
|
|
96
|
+
this.taggingSecretStrategy = undefined;
|
|
97
|
+
this.lastCallInfo = emptyLastCallState();
|
|
98
|
+
this.disposed = false;
|
|
74
99
|
}
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Closes the per-session `txe-session` LMDB and the `NativeWorldStateService` .
|
|
102
|
+
* Called via IPC when the dispatcher detects the end of a test. Idempotent.
|
|
103
|
+
*/ async dispose() {
|
|
104
|
+
if (this.disposed) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.disposed = true;
|
|
108
|
+
try {
|
|
109
|
+
await this.stateMachine.synchronizer.nativeWorldStateService.close();
|
|
110
|
+
} catch (err) {
|
|
111
|
+
this.logger.warn(`Error closing native world state during session dispose`, err);
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
await this.sessionStore.close();
|
|
115
|
+
} catch (err) {
|
|
116
|
+
this.logger.warn(`Error closing session LMDB during dispose`, err);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
static async init(contractStore, artifactResolver, rootPath, packageName) {
|
|
120
|
+
// Size LMDB's reader slots to the libuv pool (capped to 2 in bin/index.ts via
|
|
121
|
+
// HARDWARE_CONCURRENCY): each native LMDB read needs a libuv worker thread to run, so any
|
|
122
|
+
// slot beyond the pool size would sit idle while still consuming a semaphore + reader-table
|
|
123
|
+
// entry per session.
|
|
124
|
+
const store = await openEphemeralStore('txe-session', undefined, 2);
|
|
77
125
|
const addressStore = new AddressStore(store);
|
|
78
126
|
const privateEventStore = new PrivateEventStore(store);
|
|
79
127
|
const noteStore = new NoteStore(store);
|
|
80
128
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
81
129
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
82
|
-
const
|
|
130
|
+
const taggingSecretSourcesStore = new TaggingSecretSourcesStore(store);
|
|
83
131
|
const capsuleStore = new CapsuleStore(store);
|
|
132
|
+
const factStore = new FactStore(store);
|
|
84
133
|
const keyStore = new KeyStore(store);
|
|
85
134
|
const accountStore = new TXEAccountStore(store);
|
|
86
|
-
// Create job coordinator and register staged stores
|
|
87
135
|
const jobCoordinator = new JobCoordinator(store);
|
|
88
136
|
jobCoordinator.registerStores([
|
|
89
137
|
capsuleStore,
|
|
138
|
+
factStore,
|
|
90
139
|
senderTaggingStore,
|
|
91
140
|
recipientTaggingStore,
|
|
92
141
|
privateEventStore,
|
|
@@ -100,10 +149,11 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
100
149
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
101
150
|
const initialJobId = jobCoordinator.beginJob();
|
|
102
151
|
const logger = createLogger('txe:session');
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
152
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, taggingSecretSourcesStore, capsuleStore, factStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map(), undefined, artifactResolver, rootPath, packageName);
|
|
153
|
+
await topLevelOracleHandler.mineDeploymentNullifiers([
|
|
154
|
+
STANDARD_AUTH_REGISTRY_ADDRESS
|
|
155
|
+
]);
|
|
156
|
+
return new TXESession(logger, store, stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, taggingSecretSourcesStore, capsuleStore, factStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp, artifactResolver, rootPath, packageName);
|
|
107
157
|
}
|
|
108
158
|
/**
|
|
109
159
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -118,7 +168,15 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
118
168
|
return translator[validatedFunctionName](...inputs);
|
|
119
169
|
} catch (error) {
|
|
120
170
|
if (error instanceof z.ZodError) {
|
|
121
|
-
|
|
171
|
+
let versionHint;
|
|
172
|
+
if (!this.txeOracleVersion) {
|
|
173
|
+
versionHint = ' The test appears to use an older version of Aztec.nr that does not' + ' support test environment oracle versioning. Update Aztec.nr to a compatible version.' + ' See https://docs.aztec.network/errors/12';
|
|
174
|
+
} else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
|
|
175
|
+
versionHint = ` The test uses Aztec.nr test oracle version` + ` ${this.txeOracleVersion.major}.${this.txeOracleVersion.minor}, but this test environment` + ` only supports up to ${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}.` + ` Upgrade the Aztec CLI to a compatible version.` + ` See https://docs.aztec.network/errors/12`;
|
|
176
|
+
} else {
|
|
177
|
+
versionHint = ` The test's oracle version (${this.txeOracleVersion.major}.${this.txeOracleVersion.minor})` + ` is compatible with this test environment` + ` (${TXE_ORACLE_VERSION_MAJOR}.${TXE_ORACLE_VERSION_MINOR}), so this oracle should be` + ` available. This is an unexpected error, please report it.` + ` See https://docs.aztec.network/errors/13`;
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`Unknown oracle '${functionName}'.${versionHint}`);
|
|
122
180
|
} else if (error instanceof Error) {
|
|
123
181
|
throw new Error(`Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`);
|
|
124
182
|
} else {
|
|
@@ -126,14 +184,132 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
126
184
|
}
|
|
127
185
|
}
|
|
128
186
|
}
|
|
129
|
-
getCurrentJob() {
|
|
130
|
-
return this.currentJobId;
|
|
131
|
-
}
|
|
132
187
|
/** Commits the current job and begins a new one. Returns the new job ID. */ async cycleJob() {
|
|
133
188
|
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
134
189
|
this.currentJobId = this.jobCoordinator.beginJob();
|
|
135
190
|
return this.currentJobId;
|
|
136
191
|
}
|
|
192
|
+
resetLastCall() {
|
|
193
|
+
const notQueriedMessageCount = this.lastCallInfo.queried ? 0 : this.lastCallInfo.offchainEffects.filter((payload)=>payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
|
|
194
|
+
if (notQueriedMessageCount > 0) {
|
|
195
|
+
this.logger.warn(`Dropping ${notQueriedMessageCount} unqueried offchain message(s) from the previous top-level call. ` + `To deliver them, call \`env.offchain_messages()\` and forward the result to the recipient contract's ` + `\`offchain_receive\` utility before issuing another top-level call. To intentionally discard, assign ` + `to \`let _ = env.offchain_messages()\` to silence this warning.`);
|
|
196
|
+
}
|
|
197
|
+
this.lastCallInfo = emptyLastCallState();
|
|
198
|
+
}
|
|
199
|
+
recordOffchainEffect(data) {
|
|
200
|
+
this.lastCallInfo.offchainEffects.push(data);
|
|
201
|
+
}
|
|
202
|
+
setLastCallContext(txHash, anchorBlockTimestamp) {
|
|
203
|
+
this.lastCallInfo.txHash = txHash;
|
|
204
|
+
this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
|
|
205
|
+
}
|
|
206
|
+
async withTopLevelCallTracking(work) {
|
|
207
|
+
this.resetLastCall();
|
|
208
|
+
// Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
|
|
209
|
+
// side effect, and that block's timestamp should not be attributed to this call's anchor.
|
|
210
|
+
const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest')).header.globalVariables.timestamp;
|
|
211
|
+
const { result, txHash } = await work();
|
|
212
|
+
this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
getLastCallOffchainEffects() {
|
|
216
|
+
this.lastCallInfo.queried = true;
|
|
217
|
+
const effects = this.lastCallInfo.offchainEffects;
|
|
218
|
+
if (effects.length > MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY) {
|
|
219
|
+
throw new Error(`${effects.length} offchain effects exceed max ${MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY}`);
|
|
220
|
+
}
|
|
221
|
+
if (effects.some((e)=>e.length > MAX_OFFCHAIN_EFFECT_LEN)) {
|
|
222
|
+
throw new Error(`Some offchain effect has length larger than max ${MAX_OFFCHAIN_EFFECT_LEN}`);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
effects
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
getLastCallContext() {
|
|
229
|
+
const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
|
|
230
|
+
return {
|
|
231
|
+
txHash,
|
|
232
|
+
anchorBlockTimestamp
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
async executePrivateCall(from, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, authorizedUtilityCallTargets, gasSettings) {
|
|
236
|
+
const handler = this.handlerAsTxe();
|
|
237
|
+
return await this.withTopLevelCallTracking(async ()=>{
|
|
238
|
+
const { returnValues, offchainEffects } = await handler.privateCallNewFlow(from?.value, targetContractAddress, functionSelector, args, argsHash, isStaticCall, additionalScopes, this.currentJobId, authorizedUtilityCallTargets, gasSettings);
|
|
239
|
+
// Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than round-tripping
|
|
240
|
+
// them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty at this point. Drain the effects
|
|
241
|
+
// from the execution tree into the session buffer so the next `env.offchain_messages()` call in the test sees
|
|
242
|
+
// them.
|
|
243
|
+
for (const data of offchainEffects){
|
|
244
|
+
this.recordOffchainEffect(data);
|
|
245
|
+
}
|
|
246
|
+
await this.cycleJob();
|
|
247
|
+
if (isStaticCall) {
|
|
248
|
+
// Static calls revert their checkpoint and mine no block, so there is no tx hash to tag offchain effects
|
|
249
|
+
// with. Querying `getLastTxEffects()` here would return an unrelated predecessor tx.
|
|
250
|
+
return {
|
|
251
|
+
result: returnValues
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const { txHash } = await handler.getLastTxEffects();
|
|
255
|
+
return {
|
|
256
|
+
result: returnValues,
|
|
257
|
+
txHash: txHash.hash
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
async executeUtilityFunction(from, targetContractAddress, functionSelector, args, authorizedUtilityCallTargets) {
|
|
262
|
+
const handler = this.handlerAsTxe();
|
|
263
|
+
return await this.withTopLevelCallTracking(async ()=>{
|
|
264
|
+
const returnValues = await handler.executeUtilityFunction(from?.value, targetContractAddress, functionSelector, args, this.currentJobId, authorizedUtilityCallTargets);
|
|
265
|
+
await this.cycleJob();
|
|
266
|
+
return {
|
|
267
|
+
result: returnValues
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async executePublicCall(from, targetContractAddress, calldata, isStaticCall, gasSettings) {
|
|
272
|
+
const handler = this.handlerAsTxe();
|
|
273
|
+
return await this.withTopLevelCallTracking(async ()=>{
|
|
274
|
+
const returnValues = await handler.publicCallNewFlow(from?.value, targetContractAddress, calldata, isStaticCall, gasSettings);
|
|
275
|
+
await this.cycleJob();
|
|
276
|
+
if (isStaticCall) {
|
|
277
|
+
// See the equivalent branch in `executePrivateCall`.
|
|
278
|
+
return {
|
|
279
|
+
result: returnValues
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const { txHash } = await handler.getLastTxEffects();
|
|
283
|
+
return {
|
|
284
|
+
result: returnValues,
|
|
285
|
+
txHash: txHash.hash
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async getPrivateEvents(selector, contractAddress, scope) {
|
|
290
|
+
const handler = this.handlerAsTxe();
|
|
291
|
+
await handler.syncContractNonOracleMethod(contractAddress, scope, this.currentJobId);
|
|
292
|
+
// Cycle the job to commit the stores after the contract sync.
|
|
293
|
+
await this.cycleJob();
|
|
294
|
+
return handler.getPrivateEvents(selector, contractAddress, scope);
|
|
295
|
+
}
|
|
296
|
+
handlerAsTxe() {
|
|
297
|
+
if (!('isTxe' in this.oracleHandler)) {
|
|
298
|
+
throw new UnavailableOracleError('Txe');
|
|
299
|
+
}
|
|
300
|
+
return this.oracleHandler;
|
|
301
|
+
}
|
|
302
|
+
setTxeOracleVersion(major, minor) {
|
|
303
|
+
if (major !== TXE_ORACLE_VERSION_MAJOR) {
|
|
304
|
+
const hint = major > TXE_ORACLE_VERSION_MAJOR ? 'The test was compiled with a newer version of Aztec.nr than your test environment supports. Upgrade your test environment to a compatible version.' : 'The test was compiled with an older version of Aztec.nr than your test environment supports. Recompile the test with a compatible version of Aztec.nr.';
|
|
305
|
+
throw new Error(`Incompatible test environment version: ${hint} See https://docs.aztec.network/errors/12 (expected test oracle major version ${TXE_ORACLE_VERSION_MAJOR}, got ${major})`);
|
|
306
|
+
}
|
|
307
|
+
this.txeOracleVersion = {
|
|
308
|
+
major,
|
|
309
|
+
minor
|
|
310
|
+
};
|
|
311
|
+
this.logger.debug(`Test compiled with test oracle version ${major}.${minor}`);
|
|
312
|
+
}
|
|
137
313
|
async enterTopLevelState() {
|
|
138
314
|
switch(this.state.name){
|
|
139
315
|
case 'PRIVATE':
|
|
@@ -162,20 +338,23 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
162
338
|
}
|
|
163
339
|
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
164
340
|
await this.cycleJob();
|
|
165
|
-
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.
|
|
341
|
+
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.taggingSecretSourcesStore, this.capsuleStore, this.factStore, this.privateEventStore, this.nextBlockTimestamp, this.version, this.chainId, this.authwits, this.taggingSecretStrategy, this.artifactResolver, this.rootPath, this.packageName);
|
|
166
342
|
this.state = {
|
|
167
343
|
name: 'TOP_LEVEL'
|
|
168
344
|
};
|
|
169
345
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
170
346
|
}
|
|
171
|
-
async enterPrivateState(
|
|
347
|
+
async enterPrivateState(contractAddressOpt, anchorBlockNumberOpt, gasSettings) {
|
|
348
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
349
|
+
const anchorBlockNumber = anchorBlockNumberOpt?.value;
|
|
172
350
|
this.exitTopLevelState();
|
|
351
|
+
this.resetLastCall();
|
|
173
352
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
174
353
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
175
354
|
// a single transaction with the effects of what was done in the test.
|
|
176
|
-
const anchorBlock = await this.stateMachine.node.
|
|
177
|
-
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress,
|
|
178
|
-
const latestBlock = await this.stateMachine.node.
|
|
355
|
+
const anchorBlock = await this.stateMachine.node.getBlock(anchorBlockNumber ?? 'latest').then((b)=>b?.header);
|
|
356
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
357
|
+
const latestBlock = await this.stateMachine.node.getBlock('latest').then((b)=>b?.header);
|
|
179
358
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
180
359
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
181
360
|
timestamp: this.nextBlockTimestamp,
|
|
@@ -187,9 +366,11 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
187
366
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
188
367
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
189
368
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
190
|
-
|
|
369
|
+
const transientArrayService = new TransientArrayService();
|
|
370
|
+
const taggingSecretStrategy = this.taggingSecretStrategy;
|
|
371
|
+
this.oracleHandler = new TXEPrivateExecutionOracle({
|
|
191
372
|
argsHash: Fr.ZERO,
|
|
192
|
-
txContext: new TxContext(this.chainId, this.version,
|
|
373
|
+
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
193
374
|
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
194
375
|
anchorBlockHeader: anchorBlock,
|
|
195
376
|
utilityExecutor,
|
|
@@ -205,13 +386,20 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
205
386
|
aztecNode: this.stateMachine.node,
|
|
206
387
|
senderTaggingStore: this.senderTaggingStore,
|
|
207
388
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
208
|
-
|
|
209
|
-
|
|
389
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
390
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
391
|
+
factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
|
|
210
392
|
privateEventStore: this.privateEventStore,
|
|
211
393
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
394
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
212
395
|
jobId: this.currentJobId,
|
|
213
|
-
scopes:
|
|
214
|
-
|
|
396
|
+
scopes: await this.keyStore.getAccounts(),
|
|
397
|
+
txResolver: this.stateMachine.txResolver,
|
|
398
|
+
simulator: new WASMSimulator(),
|
|
399
|
+
hooks: composeHooks({
|
|
400
|
+
resolveTaggingSecretStrategy: taggingSecretStrategy ? ()=>Promise.resolve(taggingSecretStrategy) : undefined
|
|
401
|
+
}),
|
|
402
|
+
transientArrayService
|
|
215
403
|
});
|
|
216
404
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
217
405
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
@@ -225,36 +413,51 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
225
413
|
taggingIndexCache
|
|
226
414
|
};
|
|
227
415
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
416
|
+
// Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
|
|
417
|
+
// via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
|
|
418
|
+
this.setLastCallContext(Fr.ZERO, anchorBlock.globalVariables.timestamp);
|
|
228
419
|
return this.oracleHandler.getPrivateContextInputs();
|
|
229
420
|
}
|
|
230
|
-
async enterPublicState(
|
|
421
|
+
async enterPublicState(contractAddressOpt) {
|
|
422
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
231
423
|
this.exitTopLevelState();
|
|
424
|
+
this.resetLastCall();
|
|
232
425
|
// The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
|
|
233
426
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
234
|
-
const
|
|
427
|
+
const latestHeader = (await this.stateMachine.node.getBlockData('latest')).header;
|
|
235
428
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
236
|
-
blockNumber: BlockNumber(
|
|
429
|
+
blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
|
|
237
430
|
timestamp: this.nextBlockTimestamp,
|
|
238
431
|
version: this.version,
|
|
239
432
|
chainId: this.chainId
|
|
240
433
|
});
|
|
241
|
-
this.oracleHandler = new TXEOraclePublicContext(contractAddress
|
|
434
|
+
this.oracleHandler = new TXEOraclePublicContext(contractAddress, await this.stateMachine.synchronizer.nativeWorldStateService.fork(), getSingleTxBlockRequestHash(globalVariables.blockNumber), globalVariables, this.contractStore);
|
|
242
435
|
this.state = {
|
|
243
436
|
name: 'PUBLIC'
|
|
244
437
|
};
|
|
245
438
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
439
|
+
// Public state is anchored at the latest block.
|
|
440
|
+
this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
|
|
246
441
|
}
|
|
247
|
-
async enterUtilityState(
|
|
442
|
+
async enterUtilityState(contractAddressOpt) {
|
|
443
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
248
444
|
this.exitTopLevelState();
|
|
445
|
+
this.resetLastCall();
|
|
249
446
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
250
447
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
251
448
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
252
449
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
253
450
|
// be removed from the database.
|
|
254
451
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
255
|
-
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress,
|
|
452
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
256
453
|
this.oracleHandler = new UtilityExecutionOracle({
|
|
257
|
-
|
|
454
|
+
callContext: CallContext.from({
|
|
455
|
+
msgSender: AztecAddress.NULL_MSG_SENDER,
|
|
456
|
+
contractAddress,
|
|
457
|
+
// No specific function is being executed in this inlined utility context, hence the empty selector.
|
|
458
|
+
functionSelector: FunctionSelector.empty(),
|
|
459
|
+
isStaticCall: true
|
|
460
|
+
}),
|
|
258
461
|
authWitnesses: [],
|
|
259
462
|
capsules: [],
|
|
260
463
|
anchorBlockHeader,
|
|
@@ -264,33 +467,43 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
264
467
|
addressStore: this.addressStore,
|
|
265
468
|
aztecNode: this.stateMachine.node,
|
|
266
469
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
267
|
-
|
|
268
|
-
|
|
470
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
471
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
472
|
+
factService: new FactService(this.factStore, await this.keyStore.getAccounts()),
|
|
269
473
|
privateEventStore: this.privateEventStore,
|
|
270
|
-
|
|
271
|
-
contractSyncService: this.contractSyncService,
|
|
474
|
+
txResolver: this.stateMachine.txResolver,
|
|
475
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
476
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
272
477
|
jobId: this.currentJobId,
|
|
273
|
-
scopes:
|
|
478
|
+
scopes: await this.keyStore.getAccounts(),
|
|
479
|
+
simulator: new WASMSimulator(),
|
|
480
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlockHeader),
|
|
481
|
+
// Execution-tree root (top-level utility run): own store; nested frames inherit it.
|
|
482
|
+
transientArrayService: new TransientArrayService()
|
|
274
483
|
});
|
|
275
484
|
this.state = {
|
|
276
485
|
name: 'UTILITY'
|
|
277
486
|
};
|
|
278
487
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
488
|
+
// Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
|
|
489
|
+
this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
|
|
279
490
|
}
|
|
280
491
|
exitTopLevelState() {
|
|
281
492
|
if (this.state.name != 'TOP_LEVEL') {
|
|
282
493
|
throw new Error(`Expected to be in state 'TOP_LEVEL', but got '${this.state.name}' instead`);
|
|
283
494
|
}
|
|
284
495
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
//
|
|
290
|
-
//
|
|
291
|
-
// the
|
|
292
|
-
//
|
|
293
|
-
|
|
496
|
+
// them, the top level context does most of its work as it goes: it creates empty blocks (via `advanceBlocksBy`
|
|
497
|
+
// and `deploy`), creates blocks with transactions (via `privateCallNewFlow` and `publicCallNewFlow`), adds
|
|
498
|
+
// accounts to PXE (via `addAccount`), etc. This is a slight inconsistency in the working model of this class, but
|
|
499
|
+
// is not too bad. The `close` call below therefore only hands back the session-scoped values that a test
|
|
500
|
+
// sets directly at the top level, outside any contract execution (e.g. via `advanceTimestampBy`,
|
|
501
|
+
// `addAuthWitness`, `setTaggingSecretStrategy`). The oracle handler is discarded on every state transition,
|
|
502
|
+
// so the session must seed these values into the contexts it creates later.
|
|
503
|
+
// TODO: persisting authwits this way is quite unfortunate: they create a temporary utility context that would
|
|
504
|
+
// otherwise reset them, so we'd not be able to pass more than one per execution. Ideally authwits would be passed
|
|
505
|
+
// alongside a contract call instead of pre-seeded.
|
|
506
|
+
[this.nextBlockTimestamp, this.authwits, this.taggingSecretStrategy] = this.oracleHandler.close();
|
|
294
507
|
}
|
|
295
508
|
async exitPrivateState() {
|
|
296
509
|
if (this.state.name != 'PRIVATE') {
|
|
@@ -334,8 +547,14 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
334
547
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
335
548
|
}
|
|
336
549
|
try {
|
|
550
|
+
const simulator = new WASMSimulator();
|
|
337
551
|
const oracle = new UtilityExecutionOracle({
|
|
338
|
-
|
|
552
|
+
callContext: CallContext.from({
|
|
553
|
+
msgSender: AztecAddress.NULL_MSG_SENDER,
|
|
554
|
+
contractAddress: call.to,
|
|
555
|
+
functionSelector: call.selector,
|
|
556
|
+
isStaticCall: true
|
|
557
|
+
}),
|
|
339
558
|
authWitnesses: [],
|
|
340
559
|
capsules: [],
|
|
341
560
|
anchorBlockHeader: anchorBlock,
|
|
@@ -345,15 +564,21 @@ import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
|
345
564
|
addressStore: this.addressStore,
|
|
346
565
|
aztecNode: this.stateMachine.node,
|
|
347
566
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
348
|
-
|
|
349
|
-
|
|
567
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
568
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
569
|
+
factService: new FactService(this.factStore, scopes),
|
|
350
570
|
privateEventStore: this.privateEventStore,
|
|
351
|
-
|
|
352
|
-
contractSyncService: this.contractSyncService,
|
|
571
|
+
txResolver: this.stateMachine.txResolver,
|
|
572
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
573
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
353
574
|
jobId: this.currentJobId,
|
|
354
|
-
scopes
|
|
575
|
+
scopes,
|
|
576
|
+
simulator,
|
|
577
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlock),
|
|
578
|
+
// Top-level utility entrypoint: gets a fresh store. Nested frames inherit it via UtilityExecutionOracle.
|
|
579
|
+
transientArrayService: new TransientArrayService()
|
|
355
580
|
});
|
|
356
|
-
await
|
|
581
|
+
await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle)).catch((err)=>{
|
|
357
582
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
358
583
|
throw new ExecutionError(err.message, {
|
|
359
584
|
contractAddress: call.to,
|
|
@@ -9,7 +9,7 @@ import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
|
9
9
|
* @returns The transaction request hash.
|
|
10
10
|
*/
|
|
11
11
|
export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
|
|
12
|
-
export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
|
|
12
|
+
export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations, l1ToL2Messages?: Fr[]): Promise<void>;
|
|
13
13
|
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
|
|
14
14
|
/**
|
|
15
15
|
* Creates an L2Block with proper archive chaining.
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUEyQyxNQUFNLGlDQUFpQyxDQUFDO0FBRXZHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQVEsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEQsT0FBTyxFQUF3QyxLQUFLLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDM0csT0FBTyxFQUFFLFdBQVcsRUFBRSxlQUFlLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUU7Ozs7R0FJRztBQUNILHdCQUFnQiwyQkFBMkIsQ0FBQyxXQUFXLEVBQUUsV0FBVyxHQUFHLEVBQUUsQ0FFeEU7QUFFRCx3QkFBc0IsNEJBQTRCLENBQ2hELFFBQVEsRUFBRSxRQUFRLEVBQ2xCLFVBQVUsRUFBRSx5QkFBeUIsRUFDckMsY0FBYyxHQUFFLEVBQUUsRUFBTyxHQUN4QixPQUFPLENBQUMsSUFBSSxDQUFDLENBa0JmO0FBRUQsd0JBQXNCLGtCQUFrQixDQUN0QyxVQUFVLEVBQUUseUJBQXlCLEVBQ3JDLGVBQWUsRUFBRSxlQUFlLEdBQy9CLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FZdEI7QUFFRDs7Ozs7Ozs7Ozs7O0dBWUc7QUFDSCx3QkFBc0IsWUFBWSxDQUNoQyxVQUFVLEVBQUUseUJBQXlCLEVBQ3JDLGVBQWUsRUFBRSxlQUFlLEVBQ2hDLFNBQVMsRUFBRSxRQUFRLEVBQUUsR0FDcEIsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQWlCbEIifQ==
|
|
@@ -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,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,
|
|
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,EACrC,cAAc,GAAE,EAAE,EAAO,GACxB,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"}
|
|
@@ -12,10 +12,10 @@ import { BlockHeader } from '@aztec/stdlib/tx';
|
|
|
12
12
|
*/ export function getSingleTxBlockRequestHash(blockNumber) {
|
|
13
13
|
return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
|
|
14
14
|
}
|
|
15
|
-
export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
|
|
15
|
+
export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees, l1ToL2Messages = []) {
|
|
16
16
|
await worldTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
|
|
17
17
|
await worldTrees.batchInsert(MerkleTreeId.NULLIFIER_TREE, padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((nullifier)=>nullifier.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
18
|
-
await worldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(
|
|
18
|
+
await worldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
19
19
|
// We do not need to add public data writes because we apply them as we go.
|
|
20
20
|
}
|
|
21
21
|
export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|