@aztec/p2p 0.0.1-commit.358457c → 0.0.1-commit.381b1a9
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/client/factory.d.ts +4 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +12 -7
- package/dest/client/interface.d.ts +4 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +4 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +9 -27
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -2
- package/dest/config.d.ts +32 -11
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +85 -31
- package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +4 -4
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +30 -7
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +62 -16
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +9 -10
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +38 -30
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +15 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -8
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +13 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +39 -9
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +44 -23
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -7
- package/dest/services/libp2p/libp2p_service.d.ts +6 -7
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +31 -23
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +37 -14
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +11 -17
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +15 -49
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +2 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +2 -1
- package/dest/testbench/p2p_client_testbench_worker.js +7 -6
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +4 -1
- package/package.json +14 -14
- package/src/client/factory.ts +15 -14
- package/src/client/interface.ts +3 -9
- package/src/client/p2p_client.ts +7 -38
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -2
- package/src/config.ts +124 -34
- package/src/mem_pools/tx_pool/priority.ts +4 -4
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
- package/src/mem_pools/tx_pool_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +3 -3
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +89 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +11 -11
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +43 -27
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/factory.ts +22 -2
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +41 -8
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +51 -26
- package/src/services/encoding.ts +5 -6
- package/src/services/libp2p/libp2p_service.ts +30 -21
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +42 -14
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +24 -63
- package/src/test-helpers/make-test-p2p-clients.ts +0 -2
- package/src/test-helpers/mock-pubsub.ts +3 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +1 -0
- package/src/testbench/p2p_client_testbench_worker.ts +3 -6
- package/src/testbench/worker_client_manager.ts +11 -4
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
|
@@ -13,7 +13,7 @@ import { DateProvider, Timer } from '@aztec/foundation/timer';
|
|
|
13
13
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
14
14
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
15
15
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
16
|
-
import {
|
|
16
|
+
import { P2PMessage } from '@aztec/stdlib/p2p';
|
|
17
17
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
18
18
|
import { makeAztecAddress, makeBlockHeader, makeBlockProposal, mockTx } from '@aztec/stdlib/testing';
|
|
19
19
|
import { Tx } from '@aztec/stdlib/tx';
|
|
@@ -31,8 +31,8 @@ const txCache = new Map();
|
|
|
31
31
|
class TestLibP2PService extends LibP2PService {
|
|
32
32
|
disableTxValidation;
|
|
33
33
|
gossipMessageCount = 0;
|
|
34
|
-
constructor(
|
|
35
|
-
super(
|
|
34
|
+
constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:test:libp2p_service'), disableTxValidation = true){
|
|
35
|
+
super(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger);
|
|
36
36
|
this.disableTxValidation = disableTxValidation;
|
|
37
37
|
}
|
|
38
38
|
getGossipMessageCount() {
|
|
@@ -195,7 +195,8 @@ process.on('message', async (msg)=>{
|
|
|
195
195
|
if (type === 'START') {
|
|
196
196
|
const config = {
|
|
197
197
|
...rawConfig,
|
|
198
|
-
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined
|
|
198
|
+
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined,
|
|
199
|
+
priceBumpPercentage: 10n
|
|
199
200
|
};
|
|
200
201
|
workerConfig = config;
|
|
201
202
|
workerTxPool = new InMemoryTxPool();
|
|
@@ -214,8 +215,8 @@ process.on('message', async (msg)=>{
|
|
|
214
215
|
store: kvStore,
|
|
215
216
|
logger: workerLogger
|
|
216
217
|
};
|
|
217
|
-
const client = await createP2PClient(
|
|
218
|
-
const testService = new TestLibP2PService(
|
|
218
|
+
const client = await createP2PClient(config, l2BlockSource, proofVerifier, worldState, epochCache, 'test-p2p-bench-worker', undefined, telemetry, deps);
|
|
219
|
+
const testService = new TestLibP2PService(config, client.p2pService.node, client.p2pService.peerDiscoveryService, client.p2pService.reqresp, client.p2pService.peerManager, client.p2pService.mempools, client.p2pService.archiver, epochCache, proofVerifier, worldState, telemetry, workerLogger, true);
|
|
219
220
|
client.p2pService = testService;
|
|
220
221
|
await client.start();
|
|
221
222
|
for(let i = 0; i < 100; i++){
|
|
@@ -38,6 +38,8 @@ declare class WorkerClientManager {
|
|
|
38
38
|
* Note: We send the raw peerIdPrivateKey string instead of SecretValue
|
|
39
39
|
* because SecretValue.toJSON() returns '[Redacted]', losing the value.
|
|
40
40
|
* The worker must re-wrap it in SecretValue.
|
|
41
|
+
* We also omit priceBumpPercentage since it's a bigint and can't be
|
|
42
|
+
* serialized over IPC (which uses JSON under the hood).
|
|
41
43
|
*/
|
|
42
44
|
private createClientConfig;
|
|
43
45
|
/**
|
|
@@ -93,4 +95,4 @@ declare class WorkerClientManager {
|
|
|
93
95
|
export { WorkerClientManager, testChainConfig };
|
|
94
96
|
export type { DistributionPattern, CollectorType } from './p2p_client_testbench_worker.js';
|
|
95
97
|
export { COLLECTOR_DISPLAY_NAMES } from './p2p_client_testbench_worker.js';
|
|
96
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
98
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ya2VyX2NsaWVudF9tYW5hZ2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGJlbmNoL3dvcmtlcl9jbGllbnRfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1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C,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAsEzF;IAED,OAAO,CAAC,iBAAiB;IAkCzB,OAAO,CAAC,kBAAkB;CAiC3B;AAED,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAC;AAChD,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -45,8 +45,10 @@ class WorkerClientManager {
|
|
|
45
45
|
* Note: We send the raw peerIdPrivateKey string instead of SecretValue
|
|
46
46
|
* because SecretValue.toJSON() returns '[Redacted]', losing the value.
|
|
47
47
|
* The worker must re-wrap it in SecretValue.
|
|
48
|
+
* We also omit priceBumpPercentage since it's a bigint and can't be
|
|
49
|
+
* serialized over IPC (which uses JSON under the hood).
|
|
48
50
|
*/ createClientConfig(clientIndex, port, otherNodes) {
|
|
49
|
-
|
|
51
|
+
const { priceBumpPercentage: _, ...config } = {
|
|
50
52
|
...getP2PDefaultConfig(),
|
|
51
53
|
p2pEnabled: true,
|
|
52
54
|
peerIdPrivateKey: this.peerIdPrivateKeys[clientIndex],
|
|
@@ -58,6 +60,7 @@ class WorkerClientManager {
|
|
|
58
60
|
],
|
|
59
61
|
...this.p2pConfig
|
|
60
62
|
};
|
|
63
|
+
return config;
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Spawns a worker process and returns a promise that resolves when the worker is ready.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.381b1a9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.381b1a9",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.381b1a9",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.381b1a9",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.381b1a9",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.381b1a9",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.381b1a9",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.381b1a9",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.381b1a9",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.381b1a9",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.381b1a9",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.381b1a9",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
108
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
107
|
+
"@aztec/archiver": "0.0.1-commit.381b1a9",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.381b1a9",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
package/src/client/factory.ts
CHANGED
|
@@ -9,7 +9,6 @@ import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
|
9
9
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
10
10
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
11
11
|
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
12
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
13
12
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
13
|
|
|
15
14
|
import { P2PClient } from '../client/p2p_client.js';
|
|
@@ -27,14 +26,14 @@ import { NodeRpcTxSource, type TxSource, createNodeRpcTxSources } from '../servi
|
|
|
27
26
|
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
28
27
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
29
28
|
|
|
30
|
-
export type P2PClientDeps
|
|
29
|
+
export type P2PClientDeps = {
|
|
31
30
|
txPool?: TxPoolV2;
|
|
32
31
|
store?: AztecAsyncKVStore;
|
|
33
32
|
attestationPool?: AttestationPoolApi;
|
|
34
33
|
logger?: Logger;
|
|
35
34
|
txCollectionNodeSources?: TxSource[];
|
|
36
35
|
rpcTxProviders?: AztecNode[];
|
|
37
|
-
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService
|
|
36
|
+
p2pServiceFactory?: (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService>;
|
|
38
37
|
};
|
|
39
38
|
|
|
40
39
|
export const P2P_STORE_NAME = 'p2p';
|
|
@@ -42,8 +41,7 @@ export const P2P_ARCHIVE_STORE_NAME = 'p2p-archive';
|
|
|
42
41
|
export const P2P_PEER_STORE_NAME = 'p2p-peers';
|
|
43
42
|
export const P2P_ATTESTATION_STORE_NAME = 'p2p-attestation';
|
|
44
43
|
|
|
45
|
-
export async function createP2PClient
|
|
46
|
-
clientType: T,
|
|
44
|
+
export async function createP2PClient(
|
|
47
45
|
inputConfig: P2PConfig & DataStoreConfig & ChainConfig,
|
|
48
46
|
archiver: L2BlockSource & ContractDataSource,
|
|
49
47
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
@@ -52,7 +50,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
52
50
|
packageVersion: string,
|
|
53
51
|
dateProvider: DateProvider = new DateProvider(),
|
|
54
52
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
55
|
-
deps: P2PClientDeps
|
|
53
|
+
deps: P2PClientDeps = {},
|
|
56
54
|
) {
|
|
57
55
|
const config = await configureP2PClientAddresses({
|
|
58
56
|
...inputConfig,
|
|
@@ -89,10 +87,16 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
89
87
|
// We accept transactions if they are not expired by the next slot and block number (checked based on the ExpirationTimestamp field)
|
|
90
88
|
const currentBlockNumber = await archiver.getBlockNumber();
|
|
91
89
|
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
|
|
90
|
+
const l1Constants = await archiver.getL1Constants();
|
|
92
91
|
return createTxValidatorForTransactionsEnteringPendingTxPool(
|
|
93
92
|
worldStateSynchronizer,
|
|
94
93
|
nextSlotTimestamp,
|
|
95
94
|
BlockNumber(currentBlockNumber + 1),
|
|
95
|
+
{
|
|
96
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
97
|
+
maxBlockL2Gas: config.validateMaxL2BlockGas,
|
|
98
|
+
maxBlockDAGas: config.validateMaxDABlockGas,
|
|
99
|
+
},
|
|
96
100
|
);
|
|
97
101
|
},
|
|
98
102
|
},
|
|
@@ -101,7 +105,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
101
105
|
maxPendingTxCount: config.maxPendingTxCount,
|
|
102
106
|
archivedTxLimit: config.archivedTxLimit,
|
|
103
107
|
minTxPoolAgeMs: config.minTxPoolAgeMs,
|
|
104
|
-
|
|
108
|
+
priceBumpPercentage: config.priceBumpPercentage,
|
|
105
109
|
},
|
|
106
110
|
dateProvider,
|
|
107
111
|
);
|
|
@@ -111,9 +115,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
111
115
|
attestationPool: deps.attestationPool ?? new AttestationPool(attestationStore, telemetry),
|
|
112
116
|
};
|
|
113
117
|
|
|
114
|
-
const p2pService = await createP2PService
|
|
118
|
+
const p2pService = await createP2PService(
|
|
115
119
|
config,
|
|
116
|
-
clientType,
|
|
117
120
|
archiver,
|
|
118
121
|
proofVerifier,
|
|
119
122
|
worldStateSynchronizer,
|
|
@@ -171,7 +174,6 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
171
174
|
);
|
|
172
175
|
|
|
173
176
|
return new P2PClient(
|
|
174
|
-
clientType,
|
|
175
177
|
store,
|
|
176
178
|
archiver,
|
|
177
179
|
mempools,
|
|
@@ -185,9 +187,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
185
187
|
);
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
async function createP2PService
|
|
190
|
+
async function createP2PService(
|
|
189
191
|
config: P2PConfig & DataStoreConfig,
|
|
190
|
-
clientType: T,
|
|
191
192
|
archiver: L2BlockSource & ContractDataSource,
|
|
192
193
|
proofVerifier: ClientProtocolCircuitVerifier,
|
|
193
194
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -195,7 +196,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
195
196
|
store: AztecAsyncKVStore,
|
|
196
197
|
peerStore: AztecLMDBStoreV2,
|
|
197
198
|
mempools: MemPools,
|
|
198
|
-
p2pServiceFactory: P2PClientDeps
|
|
199
|
+
p2pServiceFactory: P2PClientDeps['p2pServiceFactory'],
|
|
199
200
|
packageVersion: string,
|
|
200
201
|
logger: Logger,
|
|
201
202
|
telemetry: TelemetryClient,
|
|
@@ -211,7 +212,7 @@ async function createP2PService<T extends P2PClientType>(
|
|
|
211
212
|
const peerIdPrivateKey = await getPeerIdPrivateKey(config, store, logger);
|
|
212
213
|
const peerId = await createLibP2PPeerIdFromPrivateKey(peerIdPrivateKey.getValue());
|
|
213
214
|
|
|
214
|
-
const p2pService = await (p2pServiceFactory ?? LibP2PService.new
|
|
215
|
+
const p2pService = await (p2pServiceFactory ?? LibP2PService.new)(config, peerId, {
|
|
215
216
|
packageVersion,
|
|
216
217
|
mempools,
|
|
217
218
|
l2BlockSource: archiver,
|
package/src/client/interface.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress, L2BlockId } from '@aztec/stdlib/block';
|
|
3
|
-
import type { ITxProvider,
|
|
4
|
-
import type {
|
|
5
|
-
BlockProposal,
|
|
6
|
-
CheckpointAttestation,
|
|
7
|
-
CheckpointProposal,
|
|
8
|
-
P2PClientType,
|
|
9
|
-
TopicType,
|
|
10
|
-
} from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { ITxProvider, P2PClient } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal, TopicType } from '@aztec/stdlib/p2p';
|
|
11
5
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
12
6
|
|
|
13
7
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -54,7 +48,7 @@ export interface P2PSyncState {
|
|
|
54
48
|
/**
|
|
55
49
|
* Interface of a P2P client.
|
|
56
50
|
**/
|
|
57
|
-
export type P2P
|
|
51
|
+
export type P2P = P2PClient & {
|
|
58
52
|
/**
|
|
59
53
|
* Broadcasts a block proposal to other peers.
|
|
60
54
|
*
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -18,15 +18,8 @@ import {
|
|
|
18
18
|
type L2TipsStore,
|
|
19
19
|
} from '@aztec/stdlib/block';
|
|
20
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
21
|
-
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
22
21
|
import { type PeerInfo, tryStop } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import {
|
|
24
|
-
type BlockProposal,
|
|
25
|
-
CheckpointAttestation,
|
|
26
|
-
type CheckpointProposal,
|
|
27
|
-
type P2PClientType,
|
|
28
|
-
type TopicType,
|
|
29
|
-
} from '@aztec/stdlib/p2p';
|
|
22
|
+
import { type BlockProposal, CheckpointAttestation, type CheckpointProposal, type TopicType } from '@aztec/stdlib/p2p';
|
|
30
23
|
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
31
24
|
import { Attributes, type TelemetryClient, WithTracer, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
32
25
|
|
|
@@ -59,10 +52,7 @@ import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
|
59
52
|
/**
|
|
60
53
|
* The P2P client implementation.
|
|
61
54
|
*/
|
|
62
|
-
export class P2PClient
|
|
63
|
-
extends WithTracer
|
|
64
|
-
implements P2P, P2P<P2PClientType.Prover>
|
|
65
|
-
{
|
|
55
|
+
export class P2PClient extends WithTracer implements P2P {
|
|
66
56
|
/** The JS promise that will be running to keep the client's data in sync. Can be interrupted if the client is stopped. */
|
|
67
57
|
private runningPromise!: Promise<void>;
|
|
68
58
|
|
|
@@ -94,7 +84,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
94
84
|
private slotMonitor: RunningPromise | undefined;
|
|
95
85
|
|
|
96
86
|
constructor(
|
|
97
|
-
_clientType: T,
|
|
98
87
|
private store: AztecAsyncKVStore,
|
|
99
88
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
100
89
|
mempools: MemPools,
|
|
@@ -121,27 +110,6 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
121
110
|
this.telemetry,
|
|
122
111
|
);
|
|
123
112
|
|
|
124
|
-
// Default to collecting all txs when we see a valid proposal
|
|
125
|
-
// This can be overridden by the validator client to validate, and it will call getTxsForBlockProposal on its own
|
|
126
|
-
// Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
127
|
-
// TODO(palla/txs): We should not trigger a request for txs on a proposal before fully validating it. We need to bring
|
|
128
|
-
// validator-client code into here so we can validate a proposal is reasonable.
|
|
129
|
-
this.registerBlockProposalHandler(async (block, sender) => {
|
|
130
|
-
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
131
|
-
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
132
|
-
const constants = this.txCollection.getConstants();
|
|
133
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
134
|
-
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
135
|
-
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.blockHeader.lastArchive.root);
|
|
136
|
-
if (!parentBlock) {
|
|
137
|
-
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
141
|
-
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
142
|
-
return true;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
113
|
this.l2Tips = new L2TipsKVStore(store, 'p2p_client');
|
|
146
114
|
this.synchedLatestSlot = store.openSingleton('p2p_pool_last_l2_slot');
|
|
147
115
|
}
|
|
@@ -711,10 +679,11 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
711
679
|
if (oldCheckpointNumber <= CheckpointNumber.ZERO) {
|
|
712
680
|
return false;
|
|
713
681
|
}
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
682
|
+
const newCheckpointNumber = newCheckpoint.number;
|
|
683
|
+
const isEpochPrune = oldCheckpointNumber !== newCheckpointNumber;
|
|
684
|
+
if (isEpochPrune) {
|
|
685
|
+
this.log.info(`Detected epoch prune to ${newCheckpointNumber}`, { oldCheckpointNumber, newCheckpointNumber });
|
|
686
|
+
}
|
|
718
687
|
return isEpochPrune;
|
|
719
688
|
}
|
|
720
689
|
|
|
@@ -8,7 +8,7 @@ import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
8
8
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
9
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
11
|
+
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
12
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
@@ -114,7 +114,6 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
client = await createP2PClient(
|
|
117
|
-
P2PClientType.Full,
|
|
118
117
|
config as P2PConfig & DataStoreConfig,
|
|
119
118
|
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
120
119
|
proofVerifier as ClientProtocolCircuitVerifier,
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
|
+
bigintConfigHelper,
|
|
4
5
|
booleanConfigHelper,
|
|
5
6
|
getConfigFromMappings,
|
|
6
7
|
getDefaultConfig,
|
|
@@ -38,7 +39,19 @@ export interface P2PConfig
|
|
|
38
39
|
ChainConfig,
|
|
39
40
|
TxCollectionConfig,
|
|
40
41
|
TxFileStoreConfig,
|
|
41
|
-
Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot'> {
|
|
42
|
+
Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
|
|
43
|
+
/** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
|
|
44
|
+
validateMaxTxsPerBlock?: number;
|
|
45
|
+
|
|
46
|
+
/** Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set. */
|
|
47
|
+
validateMaxTxsPerCheckpoint?: number;
|
|
48
|
+
|
|
49
|
+
/** Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
50
|
+
validateMaxL2BlockGas?: number;
|
|
51
|
+
|
|
52
|
+
/** Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
53
|
+
validateMaxDABlockGas?: number;
|
|
54
|
+
|
|
42
55
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
43
56
|
p2pEnabled: boolean;
|
|
44
57
|
|
|
@@ -150,8 +163,8 @@ export interface P2PConfig
|
|
|
150
163
|
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
151
164
|
p2pStoreMapSizeKb?: number;
|
|
152
165
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
166
|
+
/** Additional entries to extend the default setup allow list. */
|
|
167
|
+
txPublicSetupAllowListExtend: AllowedElement[];
|
|
155
168
|
|
|
156
169
|
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
157
170
|
maxPendingTxCount: number;
|
|
@@ -173,7 +186,10 @@ export interface P2PConfig
|
|
|
173
186
|
/** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
|
|
174
187
|
disableTransactions: boolean;
|
|
175
188
|
|
|
176
|
-
/**
|
|
189
|
+
/** True to simulate discarding transactions. - For testing purposes only*/
|
|
190
|
+
dropTransactions: boolean;
|
|
191
|
+
|
|
192
|
+
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
177
193
|
dropTransactionsProbability: number;
|
|
178
194
|
|
|
179
195
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
@@ -190,11 +206,36 @@ export interface P2PConfig
|
|
|
190
206
|
|
|
191
207
|
/** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
|
|
192
208
|
minTxPoolAgeMs: number;
|
|
209
|
+
|
|
210
|
+
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
211
|
+
priceBumpPercentage: bigint;
|
|
193
212
|
}
|
|
194
213
|
|
|
195
214
|
export const DEFAULT_P2P_PORT = 40400;
|
|
196
215
|
|
|
197
216
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
217
|
+
validateMaxTxsPerBlock: {
|
|
218
|
+
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
219
|
+
description:
|
|
220
|
+
'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
|
|
221
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
222
|
+
},
|
|
223
|
+
validateMaxTxsPerCheckpoint: {
|
|
224
|
+
env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
|
|
225
|
+
description:
|
|
226
|
+
'Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set.',
|
|
227
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
228
|
+
},
|
|
229
|
+
validateMaxL2BlockGas: {
|
|
230
|
+
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
231
|
+
description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
232
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
233
|
+
},
|
|
234
|
+
validateMaxDABlockGas: {
|
|
235
|
+
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
236
|
+
description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
237
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
238
|
+
},
|
|
198
239
|
p2pEnabled: {
|
|
199
240
|
env: 'P2P_ENABLED',
|
|
200
241
|
description: 'A flag dictating whether the P2P subsystem should be enabled.',
|
|
@@ -393,12 +434,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
393
434
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
394
435
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
395
436
|
},
|
|
396
|
-
|
|
437
|
+
txPublicSetupAllowListExtend: {
|
|
397
438
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
398
439
|
parseEnv: (val: string) => parseAllowList(val),
|
|
399
|
-
description:
|
|
440
|
+
description:
|
|
441
|
+
'Additional entries to extend the default setup allow list. Format: I:address:selector[:flags],C:classId:selector[:flags]. Flags: os (onlySelf), rn (rejectNullMsgSender), cl=N (calldataLength), joined with +.',
|
|
400
442
|
printDefault: () =>
|
|
401
|
-
'AuthRegistry
|
|
443
|
+
'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
|
|
402
444
|
},
|
|
403
445
|
maxPendingTxCount: {
|
|
404
446
|
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
@@ -427,6 +469,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
427
469
|
description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
|
|
428
470
|
...numberConfigHelper(3),
|
|
429
471
|
},
|
|
472
|
+
dropTransactions: {
|
|
473
|
+
env: 'P2P_DROP_TX',
|
|
474
|
+
description: 'True to simulate discarding transactions. - For testing purposes only',
|
|
475
|
+
...booleanConfigHelper(false),
|
|
476
|
+
},
|
|
430
477
|
dropTransactionsProbability: {
|
|
431
478
|
env: 'P2P_DROP_TX_CHANCE',
|
|
432
479
|
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
@@ -464,6 +511,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
464
511
|
description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
|
|
465
512
|
...numberConfigHelper(2_000),
|
|
466
513
|
},
|
|
514
|
+
priceBumpPercentage: {
|
|
515
|
+
env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
|
|
516
|
+
description:
|
|
517
|
+
'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
|
|
518
|
+
...bigintConfigHelper(10n),
|
|
519
|
+
},
|
|
467
520
|
...sharedSequencerConfigMappings,
|
|
468
521
|
...p2pReqRespConfigMappings,
|
|
469
522
|
...batchTxRequesterConfigMappings,
|
|
@@ -521,13 +574,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
|
|
|
521
574
|
bootnodeConfigKeys,
|
|
522
575
|
);
|
|
523
576
|
|
|
577
|
+
/**
|
|
578
|
+
* Parses a `+`-separated flags string into validation properties for an allow list entry.
|
|
579
|
+
* Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
580
|
+
*/
|
|
581
|
+
function parseFlags(
|
|
582
|
+
flags: string,
|
|
583
|
+
entry: string,
|
|
584
|
+
): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
|
|
585
|
+
const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
|
|
586
|
+
for (const flag of flags.split('+')) {
|
|
587
|
+
if (flag === 'os') {
|
|
588
|
+
result.onlySelf = true;
|
|
589
|
+
} else if (flag === 'rn') {
|
|
590
|
+
result.rejectNullMsgSender = true;
|
|
591
|
+
} else if (flag.startsWith('cl=')) {
|
|
592
|
+
const n = parseInt(flag.slice(3), 10);
|
|
593
|
+
if (isNaN(n) || n < 0) {
|
|
594
|
+
throw new Error(
|
|
595
|
+
`Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
result.calldataLength = n;
|
|
599
|
+
} else {
|
|
600
|
+
throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return result;
|
|
604
|
+
}
|
|
605
|
+
|
|
524
606
|
/**
|
|
525
607
|
* Parses a string to a list of allowed elements.
|
|
526
|
-
* Each
|
|
527
|
-
* `I:${address}`
|
|
528
|
-
* `
|
|
529
|
-
*
|
|
530
|
-
*
|
|
608
|
+
* Each entry is expected to be of one of the following formats:
|
|
609
|
+
* `I:${address}:${selector}` — instance (contract address) with function selector
|
|
610
|
+
* `C:${classId}:${selector}` — class with function selector
|
|
611
|
+
*
|
|
612
|
+
* An optional flags segment can be appended after the selector:
|
|
613
|
+
* `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
|
|
614
|
+
* where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
531
615
|
*
|
|
532
616
|
* @param value The string to parse
|
|
533
617
|
* @returns A list of allowed elements
|
|
@@ -540,31 +624,37 @@ export function parseAllowList(value: string): AllowedElement[] {
|
|
|
540
624
|
}
|
|
541
625
|
|
|
542
626
|
for (const val of value.split(',')) {
|
|
543
|
-
const
|
|
544
|
-
|
|
627
|
+
const trimmed = val.trim();
|
|
628
|
+
if (!trimmed) {
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
|
|
632
|
+
|
|
633
|
+
if (!selectorString) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
`Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const selector = FunctionSelector.fromString(selectorString);
|
|
640
|
+
const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
|
|
545
641
|
|
|
546
642
|
if (typeString === 'I') {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
} else {
|
|
553
|
-
entries.push({
|
|
554
|
-
address: AztecAddress.fromString(identifierString),
|
|
555
|
-
});
|
|
556
|
-
}
|
|
643
|
+
entries.push({
|
|
644
|
+
address: AztecAddress.fromString(identifierString),
|
|
645
|
+
selector,
|
|
646
|
+
...flags,
|
|
647
|
+
});
|
|
557
648
|
} else if (typeString === 'C') {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
649
|
+
entries.push({
|
|
650
|
+
classId: Fr.fromHexString(identifierString),
|
|
651
|
+
selector,
|
|
652
|
+
...flags,
|
|
653
|
+
});
|
|
654
|
+
} else {
|
|
655
|
+
throw new Error(
|
|
656
|
+
`Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
|
|
657
|
+
);
|
|
568
658
|
}
|
|
569
659
|
}
|
|
570
660
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { minBigint } from '@aztec/foundation/bigint';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
@@ -11,10 +12,9 @@ export function getPendingTxPriority(tx: Tx): string {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
* Returns the priority of a tx.
|
|
15
|
+
* Returns the priority of a tx based on the L2 priority fee only, capped by the max fees per gas.
|
|
15
16
|
*/
|
|
16
17
|
export function getTxPriorityFee(tx: Tx): bigint {
|
|
17
|
-
const priorityFees = tx.getGasSettings()
|
|
18
|
-
|
|
19
|
-
return totalFees;
|
|
18
|
+
const { maxPriorityFeesPerGas: priorityFees, maxFeesPerGas } = tx.getGasSettings();
|
|
19
|
+
return minBigint(maxFeesPerGas.feePerL2Gas, priorityFees.feePerL2Gas);
|
|
20
20
|
}
|