@aztec/txe 0.0.1-commit.023c3e5 → 0.0.1-commit.031e54b
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-PII7Q556.js +3 -0
- package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
- package/dest/FeeJuice-TQV5AQK7.js +3 -0
- package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
- package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
- package/dest/SchnorrAccount-MQXPIZ44.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.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-3VX4QA7B.js +265 -0
- package/dest/chunk-3VX4QA7B.js.map +7 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-FU3LBVE4.js +304 -0
- package/dest/chunk-FU3LBVE4.js.map +7 -0
- package/dest/constants.d.ts +5 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +8 -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 +185 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +71 -157
- package/dest/metafile.json +38352 -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 +56 -30
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
- package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/fixtures.js +39 -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 +33 -0
- package/dest/oracle/test-resolver/resolver.d.ts +34 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +114 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +38 -14
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +55 -13
- package/dest/oracle/txe_oracle_registry.d.ts +147 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +562 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +45 -26
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +243 -80
- 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 +96 -228
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +815 -612
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +6 -5
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +32 -21
- package/dest/state_machine/dummy_p2p_client.d.ts +26 -16
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +44 -20
- 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 +9 -3
- package/dest/state_machine/index.d.ts +10 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +35 -12
- package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +33 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +4 -4
- package/dest/txe_session.d.ts +80 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +240 -43
- package/dest/utils/block_creation.d.ts +1 -1
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +3 -1
- package/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/{util → utils}/txe_account_store.d.ts +1 -1
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- 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/{util → utils}/txe_public_contract_data_source.js +6 -25
- 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 -21
- 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 +10 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +97 -190
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +58 -35
- package/src/oracle/test-resolver/fixtures.ts +84 -0
- package/src/oracle/test-resolver/index.ts +45 -0
- package/src/oracle/test-resolver/resolver.ts +165 -0
- package/src/oracle/txe_oracle_public_context.ts +72 -12
- package/src/oracle/txe_oracle_registry.ts +401 -0
- package/src/oracle/txe_oracle_top_level_context.ts +293 -139
- 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 +1000 -995
- package/src/state_machine/archiver.ts +44 -20
- package/src/state_machine/dummy_p2p_client.ts +70 -32
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +48 -13
- package/src/state_machine/mock_epoch_cache.ts +43 -3
- package/src/state_machine/synchronizer.ts +5 -5
- package/src/txe_session.ts +356 -96
- package/src/utils/block_creation.ts +3 -1
- package/src/{util → utils}/encoding.ts +8 -2
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/{util → utils}/txe_public_contract_data_source.ts +10 -38
- 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_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/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/src/util/txe_contract_store.ts +0 -36
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/dest/{util → utils}/txe_account_store.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
- /package/src/{util → utils}/txe_account_store.ts +0 -0
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { ArchiverDataSourceBase, ArchiverDataStoreUpdater,
|
|
1
|
+
import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, createArchiverDataStores } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
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
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
7
|
-
import
|
|
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';
|
|
8
15
|
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
|
-
import type
|
|
16
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
17
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
10
18
|
|
|
11
19
|
/**
|
|
12
20
|
* TXE Archiver implementation.
|
|
@@ -14,11 +22,16 @@ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
|
14
22
|
* without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
|
|
15
23
|
*/
|
|
16
24
|
export class TXEArchiver extends ArchiverDataSourceBase {
|
|
17
|
-
private readonly updater = new ArchiverDataStoreUpdater(this.
|
|
25
|
+
private readonly updater = new ArchiverDataStoreUpdater(this.stores);
|
|
18
26
|
|
|
19
27
|
constructor(db: AztecAsyncKVStore) {
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
);
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
|
|
@@ -34,7 +47,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
public getL1Constants(): Promise<L1RollupConstants> {
|
|
37
|
-
|
|
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);
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
@@ -48,18 +63,21 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
48
63
|
public async getL2Tips(): Promise<L2Tips> {
|
|
49
64
|
// In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
|
|
50
65
|
// and 'finalized' to the latest block.
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
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');
|
|
69
|
+
}
|
|
70
|
+
const latestBlockData = await this.stores.blocks.getBlockData({ number: latestBlockNumber });
|
|
71
|
+
if (!latestBlockData) {
|
|
53
72
|
throw new Error('L2Tips requested from TXE Archiver but no block header found');
|
|
54
73
|
}
|
|
55
74
|
|
|
56
|
-
const number =
|
|
57
|
-
const hash =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
75
|
+
const number = latestBlockData.header.globalVariables.blockNumber;
|
|
76
|
+
const hash = latestBlockData.blockHash.toString();
|
|
77
|
+
|
|
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);
|
|
63
81
|
if (checkpoint.length === 0) {
|
|
64
82
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
65
83
|
}
|
|
@@ -74,15 +92,16 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
74
92
|
proven: tipId,
|
|
75
93
|
finalized: tipId,
|
|
76
94
|
checkpointed: tipId,
|
|
95
|
+
proposedCheckpoint: tipId,
|
|
77
96
|
};
|
|
78
97
|
}
|
|
79
98
|
|
|
80
|
-
public
|
|
81
|
-
throw new Error('TXE Archiver does not implement "
|
|
99
|
+
public getSyncedL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
100
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2SlotNumber"');
|
|
82
101
|
}
|
|
83
102
|
|
|
84
|
-
public
|
|
85
|
-
throw new Error('TXE Archiver does not implement "
|
|
103
|
+
public getSyncedL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
104
|
+
throw new Error('TXE Archiver does not implement "getSyncedL2EpochNumber"');
|
|
86
105
|
}
|
|
87
106
|
|
|
88
107
|
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
@@ -92,4 +111,9 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
92
111
|
public syncImmediate(): Promise<void> {
|
|
93
112
|
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
94
113
|
}
|
|
114
|
+
|
|
115
|
+
public getL2ToL1MembershipWitness(): Promise<undefined> {
|
|
116
|
+
// TXE doesn't drive the L2-to-L1 message flow through this archiver.
|
|
117
|
+
return Promise.resolve(undefined);
|
|
118
|
+
}
|
|
95
119
|
}
|
|
@@ -1,25 +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,
|
|
7
8
|
P2PCheckpointReceivedCallback,
|
|
8
9
|
P2PConfig,
|
|
10
|
+
P2PDuplicateAttestationCallback,
|
|
11
|
+
P2PDuplicateProposalCallback,
|
|
9
12
|
P2PSyncState,
|
|
10
13
|
PeerId,
|
|
11
14
|
ReqRespSubProtocol,
|
|
12
15
|
ReqRespSubProtocolHandler,
|
|
13
|
-
ReqRespSubProtocolValidators,
|
|
14
16
|
StatusMessage,
|
|
15
17
|
} from '@aztec/p2p';
|
|
16
18
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
17
|
-
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
18
|
-
import type {
|
|
19
|
-
|
|
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';
|
|
20
28
|
|
|
21
29
|
export class DummyP2P implements P2P {
|
|
22
|
-
public
|
|
30
|
+
public validateTxsReceivedInBlockProposal(_txs: Tx[]): Promise<void> {
|
|
23
31
|
return Promise.resolve();
|
|
24
32
|
}
|
|
25
33
|
|
|
@@ -39,6 +47,10 @@ export class DummyP2P implements P2P {
|
|
|
39
47
|
throw new Error('DummyP2P does not implement "getPeers"');
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
public getGossipMeshPeerCount(_topicType: TopicType): Promise<number> {
|
|
51
|
+
return Promise.resolve(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
public broadcastProposal(_proposal: BlockProposal): Promise<void> {
|
|
43
55
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
44
56
|
}
|
|
@@ -55,8 +67,12 @@ export class DummyP2P implements P2P {
|
|
|
55
67
|
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
56
68
|
}
|
|
57
69
|
|
|
58
|
-
public
|
|
59
|
-
throw new Error('DummyP2P does not implement "
|
|
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"');
|
|
60
76
|
}
|
|
61
77
|
|
|
62
78
|
public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
@@ -71,8 +87,8 @@ export class DummyP2P implements P2P {
|
|
|
71
87
|
throw new Error('DummyP2P does not implement "sendTx"');
|
|
72
88
|
}
|
|
73
89
|
|
|
74
|
-
public
|
|
75
|
-
throw new Error('DummyP2P does not implement "
|
|
90
|
+
public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
|
|
91
|
+
throw new Error('DummyP2P does not implement "handleFailedExecution"');
|
|
76
92
|
}
|
|
77
93
|
|
|
78
94
|
public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
|
|
@@ -97,6 +113,10 @@ export class DummyP2P implements P2P {
|
|
|
97
113
|
throw new Error('DummyP2P does not implement "iteratePendingTxs"');
|
|
98
114
|
}
|
|
99
115
|
|
|
116
|
+
public iterateEligiblePendingTxs(): AsyncIterableIterator<Tx> {
|
|
117
|
+
throw new Error('DummyP2P does not implement "iterateEligiblePendingTxs"');
|
|
118
|
+
}
|
|
119
|
+
|
|
100
120
|
public getPendingTxCount(): Promise<number> {
|
|
101
121
|
throw new Error('DummyP2P does not implement "getPendingTxCount"');
|
|
102
122
|
}
|
|
@@ -125,16 +145,30 @@ export class DummyP2P implements P2P {
|
|
|
125
145
|
throw new Error('DummyP2P does not implement "isP2PClient"');
|
|
126
146
|
}
|
|
127
147
|
|
|
148
|
+
public getTxProvider(): ITxProvider {
|
|
149
|
+
throw new Error('DummyP2P does not implement "getTxProvider"');
|
|
150
|
+
}
|
|
151
|
+
|
|
128
152
|
public getTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
129
153
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
130
154
|
}
|
|
131
155
|
|
|
132
|
-
public getCheckpointAttestationsForSlot(
|
|
156
|
+
public getCheckpointAttestationsForSlot(
|
|
157
|
+
_slot: SlotNumber,
|
|
158
|
+
_proposalPayloadHash?: CheckpointProposalHash,
|
|
159
|
+
): Promise<CheckpointAttestation[]> {
|
|
133
160
|
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
134
161
|
}
|
|
135
162
|
|
|
136
|
-
public
|
|
137
|
-
throw new Error('DummyP2P does not implement "
|
|
163
|
+
public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
164
|
+
throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public getProposalsForSlot(_slot: SlotNumber): Promise<{
|
|
168
|
+
blockProposals: BlockProposal[];
|
|
169
|
+
checkpointProposals: CheckpointProposalCore[];
|
|
170
|
+
}> {
|
|
171
|
+
return Promise.resolve({ blockProposals: [], checkpointProposals: [] });
|
|
138
172
|
}
|
|
139
173
|
|
|
140
174
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -157,14 +191,6 @@ export class DummyP2P implements P2P {
|
|
|
157
191
|
throw new Error('DummyP2P does not implement "sync"');
|
|
158
192
|
}
|
|
159
193
|
|
|
160
|
-
public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
161
|
-
throw new Error('DummyP2P does not implement "requestTxsByHash"');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
|
|
165
|
-
throw new Error('DummyP2P does not implement "getTxs"');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
194
|
public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
169
195
|
throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
|
|
170
196
|
}
|
|
@@ -173,10 +199,6 @@ export class DummyP2P implements P2P {
|
|
|
173
199
|
throw new Error('DummyP2P does not implement "hasTxsInPool"');
|
|
174
200
|
}
|
|
175
201
|
|
|
176
|
-
public addTxsToPool(_txs: Tx[]): Promise<number> {
|
|
177
|
-
throw new Error('DummyP2P does not implement "addTxs"');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
202
|
public getSyncedLatestBlockNum(): Promise<number> {
|
|
181
203
|
throw new Error('DummyP2P does not implement "getSyncedLatestBlockNum"');
|
|
182
204
|
}
|
|
@@ -189,15 +211,15 @@ export class DummyP2P implements P2P {
|
|
|
189
211
|
throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
|
|
190
212
|
}
|
|
191
213
|
|
|
192
|
-
|
|
193
|
-
throw new Error('DummyP2P does not implement "
|
|
214
|
+
protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
|
|
215
|
+
throw new Error('DummyP2P does not implement "protectTxs".');
|
|
194
216
|
}
|
|
195
217
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
): Promise<void> {
|
|
218
|
+
prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
|
|
219
|
+
return Promise.resolve();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
addReqRespSubProtocol(_subProtocol: ReqRespSubProtocol, _handler: ReqRespSubProtocolHandler): Promise<void> {
|
|
201
223
|
throw new Error('DummyP2P does not implement "addReqRespSubProtocol".');
|
|
202
224
|
}
|
|
203
225
|
handleAuthRequestFromPeer(_authRequest: AuthRequest, _peerId: PeerId): Promise<StatusMessage> {
|
|
@@ -206,4 +228,20 @@ export class DummyP2P implements P2P {
|
|
|
206
228
|
|
|
207
229
|
//This is no-op
|
|
208
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
|
+
}
|
|
209
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
|
-
|
|
15
|
+
/** Simple FeeProvider for TXE that returns zero fees. */
|
|
16
|
+
export class TXEFeeProvider implements FeeProvider {
|
|
9
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({
|
|
@@ -3,22 +3,24 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
|
3
3
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import type
|
|
7
|
-
import {
|
|
8
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
6
|
+
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
7
|
+
import { MessageContextService } from '@aztec/pxe/simulator';
|
|
8
|
+
import { L2Block, type L2TipsProvider } from '@aztec/stdlib/block';
|
|
9
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
11
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
12
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
13
12
|
|
|
14
13
|
import { TXEArchiver } from './archiver.js';
|
|
15
14
|
import { DummyP2P } from './dummy_p2p_client.js';
|
|
16
|
-
import { TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
15
|
+
import { TXEFeeProvider, TXEGlobalVariablesBuilder } from './global_variable_builder.js';
|
|
17
16
|
import { MockEpochCache } from './mock_epoch_cache.js';
|
|
18
17
|
import { TXESynchronizer } from './synchronizer.js';
|
|
19
18
|
|
|
20
19
|
const VERSION = 1;
|
|
21
20
|
const CHAIN_ID = 1;
|
|
21
|
+
// Hardcoded so the bundled TXE doesn't try to read stdlib's package.json at a relative path
|
|
22
|
+
// that becomes invalid once bundled
|
|
23
|
+
const PACKAGE_VERSION = 'txe';
|
|
22
24
|
|
|
23
25
|
export class TXEStateMachine {
|
|
24
26
|
constructor(
|
|
@@ -26,13 +28,17 @@ export class TXEStateMachine {
|
|
|
26
28
|
public synchronizer: TXESynchronizer,
|
|
27
29
|
public archiver: TXEArchiver,
|
|
28
30
|
public anchorBlockStore: AnchorBlockStore,
|
|
31
|
+
public contractSyncService: ContractSyncService,
|
|
32
|
+
public messageContextService: MessageContextService,
|
|
29
33
|
) {}
|
|
30
34
|
|
|
31
|
-
public static async create(
|
|
32
|
-
|
|
35
|
+
public static async create(
|
|
36
|
+
archiver: TXEArchiver,
|
|
37
|
+
anchorBlockStore: AnchorBlockStore,
|
|
38
|
+
contractStore: ContractStore,
|
|
39
|
+
noteStore: NoteStore,
|
|
40
|
+
) {
|
|
33
41
|
const synchronizer = await TXESynchronizer.create();
|
|
34
|
-
const anchorBlockStore = new AnchorBlockStore(db);
|
|
35
|
-
|
|
36
42
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
37
43
|
|
|
38
44
|
const log = createLogger('txe_node');
|
|
@@ -48,21 +54,47 @@ export class TXEStateMachine {
|
|
|
48
54
|
undefined,
|
|
49
55
|
undefined,
|
|
50
56
|
undefined,
|
|
57
|
+
async () => {},
|
|
51
58
|
VERSION,
|
|
52
59
|
CHAIN_ID,
|
|
53
60
|
new TXEGlobalVariablesBuilder(),
|
|
61
|
+
new TXEFeeProvider(),
|
|
54
62
|
new MockEpochCache(),
|
|
55
|
-
|
|
63
|
+
PACKAGE_VERSION,
|
|
64
|
+
new TestCircuitVerifier(),
|
|
56
65
|
new TestCircuitVerifier(),
|
|
57
66
|
undefined,
|
|
58
67
|
log,
|
|
59
68
|
);
|
|
60
69
|
|
|
61
|
-
|
|
70
|
+
const contractSyncService = new ContractSyncService(
|
|
71
|
+
node,
|
|
72
|
+
contractStore,
|
|
73
|
+
noteStore,
|
|
74
|
+
createLogger('txe:contract_sync'),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const messageContextService = new MessageContextService(node);
|
|
78
|
+
|
|
79
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, messageContextService);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Returns an {@link L2TipsProvider} backed by this node's chain tips. */
|
|
83
|
+
public get l2TipsProvider(): L2TipsProvider {
|
|
84
|
+
const node = this.node;
|
|
85
|
+
return {
|
|
86
|
+
getL2Tips: async () => {
|
|
87
|
+
const tips = await node.getChainTips();
|
|
88
|
+
return { ...tips, proposedCheckpoint: tips.checkpointed };
|
|
89
|
+
},
|
|
90
|
+
};
|
|
62
91
|
}
|
|
63
92
|
|
|
64
93
|
public async handleL2Block(block: L2Block) {
|
|
65
|
-
// Create a checkpoint from the block manually
|
|
94
|
+
// Create a checkpoint from the block manually.
|
|
95
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
96
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
97
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
|
|
66
98
|
const checkpoint = new Checkpoint(
|
|
67
99
|
block.archive,
|
|
68
100
|
CheckpointHeader.from({
|
|
@@ -79,7 +111,7 @@ export class TXEStateMachine {
|
|
|
79
111
|
totalManaUsed: block.header.totalManaUsed,
|
|
80
112
|
}),
|
|
81
113
|
[block],
|
|
82
|
-
|
|
114
|
+
checkpointNumber,
|
|
83
115
|
);
|
|
84
116
|
|
|
85
117
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
@@ -91,6 +123,9 @@ export class TXEStateMachine {
|
|
|
91
123
|
),
|
|
92
124
|
[],
|
|
93
125
|
);
|
|
126
|
+
// Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
|
|
127
|
+
this.contractSyncService.wipe();
|
|
128
|
+
|
|
94
129
|
await Promise.all([
|
|
95
130
|
this.synchronizer.handleL2Block(block),
|
|
96
131
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
2
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
|
|
7
8
|
* Since in TXE we don't validate transactions, mock suffices here.
|
|
8
9
|
*/
|
|
9
10
|
export class MockEpochCache implements EpochCacheInterface {
|
|
10
|
-
getCommittee(): Promise<EpochCommitteeInfo> {
|
|
11
|
+
getCommittee(_slot: SlotTag = 'now'): Promise<EpochCommitteeInfo> {
|
|
11
12
|
return Promise.resolve({
|
|
12
13
|
committee: undefined,
|
|
13
14
|
seed: 0n,
|
|
@@ -16,6 +17,22 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
getSlotNow(): SlotNumber {
|
|
21
|
+
return SlotNumber(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getTargetSlot(): SlotNumber {
|
|
25
|
+
return SlotNumber(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getEpochNow(): EpochNumber {
|
|
29
|
+
return EpochNumber.ZERO;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getTargetEpoch(): EpochNumber {
|
|
33
|
+
return EpochNumber.ZERO;
|
|
34
|
+
}
|
|
35
|
+
|
|
19
36
|
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
20
37
|
return {
|
|
21
38
|
epoch: EpochNumber.ZERO,
|
|
@@ -25,15 +42,19 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
25
42
|
};
|
|
26
43
|
}
|
|
27
44
|
|
|
28
|
-
getEpochAndSlotInNextL1Slot(): EpochAndSlot & {
|
|
45
|
+
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
29
46
|
return {
|
|
30
47
|
epoch: EpochNumber.ZERO,
|
|
31
48
|
slot: SlotNumber(0),
|
|
32
49
|
ts: 0n,
|
|
33
|
-
|
|
50
|
+
nowSeconds: 0n,
|
|
34
51
|
};
|
|
35
52
|
}
|
|
36
53
|
|
|
54
|
+
getTargetEpochAndSlotInNextL1Slot(): EpochAndSlot & { nowSeconds: bigint } {
|
|
55
|
+
return this.getEpochAndSlotInNextL1Slot();
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
38
59
|
return '0x00';
|
|
39
60
|
}
|
|
@@ -49,6 +70,13 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
49
70
|
};
|
|
50
71
|
}
|
|
51
72
|
|
|
73
|
+
getTargetAndNextSlot(): { targetSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
74
|
+
return {
|
|
75
|
+
targetSlot: SlotNumber(0),
|
|
76
|
+
nextSlot: SlotNumber(0),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
52
80
|
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
53
81
|
return Promise.resolve(undefined);
|
|
54
82
|
}
|
|
@@ -64,4 +92,16 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
64
92
|
filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
|
|
65
93
|
return Promise.resolve([]);
|
|
66
94
|
}
|
|
95
|
+
|
|
96
|
+
isEscapeHatchOpen(_epoch: EpochNumber): Promise<boolean> {
|
|
97
|
+
return Promise.resolve(false);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isEscapeHatchOpenAtSlot(_slot: SlotTag): Promise<boolean> {
|
|
101
|
+
return Promise.resolve(false);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getL1Constants(): L1RollupConstants {
|
|
105
|
+
return EmptyL1RollupConstants;
|
|
106
|
+
}
|
|
67
107
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
4
|
+
import type { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -18,7 +18,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
18
18
|
constructor(public nativeWorldStateService: NativeWorldStateService) {}
|
|
19
19
|
|
|
20
20
|
static async create() {
|
|
21
|
-
const nativeWorldStateService = await NativeWorldStateService.
|
|
21
|
+
const nativeWorldStateService = await NativeWorldStateService.ephemeral();
|
|
22
22
|
|
|
23
23
|
return new this(nativeWorldStateService);
|
|
24
24
|
}
|
|
@@ -33,12 +33,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Forces an immediate sync to an optionally provided minimum block number
|
|
36
|
+
* Forces an immediate sync to an optionally provided minimum block number.
|
|
37
37
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
38
|
-
* @param
|
|
38
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash.
|
|
39
39
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
40
40
|
*/
|
|
41
|
-
public syncImmediate(_minBlockNumber?: BlockNumber,
|
|
41
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _blockHash?: BlockHash): Promise<BlockNumber> {
|
|
42
42
|
return Promise.resolve(this.blockNumber);
|
|
43
43
|
}
|
|
44
44
|
|