@aztec/p2p 0.84.0-alpha-testnet.1 → 0.84.0-nightly.20250405
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/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +2 -2
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +8 -8
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +3 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +3 -3
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +10 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- package/dest/services/libp2p/libp2p_service.js +1 -1
- package/package.json +12 -12
- package/src/msg_validators/tx_validator/block_header_validator.ts +2 -2
- package/src/msg_validators/tx_validator/data_validator.ts +19 -8
- package/src/msg_validators/tx_validator/double_spend_validator.ts +10 -3
- package/src/msg_validators/tx_validator/gas_validator.ts +10 -3
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/phases_validator.ts +6 -1
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -2
- package/src/services/libp2p/libp2p_service.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_header_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/block_header_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"block_header_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/block_header_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,KAAK,KAAK,EAA6B,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpH,MAAM,WAAW,aAAa;IAC5B,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;CACxE;AAED,qBAAa,sBAAsB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;gBAIhE,aAAa,EAAE,aAAa;IAIlC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAQrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { Tx } from '@aztec/stdlib/tx';
|
|
2
|
+
import { TX_ERROR_BLOCK_HEADER, Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export class BlockHeaderTxValidator {
|
|
4
4
|
#log = createLogger('p2p:tx_validator:tx_block_header');
|
|
5
5
|
#archiveSource;
|
|
@@ -15,7 +15,7 @@ export class BlockHeaderTxValidator {
|
|
|
15
15
|
return {
|
|
16
16
|
result: 'invalid',
|
|
17
17
|
reason: [
|
|
18
|
-
|
|
18
|
+
TX_ERROR_BLOCK_HEADER
|
|
19
19
|
]
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/data_validator.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"data_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/data_validator.ts"],"names":[],"mappings":"AAGA,OAAO,EAQL,EAAE,EACF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,eAAgB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAG/C,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmFtD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { computeCalldataHash } from '@aztec/stdlib/hash';
|
|
4
|
-
import { Tx } from '@aztec/stdlib/tx';
|
|
4
|
+
import { TX_ERROR_CALLDATA_COUNT_MISMATCH, TX_ERROR_CALLDATA_COUNT_TOO_LARGE, TX_ERROR_CONTRACT_CLASS_LOGS, TX_ERROR_CONTRACT_CLASS_LOG_COUNT, TX_ERROR_CONTRACT_CLASS_LOG_LENGTH, TX_ERROR_CONTRACT_CLASS_LOG_SORTING, TX_ERROR_INCORRECT_CALLDATA, Tx } from '@aztec/stdlib/tx';
|
|
5
5
|
export class DataTxValidator {
|
|
6
6
|
#log = createLogger('p2p:tx_validator:tx_data');
|
|
7
7
|
async validateTx(tx) {
|
|
@@ -11,7 +11,7 @@ export class DataTxValidator {
|
|
|
11
11
|
}
|
|
12
12
|
async #hasCorrectCalldata(tx) {
|
|
13
13
|
if (tx.publicFunctionCalldata.length !== tx.numberOfPublicCalls()) {
|
|
14
|
-
const reason =
|
|
14
|
+
const reason = TX_ERROR_CALLDATA_COUNT_MISMATCH;
|
|
15
15
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected ${tx.numberOfPublicCalls()}. Got ${tx.publicFunctionCalldata.length}.`);
|
|
16
16
|
return {
|
|
17
17
|
result: 'invalid',
|
|
@@ -21,7 +21,7 @@ export class DataTxValidator {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
if (tx.getTotalPublicCalldataCount() > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
|
|
24
|
-
const reason =
|
|
24
|
+
const reason = TX_ERROR_CALLDATA_COUNT_TOO_LARGE;
|
|
25
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()}.`);
|
|
26
26
|
return {
|
|
27
27
|
result: 'invalid',
|
|
@@ -35,7 +35,7 @@ export class DataTxValidator {
|
|
|
35
35
|
const { request, calldata } = callRequests[i];
|
|
36
36
|
const hash = await computeCalldataHash(calldata);
|
|
37
37
|
if (!hash.equals(request.calldataHash)) {
|
|
38
|
-
const reason =
|
|
38
|
+
const reason = TX_ERROR_INCORRECT_CALLDATA;
|
|
39
39
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Call request index: ${i}.`);
|
|
40
40
|
return {
|
|
41
41
|
result: 'invalid',
|
|
@@ -57,7 +57,7 @@ export class DataTxValidator {
|
|
|
57
57
|
return {
|
|
58
58
|
result: 'invalid',
|
|
59
59
|
reason: [
|
|
60
|
-
|
|
60
|
+
TX_ERROR_CONTRACT_CLASS_LOG_COUNT
|
|
61
61
|
]
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -70,7 +70,7 @@ export class DataTxValidator {
|
|
|
70
70
|
return {
|
|
71
71
|
result: 'invalid',
|
|
72
72
|
reason: [
|
|
73
|
-
|
|
73
|
+
TX_ERROR_CONTRACT_CLASS_LOG_SORTING
|
|
74
74
|
]
|
|
75
75
|
};
|
|
76
76
|
} else {
|
|
@@ -78,7 +78,7 @@ export class DataTxValidator {
|
|
|
78
78
|
return {
|
|
79
79
|
result: 'invalid',
|
|
80
80
|
reason: [
|
|
81
|
-
|
|
81
|
+
TX_ERROR_CONTRACT_CLASS_LOGS
|
|
82
82
|
]
|
|
83
83
|
};
|
|
84
84
|
}
|
|
@@ -88,7 +88,7 @@ export class DataTxValidator {
|
|
|
88
88
|
return {
|
|
89
89
|
result: 'invalid',
|
|
90
90
|
reason: [
|
|
91
|
-
|
|
91
|
+
TX_ERROR_CONTRACT_CLASS_LOG_LENGTH
|
|
92
92
|
]
|
|
93
93
|
};
|
|
94
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"double_spend_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/double_spend_validator.ts"],"names":[],"mappings":";;AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"double_spend_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/double_spend_validator.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,KAAK,EAIV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC/D;AAED,qBAAa,sBAAsB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;gBAIhE,eAAe,EAAE,eAAe;IAItC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiBrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { Tx } from '@aztec/stdlib/tx';
|
|
2
|
+
import { TX_ERROR_DUPLICATE_NULLIFIER_IN_TX, TX_ERROR_EXISTING_NULLIFIER, Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export class DoubleSpendTxValidator {
|
|
4
4
|
#log = createLogger('p2p:tx_validator:tx_double_spend');
|
|
5
5
|
#nullifierSource;
|
|
@@ -15,7 +15,7 @@ export class DoubleSpendTxValidator {
|
|
|
15
15
|
return {
|
|
16
16
|
result: 'invalid',
|
|
17
17
|
reason: [
|
|
18
|
-
|
|
18
|
+
TX_ERROR_DUPLICATE_NULLIFIER_IN_TX
|
|
19
19
|
]
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -24,7 +24,7 @@ export class DoubleSpendTxValidator {
|
|
|
24
24
|
return {
|
|
25
25
|
result: 'invalid',
|
|
26
26
|
reason: [
|
|
27
|
-
|
|
27
|
+
TX_ERROR_EXISTING_NULLIFIER
|
|
28
28
|
]
|
|
29
29
|
};
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/gas_validator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"gas_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/gas_validator.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAGL,KAAK,EAAE,EAEP,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,cAAe,YAAW,WAAW,CAAC,EAAE,CAAC;;gBAMxC,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO;IAM1F,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyEtD"}
|
|
@@ -2,7 +2,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
3
3
|
import { getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
4
4
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
-
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
5
|
+
import { TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE, TX_ERROR_INSUFFICIENT_FEE_PER_GAS, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
6
6
|
export class GasTxValidator {
|
|
7
7
|
#log = createLogger('sequencer:tx_validator:tx_gas');
|
|
8
8
|
#publicDataSource;
|
|
@@ -18,7 +18,7 @@ export class GasTxValidator {
|
|
|
18
18
|
return Promise.resolve({
|
|
19
19
|
result: 'skipped',
|
|
20
20
|
reason: [
|
|
21
|
-
|
|
21
|
+
TX_ERROR_INSUFFICIENT_FEE_PER_GAS
|
|
22
22
|
]
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -65,7 +65,7 @@ export class GasTxValidator {
|
|
|
65
65
|
return {
|
|
66
66
|
result: 'invalid',
|
|
67
67
|
reason: [
|
|
68
|
-
|
|
68
|
+
TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE
|
|
69
69
|
]
|
|
70
70
|
};
|
|
71
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/metadata_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,
|
|
1
|
+
{"version":3,"file":"metadata_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/metadata_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EACL,KAAK,KAAK,EAKV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,mBAAmB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;IAG7D,OAAO,CAAC,OAAO;IAAM,OAAO,CAAC,aAAa;IAAM,OAAO,CAAC,WAAW;gBAA3D,OAAO,EAAE,EAAE,EAAU,aAAa,EAAE,EAAE,EAAU,WAAW,EAAE,EAAE;IAE7E,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAsDrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { Tx } from '@aztec/stdlib/tx';
|
|
2
|
+
import { TX_ERROR_INCORRECT_CHAIN_ID, TX_ERROR_INCORRECT_ROLLUP_VERSION, TX_ERROR_INVALID_BLOCK_NUMBER, Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export class MetadataTxValidator {
|
|
4
4
|
chainId;
|
|
5
5
|
rollupVersion;
|
|
@@ -14,13 +14,13 @@ export class MetadataTxValidator {
|
|
|
14
14
|
async validateTx(tx) {
|
|
15
15
|
const errors = [];
|
|
16
16
|
if (!await this.#hasCorrectChainId(tx)) {
|
|
17
|
-
errors.push(
|
|
17
|
+
errors.push(TX_ERROR_INCORRECT_CHAIN_ID);
|
|
18
18
|
}
|
|
19
19
|
if (!await this.#hasCorrectRollupVersion(tx)) {
|
|
20
|
-
errors.push(
|
|
20
|
+
errors.push(TX_ERROR_INCORRECT_ROLLUP_VERSION);
|
|
21
21
|
}
|
|
22
22
|
if (!await this.#isValidForBlockNumber(tx)) {
|
|
23
|
-
errors.push(
|
|
23
|
+
errors.push(TX_ERROR_INVALID_BLOCK_NUMBER);
|
|
24
24
|
}
|
|
25
25
|
return errors.length > 0 ? {
|
|
26
26
|
result: 'invalid',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"phases_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/phases_validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAIL,EAAE,EAEF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,iBAAkB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAIZ,OAAO,CAAC,cAAc;IAAoB,OAAO,CAAC,WAAW;IAFxG,OAAO,CAAC,WAAW,CAAoB;gBAE3B,SAAS,EAAE,kBAAkB,EAAU,cAAc,EAAE,cAAc,EAAE,EAAU,WAAW,EAAE,MAAM;IAI1G,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAqCvC,aAAa;CAiD5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
3
|
-
import { Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
3
|
+
import { TX_ERROR_DURING_VALIDATION, TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
export class PhasesTxValidator {
|
|
5
5
|
setupAllowList;
|
|
6
6
|
blockNumber;
|
|
@@ -33,7 +33,7 @@ export class PhasesTxValidator {
|
|
|
33
33
|
return {
|
|
34
34
|
result: 'invalid',
|
|
35
35
|
reason: [
|
|
36
|
-
|
|
36
|
+
TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED
|
|
37
37
|
]
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -41,6 +41,14 @@ export class PhasesTxValidator {
|
|
|
41
41
|
return {
|
|
42
42
|
result: 'valid'
|
|
43
43
|
};
|
|
44
|
+
} catch (err) {
|
|
45
|
+
this.#log.error(`Error validating phases for tx`, err);
|
|
46
|
+
return {
|
|
47
|
+
result: 'invalid',
|
|
48
|
+
reason: [
|
|
49
|
+
TX_ERROR_DURING_VALIDATION
|
|
50
|
+
]
|
|
51
|
+
};
|
|
44
52
|
} finally{
|
|
45
53
|
this.contractsDB.clearContractsForTx();
|
|
46
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_proof_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/tx_proof_validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,
|
|
1
|
+
{"version":3,"file":"tx_proof_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/tx_proof_validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAA0B,EAAE,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEzG,qBAAa,gBAAiB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAG1C,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,6BAA6B;IAErD,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAQtD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { Tx } from '@aztec/stdlib/tx';
|
|
2
|
+
import { TX_ERROR_INVALID_PROOF, Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export class TxProofValidator {
|
|
4
4
|
verifier;
|
|
5
5
|
#log;
|
|
@@ -13,7 +13,7 @@ export class TxProofValidator {
|
|
|
13
13
|
return {
|
|
14
14
|
result: 'invalid',
|
|
15
15
|
reason: [
|
|
16
|
-
|
|
16
|
+
TX_ERROR_INVALID_PROOF
|
|
17
17
|
]
|
|
18
18
|
};
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.84.0-
|
|
3
|
+
"version": "0.84.0-nightly.20250405",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/constants": "0.84.0-
|
|
69
|
-
"@aztec/epoch-cache": "0.84.0-
|
|
70
|
-
"@aztec/foundation": "0.84.0-
|
|
71
|
-
"@aztec/kv-store": "0.84.0-
|
|
72
|
-
"@aztec/noir-contracts.js": "0.84.0-
|
|
73
|
-
"@aztec/noir-protocol-circuits-types": "0.84.0-
|
|
74
|
-
"@aztec/protocol-contracts": "0.84.0-
|
|
75
|
-
"@aztec/simulator": "0.84.0-
|
|
76
|
-
"@aztec/stdlib": "0.84.0-
|
|
77
|
-
"@aztec/telemetry-client": "0.84.0-
|
|
68
|
+
"@aztec/constants": "0.84.0-nightly.20250405",
|
|
69
|
+
"@aztec/epoch-cache": "0.84.0-nightly.20250405",
|
|
70
|
+
"@aztec/foundation": "0.84.0-nightly.20250405",
|
|
71
|
+
"@aztec/kv-store": "0.84.0-nightly.20250405",
|
|
72
|
+
"@aztec/noir-contracts.js": "0.84.0-nightly.20250405",
|
|
73
|
+
"@aztec/noir-protocol-circuits-types": "0.84.0-nightly.20250405",
|
|
74
|
+
"@aztec/protocol-contracts": "0.84.0-nightly.20250405",
|
|
75
|
+
"@aztec/simulator": "0.84.0-nightly.20250405",
|
|
76
|
+
"@aztec/stdlib": "0.84.0-nightly.20250405",
|
|
77
|
+
"@aztec/telemetry-client": "0.84.0-nightly.20250405",
|
|
78
78
|
"@chainsafe/discv5": "9.0.0",
|
|
79
79
|
"@chainsafe/enr": "3.0.0",
|
|
80
80
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"xxhash-wasm": "^1.1.0"
|
|
104
104
|
},
|
|
105
105
|
"devDependencies": {
|
|
106
|
-
"@aztec/archiver": "0.84.0-
|
|
106
|
+
"@aztec/archiver": "0.84.0-nightly.20250405",
|
|
107
107
|
"@jest/globals": "^29.5.0",
|
|
108
108
|
"@types/jest": "^29.5.0",
|
|
109
109
|
"@types/node": "^18.14.6",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { type AnyTx, Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
3
|
+
import { type AnyTx, TX_ERROR_BLOCK_HEADER, Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
export interface ArchiveSource {
|
|
6
6
|
getArchiveIndices: (archives: Fr[]) => Promise<(bigint | undefined)[]>;
|
|
@@ -18,7 +18,7 @@ export class BlockHeaderTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
18
18
|
const [index] = await this.#archiveSource.getArchiveIndices([await tx.data.constants.historicalHeader.hash()]);
|
|
19
19
|
if (index === undefined) {
|
|
20
20
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for referencing an unknown block header`);
|
|
21
|
-
return { result: 'invalid', reason: [
|
|
21
|
+
return { result: 'invalid', reason: [TX_ERROR_BLOCK_HEADER] };
|
|
22
22
|
}
|
|
23
23
|
return { result: 'valid' };
|
|
24
24
|
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { computeCalldataHash } from '@aztec/stdlib/hash';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
TX_ERROR_CALLDATA_COUNT_MISMATCH,
|
|
6
|
+
TX_ERROR_CALLDATA_COUNT_TOO_LARGE,
|
|
7
|
+
TX_ERROR_CONTRACT_CLASS_LOGS,
|
|
8
|
+
TX_ERROR_CONTRACT_CLASS_LOG_COUNT,
|
|
9
|
+
TX_ERROR_CONTRACT_CLASS_LOG_LENGTH,
|
|
10
|
+
TX_ERROR_CONTRACT_CLASS_LOG_SORTING,
|
|
11
|
+
TX_ERROR_INCORRECT_CALLDATA,
|
|
12
|
+
Tx,
|
|
13
|
+
type TxValidationResult,
|
|
14
|
+
type TxValidator,
|
|
15
|
+
} from '@aztec/stdlib/tx';
|
|
5
16
|
|
|
6
17
|
export class DataTxValidator implements TxValidator<Tx> {
|
|
7
18
|
#log = createLogger('p2p:tx_validator:tx_data');
|
|
@@ -14,7 +25,7 @@ export class DataTxValidator implements TxValidator<Tx> {
|
|
|
14
25
|
|
|
15
26
|
async #hasCorrectCalldata(tx: Tx): Promise<TxValidationResult> {
|
|
16
27
|
if (tx.publicFunctionCalldata.length !== tx.numberOfPublicCalls()) {
|
|
17
|
-
const reason =
|
|
28
|
+
const reason = TX_ERROR_CALLDATA_COUNT_MISMATCH;
|
|
18
29
|
this.#log.warn(
|
|
19
30
|
`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected ${tx.numberOfPublicCalls()}. Got ${
|
|
20
31
|
tx.publicFunctionCalldata.length
|
|
@@ -24,7 +35,7 @@ export class DataTxValidator implements TxValidator<Tx> {
|
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
if (tx.getTotalPublicCalldataCount() > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
|
|
27
|
-
const reason =
|
|
38
|
+
const reason = TX_ERROR_CALLDATA_COUNT_TOO_LARGE;
|
|
28
39
|
this.#log.warn(
|
|
29
40
|
`Rejecting tx ${await Tx.getHash(
|
|
30
41
|
tx,
|
|
@@ -38,7 +49,7 @@ export class DataTxValidator implements TxValidator<Tx> {
|
|
|
38
49
|
const { request, calldata } = callRequests[i];
|
|
39
50
|
const hash = await computeCalldataHash(calldata);
|
|
40
51
|
if (!hash.equals(request.calldataHash)) {
|
|
41
|
-
const reason =
|
|
52
|
+
const reason = TX_ERROR_INCORRECT_CALLDATA;
|
|
42
53
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Call request index: ${i}.`);
|
|
43
54
|
return { result: 'invalid', reason: [reason] };
|
|
44
55
|
}
|
|
@@ -56,7 +67,7 @@ export class DataTxValidator implements TxValidator<Tx> {
|
|
|
56
67
|
contractClassLogsHashes.length
|
|
57
68
|
}. Got ${hashedContractClasslogs.length}.`,
|
|
58
69
|
);
|
|
59
|
-
return { result: 'invalid', reason: [
|
|
70
|
+
return { result: 'invalid', reason: [TX_ERROR_CONTRACT_CLASS_LOG_COUNT] };
|
|
60
71
|
}
|
|
61
72
|
for (const [i, logHash] of contractClassLogsHashes.entries()) {
|
|
62
73
|
const hashedLog = hashedContractClasslogs[i];
|
|
@@ -68,14 +79,14 @@ export class DataTxValidator implements TxValidator<Tx> {
|
|
|
68
79
|
tx,
|
|
69
80
|
)} because of mismatched contract class logs indices. Expected ${i} from the kernel's log hashes. Got ${matchingLogIndex} in the tx.`,
|
|
70
81
|
);
|
|
71
|
-
return { result: 'invalid', reason: [
|
|
82
|
+
return { result: 'invalid', reason: [TX_ERROR_CONTRACT_CLASS_LOG_SORTING] };
|
|
72
83
|
} else {
|
|
73
84
|
this.#log.warn(
|
|
74
85
|
`Rejecting tx ${await Tx.getHash(tx)} because of mismatched contract class logs. Expected hash ${
|
|
75
86
|
logHash.value
|
|
76
87
|
} from the kernels. Got ${hashedLog} in the tx.`,
|
|
77
88
|
);
|
|
78
|
-
return { result: 'invalid', reason: [
|
|
89
|
+
return { result: 'invalid', reason: [TX_ERROR_CONTRACT_CLASS_LOGS] };
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
92
|
if (logHash.logHash.length !== tx.contractClassLogs[i].getEmittedLength()) {
|
|
@@ -84,7 +95,7 @@ export class DataTxValidator implements TxValidator<Tx> {
|
|
|
84
95
|
logHash.logHash.length
|
|
85
96
|
} from the kernel's log hashes. Got ${tx.contractClassLogs[i].getEmittedLength()} in the tx.`,
|
|
86
97
|
);
|
|
87
|
-
return { result: 'invalid', reason: [
|
|
98
|
+
return { result: 'invalid', reason: [TX_ERROR_CONTRACT_CLASS_LOG_LENGTH] };
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
return { result: 'valid' };
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type AnyTx,
|
|
4
|
+
TX_ERROR_DUPLICATE_NULLIFIER_IN_TX,
|
|
5
|
+
TX_ERROR_EXISTING_NULLIFIER,
|
|
6
|
+
Tx,
|
|
7
|
+
type TxValidationResult,
|
|
8
|
+
type TxValidator,
|
|
9
|
+
} from '@aztec/stdlib/tx';
|
|
3
10
|
|
|
4
11
|
export interface NullifierSource {
|
|
5
12
|
nullifiersExist: (nullifiers: Buffer[]) => Promise<boolean[]>;
|
|
@@ -20,12 +27,12 @@ export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
20
27
|
const uniqueNullifiers = new Set(nullifiers);
|
|
21
28
|
if (uniqueNullifiers.size !== nullifiers.length) {
|
|
22
29
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for emitting duplicate nullifiers`);
|
|
23
|
-
return { result: 'invalid', reason: [
|
|
30
|
+
return { result: 'invalid', reason: [TX_ERROR_DUPLICATE_NULLIFIER_IN_TX] };
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
if ((await this.#nullifierSource.nullifiersExist(nullifiers.map(n => n.toBuffer()))).some(Boolean)) {
|
|
27
34
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for repeating a nullifier`);
|
|
28
|
-
return { result: 'invalid', reason: [
|
|
35
|
+
return { result: 'invalid', reason: [TX_ERROR_EXISTING_NULLIFIER] };
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
return { result: 'valid' };
|
|
@@ -5,7 +5,14 @@ import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
7
7
|
import type { PublicStateSource } from '@aztec/stdlib/trees';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE,
|
|
10
|
+
TX_ERROR_INSUFFICIENT_FEE_PER_GAS,
|
|
11
|
+
type Tx,
|
|
12
|
+
TxExecutionPhase,
|
|
13
|
+
type TxValidationResult,
|
|
14
|
+
type TxValidator,
|
|
15
|
+
} from '@aztec/stdlib/tx';
|
|
9
16
|
|
|
10
17
|
export class GasTxValidator implements TxValidator<Tx> {
|
|
11
18
|
#log = createLogger('sequencer:tx_validator:tx_gas');
|
|
@@ -21,7 +28,7 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
21
28
|
|
|
22
29
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
23
30
|
if (await this.#shouldSkip(tx)) {
|
|
24
|
-
return Promise.resolve({ result: 'skipped', reason: [
|
|
31
|
+
return Promise.resolve({ result: 'skipped', reason: [TX_ERROR_INSUFFICIENT_FEE_PER_GAS] });
|
|
25
32
|
}
|
|
26
33
|
return this.#validateTxFee(tx);
|
|
27
34
|
}
|
|
@@ -88,7 +95,7 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
88
95
|
balance: balance.toBigInt(),
|
|
89
96
|
feeLimit: feeLimit.toBigInt(),
|
|
90
97
|
});
|
|
91
|
-
return { result: 'invalid', reason: [
|
|
98
|
+
return { result: 'invalid', reason: [TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE] };
|
|
92
99
|
}
|
|
93
100
|
return { result: 'valid' };
|
|
94
101
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type AnyTx,
|
|
5
|
+
TX_ERROR_INCORRECT_CHAIN_ID,
|
|
6
|
+
TX_ERROR_INCORRECT_ROLLUP_VERSION,
|
|
7
|
+
TX_ERROR_INVALID_BLOCK_NUMBER,
|
|
8
|
+
Tx,
|
|
9
|
+
type TxValidationResult,
|
|
10
|
+
type TxValidator,
|
|
11
|
+
} from '@aztec/stdlib/tx';
|
|
4
12
|
|
|
5
13
|
export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
6
14
|
#log = createLogger('p2p:tx_validator:tx_metadata');
|
|
@@ -10,13 +18,13 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
10
18
|
async validateTx(tx: T): Promise<TxValidationResult> {
|
|
11
19
|
const errors = [];
|
|
12
20
|
if (!(await this.#hasCorrectChainId(tx))) {
|
|
13
|
-
errors.push(
|
|
21
|
+
errors.push(TX_ERROR_INCORRECT_CHAIN_ID);
|
|
14
22
|
}
|
|
15
23
|
if (!(await this.#hasCorrectRollupVersion(tx))) {
|
|
16
|
-
errors.push(
|
|
24
|
+
errors.push(TX_ERROR_INCORRECT_ROLLUP_VERSION);
|
|
17
25
|
}
|
|
18
26
|
if (!(await this.#isValidForBlockNumber(tx))) {
|
|
19
|
-
errors.push(
|
|
27
|
+
errors.push(TX_ERROR_INVALID_BLOCK_NUMBER);
|
|
20
28
|
}
|
|
21
29
|
return errors.length > 0 ? { result: 'invalid', reason: errors } : { result: 'valid' };
|
|
22
30
|
}
|
|
@@ -4,6 +4,8 @@ import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
|
4
4
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import {
|
|
6
6
|
type PublicCallRequestWithCalldata,
|
|
7
|
+
TX_ERROR_DURING_VALIDATION,
|
|
8
|
+
TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED,
|
|
7
9
|
Tx,
|
|
8
10
|
TxExecutionPhase,
|
|
9
11
|
type TxValidationResult,
|
|
@@ -42,11 +44,14 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
42
44
|
{ allowList: this.setupAllowList },
|
|
43
45
|
);
|
|
44
46
|
|
|
45
|
-
return { result: 'invalid', reason: [
|
|
47
|
+
return { result: 'invalid', reason: [TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED] };
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
return { result: 'valid' };
|
|
52
|
+
} catch (err) {
|
|
53
|
+
this.#log.error(`Error validating phases for tx`, err);
|
|
54
|
+
return { result: 'invalid', reason: [TX_ERROR_DURING_VALIDATION] };
|
|
50
55
|
} finally {
|
|
51
56
|
this.contractsDB.clearContractsForTx();
|
|
52
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
3
|
+
import { TX_ERROR_INVALID_PROOF, Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
export class TxProofValidator implements TxValidator<Tx> {
|
|
6
6
|
#log = createLogger('p2p:tx_validator:private_proof');
|
|
@@ -10,7 +10,7 @@ export class TxProofValidator implements TxValidator<Tx> {
|
|
|
10
10
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
11
11
|
if (!(await this.verifier.verifyProof(tx))) {
|
|
12
12
|
this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for invalid proof`);
|
|
13
|
-
return { result: 'invalid', reason: [
|
|
13
|
+
return { result: 'invalid', reason: [TX_ERROR_INVALID_PROOF] };
|
|
14
14
|
}
|
|
15
15
|
this.#log.trace(`Accepted ${await Tx.getHash(tx)} with valid proof`);
|
|
16
16
|
return { result: 'valid' };
|
|
@@ -792,7 +792,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
|
|
|
792
792
|
): Promise<ValidationOutcome> {
|
|
793
793
|
const validationPromises = Object.entries(messageValidators).map(async ([name, { validator, severity }]) => {
|
|
794
794
|
const { result } = await validator.validateTx(tx);
|
|
795
|
-
return { name, isValid: result
|
|
795
|
+
return { name, isValid: result !== 'invalid', severity };
|
|
796
796
|
});
|
|
797
797
|
|
|
798
798
|
// A promise that resolves when all validations have been run
|