@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
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/AuthRegistry-HMC7WEOJ.js +3 -0
- package/dest/AuthRegistry-HMC7WEOJ.js.map +7 -0
- package/dest/ContractClassRegistry-TXCDCFNC.js +3 -0
- package/dest/ContractClassRegistry-TXCDCFNC.js.map +7 -0
- package/dest/ContractInstanceRegistry-2TZHWOTT.js +3 -0
- package/dest/ContractInstanceRegistry-2TZHWOTT.js.map +7 -0
- package/dest/FeeJuice-FDF3J2Q5.js +3 -0
- package/dest/FeeJuice-FDF3J2Q5.js.map +7 -0
- package/dest/HandshakeRegistry-C7JF4R54.js +3 -0
- package/dest/HandshakeRegistry-C7JF4R54.js.map +7 -0
- package/dest/MultiCallEntrypoint-IGLO227K.js +3 -0
- package/dest/MultiCallEntrypoint-IGLO227K.js.map +7 -0
- package/dest/SchnorrAccount-KCIHUCXS.js +3 -0
- package/dest/SchnorrAccount-KCIHUCXS.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-PVR6XUSN.js +3 -0
- package/dest/SchnorrInitializerlessAccount-PVR6XUSN.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 +61 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/bin/oracle_test_server.d.ts +3 -0
- package/dest/bin/oracle_test_server.d.ts.map +1 -0
- package/dest/bin/oracle_test_server.js +41 -0
- package/dest/chunk-32UHX7YY.js +3 -0
- package/dest/chunk-32UHX7YY.js.map +7 -0
- package/dest/chunk-FRF5YZEO.js +304 -0
- package/dest/chunk-FRF5YZEO.js.map +7 -0
- package/dest/chunk-O57S6W5S.js +260 -0
- package/dest/chunk-O57S6W5S.js.map +7 -0
- package/dest/constants.d.ts +7 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +10 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +286 -0
- package/dest/index.d.ts +51 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +75 -158
- package/dest/metafile.json +38497 -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 +65 -31
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/default_fixtures.d.ts +9 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/default_fixtures.js +207 -0
- package/dest/oracle/test-resolver/index.d.ts +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +32 -0
- package/dest/oracle/test-resolver/resolver.d.ts +48 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +181 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +41 -17
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +69 -23
- package/dest/oracle/txe_oracle_registry.d.ts +169 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +745 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +66 -30
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +630 -275
- package/dest/oracle/txe_oracle_version.d.ts +17 -0
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_version.js +14 -0
- 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 +112 -213
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +877 -550
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +23 -52
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +76 -99
- package/dest/state_machine/dummy_p2p_client.d.ts +31 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +63 -22
- package/dest/state_machine/global_variable_builder.d.ts +10 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +20 -5
- package/dest/state_machine/index.d.ts +14 -8
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +84 -27
- package/dest/state_machine/mock_epoch_cache.d.ts +29 -12
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +50 -15
- package/dest/state_machine/synchronizer.d.ts +15 -6
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +27 -13
- package/dest/txe_session.d.ts +102 -21
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +440 -76
- package/dest/utils/block_creation.d.ts +22 -7
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +40 -6
- package/dest/utils/encoding.d.ts +192 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +8 -3
- package/dest/utils/expected_failure_error.d.ts +4 -0
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/utils/tx_effect_creation.d.ts +3 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -7
- 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_artifact_resolver.d.ts +37 -0
- package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.js +161 -0
- 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 +51 -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 +40 -22
- package/src/bin/check_txe_oracle_version.ts +70 -0
- package/src/bin/index.ts +11 -2
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +13 -0
- package/src/dispatcher_pool.ts +317 -0
- package/src/index.ts +113 -201
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +68 -36
- package/src/oracle/test-resolver/default_fixtures.ts +282 -0
- package/src/oracle/test-resolver/index.ts +44 -0
- package/src/oracle/test-resolver/resolver.ts +245 -0
- package/src/oracle/txe_oracle_public_context.ts +83 -28
- package/src/oracle/txe_oracle_registry.ts +536 -0
- package/src/oracle/txe_oracle_top_level_context.ts +539 -199
- package/src/oracle/txe_oracle_version.ts +17 -0
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +1086 -909
- package/src/state_machine/archiver.ts +82 -115
- package/src/state_machine/dummy_p2p_client.ts +96 -33
- package/src/state_machine/global_variable_builder.ts +28 -9
- package/src/state_machine/index.ts +118 -44
- package/src/state_machine/mock_epoch_cache.ts +63 -23
- package/src/state_machine/synchronizer.ts +36 -14
- package/src/txe_session.ts +719 -125
- package/src/utils/block_creation.ts +51 -15
- package/src/{util → utils}/encoding.ts +9 -3
- package/src/utils/tx_effect_creation.ts +4 -13
- package/src/{util/txe_account_data_provider.ts → utils/txe_account_store.ts} +1 -1
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/utils/txe_public_contract_data_source.ts +60 -0
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -121
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts +0 -4
- 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 -20
- 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 -85
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
|
@@ -1,151 +1,118 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
+
import { CheckpointNumber, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import {
|
|
8
|
+
type CheckpointId,
|
|
9
|
+
GENESIS_BLOCK_HEADER_HASH,
|
|
10
|
+
type L2BlockId,
|
|
11
|
+
type L2TipId,
|
|
12
|
+
type L2Tips,
|
|
13
|
+
type ValidateCheckpointResult,
|
|
14
|
+
} from '@aztec/stdlib/block';
|
|
15
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
16
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
17
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
18
|
+
|
|
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);
|
|
26
|
+
|
|
17
27
|
constructor(db: AztecAsyncKVStore) {
|
|
18
|
-
super(
|
|
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
|
+
);
|
|
19
35
|
}
|
|
20
36
|
|
|
21
|
-
public
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.store.addBlocks(blocks),
|
|
25
|
-
]);
|
|
37
|
+
public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
|
|
38
|
+
await this.updater.addCheckpoints(checkpoints, result);
|
|
39
|
+
}
|
|
26
40
|
|
|
27
|
-
|
|
41
|
+
public getRollupAddress(): Promise<EthAddress> {
|
|
42
|
+
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
33
|
-
*/
|
|
34
|
-
public getBlockNumber(): Promise<number> {
|
|
35
|
-
return this.store.getSynchedL2BlockNumber();
|
|
45
|
+
public getRegistryAddress(): Promise<EthAddress> {
|
|
46
|
+
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
public getProvenBlockNumber(): Promise<number> {
|
|
43
|
-
return this.store.getSynchedL2BlockNumber();
|
|
49
|
+
public getL1Constants(): Promise<L1RollupConstants> {
|
|
50
|
+
// The TXE has no L1, so it serves the empty constants (epochDuration=1) used throughout the TXE state machine
|
|
51
|
+
// (see mock_epoch_cache). The node calls this when assembling a mined tx receipt to derive the epoch number.
|
|
52
|
+
return Promise.resolve(EmptyL1RollupConstants);
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @param number - The block number to return (inclusive).
|
|
49
|
-
* @returns The requested L2 block.
|
|
50
|
-
*/
|
|
51
|
-
public override async getPublishedBlock(number: number): Promise<PublishedL2Block | undefined> {
|
|
52
|
-
// If the number provided is -ve, then return the latest block.
|
|
53
|
-
if (number < 0) {
|
|
54
|
-
number = await this.store.getSynchedL2BlockNumber();
|
|
55
|
-
}
|
|
56
|
-
if (number == 0) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
const blocks = await this.store.getPublishedBlocks(number, 1);
|
|
60
|
-
return blocks.length === 0 ? undefined : blocks[0];
|
|
55
|
+
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
56
|
+
return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* @param number - The block number to return (inclusive).
|
|
66
|
-
* @returns The requested L2 block.
|
|
67
|
-
*/
|
|
68
|
-
public getBlock(number: number | 'latest'): Promise<L2Block | undefined> {
|
|
69
|
-
return this.getPublishedBlock(number != 'latest' ? number : -1).then(block => block?.block);
|
|
59
|
+
public getL1Timestamp(): Promise<bigint | undefined> {
|
|
60
|
+
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (number === 'latest') {
|
|
79
|
-
number = await this.store.getSynchedL2BlockNumber();
|
|
63
|
+
public async getL2Tips(): Promise<L2Tips> {
|
|
64
|
+
// In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
|
|
65
|
+
// and 'finalized' to the latest block.
|
|
66
|
+
const latestBlockNumber = await this.stores.blocks.getLatestL2BlockNumber();
|
|
67
|
+
if (latestBlockNumber === 0) {
|
|
68
|
+
throw new Error('L2Tips requested from TXE Archiver but no block found');
|
|
80
69
|
}
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
const latestBlockData = await this.stores.blocks.getBlockData({ number: latestBlockNumber });
|
|
71
|
+
if (!latestBlockData) {
|
|
72
|
+
throw new Error('L2Tips requested from TXE Archiver but no block header found');
|
|
83
73
|
}
|
|
84
|
-
const headers = await this.store.getBlockHeaders(number, 1);
|
|
85
|
-
return headers.length === 0 ? undefined : headers[0];
|
|
86
|
-
}
|
|
87
74
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public getL2SlotNumber(): Promise<bigint> {
|
|
93
|
-
throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
|
|
94
|
-
}
|
|
75
|
+
const number = latestBlockData.header.globalVariables.blockNumber;
|
|
76
|
+
const hash = latestBlockData.blockHash.toString();
|
|
95
77
|
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
79
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
80
|
+
const checkpoint = await this.stores.blocks.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
81
|
+
if (checkpoint.length === 0) {
|
|
82
|
+
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
83
|
+
}
|
|
84
|
+
const blockId: L2BlockId = { number, hash };
|
|
85
|
+
const checkpointId: CheckpointId = {
|
|
86
|
+
number: checkpoint[0].checkpointNumber,
|
|
87
|
+
hash: checkpoint[0].header.hash().toString(),
|
|
88
|
+
};
|
|
89
|
+
const tipId: L2TipId = { block: blockId, checkpoint: checkpointId };
|
|
90
|
+
return {
|
|
91
|
+
proposed: blockId,
|
|
92
|
+
proven: tipId,
|
|
93
|
+
finalized: tipId,
|
|
94
|
+
checkpointed: tipId,
|
|
95
|
+
};
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
public
|
|
101
|
-
throw new Error('TXE Archiver does not implement "
|
|
98
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
99
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
public
|
|
105
|
-
throw new Error('TXE Archiver does not implement "
|
|
102
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
103
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
public isEpochComplete(_epochNumber:
|
|
106
|
+
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
109
107
|
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
public getL2Tips(): Promise<L2Tips> {
|
|
113
|
-
throw new Error('TXE Archiver does not implement "getL2Tips"');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
public getL1Constants(): Promise<L1RollupConstants> {
|
|
117
|
-
throw new Error('TXE Archiver does not implement "getL2Constants"');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
121
|
-
return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
|
|
122
|
-
}
|
|
123
|
-
|
|
124
110
|
public syncImmediate(): Promise<void> {
|
|
125
111
|
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
126
112
|
}
|
|
127
113
|
|
|
128
|
-
public
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
public getRollupAddress(): Promise<EthAddress> {
|
|
133
|
-
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public getRegistryAddress(): Promise<EthAddress> {
|
|
137
|
-
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public getL1Timestamp(): Promise<bigint> {
|
|
141
|
-
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public isPendingChainInvalid(): Promise<boolean> {
|
|
145
|
-
return Promise.resolve(false);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public override getPendingChainValidationStatus(): Promise<ValidateBlockResult> {
|
|
149
|
-
return Promise.resolve({ valid: true });
|
|
114
|
+
public getL2ToL1MembershipWitness(): Promise<undefined> {
|
|
115
|
+
// TXE doesn't drive the L2-to-L1 message flow through this archiver.
|
|
116
|
+
return Promise.resolve(undefined);
|
|
150
117
|
}
|
|
151
118
|
}
|
|
@@ -1,23 +1,34 @@
|
|
|
1
|
+
import type { CheckpointProposalHash, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type {
|
|
2
3
|
AuthRequest,
|
|
3
4
|
ENR,
|
|
4
5
|
P2P,
|
|
5
6
|
P2PBlockReceivedCallback,
|
|
7
|
+
P2PCheckpointAttestationCallback,
|
|
8
|
+
P2PCheckpointReceivedCallback,
|
|
6
9
|
P2PConfig,
|
|
10
|
+
P2PDuplicateAttestationCallback,
|
|
11
|
+
P2PDuplicateProposalCallback,
|
|
12
|
+
P2POversizedProposalCallback,
|
|
7
13
|
P2PSyncState,
|
|
8
14
|
PeerId,
|
|
9
15
|
ReqRespSubProtocol,
|
|
10
16
|
ReqRespSubProtocolHandler,
|
|
11
|
-
ReqRespSubProtocolValidators,
|
|
12
17
|
StatusMessage,
|
|
13
18
|
} from '@aztec/p2p';
|
|
14
19
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
15
|
-
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
16
|
-
import type {
|
|
17
|
-
|
|
20
|
+
import type { ITxProvider, PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
21
|
+
import type {
|
|
22
|
+
BlockProposal,
|
|
23
|
+
CheckpointAttestation,
|
|
24
|
+
CheckpointProposal,
|
|
25
|
+
CheckpointProposalCore,
|
|
26
|
+
TopicType,
|
|
27
|
+
} from '@aztec/stdlib/p2p';
|
|
28
|
+
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
18
29
|
|
|
19
30
|
export class DummyP2P implements P2P {
|
|
20
|
-
public
|
|
31
|
+
public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
|
|
21
32
|
return Promise.resolve();
|
|
22
33
|
}
|
|
23
34
|
|
|
@@ -37,14 +48,34 @@ export class DummyP2P implements P2P {
|
|
|
37
48
|
throw new Error('DummyP2P does not implement "getPeers"');
|
|
38
49
|
}
|
|
39
50
|
|
|
51
|
+
public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
|
|
52
|
+
return Promise.resolve(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
public broadcastProposal(_proposal: BlockProposal): Promise<void> {
|
|
41
56
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
42
57
|
}
|
|
43
58
|
|
|
59
|
+
public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
|
|
60
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
64
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
|
|
65
|
+
}
|
|
66
|
+
|
|
44
67
|
public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
|
|
45
68
|
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
46
69
|
}
|
|
47
70
|
|
|
71
|
+
public registerValidatorCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
72
|
+
throw new Error('DummyP2P does not implement "registerValidatorCheckpointProposalHandler"');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public registerAllNodesCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
76
|
+
throw new Error('DummyP2P does not implement "registerAllNodesCheckpointProposalHandler"');
|
|
77
|
+
}
|
|
78
|
+
|
|
48
79
|
public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
49
80
|
throw new Error('DummyP2P does not implement "requestTxs"');
|
|
50
81
|
}
|
|
@@ -57,8 +88,8 @@ export class DummyP2P implements P2P {
|
|
|
57
88
|
throw new Error('DummyP2P does not implement "sendTx"');
|
|
58
89
|
}
|
|
59
90
|
|
|
60
|
-
public
|
|
61
|
-
throw new Error('DummyP2P does not implement "
|
|
91
|
+
public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
|
|
92
|
+
throw new Error('DummyP2P does not implement "handleFailedExecution"');
|
|
62
93
|
}
|
|
63
94
|
|
|
64
95
|
public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
|
|
@@ -74,17 +105,27 @@ export class DummyP2P implements P2P {
|
|
|
74
105
|
}
|
|
75
106
|
|
|
76
107
|
public getTxStatus(_txHash: TxHash): Promise<'pending' | 'mined' | undefined> {
|
|
77
|
-
|
|
108
|
+
// In TXE there is no concept of transactions but we need to implement this because of tagging. We return 'mined'
|
|
109
|
+
// tx status for any tx hash.
|
|
110
|
+
return Promise.resolve('mined');
|
|
78
111
|
}
|
|
79
112
|
|
|
80
113
|
public iteratePendingTxs(): AsyncIterableIterator<Tx> {
|
|
81
114
|
throw new Error('DummyP2P does not implement "iteratePendingTxs"');
|
|
82
115
|
}
|
|
83
116
|
|
|
117
|
+
public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
|
|
118
|
+
throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
|
|
119
|
+
}
|
|
120
|
+
|
|
84
121
|
public getPendingTxCount(): Promise<number> {
|
|
85
122
|
throw new Error('DummyP2P does not implement "getPendingTxCount"');
|
|
86
123
|
}
|
|
87
124
|
|
|
125
|
+
public hasEligiblePendingTxs(_minCount: number): Promise<boolean> {
|
|
126
|
+
throw new Error('DummyP2P does not implement "hasEligiblePendingTxs"');
|
|
127
|
+
}
|
|
128
|
+
|
|
88
129
|
public start(): Promise<void> {
|
|
89
130
|
throw new Error('DummyP2P does not implement "start"');
|
|
90
131
|
}
|
|
@@ -109,20 +150,34 @@ export class DummyP2P implements P2P {
|
|
|
109
150
|
throw new Error('DummyP2P does not implement "isP2PClient"');
|
|
110
151
|
}
|
|
111
152
|
|
|
153
|
+
public getTxProvider(): ITxProvider {
|
|
154
|
+
throw new Error('DummyP2P does not implement "getTxProvider"');
|
|
155
|
+
}
|
|
156
|
+
|
|
112
157
|
public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
113
158
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
114
159
|
}
|
|
115
160
|
|
|
116
|
-
public
|
|
117
|
-
|
|
161
|
+
public getCheckpointAttestationsForSlot(
|
|
162
|
+
_slot: SlotNumber,
|
|
163
|
+
_proposalPayloadHash?: CheckpointProposalHash,
|
|
164
|
+
): Promise<CheckpointAttestation[]> {
|
|
165
|
+
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
118
166
|
}
|
|
119
167
|
|
|
120
|
-
public
|
|
121
|
-
|
|
168
|
+
public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
169
|
+
throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public getProposalsForSlot(_slot: SlotNumber): Promise<{
|
|
173
|
+
blockProposals: BlockProposal[];
|
|
174
|
+
checkpointProposals: CheckpointProposalCore[];
|
|
175
|
+
}> {
|
|
176
|
+
return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
|
|
122
177
|
}
|
|
123
178
|
|
|
124
|
-
public
|
|
125
|
-
|
|
179
|
+
public hasCheckpointProposalForSlot(_slot: SlotNumber): Promise<boolean> {
|
|
180
|
+
return Promise.resolve(false);
|
|
126
181
|
}
|
|
127
182
|
|
|
128
183
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -145,14 +200,6 @@ export class DummyP2P implements P2P {
|
|
|
145
200
|
throw new Error('DummyP2P does not implement "sync"');
|
|
146
201
|
}
|
|
147
202
|
|
|
148
|
-
public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
149
|
-
throw new Error('DummyP2P does not implement "requestTxsByHash"');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
|
|
153
|
-
throw new Error('DummyP2P does not implement "getTxs"');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
203
|
public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
157
204
|
throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
|
|
158
205
|
}
|
|
@@ -161,10 +208,6 @@ export class DummyP2P implements P2P {
|
|
|
161
208
|
throw new Error('DummyP2P does not implement "hasTxsInPool"');
|
|
162
209
|
}
|
|
163
210
|
|
|
164
|
-
public addTxsToPool(_txs: Tx[]): Promise<number> {
|
|
165
|
-
throw new Error('DummyP2P does not implement "addTxs"');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
211
|
public getSyncedLatestBlockNum(): Promise<number> {
|
|
169
212
|
throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
|
|
170
213
|
}
|
|
@@ -177,15 +220,15 @@ export class DummyP2P implements P2P {
|
|
|
177
220
|
throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
|
|
178
221
|
}
|
|
179
222
|
|
|
180
|
-
|
|
181
|
-
throw new Error('DummyP2P does not implement "
|
|
223
|
+
protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
|
|
224
|
+
throw new Error('DummyP2P does not implement "protectTxs".');
|
|
182
225
|
}
|
|
183
226
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
): Promise<void> {
|
|
227
|
+
prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
|
|
228
|
+
return Promise.resolve();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
189
232
|
throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
|
|
190
233
|
}
|
|
191
234
|
handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
|
|
@@ -194,4 +237,24 @@ export class DummyP2P implements P2P {
|
|
|
194
237
|
|
|
195
238
|
//This is no-op
|
|
196
239
|
public registerThisValidatorAddresses(_address: EthAddress[]): void {}
|
|
240
|
+
|
|
241
|
+
public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
|
|
242
|
+
throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
public registerOversizedProposalCallback(_callback: P2POversizedProposalCallback): void {
|
|
246
|
+
throw new Error('DummyP2P does not implement "registerOversizedProposalCallback"');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
|
|
250
|
+
throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
public registerCheckpointAttestationCallback(_callback: P2PCheckpointAttestationCallback): void {
|
|
254
|
+
throw new Error('DummyP2P does not implement "registerCheckpointAttestationCallback"');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public hasBlockProposalsForSlot(_slot: SlotNumber): Promise<boolean> {
|
|
258
|
+
throw new Error('DummyP2P does not implement "hasBlockProposalsForSlot"');
|
|
259
|
+
}
|
|
197
260
|
}
|
|
@@ -1,20 +1,39 @@
|
|
|
1
|
+
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { times } from '@aztec/foundation/collection';
|
|
1
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
|
6
|
+
import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
|
|
4
7
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
5
|
-
import {
|
|
8
|
+
import type { CheckpointGlobalVariables, FeeProvider, GlobalVariableBuilder } from '@aztec/stdlib/tx';
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
/** Simple FeeProvider for TXE that returns zero fees. */
|
|
11
|
+
export class TXEFeeProvider implements FeeProvider {
|
|
12
|
+
public getCurrentMinFees(): Promise<GasFees> {
|
|
9
13
|
return Promise.resolve(new GasFees(0, 0));
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
public
|
|
13
|
-
|
|
16
|
+
public getPredictedMinFees(): Promise<GasFees[]> {
|
|
17
|
+
return Promise.resolve(times(FEE_ORACLE_LAG, () => new GasFees(0, 0)));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
22
|
+
public buildCheckpointGlobalVariables(
|
|
14
23
|
_coinbase: EthAddress,
|
|
15
24
|
_feeRecipient: AztecAddress,
|
|
16
|
-
_slotNumber
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
_slotNumber: SlotNumber,
|
|
26
|
+
_simulationOverridesPlan?: SimulationOverridesPlan,
|
|
27
|
+
): Promise<CheckpointGlobalVariables> {
|
|
28
|
+
const vars = makeGlobalVariables();
|
|
29
|
+
return Promise.resolve({
|
|
30
|
+
chainId: vars.chainId,
|
|
31
|
+
version: vars.version,
|
|
32
|
+
slotNumber: vars.slotNumber,
|
|
33
|
+
timestamp: vars.timestamp,
|
|
34
|
+
coinbase: vars.coinbase,
|
|
35
|
+
feeRecipient: vars.feeRecipient,
|
|
36
|
+
gasFees: vars.gasFees,
|
|
37
|
+
});
|
|
19
38
|
}
|
|
20
39
|
}
|