@aztec/txe 0.0.0-test.1 → 0.0.1-commit.b655e406
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/bin/index.js +3 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +78 -49
- package/dest/oracle/interfaces.d.ts +54 -0
- package/dest/oracle/interfaces.d.ts.map +1 -0
- package/dest/oracle/interfaces.js +3 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +34 -0
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_public_context.js +124 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +56 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_top_level_context.js +423 -0
- package/dest/rpc_translator.d.ts +237 -0
- package/dest/rpc_translator.d.ts.map +1 -0
- package/dest/rpc_translator.js +617 -0
- package/dest/state_machine/archiver.d.ts +61 -0
- package/dest/state_machine/archiver.d.ts.map +1 -0
- package/dest/state_machine/archiver.js +118 -0
- package/dest/state_machine/dummy_p2p_client.d.ts +52 -0
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -0
- package/dest/state_machine/dummy_p2p_client.js +133 -0
- package/dest/state_machine/global_variable_builder.d.ts +9 -0
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -0
- package/dest/state_machine/global_variable_builder.js +10 -0
- package/dest/state_machine/index.d.ts +16 -0
- package/dest/state_machine/index.d.ts.map +1 -0
- package/dest/state_machine/index.js +51 -0
- package/dest/state_machine/mock_epoch_cache.d.ts +25 -0
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -0
- package/dest/state_machine/mock_epoch_cache.js +50 -0
- package/dest/state_machine/synchronizer.d.ts +32 -0
- package/dest/state_machine/synchronizer.d.ts.map +1 -0
- package/dest/state_machine/synchronizer.js +58 -0
- package/dest/txe_session.d.ts +67 -0
- package/dest/txe_session.d.ts.map +1 -0
- package/dest/txe_session.js +253 -0
- package/dest/util/encoding.d.ts +26 -8
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +65 -10
- package/dest/util/txe_contract_data_provider.d.ts +12 -0
- package/dest/util/txe_contract_data_provider.d.ts.map +1 -0
- package/dest/util/txe_contract_data_provider.js +22 -0
- package/dest/util/txe_public_contract_data_source.d.ts +8 -8
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +36 -57
- package/dest/utils/block_creation.d.ts +13 -0
- package/dest/utils/block_creation.d.ts.map +1 -0
- package/dest/utils/block_creation.js +24 -0
- package/dest/utils/tx_effect_creation.d.ts +5 -0
- package/dest/utils/tx_effect_creation.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.js +16 -0
- package/package.json +27 -22
- package/src/bin/index.ts +3 -2
- package/src/index.ts +92 -64
- package/src/oracle/interfaces.ts +83 -0
- package/src/oracle/txe_oracle_public_context.ts +165 -0
- package/src/oracle/txe_oracle_top_level_context.ts +658 -0
- package/src/rpc_translator.ts +1013 -0
- package/src/state_machine/archiver.ts +151 -0
- package/src/state_machine/dummy_p2p_client.ts +197 -0
- package/src/state_machine/global_variable_builder.ts +20 -0
- package/src/state_machine/index.ts +77 -0
- package/src/state_machine/mock_epoch_cache.ts +67 -0
- package/src/state_machine/synchronizer.ts +87 -0
- package/src/txe_session.ts +432 -0
- package/src/util/encoding.ts +84 -10
- package/src/util/txe_contract_data_provider.ts +36 -0
- package/src/util/txe_public_contract_data_source.ts +40 -56
- package/src/utils/block_creation.ts +62 -0
- package/src/utils/tx_effect_creation.ts +37 -0
- package/dest/node/txe_node.d.ts +0 -358
- package/dest/node/txe_node.d.ts.map +0 -1
- package/dest/node/txe_node.js +0 -504
- package/dest/oracle/txe_oracle.d.ts +0 -152
- package/dest/oracle/txe_oracle.d.ts.map +0 -1
- package/dest/oracle/txe_oracle.js +0 -833
- package/dest/txe_service/txe_service.d.ts +0 -212
- package/dest/txe_service/txe_service.d.ts.map +0 -1
- package/dest/txe_service/txe_service.js +0 -572
- package/dest/util/txe_world_state_db.d.ts +0 -14
- package/dest/util/txe_world_state_db.d.ts.map +0 -1
- package/dest/util/txe_world_state_db.js +0 -27
- package/src/node/txe_node.ts +0 -725
- package/src/oracle/txe_oracle.ts +0 -1241
- package/src/txe_service/txe_service.ts +0 -749
- package/src/util/txe_world_state_db.ts +0 -38
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ArchiverStoreHelper, type PublishedL2Block } from '@aztec/archiver';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import type { L2Block, L2BlockSource, L2Tips, ValidateBlockResult } from '@aztec/stdlib/block';
|
|
7
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
8
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
9
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
10
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
11
|
+
export declare class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
12
|
+
constructor(db: AztecAsyncKVStore);
|
|
13
|
+
addBlocks(blocks: PublishedL2Block[]): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
16
|
+
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
17
|
+
*/
|
|
18
|
+
getBlockNumber(): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
21
|
+
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
22
|
+
*/
|
|
23
|
+
getProvenBlockNumber(): Promise<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
|
|
26
|
+
* @param number - The block number to return (inclusive).
|
|
27
|
+
* @returns The requested L2 block.
|
|
28
|
+
*/
|
|
29
|
+
getPublishedBlock(number: number): Promise<PublishedL2Block | undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
32
|
+
* @param number - The block number to return (inclusive).
|
|
33
|
+
* @returns The requested L2 block.
|
|
34
|
+
*/
|
|
35
|
+
getBlock(number: number | 'latest'): Promise<L2Block | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets an l2 block header.
|
|
38
|
+
* @param number - The block number to return or 'latest' for the most recent one.
|
|
39
|
+
* @returns The requested L2 block header.
|
|
40
|
+
*/
|
|
41
|
+
getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
|
|
42
|
+
getBlocks(from: number, limit: number, _proven?: boolean): Promise<L2Block[]>;
|
|
43
|
+
getL2SlotNumber(): Promise<bigint>;
|
|
44
|
+
getL2EpochNumber(): Promise<bigint>;
|
|
45
|
+
getBlocksForEpoch(_epochNumber: bigint): Promise<L2Block[]>;
|
|
46
|
+
getBlockHeadersForEpoch(_epochNumber: bigint): Promise<BlockHeader[]>;
|
|
47
|
+
isEpochComplete(_epochNumber: bigint): Promise<boolean>;
|
|
48
|
+
getL2Tips(): Promise<L2Tips>;
|
|
49
|
+
getL1Constants(): Promise<L1RollupConstants>;
|
|
50
|
+
getGenesisValues(): Promise<{
|
|
51
|
+
genesisArchiveRoot: Fr;
|
|
52
|
+
}>;
|
|
53
|
+
syncImmediate(): Promise<void>;
|
|
54
|
+
getContract(_address: AztecAddress, _timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
55
|
+
getRollupAddress(): Promise<EthAddress>;
|
|
56
|
+
getRegistryAddress(): Promise<EthAddress>;
|
|
57
|
+
getL1Timestamp(): Promise<bigint>;
|
|
58
|
+
isPendingChainInvalid(): Promise<boolean>;
|
|
59
|
+
getPendingChainValidationStatus(): Promise<ValidateBlockResult>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=archiver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/state_machine/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAuB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAKlD,qBAAa,WAAY,SAAQ,mBAAoB,YAAW,aAAa;gBAC/D,EAAE,EAAE,iBAAiB;IAIX,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7E;;;OAGG;IACI,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIxC;;;OAGG;IACI,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9C;;;;OAIG;IACmB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAY9F;;;;OAIG;IACI,QA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iverStoreHelper, KVArchiverDataStore } from '@aztec/archiver';
|
|
2
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
// We are extending the ArchiverDataStoreHelper here because it provides most of the endpoints needed by the
|
|
5
|
+
// node for reading from and writing to state, without needing any of the extra overhead that the Archiver itself
|
|
6
|
+
// requires (i.e. an L1 client)
|
|
7
|
+
export class TXEArchiver extends ArchiverStoreHelper {
|
|
8
|
+
constructor(db){
|
|
9
|
+
super(new KVArchiverDataStore(db, 9999));
|
|
10
|
+
}
|
|
11
|
+
async addBlocks(blocks) {
|
|
12
|
+
const opResults = await Promise.all([
|
|
13
|
+
this.store.addLogs(blocks.map((block)=>block.block)),
|
|
14
|
+
this.store.addBlocks(blocks)
|
|
15
|
+
]);
|
|
16
|
+
return opResults.every(Boolean);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
20
|
+
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
21
|
+
*/ getBlockNumber() {
|
|
22
|
+
return this.store.getSynchedL2BlockNumber();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
26
|
+
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
27
|
+
*/ getProvenBlockNumber() {
|
|
28
|
+
return this.store.getSynchedL2BlockNumber();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
|
|
32
|
+
* @param number - The block number to return (inclusive).
|
|
33
|
+
* @returns The requested L2 block.
|
|
34
|
+
*/ async getPublishedBlock(number) {
|
|
35
|
+
// If the number provided is -ve, then return the latest block.
|
|
36
|
+
if (number < 0) {
|
|
37
|
+
number = await this.store.getSynchedL2BlockNumber();
|
|
38
|
+
}
|
|
39
|
+
if (number == 0) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const blocks = await this.store.getPublishedBlocks(number, 1);
|
|
43
|
+
return blocks.length === 0 ? undefined : blocks[0];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
47
|
+
* @param number - The block number to return (inclusive).
|
|
48
|
+
* @returns The requested L2 block.
|
|
49
|
+
*/ getBlock(number) {
|
|
50
|
+
return this.getPublishedBlock(number != 'latest' ? number : -1).then((block)=>block?.block);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets an l2 block header.
|
|
54
|
+
* @param number - The block number to return or 'latest' for the most recent one.
|
|
55
|
+
* @returns The requested L2 block header.
|
|
56
|
+
*/ async getBlockHeader(number) {
|
|
57
|
+
if (number === 'latest') {
|
|
58
|
+
number = await this.store.getSynchedL2BlockNumber();
|
|
59
|
+
}
|
|
60
|
+
if (number === 0) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const headers = await this.store.getBlockHeaders(number, 1);
|
|
64
|
+
return headers.length === 0 ? undefined : headers[0];
|
|
65
|
+
}
|
|
66
|
+
getBlocks(from, limit, _proven) {
|
|
67
|
+
return this.getPublishedBlocks(from, limit).then((blocks)=>blocks.map((b)=>b.block));
|
|
68
|
+
}
|
|
69
|
+
getL2SlotNumber() {
|
|
70
|
+
throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
|
|
71
|
+
}
|
|
72
|
+
getL2EpochNumber() {
|
|
73
|
+
throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
|
|
74
|
+
}
|
|
75
|
+
getBlocksForEpoch(_epochNumber) {
|
|
76
|
+
throw new Error('TXE Archiver does not implement "getBlocksForEpoch"');
|
|
77
|
+
}
|
|
78
|
+
getBlockHeadersForEpoch(_epochNumber) {
|
|
79
|
+
throw new Error('TXE Archiver does not implement "getBlockHeadersForEpoch"');
|
|
80
|
+
}
|
|
81
|
+
isEpochComplete(_epochNumber) {
|
|
82
|
+
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
83
|
+
}
|
|
84
|
+
getL2Tips() {
|
|
85
|
+
throw new Error('TXE Archiver does not implement "getL2Tips"');
|
|
86
|
+
}
|
|
87
|
+
getL1Constants() {
|
|
88
|
+
throw new Error('TXE Archiver does not implement "getL2Constants"');
|
|
89
|
+
}
|
|
90
|
+
getGenesisValues() {
|
|
91
|
+
return Promise.resolve({
|
|
92
|
+
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
syncImmediate() {
|
|
96
|
+
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
97
|
+
}
|
|
98
|
+
getContract(_address, _timestamp) {
|
|
99
|
+
throw new Error('TXE Archiver does not implement "getContract"');
|
|
100
|
+
}
|
|
101
|
+
getRollupAddress() {
|
|
102
|
+
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
103
|
+
}
|
|
104
|
+
getRegistryAddress() {
|
|
105
|
+
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
106
|
+
}
|
|
107
|
+
getL1Timestamp() {
|
|
108
|
+
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
109
|
+
}
|
|
110
|
+
isPendingChainInvalid() {
|
|
111
|
+
return Promise.resolve(false);
|
|
112
|
+
}
|
|
113
|
+
getPendingChainValidationStatus() {
|
|
114
|
+
return Promise.resolve({
|
|
115
|
+
valid: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AuthRequest, ENR, P2P, P2PBlockReceivedCallback, P2PConfig, P2PSyncState, PeerId, ReqRespSubProtocol, ReqRespSubProtocolHandler, ReqRespSubProtocolValidators, StatusMessage } from '@aztec/p2p';
|
|
2
|
+
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
3
|
+
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
5
|
+
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
export declare class DummyP2P implements P2P {
|
|
7
|
+
validate(_txs: Tx[]): Promise<void>;
|
|
8
|
+
clear(): Promise<void>;
|
|
9
|
+
getPendingTxs(): Promise<Tx[]>;
|
|
10
|
+
getEncodedEnr(): Promise<string | undefined>;
|
|
11
|
+
getPeers(_includePending?: boolean): Promise<PeerInfo[]>;
|
|
12
|
+
broadcastProposal(_proposal: BlockProposal): Promise<void>;
|
|
13
|
+
registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void;
|
|
14
|
+
requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
15
|
+
requestTxByHash(_txHash: TxHash): Promise<Tx | undefined>;
|
|
16
|
+
sendTx(_tx: Tx): Promise<void>;
|
|
17
|
+
deleteTxs(_txHashes: TxHash[]): Promise<void>;
|
|
18
|
+
getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined>;
|
|
19
|
+
getTxByHash(_txHash: TxHash): Promise<Tx | undefined>;
|
|
20
|
+
getArchivedTxByHash(_txHash: TxHash): Promise<Tx | undefined>;
|
|
21
|
+
getTxStatus(_txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
|
|
22
|
+
iteratePendingTxs(): AsyncIterableIterator<Tx>;
|
|
23
|
+
getPendingTxCount(): Promise<number>;
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
isReady(): boolean;
|
|
27
|
+
getStatus(): Promise<P2PSyncState>;
|
|
28
|
+
getEnr(): ENR | undefined;
|
|
29
|
+
isP2PClient(): true;
|
|
30
|
+
getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]>;
|
|
31
|
+
getAttestationsForSlot(_slot: bigint, _proposalId?: string): Promise<BlockAttestation[]>;
|
|
32
|
+
deleteAttestation(_attestation: BlockAttestation): Promise<void>;
|
|
33
|
+
addAttestations(_attestations: BlockAttestation[]): Promise<void>;
|
|
34
|
+
getL2BlockHash(_number: number): Promise<string | undefined>;
|
|
35
|
+
updateP2PConfig(_config: Partial<P2PConfig>): Promise<void>;
|
|
36
|
+
getL2Tips(): Promise<L2Tips>;
|
|
37
|
+
handleBlockStreamEvent(_event: L2BlockStreamEvent): Promise<void>;
|
|
38
|
+
sync(): void;
|
|
39
|
+
requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]>;
|
|
40
|
+
getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]>;
|
|
41
|
+
getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
42
|
+
hasTxsInPool(_txHashes: TxHash[]): Promise<boolean[]>;
|
|
43
|
+
addTxsToPool(_txs: Tx[]): Promise<number>;
|
|
44
|
+
getSyncedLatestBlockNum(): Promise<number>;
|
|
45
|
+
getSyncedProvenBlockNum(): Promise<number>;
|
|
46
|
+
getSyncedLatestSlot(): Promise<bigint>;
|
|
47
|
+
markTxsAsNonEvictable(_: TxHash[]): Promise<void>;
|
|
48
|
+
addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler, _validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol]): Promise<void>;
|
|
49
|
+
handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage>;
|
|
50
|
+
registerThisValidatorAddresses(_address: EthAddress[]): void;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=dummy_p2p_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dummy_p2p_client.d.ts","sourceRoot":"","sources":["../../src/state_machine/dummy_p2p_client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,GAAG,EACH,GAAG,EACH,wBAAwB,EACxB,SAAS,EACT,YAAY,EACZ,MAAM,E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AAO,CAAC,EAAE,EAAE,CAAC;IAIpD,MAAM,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC;IAI3D,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;IAItE,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIrD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7C,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,qBAAqB,CACnB,YAAY,EAAE,kBAAkB,EAChC,QAAQ,EAAE,yBAAyB,EACnC,UAAU,CAAC,EAAE,4BAA4B,CAAC,kBAAkB,CAAC,GAC5D,OAAO,CAAC,IAAI,CAAC;IAGhB,yBAAyB,CAAC,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAKtF,8BAA8B,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAI;CACpE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
export class DummyP2P {
|
|
2
|
+
validate(_txs) {
|
|
3
|
+
return Promise.resolve();
|
|
4
|
+
}
|
|
5
|
+
clear() {
|
|
6
|
+
throw new Error('DummyP2P does not implement "clear".');
|
|
7
|
+
}
|
|
8
|
+
getPendingTxs() {
|
|
9
|
+
throw new Error('DummyP2P does not implement "getPendingTxs"');
|
|
10
|
+
}
|
|
11
|
+
getEncodedEnr() {
|
|
12
|
+
throw new Error('DummyP2P does not implement "getEncodedEnr"');
|
|
13
|
+
}
|
|
14
|
+
getPeers(_includePending) {
|
|
15
|
+
throw new Error('DummyP2P does not implement "getPeers"');
|
|
16
|
+
}
|
|
17
|
+
broadcastProposal(_proposal) {
|
|
18
|
+
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
19
|
+
}
|
|
20
|
+
registerBlockProposalHandler(_handler) {
|
|
21
|
+
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
22
|
+
}
|
|
23
|
+
requestTxs(_txHashes) {
|
|
24
|
+
throw new Error('DummyP2P does not implement "requestTxs"');
|
|
25
|
+
}
|
|
26
|
+
requestTxByHash(_txHash) {
|
|
27
|
+
throw new Error('DummyP2P does not implement "requestTxByHash"');
|
|
28
|
+
}
|
|
29
|
+
sendTx(_tx) {
|
|
30
|
+
throw new Error('DummyP2P does not implement "sendTx"');
|
|
31
|
+
}
|
|
32
|
+
deleteTxs(_txHashes) {
|
|
33
|
+
throw new Error('DummyP2P does not implement "deleteTxs"');
|
|
34
|
+
}
|
|
35
|
+
getTxByHashFromPool(_txHash) {
|
|
36
|
+
throw new Error('DummyP2P does not implement "getTxByHashFromPool"');
|
|
37
|
+
}
|
|
38
|
+
getTxByHash(_txHash) {
|
|
39
|
+
throw new Error('DummyP2P does not implement "getTxByHash"');
|
|
40
|
+
}
|
|
41
|
+
getArchivedTxByHash(_txHash) {
|
|
42
|
+
throw new Error('DummyP2P does not implement "getArchivedTxByHash"');
|
|
43
|
+
}
|
|
44
|
+
getTxStatus(_txHash) {
|
|
45
|
+
throw new Error('DummyP2P does not implement "getTxStatus"');
|
|
46
|
+
}
|
|
47
|
+
iteratePendingTxs() {
|
|
48
|
+
throw new Error('DummyP2P does not implement "iteratePendingTxs"');
|
|
49
|
+
}
|
|
50
|
+
getPendingTxCount() {
|
|
51
|
+
throw new Error('DummyP2P does not implement "getPendingTxCount"');
|
|
52
|
+
}
|
|
53
|
+
start() {
|
|
54
|
+
throw new Error('DummyP2P does not implement "start"');
|
|
55
|
+
}
|
|
56
|
+
stop() {
|
|
57
|
+
throw new Error('DummyP2P does not implement "stop"');
|
|
58
|
+
}
|
|
59
|
+
isReady() {
|
|
60
|
+
throw new Error('DummyP2P does not implement "isReady"');
|
|
61
|
+
}
|
|
62
|
+
getStatus() {
|
|
63
|
+
throw new Error('DummyP2P does not implement "getStatus"');
|
|
64
|
+
}
|
|
65
|
+
getEnr() {
|
|
66
|
+
throw new Error('DummyP2P does not implement "getEnr"');
|
|
67
|
+
}
|
|
68
|
+
isP2PClient() {
|
|
69
|
+
throw new Error('DummyP2P does not implement "isP2PClient"');
|
|
70
|
+
}
|
|
71
|
+
getTxsByHash(_txHashes) {
|
|
72
|
+
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
73
|
+
}
|
|
74
|
+
getAttestationsForSlot(_slot, _proposalId) {
|
|
75
|
+
throw new Error('DummyP2P does not implement "getAttestationForSlot"');
|
|
76
|
+
}
|
|
77
|
+
deleteAttestation(_attestation) {
|
|
78
|
+
return Promise.resolve();
|
|
79
|
+
}
|
|
80
|
+
addAttestations(_attestations) {
|
|
81
|
+
throw new Error('DummyP2P does not implement "addAttestations"');
|
|
82
|
+
}
|
|
83
|
+
getL2BlockHash(_number) {
|
|
84
|
+
throw new Error('DummyP2P does not implement "getL2BlockHash"');
|
|
85
|
+
}
|
|
86
|
+
updateP2PConfig(_config) {
|
|
87
|
+
throw new Error('DummyP2P does not implement "updateP2PConfig"');
|
|
88
|
+
}
|
|
89
|
+
getL2Tips() {
|
|
90
|
+
throw new Error('DummyP2P does not implement "getL2Tips"');
|
|
91
|
+
}
|
|
92
|
+
handleBlockStreamEvent(_event) {
|
|
93
|
+
throw new Error('DummyP2P does not implement "handleBlockStreamEvent"');
|
|
94
|
+
}
|
|
95
|
+
sync() {
|
|
96
|
+
throw new Error('DummyP2P does not implement "sync"');
|
|
97
|
+
}
|
|
98
|
+
requestTxsByHash(_txHashes) {
|
|
99
|
+
throw new Error('DummyP2P does not implement "requestTxsByHash"');
|
|
100
|
+
}
|
|
101
|
+
getTxs(_filter) {
|
|
102
|
+
throw new Error('DummyP2P does not implement "getTxs"');
|
|
103
|
+
}
|
|
104
|
+
getTxsByHashFromPool(_txHashes) {
|
|
105
|
+
throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
|
|
106
|
+
}
|
|
107
|
+
hasTxsInPool(_txHashes) {
|
|
108
|
+
throw new Error('DummyP2P does not implement "hasTxsInPool"');
|
|
109
|
+
}
|
|
110
|
+
addTxsToPool(_txs) {
|
|
111
|
+
throw new Error('DummyP2P does not implement "addTxs"');
|
|
112
|
+
}
|
|
113
|
+
getSyncedLatestBlockNum() {
|
|
114
|
+
throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
|
|
115
|
+
}
|
|
116
|
+
getSyncedProvenBlockNum() {
|
|
117
|
+
throw new Error('DummyP2P does not implement "getSyncedProvenBlockNum"');
|
|
118
|
+
}
|
|
119
|
+
getSyncedLatestSlot() {
|
|
120
|
+
throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
|
|
121
|
+
}
|
|
122
|
+
markTxsAsNonEvictable(_) {
|
|
123
|
+
throw new Error('DummyP2P does not implement "markTxsAsNonEvictable".');
|
|
124
|
+
}
|
|
125
|
+
addReqRespSubProtocol(_subProtocol, _handler, _validator) {
|
|
126
|
+
throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
|
|
127
|
+
}
|
|
128
|
+
handleAuthRequestFromPeer(_authRequest, _peerId) {
|
|
129
|
+
throw new Error('DummyP2P does not implement "handleAuthRequestFromPeer".');
|
|
130
|
+
}
|
|
131
|
+
//This is no-op
|
|
132
|
+
registerThisValidatorAddresses(_address) {}
|
|
133
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
4
|
+
import { type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
|
|
5
|
+
export declare class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
6
|
+
getCurrentBaseFees(): Promise<GasFees>;
|
|
7
|
+
buildGlobalVariables(_blockNumber: number, _coinbase: EthAddress, _feeRecipient: AztecAddress, _slotNumber?: bigint): Promise<GlobalVariables>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=global_variable_builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global_variable_builder.d.ts","sourceRoot":"","sources":["../../src/state_machine/global_variable_builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,KAAK,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE/E,qBAAa,yBAA0B,YAAW,qBAAqB;IAC9D,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAItC,oBAAoB,CACzB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,YAAY,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;CAG5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
|
2
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
3
|
+
export class TXEGlobalVariablesBuilder {
|
|
4
|
+
getCurrentBaseFees() {
|
|
5
|
+
return Promise.resolve(new GasFees(0, 0));
|
|
6
|
+
}
|
|
7
|
+
buildGlobalVariables(_blockNumber, _coinbase, _feeRecipient, _slotNumber) {
|
|
8
|
+
return Promise.resolve(makeGlobalVariables());
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
+
import { SyncDataProvider } from '@aztec/pxe/server';
|
|
3
|
+
import { type L2Block } from '@aztec/stdlib/block';
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import { TXEArchiver } from './archiver.js';
|
|
6
|
+
import { TXESynchronizer } from './synchronizer.js';
|
|
7
|
+
export declare class TXEStateMachine {
|
|
8
|
+
node: AztecNode;
|
|
9
|
+
synchronizer: TXESynchronizer;
|
|
10
|
+
archiver: TXEArchiver;
|
|
11
|
+
syncDataProvider: SyncDataProvider;
|
|
12
|
+
constructor(node: AztecNode, synchronizer: TXESynchronizer, archiver: TXEArchiver, syncDataProvider: SyncDataProvider);
|
|
13
|
+
static create(db: AztecAsyncKVStore): Promise<TXEStateMachine>;
|
|
14
|
+
handleL2Block(block: L2Block): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state_machine/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,qBAAa,eAAe;IAEjB,IAAI,EAAE,SAAS;IACf,YAAY,EAAE,eAAe;IAC7B,QAAQ,EAAE,WAAW;IACrB,gBAAgB,EAAE,gBAAgB;gBAHlC,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,eAAe,EAC7B,QAAQ,EAAE,WAAW,EACrB,gBAAgB,EAAE,gBAAgB;WAGvB,MAAM,CAAC,EAAE,EAAE,iBAAiB;IAiCnC,aAAa,CAAC,KAAK,EAAE,OAAO;CAiB1C"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { SyncDataProvider } from '@aztec/pxe/server';
|
|
5
|
+
import { PublishedL2Block } from '@aztec/stdlib/block';
|
|
6
|
+
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
7
|
+
import { TXEArchiver } from './archiver.js';
|
|
8
|
+
import { DummyP2P } from './dummy_p2p_client.js';
|
|
9
|
+
import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
10
|
+
import { MockEpochCache } from './mock_epoch_cache.js';
|
|
11
|
+
import { TXESynchronizer } from './synchronizer.js';
|
|
12
|
+
const VERSION = 1;
|
|
13
|
+
const CHAIN_ID = 1;
|
|
14
|
+
export class TXEStateMachine {
|
|
15
|
+
node;
|
|
16
|
+
synchronizer;
|
|
17
|
+
archiver;
|
|
18
|
+
syncDataProvider;
|
|
19
|
+
constructor(node, synchronizer, archiver, syncDataProvider){
|
|
20
|
+
this.node = node;
|
|
21
|
+
this.synchronizer = synchronizer;
|
|
22
|
+
this.archiver = archiver;
|
|
23
|
+
this.syncDataProvider = syncDataProvider;
|
|
24
|
+
}
|
|
25
|
+
static async create(db) {
|
|
26
|
+
const archiver = new TXEArchiver(db);
|
|
27
|
+
const synchronizer = await TXESynchronizer.create();
|
|
28
|
+
const syncDataProvider = new SyncDataProvider(db);
|
|
29
|
+
const aztecNodeConfig = {};
|
|
30
|
+
const log = createLogger('txe_node');
|
|
31
|
+
const node = new AztecNodeService(aztecNodeConfig, new DummyP2P(), archiver, archiver, archiver, archiver, synchronizer, undefined, undefined, undefined, undefined, VERSION, CHAIN_ID, new TXEGlobalVariablesBuilder(), new MockEpochCache(), getPackageVersion() ?? '', new TestCircuitVerifier(), undefined, log);
|
|
32
|
+
return new this(node, synchronizer, archiver, syncDataProvider);
|
|
33
|
+
}
|
|
34
|
+
async handleL2Block(block) {
|
|
35
|
+
await Promise.all([
|
|
36
|
+
this.synchronizer.handleL2Block(block),
|
|
37
|
+
this.archiver.addBlocks([
|
|
38
|
+
PublishedL2Block.fromFields({
|
|
39
|
+
block,
|
|
40
|
+
l1: {
|
|
41
|
+
blockHash: block.header.globalVariables.blockNumber.toString(),
|
|
42
|
+
blockNumber: BigInt(block.header.globalVariables.blockNumber),
|
|
43
|
+
timestamp: block.header.globalVariables.timestamp
|
|
44
|
+
},
|
|
45
|
+
attestations: []
|
|
46
|
+
})
|
|
47
|
+
]),
|
|
48
|
+
this.syncDataProvider.setHeader(block.getBlockHeader())
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
/**
|
|
4
|
+
* Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
|
|
5
|
+
* Since in TXE we don't validate transactions, mock suffices here.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MockEpochCache implements EpochCacheInterface {
|
|
8
|
+
getCommittee(): Promise<EpochCommitteeInfo>;
|
|
9
|
+
getEpochAndSlotNow(): EpochAndSlot;
|
|
10
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
11
|
+
now: bigint;
|
|
12
|
+
};
|
|
13
|
+
getProposerIndexEncoding(_epoch: bigint, _slot: bigint, _seed: bigint): `0x${string}`;
|
|
14
|
+
computeProposerIndex(_slot: bigint, _epoch: bigint, _seed: bigint, _size: bigint): bigint;
|
|
15
|
+
getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
|
|
16
|
+
currentProposer: EthAddress | undefined;
|
|
17
|
+
nextProposer: EthAddress | undefined;
|
|
18
|
+
currentSlot: bigint;
|
|
19
|
+
nextSlot: bigint;
|
|
20
|
+
}>;
|
|
21
|
+
isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean>;
|
|
22
|
+
getRegisteredValidators(): Promise<EthAddress[]>;
|
|
23
|
+
filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=mock_epoch_cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock_epoch_cache.d.ts","sourceRoot":"","sources":["../../src/state_machine/mock_epoch_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,cAAe,YAAW,mBAAmB;IACxD,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQ3C,kBAAkB,IAAI,YAAY;IAQlC,2BAA2B,IAAI,YAAY,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;IAS7D,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE;IAIrF,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAIzF,6CAA6C,IAAI,OAAO,CAAC;QACvD,eAAe,EAAE,UAAU,GAAG,SAAS,CAAC;QACxC,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC;QACrC,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IASF,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvE,uBAAuB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAIhD,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAGpF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
|
|
3
|
+
* Since in TXE we don't validate transactions, mock suffices here.
|
|
4
|
+
*/ export class MockEpochCache {
|
|
5
|
+
getCommittee() {
|
|
6
|
+
return Promise.resolve({
|
|
7
|
+
committee: undefined,
|
|
8
|
+
seed: 0n,
|
|
9
|
+
epoch: 0n
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
getEpochAndSlotNow() {
|
|
13
|
+
return {
|
|
14
|
+
epoch: 0n,
|
|
15
|
+
slot: 0n,
|
|
16
|
+
ts: 0n
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
getEpochAndSlotInNextL1Slot() {
|
|
20
|
+
return {
|
|
21
|
+
epoch: 0n,
|
|
22
|
+
slot: 0n,
|
|
23
|
+
ts: 0n,
|
|
24
|
+
now: 0n
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getProposerIndexEncoding(_epoch, _slot, _seed) {
|
|
28
|
+
return '0x00';
|
|
29
|
+
}
|
|
30
|
+
computeProposerIndex(_slot, _epoch, _seed, _size) {
|
|
31
|
+
return 0n;
|
|
32
|
+
}
|
|
33
|
+
getProposerAttesterAddressInCurrentOrNextSlot() {
|
|
34
|
+
return Promise.resolve({
|
|
35
|
+
currentProposer: undefined,
|
|
36
|
+
nextProposer: undefined,
|
|
37
|
+
currentSlot: 0n,
|
|
38
|
+
nextSlot: 0n
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
isInCommittee(_slot, _validator) {
|
|
42
|
+
return Promise.resolve(false);
|
|
43
|
+
}
|
|
44
|
+
getRegisteredValidators() {
|
|
45
|
+
return Promise.resolve([]);
|
|
46
|
+
}
|
|
47
|
+
filterInCommittee(_slot, _validators) {
|
|
48
|
+
return Promise.resolve([]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
2
|
+
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations, SnapshotDataKeys, WorldStateSynchronizer, WorldStateSynchronizerStatus } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
4
|
+
export declare class TXESynchronizer implements WorldStateSynchronizer {
|
|
5
|
+
nativeWorldStateService: NativeWorldStateService;
|
|
6
|
+
private blockNumber;
|
|
7
|
+
constructor(nativeWorldStateService: NativeWorldStateService);
|
|
8
|
+
static create(): Promise<TXESynchronizer>;
|
|
9
|
+
handleL2Block(block: L2Block): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Forces an immediate sync to an optionally provided minimum block number
|
|
12
|
+
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
13
|
+
* @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
|
|
14
|
+
* @returns A promise that resolves with the block number the world state was synced to
|
|
15
|
+
*/
|
|
16
|
+
syncImmediate(_minBlockNumber?: number, _skipThrowIfTargetNotReached?: boolean): Promise<number>;
|
|
17
|
+
/** Returns an instance of MerkleTreeAdminOperations that will not include uncommitted data. */
|
|
18
|
+
getCommitted(): MerkleTreeReadOperations;
|
|
19
|
+
/** Forks the world state at the given block number, defaulting to the latest one. */
|
|
20
|
+
fork(block?: number): Promise<MerkleTreeWriteOperations>;
|
|
21
|
+
/** Gets a handle that allows reading the state as it was at the given block number. */
|
|
22
|
+
getSnapshot(blockNumber: number): MerkleTreeReadOperations;
|
|
23
|
+
/** Backups the db to the target path. */
|
|
24
|
+
backupTo(dstPath: string, compact?: boolean): Promise<Record<Exclude<SnapshotDataKeys, 'archiver'>, string>>;
|
|
25
|
+
start(): Promise<void>;
|
|
26
|
+
status(): Promise<WorldStateSynchronizerStatus>;
|
|
27
|
+
stop(): Promise<void>;
|
|
28
|
+
stopSync(): Promise<void>;
|
|
29
|
+
resumeSync(): void;
|
|
30
|
+
clear(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=synchronizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synchronizer.d.ts","sourceRoot":"","sources":["../../src/state_machine/synchronizer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,qBAAa,eAAgB,YAAW,sBAAsB;IAIzC,uBAAuB,EAAE,uBAAuB;IAFnE,OAAO,CAAC,WAAW,CAAK;gBAEL,uBAAuB,EAAE,uBAAuB;WAEtD,MAAM;IAMN,aAAa,CAAC,KAAK,EAAE,OAAO;IASzC;;;;;OAKG;IACI,aAAa,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,4BAA4B,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvG,+FAA+F;IACxF,YAAY,IAAI,wBAAwB;IAI/C,qFAAqF;IAC9E,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAI/D,uFAAuF;IAChF,WAAW,CAAC,WAAW,EAAE,MAAM,GA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