@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.04d373f
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/ContractClassRegistry-KKNT527R.js +3 -0
- package/dest/ContractClassRegistry-KKNT527R.js.map +7 -0
- package/dest/ContractInstanceRegistry-GSKBNL3Q.js +3 -0
- package/dest/ContractInstanceRegistry-GSKBNL3Q.js.map +7 -0
- package/dest/FeeJuice-GUJ5O6GB.js +3 -0
- package/dest/FeeJuice-GUJ5O6GB.js.map +7 -0
- package/dest/MultiCallEntrypoint-ZQPCKVKL.js +3 -0
- package/dest/MultiCallEntrypoint-ZQPCKVKL.js.map +7 -0
- package/dest/SchnorrAccount-QIXE5DXA.js +3 -0
- package/dest/SchnorrAccount-QIXE5DXA.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +32 -0
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-DF6RMOC6.js +304 -0
- package/dest/chunk-DF6RMOC6.js.map +7 -0
- package/dest/chunk-PPJTNNUG.js +265 -0
- package/dest/chunk-PPJTNNUG.js.map +7 -0
- package/dest/constants.d.ts +5 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +7 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +188 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +148 -75
- package/dest/metafile.json +38147 -0
- package/dest/msgpackr_fr_extension.d.ts +2 -0
- package/dest/msgpackr_fr_extension.d.ts.map +1 -0
- package/dest/msgpackr_fr_extension.js +21 -0
- package/dest/oracle/interfaces.d.ts +40 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +18 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +31 -16
- package/dest/oracle/txe_oracle_top_level_context.d.ts +49 -31
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +265 -119
- package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
- package/dest/oracle/txe_private_execution_oracle.js +15 -0
- package/dest/rpc_server.d.ts +14 -0
- package/dest/rpc_server.d.ts.map +1 -0
- package/dest/rpc_server.js +78 -0
- package/dest/rpc_translator.d.ts +144 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +599 -238
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +20 -67
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +65 -182
- package/dest/state_machine/dummy_p2p_client.d.ts +28 -17
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +51 -24
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +10 -4
- package/dest/state_machine/index.d.ts +11 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +57 -16
- package/dest/state_machine/mock_epoch_cache.d.ts +26 -8
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +49 -9
- package/dest/state_machine/synchronizer.d.ts +6 -6
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +4 -4
- package/dest/txe_oracle_version.d.ts +17 -0
- package/dest/txe_oracle_version.d.ts.map +1 -0
- package/dest/txe_oracle_version.js +14 -0
- package/dest/txe_session.d.ts +83 -19
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +291 -66
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +18 -5
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +7 -2
- package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/dest/utils/txe_account_store.d.ts +10 -0
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/{util/txe_account_data_provider.js → utils/txe_account_store.js} +1 -1
- package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
- package/dest/utils/txe_public_contract_data_source.js +48 -0
- package/dest/worker.bundle.js +3 -0
- package/dest/worker.bundle.js.map +7 -0
- package/dest/worker.d.ts +2 -0
- package/dest/worker.d.ts.map +1 -0
- package/dest/worker.js +92 -0
- package/package.json +38 -22
- package/src/bin/check_txe_oracle_version.ts +37 -0
- package/src/bin/index.ts +11 -2
- package/src/constants.ts +9 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +166 -80
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +48 -34
- package/src/oracle/txe_oracle_public_context.ts +46 -18
- package/src/oracle/txe_oracle_top_level_context.ts +322 -169
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +687 -326
- package/src/state_machine/archiver.ts +69 -220
- package/src/state_machine/dummy_p2p_client.ts +80 -37
- package/src/state_machine/global_variable_builder.ts +19 -4
- package/src/state_machine/index.ts +73 -16
- package/src/state_machine/mock_epoch_cache.ts +61 -14
- package/src/state_machine/synchronizer.ts +6 -6
- package/src/txe_oracle_version.ts +17 -0
- package/src/txe_session.ts +439 -132
- package/src/utils/block_creation.ts +19 -16
- package/src/{util → utils}/encoding.ts +8 -2
- package/src/utils/tx_effect_creation.ts +3 -11
- package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
- package/src/utils/txe_public_contract_data_source.ts +58 -0
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -720
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.js +0 -22
- package/dest/util/txe_public_contract_data_source.d.ts +0 -21
- package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
- package/dest/util/txe_public_contract_data_source.js +0 -67
- package/src/util/txe_contract_data_provider.ts +0 -36
- package/src/util/txe_public_contract_data_source.ts +0 -86
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
|
@@ -1,263 +1,112 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckpointNumber, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
-
import { isDefined } from '@aztec/foundation/types';
|
|
7
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
8
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
7
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
type CheckpointId,
|
|
9
|
+
GENESIS_BLOCK_HEADER_HASH,
|
|
12
10
|
type L2BlockId,
|
|
13
|
-
type
|
|
14
|
-
type L2BlockSource,
|
|
11
|
+
type L2TipId,
|
|
15
12
|
type L2Tips,
|
|
16
|
-
|
|
17
|
-
type ValidateBlockResult,
|
|
13
|
+
type ValidateCheckpointResult,
|
|
18
14
|
} from '@aztec/stdlib/block';
|
|
19
|
-
import {
|
|
20
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
15
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
21
16
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
22
|
-
import
|
|
23
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
17
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
public async getBlock(number: BlockNumber): Promise<L2Block | undefined> {
|
|
34
|
-
if (number === 0) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
const publishedBlocks = await this.getPublishedBlocks(number, 1);
|
|
38
|
-
if (publishedBlocks.length === 0) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return publishedBlocks[0].block;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public async getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2Block[]> {
|
|
45
|
-
const publishedBlocks = await this.getPublishedBlocks(from, limit, proven);
|
|
46
|
-
return publishedBlocks.map(x => x.block);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public override async addCheckpoints(
|
|
50
|
-
checkpoints: PublishedCheckpoint[],
|
|
51
|
-
_result?: ValidateBlockResult,
|
|
52
|
-
): Promise<boolean> {
|
|
53
|
-
const allBlocks = checkpoints.flatMap(ch => ch.checkpoint.blocks);
|
|
54
|
-
const opResults = await Promise.all([this.store.addLogs(allBlocks), this.store.addCheckpoints(checkpoints)]);
|
|
55
|
-
|
|
56
|
-
return opResults.every(Boolean);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
61
|
-
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
62
|
-
*/
|
|
63
|
-
public getBlockNumber(): Promise<BlockNumber> {
|
|
64
|
-
return this.store.getLatestBlockNumber();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
69
|
-
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
70
|
-
*/
|
|
71
|
-
public override getProvenBlockNumber(): Promise<BlockNumber> {
|
|
72
|
-
return this.store.getProvenBlockNumber();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
|
|
77
|
-
* @param number - The block number to return (inclusive).
|
|
78
|
-
* @returns The requested L2 block.
|
|
79
|
-
*/
|
|
80
|
-
public async getPublishedBlock(number: number): Promise<PublishedL2Block | undefined> {
|
|
81
|
-
// If the number provided is -ve, then return the latest block.
|
|
82
|
-
if (number < 0) {
|
|
83
|
-
number = await this.store.getLatestBlockNumber();
|
|
84
|
-
}
|
|
85
|
-
if (number == 0) {
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
const publishedBlocks = await this.retrievePublishedBlocks(BlockNumber(number), 1);
|
|
89
|
-
return publishedBlocks.length === 0 ? undefined : publishedBlocks[0];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<PublishedL2Block[]> {
|
|
93
|
-
return this.retrievePublishedBlocks(from, limit, proven);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private async retrievePublishedBlocks(
|
|
97
|
-
from: BlockNumber,
|
|
98
|
-
limit: number,
|
|
99
|
-
proven?: boolean,
|
|
100
|
-
): Promise<PublishedL2Block[]> {
|
|
101
|
-
const checkpoints = await this.store.getRangeOfCheckpoints(CheckpointNumber(from), limit);
|
|
102
|
-
const provenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
103
|
-
const blocks = (
|
|
104
|
-
await Promise.all(checkpoints.map(ch => this.store.getBlocksForCheckpoint(ch.checkpointNumber)))
|
|
105
|
-
).filter(isDefined);
|
|
106
|
-
|
|
107
|
-
const olbBlocks: PublishedL2Block[] = [];
|
|
108
|
-
for (let i = 0; i < checkpoints.length; i++) {
|
|
109
|
-
const blockForCheckpoint = blocks[i][0];
|
|
110
|
-
const checkpoint = checkpoints[i];
|
|
111
|
-
if (proven === true && checkpoint.checkpointNumber > provenCheckpointNumber) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const oldCheckpoint = new Checkpoint(
|
|
115
|
-
blockForCheckpoint.archive,
|
|
116
|
-
checkpoint.header,
|
|
117
|
-
[blockForCheckpoint],
|
|
118
|
-
checkpoint.checkpointNumber,
|
|
119
|
-
);
|
|
120
|
-
const oldBlock = L2Block.fromCheckpoint(oldCheckpoint);
|
|
121
|
-
const publishedBlock = new PublishedL2Block(
|
|
122
|
-
oldBlock,
|
|
123
|
-
checkpoint.l1,
|
|
124
|
-
checkpoint.attestations.map(x => CommitteeAttestation.fromBuffer(x)),
|
|
125
|
-
);
|
|
126
|
-
olbBlocks.push(publishedBlock);
|
|
127
|
-
}
|
|
128
|
-
return olbBlocks;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
133
|
-
* @param number - The block number to return (inclusive).
|
|
134
|
-
* @returns The requested L2 block.
|
|
135
|
-
*/
|
|
136
|
-
public getL2Block(number: BlockNumber | 'latest'): Promise<L2Block | undefined> {
|
|
137
|
-
return this.getPublishedBlock(number != 'latest' ? number : -1).then(b => b?.block);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Gets an L2 block (new format).
|
|
142
|
-
* @param number - The block number to return.
|
|
143
|
-
* @returns The requested L2 block.
|
|
144
|
-
*/
|
|
145
|
-
public getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined> {
|
|
146
|
-
if (number === 0) {
|
|
147
|
-
return Promise.resolve(undefined);
|
|
148
|
-
}
|
|
149
|
-
return this.store.getBlock(number);
|
|
150
|
-
}
|
|
19
|
+
/**
|
|
20
|
+
* TXE Archiver implementation.
|
|
21
|
+
* Provides most of the endpoints needed by the node for reading from and writing to state,
|
|
22
|
+
* without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
|
|
23
|
+
*/
|
|
24
|
+
export class TXEArchiver extends ArchiverDataSourceBase {
|
|
25
|
+
private readonly updater = new ArchiverDataStoreUpdater(this.stores);
|
|
151
26
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
if (number === 0) {
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
const headers = await this.store.getBlockHeaders(BlockNumber(number), 1);
|
|
165
|
-
return headers.length === 0 ? undefined : headers[0];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public getBlockRange(from: number, limit: number, _proven?: boolean): Promise<L2Block[]> {
|
|
169
|
-
return this.getPublishedBlocks(BlockNumber(from), limit).then(blocks => blocks.map(b => b.block));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public getPublishedCheckpoints(_from: CheckpointNumber, _limit: number): Promise<PublishedCheckpoint[]> {
|
|
173
|
-
throw new Error('TXE Archiver does not implement "getPublishedCheckpoints"');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
public getCheckpointByArchive(_archive: Fr): Promise<Checkpoint | undefined> {
|
|
177
|
-
throw new Error('TXE Archiver does not implement "getCheckpointByArchive"');
|
|
27
|
+
constructor(db: AztecAsyncKVStore) {
|
|
28
|
+
super(
|
|
29
|
+
createArchiverDataStores(db, GENESIS_BLOCK_HEADER_HASH),
|
|
30
|
+
undefined,
|
|
31
|
+
BlockHeader.empty(),
|
|
32
|
+
GENESIS_BLOCK_HEADER_HASH,
|
|
33
|
+
new Fr(GENESIS_ARCHIVE_ROOT),
|
|
34
|
+
);
|
|
178
35
|
}
|
|
179
36
|
|
|
180
|
-
public
|
|
181
|
-
|
|
37
|
+
public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
|
|
38
|
+
await this.updater.addCheckpoints(checkpoints, result);
|
|
182
39
|
}
|
|
183
40
|
|
|
184
|
-
public
|
|
185
|
-
throw new Error('TXE Archiver does not implement "
|
|
41
|
+
public getRollupAddress(): Promise<EthAddress> {
|
|
42
|
+
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
186
43
|
}
|
|
187
44
|
|
|
188
|
-
public
|
|
189
|
-
throw new Error('TXE Archiver does not implement "
|
|
45
|
+
public getRegistryAddress(): Promise<EthAddress> {
|
|
46
|
+
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
190
47
|
}
|
|
191
48
|
|
|
192
|
-
public
|
|
193
|
-
throw new Error('TXE Archiver does not implement "
|
|
49
|
+
public getL1Constants(): Promise<L1RollupConstants> {
|
|
50
|
+
throw new Error('TXE Archiver does not implement "getL1Constants"');
|
|
194
51
|
}
|
|
195
52
|
|
|
196
|
-
public
|
|
197
|
-
|
|
53
|
+
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
54
|
+
return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
|
|
198
55
|
}
|
|
199
56
|
|
|
200
|
-
public
|
|
201
|
-
throw new Error('TXE Archiver does not implement "
|
|
57
|
+
public getL1Timestamp(): Promise<bigint | undefined> {
|
|
58
|
+
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
202
59
|
}
|
|
203
60
|
|
|
204
61
|
public async getL2Tips(): Promise<L2Tips> {
|
|
205
62
|
// In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
|
|
206
63
|
// and 'finalized' to the latest block.
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
64
|
+
const latestBlockNumber = await this.stores.blocks.getLatestL2BlockNumber();
|
|
65
|
+
if (latestBlockNumber === 0) {
|
|
66
|
+
throw new Error('L2Tips requested from TXE Archiver but no block found');
|
|
67
|
+
}
|
|
68
|
+
const latestBlockData = await this.stores.blocks.getBlockData({ number: latestBlockNumber });
|
|
69
|
+
if (!latestBlockData) {
|
|
209
70
|
throw new Error('L2Tips requested from TXE Archiver but no block header found');
|
|
210
71
|
}
|
|
211
72
|
|
|
212
|
-
const number =
|
|
213
|
-
const hash =
|
|
73
|
+
const number = latestBlockData.header.globalVariables.blockNumber;
|
|
74
|
+
const hash = latestBlockData.blockHash.toString();
|
|
75
|
+
|
|
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 checkpoint = await this.stores.blocks.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
79
|
+
if (checkpoint.length === 0) {
|
|
80
|
+
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
81
|
+
}
|
|
82
|
+
const blockId: L2BlockId = { number, hash };
|
|
83
|
+
const checkpointId: CheckpointId = {
|
|
84
|
+
number: checkpoint[0].checkpointNumber,
|
|
85
|
+
hash: checkpoint[0].header.hash().toString(),
|
|
86
|
+
};
|
|
87
|
+
const tipId: L2TipId = { block: blockId, checkpoint: checkpointId };
|
|
214
88
|
return {
|
|
215
|
-
|
|
216
|
-
proven:
|
|
217
|
-
finalized:
|
|
89
|
+
proposed: blockId,
|
|
90
|
+
proven: tipId,
|
|
91
|
+
finalized: tipId,
|
|
92
|
+
checkpointed: tipId,
|
|
93
|
+
proposedCheckpoint: tipId,
|
|
218
94
|
};
|
|
219
95
|
}
|
|
220
96
|
|
|
221
|
-
public
|
|
222
|
-
throw new Error('TXE Archiver does not implement "
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
226
|
-
return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
public syncImmediate(): Promise<void> {
|
|
230
|
-
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
public getContract(_address: AztecAddress, _timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined> {
|
|
234
|
-
throw new Error('TXE Archiver does not implement "getContract"');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public getRollupAddress(): Promise<EthAddress> {
|
|
238
|
-
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
public getRegistryAddress(): Promise<EthAddress> {
|
|
242
|
-
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public getL1Timestamp(): Promise<bigint> {
|
|
246
|
-
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
97
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
98
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
247
99
|
}
|
|
248
100
|
|
|
249
|
-
public
|
|
250
|
-
|
|
101
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
102
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
251
103
|
}
|
|
252
104
|
|
|
253
|
-
public
|
|
254
|
-
|
|
105
|
+
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
106
|
+
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
255
107
|
}
|
|
256
108
|
|
|
257
|
-
|
|
258
|
-
throw new Error('
|
|
259
|
-
}
|
|
260
|
-
getPublishedBlockByArchive(_archive: Fr): Promise<PublishedL2Block | undefined> {
|
|
261
|
-
throw new Error('Method not implemented.');
|
|
109
|
+
public syncImmediate(): Promise<void> {
|
|
110
|
+
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
262
111
|
}
|
|
263
112
|
}
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import type { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type {
|
|
3
3
|
AuthRequest,
|
|
4
4
|
ENR,
|
|
5
5
|
P2P,
|
|
6
6
|
P2PBlockReceivedCallback,
|
|
7
|
+
P2PCheckpointAttestationCallback,
|
|
8
|
+
P2PCheckpointReceivedCallback,
|
|
7
9
|
P2PConfig,
|
|
10
|
+
P2PDuplicateAttestationCallback,
|
|
11
|
+
P2PDuplicateProposalCallback,
|
|
8
12
|
P2PSyncState,
|
|
9
13
|
PeerId,
|
|
10
14
|
ReqRespSubProtocol,
|
|
11
15
|
ReqRespSubProtocolHandler,
|
|
12
|
-
ReqRespSubProtocolValidators,
|
|
13
16
|
StatusMessage,
|
|
14
17
|
} from '@aztec/p2p';
|
|
15
18
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
16
|
-
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
17
|
-
import type {
|
|
18
|
-
|
|
19
|
+
import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type {
|
|
21
|
+
BlockProposal,
|
|
22
|
+
CheckpointAttestation,
|
|
23
|
+
CheckpointProposal,
|
|
24
|
+
CheckpointProposalCore,
|
|
25
|
+
TopicType,
|
|
26
|
+
} from '@aztec/stdlib/p2p';
|
|
27
|
+
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
19
28
|
|
|
20
29
|
export class DummyP2P implements P2P {
|
|
21
|
-
public
|
|
22
|
-
return Promise.resolve();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public validate(_txs: Tx[]): Promise<void> {
|
|
30
|
+
public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
|
|
26
31
|
return Promise.resolve();
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -42,14 +47,34 @@ export class DummyP2P implements P2P {
|
|
|
42
47
|
throw new Error('DummyP2P does not implement "getPeers"');
|
|
43
48
|
}
|
|
44
49
|
|
|
50
|
+
public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
|
|
51
|
+
return Promise.resolve(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
public broadcastProposal(_proposal: BlockProposal): Promise<void> {
|
|
46
55
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
47
56
|
}
|
|
48
57
|
|
|
58
|
+
public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
|
|
59
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
63
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
|
|
50
67
|
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
51
68
|
}
|
|
52
69
|
|
|
70
|
+
public registerValidatorCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
71
|
+
throw new Error('DummyP2P does not implement "registerValidatorCheckpointProposalHandler"');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public registerAllNodesCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
75
|
+
throw new Error('DummyP2P does not implement "registerAllNodesCheckpointProposalHandler"');
|
|
76
|
+
}
|
|
77
|
+
|
|
53
78
|
public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
54
79
|
throw new Error('DummyP2P does not implement "requestTxs"');
|
|
55
80
|
}
|
|
@@ -62,8 +87,8 @@ export class DummyP2P implements P2P {
|
|
|
62
87
|
throw new Error('DummyP2P does not implement "sendTx"');
|
|
63
88
|
}
|
|
64
89
|
|
|
65
|
-
public
|
|
66
|
-
throw new Error('DummyP2P does not implement "
|
|
90
|
+
public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
|
|
91
|
+
throw new Error('DummyP2P does not implement "handleFailedExecution"');
|
|
67
92
|
}
|
|
68
93
|
|
|
69
94
|
public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
|
|
@@ -88,6 +113,10 @@ export class DummyP2P implements P2P {
|
|
|
88
113
|
throw new Error('DummyP2P does not implement "iteratePendingTxs"');
|
|
89
114
|
}
|
|
90
115
|
|
|
116
|
+
public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
|
|
117
|
+
throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
|
|
118
|
+
}
|
|
119
|
+
|
|
91
120
|
public getPendingTxCount(): Promise<number> {
|
|
92
121
|
throw new Error('DummyP2P does not implement "getPendingTxCount"');
|
|
93
122
|
}
|
|
@@ -116,20 +145,30 @@ export class DummyP2P implements P2P {
|
|
|
116
145
|
throw new Error('DummyP2P does not implement "isP2PClient"');
|
|
117
146
|
}
|
|
118
147
|
|
|
148
|
+
public getTxProvider(): ITxProvider {
|
|
149
|
+
throw new Error('DummyP2P does not implement "getTxProvider"');
|
|
150
|
+
}
|
|
151
|
+
|
|
119
152
|
public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
120
153
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
121
154
|
}
|
|
122
155
|
|
|
123
|
-
public
|
|
124
|
-
|
|
156
|
+
public getCheckpointAttestationsForSlot(
|
|
157
|
+
_slot: SlotNumber,
|
|
158
|
+
_proposalPayloadHash?: CheckpointProposalHash,
|
|
159
|
+
): Promise<CheckpointAttestation[]> {
|
|
160
|
+
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
125
161
|
}
|
|
126
162
|
|
|
127
|
-
public
|
|
128
|
-
|
|
163
|
+
public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
164
|
+
throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
|
|
129
165
|
}
|
|
130
166
|
|
|
131
|
-
public
|
|
132
|
-
|
|
167
|
+
public getProposalsForSlot(_slot: SlotNumber): Promise<{
|
|
168
|
+
blockProposals: BlockProposal[];
|
|
169
|
+
checkpointProposals: CheckpointProposalCore[];
|
|
170
|
+
}> {
|
|
171
|
+
return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
|
|
133
172
|
}
|
|
134
173
|
|
|
135
174
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -152,14 +191,6 @@ export class DummyP2P implements P2P {
|
|
|
152
191
|
throw new Error('DummyP2P does not implement "sync"');
|
|
153
192
|
}
|
|
154
193
|
|
|
155
|
-
public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
156
|
-
throw new Error('DummyP2P does not implement "requestTxsByHash"');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
|
|
160
|
-
throw new Error('DummyP2P does not implement "getTxs"');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
194
|
public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
164
195
|
throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
|
|
165
196
|
}
|
|
@@ -168,10 +199,6 @@ export class DummyP2P implements P2P {
|
|
|
168
199
|
throw new Error('DummyP2P does not implement "hasTxsInPool"');
|
|
169
200
|
}
|
|
170
201
|
|
|
171
|
-
public addTxsToPool(_txs: Tx[]): Promise<number> {
|
|
172
|
-
throw new Error('DummyP2P does not implement "addTxs"');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
202
|
public getSyncedLatestBlockNum(): Promise<number> {
|
|
176
203
|
throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
|
|
177
204
|
}
|
|
@@ -184,15 +211,15 @@ export class DummyP2P implements P2P {
|
|
|
184
211
|
throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
|
|
185
212
|
}
|
|
186
213
|
|
|
187
|
-
|
|
188
|
-
throw new Error('DummyP2P does not implement "
|
|
214
|
+
protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
|
|
215
|
+
throw new Error('DummyP2P does not implement "protectTxs".');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
|
|
219
|
+
return Promise.resolve();
|
|
189
220
|
}
|
|
190
221
|
|
|
191
|
-
addReqRespSubProtocol(
|
|
192
|
-
_subProtocol: ReqRespSubProtocol,
|
|
193
|
-
_handler: ReqRespSubProtocolHandler,
|
|
194
|
-
_validator?: ReqRespSubProtocolValidators[ReqRespSubProtocol],
|
|
195
|
-
): Promise<void> {
|
|
222
|
+
addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
196
223
|
throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
|
|
197
224
|
}
|
|
198
225
|
handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
|
|
@@ -201,4 +228,20 @@ export class DummyP2P implements P2P {
|
|
|
201
228
|
|
|
202
229
|
//This is no-op
|
|
203
230
|
public registerThisValidatorAddresses(_address: EthAddress[]): void {}
|
|
231
|
+
|
|
232
|
+
public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
|
|
233
|
+
throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
|
|
237
|
+
throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
|
|
241
|
+
throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
|
|
245
|
+
throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
|
|
246
|
+
}
|
|
204
247
|
}
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
1
2
|
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
2
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
|
+
import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
|
|
5
7
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
6
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
type CheckpointGlobalVariables,
|
|
10
|
+
type FeeProvider,
|
|
11
|
+
type GlobalVariableBuilder,
|
|
12
|
+
GlobalVariables,
|
|
13
|
+
} from '@aztec/stdlib/tx';
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
/** Simple FeeProvider for TXE that returns zero fees. */
|
|
16
|
+
export class TXEFeeProvider implements FeeProvider {
|
|
17
|
+
public getCurrentMinFees(): Promise<GasFees> {
|
|
10
18
|
return Promise.resolve(new GasFees(0, 0));
|
|
11
19
|
}
|
|
12
20
|
|
|
21
|
+
public getPredictedMinFees(): Promise<GasFees[]> {
|
|
22
|
+
return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
13
27
|
public buildGlobalVariables(
|
|
14
28
|
_blockNumber: BlockNumber,
|
|
15
29
|
_coinbase: EthAddress,
|
|
@@ -23,6 +37,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
23
37
|
_coinbase: EthAddress,
|
|
24
38
|
_feeRecipient: AztecAddress,
|
|
25
39
|
_slotNumber: SlotNumber,
|
|
40
|
+
_simulationOverridesPlan?: SimulationOverridesPlan,
|
|
26
41
|
): Promise<CheckpointGlobalVariables> {
|
|
27
42
|
const vars = makeGlobalVariables();
|
|
28
43
|
return Promise.resolve({
|