@aztec/txe 0.0.1-commit.c80b6263 → 0.0.1-commit.c949de6bc
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 +4 -3
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +7 -8
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +99 -30
- package/dest/rpc_translator.d.ts +8 -8
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +53 -29
- package/dest/state_machine/archiver.d.ts +1 -1
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +2 -0
- package/dest/state_machine/dummy_p2p_client.d.ts +16 -12
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +28 -16
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +15 -10
- 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 +9 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +80 -21
- 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/dest/utils/block_creation.d.ts +1 -1
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +3 -1
- package/package.json +15 -15
- package/src/index.ts +83 -49
- package/src/oracle/interfaces.ts +6 -1
- package/src/oracle/txe_oracle_top_level_context.ts +111 -77
- package/src/rpc_translator.ts +57 -23
- package/src/state_machine/archiver.ts +2 -0
- package/src/state_machine/dummy_p2p_client.ts +40 -22
- package/src/state_machine/index.ts +25 -9
- package/src/state_machine/mock_epoch_cache.ts +5 -0
- package/src/txe_session.ts +89 -81
- package/src/util/txe_public_contract_data_source.ts +10 -36
- package/src/utils/block_creation.ts +3 -1
- 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
package/src/rpc_translator.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
toSingle,
|
|
31
31
|
} from './util/encoding.js';
|
|
32
32
|
|
|
33
|
-
const MAX_EVENT_LEN =
|
|
33
|
+
const MAX_EVENT_LEN = 10; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN
|
|
34
34
|
const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
|
|
35
35
|
|
|
36
36
|
export class UnavailableOracleError extends Error {
|
|
@@ -285,6 +285,13 @@ export class RPCTranslator {
|
|
|
285
285
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
286
286
|
const scope = addressFromSingle(foreignScope);
|
|
287
287
|
|
|
288
|
+
// TODO(F-335): Avoid doing the following 2 calls here.
|
|
289
|
+
{
|
|
290
|
+
await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
|
|
291
|
+
// We cycle job to commit the stores after the contract sync.
|
|
292
|
+
await this.stateHandler.cycleJob();
|
|
293
|
+
}
|
|
294
|
+
|
|
288
295
|
const events = await this.handlerAsTxe().txeGetPrivateEvents(selector, contractAddress, scope);
|
|
289
296
|
|
|
290
297
|
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
@@ -328,7 +335,7 @@ export class RPCTranslator {
|
|
|
328
335
|
|
|
329
336
|
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
330
337
|
// When the argument is an array, we add the field length manually to the signature.
|
|
331
|
-
|
|
338
|
+
async utilityLog(
|
|
332
339
|
foreignLevel: ForeignCallSingle,
|
|
333
340
|
foreignMessage: ForeignCallArray,
|
|
334
341
|
_foreignLength: ForeignCallSingle,
|
|
@@ -340,7 +347,7 @@ export class RPCTranslator {
|
|
|
340
347
|
.join('');
|
|
341
348
|
const fields = fromArray(foreignFields);
|
|
342
349
|
|
|
343
|
-
this.handlerAsMisc().
|
|
350
|
+
await this.handlerAsMisc().utilityLog(level, message, fields);
|
|
344
351
|
|
|
345
352
|
return toForeignCallResult([]);
|
|
346
353
|
}
|
|
@@ -351,7 +358,7 @@ export class RPCTranslator {
|
|
|
351
358
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
352
359
|
foreignNumberOfElements: ForeignCallSingle,
|
|
353
360
|
) {
|
|
354
|
-
const blockHash = BlockHash
|
|
361
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
355
362
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
356
363
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
357
364
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
@@ -367,7 +374,7 @@ export class RPCTranslator {
|
|
|
367
374
|
}
|
|
368
375
|
|
|
369
376
|
async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
370
|
-
const blockHash = BlockHash
|
|
377
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
371
378
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
372
379
|
|
|
373
380
|
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
|
|
@@ -545,12 +552,23 @@ export class RPCTranslator {
|
|
|
545
552
|
);
|
|
546
553
|
}
|
|
547
554
|
|
|
548
|
-
async
|
|
555
|
+
async utilityTryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
549
556
|
const address = addressFromSingle(foreignAddress);
|
|
550
557
|
|
|
551
|
-
const
|
|
558
|
+
const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(address);
|
|
552
559
|
|
|
553
|
-
return
|
|
560
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
561
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
562
|
+
if (result === undefined) {
|
|
563
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
564
|
+
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
|
|
565
|
+
} else {
|
|
566
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
567
|
+
return toForeignCallResult([
|
|
568
|
+
toSingle(new Fr(1)),
|
|
569
|
+
toArray([...result.publicKeys.toFields(), result.partialAddress]),
|
|
570
|
+
]);
|
|
571
|
+
}
|
|
554
572
|
}
|
|
555
573
|
|
|
556
574
|
async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
|
|
@@ -574,7 +592,7 @@ export class RPCTranslator {
|
|
|
574
592
|
}
|
|
575
593
|
|
|
576
594
|
async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
|
|
577
|
-
const blockHash = BlockHash
|
|
595
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
578
596
|
const nullifier = fromSingle(foreignNullifier);
|
|
579
597
|
|
|
580
598
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -641,26 +659,34 @@ export class RPCTranslator {
|
|
|
641
659
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
642
660
|
}
|
|
643
661
|
|
|
644
|
-
async utilityGetNoteHashMembershipWitness(
|
|
645
|
-
|
|
646
|
-
|
|
662
|
+
async utilityGetNoteHashMembershipWitness(
|
|
663
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
664
|
+
foreignNoteHash: ForeignCallSingle,
|
|
665
|
+
) {
|
|
666
|
+
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
667
|
+
const noteHash = fromSingle(foreignNoteHash);
|
|
647
668
|
|
|
648
|
-
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash,
|
|
669
|
+
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
|
|
649
670
|
|
|
650
671
|
if (!witness) {
|
|
651
|
-
throw new Error(`Note hash ${
|
|
672
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
652
673
|
}
|
|
653
674
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
654
675
|
}
|
|
655
676
|
|
|
656
|
-
async
|
|
657
|
-
|
|
658
|
-
|
|
677
|
+
async utilityGetBlockHashMembershipWitness(
|
|
678
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
679
|
+
foreignBlockHash: ForeignCallSingle,
|
|
680
|
+
) {
|
|
681
|
+
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
682
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
659
683
|
|
|
660
|
-
const witness = await this.handlerAsUtility().
|
|
684
|
+
const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
661
685
|
|
|
662
686
|
if (!witness) {
|
|
663
|
-
throw new Error(
|
|
687
|
+
throw new Error(
|
|
688
|
+
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
689
|
+
);
|
|
664
690
|
}
|
|
665
691
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
666
692
|
}
|
|
@@ -669,7 +695,7 @@ export class RPCTranslator {
|
|
|
669
695
|
foreignBlockHash: ForeignCallSingle,
|
|
670
696
|
foreignNullifier: ForeignCallSingle,
|
|
671
697
|
) {
|
|
672
|
-
const blockHash = BlockHash
|
|
698
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
673
699
|
const nullifier = fromSingle(foreignNullifier);
|
|
674
700
|
|
|
675
701
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -830,7 +856,7 @@ export class RPCTranslator {
|
|
|
830
856
|
|
|
831
857
|
// AVM opcodes
|
|
832
858
|
|
|
833
|
-
|
|
859
|
+
avmOpcodeEmitPublicLog(_foreignMessage: ForeignCallArray) {
|
|
834
860
|
// TODO(#8811): Implement
|
|
835
861
|
return toForeignCallResult([]);
|
|
836
862
|
}
|
|
@@ -1019,12 +1045,15 @@ export class RPCTranslator {
|
|
|
1019
1045
|
args,
|
|
1020
1046
|
argsHash,
|
|
1021
1047
|
isStaticCall,
|
|
1048
|
+
this.stateHandler.getCurrentJob(),
|
|
1022
1049
|
);
|
|
1023
1050
|
|
|
1051
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1052
|
+
await this.stateHandler.cycleJob();
|
|
1024
1053
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1025
1054
|
}
|
|
1026
1055
|
|
|
1027
|
-
async
|
|
1056
|
+
async txeExecuteUtilityFunction(
|
|
1028
1057
|
foreignTargetContractAddress: ForeignCallSingle,
|
|
1029
1058
|
foreignFunctionSelector: ForeignCallSingle,
|
|
1030
1059
|
foreignArgs: ForeignCallArray,
|
|
@@ -1033,12 +1062,15 @@ export class RPCTranslator {
|
|
|
1033
1062
|
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1034
1063
|
const args = fromArray(foreignArgs);
|
|
1035
1064
|
|
|
1036
|
-
const returnValues = await this.handlerAsTxe().
|
|
1065
|
+
const returnValues = await this.handlerAsTxe().txeExecuteUtilityFunction(
|
|
1037
1066
|
targetContractAddress,
|
|
1038
1067
|
functionSelector,
|
|
1039
1068
|
args,
|
|
1069
|
+
this.stateHandler.getCurrentJob(),
|
|
1040
1070
|
);
|
|
1041
1071
|
|
|
1072
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1073
|
+
await this.stateHandler.cycleJob();
|
|
1042
1074
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1043
1075
|
}
|
|
1044
1076
|
|
|
@@ -1055,6 +1087,8 @@ export class RPCTranslator {
|
|
|
1055
1087
|
|
|
1056
1088
|
const returnValues = await this.handlerAsTxe().txePublicCallNewFlow(from, address, calldata, isStaticCall);
|
|
1057
1089
|
|
|
1090
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1091
|
+
await this.stateHandler.cycleJob();
|
|
1058
1092
|
return toForeignCallResult([toArray(returnValues)]);
|
|
1059
1093
|
}
|
|
1060
1094
|
|
|
@@ -59,6 +59,8 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
59
59
|
if (!checkpointedBlock) {
|
|
60
60
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
61
61
|
}
|
|
62
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
63
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
62
64
|
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
63
65
|
if (checkpoint.length === 0) {
|
|
64
66
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
@@ -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,12 +16,12 @@ 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
|
-
public
|
|
24
|
+
public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
|
|
23
25
|
return Promise.resolve();
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -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
|
}
|
|
@@ -3,8 +3,7 @@ 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
|
|
7
|
-
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
+
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
8
7
|
import { L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
9
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,13 +25,16 @@ export class TXEStateMachine {
|
|
|
26
25
|
public synchronizer: TXESynchronizer,
|
|
27
26
|
public archiver: TXEArchiver,
|
|
28
27
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
|
+
public contractSyncService: ContractSyncService,
|
|
29
29
|
) {}
|
|
30
30
|
|
|
31
|
-
public static async create(
|
|
32
|
-
|
|
31
|
+
public static async create(
|
|
32
|
+
archiver: TXEArchiver,
|
|
33
|
+
anchorBlockStore: AnchorBlockStore,
|
|
34
|
+
contractStore: ContractStore,
|
|
35
|
+
noteStore: NoteStore,
|
|
36
|
+
) {
|
|
33
37
|
const synchronizer = await TXESynchronizer.create();
|
|
34
|
-
const anchorBlockStore = new AnchorBlockStore(db);
|
|
35
|
-
|
|
36
38
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
37
39
|
|
|
38
40
|
const log = createLogger('txe_node');
|
|
@@ -48,6 +50,7 @@ export class TXEStateMachine {
|
|
|
48
50
|
undefined,
|
|
49
51
|
undefined,
|
|
50
52
|
undefined,
|
|
53
|
+
undefined,
|
|
51
54
|
VERSION,
|
|
52
55
|
CHAIN_ID,
|
|
53
56
|
new TXEGlobalVariablesBuilder(),
|
|
@@ -58,11 +61,21 @@ export class TXEStateMachine {
|
|
|
58
61
|
log,
|
|
59
62
|
);
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
const contractSyncService = new ContractSyncService(
|
|
65
|
+
node,
|
|
66
|
+
contractStore,
|
|
67
|
+
noteStore,
|
|
68
|
+
createLogger('txe:contract_sync'),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
public async handleL2Block(block: L2Block) {
|
|
65
|
-
// Create a checkpoint from the block manually
|
|
75
|
+
// Create a checkpoint from the block manually.
|
|
76
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
77
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
78
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
|
|
66
79
|
const checkpoint = new Checkpoint(
|
|
67
80
|
block.archive,
|
|
68
81
|
CheckpointHeader.from({
|
|
@@ -79,7 +92,7 @@ export class TXEStateMachine {
|
|
|
79
92
|
totalManaUsed: block.header.totalManaUsed,
|
|
80
93
|
}),
|
|
81
94
|
[block],
|
|
82
|
-
|
|
95
|
+
checkpointNumber,
|
|
83
96
|
);
|
|
84
97
|
|
|
85
98
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
@@ -91,6 +104,9 @@ export class TXEStateMachine {
|
|
|
91
104
|
),
|
|
92
105
|
[],
|
|
93
106
|
);
|
|
107
|
+
// Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
|
|
108
|
+
this.contractSyncService.wipe();
|
|
109
|
+
|
|
94
110
|
await Promise.all([
|
|
95
111
|
this.synchronizer.handleL2Block(block),
|
|
96
112
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
@@ -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
|
}
|