@aztec/stdlib 0.0.1-commit.f504929 → 0.0.1-commit.f81dbcf
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/block/l2_block.d.ts +9 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +12 -2
- package/dest/block/l2_block_source.d.ts +14 -8
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.d.ts +2 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -4
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/validate.d.ts +36 -0
- package/dest/checkpoint/validate.d.ts.map +1 -0
- package/dest/checkpoint/validate.js +120 -0
- package/dest/config/sequencer-config.d.ts +2 -4
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +1 -3
- package/dest/epoch-helpers/index.d.ts +5 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +4 -2
- package/dest/gas/gas_fees.d.ts +1 -1
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +1 -4
- package/dest/interfaces/allowed_element.d.ts +25 -1
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +8 -2
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -2
- package/dest/interfaces/aztec-node-admin.d.ts +55 -7
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +11 -6
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +5 -2
- package/dest/interfaces/block-builder.d.ts +17 -9
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +12 -5
- package/dest/interfaces/configs.d.ts +42 -7
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +7 -1
- package/dest/interfaces/validator.d.ts +65 -6
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +6 -3
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
- package/dest/logs/log_filter.d.ts +4 -1
- package/dest/logs/log_filter.d.ts.map +1 -1
- package/dest/logs/log_filter.js +2 -1
- package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +7 -0
- package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +69 -26
- package/dest/p2p/block_proposal.d.ts +2 -2
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +1 -1
- package/dest/p2p/checkpoint_proposal.d.ts +2 -7
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +14 -24
- package/dest/p2p/peer_error.d.ts +3 -1
- package/dest/p2p/peer_error.d.ts.map +1 -1
- package/dest/p2p/peer_error.js +5 -0
- package/dest/slashing/tally.d.ts +5 -6
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +19 -10
- package/dest/tests/mocks.d.ts +4 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +13 -8
- package/dest/tx/block_header.d.ts +3 -1
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +4 -0
- package/dest/tx/tx.d.ts +6 -5
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- package/dest/tx/tx_receipt.d.ts +7 -2
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +6 -3
- package/dest/tx/validator/error_texts.d.ts +6 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +6 -0
- package/dest/update-checker/index.d.ts +3 -2
- package/dest/update-checker/index.d.ts.map +1 -1
- package/dest/update-checker/index.js +2 -1
- package/dest/update-checker/package_version.d.ts +3 -0
- package/dest/update-checker/package_version.d.ts.map +1 -0
- package/dest/update-checker/package_version.js +24 -0
- package/dest/update-checker/version_checker.d.ts +25 -0
- package/dest/update-checker/version_checker.d.ts.map +1 -0
- package/dest/update-checker/version_checker.js +50 -0
- package/dest/validators/errors.d.ts +6 -1
- package/dest/validators/errors.d.ts.map +1 -1
- package/dest/validators/errors.js +7 -0
- package/dest/versioning/versioning.d.ts +4 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +4 -1
- package/package.json +9 -9
- package/src/block/l2_block.ts +13 -1
- package/src/block/l2_block_source.ts +14 -7
- package/src/checkpoint/checkpoint.ts +12 -3
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/validate.ts +230 -0
- package/src/config/sequencer-config.ts +2 -5
- package/src/epoch-helpers/index.ts +3 -0
- package/src/gas/gas_fees.ts +1 -7
- package/src/interfaces/allowed_element.ts +28 -4
- package/src/interfaces/archiver.ts +3 -2
- package/src/interfaces/aztec-node.ts +23 -5
- package/src/interfaces/block-builder.ts +30 -11
- package/src/interfaces/configs.ts +12 -4
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/validator.ts +18 -3
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/tx_scoped_l2_log.ts +16 -0
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/p2p/block_proposal.ts +1 -1
- package/src/p2p/checkpoint_proposal.ts +24 -38
- package/src/p2p/peer_error.ts +7 -0
- package/src/slashing/tally.ts +22 -4
- package/src/tests/mocks.ts +18 -7
- package/src/tx/block_header.ts +6 -0
- package/src/tx/tx.ts +20 -11
- package/src/tx/tx_receipt.ts +7 -2
- package/src/tx/validator/error_texts.ts +7 -0
- package/src/update-checker/index.ts +2 -1
- package/src/update-checker/package_version.ts +30 -0
- package/src/update-checker/version_checker.ts +65 -0
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/dest/ha-signing/config.d.ts +0 -101
- package/dest/ha-signing/config.d.ts.map +0 -1
- package/dest/ha-signing/config.js +0 -92
- package/dest/ha-signing/index.d.ts +0 -3
- package/dest/ha-signing/index.d.ts.map +0 -1
- package/dest/ha-signing/index.js +0 -2
- package/dest/ha-signing/types.d.ts +0 -85
- package/dest/ha-signing/types.d.ts.map +0 -1
- package/dest/ha-signing/types.js +0 -32
- package/dest/update-checker/update-checker.d.ts +0 -49
- package/dest/update-checker/update-checker.d.ts.map +0 -1
- package/dest/update-checker/update-checker.js +0 -130
- package/src/ha-signing/config.ts +0 -149
- package/src/ha-signing/index.ts +0 -18
- package/src/ha-signing/types.ts +0 -112
- package/src/update-checker/update-checker.ts +0 -166
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
3
|
+
import { EventEmitter } from 'node:events';
|
|
4
|
+
export class VersionChecker extends EventEmitter {
|
|
5
|
+
checks;
|
|
6
|
+
logger;
|
|
7
|
+
runningPromise;
|
|
8
|
+
constructor(checks, intervalCheckMs = 60_000, logger = createLogger('version_checker')){
|
|
9
|
+
super(), this.checks = checks, this.logger = logger, this.run = async ()=>{
|
|
10
|
+
await Promise.allSettled(this.checks.map((check)=>this.checkVersion(check)));
|
|
11
|
+
};
|
|
12
|
+
this.runningPromise = new RunningPromise(this.run, logger, intervalCheckMs);
|
|
13
|
+
}
|
|
14
|
+
start() {
|
|
15
|
+
if (this.runningPromise.isRunning()) {
|
|
16
|
+
this.logger.warn('VersionChecker is already running');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.runningPromise.start();
|
|
20
|
+
this.logger.info('Version check started');
|
|
21
|
+
}
|
|
22
|
+
trigger() {
|
|
23
|
+
return this.runningPromise.trigger();
|
|
24
|
+
}
|
|
25
|
+
async stop() {
|
|
26
|
+
if (!this.runningPromise.isRunning()) {
|
|
27
|
+
this.logger.warn('VersionChecker is not running');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await this.runningPromise.stop();
|
|
31
|
+
this.logger.info('Version checker stopped');
|
|
32
|
+
}
|
|
33
|
+
run;
|
|
34
|
+
async checkVersion({ name, currentVersion, getLatestVersion }) {
|
|
35
|
+
try {
|
|
36
|
+
const latestVersion = await getLatestVersion();
|
|
37
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
38
|
+
this.emit('newVersion', {
|
|
39
|
+
name,
|
|
40
|
+
latestVersion,
|
|
41
|
+
currentVersion
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
this.logger.warn(`Error checking for new ${name} versions: ${err}`, {
|
|
46
|
+
err
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -19,6 +19,11 @@ export declare class TransactionsNotAvailableError extends ValidatorError {
|
|
|
19
19
|
export declare class FailedToReExecuteTransactionsError extends ValidatorError {
|
|
20
20
|
constructor(txHashes: TxHash[]);
|
|
21
21
|
}
|
|
22
|
+
export declare class ReExInitialStateMismatchError extends ValidatorError {
|
|
23
|
+
readonly expectedArchiveRoot: Fr;
|
|
24
|
+
readonly actualArchiveRoot: Fr;
|
|
25
|
+
constructor(expectedArchiveRoot: Fr, actualArchiveRoot: Fr);
|
|
26
|
+
}
|
|
22
27
|
export declare class ReExStateMismatchError extends ValidatorError {
|
|
23
28
|
readonly expectedArchiveRoot: Fr;
|
|
24
29
|
readonly actualArchiveRoot: Fr;
|
|
@@ -30,4 +35,4 @@ export declare class ReExFailedTxsError extends ValidatorError {
|
|
|
30
35
|
export declare class ReExTimeoutError extends ValidatorError {
|
|
31
36
|
constructor();
|
|
32
37
|
}
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmFsaWRhdG9ycy9lcnJvcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFL0MscUJBQWEsY0FBZSxTQUFRLEtBQUs7SUFDdkMsWUFBWSxPQUFPLEVBQUUsTUFBTSxFQUUxQjtDQUNGO0FBRUQscUJBQWEsK0JBQWdDLFNBQVEsY0FBYztJQUNqRSxjQUVDO0NBQ0Y7QUFFRCxxQkFBYSx1QkFBd0IsU0FBUSxjQUFjO2FBRXZDLGNBQWMsRUFBRSxNQUFNO2FBQ3RCLGFBQWEsRUFBRSxNQUFNO2FBQ3JCLElBQUksRUFBRSxVQUFVO0lBSGxDLFlBQ2tCLGNBQWMsRUFBRSxNQU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YACkB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,UAAU,EAGjC;CACF;AAED,qBAAa,6BAA8B,SAAQ,cAAc;IAC/D,YAAY,QAAQ,EAAE,MAAM,EAAE,EAE7B;CACF;AAED,qBAAa,kCAAmC,SAAQ,cAAc;IACpE,YAAY,QAAQ,EAAE,MAAM,EAAE,EAE7B;CACF;AAED,qBAAa,6BAA8B,SAAQ,cAAc;aAE7C,mBAAmB,EAAE,EAAE;aACvB,iBAAiB,EAAE,EAAE;IAFvC,YACkB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,EAAE,EAGtC;CACF;AAED,qBAAa,sBAAuB,SAAQ,cAAc;aAEtC,mBAAmB,EAAE,EAAE;aACvB,iBAAiB,EAAE,EAAE;IAFvC,YACkB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,EAAE,EAGtC;CACF;AAED,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,YAAY,YAAY,EAAE,MAAM,EAE/B;CACF;AAED,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,cAEC;CACF"}
|
|
@@ -26,6 +26,13 @@ export class FailedToReExecuteTransactionsError extends ValidatorError {
|
|
|
26
26
|
super(`Failed to re-execute transactions: ${txHashes.join(', ')}`);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
export class ReExInitialStateMismatchError extends ValidatorError {
|
|
30
|
+
expectedArchiveRoot;
|
|
31
|
+
actualArchiveRoot;
|
|
32
|
+
constructor(expectedArchiveRoot, actualArchiveRoot){
|
|
33
|
+
super('Re-execution initial state mismatch'), this.expectedArchiveRoot = expectedArchiveRoot, this.actualArchiveRoot = actualArchiveRoot;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
29
36
|
export class ReExStateMismatchError extends ValidatorError {
|
|
30
37
|
expectedArchiveRoot;
|
|
31
38
|
actualArchiveRoot;
|
|
@@ -22,11 +22,13 @@ export declare function checkCompressedComponentVersion(compressed: string, expe
|
|
|
22
22
|
/** Checks that two component versions match. Undefined fields are ignored. */
|
|
23
23
|
export declare function validatePartialComponentVersionsMatch(expected: Partial<ComponentsVersions>, actual: Partial<ComponentsVersions>): void;
|
|
24
24
|
/** Returns a Koa middleware that injects the versioning info as headers. */
|
|
25
|
-
export declare function getVersioningMiddleware(versions: Partial<ComponentsVersions
|
|
25
|
+
export declare function getVersioningMiddleware(versions: Partial<ComponentsVersions>, opts?: {
|
|
26
|
+
packageVersion?: string;
|
|
27
|
+
}): (ctx: Koa.Context, next: () => Promise<void>) => Promise<void>;
|
|
26
28
|
/** Returns a json rpc client handler that rejects responses with mismatching versions. */
|
|
27
29
|
export declare function getVersioningResponseHandler(versions: Partial<ComponentsVersions>): ({ headers }: {
|
|
28
30
|
headers: {
|
|
29
31
|
get: (header: string) => string | null | undefined;
|
|
30
32
|
};
|
|
31
33
|
}) => Promise<void>;
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbmluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ZlcnNpb25pbmcvdmVyc2lvbmluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssR0FBRyxNQUFNLEtBQUssQ0FBQztBQUUzQixPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUU3RCw4SUFBOEk7QUFDOUksTUFBTSxNQUFNLGtCQUFrQixHQUFHO0lBQy9CLFNBQVMsRUFBRSxNQUFNLENBQUM7SUFJbEIsZUFBZSxFQUF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B,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,kEAkBhH;AAED,0FAA0F;AAC1F,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC;;;;oBAajF"}
|
|
@@ -65,7 +65,7 @@ export class ComponentsVersionsError extends Error {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
/** Returns a Koa middleware that injects the versioning info as headers. */ export function getVersioningMiddleware(versions) {
|
|
68
|
+
/** Returns a Koa middleware that injects the versioning info as headers. */ export function getVersioningMiddleware(versions, opts) {
|
|
69
69
|
return async (ctx, next)=>{
|
|
70
70
|
try {
|
|
71
71
|
await next();
|
|
@@ -78,6 +78,9 @@ export class ComponentsVersionsError extends Error {
|
|
|
78
78
|
ctx.set(`x-aztec-${key}`, value.toString());
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
if (opts?.packageVersion) {
|
|
82
|
+
ctx.set('x-aztec-packageVersion', opts.packageVersion);
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
};
|
|
83
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.f81dbcf",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"./database-version/version": "./dest/database-version/database_version.js",
|
|
56
56
|
"./database-version/manager": "./dest/database-version/version_manager.js",
|
|
57
57
|
"./validators": "./dest/validators/index.js",
|
|
58
|
-
"./ha-signing": "./dest/ha-signing/index.js",
|
|
59
58
|
"./file-store": "./dest/file-store/index.js",
|
|
60
59
|
"./snapshots": "./dest/snapshots/index.js",
|
|
61
60
|
"./update-checker": "./dest/update-checker/index.js",
|
|
@@ -91,13 +90,14 @@
|
|
|
91
90
|
},
|
|
92
91
|
"dependencies": {
|
|
93
92
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
94
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
95
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
96
|
-
"@aztec/constants": "0.0.1-commit.
|
|
97
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
98
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
99
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
100
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
93
|
+
"@aztec/bb.js": "0.0.1-commit.f81dbcf",
|
|
94
|
+
"@aztec/blob-lib": "0.0.1-commit.f81dbcf",
|
|
95
|
+
"@aztec/constants": "0.0.1-commit.f81dbcf",
|
|
96
|
+
"@aztec/ethereum": "0.0.1-commit.f81dbcf",
|
|
97
|
+
"@aztec/foundation": "0.0.1-commit.f81dbcf",
|
|
98
|
+
"@aztec/l1-artifacts": "0.0.1-commit.f81dbcf",
|
|
99
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.f81dbcf",
|
|
100
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.f81dbcf",
|
|
101
101
|
"@google-cloud/storage": "^7.15.0",
|
|
102
102
|
"axios": "^1.13.5",
|
|
103
103
|
"json-stringify-deterministic": "1.0.12",
|
package/src/block/l2_block.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BlockBlobData, encodeBlockBlobData } from '@aztec/blob-lib/encoding';
|
|
2
|
+
import { DA_GAS_PER_FIELD } from '@aztec/constants';
|
|
2
3
|
import {
|
|
3
4
|
BlockNumber,
|
|
4
5
|
CheckpointNumber,
|
|
@@ -175,7 +176,7 @@ export class L2Block {
|
|
|
175
176
|
} & Partial<Parameters<typeof BlockHeader.random>[0]> = {},
|
|
176
177
|
): Promise<L2Block> {
|
|
177
178
|
const archive = new AppendOnlyTreeSnapshot(Fr.random(), blockNumber + 1);
|
|
178
|
-
const header = BlockHeader.random({
|
|
179
|
+
const header = BlockHeader.random({ ...blockHeaderOverrides, blockNumber });
|
|
179
180
|
const body = await Body.random({ txsPerBlock, makeTxOptions, ...txOptions });
|
|
180
181
|
return new L2Block(archive, header, body, checkpointNumber, indexWithinCheckpoint);
|
|
181
182
|
}
|
|
@@ -221,4 +222,15 @@ export class L2Block {
|
|
|
221
222
|
timestamp: this.header.globalVariables.timestamp,
|
|
222
223
|
};
|
|
223
224
|
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Compute how much DA gas this block uses.
|
|
228
|
+
*
|
|
229
|
+
* @remarks This assumes DA gas is computed solely based on the number of blob fields in transactions.
|
|
230
|
+
* This may change in the future, but we cannot access the actual DA gas used in a block since it's not exposed
|
|
231
|
+
* in the L2BlockHeader, so we have to rely on recomputing it.
|
|
232
|
+
*/
|
|
233
|
+
computeDAGasUsed(): number {
|
|
234
|
+
return this.body.txEffects.reduce((total, txEffect) => total + txEffect.getNumBlobFields(), 0) * DA_GAS_PER_FIELD;
|
|
235
|
+
}
|
|
224
236
|
}
|
|
@@ -49,6 +49,12 @@ export interface L2BlockSource {
|
|
|
49
49
|
*/
|
|
50
50
|
getBlockNumber(): Promise<BlockNumber>;
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Gets the number of the latest L2 checkpoint processed by the block source implementation.
|
|
54
|
+
* @returns The number of the latest L2 checkpoint processed by the block source implementation.
|
|
55
|
+
*/
|
|
56
|
+
getCheckpointNumber(): Promise<CheckpointNumber>;
|
|
57
|
+
|
|
52
58
|
/**
|
|
53
59
|
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
54
60
|
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
@@ -62,9 +68,8 @@ export interface L2BlockSource {
|
|
|
62
68
|
getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
|
|
63
69
|
|
|
64
70
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* TODO(#13569): Compute proper finalized block number based on L1 finalized block.
|
|
71
|
+
* Returns the finalized L2 block number. A block is finalized when it was proven
|
|
72
|
+
* in an L1 block that has itself been finalized on Ethereum.
|
|
68
73
|
* @returns The finalized block number.
|
|
69
74
|
*/
|
|
70
75
|
getFinalizedL2BlockNumber(): Promise<BlockNumber>;
|
|
@@ -170,14 +175,16 @@ export interface L2BlockSource {
|
|
|
170
175
|
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
|
|
171
176
|
|
|
172
177
|
/**
|
|
173
|
-
* Returns the
|
|
178
|
+
* Returns the last L2 slot number that has been fully synchronized from L1.
|
|
179
|
+
* An L2 slot is fully synced when all L1 blocks that fall within its time range have been processed.
|
|
174
180
|
*/
|
|
175
|
-
|
|
181
|
+
getSyncedL2SlotNumber(): Promise<SlotNumber | undefined>;
|
|
176
182
|
|
|
177
183
|
/**
|
|
178
|
-
* Returns the
|
|
184
|
+
* Returns the last L2 epoch number that has been fully synchronized from L1.
|
|
185
|
+
* An epoch is fully synced when all its L2 slots have been fully synced.
|
|
179
186
|
*/
|
|
180
|
-
|
|
187
|
+
getSyncedL2EpochNumber(): Promise<EpochNumber | undefined>;
|
|
181
188
|
|
|
182
189
|
/**
|
|
183
190
|
* Returns all checkpointed block headers for a given epoch.
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IndexWithinCheckpoint,
|
|
7
7
|
SlotNumber,
|
|
8
8
|
} from '@aztec/foundation/branded-types';
|
|
9
|
-
import { sum } from '@aztec/foundation/collection';
|
|
9
|
+
import { pick, sum } from '@aztec/foundation/collection';
|
|
10
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import { BufferReader, serializeSignedBigInt, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
12
12
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
@@ -152,10 +152,12 @@ export class Checkpoint {
|
|
|
152
152
|
startBlockNumber?: number;
|
|
153
153
|
previousArchive?: AppendOnlyTreeSnapshot;
|
|
154
154
|
feeAssetPriceModifier?: bigint;
|
|
155
|
+
archive?: AppendOnlyTreeSnapshot;
|
|
155
156
|
} & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
|
|
156
157
|
Partial<Parameters<typeof L2Block.random>[1]> = {},
|
|
157
158
|
) {
|
|
158
|
-
const
|
|
159
|
+
const headerOptions = previousArchive ? { lastArchiveRoot: previousArchive.root, ...options } : options;
|
|
160
|
+
const header = CheckpointHeader.random(headerOptions);
|
|
159
161
|
|
|
160
162
|
// Create blocks sequentially to chain archive roots properly.
|
|
161
163
|
// Each block's header.lastArchive must equal the previous block's archive.
|
|
@@ -166,11 +168,18 @@ export class Checkpoint {
|
|
|
166
168
|
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
167
169
|
...options,
|
|
168
170
|
...(lastArchive ? { lastArchive } : {}),
|
|
171
|
+
...pick(header, 'slotNumber', 'timestamp', 'coinbase', 'feeRecipient', 'gasFees'),
|
|
169
172
|
});
|
|
170
173
|
lastArchive = block.archive;
|
|
171
174
|
blocks.push(block);
|
|
172
175
|
}
|
|
173
176
|
|
|
174
|
-
return new Checkpoint(
|
|
177
|
+
return new Checkpoint(
|
|
178
|
+
options.archive ?? AppendOnlyTreeSnapshot.random(),
|
|
179
|
+
header,
|
|
180
|
+
blocks,
|
|
181
|
+
checkpointNumber,
|
|
182
|
+
feeAssetPriceModifier,
|
|
183
|
+
);
|
|
175
184
|
}
|
|
176
185
|
}
|
package/src/checkpoint/index.ts
CHANGED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
|
+
import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { sum } from '@aztec/foundation/collection';
|
|
4
|
+
|
|
5
|
+
import { MAX_BLOCKS_PER_CHECKPOINT } from '../deserialization/index.js';
|
|
6
|
+
import type { Checkpoint } from './checkpoint.js';
|
|
7
|
+
|
|
8
|
+
export class CheckpointValidationError extends Error {
|
|
9
|
+
constructor(
|
|
10
|
+
message: string,
|
|
11
|
+
public readonly checkpointNumber: CheckpointNumber,
|
|
12
|
+
public readonly slot: SlotNumber,
|
|
13
|
+
) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'CheckpointValidationError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Validates a checkpoint. Throws a CheckpointValidationError if any validation fails.
|
|
21
|
+
* - Validates structural integrity (non-empty, block count, sequential numbers, archive chaining, slot consistency)
|
|
22
|
+
* - Validates checkpoint blob field count against maxBlobFields limit
|
|
23
|
+
* - Validates total L2 gas used by checkpoint blocks against the Rollup contract mana limit
|
|
24
|
+
* - Validates total DA gas used by checkpoint blocks against MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT
|
|
25
|
+
* - Validates individual block L2 gas and DA gas against maxL2BlockGas and maxDABlockGas limits
|
|
26
|
+
*/
|
|
27
|
+
export function validateCheckpoint(
|
|
28
|
+
checkpoint: Checkpoint,
|
|
29
|
+
opts: {
|
|
30
|
+
rollupManaLimit?: number;
|
|
31
|
+
maxL2BlockGas?: number;
|
|
32
|
+
maxDABlockGas?: number;
|
|
33
|
+
maxTxsPerCheckpoint?: number;
|
|
34
|
+
maxTxsPerBlock?: number;
|
|
35
|
+
},
|
|
36
|
+
): void {
|
|
37
|
+
validateCheckpointStructure(checkpoint);
|
|
38
|
+
validateCheckpointLimits(checkpoint, opts);
|
|
39
|
+
validateCheckpointBlocksGasLimits(checkpoint, opts);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Validates structural integrity of a checkpoint.
|
|
44
|
+
* - Non-empty block list
|
|
45
|
+
* - Block count within MAX_BLOCKS_PER_CHECKPOINT
|
|
46
|
+
* - Checkpoint slot matches the first block's slot
|
|
47
|
+
* - Checkpoint lastArchiveRoot matches the first block's lastArchive root
|
|
48
|
+
* - Sequential block numbers without gaps
|
|
49
|
+
* - Sequential indexWithinCheckpoint starting at 0
|
|
50
|
+
* - Archive root chaining between consecutive blocks
|
|
51
|
+
* - Consistent slot number across all blocks
|
|
52
|
+
* - Global variables (slot, timestamp, coinbase, feeRecipient, gasFees) match checkpoint header for each block
|
|
53
|
+
*/
|
|
54
|
+
export function validateCheckpointStructure(checkpoint: Checkpoint): void {
|
|
55
|
+
const { blocks, number, slot } = checkpoint;
|
|
56
|
+
|
|
57
|
+
if (blocks.length === 0) {
|
|
58
|
+
throw new CheckpointValidationError('Checkpoint has no blocks', number, slot);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (blocks.length > MAX_BLOCKS_PER_CHECKPOINT) {
|
|
62
|
+
throw new CheckpointValidationError(
|
|
63
|
+
`Checkpoint has ${blocks.length} blocks, exceeding limit of ${MAX_BLOCKS_PER_CHECKPOINT}`,
|
|
64
|
+
number,
|
|
65
|
+
slot,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const firstBlock = blocks[0];
|
|
70
|
+
|
|
71
|
+
if (!checkpoint.header.lastArchiveRoot.equals(firstBlock.header.lastArchive.root)) {
|
|
72
|
+
throw new CheckpointValidationError(
|
|
73
|
+
`Checkpoint lastArchiveRoot does not match first block's lastArchive root`,
|
|
74
|
+
number,
|
|
75
|
+
slot,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
80
|
+
const block = blocks[i];
|
|
81
|
+
|
|
82
|
+
if (block.indexWithinCheckpoint !== i) {
|
|
83
|
+
throw new CheckpointValidationError(
|
|
84
|
+
`Block at index ${i} has indexWithinCheckpoint ${block.indexWithinCheckpoint}, expected ${i}`,
|
|
85
|
+
number,
|
|
86
|
+
slot,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (block.slot !== slot) {
|
|
91
|
+
throw new CheckpointValidationError(
|
|
92
|
+
`Block ${block.number} has slot ${block.slot}, expected ${slot} (all blocks must share the same slot)`,
|
|
93
|
+
number,
|
|
94
|
+
slot,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!checkpoint.header.matchesGlobalVariables(block.header.globalVariables)) {
|
|
99
|
+
throw new CheckpointValidationError(
|
|
100
|
+
`Block ${block.number} global variables (slot, timestamp, coinbase, feeRecipient, gasFees) do not match checkpoint header`,
|
|
101
|
+
number,
|
|
102
|
+
slot,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (i > 0) {
|
|
107
|
+
const prev = blocks[i - 1];
|
|
108
|
+
if (block.number !== prev.number + 1) {
|
|
109
|
+
throw new CheckpointValidationError(
|
|
110
|
+
`Block numbers are not sequential: block at index ${i - 1} has number ${prev.number}, block at index ${i} has number ${block.number}`,
|
|
111
|
+
number,
|
|
112
|
+
slot,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!block.header.lastArchive.root.equals(prev.archive.root)) {
|
|
117
|
+
throw new CheckpointValidationError(
|
|
118
|
+
`Block ${block.number} lastArchive root does not match archive root of block ${prev.number}`,
|
|
119
|
+
number,
|
|
120
|
+
slot,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Validates checkpoint blocks gas limits */
|
|
128
|
+
function validateCheckpointBlocksGasLimits(
|
|
129
|
+
checkpoint: Checkpoint,
|
|
130
|
+
opts: {
|
|
131
|
+
maxL2BlockGas?: number;
|
|
132
|
+
maxDABlockGas?: number;
|
|
133
|
+
maxTxsPerBlock?: number;
|
|
134
|
+
},
|
|
135
|
+
): void {
|
|
136
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = opts;
|
|
137
|
+
|
|
138
|
+
if (maxL2BlockGas !== undefined) {
|
|
139
|
+
for (const block of checkpoint.blocks) {
|
|
140
|
+
const blockL2Gas = block.header.totalManaUsed.toNumber();
|
|
141
|
+
if (blockL2Gas > maxL2BlockGas) {
|
|
142
|
+
throw new CheckpointValidationError(
|
|
143
|
+
`Block ${block.number} in checkpoint has L2 gas used ${blockL2Gas} exceeding limit of ${maxL2BlockGas}`,
|
|
144
|
+
checkpoint.number,
|
|
145
|
+
checkpoint.slot,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (maxDABlockGas !== undefined) {
|
|
152
|
+
for (const block of checkpoint.blocks) {
|
|
153
|
+
const blockDAGas = block.computeDAGasUsed();
|
|
154
|
+
if (blockDAGas > maxDABlockGas) {
|
|
155
|
+
throw new CheckpointValidationError(
|
|
156
|
+
`Block ${block.number} in checkpoint has DA gas used ${blockDAGas} exceeding limit of ${maxDABlockGas}`,
|
|
157
|
+
checkpoint.number,
|
|
158
|
+
checkpoint.slot,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (maxTxsPerBlock !== undefined) {
|
|
165
|
+
for (const block of checkpoint.blocks) {
|
|
166
|
+
const blockTxCount = block.body.txEffects.length;
|
|
167
|
+
if (blockTxCount > maxTxsPerBlock) {
|
|
168
|
+
throw new CheckpointValidationError(
|
|
169
|
+
`Block ${block.number} in checkpoint has ${blockTxCount} txs exceeding limit of ${maxTxsPerBlock}`,
|
|
170
|
+
checkpoint.number,
|
|
171
|
+
checkpoint.slot,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Validates checkpoint max blob fields, gas limits, and tx limits */
|
|
179
|
+
function validateCheckpointLimits(
|
|
180
|
+
checkpoint: Checkpoint,
|
|
181
|
+
opts: {
|
|
182
|
+
rollupManaLimit?: number;
|
|
183
|
+
maxTxsPerCheckpoint?: number;
|
|
184
|
+
},
|
|
185
|
+
): void {
|
|
186
|
+
const { rollupManaLimit, maxTxsPerCheckpoint } = opts;
|
|
187
|
+
|
|
188
|
+
const maxBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB;
|
|
189
|
+
const maxDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
190
|
+
|
|
191
|
+
if (rollupManaLimit !== undefined) {
|
|
192
|
+
const checkpointMana = sum(checkpoint.blocks.map(block => block.header.totalManaUsed.toNumber()));
|
|
193
|
+
if (checkpointMana > rollupManaLimit) {
|
|
194
|
+
throw new CheckpointValidationError(
|
|
195
|
+
`Checkpoint mana cost ${checkpointMana} exceeds rollup limit of ${rollupManaLimit}`,
|
|
196
|
+
checkpoint.number,
|
|
197
|
+
checkpoint.slot,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const checkpointDAGas = sum(checkpoint.blocks.map(block => block.computeDAGasUsed()));
|
|
203
|
+
if (checkpointDAGas > maxDAGas) {
|
|
204
|
+
throw new CheckpointValidationError(
|
|
205
|
+
`Checkpoint DA gas cost ${checkpointDAGas} exceeds limit of ${maxDAGas}`,
|
|
206
|
+
checkpoint.number,
|
|
207
|
+
checkpoint.slot,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const checkpointBlobFields = checkpoint.toBlobFields().length;
|
|
212
|
+
if (checkpointBlobFields > maxBlobFields) {
|
|
213
|
+
throw new CheckpointValidationError(
|
|
214
|
+
`Checkpoint blob field count ${checkpointBlobFields} exceeds limit of ${maxBlobFields}`,
|
|
215
|
+
checkpoint.number,
|
|
216
|
+
checkpoint.slot,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (maxTxsPerCheckpoint !== undefined) {
|
|
221
|
+
const checkpointTxCount = sum(checkpoint.blocks.map(block => block.body.txEffects.length));
|
|
222
|
+
if (checkpointTxCount > maxTxsPerCheckpoint) {
|
|
223
|
+
throw new CheckpointValidationError(
|
|
224
|
+
`Checkpoint tx count ${checkpointTxCount} exceeds limit of ${maxTxsPerCheckpoint}`,
|
|
225
|
+
checkpoint.number,
|
|
226
|
+
checkpoint.slot,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
|
|
3
3
|
import type { SequencerConfig } from '../interfaces/configs.js';
|
|
4
4
|
|
|
5
|
-
/** Default maximum number of transactions per block. */
|
|
6
|
-
export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
|
|
7
|
-
|
|
8
5
|
/**
|
|
9
6
|
* Partial sequencer config mappings for fields that need to be shared across packages.
|
|
10
7
|
* The full sequencer config mappings remain in sequencer-client, but shared fields
|
|
@@ -32,6 +29,6 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
|
|
|
32
29
|
maxTxsPerBlock: {
|
|
33
30
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
34
31
|
description: 'The maximum number of txs to include in a block.',
|
|
35
|
-
|
|
32
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
36
33
|
},
|
|
37
34
|
};
|
|
@@ -12,6 +12,7 @@ export type L1RollupConstants = {
|
|
|
12
12
|
ethereumSlotDuration: number;
|
|
13
13
|
proofSubmissionEpochs: number;
|
|
14
14
|
targetCommitteeSize: number;
|
|
15
|
+
rollupManaLimit: number;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export const EmptyL1RollupConstants: L1RollupConstants = {
|
|
@@ -22,6 +23,7 @@ export const EmptyL1RollupConstants: L1RollupConstants = {
|
|
|
22
23
|
ethereumSlotDuration: 1,
|
|
23
24
|
proofSubmissionEpochs: 1,
|
|
24
25
|
targetCommitteeSize: 48,
|
|
26
|
+
rollupManaLimit: Number.MAX_SAFE_INTEGER,
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
|
|
@@ -33,6 +35,7 @@ export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
|
|
|
33
35
|
ethereumSlotDuration: z.number(),
|
|
34
36
|
proofSubmissionEpochs: z.number(),
|
|
35
37
|
targetCommitteeSize: z.number(),
|
|
38
|
+
rollupManaLimit: z.number(),
|
|
36
39
|
}),
|
|
37
40
|
);
|
|
38
41
|
|
package/src/gas/gas_fees.ts
CHANGED
|
@@ -56,14 +56,8 @@ export class GasFees {
|
|
|
56
56
|
return this.clone();
|
|
57
57
|
} else if (typeof scalar === 'bigint') {
|
|
58
58
|
return new GasFees(this.feePerDaGas * scalar, this.feePerL2Gas * scalar);
|
|
59
|
-
} else if (Number.isInteger(scalar)) {
|
|
60
|
-
const s = BigInt(scalar);
|
|
61
|
-
return new GasFees(this.feePerDaGas * s, this.feePerL2Gas * s);
|
|
62
59
|
} else {
|
|
63
|
-
return new GasFees(
|
|
64
|
-
BigInt(Math.ceil(Number(this.feePerDaGas) * scalar)),
|
|
65
|
-
BigInt(Math.ceil(Number(this.feePerL2Gas) * scalar)),
|
|
66
|
-
);
|
|
60
|
+
return new GasFees(Number(this.feePerDaGas) * scalar, Number(this.feePerL2Gas) * scalar);
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
|
|
@@ -6,14 +6,38 @@ import type { FunctionSelector } from '../abi/function_selector.js';
|
|
|
6
6
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
7
7
|
import { schemas, zodFor } from '../schemas/index.js';
|
|
8
8
|
|
|
9
|
-
type AllowedInstanceFunction = {
|
|
10
|
-
|
|
9
|
+
type AllowedInstanceFunction = {
|
|
10
|
+
address: AztecAddress;
|
|
11
|
+
selector: FunctionSelector;
|
|
12
|
+
onlySelf?: boolean;
|
|
13
|
+
rejectNullMsgSender?: boolean;
|
|
14
|
+
calldataLength?: number;
|
|
15
|
+
};
|
|
16
|
+
type AllowedClassFunction = {
|
|
17
|
+
classId: Fr;
|
|
18
|
+
selector: FunctionSelector;
|
|
19
|
+
onlySelf?: boolean;
|
|
20
|
+
rejectNullMsgSender?: boolean;
|
|
21
|
+
calldataLength?: number;
|
|
22
|
+
};
|
|
11
23
|
|
|
12
24
|
export type AllowedElement = AllowedInstanceFunction | AllowedClassFunction;
|
|
13
25
|
|
|
14
26
|
export const AllowedElementSchema = zodFor<AllowedElement>()(
|
|
15
27
|
z.union([
|
|
16
|
-
z.object({
|
|
17
|
-
|
|
28
|
+
z.object({
|
|
29
|
+
address: schemas.AztecAddress,
|
|
30
|
+
selector: schemas.FunctionSelector,
|
|
31
|
+
onlySelf: z.boolean().optional(),
|
|
32
|
+
rejectNullMsgSender: z.boolean().optional(),
|
|
33
|
+
calldataLength: z.number().optional(),
|
|
34
|
+
}),
|
|
35
|
+
z.object({
|
|
36
|
+
classId: schemas.Fr,
|
|
37
|
+
selector: schemas.FunctionSelector,
|
|
38
|
+
onlySelf: z.boolean().optional(),
|
|
39
|
+
rejectNullMsgSender: z.boolean().optional(),
|
|
40
|
+
calldataLength: z.number().optional(),
|
|
41
|
+
}),
|
|
18
42
|
]),
|
|
19
43
|
);
|