@aztec/txe 0.0.1-commit.6d63667d → 0.0.1-commit.7b97ef96e
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/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +82 -50
- package/dest/oracle/interfaces.d.ts +2 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +5 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +80 -28
- package/dest/rpc_translator.d.ts +5 -5
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +5 -5
- package/dest/state_machine/dummy_p2p_client.d.ts +15 -11
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +27 -15
- package/dest/state_machine/index.d.ts +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +1 -1
- package/dest/state_machine/mock_epoch_cache.d.ts +3 -1
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +4 -0
- package/dest/txe_session.d.ts +4 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +63 -14
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +5 -22
- package/package.json +15 -15
- package/src/index.ts +83 -49
- package/src/oracle/interfaces.ts +1 -1
- package/src/oracle/txe_oracle_top_level_context.ts +74 -81
- package/src/rpc_translator.ts +5 -5
- package/src/state_machine/dummy_p2p_client.ts +39 -21
- package/src/state_machine/index.ts +1 -0
- package/src/state_machine/mock_epoch_cache.ts +5 -0
- package/src/txe_session.ts +61 -64
- package/src/util/txe_public_contract_data_source.ts +10 -36
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
P2PBlockReceivedCallback,
|
|
7
7
|
P2PCheckpointReceivedCallback,
|
|
8
8
|
P2PConfig,
|
|
9
|
+
P2PDuplicateAttestationCallback,
|
|
10
|
+
P2PDuplicateProposalCallback,
|
|
9
11
|
P2PSyncState,
|
|
10
12
|
PeerId,
|
|
11
13
|
ReqRespSubProtocol,
|
|
@@ -14,9 +16,9 @@ import type {
|
|
|
14
16
|
StatusMessage,
|
|
15
17
|
} from '@aztec/p2p';
|
|
16
18
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
17
|
-
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
18
|
-
import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
19
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
19
|
+
import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
21
|
+
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
20
22
|
|
|
21
23
|
export class DummyP2P implements P2P {
|
|
22
24
|
public validate(_txs: Tx[]): Promise<void> {
|
|
@@ -39,6 +41,10 @@ export class DummyP2P implements P2P {
|
|
|
39
41
|
throw new Error('DummyP2P does not implement "getPeers"');
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
|
|
45
|
+
return Promise.resolve(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
public broadcastProposal(_proposal: BlockProposal): Promise<void> {
|
|
43
49
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
44
50
|
}
|
|
@@ -71,8 +77,8 @@ export class DummyP2P implements P2P {
|
|
|
71
77
|
throw new Error('DummyP2P does not implement "sendTx"');
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
public
|
|
75
|
-
throw new Error('DummyP2P does not implement "
|
|
80
|
+
public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
|
|
81
|
+
throw new Error('DummyP2P does not implement "handleFailedExecution"');
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
|
|
@@ -97,6 +103,10 @@ export class DummyP2P implements P2P {
|
|
|
97
103
|
throw new Error('DummyP2P does not implement "iteratePendingTxs"');
|
|
98
104
|
}
|
|
99
105
|
|
|
106
|
+
public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
|
|
107
|
+
throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
|
|
108
|
+
}
|
|
109
|
+
|
|
100
110
|
public getPendingTxCount(): Promise<number> {
|
|
101
111
|
throw new Error('DummyP2P does not implement "getPendingTxCount"');
|
|
102
112
|
}
|
|
@@ -125,6 +135,10 @@ export class DummyP2P implements P2P {
|
|
|
125
135
|
throw new Error('DummyP2P does not implement "isP2PClient"');
|
|
126
136
|
}
|
|
127
137
|
|
|
138
|
+
public getTxProvider(): ITxProvider {
|
|
139
|
+
throw new Error('DummyP2P does not implement "getTxProvider"');
|
|
140
|
+
}
|
|
141
|
+
|
|
128
142
|
public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
129
143
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
130
144
|
}
|
|
@@ -133,8 +147,8 @@ export class DummyP2P implements P2P {
|
|
|
133
147
|
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
134
148
|
}
|
|
135
149
|
|
|
136
|
-
public
|
|
137
|
-
throw new Error('DummyP2P does not implement "
|
|
150
|
+
public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
151
|
+
throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
|
|
138
152
|
}
|
|
139
153
|
|
|
140
154
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -157,14 +171,6 @@ export class DummyP2P implements P2P {
|
|
|
157
171
|
throw new Error('DummyP2P does not implement "sync"');
|
|
158
172
|
}
|
|
159
173
|
|
|
160
|
-
public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
161
|
-
throw new Error('DummyP2P does not implement "requestTxsByHash"');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
|
|
165
|
-
throw new Error('DummyP2P does not implement "getTxs"');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
174
|
public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
169
175
|
throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
|
|
170
176
|
}
|
|
@@ -173,10 +179,6 @@ export class DummyP2P implements P2P {
|
|
|
173
179
|
throw new Error('DummyP2P does not implement "hasTxsInPool"');
|
|
174
180
|
}
|
|
175
181
|
|
|
176
|
-
public addTxsToPool(_txs: Tx[]): Promise<number> {
|
|
177
|
-
throw new Error('DummyP2P does not implement "addTxs"');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
182
|
public getSyncedLatestBlockNum(): Promise<number> {
|
|
181
183
|
throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
|
|
182
184
|
}
|
|
@@ -189,8 +191,12 @@ export class DummyP2P implements P2P {
|
|
|
189
191
|
throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
|
|
190
192
|
}
|
|
191
193
|
|
|
192
|
-
|
|
193
|
-
throw new Error('DummyP2P does not implement "
|
|
194
|
+
protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
|
|
195
|
+
throw new Error('DummyP2P does not implement "protectTxs".');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
|
|
199
|
+
return Promise.resolve();
|
|
194
200
|
}
|
|
195
201
|
|
|
196
202
|
addReqRespSubProtocol(
|
|
@@ -206,4 +212,16 @@ export class DummyP2P implements P2P {
|
|
|
206
212
|
|
|
207
213
|
//This is no-op
|
|
208
214
|
public registerThisValidatorAddresses(_address: EthAddress[]): void {}
|
|
215
|
+
|
|
216
|
+
public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
|
|
217
|
+
throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
|
|
221
|
+
throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
|
|
225
|
+
throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
|
|
226
|
+
}
|
|
209
227
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
2
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
|
|
@@ -64,4 +65,8 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
64
65
|
filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
|
|
65
66
|
return Promise.resolve([]);
|
|
66
67
|
}
|
|
68
|
+
|
|
69
|
+
getL1Constants(): L1RollupConstants {
|
|
70
|
+
return EmptyL1RollupConstants;
|
|
71
|
+
}
|
|
67
72
|
}
|
package/src/txe_session.ts
CHANGED
|
@@ -3,11 +3,12 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, 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 type {
|
|
6
|
+
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
7
7
|
import {
|
|
8
8
|
AddressStore,
|
|
9
9
|
AnchorBlockStore,
|
|
10
10
|
CapsuleStore,
|
|
11
|
+
ContractStore,
|
|
11
12
|
JobCoordinator,
|
|
12
13
|
NoteService,
|
|
13
14
|
NoteStore,
|
|
@@ -54,7 +55,6 @@ import { TXEArchiver } from './state_machine/archiver.js';
|
|
|
54
55
|
import { TXEStateMachine } from './state_machine/index.js';
|
|
55
56
|
import type { ForeignCallArgs, ForeignCallResult } from './util/encoding.js';
|
|
56
57
|
import { TXEAccountStore } from './util/txe_account_store.js';
|
|
57
|
-
import { TXEContractStore } from './util/txe_contract_store.js';
|
|
58
58
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from './utils/block_creation.js';
|
|
59
59
|
import { makeTxEffect } from './utils/tx_effect_creation.js';
|
|
60
60
|
|
|
@@ -131,7 +131,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
131
131
|
| IPrivateExecutionOracle
|
|
132
132
|
| IAvmExecutionOracle
|
|
133
133
|
| ITxeExecutionOracle,
|
|
134
|
-
private contractStore:
|
|
134
|
+
private contractStore: ContractStore,
|
|
135
135
|
private noteStore: NoteStore,
|
|
136
136
|
private keyStore: KeyStore,
|
|
137
137
|
private addressStore: AddressStore,
|
|
@@ -148,12 +148,11 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
148
148
|
private nextBlockTimestamp: bigint,
|
|
149
149
|
) {}
|
|
150
150
|
|
|
151
|
-
static async init(
|
|
151
|
+
static async init(contractStore: ContractStore) {
|
|
152
152
|
const store = await openTmpStore('txe-session');
|
|
153
153
|
|
|
154
154
|
const addressStore = new AddressStore(store);
|
|
155
155
|
const privateEventStore = new PrivateEventStore(store);
|
|
156
|
-
const contractStore = new TXEContractStore(store);
|
|
157
156
|
const noteStore = new NoteStore(store);
|
|
158
157
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
159
158
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
@@ -172,12 +171,6 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
172
171
|
noteStore,
|
|
173
172
|
]);
|
|
174
173
|
|
|
175
|
-
// Register protocol contracts.
|
|
176
|
-
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
177
|
-
await contractStore.addContractArtifact(contractClass.id, artifact);
|
|
178
|
-
await contractStore.addContractInstance(instance);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
174
|
const archiver = new TXEArchiver(store);
|
|
182
175
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
183
176
|
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
@@ -323,6 +316,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
323
316
|
|
|
324
317
|
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
325
318
|
contractAddress,
|
|
319
|
+
'ALL_SCOPES',
|
|
326
320
|
);
|
|
327
321
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
328
322
|
|
|
@@ -339,30 +333,31 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
339
333
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
340
334
|
|
|
341
335
|
const utilityExecutor = this.utilityExecutorForContractSync(anchorBlock);
|
|
342
|
-
this.oracleHandler = new PrivateExecutionOracle(
|
|
343
|
-
Fr.ZERO,
|
|
344
|
-
new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
345
|
-
new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
346
|
-
anchorBlock!,
|
|
336
|
+
this.oracleHandler = new PrivateExecutionOracle({
|
|
337
|
+
argsHash: Fr.ZERO,
|
|
338
|
+
txContext: new TxContext(this.chainId, this.version, GasSettings.empty()),
|
|
339
|
+
callContext: new CallContext(AztecAddress.ZERO, contractAddress, FunctionSelector.empty(), false),
|
|
340
|
+
anchorBlockHeader: anchorBlock!,
|
|
347
341
|
utilityExecutor,
|
|
348
|
-
[],
|
|
349
|
-
[],
|
|
350
|
-
new HashedValuesCache(),
|
|
342
|
+
authWitnesses: [],
|
|
343
|
+
capsules: [],
|
|
344
|
+
executionCache: new HashedValuesCache(),
|
|
351
345
|
noteCache,
|
|
352
346
|
taggingIndexCache,
|
|
353
|
-
this.contractStore,
|
|
354
|
-
this.noteStore,
|
|
355
|
-
this.keyStore,
|
|
356
|
-
this.addressStore,
|
|
357
|
-
this.stateMachine.node,
|
|
358
|
-
this.senderTaggingStore,
|
|
359
|
-
this.recipientTaggingStore,
|
|
360
|
-
this.senderAddressBookStore,
|
|
361
|
-
this.capsuleStore,
|
|
362
|
-
this.privateEventStore,
|
|
363
|
-
this.stateMachine.contractSyncService,
|
|
364
|
-
this.currentJobId,
|
|
365
|
-
|
|
347
|
+
contractStore: this.contractStore,
|
|
348
|
+
noteStore: this.noteStore,
|
|
349
|
+
keyStore: this.keyStore,
|
|
350
|
+
addressStore: this.addressStore,
|
|
351
|
+
aztecNode: this.stateMachine.node,
|
|
352
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
353
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
354
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
355
|
+
capsuleStore: this.capsuleStore,
|
|
356
|
+
privateEventStore: this.privateEventStore,
|
|
357
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
358
|
+
jobId: this.currentJobId,
|
|
359
|
+
scopes: 'ALL_SCOPES',
|
|
360
|
+
});
|
|
366
361
|
|
|
367
362
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
368
363
|
// data) in order to refer to it later, mimicking the way this object is used by the ContractFunctionSimulator. The
|
|
@@ -414,24 +409,25 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
414
409
|
this.stateMachine.node,
|
|
415
410
|
anchorBlockHeader,
|
|
416
411
|
this.currentJobId,
|
|
417
|
-
).syncNoteNullifiers(contractAddress);
|
|
412
|
+
).syncNoteNullifiers(contractAddress, 'ALL_SCOPES');
|
|
418
413
|
|
|
419
|
-
this.oracleHandler = new UtilityExecutionOracle(
|
|
414
|
+
this.oracleHandler = new UtilityExecutionOracle({
|
|
420
415
|
contractAddress,
|
|
421
|
-
[],
|
|
422
|
-
[],
|
|
416
|
+
authWitnesses: [],
|
|
417
|
+
capsules: [],
|
|
423
418
|
anchorBlockHeader,
|
|
424
|
-
this.contractStore,
|
|
425
|
-
this.noteStore,
|
|
426
|
-
this.keyStore,
|
|
427
|
-
this.addressStore,
|
|
428
|
-
this.stateMachine.node,
|
|
429
|
-
this.recipientTaggingStore,
|
|
430
|
-
this.senderAddressBookStore,
|
|
431
|
-
this.capsuleStore,
|
|
432
|
-
this.privateEventStore,
|
|
433
|
-
this.currentJobId,
|
|
434
|
-
|
|
419
|
+
contractStore: this.contractStore,
|
|
420
|
+
noteStore: this.noteStore,
|
|
421
|
+
keyStore: this.keyStore,
|
|
422
|
+
addressStore: this.addressStore,
|
|
423
|
+
aztecNode: this.stateMachine.node,
|
|
424
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
425
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
426
|
+
capsuleStore: this.capsuleStore,
|
|
427
|
+
privateEventStore: this.privateEventStore,
|
|
428
|
+
jobId: this.currentJobId,
|
|
429
|
+
scopes: 'ALL_SCOPES',
|
|
430
|
+
});
|
|
435
431
|
|
|
436
432
|
this.state = { name: 'UTILITY' };
|
|
437
433
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
@@ -499,29 +495,30 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
499
495
|
}
|
|
500
496
|
|
|
501
497
|
private utilityExecutorForContractSync(anchorBlock: any) {
|
|
502
|
-
return async (call: FunctionCall) => {
|
|
498
|
+
return async (call: FunctionCall, scopes: AccessScopes) => {
|
|
503
499
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
504
500
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
505
501
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
506
502
|
}
|
|
507
503
|
|
|
508
504
|
try {
|
|
509
|
-
const oracle = new UtilityExecutionOracle(
|
|
510
|
-
call.to,
|
|
511
|
-
[],
|
|
512
|
-
[],
|
|
513
|
-
anchorBlock!,
|
|
514
|
-
this.contractStore,
|
|
515
|
-
this.noteStore,
|
|
516
|
-
this.keyStore,
|
|
517
|
-
this.addressStore,
|
|
518
|
-
this.stateMachine.node,
|
|
519
|
-
this.recipientTaggingStore,
|
|
520
|
-
this.senderAddressBookStore,
|
|
521
|
-
this.capsuleStore,
|
|
522
|
-
this.privateEventStore,
|
|
523
|
-
this.currentJobId,
|
|
524
|
-
|
|
505
|
+
const oracle = new UtilityExecutionOracle({
|
|
506
|
+
contractAddress: call.to,
|
|
507
|
+
authWitnesses: [],
|
|
508
|
+
capsules: [],
|
|
509
|
+
anchorBlockHeader: anchorBlock!,
|
|
510
|
+
contractStore: this.contractStore,
|
|
511
|
+
noteStore: this.noteStore,
|
|
512
|
+
keyStore: this.keyStore,
|
|
513
|
+
addressStore: this.addressStore,
|
|
514
|
+
aztecNode: this.stateMachine.node,
|
|
515
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
516
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
517
|
+
capsuleStore: this.capsuleStore,
|
|
518
|
+
privateEventStore: this.privateEventStore,
|
|
519
|
+
jobId: this.currentJobId,
|
|
520
|
+
scopes,
|
|
521
|
+
});
|
|
525
522
|
await new WASMSimulator()
|
|
526
523
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
527
524
|
.catch((err: Error) => {
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ContractStore } from '@aztec/pxe/server';
|
|
4
|
-
import { type ContractArtifact, FunctionSelector
|
|
4
|
+
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import {
|
|
7
|
-
type ContractClassPublic,
|
|
8
|
-
type ContractDataSource,
|
|
9
|
-
type ContractInstanceWithAddress,
|
|
10
|
-
computePrivateFunctionsRoot,
|
|
11
|
-
computePublicBytecodeCommitment,
|
|
12
|
-
getContractClassPrivateFunctionFromArtifact,
|
|
13
|
-
} from '@aztec/stdlib/contract';
|
|
6
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
14
7
|
|
|
15
8
|
export class TXEPublicContractDataSource implements ContractDataSource {
|
|
16
|
-
#privateFunctionsRoot: Map<string, Buffer> = new Map();
|
|
17
9
|
constructor(
|
|
18
10
|
private blockNumber: BlockNumber,
|
|
19
11
|
private contractStore: ContractStore,
|
|
@@ -24,42 +16,24 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
24
16
|
}
|
|
25
17
|
|
|
26
18
|
async getContractClass(id: Fr): Promise<ContractClassPublic | undefined> {
|
|
27
|
-
const contractClass = await this.contractStore.
|
|
19
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
28
20
|
if (!contractClass) {
|
|
29
21
|
return;
|
|
30
22
|
}
|
|
31
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
32
|
-
if (!artifact) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let privateFunctionsRoot;
|
|
37
|
-
if (!this.#privateFunctionsRoot.has(id.toString())) {
|
|
38
|
-
const privateFunctions = await Promise.all(
|
|
39
|
-
artifact.functions
|
|
40
|
-
.filter(fn => fn.functionType === FunctionType.PRIVATE)
|
|
41
|
-
.map(fn => getContractClassPrivateFunctionFromArtifact(fn)),
|
|
42
|
-
);
|
|
43
|
-
privateFunctionsRoot = await computePrivateFunctionsRoot(privateFunctions);
|
|
44
|
-
this.#privateFunctionsRoot.set(id.toString(), privateFunctionsRoot.toBuffer());
|
|
45
|
-
} else {
|
|
46
|
-
privateFunctionsRoot = Fr.fromBuffer(this.#privateFunctionsRoot.get(id.toString())!);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
23
|
return {
|
|
50
|
-
id,
|
|
51
|
-
artifactHash: contractClass
|
|
52
|
-
packedBytecode: contractClass
|
|
53
|
-
privateFunctionsRoot,
|
|
54
|
-
version: contractClass
|
|
24
|
+
id: contractClass.id,
|
|
25
|
+
artifactHash: contractClass.artifactHash,
|
|
26
|
+
packedBytecode: contractClass.packedBytecode,
|
|
27
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
28
|
+
version: contractClass.version,
|
|
55
29
|
privateFunctions: [],
|
|
56
30
|
utilityFunctions: [],
|
|
57
31
|
};
|
|
58
32
|
}
|
|
59
33
|
|
|
60
34
|
async getBytecodeCommitment(id: Fr): Promise<Fr | undefined> {
|
|
61
|
-
const contractClass = await this.contractStore.
|
|
62
|
-
return contractClass
|
|
35
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(id);
|
|
36
|
+
return contractClass?.publicBytecodeCommitment;
|
|
63
37
|
}
|
|
64
38
|
|
|
65
39
|
async getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { ContractStore } from '@aztec/pxe/server';
|
|
4
|
-
export type ContractArtifactWithHash = ContractArtifact & {
|
|
5
|
-
artifactHash: Fr;
|
|
6
|
-
};
|
|
7
|
-
export declare class TXEContractStore extends ContractStore {
|
|
8
|
-
#private;
|
|
9
|
-
addContractArtifact(id: Fr, artifact: ContractArtifact | ContractArtifactWithHash): Promise<void>;
|
|
10
|
-
getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | ContractArtifactWithHash | undefined>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX2NvbnRyYWN0X3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbC90eGVfY29udHJhY3Rfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUM1RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDNUMsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWxELE1BQU0sTUFBTSx3QkFBd0IsR0FBRyxnQkFBZ0IsR0FBRztJQUFFLFlBQVksRUFBRSxFQUFFLENBQUE7Q0FBRSxDQUFDO0FBTy9FLHFCQUFhLGdCQUFpQixTQUFRLGFBQWE7O0lBRzNCLG1CQUFtQixDQUN2QyxFQUFFLEVBQUUsRUFBRSxFQUNOLFFBQVEsRUFBRSxnQkFBZ0IsR0FBRyx3QkFBd0IsR0FDcEQsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUtmO0lBRXFCLG1CQUFtQixDQUN2QyxlQUFlLEVBQUUsRUFBRSxHQUNsQixPQUFPLENBQUMsZ0JBQWdCLEdBQUcsd0JBQXdCLEdBQUcsU0FBUyxDQUFDLENBUWxFO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"txe_contract_store.d.ts","sourceRoot":"","sources":["../../src/util/txe_contract_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GAAG;IAAE,YAAY,EAAE,EAAE,CAAA;CAAE,CAAC;AAO/E,qBAAa,gBAAiB,SAAQ,aAAa;;IAG3B,mBAAmB,CACvC,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,gBAAgB,GAAG,wBAAwB,GACpD,OAAO,CAAC,IAAI,CAAC,CAKf;IAEqB,mBAAmB,CACvC,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,gBAAgB,GAAG,wBAAwB,GAAG,SAAS,CAAC,CAQlE;CACF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
-
import { ContractStore } from '@aztec/pxe/server';
|
|
3
|
-
/*
|
|
4
|
-
* A contract store that stores contract artifacts with their hashes. Since
|
|
5
|
-
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
6
|
-
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
7
|
-
*/ export class TXEContractStore extends ContractStore {
|
|
8
|
-
#artifactHashes = new Map();
|
|
9
|
-
async addContractArtifact(id, artifact) {
|
|
10
|
-
if ('artifactHash' in artifact) {
|
|
11
|
-
this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
|
|
12
|
-
}
|
|
13
|
-
await super.addContractArtifact(id, artifact);
|
|
14
|
-
}
|
|
15
|
-
async getContractArtifact(contractClassId) {
|
|
16
|
-
const artifact = await super.getContractArtifact(contractClassId);
|
|
17
|
-
if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
|
|
18
|
-
artifact.artifactHash = Fr.fromBuffer(this.#artifactHashes.get(contractClassId.toString()));
|
|
19
|
-
}
|
|
20
|
-
return artifact;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { ContractStore } from '@aztec/pxe/server';
|
|
4
|
-
|
|
5
|
-
export type ContractArtifactWithHash = ContractArtifact & { artifactHash: Fr };
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* A contract store that stores contract artifacts with their hashes. Since
|
|
9
|
-
* TXE typically deploys the same contract again and again for multiple tests, caching
|
|
10
|
-
* the *very* expensive artifact hash computation improves testing speed significantly.
|
|
11
|
-
*/
|
|
12
|
-
export class TXEContractStore extends ContractStore {
|
|
13
|
-
#artifactHashes: Map<string, Buffer> = new Map();
|
|
14
|
-
|
|
15
|
-
public override async addContractArtifact(
|
|
16
|
-
id: Fr,
|
|
17
|
-
artifact: ContractArtifact | ContractArtifactWithHash,
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
if ('artifactHash' in artifact) {
|
|
20
|
-
this.#artifactHashes.set(id.toString(), artifact.artifactHash.toBuffer());
|
|
21
|
-
}
|
|
22
|
-
await super.addContractArtifact(id, artifact);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public override async getContractArtifact(
|
|
26
|
-
contractClassId: Fr,
|
|
27
|
-
): Promise<ContractArtifact | ContractArtifactWithHash | undefined> {
|
|
28
|
-
const artifact = await super.getContractArtifact(contractClassId);
|
|
29
|
-
if (artifact && this.#artifactHashes.has(contractClassId.toString())) {
|
|
30
|
-
(artifact as ContractArtifactWithHash).artifactHash = Fr.fromBuffer(
|
|
31
|
-
this.#artifactHashes.get(contractClassId.toString())!,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return artifact;
|
|
35
|
-
}
|
|
36
|
-
}
|