@aztec/sequencer-client 0.40.1 → 0.42.0
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.js +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +9 -12
- 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 +6 -3
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +2 -1
- package/dest/receiver.d.ts +4 -1
- package/dest/receiver.d.ts.map +1 -1
- package/dest/sequencer/sequencer.d.ts +5 -2
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +39 -10
- package/dest/tx_validator/gas_validator.d.ts +1 -1
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +29 -8
- package/dest/tx_validator/phases_validator.d.ts +2 -2
- package/dest/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/tx_validator/phases_validator.js +14 -9
- package/dest/tx_validator/test_utils.d.ts +21 -0
- package/dest/tx_validator/test_utils.d.ts.map +1 -0
- package/dest/tx_validator/test_utils.js +19 -0
- package/dest/tx_validator/tx_validator_factory.d.ts +2 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +4 -5
- package/package.json +14 -14
- package/src/client/sequencer-client.ts +1 -1
- package/src/config.ts +8 -13
- package/src/publisher/l1-publisher.ts +8 -2
- package/src/publisher/viem-tx-sender.ts +1 -0
- package/src/receiver.ts +4 -1
- package/src/sequencer/sequencer.ts +51 -11
- package/src/tx_validator/gas_validator.ts +36 -6
- package/src/tx_validator/phases_validator.ts +17 -10
- package/src/tx_validator/test_utils.ts +37 -0
- package/src/tx_validator/tx_validator_factory.ts +4 -8
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import { type AllowedFunction, Tx, type TxValidator } from '@aztec/circuit-types';
|
|
2
2
|
import { type PublicCallRequest } from '@aztec/circuits.js';
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { AbstractPhaseManager, PublicKernelPhase } from '@aztec/simulator';
|
|
4
|
+
import { AbstractPhaseManager, ContractsDataSourcePublicDB, PublicKernelPhase } from '@aztec/simulator';
|
|
5
5
|
import { type ContractDataSource } from '@aztec/types/contracts';
|
|
6
6
|
|
|
7
7
|
export class PhasesTxValidator implements TxValidator<Tx> {
|
|
8
8
|
#log = createDebugLogger('aztec:sequencer:tx_validator:tx_phases');
|
|
9
|
+
private contractDataSource: ContractsDataSourcePublicDB;
|
|
9
10
|
|
|
10
|
-
constructor(
|
|
11
|
+
constructor(contracts: ContractDataSource, private setupAllowList: AllowedFunction[]) {
|
|
12
|
+
this.contractDataSource = new ContractsDataSourcePublicDB(contracts);
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
async validateTxs(txs: Tx[]): Promise<[validTxs: Tx[], invalidTxs: Tx[]]> {
|
|
13
16
|
const validTxs: Tx[] = [];
|
|
14
17
|
const invalidTxs: Tx[] = [];
|
|
15
18
|
|
|
16
19
|
for (const tx of txs) {
|
|
20
|
+
// TODO(@spalladino): We add this just to handle public authwit-check calls during setup
|
|
21
|
+
// which are needed for public FPC flows, but fail if the account contract hasnt been deployed yet,
|
|
22
|
+
// which is what we're trying to do as part of the current txs.
|
|
23
|
+
await this.contractDataSource.addNewContracts(tx);
|
|
24
|
+
|
|
17
25
|
if (await this.#validateTx(tx)) {
|
|
18
26
|
validTxs.push(tx);
|
|
19
27
|
} else {
|
|
20
28
|
invalidTxs.push(tx);
|
|
21
29
|
}
|
|
30
|
+
|
|
31
|
+
await this.contractDataSource.removeNewContracts(tx);
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
return Promise.resolve([validTxs, invalidTxs]);
|
|
@@ -37,7 +47,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
37
47
|
this.#log.warn(
|
|
38
48
|
`Rejecting tx ${Tx.getHash(tx)} because it calls setup function not on allow list: ${
|
|
39
49
|
setupFn.contractAddress
|
|
40
|
-
}:${setupFn.
|
|
50
|
+
}:${setupFn.functionSelector}`,
|
|
41
51
|
);
|
|
42
52
|
|
|
43
53
|
return false;
|
|
@@ -52,10 +62,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
52
62
|
return true;
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
const {
|
|
56
|
-
contractAddress,
|
|
57
|
-
functionData: { selector },
|
|
58
|
-
} = publicCall;
|
|
65
|
+
const { contractAddress, functionSelector } = publicCall;
|
|
59
66
|
|
|
60
67
|
// do these checks first since they don't require the contract class
|
|
61
68
|
for (const entry of allowList) {
|
|
@@ -63,12 +70,12 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
63
70
|
continue;
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
if (contractAddress.equals(entry.address) && entry.selector.equals(
|
|
73
|
+
if (contractAddress.equals(entry.address) && entry.selector.equals(functionSelector)) {
|
|
67
74
|
return true;
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
const contractClass = await this.contractDataSource.
|
|
78
|
+
const contractClass = await this.contractDataSource.getContractInstance(contractAddress);
|
|
72
79
|
if (!contractClass) {
|
|
73
80
|
throw new Error(`Contract not found: ${publicCall.contractAddress.toString()}`);
|
|
74
81
|
}
|
|
@@ -78,7 +85,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
78
85
|
continue;
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
if (contractClass.contractClassId.equals(entry.classId) && entry.selector.equals(
|
|
88
|
+
if (contractClass.contractClassId.equals(entry.classId) && entry.selector.equals(functionSelector)) {
|
|
82
89
|
return true;
|
|
83
90
|
}
|
|
84
91
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Tx } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, type Fr, type FunctionSelector } from '@aztec/circuits.js';
|
|
3
|
+
|
|
4
|
+
export function patchNonRevertibleFn(
|
|
5
|
+
tx: Tx,
|
|
6
|
+
index: number,
|
|
7
|
+
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
8
|
+
): { address: AztecAddress; selector: FunctionSelector } {
|
|
9
|
+
return patchFn('endNonRevertibleData', tx, index, overrides);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function patchRevertibleFn(
|
|
13
|
+
tx: Tx,
|
|
14
|
+
index: number,
|
|
15
|
+
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
16
|
+
): { address: AztecAddress; selector: FunctionSelector } {
|
|
17
|
+
return patchFn('end', tx, index, overrides);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function patchFn(
|
|
21
|
+
where: 'end' | 'endNonRevertibleData',
|
|
22
|
+
tx: Tx,
|
|
23
|
+
index: number,
|
|
24
|
+
overrides: { address?: AztecAddress; selector: FunctionSelector; args?: Fr[]; msgSender?: AztecAddress },
|
|
25
|
+
): { address: AztecAddress; selector: FunctionSelector } {
|
|
26
|
+
const fn = tx.enqueuedPublicFunctionCalls.at(-1 * index - 1)!;
|
|
27
|
+
fn.contractAddress = overrides.address ?? fn.contractAddress;
|
|
28
|
+
fn.functionSelector = overrides.selector;
|
|
29
|
+
fn.args = overrides.args ?? fn.args;
|
|
30
|
+
fn.callContext.msgSender = overrides.msgSender ?? fn.callContext.msgSender;
|
|
31
|
+
tx.data.forPublic![where].publicCallStack[index] = fn.toCallRequest();
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
address: fn.contractAddress,
|
|
35
|
+
selector: fn.functionSelector,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AllowedFunction, type ProcessedTx, type Tx, type TxValidator } from '@aztec/circuit-types';
|
|
2
|
-
import { type
|
|
3
|
-
import {
|
|
2
|
+
import { type GlobalVariables } from '@aztec/circuits.js';
|
|
3
|
+
import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
4
4
|
import { WorldStateDB, WorldStatePublicDB } from '@aztec/simulator';
|
|
5
5
|
import { type ContractDataSource } from '@aztec/types/contracts';
|
|
6
6
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
@@ -12,18 +12,14 @@ import { MetadataTxValidator } from './metadata_validator.js';
|
|
|
12
12
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
13
13
|
|
|
14
14
|
export class TxValidatorFactory {
|
|
15
|
-
constructor(
|
|
16
|
-
private merkleTreeDb: MerkleTreeOperations,
|
|
17
|
-
private contractDataSource: ContractDataSource,
|
|
18
|
-
private gasPortalAddress: EthAddress,
|
|
19
|
-
) {}
|
|
15
|
+
constructor(private merkleTreeDb: MerkleTreeOperations, private contractDataSource: ContractDataSource) {}
|
|
20
16
|
|
|
21
17
|
validatorForNewTxs(globalVariables: GlobalVariables, setupAllowList: AllowedFunction[]): TxValidator<Tx> {
|
|
22
18
|
return new AggregateTxValidator(
|
|
23
19
|
new MetadataTxValidator(globalVariables),
|
|
24
20
|
new DoubleSpendTxValidator(new WorldStateDB(this.merkleTreeDb)),
|
|
25
21
|
new PhasesTxValidator(this.contractDataSource, setupAllowList),
|
|
26
|
-
new GasTxValidator(new WorldStatePublicDB(this.merkleTreeDb),
|
|
22
|
+
new GasTxValidator(new WorldStatePublicDB(this.merkleTreeDb), GasTokenAddress),
|
|
27
23
|
);
|
|
28
24
|
}
|
|
29
25
|
|