@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.
@@ -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,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,mB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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.enqueuedPublicFunctionCalls, tx.publicTeardownFunctionCall);
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":"AAEA,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;CAoGtD"}
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 { MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
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.#hasCorrectExecutionRequests(tx);
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 #hasCorrectExecutionRequests(tx) {
12
- const callRequests = [
13
- ...tx.data.getRevertiblePublicCallRequests(),
14
- ...tx.data.getNonRevertiblePublicCallRequests()
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
- 'Wrong number of execution requests for public calls'
19
+ reason
22
20
  ]
23
21
  };
24
22
  }
25
- if (tx.getTotalPublicArgsCount() > MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS) {
26
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because the total length of args to public enqueued calls is greater than ${MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS}`);
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
- 'Too many args in total to enqueued public calls'
29
+ reason
31
30
  ]
32
31
  };
33
32
  }
34
- const invalidExecutionRequestIndex = (await Promise.all(tx.enqueuedPublicFunctionCalls.map(async (execRequest, i)=>!await execRequest.isForCallRequest(callRequests[i])))).findIndex(Boolean);
35
- if (invalidExecutionRequestIndex !== -1) {
36
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of incorrect execution requests for public call at index ${invalidExecutionRequestIndex}.`);
37
- return {
38
- result: 'invalid',
39
- reason: [
40
- 'Incorrect execution request for public call'
41
- ]
42
- };
43
- }
44
- const teardownCallRequest = tx.data.getTeardownPublicCallRequest();
45
- const isInvalidTeardownExecutionRequest = !teardownCallRequest && !tx.publicTeardownFunctionCall.isEmpty() || teardownCallRequest && !await tx.publicTeardownFunctionCall.isForCallRequest(teardownCallRequest);
46
- if (isInvalidTeardownExecutionRequest) {
47
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of incorrect teardown execution requests.`);
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.0",
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.0",
69
- "@aztec/epoch-cache": "0.82.0",
70
- "@aztec/foundation": "0.82.0",
71
- "@aztec/kv-store": "0.82.0",
72
- "@aztec/noir-protocol-circuits-types": "0.82.0",
73
- "@aztec/protocol-contracts": "0.82.0",
74
- "@aztec/stdlib": "0.82.0",
75
- "@aztec/telemetry-client": "0.82.0",
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.0",
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 { MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
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.#hasCorrectExecutionRequests(tx);
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 #hasCorrectExecutionRequests(tx: Tx): Promise<TxValidationResult> {
15
- const callRequests = [
16
- ...tx.data.getRevertiblePublicCallRequests(),
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: ['Wrong number of execution requests for public calls'] };
23
+ return { result: 'invalid', reason: [reason] };
28
24
  }
29
25
 
30
- if (tx.getTotalPublicArgsCount() > MAX_FR_ARGS_TO_ALL_ENQUEUED_CALLS) {
31
- this.#log.warn(
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
- )} because of incorrect execution requests for public call at index ${invalidExecutionRequestIndex}.`,
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: ['Incorrect execution request for public call'] };
33
+ return { result: 'invalid', reason: [reason] };
52
34
  }
53
35
 
54
- const teardownCallRequest = tx.data.getTeardownPublicCallRequest();
55
- const isInvalidTeardownExecutionRequest =
56
- (!teardownCallRequest && !tx.publicTeardownFunctionCall.isEmpty()) ||
57
- (teardownCallRequest && !(await tx.publicTeardownFunctionCall.isForCallRequest(teardownCallRequest)));
58
- if (isInvalidTeardownExecutionRequest) {
59
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of incorrect teardown execution requests.`);
60
- return { result: 'invalid', reason: ['Incorrect teardown execution request'] };
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' };