@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a
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/constants.d.ts +3 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +2 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +88 -54
- package/dest/oracle/interfaces.d.ts +29 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +16 -16
- package/dest/oracle/txe_oracle_top_level_context.d.ts +33 -31
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +179 -92
- package/dest/rpc_translator.d.ts +87 -81
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +291 -173
- package/dest/state_machine/archiver.d.ts +20 -67
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +59 -178
- package/dest/state_machine/dummy_p2p_client.d.ts +20 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +39 -24
- package/dest/state_machine/global_variable_builder.d.ts +2 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +1 -1
- package/dest/state_machine/index.d.ts +6 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +37 -14
- package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +14 -7
- 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 +22 -16
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +153 -56
- package/dest/util/encoding.d.ts +17 -17
- package/dest/util/txe_account_store.d.ts +10 -0
- package/dest/util/txe_account_store.d.ts.map +1 -0
- package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +5 -6
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +12 -29
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +18 -5
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/package.json +16 -16
- package/src/constants.ts +3 -0
- package/src/index.ts +89 -52
- package/src/oracle/interfaces.ts +32 -31
- package/src/oracle/txe_oracle_public_context.ts +16 -18
- package/src/oracle/txe_oracle_top_level_context.ts +217 -133
- package/src/rpc_translator.ts +309 -185
- package/src/state_machine/archiver.ts +54 -220
- package/src/state_machine/dummy_p2p_client.ts +55 -32
- package/src/state_machine/global_variable_builder.ts +1 -1
- package/src/state_machine/index.ts +50 -12
- package/src/state_machine/mock_epoch_cache.ts +15 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +207 -120
- package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
- package/src/util/txe_public_contract_data_source.ts +16 -42
- package/src/utils/block_creation.ts +19 -16
- package/src/utils/tx_effect_creation.ts +3 -11
- 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/src/util/txe_contract_data_provider.ts +0 -36
package/dest/txe_session.js
CHANGED
|
@@ -3,24 +3,25 @@ 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 {
|
|
7
|
-
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
|
-
import {
|
|
6
|
+
import { AddressStore, AnchorBlockStore, CapsuleStore, JobCoordinator, NoteService, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
7
|
+
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
8
|
+
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness } from '@aztec/simulator/client';
|
|
9
|
+
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
9
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
11
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
11
12
|
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
12
13
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
13
14
|
import { CallContext, TxContext } from '@aztec/stdlib/tx';
|
|
14
15
|
import { z } from 'zod';
|
|
16
|
+
import { DEFAULT_ADDRESS } from './constants.js';
|
|
15
17
|
import { TXEOraclePublicContext } from './oracle/txe_oracle_public_context.js';
|
|
16
18
|
import { TXEOracleTopLevelContext } from './oracle/txe_oracle_top_level_context.js';
|
|
17
19
|
import { RPCTranslator } from './rpc_translator.js';
|
|
20
|
+
import { TXEArchiver } from './state_machine/archiver.js';
|
|
18
21
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
19
|
-
import {
|
|
20
|
-
import { TXEContractDataProvider } from './util/txe_contract_data_provider.js';
|
|
22
|
+
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
21
23
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
22
24
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
23
|
-
export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
24
25
|
/**
|
|
25
26
|
* A `TXESession` corresponds to a Noir `#[test]` function, and handles all of its oracle calls, stores test-specific
|
|
26
27
|
* state, etc., independent of all other tests running in parallel.
|
|
@@ -28,33 +29,39 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
28
29
|
logger;
|
|
29
30
|
stateMachine;
|
|
30
31
|
oracleHandler;
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
contractStore;
|
|
33
|
+
noteStore;
|
|
33
34
|
keyStore;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
addressStore;
|
|
36
|
+
accountStore;
|
|
37
|
+
senderTaggingStore;
|
|
38
|
+
recipientTaggingStore;
|
|
39
|
+
senderAddressBookStore;
|
|
40
|
+
capsuleStore;
|
|
41
|
+
privateEventStore;
|
|
42
|
+
jobCoordinator;
|
|
43
|
+
currentJobId;
|
|
40
44
|
chainId;
|
|
41
45
|
version;
|
|
42
46
|
nextBlockTimestamp;
|
|
43
47
|
state;
|
|
44
48
|
authwits;
|
|
45
|
-
constructor(logger, stateMachine, oracleHandler,
|
|
49
|
+
constructor(logger, stateMachine, oracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, currentJobId, chainId, version, nextBlockTimestamp){
|
|
46
50
|
this.logger = logger;
|
|
47
51
|
this.stateMachine = stateMachine;
|
|
48
52
|
this.oracleHandler = oracleHandler;
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
53
|
+
this.contractStore = contractStore;
|
|
54
|
+
this.noteStore = noteStore;
|
|
51
55
|
this.keyStore = keyStore;
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
56
|
+
this.addressStore = addressStore;
|
|
57
|
+
this.accountStore = accountStore;
|
|
58
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
59
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
60
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
61
|
+
this.capsuleStore = capsuleStore;
|
|
62
|
+
this.privateEventStore = privateEventStore;
|
|
63
|
+
this.jobCoordinator = jobCoordinator;
|
|
64
|
+
this.currentJobId = currentJobId;
|
|
58
65
|
this.chainId = chainId;
|
|
59
66
|
this.version = version;
|
|
60
67
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
@@ -63,29 +70,36 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
63
70
|
};
|
|
64
71
|
this.authwits = new Map();
|
|
65
72
|
}
|
|
66
|
-
static async init(
|
|
73
|
+
static async init(contractStore) {
|
|
67
74
|
const store = await openTmpStore('txe-session');
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
+
const addressStore = new AddressStore(store);
|
|
76
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
77
|
+
const noteStore = new NoteStore(store);
|
|
78
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
79
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
80
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
81
|
+
const capsuleStore = new CapsuleStore(store);
|
|
75
82
|
const keyStore = new KeyStore(store);
|
|
76
|
-
const
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
const accountStore = new TXEAccountStore(store);
|
|
84
|
+
// Create job coordinator and register staged stores
|
|
85
|
+
const jobCoordinator = new JobCoordinator(store);
|
|
86
|
+
jobCoordinator.registerStores([
|
|
87
|
+
capsuleStore,
|
|
88
|
+
senderTaggingStore,
|
|
89
|
+
recipientTaggingStore,
|
|
90
|
+
privateEventStore,
|
|
91
|
+
noteStore
|
|
92
|
+
]);
|
|
93
|
+
const archiver = new TXEArchiver(store);
|
|
94
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
95
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
83
96
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
84
97
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
85
98
|
const chainId = new Fr(await stateMachine.node.getChainId());
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
const initialJobId = jobCoordinator.beginJob();
|
|
100
|
+
const topLevelOracleHandler = new TXEOracleTopLevelContext(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, new Map());
|
|
101
|
+
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
102
|
+
return new TXESession(createLogger('txe:session'), stateMachine, topLevelOracleHandler, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, jobCoordinator, initialJobId, version, chainId, nextBlockTimestamp);
|
|
89
103
|
}
|
|
90
104
|
/**
|
|
91
105
|
* Processes an oracle function invoked by the Noir test associated to this session.
|
|
@@ -108,6 +122,14 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
108
122
|
}
|
|
109
123
|
}
|
|
110
124
|
}
|
|
125
|
+
getCurrentJob() {
|
|
126
|
+
return this.currentJobId;
|
|
127
|
+
}
|
|
128
|
+
/** Commits the current job and begins a new one. Returns the new job ID. */ async cycleJob() {
|
|
129
|
+
await this.jobCoordinator.commitJob(this.currentJobId);
|
|
130
|
+
this.currentJobId = this.jobCoordinator.beginJob();
|
|
131
|
+
return this.currentJobId;
|
|
132
|
+
}
|
|
111
133
|
async enterTopLevelState() {
|
|
112
134
|
switch(this.state.name){
|
|
113
135
|
case 'PRIVATE':
|
|
@@ -134,7 +156,9 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
134
156
|
this.state;
|
|
135
157
|
}
|
|
136
158
|
}
|
|
137
|
-
|
|
159
|
+
// Commit all staged stores from the job that was just completed, then begin a new job
|
|
160
|
+
await this.cycleJob();
|
|
161
|
+
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);
|
|
138
162
|
this.state = {
|
|
139
163
|
name: 'TOP_LEVEL'
|
|
140
164
|
};
|
|
@@ -142,16 +166,11 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
142
166
|
}
|
|
143
167
|
async enterPrivateState(contractAddress = DEFAULT_ADDRESS, anchorBlockNumber) {
|
|
144
168
|
this.exitTopLevelState();
|
|
145
|
-
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
146
|
-
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
147
|
-
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
148
|
-
// be removed from the database.
|
|
149
|
-
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
150
|
-
await new NoteService(this.noteDataProvider, this.stateMachine.node, this.stateMachine.anchorBlockDataProvider).syncNoteNullifiers(contractAddress);
|
|
151
169
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
152
170
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
153
171
|
// a single transaction with the effects of what was done in the test.
|
|
154
172
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
173
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock, this.currentJobId).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
|
|
155
174
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
156
175
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
157
176
|
blockNumber: BlockNumber(latestBlock.globalVariables.blockNumber + 1),
|
|
@@ -163,7 +182,32 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
163
182
|
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
164
183
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
165
184
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
166
|
-
|
|
185
|
+
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
186
|
+
this.oracleHandler = new PrivateExecutionOracle({
|
|
187
|
+
argsHash: Fr.ZERO,
|
|
188
|
+
txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
189
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
190
|
+
anchorBlockHeader: anchorBlock,
|
|
191
|
+
utilityExecutor,
|
|
192
|
+
authWitnesses: [],
|
|
193
|
+
capsules: [],
|
|
194
|
+
executionCache: new HashedValuesCache(),
|
|
195
|
+
noteCache,
|
|
196
|
+
taggingIndexCache,
|
|
197
|
+
contractStore: this.contractStore,
|
|
198
|
+
noteStore: this.noteStore,
|
|
199
|
+
keyStore: this.keyStore,
|
|
200
|
+
addressStore: this.addressStore,
|
|
201
|
+
aztecNode: this.stateMachine.node,
|
|
202
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
203
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
204
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
205
|
+
capsuleStore: this.capsuleStore,
|
|
206
|
+
privateEventStore: this.privateEventStore,
|
|
207
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
208
|
+
jobId: this.currentJobId,
|
|
209
|
+
scopes: 'ALL_SCOPES'
|
|
210
|
+
});
|
|
167
211
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
168
212
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
169
213
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
@@ -172,7 +216,6 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
172
216
|
this.state = {
|
|
173
217
|
name: 'PRIVATE',
|
|
174
218
|
nextBlockGlobalVariables,
|
|
175
|
-
protocolNullifier,
|
|
176
219
|
noteCache,
|
|
177
220
|
taggingIndexCache
|
|
178
221
|
};
|
|
@@ -198,14 +241,30 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
198
241
|
}
|
|
199
242
|
async enterUtilityState(contractAddress = DEFAULT_ADDRESS) {
|
|
200
243
|
this.exitTopLevelState();
|
|
244
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
201
245
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
202
246
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
203
247
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
204
248
|
// be removed from the database.
|
|
205
249
|
// TODO(#12553): make the synchronizer sync here instead and remove this
|
|
206
|
-
await new NoteService(this.
|
|
207
|
-
|
|
208
|
-
|
|
250
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlockHeader, this.currentJobId).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
|
|
251
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
252
|
+
contractAddress,
|
|
253
|
+
authWitnesses: [],
|
|
254
|
+
capsules: [],
|
|
255
|
+
anchorBlockHeader,
|
|
256
|
+
contractStore: this.contractStore,
|
|
257
|
+
noteStore: this.noteStore,
|
|
258
|
+
keyStore: this.keyStore,
|
|
259
|
+
addressStore: this.addressStore,
|
|
260
|
+
aztecNode: this.stateMachine.node,
|
|
261
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
262
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
263
|
+
capsuleStore: this.capsuleStore,
|
|
264
|
+
privateEventStore: this.privateEventStore,
|
|
265
|
+
jobId: this.currentJobId,
|
|
266
|
+
scopes: 'ALL_SCOPES'
|
|
267
|
+
});
|
|
209
268
|
this.state = {
|
|
210
269
|
name: 'UTILITY'
|
|
211
270
|
};
|
|
@@ -217,8 +276,8 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
217
276
|
}
|
|
218
277
|
// Note that while all public and private contexts do is build a single block that we then process when exiting
|
|
219
278
|
// those, the top level context performs a large number of actions not captured in the following 'close' call. Among
|
|
220
|
-
// others, it will create empty blocks (via `
|
|
221
|
-
// `
|
|
279
|
+
// others, it will create empty blocks (via `advanceBlocksBy` and `deploy`), create blocks with transactions via
|
|
280
|
+
// `privateCallNewFlow` and `publicCallNewFlow`, add accounts to PXE via `addAccount`, etc. This is a
|
|
222
281
|
// slight inconsistency in the working model of this class, but is not too bad.
|
|
223
282
|
// TODO: it's quite unfortunate that we need to capture the authwits created to later pass them again when the top
|
|
224
283
|
// level context is re-created. This is because authwits create a temporary utility context that'd otherwise reset
|
|
@@ -235,7 +294,7 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
235
294
|
});
|
|
236
295
|
// We rely on the note cache to determine the effects of the transaction. This is incomplete as it doesn't private
|
|
237
296
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
238
|
-
const txEffect = await makeTxEffect(this.state.noteCache, this.state.
|
|
297
|
+
const txEffect = await makeTxEffect(this.state.noteCache, this.state.nextBlockGlobalVariables.blockNumber);
|
|
239
298
|
// We build a block holding just this transaction
|
|
240
299
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
241
300
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
@@ -261,4 +320,42 @@ export const DEFAULT_ADDRESS = AztecAddress.fromNumber(42);
|
|
|
261
320
|
throw new Error(`Expected to be in state 'UTILITY', but got '${this.state.name}' instead`);
|
|
262
321
|
}
|
|
263
322
|
}
|
|
323
|
+
utilityExecutorForContractSync(anchorBlock) {
|
|
324
|
+
return async (call, scopes)=>{
|
|
325
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
326
|
+
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
327
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
const oracle = new UtilityExecutionOracle({
|
|
331
|
+
contractAddress: call.to,
|
|
332
|
+
authWitnesses: [],
|
|
333
|
+
capsules: [],
|
|
334
|
+
anchorBlockHeader: anchorBlock,
|
|
335
|
+
contractStore: this.contractStore,
|
|
336
|
+
noteStore: this.noteStore,
|
|
337
|
+
keyStore: this.keyStore,
|
|
338
|
+
addressStore: this.addressStore,
|
|
339
|
+
aztecNode: this.stateMachine.node,
|
|
340
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
341
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
342
|
+
capsuleStore: this.capsuleStore,
|
|
343
|
+
privateEventStore: this.privateEventStore,
|
|
344
|
+
jobId: this.currentJobId,
|
|
345
|
+
scopes
|
|
346
|
+
});
|
|
347
|
+
await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
348
|
+
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
349
|
+
throw new ExecutionError(err.message, {
|
|
350
|
+
contractAddress: call.to,
|
|
351
|
+
functionSelector: call.selector
|
|
352
|
+
}, extractCallStack(err, entryPointArtifact.debug), {
|
|
353
|
+
cause: err
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
} catch (err) {
|
|
357
|
+
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error contract data sync'));
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
264
361
|
}
|
package/dest/util/encoding.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
|
|
|
150
150
|
error_kind: "custom";
|
|
151
151
|
} & import("@aztec/stdlib/abi").AbiType) | undefined>;
|
|
152
152
|
}>, z.ZodObject<{
|
|
153
|
-
bytecode: import("
|
|
153
|
+
bytecode: import("@aztec/foundation/schemas").ZodFor<Buffer<ArrayBufferLike>>;
|
|
154
154
|
verificationKey: z.ZodOptional<z.ZodString>;
|
|
155
155
|
debugSymbols: z.ZodString;
|
|
156
156
|
debug: z.ZodOptional<z.ZodObject<{
|
|
@@ -656,27 +656,27 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
|
|
|
656
656
|
}>;
|
|
657
657
|
}>, z.ZodIntersection<z.ZodObject<{
|
|
658
658
|
version: z.ZodLiteral<1>;
|
|
659
|
-
salt: import("
|
|
660
|
-
deployer: import("
|
|
661
|
-
currentContractClassId: import("
|
|
662
|
-
originalContractClassId: import("
|
|
663
|
-
initializationHash: import("
|
|
659
|
+
salt: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
660
|
+
deployer: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
|
|
661
|
+
currentContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
662
|
+
originalContractClassId: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
663
|
+
initializationHash: import("@aztec/foundation/schemas").ZodFor<Fr>;
|
|
664
664
|
publicKeys: z.ZodEffects<z.ZodObject<{
|
|
665
|
-
masterNullifierPublicKey: z.ZodType<import("
|
|
666
|
-
masterIncomingViewingPublicKey: z.ZodType<import("
|
|
667
|
-
masterOutgoingViewingPublicKey: z.ZodType<import("
|
|
668
|
-
masterTaggingPublicKey: z.ZodType<import("
|
|
665
|
+
masterNullifierPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
|
|
666
|
+
masterIncomingViewingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
|
|
667
|
+
masterOutgoingViewingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
|
|
668
|
+
masterTaggingPublicKey: z.ZodType<import("@aztec/foundation/schemas").Point, any, string>;
|
|
669
669
|
}, "strip", z.ZodTypeAny, {
|
|
670
|
-
masterNullifierPublicKey: import("
|
|
671
|
-
masterIncomingViewingPublicKey: import("
|
|
672
|
-
masterOutgoingViewingPublicKey: import("
|
|
673
|
-
masterTaggingPublicKey: import("
|
|
670
|
+
masterNullifierPublicKey: import("@aztec/foundation/schemas").Point;
|
|
671
|
+
masterIncomingViewingPublicKey: import("@aztec/foundation/schemas").Point;
|
|
672
|
+
masterOutgoingViewingPublicKey: import("@aztec/foundation/schemas").Point;
|
|
673
|
+
masterTaggingPublicKey: import("@aztec/foundation/schemas").Point;
|
|
674
674
|
}, {
|
|
675
675
|
masterNullifierPublicKey: string;
|
|
676
676
|
masterIncomingViewingPublicKey: string;
|
|
677
677
|
masterOutgoingViewingPublicKey: string;
|
|
678
678
|
masterTaggingPublicKey: string;
|
|
679
|
-
}>, import("
|
|
679
|
+
}>, import("@aztec/stdlib/keys").PublicKeys, {
|
|
680
680
|
masterNullifierPublicKey: string;
|
|
681
681
|
masterIncomingViewingPublicKey: string;
|
|
682
682
|
masterOutgoingViewingPublicKey: string;
|
|
@@ -689,7 +689,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
|
|
|
689
689
|
currentContractClassId: Fr;
|
|
690
690
|
originalContractClassId: Fr;
|
|
691
691
|
initializationHash: Fr;
|
|
692
|
-
publicKeys: import("
|
|
692
|
+
publicKeys: import("@aztec/stdlib/keys").PublicKeys;
|
|
693
693
|
}, {
|
|
694
694
|
version: 1;
|
|
695
695
|
salt?: any;
|
|
@@ -704,7 +704,7 @@ export declare const ForeignCallArgsSchema: z.ZodArray<z.ZodUnion<[z.ZodString,
|
|
|
704
704
|
masterTaggingPublicKey: string;
|
|
705
705
|
};
|
|
706
706
|
}>, z.ZodObject<{
|
|
707
|
-
address: import("
|
|
707
|
+
address: import("@aztec/foundation/schemas").ZodFor<AztecAddress>;
|
|
708
708
|
}, "strip", z.ZodTypeAny, {
|
|
709
709
|
address: AztecAddress;
|
|
710
710
|
}, {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
+
export declare class TXEAccountStore {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(store: AztecAsyncKVStore);
|
|
7
|
+
getAccount(key: AztecAddress): Promise<CompleteAddress>;
|
|
8
|
+
setAccount(key: AztecAddress, value: CompleteAddress): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2FjY291bnRfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3R4ZV9hY2NvdW50X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RCxxQkFBYSxlQUFlOztJQUcxQixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFFbkM7SUFFSyxVQUFVLENBQUMsR0FBRyxFQUFFLFlBQVksNEJBTWpDO0lBRUssVUFBVSxDQUFDLEdBQUcsRUFBRSxZQUFZLEVBQUUsS0FBSyxFQUFFLGVBQWUsaUJBRXpEO0NBQ0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txe_account_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_account_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,eAAe;;IAG1B,YAAY,KAAK,EAAE,iBAAiB,EAEnC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,4BAMjC;IAEK,UAAU,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,iBAEzD;CACF"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
4
|
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
7
|
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
8
|
-
#private;
|
|
9
8
|
private blockNumber;
|
|
10
|
-
private
|
|
11
|
-
constructor(blockNumber: BlockNumber,
|
|
9
|
+
private contractStore;
|
|
10
|
+
constructor(blockNumber: BlockNumber, contractStore: ContractStore);
|
|
12
11
|
getBlockNumber(): Promise<BlockNumber>;
|
|
13
12
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
14
13
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
@@ -18,4 +17,4 @@ export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
18
17
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
19
18
|
registerContractFunctionSignatures(_signatures: []): Promise<void>;
|
|
20
19
|
}
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWwvdHhlX3B1YmxpY19jb250cmFjdF9kYXRhX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDNUUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsa0JBQWtCLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVuSCxxQkFBYSwyQkFBNEIsWUFBVyxrQkFBa0I7SUFFbEUsT0FBTyxDQUFDLFdBQVc7SUFDbkIsT0FBTyxDQUFDLGFBQWE7SUFGdkIsWUFDVSxXQUFXLEVBQUUsV0FBVyxFQUN4QixhQUFhLEVBQUUsYUFBYSxFQUNsQztJQUVKLGNBQWMsSUFBSSxPQUFPLENBQUMsV0FBVyxDQUFDLENBRXJDO0lBRUssZ0JBQWdCLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsbUJBQW1CLEdBQUcsU0FBUyxDQUFDLENBY3ZFO0lBRUsscUJBQXFCLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsRUFBRSxHQUFHLFNBQVMsQ0FBQyxDQUczRDtJQUVLLFdBQVcsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQywyQkFBMkIsR0FBRyxTQUFTLENBQUMsQ0FHekY7SUFFRCxtQkFBbUIsSUFBSSxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FFbkM7SUFFSyxtQkFBbUIsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsR0FBRyxTQUFTLENBQUMsQ0FHdEY7SUFFSyxvQkFBb0IsQ0FBQyxPQUFPLEVBQUUsWUFBWSxFQUFFLFFBQVEsRUFBRSxnQkFBZ0IsR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQUV6RztJQUVELGtDQUFrQyxDQUFDLFdBQVcsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUVqRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAEnH,qBAAa,2BAA4B,YAAW,kBAAkB;IAElE,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IAFvB,YACU,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAClC;IAEJ,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAErC;IAEK,gBAAgB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAcvE;IAEK,qBAAqB,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAG3D;IAEK,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAGzF;IAED,mBAAmB,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC,CAEnC;IAEK,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAGtF;IAEK,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEzG;IAED,kCAAkC,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;CACF"}
|
|
@@ -1,51 +1,34 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { FunctionType } from '@aztec/stdlib/abi';
|
|
3
|
-
import { computePrivateFunctionsRoot, computePublicBytecodeCommitment, getContractClassPrivateFunctionFromArtifact } from '@aztec/stdlib/contract';
|
|
4
1
|
export class TXEPublicContractDataSource {
|
|
5
2
|
blockNumber;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(blockNumber, contractDataProvider){
|
|
3
|
+
contractStore;
|
|
4
|
+
constructor(blockNumber, contractStore){
|
|
9
5
|
this.blockNumber = blockNumber;
|
|
10
|
-
this.
|
|
11
|
-
this.#privateFunctionsRoot = new Map();
|
|
6
|
+
this.contractStore = contractStore;
|
|
12
7
|
}
|
|
13
8
|
getBlockNumber() {
|
|
14
9
|
return Promise.resolve(this.blockNumber);
|
|
15
10
|
}
|
|
16
11
|
async getContractClass(id) {
|
|
17
|
-
const contractClass = await this.
|
|
12
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
18
13
|
if (!contractClass) {
|
|
19
14
|
return;
|
|
20
15
|
}
|
|
21
|
-
const artifact = await this.contractDataProvider.getContractArtifact(id);
|
|
22
|
-
if (!artifact) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
let privateFunctionsRoot;
|
|
26
|
-
if (!this.#privateFunctionsRoot.has(id.toString())) {
|
|
27
|
-
const privateFunctions = await Promise.all(artifact.functions.filter((fn)=>fn.functionType === FunctionType.PRIVATE).map((fn)=>getContractClassPrivateFunctionFromArtifact(fn)));
|
|
28
|
-
privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
29
|
-
this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
|
|
30
|
-
} else {
|
|
31
|
-
privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString()));
|
|
32
|
-
}
|
|
33
16
|
return {
|
|
34
|
-
id,
|
|
17
|
+
id: contractClass.id,
|
|
35
18
|
artifactHash: contractClass.artifactHash,
|
|
36
19
|
packedBytecode: contractClass.packedBytecode,
|
|
37
|
-
privateFunctionsRoot,
|
|
20
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
38
21
|
version: contractClass.version,
|
|
39
22
|
privateFunctions: [],
|
|
40
23
|
utilityFunctions: []
|
|
41
24
|
};
|
|
42
25
|
}
|
|
43
26
|
async getBytecodeCommitment(id) {
|
|
44
|
-
const contractClass = await this.
|
|
45
|
-
return contractClass
|
|
27
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
28
|
+
return contractClass?.publicBytecodeCommitment;
|
|
46
29
|
}
|
|
47
30
|
async getContract(address) {
|
|
48
|
-
const instance = await this.
|
|
31
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
49
32
|
return instance && {
|
|
50
33
|
...instance,
|
|
51
34
|
address
|
|
@@ -55,11 +38,11 @@ export class TXEPublicContractDataSource {
|
|
|
55
38
|
throw new Error('Method not implemented.');
|
|
56
39
|
}
|
|
57
40
|
async getContractArtifact(address) {
|
|
58
|
-
const instance = await this.
|
|
59
|
-
return instance && this.
|
|
41
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
42
|
+
return instance && this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
60
43
|
}
|
|
61
44
|
async getDebugFunctionName(address, selector) {
|
|
62
|
-
return await this.
|
|
45
|
+
return await this.contractStore.getDebugFunctionName(address, selector);
|
|
63
46
|
}
|
|
64
47
|
registerContractFunctionSignatures(_signatures) {
|
|
65
48
|
return Promise.resolve();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { L2Block
|
|
3
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
4
4
|
import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
5
|
-
import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
5
|
+
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
6
6
|
/**
|
|
7
7
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
8
8
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
@@ -10,7 +10,7 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr;
|
|
12
12
|
export declare function insertTxEffectIntoWorldTrees(txEffect: TxEffect, worldTrees: MerkleTreeWriteOperations): Promise<void>;
|
|
13
|
-
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<
|
|
13
|
+
export declare function makeTXEBlockHeader(worldTrees: MerkleTreeWriteOperations, globalVariables: GlobalVariables): Promise<BlockHeader>;
|
|
14
14
|
/**
|
|
15
15
|
* Creates an L2Block with proper archive chaining.
|
|
16
16
|
* This function:
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfY3JlYXRpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9ibG9ja19jcmVhdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxPQUFPLEVBQUUsV0FBVyxFQUEyQyxNQUFNLGlDQUFpQyxDQUFDO0FBRXZHLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQVEsT0FBTyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDcEQsT0FBTyxFQUF3QyxLQUFLLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDM0csT0FBTyxFQUFFLFdBQVcsRUFBRSxlQUFlLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUU7Ozs7R0FJRztBQUNILHdCQUFnQiwyQkFBMkIsQ0FBQyxXQUFXLEVBQUUsV0FBVyxHQUFHLEVBQUUsQ0FFeEU7QUFFRCx3QkFBc0IsNEJBQTRCLENBQ2hELFFBQVEsRUFBRSxRQUFRLEVBQ2xCLFVBQVUsRUFBRSx5QkFBeUIsR0FDcEMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQWtCZjtBQUVELHdCQUFzQixrQkFBa0IsQ0FDdEMsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxlQUFlLEVBQUUsZUFBZSxHQUMvQixPQUFPLENBQUMsV0FBVyxDQUFDLENBWXRCO0FBRUQ7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLFlBQVksQ0FDaEMsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxlQUFlLEVBQUUsZUFBZSxFQUNoQyxTQUFTLEVBQUUsUUFBUSxFQUFFLEdBQ3BCLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FpQmxCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,
|
|
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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { Body, L2Block
|
|
5
|
-
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
5
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
6
6
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
7
8
|
/**
|
|
8
9
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
9
10
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
@@ -20,7 +21,14 @@ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
|
|
|
20
21
|
export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
21
22
|
const stateReference = await worldTrees.getStateReference();
|
|
22
23
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
23
|
-
return
|
|
24
|
+
return BlockHeader.from({
|
|
25
|
+
lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
26
|
+
spongeBlobHash: Fr.ZERO,
|
|
27
|
+
state: stateReference,
|
|
28
|
+
globalVariables,
|
|
29
|
+
totalFees: Fr.ZERO,
|
|
30
|
+
totalManaUsed: Fr.ZERO
|
|
31
|
+
});
|
|
24
32
|
}
|
|
25
33
|
/**
|
|
26
34
|
* Creates an L2Block with proper archive chaining.
|
|
@@ -37,9 +45,14 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
|
37
45
|
*/ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
|
|
38
46
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
39
47
|
// Update the archive tree with this block's header hash
|
|
40
|
-
await worldTrees.updateArchive(header
|
|
48
|
+
await worldTrees.updateArchive(header);
|
|
41
49
|
// Get the new archive state after updating
|
|
42
50
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
43
51
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
44
|
-
|
|
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.
|
|
55
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
56
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
57
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
45
58
|
}
|