@aztec/p2p 0.81.0 → 0.82.1-alpha-testnet.1
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.js +2 -1
- package/dest/config.d.ts +5 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +5 -0
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +26 -33
- package/package.json +10 -10
- package/src/client/factory.ts +1 -1
- package/src/config.ts +10 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +1 -7
- package/src/msg_validators/tx_validator/data_validator.ts +22 -38
package/dest/client/factory.js
CHANGED
|
@@ -11,7 +11,8 @@ import { LibP2PService } from '../services/index.js';
|
|
|
11
11
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
12
12
|
export const createP2PClient = async (clientType, _config, l2BlockSource, proofVerifier, worldStateSynchronizer, epochCache, telemetry = getTelemetryClient(), deps = {})=>{
|
|
13
13
|
let config = {
|
|
14
|
-
..._config
|
|
14
|
+
..._config,
|
|
15
|
+
dataStoreMapSizeKB: _config.p2pStoreMapSizeKb ?? _config.dataStoreMapSizeKB
|
|
15
16
|
};
|
|
16
17
|
const logger = deps.logger ?? createLogger('p2p');
|
|
17
18
|
const store = deps.store ?? await createStore('p2p', 1, config, createLogger('p2p:lmdb-v2'));
|
package/dest/config.d.ts
CHANGED
|
@@ -124,6 +124,10 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
|
|
|
124
124
|
* A list of trusted peers.
|
|
125
125
|
*/
|
|
126
126
|
trustedPeers: string[];
|
|
127
|
+
/**
|
|
128
|
+
* The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKB.
|
|
129
|
+
*/
|
|
130
|
+
p2pStoreMapSizeKb?: number;
|
|
127
131
|
}
|
|
128
132
|
export declare const p2pConfigMappings: ConfigMappingsType<P2PConfig>;
|
|
129
133
|
/**
|
|
@@ -176,5 +180,6 @@ export declare const bootnodeConfigMappings: ConfigMappingsType<Pick<{
|
|
|
176
180
|
peerPenaltyValues: unknown;
|
|
177
181
|
archivedTxLimit: unknown;
|
|
178
182
|
trustedPeers: unknown;
|
|
183
|
+
p2pStoreMapSizeKb: unknown;
|
|
179
184
|
}, "p2pPort" | "p2pIp" | "listenAddress" | "peerIdPrivateKey" | "bootstrapNodes" | "l1ChainId" | "dataDirectory" | "dataStoreMapSizeKB">>;
|
|
180
185
|
//# sourceMappingURL=config.d.ts.map
|
package/dest/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,8BAA8B,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,WAAW;IAC9D;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,6BAA6B,EAAE,OAAO,CAAC;IAEvC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EA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;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,qBAAqB,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,kCAAkC,EAAE,MAAM,CAAC;IAE3C;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,yCAAyC,EAAE,MAAM,CAAC;IAElD;;OAEG;IACH,wCAAwC,EAAE,MAAM,CAAC;IAEjD;;OAEG;IACH,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,sIAAsI;IACtI,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,SAAS,CA4K3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAE/C;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACT,OAAO,GAAG,SAAS,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,eAAe,CAC9E,GACC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC,GAC9C,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,oBAAoB,CAAC,GAC7D,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAYjC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yIAGlC,CAAC"}
|
package/dest/config.js
CHANGED
|
@@ -167,6 +167,11 @@ export const p2pConfigMappings = {
|
|
|
167
167
|
description: 'A list of trusted peers ENRs. Separated by commas.',
|
|
168
168
|
defaultValue: []
|
|
169
169
|
},
|
|
170
|
+
p2pStoreMapSizeKb: {
|
|
171
|
+
env: 'P2P_STORE_MAP_SIZE_KB',
|
|
172
|
+
parseEnv: (val)=>val ? +val : undefined,
|
|
173
|
+
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKB.'
|
|
174
|
+
},
|
|
170
175
|
...p2pReqRespConfigMappings,
|
|
171
176
|
...chainConfigMappings
|
|
172
177
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAG5F,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAInF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,qBAAa,aAAc,YAAW,MAAM;;IA4B1C;;;;;;;OAOG;gBAED,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,iBAAiB,EAC1B,SAAS,GAAE,eAAsC,EACjD,eAAe,GAAE,MAAU,EAC3B,GAAG,SAA8B;IAgB5B,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBnE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB/C,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKvC,gBAAgB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAK/C,WAAW,C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MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBnE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB/C,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKvC,gBAAgB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAK/C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAalF;;;;OAIG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAUjE;;;;OAIG;IACU,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAUzE;;;;OAIG;IACU,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B7C;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCnD;;;OAGG;IACU,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IASvC;;;OAGG;IACU,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKhD;;;;OAIG;YACW,UAAU;CA2BzB"}
|
|
@@ -234,7 +234,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
234
234
|
}
|
|
235
235
|
tailIdx++;
|
|
236
236
|
}
|
|
237
|
-
const archivedTx = new Tx(tx.data, ClientIvcProof.empty(), tx.contractClassLogs, tx.
|
|
237
|
+
const archivedTx = new Tx(tx.data, ClientIvcProof.empty(), tx.contractClassLogs, tx.publicFunctionCalldata);
|
|
238
238
|
const txHash = txHashes[i].toString();
|
|
239
239
|
await this.#archivedTxs.set(txHash, archivedTx.toBuffer());
|
|
240
240
|
await this.#archivedTxIndices.set(headIdx, txHash);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/data_validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/data_validator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjF,qBAAa,eAAgB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAG/C,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmFtD"}
|
|
@@ -1,56 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { computeCalldataHash } from '@aztec/stdlib/hash';
|
|
3
4
|
import { Tx } from '@aztec/stdlib/tx';
|
|
4
5
|
export class DataTxValidator {
|
|
5
6
|
#log = createLogger('p2p:tx_validator:tx_data');
|
|
6
7
|
async validateTx(tx) {
|
|
7
|
-
const execRequestRes = this.#
|
|
8
|
+
const execRequestRes = this.#hasCorrectCalldata(tx);
|
|
8
9
|
// Note: If we ever skip txs here, must change this return statement to account for them.
|
|
9
10
|
return (await execRequestRes).result === 'invalid' ? execRequestRes : this.#hasCorrectContractClassLogs(tx);
|
|
10
11
|
}
|
|
11
|
-
async #
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
];
|
|
16
|
-
if (callRequests.length !== tx.enqueuedPublicFunctionCalls.length) {
|
|
17
|
-
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of mismatch number of execution requests for public calls. Expected ${callRequests.length}. Got ${tx.enqueuedPublicFunctionCalls.length}.`);
|
|
12
|
+
async #hasCorrectCalldata(tx) {
|
|
13
|
+
if (tx.publicFunctionCalldata.length !== tx.numberOfPublicCalls()) {
|
|
14
|
+
const reason = 'Wrong number of calldata for public calls';
|
|
15
|
+
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected ${tx.numberOfPublicCalls()}. Got ${tx.publicFunctionCalldata.length}.`);
|
|
18
16
|
return {
|
|
19
17
|
result: 'invalid',
|
|
20
18
|
reason: [
|
|
21
|
-
|
|
19
|
+
reason
|
|
22
20
|
]
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
|
-
if (tx.
|
|
26
|
-
|
|
23
|
+
if (tx.getTotalPublicCalldataCount() > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
|
|
24
|
+
const reason = 'Total calldata too large for enqueued public calls';
|
|
25
|
+
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected no greater than ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS} fields. Got ${tx.getTotalPublicCalldataCount()}.`);
|
|
27
26
|
return {
|
|
28
27
|
result: 'invalid',
|
|
29
28
|
reason: [
|
|
30
|
-
|
|
29
|
+
reason
|
|
31
30
|
]
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
reason
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
result: 'invalid',
|
|
50
|
-
reason: [
|
|
51
|
-
'Incorrect teardown execution request'
|
|
52
|
-
]
|
|
53
|
-
};
|
|
33
|
+
const callRequests = tx.getPublicCallRequestsWithCalldata();
|
|
34
|
+
for(let i = 0; i < callRequests.length; i++){
|
|
35
|
+
const { request, calldata } = callRequests[i];
|
|
36
|
+
const hash = await computeCalldataHash(calldata);
|
|
37
|
+
if (!hash.equals(request.calldataHash)) {
|
|
38
|
+
const reason = 'Incorrect calldata for public call';
|
|
39
|
+
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Call request index: ${i}.`);
|
|
40
|
+
return {
|
|
41
|
+
result: 'invalid',
|
|
42
|
+
reason: [
|
|
43
|
+
reason
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
54
47
|
}
|
|
55
48
|
return {
|
|
56
49
|
result: 'valid'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1-alpha-testnet.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/constants": "0.
|
|
69
|
-
"@aztec/epoch-cache": "0.
|
|
70
|
-
"@aztec/foundation": "0.
|
|
71
|
-
"@aztec/kv-store": "0.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
73
|
-
"@aztec/protocol-contracts": "0.
|
|
74
|
-
"@aztec/stdlib": "0.
|
|
75
|
-
"@aztec/telemetry-client": "0.
|
|
68
|
+
"@aztec/constants": "0.82.1-alpha-testnet.1",
|
|
69
|
+
"@aztec/epoch-cache": "0.82.1-alpha-testnet.1",
|
|
70
|
+
"@aztec/foundation": "0.82.1-alpha-testnet.1",
|
|
71
|
+
"@aztec/kv-store": "0.82.1-alpha-testnet.1",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.82.1-alpha-testnet.1",
|
|
73
|
+
"@aztec/protocol-contracts": "0.82.1-alpha-testnet.1",
|
|
74
|
+
"@aztec/stdlib": "0.82.1-alpha-testnet.1",
|
|
75
|
+
"@aztec/telemetry-client": "0.82.1-alpha-testnet.1",
|
|
76
76
|
"@chainsafe/discv5": "9.0.0",
|
|
77
77
|
"@chainsafe/enr": "3.0.0",
|
|
78
78
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"xxhash-wasm": "^1.1.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@aztec/archiver": "0.
|
|
104
|
+
"@aztec/archiver": "0.82.1-alpha-testnet.1",
|
|
105
105
|
"@jest/globals": "^29.5.0",
|
|
106
106
|
"@types/jest": "^29.5.0",
|
|
107
107
|
"@types/node": "^18.14.6",
|
package/src/client/factory.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const createP2PClient = async <T extends P2PClientType>(
|
|
|
36
36
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
37
37
|
deps: P2PClientDeps<T> = {},
|
|
38
38
|
) => {
|
|
39
|
-
let config = { ..._config };
|
|
39
|
+
let config = { ..._config, dataStoreMapSizeKB: _config.p2pStoreMapSizeKb ?? _config.dataStoreMapSizeKB };
|
|
40
40
|
const logger = deps.logger ?? createLogger('p2p');
|
|
41
41
|
const store = deps.store ?? (await createStore('p2p', 1, config, createLogger('p2p:lmdb-v2')));
|
|
42
42
|
const archive = await createStore('p2p-archive', 1, config, createLogger('p2p-archive:lmdb-v2'));
|
package/src/config.ts
CHANGED
|
@@ -164,6 +164,11 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig {
|
|
|
164
164
|
* A list of trusted peers.
|
|
165
165
|
*/
|
|
166
166
|
trustedPeers: string[];
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKB.
|
|
170
|
+
*/
|
|
171
|
+
p2pStoreMapSizeKb?: number;
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
@@ -331,6 +336,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
331
336
|
description: 'A list of trusted peers ENRs. Separated by commas.',
|
|
332
337
|
defaultValue: [],
|
|
333
338
|
},
|
|
339
|
+
p2pStoreMapSizeKb: {
|
|
340
|
+
env: 'P2P_STORE_MAP_SIZE_KB',
|
|
341
|
+
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
342
|
+
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKB.',
|
|
343
|
+
},
|
|
334
344
|
...p2pReqRespConfigMappings,
|
|
335
345
|
...chainConfigMappings,
|
|
336
346
|
};
|
|
@@ -292,13 +292,7 @@ export class AztecKVTxPool implements TxPool {
|
|
|
292
292
|
tailIdx++;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
const archivedTx: Tx = new Tx(
|
|
296
|
-
tx.data,
|
|
297
|
-
ClientIvcProof.empty(),
|
|
298
|
-
tx.contractClassLogs,
|
|
299
|
-
tx.enqueuedPublicFunctionCalls,
|
|
300
|
-
tx.publicTeardownFunctionCall,
|
|
301
|
-
);
|
|
295
|
+
const archivedTx: Tx = new Tx(tx.data, ClientIvcProof.empty(), tx.contractClassLogs, tx.publicFunctionCalldata);
|
|
302
296
|
const txHash = txHashes[i].toString();
|
|
303
297
|
await this.#archivedTxs.set(txHash, archivedTx.toBuffer());
|
|
304
298
|
await this.#archivedTxIndices.set(headIdx, txHash);
|
|
@@ -1,63 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { computeCalldataHash } from '@aztec/stdlib/hash';
|
|
3
4
|
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
5
|
|
|
5
6
|
export class DataTxValidator implements TxValidator<Tx> {
|
|
6
7
|
#log = createLogger('p2p:tx_validator:tx_data');
|
|
7
8
|
|
|
8
9
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
9
|
-
const execRequestRes = this.#
|
|
10
|
+
const execRequestRes = this.#hasCorrectCalldata(tx);
|
|
10
11
|
// Note: If we ever skip txs here, must change this return statement to account for them.
|
|
11
12
|
return (await execRequestRes).result === 'invalid' ? execRequestRes : this.#hasCorrectContractClassLogs(tx);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
async #
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
...tx.data.getNonRevertiblePublicCallRequests(),
|
|
18
|
-
];
|
|
19
|
-
if (callRequests.length !== tx.enqueuedPublicFunctionCalls.length) {
|
|
15
|
+
async #hasCorrectCalldata(tx: Tx): Promise<TxValidationResult> {
|
|
16
|
+
if (tx.publicFunctionCalldata.length !== tx.numberOfPublicCalls()) {
|
|
17
|
+
const reason = 'Wrong number of calldata for public calls';
|
|
20
18
|
this.#log.warn(
|
|
21
|
-
`Rejecting tx ${await Tx.getHash(
|
|
22
|
-
tx
|
|
23
|
-
)} because of mismatch number of execution requests for public calls. Expected ${callRequests.length}. Got ${
|
|
24
|
-
tx.enqueuedPublicFunctionCalls.length
|
|
19
|
+
`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected ${tx.numberOfPublicCalls()}. Got ${
|
|
20
|
+
tx.publicFunctionCalldata.length
|
|
25
21
|
}.`,
|
|
26
22
|
);
|
|
27
|
-
return { result: 'invalid', reason: [
|
|
23
|
+
return { result: 'invalid', reason: [reason] };
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
if (tx.
|
|
31
|
-
|
|
32
|
-
`Rejecting tx ${await Tx.getHash(
|
|
33
|
-
tx,
|
|
34
|
-
)} because the total length of args to public enqueued calls is greater than ${MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS}`,
|
|
35
|
-
);
|
|
36
|
-
return { result: 'invalid', reason: ['Too many args in total to enqueued public calls'] };
|
|
37
|
-
}
|
|
38
|
-
const invalidExecutionRequestIndex = (
|
|
39
|
-
await Promise.all(
|
|
40
|
-
tx.enqueuedPublicFunctionCalls.map(
|
|
41
|
-
async (execRequest, i) => !(await execRequest.isForCallRequest(callRequests[i])),
|
|
42
|
-
),
|
|
43
|
-
)
|
|
44
|
-
).findIndex(Boolean);
|
|
45
|
-
if (invalidExecutionRequestIndex !== -1) {
|
|
26
|
+
if (tx.getTotalPublicCalldataCount() > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
|
|
27
|
+
const reason = 'Total calldata too large for enqueued public calls';
|
|
46
28
|
this.#log.warn(
|
|
47
29
|
`Rejecting tx ${await Tx.getHash(
|
|
48
30
|
tx,
|
|
49
|
-
)}
|
|
31
|
+
)}. Reason: ${reason}. Expected no greater than ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS} fields. Got ${tx.getTotalPublicCalldataCount()}.`,
|
|
50
32
|
);
|
|
51
|
-
return { result: 'invalid', reason: [
|
|
33
|
+
return { result: 'invalid', reason: [reason] };
|
|
52
34
|
}
|
|
53
35
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
const callRequests = tx.getPublicCallRequestsWithCalldata();
|
|
37
|
+
for (let i = 0; i < callRequests.length; i++) {
|
|
38
|
+
const { request, calldata } = callRequests[i];
|
|
39
|
+
const hash = await computeCalldataHash(calldata);
|
|
40
|
+
if (!hash.equals(request.calldataHash)) {
|
|
41
|
+
const reason = 'Incorrect calldata for public call';
|
|
42
|
+
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Call request index: ${i}.`);
|
|
43
|
+
return { result: 'invalid', reason: [reason] };
|
|
44
|
+
}
|
|
61
45
|
}
|
|
62
46
|
|
|
63
47
|
return { result: 'valid' };
|