@aztec/stdlib 5.0.0-nightly.20260410 → 5.0.0-nightly.20260411
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/config/sequencer-config.d.ts +2 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +7 -0
- 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 +10 -1
- package/dest/interfaces/aztec-node-debug.d.ts +21 -0
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
- package/dest/interfaces/aztec-node-debug.js +18 -0
- package/dest/interfaces/client.d.ts +2 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +1 -0
- package/dest/timetable/index.d.ts +50 -1
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +204 -18
- package/dest/tx/global_variable_builder.d.ts +3 -14
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/simulated_tx.d.ts +1 -1
- package/dest/tx/simulated_tx.js +1 -1
- package/package.json +8 -8
- package/src/config/sequencer-config.ts +11 -1
- package/src/gas/gas_fees.ts +12 -4
- package/src/interfaces/aztec-node-debug.ts +40 -0
- package/src/interfaces/client.ts +1 -0
- package/src/timetable/index.ts +291 -16
- package/src/tx/global_variable_builder.ts +2 -15
- package/src/tx/simulated_tx.ts +1 -1
|
@@ -8,5 +8,5 @@ export declare const DEFAULT_MAX_TXS_PER_BLOCK = 32;
|
|
|
8
8
|
* (like blockDurationMs needed by both p2p and sequencer-client) are defined here
|
|
9
9
|
* to avoid duplication.
|
|
10
10
|
*/
|
|
11
|
-
export declare const sharedSequencerConfigMappings: ConfigMappingsType<Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'>>;
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
export declare const sharedSequencerConfigMappings: ConfigMappingsType<Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock' | 'attestationPropagationTime'>>;
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VxdWVuY2VyLWNvbmZpZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbmZpZy9zZXF1ZW5jZXItY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFbkUsT0FBTyxLQUFLLEVBQUUsZUFBZSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFHaEUsd0RBQXdEO0FBQ3hELGVBQU8sTUFBTSx5QkFBeUIsS0FBSyxDQUFDO0FBRTVDOzs7OztHQUtHO0FBQ0gsZUFBTyxNQUFNLDZCQUE2QixFQUFFLGtCQUFrQixDQUM1RCxJQUFJLENBQ0YsZUFBZSxFQUNmLGlCQUFpQixHQUFHLCtCQUErQixHQUFHLGdCQUFnQixHQUFHLDRCQUE0QixDQUN0RyxDQTRCRixDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequencer-config.d.ts","sourceRoot":"","sources":["../../src/config/sequencer-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"sequencer-config.d.ts","sourceRoot":"","sources":["../../src/config/sequencer-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE,wDAAwD;AACxD,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAC5D,IAAI,CACF,eAAe,EACf,iBAAiB,GAAG,+BAA+B,GAAG,gBAAgB,GAAG,4BAA4B,CACtG,CA4BF,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '../timetable/index.js';
|
|
1
2
|
/** Default maximum number of transactions per block. */ export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
|
|
2
3
|
/**
|
|
3
4
|
* Partial sequencer config mappings for fields that need to be shared across packages.
|
|
@@ -20,5 +21,11 @@
|
|
|
20
21
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
21
22
|
description: 'The maximum number of txs to include in a block.',
|
|
22
23
|
parseEnv: (val)=>val ? parseInt(val, 10) : undefined
|
|
24
|
+
},
|
|
25
|
+
attestationPropagationTime: {
|
|
26
|
+
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
27
|
+
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way).',
|
|
28
|
+
parseEnv: (val)=>val ? parseFloat(val) : undefined,
|
|
29
|
+
defaultValue: DEFAULT_P2P_PROPAGATION_TIME
|
|
23
30
|
}
|
|
24
31
|
};
|
package/dest/gas/gas_fees.d.ts
CHANGED
|
@@ -49,4 +49,4 @@ export declare class GasFees {
|
|
|
49
49
|
};
|
|
50
50
|
[inspect.custom](): string;
|
|
51
51
|
}
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
52
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2FzX2ZlZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nYXMvZ2FzX2ZlZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBT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FHLE9BQU8sQ0FLeEM7SUFFRCxNQUFNLENBQUMsTUFBTSxZQUVaO0lBRUQsTUFBTSxDQUFDLEtBQUssWUFFWDtJQUVELE9BQU8sWUFFTjtJQUVELE1BQU0sQ0FBQyxVQUFVLENBQUMsTUFBTSxFQUFFLE1BQU0sR0FBRyxZQUFZLEdBQUcsT0FBTyxDQUd4RDtJQUVELFFBQVEsNEJBRVA7SUFFRCxNQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sRUFBRSxFQUFFLEVBQUUsR0FBRyxXQUFXLFdBRzNDO0lBRUQsUUFBUSxTQUVQO0lBRUQsU0FBUzs7O01BS1I7SUFFRCxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsV0FFZjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas_fees.d.ts","sourceRoot":"","sources":["../../src/gas/gas_fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EACL,YAAY,EACZ,WAAW,EAIZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"gas_fees.d.ts","sourceRoot":"","sources":["../../src/gas/gas_fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EACL,YAAY,EACZ,WAAW,EAIZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAa9C,qCAAqC;AACrC,qBAAa,OAAO;IAClB,SAAgB,WAAW,EAAE,OAAO,CAAC;IACrC,SAAgB,WAAW,EAAE,OAAO,CAAC;IAErC,YAAY,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAGrE;IAED,MAAM,KAAK,MAAM;;;;;;;;;;;;OAOhB;IAED,KAAK,IAAI,OAAO,CAEf;IAED,MAAM,CAAC,KAAK,EAAE,OAAO,WAEpB;IAED,GAAG,CAAC,SAAS,EAAE,aAAa,UAO3B;IAED,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,WAW1B;IAED,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,WAEpC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAKxC;IAED,MAAM,CAAC,MAAM,YAEZ;IAED,MAAM,CAAC,KAAK,YAEX;IAED,OAAO,YAEN;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAGxD;IAED,QAAQ,4BAEP;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,WAG3C;IAED,QAAQ,SAEP;IAED,SAAS;;;MAKR;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,WAEf;CACF"}
|
package/dest/gas/gas_fees.js
CHANGED
|
@@ -3,6 +3,15 @@ import { schemas } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import { BufferReader, FieldReader, bigintToUInt128BE, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
|
|
4
4
|
import { inspect } from 'util';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Multiplies a bigint by a non-integer scalar and returns the ceiling of the result.
|
|
8
|
+
* Avoids converting the bigint to Number (which loses precision above 2^53) by instead
|
|
9
|
+
* scaling the scalar into a bigint rational and performing ceiling division.
|
|
10
|
+
*/ function bigintMulCeil(value, scalar) {
|
|
11
|
+
const SCALE = 1_000_000_000_000n; // 1e12
|
|
12
|
+
const scaledScalar = BigInt(Math.round(scalar * 1e12));
|
|
13
|
+
return (value * scaledScalar + SCALE - 1n) / SCALE;
|
|
14
|
+
}
|
|
6
15
|
_computedKey = inspect.custom;
|
|
7
16
|
/** Gas prices for each dimension. */ export class GasFees {
|
|
8
17
|
feePerDaGas;
|
|
@@ -40,7 +49,7 @@ _computedKey = inspect.custom;
|
|
|
40
49
|
const s = BigInt(scalar);
|
|
41
50
|
return new GasFees(this.feePerDaGas * s, this.feePerL2Gas * s);
|
|
42
51
|
} else {
|
|
43
|
-
return new GasFees(
|
|
52
|
+
return new GasFees(bigintMulCeil(this.feePerDaGas, scalar), bigintMulCeil(this.feePerL2Gas, scalar));
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
static from(fields) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defaultFetch } from '@aztec/foundation/json-rpc/client';
|
|
2
|
+
import type { ApiSchemaFor } from '../schemas/schemas.js';
|
|
3
|
+
import { type ComponentsVersions } from '../versioning/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Debug interface for Aztec node available in sandbox/local-network mode.
|
|
6
|
+
*/
|
|
7
|
+
export interface AztecNodeDebug {
|
|
8
|
+
/**
|
|
9
|
+
* Triggers the sequencer to produce an L2 block and waits for it to appear.
|
|
10
|
+
*
|
|
11
|
+
* **Precondition**: The current L2 slot must not already contain a block. Callers must ensure L1 time has been
|
|
12
|
+
* advanced to a slot with no existing block before calling this method (e.g. via `EthCheatCodes.warp()`).
|
|
13
|
+
* If the slot is already taken, the sequencer will fail to propose and this call will time out.
|
|
14
|
+
*
|
|
15
|
+
* @throws If no sequencer is running.
|
|
16
|
+
*/
|
|
17
|
+
mineBlock(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare const AztecNodeDebugApiSchema: ApiSchemaFor<AztecNodeDebug>;
|
|
20
|
+
export declare function createAztecNodeDebugClient(url: string, versions?: Partial<ComponentsVersions>, fetch?: typeof defaultFetch, apiKey?: string): AztecNodeDebug;
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWMtbm9kZS1kZWJ1Zy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2ludGVyZmFjZXMvYXp0ZWMtbm9kZS1kZWJ1Zy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQTJCLFlBQVksRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBSTFGLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzFELE9BQU8sRUFBRSxLQUFLLGtCQUFrQixFQUFnQyxNQUFNLHdCQUF3QixDQUFDO0FBRS9GOztHQUVHO0FBQ0gsTUFBTSxXQUFXLGNBQWM7SUFDN0I7Ozs7Ozs7O09BUUc7SUFDSCxTQUFTLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0NBQzVCO0FBRUQsZUFBTyxNQUFNLHVCQUF1QixFQUFFLFlBQVksQ0FBQyxjQUFjLENBRWhFLENBQUM7QUFFRix3QkFBZ0IsMEJBQTBCLENBQ3hDLEdBQUcsRUFBRSxNQUFNLEVBQ1gsUUFBUSxHQUFFLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBTSxFQUMxQyxLQUFLLHNCQUFlLEVBQ3BCLE1BQU0sQ0FBQyxFQUFFLE1BQU0sR0FDZCxjQUFjLENBT2hCIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aztec-node-debug.d.ts","sourceRoot":"","sources":["../../src/interfaces/aztec-node-debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAI1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,KAAK,kBAAkB,EAAgC,MAAM,wBAAwB,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;OAQG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAAC,cAAc,CAEhE,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,EAC1C,KAAK,sBAAe,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,cAAc,CAOhB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { getVersioningResponseHandler } from '../versioning/index.js';
|
|
4
|
+
export const AztecNodeDebugApiSchema = {
|
|
5
|
+
mineBlock: z.function().returns(z.void())
|
|
6
|
+
};
|
|
7
|
+
export function createAztecNodeDebugClient(url, versions = {}, fetch = defaultFetch, apiKey) {
|
|
8
|
+
return createSafeJsonRpcClient(url, AztecNodeDebugApiSchema, {
|
|
9
|
+
namespaceMethods: 'nodeDebug',
|
|
10
|
+
fetch,
|
|
11
|
+
onResponse: getVersioningResponseHandler(versions),
|
|
12
|
+
...apiKey ? {
|
|
13
|
+
extraHeaders: {
|
|
14
|
+
'x-api-key': apiKey
|
|
15
|
+
}
|
|
16
|
+
} : {}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './aztec-node.js';
|
|
2
2
|
export * from './aztec-node-admin.js';
|
|
3
|
+
export * from './aztec-node-debug.js';
|
|
3
4
|
export * from './private_kernel_prover.js';
|
|
4
5
|
export * from './get_logs_response.js';
|
|
5
6
|
export * from './api_limit.js';
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW50ZXJmYWNlcy9jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxpQkFBaUIsQ0FBQztBQUNoQyxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxjQUFjLHdCQUF3QixDQUFDO0FBQ3ZDLGNBQWMsZ0JBQWdCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/interfaces/client.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/interfaces/client.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
|
|
@@ -19,6 +19,55 @@ export declare const DEFAULT_P2P_PROPAGATION_TIME = 2;
|
|
|
19
19
|
export declare const DEFAULT_L1_PUBLISHING_TIME = 12;
|
|
20
20
|
/** Minimum execution time for building a block in seconds */
|
|
21
21
|
export declare const MIN_EXECUTION_TIME = 2;
|
|
22
|
+
export type CheckpointTimingConfig = {
|
|
23
|
+
aztecSlotDuration: number;
|
|
24
|
+
ethereumSlotDuration?: number;
|
|
25
|
+
blockDuration?: number;
|
|
26
|
+
checkpointAssembleTime?: number;
|
|
27
|
+
checkpointInitializationTime?: number;
|
|
28
|
+
l1PublishingTime?: number;
|
|
29
|
+
minExecutionTime?: number;
|
|
30
|
+
p2pPropagationTime?: number;
|
|
31
|
+
pipelining?: boolean;
|
|
32
|
+
};
|
|
33
|
+
export interface CheckpointTiming {
|
|
34
|
+
readonly aztecSlotDuration: number;
|
|
35
|
+
readonly blockDuration: number | undefined;
|
|
36
|
+
readonly checkpointAssembleTime: number;
|
|
37
|
+
readonly checkpointInitializationTime: number;
|
|
38
|
+
readonly l1PublishingTime: number;
|
|
39
|
+
readonly minExecutionTime: number;
|
|
40
|
+
readonly p2pPropagationTime: number;
|
|
41
|
+
readonly checkpointFinalizationTime: number;
|
|
42
|
+
readonly pipeliningAttestationGracePeriod: number;
|
|
43
|
+
readonly timeReservedAtEnd: number;
|
|
44
|
+
readonly minimumBuildSlotWork: number;
|
|
45
|
+
readonly initializeDeadline: number;
|
|
46
|
+
readonly checkpointAssemblyDeadline: number;
|
|
47
|
+
readonly checkpointAttestationStartDeadline: number;
|
|
48
|
+
readonly checkpointAttestationDeadline: number;
|
|
49
|
+
readonly checkpointPublishingDeadline: number;
|
|
50
|
+
calculateMaxBlocksPerSlot(): number;
|
|
51
|
+
}
|
|
52
|
+
export interface PipelinedCheckpointTiming extends CheckpointTiming {
|
|
53
|
+
readonly proposalWindowIntoTargetSlot: number;
|
|
54
|
+
readonly attestationWindowIntoTargetSlot: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a checkpoint timing model for the requested scheduling mode.
|
|
58
|
+
*
|
|
59
|
+
* Most callers should use this factory and depend only on the shared
|
|
60
|
+
* `CheckpointTiming` interface. The returned implementation is selected from
|
|
61
|
+
* `opts.pipelining`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createCheckpointTimingModel(opts: CheckpointTimingConfig): CheckpointTiming;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a pipelined checkpoint timing model with target-slot window accessors.
|
|
66
|
+
*
|
|
67
|
+
* Use this when the caller specifically needs the pipelined-only timing surface,
|
|
68
|
+
* such as proposal or attestation acceptance windows into the target slot.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createPipelinedCheckpointTimingModel(opts: Omit<CheckpointTimingConfig, 'pipelining'>): PipelinedCheckpointTiming;
|
|
22
71
|
/**
|
|
23
72
|
* Calculates the maximum number of blocks that can be built in a slot.
|
|
24
73
|
* Used by both the sequencer timetable and p2p gossipsub scoring.
|
|
@@ -35,4 +84,4 @@ export declare function calculateMaxBlocksPerSlot(aztecSlotDurationSec: number,
|
|
|
35
84
|
l1PublishingTime?: number;
|
|
36
85
|
pipelining?: boolean;
|
|
37
86
|
}): number;
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
87
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90aW1ldGFibGUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7R0FVRztBQUVILG1GQUFtRjtBQUNuRixlQUFPLE1BQU0sOEJBQThCLElBQUksQ0FBQztBQUVoRCx1RkFBdUY7QUFDdkYsZUFBTyxNQUFNLHdCQUF3QixJQUFJLENBQUM7QUFFMUMscUZBQXFGO0FBQ3JGLGVBQU8sTUFBTSw0QkFBNEIsSUFBSSxDQUFDO0FBRTlDLHdGQUF3RjtBQUN4RixlQUFPLE1BQU0sMEJBQTBCLEtBQU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QUM1QixnQkFBZ0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUMxQixVQUFVLENBQUMsRUFBRSxPQUFPLENBQUM7Q0FDakIsR0FDTCxNQUFNLENBVVIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/timetable/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mFAAmF;AACnF,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,uFAAuF;AACvF,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,qFAAqF;AACrF,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,IAAI,GAAE;IACJ,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB,GACL,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/timetable/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mFAAmF;AACnF,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,uFAAuF;AACvF,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,qFAAqF;AACrF,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,IAAI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B,SAAQ,gBAAgB;IACjE,QAAQ,CAAC,4BAA4B,EAAE,MAAM,CAAC;IAC9C,QAAQ,CAAC,+BAA+B,EAAE,MAAM,CAAC;CAClD;AA8ID;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,sBAAsB,GAAG,gBAAgB,CAS1F;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC,GAC/C,yBAAyB,CAO3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,IAAI,GAAE;IACJ,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACjB,GACL,MAAM,CAUR"}
|
package/dest/timetable/index.js
CHANGED
|
@@ -13,6 +13,139 @@
|
|
|
13
13
|
/** Default one-way P2P propagation time for proposals and attestations in seconds */ export const DEFAULT_P2P_PROPAGATION_TIME = 2;
|
|
14
14
|
/** Default L1 publishing time (matches Ethereum slot duration on mainnet) in seconds */ export const DEFAULT_L1_PUBLISHING_TIME = 12;
|
|
15
15
|
/** Minimum execution time for building a block in seconds */ export const MIN_EXECUTION_TIME = 2;
|
|
16
|
+
/**
|
|
17
|
+
* Shared base for checkpoint timing implementations.
|
|
18
|
+
*
|
|
19
|
+
* This class owns the common inputs and formulas used by both pipelined and
|
|
20
|
+
* non-pipelined scheduling. Variant-specific deadline math is delegated to the
|
|
21
|
+
* concrete subclasses below.
|
|
22
|
+
*/ class BaseCheckpointTiming {
|
|
23
|
+
aztecSlotDuration;
|
|
24
|
+
blockDuration;
|
|
25
|
+
checkpointAssembleTime;
|
|
26
|
+
checkpointInitializationTime;
|
|
27
|
+
l1PublishingTime;
|
|
28
|
+
minExecutionTime;
|
|
29
|
+
p2pPropagationTime;
|
|
30
|
+
constructor(opts){
|
|
31
|
+
this.aztecSlotDuration = opts.aztecSlotDuration;
|
|
32
|
+
this.blockDuration = opts.blockDuration;
|
|
33
|
+
this.checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
|
|
34
|
+
this.checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
|
|
35
|
+
this.l1PublishingTime = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
|
|
36
|
+
this.minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
|
|
37
|
+
this.p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
|
|
38
|
+
}
|
|
39
|
+
get checkpointFinalizationTime() {
|
|
40
|
+
// Allow enough time to
|
|
41
|
+
// - build the checkpoint
|
|
42
|
+
// - Round-trip over p2p
|
|
43
|
+
// - Publish to L1
|
|
44
|
+
return this.checkpointAssembleTime + this.p2pPropagationTime * 2 + this.l1PublishingTime;
|
|
45
|
+
}
|
|
46
|
+
get pipeliningAttestationGracePeriod() {
|
|
47
|
+
// Allow enough time to
|
|
48
|
+
// - build the block
|
|
49
|
+
// - pass it back over p2p
|
|
50
|
+
return (this.blockDuration ?? 0) + this.p2pPropagationTime;
|
|
51
|
+
}
|
|
52
|
+
get initializeDeadline() {
|
|
53
|
+
return this.aztecSlotDuration - this.minimumBuildSlotWork;
|
|
54
|
+
}
|
|
55
|
+
get checkpointAttestationStartDeadline() {
|
|
56
|
+
return this.checkpointAssemblyDeadline;
|
|
57
|
+
}
|
|
58
|
+
calculateMaxBlocksPerSlot() {
|
|
59
|
+
if (!this.blockDuration) {
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
const timeAvailableForBlocks = this.aztecSlotDuration - this.checkpointInitializationTime - this.timeReservedAtEnd;
|
|
63
|
+
return Math.floor(timeAvailableForBlocks / this.blockDuration);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Checkpoint timing model for the non-pipelined sequencer flow.
|
|
68
|
+
*
|
|
69
|
+
* In this mode, checkpoint assembly, attestation collection, and L1 publishing
|
|
70
|
+
* must all complete within the current Aztec slot.
|
|
71
|
+
*/ class StandardCheckpointTimingModel extends BaseCheckpointTiming {
|
|
72
|
+
get timeReservedAtEnd() {
|
|
73
|
+
return (this.blockDuration ?? 0) + this.checkpointFinalizationTime;
|
|
74
|
+
}
|
|
75
|
+
get minimumBuildSlotWork() {
|
|
76
|
+
return this.checkpointInitializationTime + this.minExecutionTime * 2 + this.checkpointFinalizationTime;
|
|
77
|
+
}
|
|
78
|
+
get checkpointAssemblyDeadline() {
|
|
79
|
+
return this.aztecSlotDuration - this.l1PublishingTime - 2 * this.p2pPropagationTime;
|
|
80
|
+
}
|
|
81
|
+
get checkpointAttestationDeadline() {
|
|
82
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
83
|
+
}
|
|
84
|
+
get checkpointPublishingDeadline() {
|
|
85
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Checkpoint timing model for proposer pipelining.
|
|
90
|
+
*
|
|
91
|
+
* In this mode, the build work still starts in the current slot, but checkpoint
|
|
92
|
+
* assembly and attestation collection can extend into the target slot. The extra
|
|
93
|
+
* target-slot window getters are intended for consumers such as P2P validators
|
|
94
|
+
* that need to validate pipelined messages against wallclock time.
|
|
95
|
+
*/ class PipelinedCheckpointTimingModel extends BaseCheckpointTiming {
|
|
96
|
+
get proposalWindowIntoTargetSlot() {
|
|
97
|
+
// Allow the p2p propagation time to receive a checkpoint proposal from leader
|
|
98
|
+
return this.p2pPropagationTime;
|
|
99
|
+
}
|
|
100
|
+
get attestationWindowIntoTargetSlot() {
|
|
101
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
102
|
+
}
|
|
103
|
+
get timeReservedAtEnd() {
|
|
104
|
+
return this.checkpointAssembleTime + this.p2pPropagationTime;
|
|
105
|
+
}
|
|
106
|
+
get minimumBuildSlotWork() {
|
|
107
|
+
return this.checkpointInitializationTime + this.minExecutionTime * 2;
|
|
108
|
+
}
|
|
109
|
+
get checkpointAssemblyDeadline() {
|
|
110
|
+
// Allow enough time to
|
|
111
|
+
// - build all blocks
|
|
112
|
+
// - receive attestations
|
|
113
|
+
return this.aztecSlotDuration + this.pipeliningAttestationGracePeriod;
|
|
114
|
+
}
|
|
115
|
+
get checkpointAttestationDeadline() {
|
|
116
|
+
// Allowed to be into the next wallclock slot minus the allocated l1 publishing time
|
|
117
|
+
return this.aztecSlotDuration * 2 - this.l1PublishingTime;
|
|
118
|
+
}
|
|
119
|
+
get checkpointPublishingDeadline() {
|
|
120
|
+
// Allowed to be into the next wallclock slot minus the allocated l1 Publishing time
|
|
121
|
+
return this.aztecSlotDuration * 2 - this.l1PublishingTime;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a checkpoint timing model for the requested scheduling mode.
|
|
126
|
+
*
|
|
127
|
+
* Most callers should use this factory and depend only on the shared
|
|
128
|
+
* `CheckpointTiming` interface. The returned implementation is selected from
|
|
129
|
+
* `opts.pipelining`.
|
|
130
|
+
*/ export function createCheckpointTimingModel(opts) {
|
|
131
|
+
validateCheckpointTimingConfig(opts);
|
|
132
|
+
const normalizedOpts = normalizeCheckpointTimingConfig(opts);
|
|
133
|
+
const timing = normalizedOpts.pipelining ? new PipelinedCheckpointTimingModel(normalizedOpts) : new StandardCheckpointTimingModel(normalizedOpts);
|
|
134
|
+
validateCheckpointTimingModel(timing);
|
|
135
|
+
return timing;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Creates a pipelined checkpoint timing model with target-slot window accessors.
|
|
139
|
+
*
|
|
140
|
+
* Use this when the caller specifically needs the pipelined-only timing surface,
|
|
141
|
+
* such as proposal or attestation acceptance windows into the target slot.
|
|
142
|
+
*/ export function createPipelinedCheckpointTimingModel(opts) {
|
|
143
|
+
validateCheckpointTimingConfig(opts);
|
|
144
|
+
const normalizedOpts = normalizeCheckpointTimingConfig(opts);
|
|
145
|
+
const timing = new PipelinedCheckpointTimingModel(normalizedOpts);
|
|
146
|
+
validateCheckpointTimingModel(timing);
|
|
147
|
+
return timing;
|
|
148
|
+
}
|
|
16
149
|
/**
|
|
17
150
|
* Calculates the maximum number of blocks that can be built in a slot.
|
|
18
151
|
* Used by both the sequencer timetable and p2p gossipsub scoring.
|
|
@@ -22,22 +155,75 @@
|
|
|
22
155
|
* @param opts - Optional overrides for timing constants
|
|
23
156
|
* @returns Maximum number of blocks per slot
|
|
24
157
|
*/ export function calculateMaxBlocksPerSlot(aztecSlotDurationSec, blockDurationSec, opts = {}) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
158
|
+
return createCheckpointTimingModel({
|
|
159
|
+
aztecSlotDuration: aztecSlotDurationSec,
|
|
160
|
+
blockDuration: blockDurationSec,
|
|
161
|
+
checkpointAssembleTime: opts.checkpointAssembleTime,
|
|
162
|
+
checkpointInitializationTime: opts.checkpointInitializationTime,
|
|
163
|
+
l1PublishingTime: opts.l1PublishingTime,
|
|
164
|
+
p2pPropagationTime: opts.p2pPropagationTime,
|
|
165
|
+
pipelining: opts.pipelining
|
|
166
|
+
}).calculateMaxBlocksPerSlot();
|
|
167
|
+
}
|
|
168
|
+
function assertNonNegative(name, value) {
|
|
169
|
+
if (value < 0) {
|
|
170
|
+
throw new Error(`${name} must be non-negative (got ${value})`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function validateCheckpointTimingConfig(opts) {
|
|
174
|
+
if (opts.aztecSlotDuration <= 0) {
|
|
175
|
+
throw new Error(`aztecSlotDuration must be positive (got ${opts.aztecSlotDuration})`);
|
|
176
|
+
}
|
|
177
|
+
if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration <= 0) {
|
|
178
|
+
throw new Error(`ethereumSlotDuration must be positive when provided (got ${opts.ethereumSlotDuration})`);
|
|
179
|
+
}
|
|
180
|
+
if (opts.blockDuration !== undefined && opts.blockDuration <= 0) {
|
|
181
|
+
throw new Error(`blockDuration must be positive when provided (got ${opts.blockDuration})`);
|
|
182
|
+
}
|
|
183
|
+
if (opts.minExecutionTime !== undefined && opts.minExecutionTime <= 0) {
|
|
184
|
+
throw new Error(`minExecutionTime must be positive when provided (got ${opts.minExecutionTime})`);
|
|
185
|
+
}
|
|
186
|
+
if (opts.checkpointAssembleTime !== undefined) {
|
|
187
|
+
assertNonNegative('checkpointAssembleTime', opts.checkpointAssembleTime);
|
|
188
|
+
}
|
|
189
|
+
if (opts.checkpointInitializationTime !== undefined) {
|
|
190
|
+
assertNonNegative('checkpointInitializationTime', opts.checkpointInitializationTime);
|
|
191
|
+
}
|
|
192
|
+
if (opts.l1PublishingTime !== undefined) {
|
|
193
|
+
assertNonNegative('l1PublishingTime', opts.l1PublishingTime);
|
|
194
|
+
}
|
|
195
|
+
if (opts.p2pPropagationTime !== undefined) {
|
|
196
|
+
assertNonNegative('p2pPropagationTime', opts.p2pPropagationTime);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function normalizeCheckpointTimingConfig(opts) {
|
|
200
|
+
let checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
|
|
201
|
+
let checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
|
|
202
|
+
let minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
|
|
203
|
+
let p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
|
|
204
|
+
if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration < 8) {
|
|
205
|
+
p2pPropagationTime = 0;
|
|
206
|
+
checkpointAssembleTime = 0.5;
|
|
207
|
+
checkpointInitializationTime = 0.5;
|
|
208
|
+
minExecutionTime = 1;
|
|
209
|
+
}
|
|
210
|
+
if (opts.blockDuration !== undefined && minExecutionTime > opts.blockDuration) {
|
|
211
|
+
minExecutionTime = opts.blockDuration;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
...opts,
|
|
215
|
+
checkpointAssembleTime,
|
|
216
|
+
checkpointInitializationTime,
|
|
217
|
+
minExecutionTime,
|
|
218
|
+
p2pPropagationTime
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function validateCheckpointTimingModel(model) {
|
|
222
|
+
if (model.blockDuration === undefined) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const timeAvailableForBlocks = model.aztecSlotDuration - model.checkpointInitializationTime - model.timeReservedAtEnd;
|
|
226
|
+
if (timeAvailableForBlocks < model.blockDuration) {
|
|
227
|
+
throw new Error(`Invalid timing configuration: only ${timeAvailableForBlocks}s available for block building, which is less than one blockDuration (${model.blockDuration}s).`);
|
|
228
|
+
}
|
|
43
229
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
3
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
3
|
import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
5
4
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
6
5
|
import type { GasFees } from '../gas/gas_fees.js';
|
|
7
6
|
import type { UInt32 } from '../types/index.js';
|
|
8
7
|
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
9
|
-
/** Fee header fields needed for pipelining overrides. */
|
|
10
|
-
export type ForceProposedFeeHeader = {
|
|
11
|
-
checkpointNumber: CheckpointNumber;
|
|
12
|
-
feeHeader: FeeHeader;
|
|
13
|
-
};
|
|
14
|
-
/** Options for building checkpoint global variables during pipelining. */
|
|
15
|
-
export type BuildCheckpointGlobalVariablesOpts = {
|
|
16
|
-
forcePendingCheckpointNumber?: CheckpointNumber;
|
|
17
|
-
forceProposedFeeHeader?: ForceProposedFeeHeader;
|
|
18
|
-
};
|
|
19
8
|
/**
|
|
20
9
|
* Interface for building global variables for Aztec blocks.
|
|
21
10
|
*/
|
|
@@ -31,6 +20,6 @@ export interface GlobalVariableBuilder {
|
|
|
31
20
|
*/
|
|
32
21
|
buildGlobalVariables(blockNumber: UInt32, coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber?: SlotNumber): Promise<GlobalVariables>;
|
|
33
22
|
/** Builds global variables that are constant throughout a checkpoint. */
|
|
34
|
-
buildCheckpointGlobalVariables(coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber: SlotNumber,
|
|
23
|
+
buildCheckpointGlobalVariables(coinbase: EthAddress, feeRecipient: AztecAddress, slotNumber: SlotNumber, simulationOverridesPlan?: SimulationOverridesPlan): Promise<CheckpointGlobalVariables>;
|
|
35
24
|
}
|
|
36
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYmFsX3ZhcmlhYmxlX2J1aWxkZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eC9nbG9iYWxfdmFyaWFibGVfYnVpbGRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSx1QkFBdUIsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ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":3,"file":"global_variable_builder.d.ts","sourceRoot":"","sources":["../../src/tx/global_variable_builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;;;;;OAOG;IACH,oBAAoB,CAClB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,CAAC,EAAE,UAAU,GACtB,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5B,yEAAyE;IACzE,8BAA8B,CAC5B,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,uBAAuB,CAAC,EAAE,uBAAuB,GAChD,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACvC"}
|
|
@@ -1322,7 +1322,7 @@ export declare class TxSimulationResult {
|
|
|
1322
1322
|
getPublicReturnValues(): NestedProcessReturnValues[];
|
|
1323
1323
|
}
|
|
1324
1324
|
/**
|
|
1325
|
-
* Recursively
|
|
1325
|
+
* Recursively accumulate the return values of a call result and its nested executions,
|
|
1326
1326
|
* so they can be retrieved in order.
|
|
1327
1327
|
* @param executionResult
|
|
1328
1328
|
* @returns
|
package/dest/tx/simulated_tx.js
CHANGED
|
@@ -98,7 +98,7 @@ export class TxSimulationResult {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
|
-
* Recursively
|
|
101
|
+
* Recursively accumulate the return values of a call result and its nested executions,
|
|
102
102
|
* so they can be retrieved in order.
|
|
103
103
|
* @param executionResult
|
|
104
104
|
* @returns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "5.0.0-nightly.
|
|
3
|
+
"version": "5.0.0-nightly.20260411",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
95
|
-
"@aztec/bb.js": "5.0.0-nightly.
|
|
96
|
-
"@aztec/blob-lib": "5.0.0-nightly.
|
|
97
|
-
"@aztec/constants": "5.0.0-nightly.
|
|
98
|
-
"@aztec/ethereum": "5.0.0-nightly.
|
|
99
|
-
"@aztec/foundation": "5.0.0-nightly.
|
|
100
|
-
"@aztec/l1-artifacts": "5.0.0-nightly.
|
|
101
|
-
"@aztec/noir-noirc_abi": "5.0.0-nightly.
|
|
95
|
+
"@aztec/bb.js": "5.0.0-nightly.20260411",
|
|
96
|
+
"@aztec/blob-lib": "5.0.0-nightly.20260411",
|
|
97
|
+
"@aztec/constants": "5.0.0-nightly.20260411",
|
|
98
|
+
"@aztec/ethereum": "5.0.0-nightly.20260411",
|
|
99
|
+
"@aztec/foundation": "5.0.0-nightly.20260411",
|
|
100
|
+
"@aztec/l1-artifacts": "5.0.0-nightly.20260411",
|
|
101
|
+
"@aztec/noir-noirc_abi": "5.0.0-nightly.20260411",
|
|
102
102
|
"@google-cloud/storage": "^7.15.0",
|
|
103
103
|
"axios": "^1.13.5",
|
|
104
104
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
|
|
3
3
|
import type { SequencerConfig } from '../interfaces/configs.js';
|
|
4
|
+
import { DEFAULT_P2P_PROPAGATION_TIME } from '../timetable/index.js';
|
|
4
5
|
|
|
5
6
|
/** Default maximum number of transactions per block. */
|
|
6
7
|
export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
|
|
@@ -12,7 +13,10 @@ export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
|
|
|
12
13
|
* to avoid duplication.
|
|
13
14
|
*/
|
|
14
15
|
export const sharedSequencerConfigMappings: ConfigMappingsType<
|
|
15
|
-
Pick<
|
|
16
|
+
Pick<
|
|
17
|
+
SequencerConfig,
|
|
18
|
+
'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock' | 'attestationPropagationTime'
|
|
19
|
+
>
|
|
16
20
|
> = {
|
|
17
21
|
blockDurationMs: {
|
|
18
22
|
env: 'SEQ_BLOCK_DURATION_MS',
|
|
@@ -34,4 +38,10 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
|
|
|
34
38
|
description: 'The maximum number of txs to include in a block.',
|
|
35
39
|
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
36
40
|
},
|
|
41
|
+
attestationPropagationTime: {
|
|
42
|
+
env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
|
|
43
|
+
description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way).',
|
|
44
|
+
parseEnv: (val: string) => (val ? parseFloat(val) : undefined),
|
|
45
|
+
defaultValue: DEFAULT_P2P_PROPAGATION_TIME,
|
|
46
|
+
},
|
|
37
47
|
};
|
package/src/gas/gas_fees.ts
CHANGED
|
@@ -15,6 +15,17 @@ import { z } from 'zod';
|
|
|
15
15
|
import type { UInt128 } from '../types/shared.js';
|
|
16
16
|
import type { GasDimensions } from './gas.js';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Multiplies a bigint by a non-integer scalar and returns the ceiling of the result.
|
|
20
|
+
* Avoids converting the bigint to Number (which loses precision above 2^53) by instead
|
|
21
|
+
* scaling the scalar into a bigint rational and performing ceiling division.
|
|
22
|
+
*/
|
|
23
|
+
function bigintMulCeil(value: bigint, scalar: number): bigint {
|
|
24
|
+
const SCALE = 1_000_000_000_000n; // 1e12
|
|
25
|
+
const scaledScalar = BigInt(Math.round(scalar * 1e12));
|
|
26
|
+
return (value * scaledScalar + SCALE - 1n) / SCALE;
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
/** Gas prices for each dimension. */
|
|
19
30
|
export class GasFees {
|
|
20
31
|
public readonly feePerDaGas: UInt128;
|
|
@@ -60,10 +71,7 @@ export class GasFees {
|
|
|
60
71
|
const s = BigInt(scalar);
|
|
61
72
|
return new GasFees(this.feePerDaGas * s, this.feePerL2Gas * s);
|
|
62
73
|
} else {
|
|
63
|
-
return new GasFees(
|
|
64
|
-
BigInt(Math.ceil(Number(this.feePerDaGas) * scalar)),
|
|
65
|
-
BigInt(Math.ceil(Number(this.feePerL2Gas) * scalar)),
|
|
66
|
-
);
|
|
74
|
+
return new GasFees(bigintMulCeil(this.feePerDaGas, scalar), bigintMulCeil(this.feePerL2Gas, scalar));
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import type { ApiSchemaFor } from '../schemas/schemas.js';
|
|
6
|
+
import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Debug interface for Aztec node available in sandbox/local-network mode.
|
|
10
|
+
*/
|
|
11
|
+
export interface AztecNodeDebug {
|
|
12
|
+
/**
|
|
13
|
+
* Triggers the sequencer to produce an L2 block and waits for it to appear.
|
|
14
|
+
*
|
|
15
|
+
* **Precondition**: The current L2 slot must not already contain a block. Callers must ensure L1 time has been
|
|
16
|
+
* advanced to a slot with no existing block before calling this method (e.g. via `EthCheatCodes.warp()`).
|
|
17
|
+
* If the slot is already taken, the sequencer will fail to propose and this call will time out.
|
|
18
|
+
*
|
|
19
|
+
* @throws If no sequencer is running.
|
|
20
|
+
*/
|
|
21
|
+
mineBlock(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const AztecNodeDebugApiSchema: ApiSchemaFor<AztecNodeDebug> = {
|
|
25
|
+
mineBlock: z.function().returns(z.void()),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function createAztecNodeDebugClient(
|
|
29
|
+
url: string,
|
|
30
|
+
versions: Partial<ComponentsVersions> = {},
|
|
31
|
+
fetch = defaultFetch,
|
|
32
|
+
apiKey?: string,
|
|
33
|
+
): AztecNodeDebug {
|
|
34
|
+
return createSafeJsonRpcClient<AztecNodeDebug>(url, AztecNodeDebugApiSchema, {
|
|
35
|
+
namespaceMethods: 'nodeDebug',
|
|
36
|
+
fetch,
|
|
37
|
+
onResponse: getVersioningResponseHandler(versions),
|
|
38
|
+
...(apiKey ? { extraHeaders: { 'x-api-key': apiKey } } : {}),
|
|
39
|
+
});
|
|
40
|
+
}
|
package/src/interfaces/client.ts
CHANGED
package/src/timetable/index.ts
CHANGED
|
@@ -25,6 +25,219 @@ export const DEFAULT_L1_PUBLISHING_TIME = 12;
|
|
|
25
25
|
/** Minimum execution time for building a block in seconds */
|
|
26
26
|
export const MIN_EXECUTION_TIME = 2;
|
|
27
27
|
|
|
28
|
+
export type CheckpointTimingConfig = {
|
|
29
|
+
aztecSlotDuration: number;
|
|
30
|
+
ethereumSlotDuration?: number;
|
|
31
|
+
blockDuration?: number;
|
|
32
|
+
checkpointAssembleTime?: number;
|
|
33
|
+
checkpointInitializationTime?: number;
|
|
34
|
+
l1PublishingTime?: number;
|
|
35
|
+
minExecutionTime?: number;
|
|
36
|
+
p2pPropagationTime?: number;
|
|
37
|
+
pipelining?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export interface CheckpointTiming {
|
|
41
|
+
readonly aztecSlotDuration: number;
|
|
42
|
+
readonly blockDuration: number | undefined;
|
|
43
|
+
readonly checkpointAssembleTime: number;
|
|
44
|
+
readonly checkpointInitializationTime: number;
|
|
45
|
+
readonly l1PublishingTime: number;
|
|
46
|
+
readonly minExecutionTime: number;
|
|
47
|
+
readonly p2pPropagationTime: number;
|
|
48
|
+
readonly checkpointFinalizationTime: number;
|
|
49
|
+
readonly pipeliningAttestationGracePeriod: number;
|
|
50
|
+
readonly timeReservedAtEnd: number;
|
|
51
|
+
readonly minimumBuildSlotWork: number;
|
|
52
|
+
readonly initializeDeadline: number;
|
|
53
|
+
readonly checkpointAssemblyDeadline: number;
|
|
54
|
+
readonly checkpointAttestationStartDeadline: number;
|
|
55
|
+
readonly checkpointAttestationDeadline: number;
|
|
56
|
+
readonly checkpointPublishingDeadline: number;
|
|
57
|
+
|
|
58
|
+
calculateMaxBlocksPerSlot(): number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PipelinedCheckpointTiming extends CheckpointTiming {
|
|
62
|
+
readonly proposalWindowIntoTargetSlot: number;
|
|
63
|
+
readonly attestationWindowIntoTargetSlot: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Shared base for checkpoint timing implementations.
|
|
68
|
+
*
|
|
69
|
+
* This class owns the common inputs and formulas used by both pipelined and
|
|
70
|
+
* non-pipelined scheduling. Variant-specific deadline math is delegated to the
|
|
71
|
+
* concrete subclasses below.
|
|
72
|
+
*/
|
|
73
|
+
abstract class BaseCheckpointTiming implements CheckpointTiming {
|
|
74
|
+
public readonly aztecSlotDuration: number;
|
|
75
|
+
public readonly blockDuration: number | undefined;
|
|
76
|
+
public readonly checkpointAssembleTime: number;
|
|
77
|
+
public readonly checkpointInitializationTime: number;
|
|
78
|
+
public readonly l1PublishingTime: number;
|
|
79
|
+
public readonly minExecutionTime: number;
|
|
80
|
+
public readonly p2pPropagationTime: number;
|
|
81
|
+
|
|
82
|
+
constructor(opts: CheckpointTimingConfig) {
|
|
83
|
+
this.aztecSlotDuration = opts.aztecSlotDuration;
|
|
84
|
+
this.blockDuration = opts.blockDuration;
|
|
85
|
+
|
|
86
|
+
this.checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
|
|
87
|
+
this.checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
|
|
88
|
+
this.l1PublishingTime = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
|
|
89
|
+
this.minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
|
|
90
|
+
this.p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public get checkpointFinalizationTime(): number {
|
|
94
|
+
// Allow enough time to
|
|
95
|
+
// - build the checkpoint
|
|
96
|
+
// - Round-trip over p2p
|
|
97
|
+
// - Publish to L1
|
|
98
|
+
return this.checkpointAssembleTime + this.p2pPropagationTime * 2 + this.l1PublishingTime;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public get pipeliningAttestationGracePeriod(): number {
|
|
102
|
+
// Allow enough time to
|
|
103
|
+
// - build the block
|
|
104
|
+
// - pass it back over p2p
|
|
105
|
+
return (this.blockDuration ?? 0) + this.p2pPropagationTime;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public abstract get timeReservedAtEnd(): number;
|
|
109
|
+
public abstract get minimumBuildSlotWork(): number;
|
|
110
|
+
|
|
111
|
+
public get initializeDeadline(): number {
|
|
112
|
+
return this.aztecSlotDuration - this.minimumBuildSlotWork;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public abstract get checkpointAssemblyDeadline(): number;
|
|
116
|
+
|
|
117
|
+
public get checkpointAttestationStartDeadline(): number {
|
|
118
|
+
return this.checkpointAssemblyDeadline;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public abstract get checkpointAttestationDeadline(): number;
|
|
122
|
+
public abstract get checkpointPublishingDeadline(): number;
|
|
123
|
+
|
|
124
|
+
public calculateMaxBlocksPerSlot(): number {
|
|
125
|
+
if (!this.blockDuration) {
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const timeAvailableForBlocks = this.aztecSlotDuration - this.checkpointInitializationTime - this.timeReservedAtEnd;
|
|
130
|
+
return Math.floor(timeAvailableForBlocks / this.blockDuration);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Checkpoint timing model for the non-pipelined sequencer flow.
|
|
136
|
+
*
|
|
137
|
+
* In this mode, checkpoint assembly, attestation collection, and L1 publishing
|
|
138
|
+
* must all complete within the current Aztec slot.
|
|
139
|
+
*/
|
|
140
|
+
class StandardCheckpointTimingModel extends BaseCheckpointTiming {
|
|
141
|
+
public get timeReservedAtEnd(): number {
|
|
142
|
+
return (this.blockDuration ?? 0) + this.checkpointFinalizationTime;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public get minimumBuildSlotWork(): number {
|
|
146
|
+
return this.checkpointInitializationTime + this.minExecutionTime * 2 + this.checkpointFinalizationTime;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public get checkpointAssemblyDeadline(): number {
|
|
150
|
+
return this.aztecSlotDuration - this.l1PublishingTime - 2 * this.p2pPropagationTime;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public get checkpointAttestationDeadline(): number {
|
|
154
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public get checkpointPublishingDeadline(): number {
|
|
158
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Checkpoint timing model for proposer pipelining.
|
|
164
|
+
*
|
|
165
|
+
* In this mode, the build work still starts in the current slot, but checkpoint
|
|
166
|
+
* assembly and attestation collection can extend into the target slot. The extra
|
|
167
|
+
* target-slot window getters are intended for consumers such as P2P validators
|
|
168
|
+
* that need to validate pipelined messages against wallclock time.
|
|
169
|
+
*/
|
|
170
|
+
class PipelinedCheckpointTimingModel extends BaseCheckpointTiming implements PipelinedCheckpointTiming {
|
|
171
|
+
public get proposalWindowIntoTargetSlot(): number {
|
|
172
|
+
// Allow the p2p propagation time to receive a checkpoint proposal from leader
|
|
173
|
+
return this.p2pPropagationTime;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public get attestationWindowIntoTargetSlot(): number {
|
|
177
|
+
return this.aztecSlotDuration - this.l1PublishingTime;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public get timeReservedAtEnd(): number {
|
|
181
|
+
return this.checkpointAssembleTime + this.p2pPropagationTime;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public get minimumBuildSlotWork(): number {
|
|
185
|
+
return this.checkpointInitializationTime + this.minExecutionTime * 2;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public get checkpointAssemblyDeadline(): number {
|
|
189
|
+
// Allow enough time to
|
|
190
|
+
// - build all blocks
|
|
191
|
+
// - receive attestations
|
|
192
|
+
return this.aztecSlotDuration + this.pipeliningAttestationGracePeriod;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public get checkpointAttestationDeadline(): number {
|
|
196
|
+
// Allowed to be into the next wallclock slot minus the allocated l1 publishing time
|
|
197
|
+
return this.aztecSlotDuration * 2 - this.l1PublishingTime;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public get checkpointPublishingDeadline(): number {
|
|
201
|
+
// Allowed to be into the next wallclock slot minus the allocated l1 Publishing time
|
|
202
|
+
return this.aztecSlotDuration * 2 - this.l1PublishingTime;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Creates a checkpoint timing model for the requested scheduling mode.
|
|
208
|
+
*
|
|
209
|
+
* Most callers should use this factory and depend only on the shared
|
|
210
|
+
* `CheckpointTiming` interface. The returned implementation is selected from
|
|
211
|
+
* `opts.pipelining`.
|
|
212
|
+
*/
|
|
213
|
+
export function createCheckpointTimingModel(opts: CheckpointTimingConfig): CheckpointTiming {
|
|
214
|
+
validateCheckpointTimingConfig(opts);
|
|
215
|
+
const normalizedOpts = normalizeCheckpointTimingConfig(opts);
|
|
216
|
+
|
|
217
|
+
const timing = normalizedOpts.pipelining
|
|
218
|
+
? new PipelinedCheckpointTimingModel(normalizedOpts)
|
|
219
|
+
: new StandardCheckpointTimingModel(normalizedOpts);
|
|
220
|
+
validateCheckpointTimingModel(timing);
|
|
221
|
+
return timing;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Creates a pipelined checkpoint timing model with target-slot window accessors.
|
|
226
|
+
*
|
|
227
|
+
* Use this when the caller specifically needs the pipelined-only timing surface,
|
|
228
|
+
* such as proposal or attestation acceptance windows into the target slot.
|
|
229
|
+
*/
|
|
230
|
+
export function createPipelinedCheckpointTimingModel(
|
|
231
|
+
opts: Omit<CheckpointTimingConfig, 'pipelining'>,
|
|
232
|
+
): PipelinedCheckpointTiming {
|
|
233
|
+
validateCheckpointTimingConfig(opts);
|
|
234
|
+
const normalizedOpts = normalizeCheckpointTimingConfig(opts);
|
|
235
|
+
|
|
236
|
+
const timing = new PipelinedCheckpointTimingModel(normalizedOpts);
|
|
237
|
+
validateCheckpointTimingModel(timing);
|
|
238
|
+
return timing;
|
|
239
|
+
}
|
|
240
|
+
|
|
28
241
|
/**
|
|
29
242
|
* Calculates the maximum number of blocks that can be built in a slot.
|
|
30
243
|
* Used by both the sequencer timetable and p2p gossipsub scoring.
|
|
@@ -45,27 +258,89 @@ export function calculateMaxBlocksPerSlot(
|
|
|
45
258
|
pipelining?: boolean;
|
|
46
259
|
} = {},
|
|
47
260
|
): number {
|
|
48
|
-
|
|
49
|
-
|
|
261
|
+
return createCheckpointTimingModel({
|
|
262
|
+
aztecSlotDuration: aztecSlotDurationSec,
|
|
263
|
+
blockDuration: blockDurationSec,
|
|
264
|
+
checkpointAssembleTime: opts.checkpointAssembleTime,
|
|
265
|
+
checkpointInitializationTime: opts.checkpointInitializationTime,
|
|
266
|
+
l1PublishingTime: opts.l1PublishingTime,
|
|
267
|
+
p2pPropagationTime: opts.p2pPropagationTime,
|
|
268
|
+
pipelining: opts.pipelining,
|
|
269
|
+
}).calculateMaxBlocksPerSlot();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function assertNonNegative(name: string, value: number): void {
|
|
273
|
+
if (value < 0) {
|
|
274
|
+
throw new Error(`${name} must be non-negative (got ${value})`);
|
|
50
275
|
}
|
|
276
|
+
}
|
|
51
277
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
278
|
+
function validateCheckpointTimingConfig(opts: CheckpointTimingConfig): void {
|
|
279
|
+
if (opts.aztecSlotDuration <= 0) {
|
|
280
|
+
throw new Error(`aztecSlotDuration must be positive (got ${opts.aztecSlotDuration})`);
|
|
281
|
+
}
|
|
56
282
|
|
|
57
|
-
|
|
58
|
-
|
|
283
|
+
if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration <= 0) {
|
|
284
|
+
throw new Error(`ethereumSlotDuration must be positive when provided (got ${opts.ethereumSlotDuration})`);
|
|
285
|
+
}
|
|
59
286
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let timeReservedAtEnd = blockDurationSec;
|
|
63
|
-
if (!opts.pipelining) {
|
|
64
|
-
timeReservedAtEnd += checkpointFinalizationTime;
|
|
287
|
+
if (opts.blockDuration !== undefined && opts.blockDuration <= 0) {
|
|
288
|
+
throw new Error(`blockDuration must be positive when provided (got ${opts.blockDuration})`);
|
|
65
289
|
}
|
|
66
290
|
|
|
67
|
-
|
|
68
|
-
|
|
291
|
+
if (opts.minExecutionTime !== undefined && opts.minExecutionTime <= 0) {
|
|
292
|
+
throw new Error(`minExecutionTime must be positive when provided (got ${opts.minExecutionTime})`);
|
|
293
|
+
}
|
|
69
294
|
|
|
70
|
-
|
|
295
|
+
if (opts.checkpointAssembleTime !== undefined) {
|
|
296
|
+
assertNonNegative('checkpointAssembleTime', opts.checkpointAssembleTime);
|
|
297
|
+
}
|
|
298
|
+
if (opts.checkpointInitializationTime !== undefined) {
|
|
299
|
+
assertNonNegative('checkpointInitializationTime', opts.checkpointInitializationTime);
|
|
300
|
+
}
|
|
301
|
+
if (opts.l1PublishingTime !== undefined) {
|
|
302
|
+
assertNonNegative('l1PublishingTime', opts.l1PublishingTime);
|
|
303
|
+
}
|
|
304
|
+
if (opts.p2pPropagationTime !== undefined) {
|
|
305
|
+
assertNonNegative('p2pPropagationTime', opts.p2pPropagationTime);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function normalizeCheckpointTimingConfig(opts: CheckpointTimingConfig): CheckpointTimingConfig {
|
|
310
|
+
let checkpointAssembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
|
|
311
|
+
let checkpointInitializationTime = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
|
|
312
|
+
let minExecutionTime = opts.minExecutionTime ?? MIN_EXECUTION_TIME;
|
|
313
|
+
let p2pPropagationTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
|
|
314
|
+
|
|
315
|
+
if (opts.ethereumSlotDuration !== undefined && opts.ethereumSlotDuration < 8) {
|
|
316
|
+
p2pPropagationTime = 0;
|
|
317
|
+
checkpointAssembleTime = 0.5;
|
|
318
|
+
checkpointInitializationTime = 0.5;
|
|
319
|
+
minExecutionTime = 1;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (opts.blockDuration !== undefined && minExecutionTime > opts.blockDuration) {
|
|
323
|
+
minExecutionTime = opts.blockDuration;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return {
|
|
327
|
+
...opts,
|
|
328
|
+
checkpointAssembleTime,
|
|
329
|
+
checkpointInitializationTime,
|
|
330
|
+
minExecutionTime,
|
|
331
|
+
p2pPropagationTime,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function validateCheckpointTimingModel(model: CheckpointTiming): void {
|
|
336
|
+
if (model.blockDuration === undefined) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const timeAvailableForBlocks = model.aztecSlotDuration - model.checkpointInitializationTime - model.timeReservedAtEnd;
|
|
341
|
+
if (timeAvailableForBlocks < model.blockDuration) {
|
|
342
|
+
throw new Error(
|
|
343
|
+
`Invalid timing configuration: only ${timeAvailableForBlocks}s available for block building, which is less than one blockDuration (${model.blockDuration}s).`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
71
346
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
3
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
3
|
import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
5
4
|
|
|
@@ -8,18 +7,6 @@ import type { GasFees } from '../gas/gas_fees.js';
|
|
|
8
7
|
import type { UInt32 } from '../types/index.js';
|
|
9
8
|
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
10
9
|
|
|
11
|
-
/** Fee header fields needed for pipelining overrides. */
|
|
12
|
-
export type ForceProposedFeeHeader = {
|
|
13
|
-
checkpointNumber: CheckpointNumber;
|
|
14
|
-
feeHeader: FeeHeader;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/** Options for building checkpoint global variables during pipelining. */
|
|
18
|
-
export type BuildCheckpointGlobalVariablesOpts = {
|
|
19
|
-
forcePendingCheckpointNumber?: CheckpointNumber;
|
|
20
|
-
forceProposedFeeHeader?: ForceProposedFeeHeader;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
10
|
/**
|
|
24
11
|
* Interface for building global variables for Aztec blocks.
|
|
25
12
|
*/
|
|
@@ -46,6 +33,6 @@ export interface GlobalVariableBuilder {
|
|
|
46
33
|
coinbase: EthAddress,
|
|
47
34
|
feeRecipient: AztecAddress,
|
|
48
35
|
slotNumber: SlotNumber,
|
|
49
|
-
|
|
36
|
+
simulationOverridesPlan?: SimulationOverridesPlan,
|
|
50
37
|
): Promise<CheckpointGlobalVariables>;
|
|
51
38
|
}
|
package/src/tx/simulated_tx.ts
CHANGED
|
@@ -161,7 +161,7 @@ export class TxSimulationResult {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* Recursively
|
|
164
|
+
* Recursively accumulate the return values of a call result and its nested executions,
|
|
165
165
|
* so they can be retrieved in order.
|
|
166
166
|
* @param executionResult
|
|
167
167
|
* @returns
|