@aztec/sequencer-client 0.67.1 → 0.68.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/sequencer-client.d.ts +3 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +17 -3
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +8 -56
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -2
- package/dest/publisher/index.d.ts +0 -1
- package/dest/publisher/index.d.ts.map +1 -1
- package/dest/publisher/index.js +1 -2
- package/dest/publisher/l1-publisher-metrics.d.ts +5 -2
- package/dest/publisher/l1-publisher-metrics.d.ts.map +1 -1
- package/dest/publisher/l1-publisher-metrics.js +16 -1
- package/dest/publisher/l1-publisher.d.ts +4 -1
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +200 -44
- package/dest/publisher/utils.d.ts +1 -3
- package/dest/publisher/utils.d.ts.map +1 -1
- package/dest/publisher/utils.js +2 -8
- package/dest/sequencer/allowed.d.ts +3 -0
- package/dest/sequencer/allowed.d.ts.map +1 -0
- package/dest/sequencer/allowed.js +34 -0
- package/dest/sequencer/config.d.ts +1 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/metrics.d.ts +2 -0
- package/dest/sequencer/metrics.d.ts.map +1 -1
- package/dest/sequencer/metrics.js +13 -2
- package/dest/sequencer/sequencer.d.ts +14 -11
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +160 -87
- package/dest/sequencer/utils.d.ts +2 -7
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +3 -11
- package/dest/tx_validator/gas_validator.d.ts +3 -4
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +25 -8
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +6 -4
- package/package.json +26 -23
- package/src/client/sequencer-client.ts +25 -5
- package/src/config.ts +10 -60
- package/src/index.ts +1 -1
- package/src/publisher/index.ts +0 -1
- package/src/publisher/l1-publisher-metrics.ts +24 -3
- package/src/publisher/l1-publisher.ts +241 -68
- package/src/publisher/utils.ts +1 -10
- package/src/sequencer/allowed.ts +36 -0
- package/src/sequencer/config.ts +1 -1
- package/src/sequencer/metrics.ts +15 -1
- package/src/sequencer/sequencer.ts +195 -109
- package/src/sequencer/utils.ts +2 -11
- package/src/tx_validator/gas_validator.ts +32 -6
- package/src/tx_validator/tx_validator_factory.ts +11 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Tx, TxExecutionPhase, type TxValidator } from '@aztec/circuit-types';
|
|
2
|
-
import { type AztecAddress, type Fr, FunctionSelector } from '@aztec/circuits.js';
|
|
2
|
+
import { type AztecAddress, type Fr, FunctionSelector, type GasFees } from '@aztec/circuits.js';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { computeFeePayerBalanceStorageSlot, getExecutionRequestsByPhase } from '@aztec/simulator';
|
|
5
5
|
|
|
@@ -12,36 +12,62 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
12
12
|
#log = createLogger('sequencer:tx_validator:tx_gas');
|
|
13
13
|
#publicDataSource: PublicStateSource;
|
|
14
14
|
#feeJuiceAddress: AztecAddress;
|
|
15
|
+
#enforceFees: boolean;
|
|
16
|
+
#gasFees: GasFees;
|
|
15
17
|
|
|
16
|
-
constructor(
|
|
18
|
+
constructor(
|
|
19
|
+
publicDataSource: PublicStateSource,
|
|
20
|
+
feeJuiceAddress: AztecAddress,
|
|
21
|
+
enforceFees: boolean,
|
|
22
|
+
gasFees: GasFees,
|
|
23
|
+
) {
|
|
17
24
|
this.#publicDataSource = publicDataSource;
|
|
18
25
|
this.#feeJuiceAddress = feeJuiceAddress;
|
|
26
|
+
this.#enforceFees = enforceFees;
|
|
27
|
+
this.#gasFees = gasFees;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
async validateTxs(txs: Tx[]): Promise<[validTxs: Tx[], invalidTxs: Tx[]]> {
|
|
30
|
+
async validateTxs(txs: Tx[]): Promise<[validTxs: Tx[], invalidTxs: Tx[], skippedTxs: Tx[]]> {
|
|
22
31
|
const validTxs: Tx[] = [];
|
|
23
32
|
const invalidTxs: Tx[] = [];
|
|
33
|
+
const skippedTxs: Tx[] = [];
|
|
24
34
|
|
|
25
35
|
for (const tx of txs) {
|
|
26
|
-
if (
|
|
36
|
+
if (this.#shouldSkip(tx)) {
|
|
37
|
+
skippedTxs.push(tx);
|
|
38
|
+
} else if (await this.#validateTxFee(tx)) {
|
|
27
39
|
validTxs.push(tx);
|
|
28
40
|
} else {
|
|
29
41
|
invalidTxs.push(tx);
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
|
|
33
|
-
return [validTxs, invalidTxs];
|
|
45
|
+
return [validTxs, invalidTxs, skippedTxs];
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
validateTx(tx: Tx): Promise<boolean> {
|
|
37
49
|
return this.#validateTxFee(tx);
|
|
38
50
|
}
|
|
39
51
|
|
|
52
|
+
#shouldSkip(tx: Tx): boolean {
|
|
53
|
+
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
54
|
+
|
|
55
|
+
// Skip the tx if its max fees are not enough for the current block's gas fees.
|
|
56
|
+
const maxFeesPerGas = gasSettings.maxFeesPerGas;
|
|
57
|
+
const notEnoughMaxFees =
|
|
58
|
+
maxFeesPerGas.feePerDaGas.lt(this.#gasFees.feePerDaGas) ||
|
|
59
|
+
maxFeesPerGas.feePerL2Gas.lt(this.#gasFees.feePerL2Gas);
|
|
60
|
+
if (notEnoughMaxFees) {
|
|
61
|
+
this.#log.warn(`Skipping transaction ${tx.getTxHash()} due to insufficient fee per gas`);
|
|
62
|
+
}
|
|
63
|
+
return notEnoughMaxFees;
|
|
64
|
+
}
|
|
65
|
+
|
|
40
66
|
async #validateTxFee(tx: Tx): Promise<boolean> {
|
|
41
67
|
const feePayer = tx.data.feePayer;
|
|
42
68
|
// TODO(@spalladino) Eventually remove the is_zero condition as we should always charge fees to every tx
|
|
43
69
|
if (feePayer.isZero()) {
|
|
44
|
-
if (this
|
|
70
|
+
if (this.#enforceFees) {
|
|
45
71
|
this.#log.warn(`Rejecting transaction ${tx.getTxHash()} due to missing fee payer`);
|
|
46
72
|
} else {
|
|
47
73
|
return true;
|
|
@@ -29,7 +29,10 @@ export class TxValidatorFactory {
|
|
|
29
29
|
private enforceFees: boolean,
|
|
30
30
|
) {
|
|
31
31
|
this.nullifierSource = {
|
|
32
|
-
|
|
32
|
+
getNullifierIndices: nullifiers =>
|
|
33
|
+
this.committedDb
|
|
34
|
+
.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers)
|
|
35
|
+
.then(x => x.filter(index => index !== undefined) as bigint[]),
|
|
33
36
|
};
|
|
34
37
|
|
|
35
38
|
this.publicStateSource = {
|
|
@@ -45,13 +48,18 @@ export class TxValidatorFactory {
|
|
|
45
48
|
new MetadataTxValidator(globalVariables.chainId, globalVariables.blockNumber),
|
|
46
49
|
new DoubleSpendTxValidator(this.nullifierSource),
|
|
47
50
|
new PhasesTxValidator(this.contractDataSource, setupAllowList),
|
|
48
|
-
new GasTxValidator(
|
|
51
|
+
new GasTxValidator(
|
|
52
|
+
this.publicStateSource,
|
|
53
|
+
ProtocolContractAddress.FeeJuice,
|
|
54
|
+
this.enforceFees,
|
|
55
|
+
globalVariables.gasFees,
|
|
56
|
+
),
|
|
49
57
|
);
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
validatorForProcessedTxs(fork: MerkleTreeReadOperations): TxValidator<ProcessedTx> {
|
|
53
61
|
return new DoubleSpendTxValidator({
|
|
54
|
-
|
|
62
|
+
getNullifierIndices: nullifiers => fork.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers),
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
65
|
}
|