@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97
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/ContractClassRegistry-PII7Q556.js +3 -0
- package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
- package/dest/FeeJuice-TQV5AQK7.js +3 -0
- package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
- package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
- package/dest/SchnorrAccount-MQXPIZ44.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.d.ts +1 -1
- 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-CUSVOJA4.js +304 -0
- package/dest/chunk-CUSVOJA4.js.map +7 -0
- package/dest/chunk-OYLIPWI6.js +260 -0
- package/dest/chunk-OYLIPWI6.js.map +7 -0
- package/dest/constants.d.ts +7 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +10 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +185 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +73 -158
- package/dest/metafile.json +36863 -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 +60 -31
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
- package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/fixtures.js +39 -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 +33 -0
- package/dest/oracle/test-resolver/resolver.d.ts +34 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +114 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +41 -17
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +63 -23
- package/dest/oracle/txe_oracle_registry.d.ts +147 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +562 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +57 -28
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +341 -130
- 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 +96 -213
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +815 -550
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +23 -52
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +77 -99
- package/dest/state_machine/dummy_p2p_client.d.ts +28 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +54 -22
- package/dest/state_machine/global_variable_builder.d.ts +11 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +21 -3
- package/dest/state_machine/index.d.ts +11 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +60 -25
- package/dest/state_machine/mock_epoch_cache.d.ts +29 -12
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +50 -15
- package/dest/state_machine/synchronizer.d.ts +6 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +9 -8
- package/dest/txe_session.d.ts +94 -21
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +314 -68
- package/dest/utils/block_creation.d.ts +21 -6
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +38 -4
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +8 -3
- package/dest/utils/expected_failure_error.d.ts +4 -0
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.d.ts +3 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +4 -7
- package/dest/utils/txe_account_store.d.ts +10 -0
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
- 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/utils/txe_public_contract_data_source.js +48 -0
- 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 +40 -22
- 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 +13 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +111 -201
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +62 -36
- package/src/oracle/test-resolver/fixtures.ts +84 -0
- package/src/oracle/test-resolver/index.ts +45 -0
- package/src/oracle/test-resolver/resolver.ts +165 -0
- package/src/oracle/txe_oracle_public_context.ts +81 -28
- package/src/oracle/txe_oracle_registry.ts +401 -0
- package/src/oracle/txe_oracle_top_level_context.ts +418 -178
- 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 +999 -909
- package/src/state_machine/archiver.ts +83 -115
- package/src/state_machine/dummy_p2p_client.ts +83 -33
- package/src/state_machine/global_variable_builder.ts +39 -6
- package/src/state_machine/index.ts +82 -24
- package/src/state_machine/mock_epoch_cache.ts +63 -23
- package/src/state_machine/synchronizer.ts +10 -9
- package/src/txe_session.ts +486 -119
- package/src/utils/block_creation.ts +49 -14
- package/src/{util → utils}/encoding.ts +9 -3
- package/src/utils/tx_effect_creation.ts +5 -12
- package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/utils/txe_public_contract_data_source.ts +58 -0
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -121
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts +0 -4
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.js +0 -22
- 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/txe_public_contract_data_source.js +0 -67
- package/src/util/txe_contract_data_provider.ts +0 -36
- package/src/util/txe_public_contract_data_source.ts +0 -85
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_session.d.ts","sourceRoot":"","sources":["../src/txe_session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
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;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EACL,YAAY,EAGZ,YAAY,EACZ,aAAa,EACb,cAAc,EAEd,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,MAAM,EAGP,MAAM,sBAAsB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types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { KeyStore } from '@aztec/key-store';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache,
|
|
7
|
-
import {
|
|
5
|
+
import { openEphemeralStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleService, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
|
+
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
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';
|
|
10
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
8
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
12
|
+
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
13
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
14
|
+
import { CallContext, OFFCHAIN_MESSAGE_IDENTIFIER, TxContext } from '@aztec/stdlib/tx';
|
|
13
15
|
import { z } from 'zod';
|
|
16
|
+
import { DEFAULT_ADDRESS, MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY, MAX_OFFCHAIN_EFFECT_LEN } from './constants.js';
|
|
14
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
15
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
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';
|
|
16
21
|
import { RPCTranslator } from './rpc_translator.js';
|
|
22
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
17
23
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
18
|
-
import {
|
|
19
|
-
import { TXEContractDataProvider } from './util/txe_contract_data_provider.js';
|
|
20
|
-
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlockHeader } from './utils/block_creation.js';
|
|
24
|
+
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
21
25
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
22
|
-
|
|
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
|
+
}
|
|
23
35
|
/**
|
|
24
36
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
25
37
|
* state, etc., independent of all other tests running in parallel.
|
|
26
38
|
*/ export class TXESession {
|
|
27
39
|
logger;
|
|
40
|
+
sessionStore;
|
|
28
41
|
stateMachine;
|
|
29
42
|
oracleHandler;
|
|
30
|
-
|
|
43
|
+
contractStore;
|
|
44
|
+
noteStore;
|
|
31
45
|
keyStore;
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
addressStore;
|
|
47
|
+
accountStore;
|
|
48
|
+
senderTaggingStore;
|
|
49
|
+
recipientTaggingStore;
|
|
50
|
+
senderAddressBookStore;
|
|
51
|
+
capsuleStore;
|
|
52
|
+
privateEventStore;
|
|
53
|
+
jobCoordinator;
|
|
54
|
+
currentJobId;
|
|
34
55
|
chainId;
|
|
35
56
|
version;
|
|
36
57
|
nextBlockTimestamp;
|
|
37
|
-
|
|
58
|
+
artifactResolver;
|
|
59
|
+
rootPath;
|
|
60
|
+
packageName;
|
|
38
61
|
state;
|
|
39
62
|
authwits;
|
|
40
|
-
|
|
63
|
+
lastCallInfo;
|
|
64
|
+
txeOracleVersion;
|
|
65
|
+
disposed;
|
|
66
|
+
constructor(logger, sessionStore, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp, artifactResolver, rootPath, packageName){
|
|
41
67
|
this.logger = logger;
|
|
68
|
+
this.sessionStore = sessionStore;
|
|
42
69
|
this.stateMachine = stateMachine;
|
|
43
70
|
this.oracleHandler = oracleHandler;
|
|
44
|
-
this.
|
|
71
|
+
this.contractStore = contractStore;
|
|
72
|
+
this.noteStore = noteStore;
|
|
45
73
|
this.keyStore = keyStore;
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
74
|
+
this.addressStore = addressStore;
|
|
75
|
+
this.accountStore = accountStore;
|
|
76
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
77
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
78
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
79
|
+
this.capsuleStore = capsuleStore;
|
|
80
|
+
this.privateEventStore = privateEventStore;
|
|
81
|
+
this.jobCoordinator = jobCoordinator;
|
|
82
|
+
this.currentJobId = currentJobId;
|
|
48
83
|
this.chainId = chainId;
|
|
49
84
|
this.version = version;
|
|
50
85
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
51
|
-
this.
|
|
86
|
+
this.artifactResolver = artifactResolver;
|
|
87
|
+
this.rootPath = rootPath;
|
|
88
|
+
this.packageName = packageName;
|
|
52
89
|
this.state = {
|
|
53
90
|
name: 'TOP_LEVEL'
|
|
54
91
|
};
|
|
55
92
|
this.authwits = new Map();
|
|
93
|
+
this.lastCallInfo = emptyLastCallState();
|
|
94
|
+
this.disposed = false;
|
|
56
95
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
70
|
-
await contractDataProvider.addContractInstance(instance);
|
|
96
|
+
/**
|
|
97
|
+
* Closes the per-session `txe-session` LMDB and the `NativeWorldStateService` .
|
|
98
|
+
* Called via IPC when the dispatcher detects the end of a test. Idempotent.
|
|
99
|
+
*/ async dispose() {
|
|
100
|
+
if (this.disposed) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.disposed = true;
|
|
104
|
+
try {
|
|
105
|
+
await this.stateMachine.synchronizer.nativeWorldStateService.close();
|
|
106
|
+
} catch (err) {
|
|
107
|
+
this.logger.warn(`Error closing native world state during session dispose`, err);
|
|
71
108
|
}
|
|
72
|
-
|
|
109
|
+
try {
|
|
110
|
+
await this.sessionStore.close();
|
|
111
|
+
} catch (err) {
|
|
112
|
+
this.logger.warn(`Error closing session LMDB during dispose`, err);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
static async init(contractStore, artifactResolver, rootPath, packageName) {
|
|
116
|
+
// Size LMDB's reader slots to the libuv pool (capped to 2 in bin/index.ts via
|
|
117
|
+
// HARDWARE_CONCURRENCY): each native LMDB read needs a libuv worker thread to run, so any
|
|
118
|
+
// slot beyond the pool size would sit idle while still consuming a semaphore + reader-table
|
|
119
|
+
// entry per session.
|
|
120
|
+
const store = await openEphemeralStore('txe-session', undefined, 2);
|
|
121
|
+
const addressStore = new AddressStore(store);
|
|
122
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
123
|
+
const noteStore = new NoteStore(store);
|
|
124
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
125
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
126
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
127
|
+
const capsuleStore = new CapsuleStore(store);
|
|
128
|
+
const keyStore = new KeyStore(store);
|
|
129
|
+
const accountStore = new TXEAccountStore(store);
|
|
130
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
131
|
+
jobCoordinator.registerStores([
|
|
132
|
+
capsuleStore,
|
|
133
|
+
senderTaggingStore,
|
|
134
|
+
recipientTaggingStore,
|
|
135
|
+
privateEventStore,
|
|
136
|
+
noteStore
|
|
137
|
+
]);
|
|
138
|
+
const archiver = new TXEArchiver(store);
|
|
139
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
140
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
73
141
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
74
142
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
75
143
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
144
|
+
const initialJobId = jobCoordinator.beginJob();
|
|
145
|
+
const logger = createLogger('txe:session');
|
|
146
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map(), artifactResolver, rootPath, packageName);
|
|
147
|
+
await topLevelOracleHandler.mineDeploymentNullifiers([
|
|
148
|
+
STANDARD_AUTH_REGISTRY_ADDRESS
|
|
149
|
+
]);
|
|
150
|
+
return new TXESession(logger, store, stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp, artifactResolver, rootPath, packageName);
|
|
80
151
|
}
|
|
81
152
|
/**
|
|
82
153
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -91,7 +162,15 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
91
162
|
return translator[validatedFunctionName](...inputs);
|
|
92
163
|
} catch (error) {
|
|
93
164
|
if (error instanceof z.ZodError) {
|
|
94
|
-
|
|
165
|
+
let versionHint;
|
|
166
|
+
if (!this.txeOracleVersion) {
|
|
167
|
+
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';
|
|
168
|
+
} else if (this.txeOracleVersion.minor > TXE_ORACLE_VERSION_MINOR) {
|
|
169
|
+
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`;
|
|
170
|
+
} else {
|
|
171
|
+
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`;
|
|
172
|
+
}
|
|
173
|
+
throw new Error(`Unknown oracle '${functionName}'.${versionHint}`);
|
|
95
174
|
} else if (error instanceof Error) {
|
|
96
175
|
throw new Error(`Execution error while processing function ${functionName} in state ${this.state.name}: ${error.message}`);
|
|
97
176
|
} else {
|
|
@@ -99,6 +178,68 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
99
178
|
}
|
|
100
179
|
}
|
|
101
180
|
}
|
|
181
|
+
getCurrentJob() {
|
|
182
|
+
return this.currentJobId;
|
|
183
|
+
}
|
|
184
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */ async cycleJob() {
|
|
185
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
186
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
187
|
+
return this.currentJobId;
|
|
188
|
+
}
|
|
189
|
+
resetLastCall() {
|
|
190
|
+
const notQueriedMessageCount = this.lastCallInfo.queried ? 0 : this.lastCallInfo.offchainEffects.filter((payload)=>payload[0]?.equals(OFFCHAIN_MESSAGE_IDENTIFIER)).length;
|
|
191
|
+
if (notQueriedMessageCount > 0) {
|
|
192
|
+
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.`);
|
|
193
|
+
}
|
|
194
|
+
this.lastCallInfo = emptyLastCallState();
|
|
195
|
+
}
|
|
196
|
+
recordOffchainEffect(data) {
|
|
197
|
+
this.lastCallInfo.offchainEffects.push(data);
|
|
198
|
+
}
|
|
199
|
+
setLastCallContext(txHash, anchorBlockTimestamp) {
|
|
200
|
+
this.lastCallInfo.txHash = txHash;
|
|
201
|
+
this.lastCallInfo.anchorBlockTimestamp = anchorBlockTimestamp;
|
|
202
|
+
}
|
|
203
|
+
async withTopLevelCallTracking(work) {
|
|
204
|
+
this.resetLastCall();
|
|
205
|
+
// Capture the anchor *before* `work` runs: private/public executor calls mine a new block as a
|
|
206
|
+
// side effect, and that block's timestamp should not be attributed to this call's anchor.
|
|
207
|
+
const anchorBlockTimestamp = (await this.stateMachine.node.getBlockData('latest')).header.globalVariables.timestamp;
|
|
208
|
+
const { result, txHash } = await work();
|
|
209
|
+
this.setLastCallContext(txHash ?? Fr.ZERO, anchorBlockTimestamp);
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
getLastCallOffchainEffects() {
|
|
213
|
+
this.lastCallInfo.queried = true;
|
|
214
|
+
const effects = this.lastCallInfo.offchainEffects;
|
|
215
|
+
if (effects.length > MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY) {
|
|
216
|
+
throw new Error(`${effects.length} offchain effects exceed max ${MAX_OFFCHAIN_EFFECTS_PER_TXE_QUERY}`);
|
|
217
|
+
}
|
|
218
|
+
if (effects.some((e)=>e.length > MAX_OFFCHAIN_EFFECT_LEN)) {
|
|
219
|
+
throw new Error(`Some offchain effect has length larger than max ${MAX_OFFCHAIN_EFFECT_LEN}`);
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
effects
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
getLastCallContext() {
|
|
226
|
+
const { txHash, anchorBlockTimestamp } = this.lastCallInfo;
|
|
227
|
+
return {
|
|
228
|
+
txHash,
|
|
229
|
+
anchorBlockTimestamp
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
setTxeOracleVersion(major, minor) {
|
|
233
|
+
if (major !== TXE_ORACLE_VERSION_MAJOR) {
|
|
234
|
+
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.';
|
|
235
|
+
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})`);
|
|
236
|
+
}
|
|
237
|
+
this.txeOracleVersion = {
|
|
238
|
+
major,
|
|
239
|
+
minor
|
|
240
|
+
};
|
|
241
|
+
this.logger.debug(`Test compiled with test oracle version ${major}.${minor}`);
|
|
242
|
+
}
|
|
102
243
|
async enterTopLevelState() {
|
|
103
244
|
switch(this.state.name){
|
|
104
245
|
case 'PRIVATE':
|
|
@@ -125,35 +266,64 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
125
266
|
this.state;
|
|
126
267
|
}
|
|
127
268
|
}
|
|
128
|
-
|
|
269
|
+
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
270
|
+
await this.cycleJob();
|
|
271
|
+
this.oracleHandler = new TXEOracleTopLevelContext(this.stateMachine, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.accountStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, this.nextBlockTimestamp, this.version, this.chainId, this.authwits, this.artifactResolver, this.rootPath, this.packageName);
|
|
129
272
|
this.state = {
|
|
130
273
|
name: 'TOP_LEVEL'
|
|
131
274
|
};
|
|
132
275
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
133
276
|
}
|
|
134
|
-
async enterPrivateState(
|
|
277
|
+
async enterPrivateState(contractAddressOpt, anchorBlockNumberOpt, gasSettings) {
|
|
278
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
279
|
+
const anchorBlockNumber = anchorBlockNumberOpt?.value;
|
|
135
280
|
this.exitTopLevelState();
|
|
136
|
-
|
|
137
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
138
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
139
|
-
// be removed from the database.
|
|
140
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
141
|
-
await this.pxeOracleInterface.syncNoteNullifiers(contractAddress);
|
|
281
|
+
this.resetLastCall();
|
|
142
282
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
143
283
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
144
284
|
// a single transaction with the effects of what was done in the test.
|
|
145
|
-
const anchorBlock = await this.stateMachine.node.
|
|
146
|
-
|
|
285
|
+
const anchorBlock = await this.stateMachine.node.getBlock(anchorBlockNumber ?? 'latest').then((b)=>b?.header);
|
|
286
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
287
|
+
const latestBlock = await this.stateMachine.node.getBlock('latest').then((b)=>b?.header);
|
|
147
288
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
148
|
-
blockNumber: latestBlock.globalVariables.blockNumber + 1,
|
|
289
|
+
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
149
290
|
timestamp: this.nextBlockTimestamp,
|
|
150
291
|
version: this.version,
|
|
151
292
|
chainId: this.chainId
|
|
152
293
|
});
|
|
153
294
|
const txRequestHash = getSingleTxBlockRequestHash(nextBlockGlobalVariables.blockNumber);
|
|
154
|
-
const
|
|
295
|
+
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
296
|
+
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
155
297
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
156
|
-
|
|
298
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
299
|
+
this.oracleHandler = new TXEPrivateExecutionOracle({
|
|
300
|
+
argsHash: Fr.ZERO,
|
|
301
|
+
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
302
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
303
|
+
anchorBlockHeader: anchorBlock,
|
|
304
|
+
utilityExecutor,
|
|
305
|
+
authWitnesses: [],
|
|
306
|
+
capsules: [],
|
|
307
|
+
executionCache: new HashedValuesCache(),
|
|
308
|
+
noteCache,
|
|
309
|
+
taggingIndexCache,
|
|
310
|
+
contractStore: this.contractStore,
|
|
311
|
+
noteStore: this.noteStore,
|
|
312
|
+
keyStore: this.keyStore,
|
|
313
|
+
addressStore: this.addressStore,
|
|
314
|
+
aztecNode: this.stateMachine.node,
|
|
315
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
316
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
317
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
318
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
319
|
+
privateEventStore: this.privateEventStore,
|
|
320
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
321
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
322
|
+
jobId: this.currentJobId,
|
|
323
|
+
scopes: await this.keyStore.getAccounts(),
|
|
324
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
325
|
+
simulator: new WASMSimulator()
|
|
326
|
+
});
|
|
157
327
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
158
328
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
159
329
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -162,43 +332,75 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
162
332
|
this.state = {
|
|
163
333
|
name: 'PRIVATE',
|
|
164
334
|
nextBlockGlobalVariables,
|
|
165
|
-
txRequestHash,
|
|
166
335
|
noteCache,
|
|
167
336
|
taggingIndexCache
|
|
168
337
|
};
|
|
169
338
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
339
|
+
// Record the *resolved* anchor's timestamp — if the caller pinned the anchor to a past block
|
|
340
|
+
// via `anchorBlockNumber`, "latest" would be the wrong anchor for offchain-message semantics.
|
|
341
|
+
this.setLastCallContext(Fr.ZERO, anchorBlock.globalVariables.timestamp);
|
|
170
342
|
return this.oracleHandler.getPrivateContextInputs();
|
|
171
343
|
}
|
|
172
|
-
async enterPublicState(
|
|
344
|
+
async enterPublicState(contractAddressOpt) {
|
|
345
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
173
346
|
this.exitTopLevelState();
|
|
347
|
+
this.resetLastCall();
|
|
174
348
|
// The PublicContext will create a block with a single transaction in it, containing the effects of what was done in
|
|
175
349
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
176
|
-
const
|
|
350
|
+
const latestHeader = (await this.stateMachine.node.getBlockData('latest')).header;
|
|
177
351
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
178
|
-
blockNumber:
|
|
352
|
+
blockNumber: BlockNumber(latestHeader.globalVariables.blockNumber + 1),
|
|
179
353
|
timestamp: this.nextBlockTimestamp,
|
|
180
354
|
version: this.version,
|
|
181
355
|
chainId: this.chainId
|
|
182
356
|
});
|
|
183
|
-
this.oracleHandler = new TXEOraclePublicContext(contractAddress
|
|
357
|
+
this.oracleHandler = new TXEOraclePublicContext(contractAddress, await this.stateMachine.synchronizer.nativeWorldStateService.fork(), getSingleTxBlockRequestHash(globalVariables.blockNumber), globalVariables, this.contractStore);
|
|
184
358
|
this.state = {
|
|
185
359
|
name: 'PUBLIC'
|
|
186
360
|
};
|
|
187
361
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
362
|
+
// Public state is anchored at the latest block.
|
|
363
|
+
this.setLastCallContext(Fr.ZERO, latestHeader.globalVariables.timestamp);
|
|
188
364
|
}
|
|
189
|
-
async enterUtilityState(
|
|
365
|
+
async enterUtilityState(contractAddressOpt) {
|
|
366
|
+
const contractAddress = contractAddressOpt?.value ?? DEFAULT_ADDRESS;
|
|
190
367
|
this.exitTopLevelState();
|
|
368
|
+
this.resetLastCall();
|
|
369
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
191
370
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
192
371
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
193
372
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
194
373
|
// be removed from the database.
|
|
195
374
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
196
|
-
await this.
|
|
197
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
375
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress, await this.keyStore.getAccounts());
|
|
376
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
377
|
+
contractAddress,
|
|
378
|
+
authWitnesses: [],
|
|
379
|
+
capsules: [],
|
|
380
|
+
anchorBlockHeader,
|
|
381
|
+
contractStore: this.contractStore,
|
|
382
|
+
noteStore: this.noteStore,
|
|
383
|
+
keyStore: this.keyStore,
|
|
384
|
+
addressStore: this.addressStore,
|
|
385
|
+
aztecNode: this.stateMachine.node,
|
|
386
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
387
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
388
|
+
capsuleService: new CapsuleService(this.capsuleStore, await this.keyStore.getAccounts()),
|
|
389
|
+
privateEventStore: this.privateEventStore,
|
|
390
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
391
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
392
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
393
|
+
jobId: this.currentJobId,
|
|
394
|
+
scopes: await this.keyStore.getAccounts(),
|
|
395
|
+
simulator: new WASMSimulator(),
|
|
396
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlockHeader)
|
|
397
|
+
});
|
|
198
398
|
this.state = {
|
|
199
399
|
name: 'UTILITY'
|
|
200
400
|
};
|
|
201
401
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
402
|
+
// Utility state anchors at whatever the anchor block store is pointing to (tracked as latest).
|
|
403
|
+
this.setLastCallContext(Fr.ZERO, anchorBlockHeader.globalVariables.timestamp);
|
|
202
404
|
}
|
|
203
405
|
exitTopLevelState() {
|
|
204
406
|
if (this.state.name != 'TOP_LEVEL') {
|
|
@@ -206,8 +408,8 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
206
408
|
}
|
|
207
409
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
208
410
|
// those, the top level context performs a large number of actions not captured in the following 'close' call. Among
|
|
209
|
-
// others, it will create empty blocks (via `
|
|
210
|
-
// `
|
|
411
|
+
// others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
|
|
412
|
+
// `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
|
|
211
413
|
// slight inconsistency in the working model of this class, but is not too bad.
|
|
212
414
|
// TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
|
|
213
415
|
// level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
|
|
@@ -224,13 +426,13 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
224
426
|
});
|
|
225
427
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
226
428
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
227
|
-
const txEffect = await makeTxEffect(this.state.noteCache, this.state.
|
|
429
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
228
430
|
// We build a block holding just this transaction
|
|
229
431
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
230
432
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
231
|
-
const block =
|
|
433
|
+
const block = await makeTXEBlock(forkedWorldTrees, this.state.nextBlockGlobalVariables, [
|
|
232
434
|
txEffect
|
|
233
|
-
])
|
|
435
|
+
]);
|
|
234
436
|
await this.stateMachine.handleL2Block(block);
|
|
235
437
|
await forkedWorldTrees.close();
|
|
236
438
|
this.logger.debug('Exited PublicContext with built block', {
|
|
@@ -250,4 +452,48 @@ const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
250
452
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
251
453
|
}
|
|
252
454
|
}
|
|
455
|
+
utilityExecutorForContractSync(anchorBlock) {
|
|
456
|
+
return async (call, scopes)=>{
|
|
457
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
458
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
459
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
const simulator = new WASMSimulator();
|
|
463
|
+
const oracle = new UtilityExecutionOracle({
|
|
464
|
+
contractAddress: call.to,
|
|
465
|
+
authWitnesses: [],
|
|
466
|
+
capsules: [],
|
|
467
|
+
anchorBlockHeader: anchorBlock,
|
|
468
|
+
contractStore: this.contractStore,
|
|
469
|
+
noteStore: this.noteStore,
|
|
470
|
+
keyStore: this.keyStore,
|
|
471
|
+
addressStore: this.addressStore,
|
|
472
|
+
aztecNode: this.stateMachine.node,
|
|
473
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
474
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
475
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
476
|
+
privateEventStore: this.privateEventStore,
|
|
477
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
478
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
479
|
+
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
480
|
+
jobId: this.currentJobId,
|
|
481
|
+
scopes,
|
|
482
|
+
simulator,
|
|
483
|
+
utilityExecutor: this.utilityExecutorForContractSync(anchorBlock)
|
|
484
|
+
});
|
|
485
|
+
await simulator.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
486
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
487
|
+
throw new ExecutionError(err.message, {
|
|
488
|
+
contractAddress: call.to,
|
|
489
|
+
functionSelector: call.selector
|
|
490
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
491
|
+
cause: err
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
} catch (err) {
|
|
495
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
}
|
|
253
499
|
}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
3
4
|
import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
4
|
-
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
5
|
+
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
5
6
|
/**
|
|
6
7
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
7
8
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
8
9
|
* @returns The transaction request hash.
|
|
9
10
|
*/
|
|
10
|
-
export declare function getSingleTxBlockRequestHash(blockNumber:
|
|
11
|
+
export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
|
|
11
12
|
export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
|
|
12
|
-
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<
|
|
13
|
-
|
|
13
|
+
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an L2Block with proper archive chaining.
|
|
16
|
+
* This function:
|
|
17
|
+
* 1. Gets the current archive state as lastArchive for the header
|
|
18
|
+
* 2. Creates the block header
|
|
19
|
+
* 3. Updates the archive tree with the header hash
|
|
20
|
+
* 4. Gets the new archive state for the block's archive
|
|
21
|
+
*
|
|
22
|
+
* @param worldTrees - The world trees to read/write from
|
|
23
|
+
* @param globalVariables - Global variables for the block
|
|
24
|
+
* @param txEffects - Transaction effects to include in the block
|
|
25
|
+
* @returns The created L2Block with proper archive chaining
|
|
26
|
+
*/
|
|
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":"
|
|
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"}
|