@aztec/sequencer-client 0.69.0 → 0.69.1-devnet
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 +4 -0
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +4 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -2
- package/dest/publisher/config.d.ts +4 -0
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/config.js +6 -1
- 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.d.ts +43 -12
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +184 -132
- package/dest/sequencer/index.d.ts +1 -0
- package/dest/sequencer/index.d.ts.map +1 -1
- package/dest/sequencer/index.js +2 -1
- package/dest/sequencer/sequencer.d.ts +22 -29
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +68 -132
- package/dest/sequencer/utils.d.ts +2 -2
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +3 -3
- package/dest/slasher/factory.d.ts +11 -0
- package/dest/slasher/factory.d.ts.map +1 -0
- package/dest/slasher/factory.js +10 -0
- package/dest/slasher/index.d.ts +3 -0
- package/dest/slasher/index.d.ts.map +1 -0
- package/dest/slasher/index.js +3 -0
- package/dest/slasher/slasher_client.d.ts +127 -0
- package/dest/slasher/slasher_client.d.ts.map +1 -0
- package/dest/slasher/slasher_client.js +305 -0
- package/dest/test/index.d.ts +18 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +8 -0
- package/dest/{publisher → test}/test-l1-publisher.d.ts +1 -1
- package/dest/test/test-l1-publisher.d.ts.map +1 -0
- package/dest/test/test-l1-publisher.js +11 -0
- package/dest/tx_validator/archive_cache.d.ts +14 -0
- package/dest/tx_validator/archive_cache.d.ts.map +1 -0
- package/dest/tx_validator/archive_cache.js +22 -0
- package/dest/tx_validator/gas_validator.d.ts +2 -3
- package/dest/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/tx_validator/gas_validator.js +9 -22
- package/dest/tx_validator/nullifier_cache.d.ts +16 -0
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/tx_validator/nullifier_cache.js +24 -0
- package/dest/tx_validator/phases_validator.d.ts +2 -3
- package/dest/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/tx_validator/phases_validator.js +15 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +15 -14
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +41 -24
- package/package.json +24 -20
- package/src/client/sequencer-client.ts +9 -3
- package/src/config.ts +10 -0
- package/src/index.ts +3 -1
- package/src/publisher/config.ts +10 -0
- package/src/publisher/index.ts +0 -1
- package/src/publisher/l1-publisher.ts +222 -137
- package/src/sequencer/index.ts +1 -0
- package/src/sequencer/sequencer.ts +91 -195
- package/src/sequencer/utils.ts +2 -2
- package/src/slasher/factory.ts +22 -0
- package/src/slasher/index.ts +2 -0
- package/src/slasher/slasher_client.ts +402 -0
- package/src/test/index.ts +23 -0
- package/src/{publisher → test}/test-l1-publisher.ts +1 -1
- package/src/tx_validator/archive_cache.ts +27 -0
- package/src/tx_validator/gas_validator.ts +11 -24
- package/src/tx_validator/nullifier_cache.ts +29 -0
- package/src/tx_validator/phases_validator.ts +22 -33
- package/src/tx_validator/tx_validator_factory.ts +89 -40
- package/dest/publisher/test-l1-publisher.d.ts.map +0 -1
- package/dest/publisher/test-l1-publisher.js +0 -11
- package/dest/publisher/utils.d.ts +0 -2
- package/dest/publisher/utils.d.ts.map +0 -1
- package/dest/publisher/utils.js +0 -13
- package/src/publisher/utils.ts +0 -14
|
@@ -1,65 +1,114 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AllowedElement,
|
|
3
|
-
|
|
3
|
+
type ClientProtocolCircuitVerifier,
|
|
4
4
|
type MerkleTreeReadOperations,
|
|
5
5
|
type ProcessedTx,
|
|
6
6
|
type Tx,
|
|
7
7
|
type TxValidator,
|
|
8
8
|
} from '@aztec/circuit-types';
|
|
9
|
-
import { type ContractDataSource, type GlobalVariables } from '@aztec/circuits.js';
|
|
9
|
+
import { type AztecAddress, type ContractDataSource, Fr, type GasFees, type GlobalVariables } from '@aztec/circuits.js';
|
|
10
10
|
import {
|
|
11
11
|
AggregateTxValidator,
|
|
12
|
+
BlockHeaderTxValidator,
|
|
12
13
|
DataTxValidator,
|
|
13
14
|
DoubleSpendTxValidator,
|
|
14
15
|
MetadataTxValidator,
|
|
15
|
-
|
|
16
|
+
TxProofValidator,
|
|
16
17
|
} from '@aztec/p2p';
|
|
17
18
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
18
19
|
import { readPublicState } from '@aztec/simulator';
|
|
19
20
|
|
|
21
|
+
import { ArchiveCache } from './archive_cache.js';
|
|
20
22
|
import { GasTxValidator, type PublicStateSource } from './gas_validator.js';
|
|
23
|
+
import { NullifierCache } from './nullifier_cache.js';
|
|
21
24
|
import { PhasesTxValidator } from './phases_validator.js';
|
|
22
25
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
export function createValidatorForAcceptingTxs(
|
|
27
|
+
db: MerkleTreeReadOperations,
|
|
28
|
+
contractDataSource: ContractDataSource,
|
|
29
|
+
verifier: ClientProtocolCircuitVerifier | undefined,
|
|
30
|
+
data: {
|
|
31
|
+
blockNumber: number;
|
|
32
|
+
l1ChainId: number;
|
|
33
|
+
enforceFees: boolean;
|
|
34
|
+
setupAllowList: AllowedElement[];
|
|
35
|
+
gasFees: GasFees;
|
|
36
|
+
},
|
|
37
|
+
): TxValidator<Tx> {
|
|
38
|
+
const { blockNumber, l1ChainId, enforceFees, setupAllowList, gasFees } = data;
|
|
39
|
+
const validators: TxValidator<Tx>[] = [
|
|
40
|
+
new DataTxValidator(),
|
|
41
|
+
new MetadataTxValidator(new Fr(l1ChainId), new Fr(blockNumber)),
|
|
42
|
+
new DoubleSpendTxValidator(new NullifierCache(db)),
|
|
43
|
+
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
44
|
+
new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, enforceFees, gasFees),
|
|
45
|
+
new BlockHeaderTxValidator(new ArchiveCache(db)),
|
|
46
|
+
];
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return readPublicState(this.committedDb, contractAddress, slot);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
48
|
+
if (verifier) {
|
|
49
|
+
validators.push(new TxProofValidator(verifier));
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
return new AggregateTxValidator(...validators);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createValidatorsForBlockBuilding(
|
|
56
|
+
db: MerkleTreeReadOperations,
|
|
57
|
+
contractDataSource: ContractDataSource,
|
|
58
|
+
globalVariables: GlobalVariables,
|
|
59
|
+
enforceFees: boolean,
|
|
60
|
+
setupAllowList: AllowedElement[],
|
|
61
|
+
): {
|
|
62
|
+
preprocessValidator: TxValidator<Tx>;
|
|
63
|
+
postprocessValidator: TxValidator<ProcessedTx>;
|
|
64
|
+
nullifierCache: NullifierCache;
|
|
65
|
+
} {
|
|
66
|
+
const nullifierCache = new NullifierCache(db);
|
|
67
|
+
const archiveCache = new ArchiveCache(db);
|
|
68
|
+
const publicStateSource = new DatabasePublicStateSource(db);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
preprocessValidator: preprocessValidator(
|
|
72
|
+
nullifierCache,
|
|
73
|
+
archiveCache,
|
|
74
|
+
publicStateSource,
|
|
75
|
+
contractDataSource,
|
|
76
|
+
enforceFees,
|
|
77
|
+
globalVariables,
|
|
78
|
+
setupAllowList,
|
|
79
|
+
),
|
|
80
|
+
postprocessValidator: postprocessValidator(nullifierCache),
|
|
81
|
+
nullifierCache,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
class DatabasePublicStateSource implements PublicStateSource {
|
|
86
|
+
constructor(private db: MerkleTreeReadOperations) {}
|
|
87
|
+
|
|
88
|
+
storageRead(contractAddress: AztecAddress, slot: Fr): Promise<Fr> {
|
|
89
|
+
return readPublicState(this.db, contractAddress, slot);
|
|
64
90
|
}
|
|
65
91
|
}
|
|
92
|
+
|
|
93
|
+
function preprocessValidator(
|
|
94
|
+
nullifierCache: NullifierCache,
|
|
95
|
+
archiveCache: ArchiveCache,
|
|
96
|
+
publicStateSource: PublicStateSource,
|
|
97
|
+
contractDataSource: ContractDataSource,
|
|
98
|
+
enforceFees: boolean,
|
|
99
|
+
globalVariables: GlobalVariables,
|
|
100
|
+
setupAllowList: AllowedElement[],
|
|
101
|
+
): TxValidator<Tx> {
|
|
102
|
+
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
103
|
+
return new AggregateTxValidator(
|
|
104
|
+
new MetadataTxValidator(globalVariables.chainId, globalVariables.blockNumber),
|
|
105
|
+
new DoubleSpendTxValidator(nullifierCache),
|
|
106
|
+
new PhasesTxValidator(contractDataSource, setupAllowList),
|
|
107
|
+
new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, enforceFees, globalVariables.gasFees),
|
|
108
|
+
new BlockHeaderTxValidator(archiveCache),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function postprocessValidator(nullifierCache: NullifierCache): TxValidator<ProcessedTx> {
|
|
113
|
+
return new DoubleSpendTxValidator(nullifierCache);
|
|
114
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-l1-publisher.d.ts","sourceRoot":"","sources":["../../src/publisher/test-l1-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAEjG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,eAAgB,SAAQ,WAAW;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;cAEjB,kBAAkB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,aAAa,GACnB,YAAY,CAAC,aAAa,EAAE,KAAK,EAAE,iBAAiB,CAAC;CAMzD"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { withDelayer } from '@aztec/ethereum/test';
|
|
2
|
-
import { L1Publisher } from './l1-publisher.js';
|
|
3
|
-
export class TestL1Publisher extends L1Publisher {
|
|
4
|
-
createWalletClient(account, chain) {
|
|
5
|
-
const baseClient = super.createWalletClient(account, chain);
|
|
6
|
-
const { client, delayer } = withDelayer(baseClient, { ethereumSlotDuration: this.ethereumSlotDuration });
|
|
7
|
-
this.delayer = delayer;
|
|
8
|
-
return client;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC1sMS1wdWJsaXNoZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL3Rlc3QtbDEtcHVibGlzaGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBZ0IsV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFJakUsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBRWhELE1BQU0sT0FBTyxlQUFnQixTQUFRLFdBQVc7SUFHM0Isa0JBQWtCLENBQ25DLE9BQTBCLEVBQzFCLEtBQW9CO1FBRXBCLE1BQU0sVUFBVSxHQUFHLEtBQUssQ0FBQyxrQkFBa0IsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUM7UUFDNUQsTUFBTSxFQUFFLE1BQU0sRUFBRSxPQUFPLEVBQUUsR0FBRyxXQUFXLENBQUMsVUFBVSxFQUFFLEVBQUUsb0JBQW9CLEVBQUUsSUFBSSxDQUFDLG9CQUFvQixFQUFFLENBQUMsQ0FBQztRQUN6RyxJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQztRQUN2QixPQUFPLE1BQU0sQ0FBQztJQUNoQixDQUFDO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/publisher/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,OAW7C"}
|
package/dest/publisher/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseError, ContractFunctionRevertedError } from 'viem';
|
|
2
|
-
export function prettyLogViemErrorMsg(err) {
|
|
3
|
-
if (err instanceof BaseError) {
|
|
4
|
-
const revertError = err.walk(err => err instanceof ContractFunctionRevertedError);
|
|
5
|
-
if (revertError instanceof ContractFunctionRevertedError) {
|
|
6
|
-
const errorName = revertError.data?.errorName ?? '';
|
|
7
|
-
const args = revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
8
|
-
return `${errorName}${args}`;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return err?.message ?? err;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHVibGlzaGVyL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsNkJBQTZCLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFFaEUsTUFBTSxVQUFVLHFCQUFxQixDQUFDLEdBQVE7SUFDNUMsSUFBSSxHQUFHLFlBQVksU0FBUyxFQUFFLENBQUM7UUFDN0IsTUFBTSxXQUFXLEdBQUcsR0FBRyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEdBQUcsWUFBWSw2QkFBNkIsQ0FBQyxDQUFDO1FBQ2xGLElBQUksV0FBVyxZQUFZLDZCQUE2QixFQUFFLENBQUM7WUFDekQsTUFBTSxTQUFTLEdBQUcsV0FBVyxDQUFDLElBQUksRUFBRSxTQUFTLElBQUksRUFBRSxDQUFDO1lBQ3BELE1BQU0sSUFBSSxHQUNSLFdBQVcsQ0FBQyxZQUFZLElBQUksV0FBVyxDQUFDLFlBQVksRUFBRSxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDLFNBQVMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUM7WUFDbEgsT0FBTyxHQUFHLFNBQVMsR0FBRyxJQUFJLEVBQUUsQ0FBQztRQUMvQixDQUFDO0lBQ0gsQ0FBQztJQUNELE9BQU8sR0FBRyxFQUFFLE9BQU8sSUFBSSxHQUFHLENBQUM7QUFDN0IsQ0FBQyJ9
|
package/src/publisher/utils.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseError, ContractFunctionRevertedError } from 'viem';
|
|
2
|
-
|
|
3
|
-
export function prettyLogViemErrorMsg(err: any) {
|
|
4
|
-
if (err instanceof BaseError) {
|
|
5
|
-
const revertError = err.walk(err => err instanceof ContractFunctionRevertedError);
|
|
6
|
-
if (revertError instanceof ContractFunctionRevertedError) {
|
|
7
|
-
const errorName = revertError.data?.errorName ?? '';
|
|
8
|
-
const args =
|
|
9
|
-
revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
10
|
-
return `${errorName}${args}`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return err?.message ?? err;
|
|
14
|
-
}
|