@aztec/txe 0.0.1-commit.f504929 → 0.0.1-commit.f5d02921e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/oracle/txe_oracle_top_level_context.d.ts +4 -3
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +13 -7
- package/dest/rpc_translator.d.ts +24 -19
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +78 -38
- package/dest/state_machine/archiver.d.ts +3 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +7 -8
- package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +5 -2
- package/dest/state_machine/global_variable_builder.d.ts +3 -3
- 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 -3
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +9 -5
- package/dest/state_machine/mock_epoch_cache.d.ts +17 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +32 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +4 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +19 -10
- package/dest/util/encoding.d.ts +69 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +1 -3
- package/package.json +15 -15
- package/src/oracle/txe_oracle_top_level_context.ts +14 -4
- package/src/rpc_translator.ts +108 -48
- package/src/state_machine/archiver.ts +6 -5
- package/src/state_machine/dummy_p2p_client.ts +6 -2
- package/src/state_machine/global_variable_builder.ts +7 -1
- package/src/state_machine/index.ts +9 -1
- package/src/state_machine/mock_epoch_cache.ts +42 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +25 -5
- package/src/util/txe_public_contract_data_source.ts +0 -2
|
@@ -17,7 +17,7 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
17
17
|
private readonly updater = new ArchiverDataStoreUpdater(this.store);
|
|
18
18
|
|
|
19
19
|
constructor(db: AztecAsyncKVStore) {
|
|
20
|
-
const store = new KVArchiverDataStore(db, 9999
|
|
20
|
+
const store = new KVArchiverDataStore(db, 9999);
|
|
21
21
|
super(store);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -76,15 +76,16 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
76
76
|
proven: tipId,
|
|
77
77
|
finalized: tipId,
|
|
78
78
|
checkpointed: tipId,
|
|
79
|
+
proposedCheckpoint: tipId,
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
public
|
|
83
|
-
throw new Error('TXE Archiver does not implement "
|
|
83
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
84
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
public
|
|
87
|
-
throw new Error('TXE Archiver does not implement "
|
|
87
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
88
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
@@ -61,8 +61,12 @@ export class DummyP2P implements P2P {
|
|
|
61
61
|
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
public
|
|
65
|
-
throw new Error('DummyP2P does not implement "
|
|
64
|
+
public registerValidatorCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
65
|
+
throw new Error('DummyP2P does not implement "registerValidatorCheckpointProposalHandler"');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public registerAllNodesCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
69
|
+
throw new Error('DummyP2P does not implement "registerAllNodesCheckpointProposalHandler"');
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
@@ -3,7 +3,12 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
5
5
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type BuildCheckpointGlobalVariablesOpts,
|
|
8
|
+
type CheckpointGlobalVariables,
|
|
9
|
+
type GlobalVariableBuilder,
|
|
10
|
+
GlobalVariables,
|
|
11
|
+
} from '@aztec/stdlib/tx';
|
|
7
12
|
|
|
8
13
|
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
9
14
|
public getCurrentMinFees(): Promise<GasFees> {
|
|
@@ -23,6 +28,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
23
28
|
_coinbase: EthAddress,
|
|
24
29
|
_feeRecipient: AztecAddress,
|
|
25
30
|
_slotNumber: SlotNumber,
|
|
31
|
+
_opts?: BuildCheckpointGlobalVariablesOpts,
|
|
26
32
|
): Promise<CheckpointGlobalVariables> {
|
|
27
33
|
const vars = makeGlobalVariables();
|
|
28
34
|
return Promise.resolve({
|
|
@@ -3,7 +3,9 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
|
3
3
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
6
7
|
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
8
|
+
import { MessageContextService } from '@aztec/pxe/simulator';
|
|
7
9
|
import { L2Block } from '@aztec/stdlib/block';
|
|
8
10
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
11
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,6 +28,7 @@ export class TXEStateMachine {
|
|
|
26
28
|
public archiver: TXEArchiver,
|
|
27
29
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
30
|
public contractSyncService: ContractSyncService,
|
|
31
|
+
public messageContextService: MessageContextService,
|
|
29
32
|
) {}
|
|
30
33
|
|
|
31
34
|
public static async create(
|
|
@@ -33,6 +36,7 @@ export class TXEStateMachine {
|
|
|
33
36
|
anchorBlockStore: AnchorBlockStore,
|
|
34
37
|
contractStore: ContractStore,
|
|
35
38
|
noteStore: NoteStore,
|
|
39
|
+
keyStore: KeyStore,
|
|
36
40
|
) {
|
|
37
41
|
const synchronizer = await TXESynchronizer.create();
|
|
38
42
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
@@ -57,6 +61,7 @@ export class TXEStateMachine {
|
|
|
57
61
|
new MockEpochCache(),
|
|
58
62
|
getPackageVersion() ?? '',
|
|
59
63
|
new TestCircuitVerifier(),
|
|
64
|
+
new TestCircuitVerifier(),
|
|
60
65
|
undefined,
|
|
61
66
|
log,
|
|
62
67
|
);
|
|
@@ -65,10 +70,13 @@ export class TXEStateMachine {
|
|
|
65
70
|
node,
|
|
66
71
|
contractStore,
|
|
67
72
|
noteStore,
|
|
73
|
+
() => keyStore.getAccounts(),
|
|
68
74
|
createLogger('txe:contract_sync'),
|
|
69
75
|
);
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
const messageContextService = new MessageContextService(node);
|
|
78
|
+
|
|
79
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
public async handleL2Block(block: L2Block) {
|
|
@@ -8,7 +8,7 @@ import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/ep
|
|
|
8
8
|
* Since in TXE we don't validate transactions, mock suffices here.
|
|
9
9
|
*/
|
|
10
10
|
export class MockEpochCache implements EpochCacheInterface {
|
|
11
|
-
getCommittee(): Promise<EpochCommitteeInfo> {
|
|
11
|
+
getCommittee(_slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
|
|
12
12
|
return Promise.resolve({
|
|
13
13
|
committee: undefined,
|
|
14
14
|
seed: 0n,
|
|
@@ -17,6 +17,22 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
getSlotNow(): SlotNumber {
|
|
21
|
+
return SlotNumber(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getTargetSlot(): SlotNumber {
|
|
25
|
+
return SlotNumber(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getEpochNow(): EpochNumber {
|
|
29
|
+
return EpochNumber.ZERO;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getTargetEpoch(): EpochNumber {
|
|
33
|
+
return EpochNumber.ZERO;
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
21
37
|
return {
|
|
22
38
|
epoch: EpochNumber.ZERO,
|
|
@@ -26,15 +42,23 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
26
42
|
};
|
|
27
43
|
}
|
|
28
44
|
|
|
29
|
-
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
45
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
30
46
|
return {
|
|
31
47
|
epoch: EpochNumber.ZERO,
|
|
32
48
|
slot: SlotNumber(0),
|
|
33
49
|
ts: 0n,
|
|
34
|
-
|
|
50
|
+
nowSeconds: 0n,
|
|
35
51
|
};
|
|
36
52
|
}
|
|
37
53
|
|
|
54
|
+
getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
55
|
+
return this.getEpochAndSlotInNextL1Slot();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
isProposerPipeliningEnabled(): boolean {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
39
63
|
return '0x00';
|
|
40
64
|
}
|
|
@@ -50,6 +74,13 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
50
74
|
};
|
|
51
75
|
}
|
|
52
76
|
|
|
77
|
+
getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
78
|
+
return {
|
|
79
|
+
targetSlot: SlotNumber(0),
|
|
80
|
+
nextSlot: SlotNumber(0),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
53
84
|
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
54
85
|
return Promise.resolve(undefined);
|
|
55
86
|
}
|
|
@@ -66,6 +97,14 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
66
97
|
return Promise.resolve([]);
|
|
67
98
|
}
|
|
68
99
|
|
|
100
|
+
isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean> {
|
|
101
|
+
return Promise.resolve(false);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
isEscapeHatchOpenAtSlot(_slot: SlotTag): Promise<boolean> {
|
|
105
|
+
return Promise.resolve(false);
|
|
106
|
+
}
|
|
107
|
+
|
|
69
108
|
getL1Constants(): L1RollupConstants {
|
|
70
109
|
return EmptyL1RollupConstants;
|
|
71
110
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
4
|
+
import type { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -33,12 +33,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
36
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
37
37
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
38
|
-
* @param
|
|
38
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
|
|
39
39
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
40
40
|
*/
|
|
41
|
-
public syncImmediate(_minBlockNumber?: BlockNumber,
|
|
41
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber> {
|
|
42
42
|
return Promise.resolve(this.blockNumber);
|
|
43
43
|
}
|
|
44
44
|
|
package/src/txe_session.ts
CHANGED
|
@@ -7,8 +7,10 @@ import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
|
7
7
|
import {
|
|
8
8
|
AddressStore,
|
|
9
9
|
AnchorBlockStore,
|
|
10
|
+
CapsuleService,
|
|
10
11
|
CapsuleStore,
|
|
11
12
|
ContractStore,
|
|
13
|
+
ContractSyncService,
|
|
12
14
|
JobCoordinator,
|
|
13
15
|
NoteService,
|
|
14
16
|
NoteStore,
|
|
@@ -150,6 +152,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
150
152
|
private chainId: Fr,
|
|
151
153
|
private version: Fr,
|
|
152
154
|
private nextBlockTimestamp: bigint,
|
|
155
|
+
private contractSyncService: ContractSyncService,
|
|
153
156
|
) {}
|
|
154
157
|
|
|
155
158
|
static async init(contractStore: ContractStore) {
|
|
@@ -177,7 +180,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
177
180
|
|
|
178
181
|
const archiver = new TXEArchiver(store);
|
|
179
182
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
180
|
-
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore);
|
|
183
|
+
const stateMachine = await TXEStateMachine.create(archiver, anchorBlockStore, contractStore, noteStore, keyStore);
|
|
181
184
|
|
|
182
185
|
const nextBlockTimestamp = BigInt(Math.floor(new Date().getTime() / 1000));
|
|
183
186
|
const version = new Fr(await stateMachine.node.getVersion());
|
|
@@ -185,6 +188,15 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
185
188
|
|
|
186
189
|
const initialJobId = jobCoordinator.beginJob();
|
|
187
190
|
|
|
191
|
+
const logger = createLogger('txe:session');
|
|
192
|
+
const contractSyncService = new ContractSyncService(
|
|
193
|
+
stateMachine.node,
|
|
194
|
+
contractStore,
|
|
195
|
+
noteStore,
|
|
196
|
+
() => keyStore.getAccounts(),
|
|
197
|
+
logger,
|
|
198
|
+
);
|
|
199
|
+
|
|
188
200
|
const topLevelOracleHandler = new TXEOracleTopLevelContext(
|
|
189
201
|
stateMachine,
|
|
190
202
|
contractStore,
|
|
@@ -201,11 +213,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
201
213
|
version,
|
|
202
214
|
chainId,
|
|
203
215
|
new Map(),
|
|
216
|
+
contractSyncService,
|
|
204
217
|
);
|
|
205
218
|
await topLevelOracleHandler.advanceBlocksBy(1);
|
|
206
219
|
|
|
207
220
|
return new TXESession(
|
|
208
|
-
|
|
221
|
+
logger,
|
|
209
222
|
stateMachine,
|
|
210
223
|
topLevelOracleHandler,
|
|
211
224
|
contractStore,
|
|
@@ -223,6 +236,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
223
236
|
version,
|
|
224
237
|
chainId,
|
|
225
238
|
nextBlockTimestamp,
|
|
239
|
+
contractSyncService,
|
|
226
240
|
);
|
|
227
241
|
}
|
|
228
242
|
|
|
@@ -309,6 +323,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
309
323
|
this.version,
|
|
310
324
|
this.chainId,
|
|
311
325
|
this.authwits,
|
|
326
|
+
this.contractSyncService,
|
|
312
327
|
);
|
|
313
328
|
|
|
314
329
|
this.state = { name: 'TOP_LEVEL' };
|
|
@@ -364,11 +379,12 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
364
379
|
senderTaggingStore: this.senderTaggingStore,
|
|
365
380
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
366
381
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
367
|
-
|
|
382
|
+
capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
|
|
368
383
|
privateEventStore: this.privateEventStore,
|
|
369
384
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
370
385
|
jobId: this.currentJobId,
|
|
371
386
|
scopes: 'ALL_SCOPES',
|
|
387
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
372
388
|
});
|
|
373
389
|
|
|
374
390
|
// We store the note and tagging index caches fed into the PrivateExecutionOracle (along with some other auxiliary
|
|
@@ -435,8 +451,10 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
435
451
|
aztecNode: this.stateMachine.node,
|
|
436
452
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
437
453
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
438
|
-
|
|
454
|
+
capsuleService: new CapsuleService(this.capsuleStore, 'ALL_SCOPES'),
|
|
439
455
|
privateEventStore: this.privateEventStore,
|
|
456
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
457
|
+
contractSyncService: this.contractSyncService,
|
|
440
458
|
jobId: this.currentJobId,
|
|
441
459
|
scopes: 'ALL_SCOPES',
|
|
442
460
|
});
|
|
@@ -526,8 +544,10 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
526
544
|
aztecNode: this.stateMachine.node,
|
|
527
545
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
528
546
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
529
|
-
|
|
547
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
530
548
|
privateEventStore: this.privateEventStore,
|
|
549
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
550
|
+
contractSyncService: this.contractSyncService,
|
|
531
551
|
jobId: this.currentJobId,
|
|
532
552
|
scopes,
|
|
533
553
|
});
|
|
@@ -26,8 +26,6 @@ export class TXEPublicContractDataSource implements ContractDataSource {
|
|
|
26
26
|
packedBytecode: contractClass.packedBytecode,
|
|
27
27
|
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
28
28
|
version: contractClass.version,
|
|
29
|
-
privateFunctions: [],
|
|
30
|
-
utilityFunctions: [],
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
|