@aztec/p2p 0.82.0 → 0.82.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/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/mem_pools/tx_pool/aztec_kv_tx_pool.ts +1 -7
- package/src/msg_validators/tx_validator/data_validator.ts +22 -38
|
@@ -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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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,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.82.
|
|
3
|
+
"version": "0.82.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.82.
|
|
69
|
-
"@aztec/epoch-cache": "0.82.
|
|
70
|
-
"@aztec/foundation": "0.82.
|
|
71
|
-
"@aztec/kv-store": "0.82.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.82.
|
|
73
|
-
"@aztec/protocol-contracts": "0.82.
|
|
74
|
-
"@aztec/stdlib": "0.82.
|
|
75
|
-
"@aztec/telemetry-client": "0.82.
|
|
68
|
+
"@aztec/constants": "0.82.1",
|
|
69
|
+
"@aztec/epoch-cache": "0.82.1",
|
|
70
|
+
"@aztec/foundation": "0.82.1",
|
|
71
|
+
"@aztec/kv-store": "0.82.1",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.82.1",
|
|
73
|
+
"@aztec/protocol-contracts": "0.82.1",
|
|
74
|
+
"@aztec/stdlib": "0.82.1",
|
|
75
|
+
"@aztec/telemetry-client": "0.82.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.82.
|
|
104
|
+
"@aztec/archiver": "0.82.1",
|
|
105
105
|
"@jest/globals": "^29.5.0",
|
|
106
106
|
"@types/jest": "^29.5.0",
|
|
107
107
|
"@types/node": "^18.14.6",
|
|
@@ -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' };
|