@aztec/stdlib 0.0.1-commit.6d63667d → 0.0.1-commit.7cf39cb55

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.
Files changed (108) hide show
  1. package/dest/abi/function_call.d.ts +39 -9
  2. package/dest/abi/function_call.d.ts.map +1 -1
  3. package/dest/abi/function_call.js +20 -3
  4. package/dest/block/in_block.js +1 -1
  5. package/dest/config/index.d.ts +2 -1
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +1 -0
  8. package/dest/config/sequencer-config.d.ts +10 -0
  9. package/dest/config/sequencer-config.d.ts.map +1 -0
  10. package/dest/config/sequencer-config.js +12 -0
  11. package/dest/contract/interfaces/node-info.d.ts +3 -1
  12. package/dest/contract/interfaces/node-info.d.ts.map +1 -1
  13. package/dest/contract/interfaces/node-info.js +2 -1
  14. package/dest/epoch-helpers/index.d.ts +5 -1
  15. package/dest/epoch-helpers/index.d.ts.map +1 -1
  16. package/dest/epoch-helpers/index.js +4 -2
  17. package/dest/hash/hash.d.ts +2 -1
  18. package/dest/hash/hash.d.ts.map +1 -1
  19. package/dest/hash/hash.js +6 -0
  20. package/dest/interfaces/aztec-node-admin.d.ts +10 -1
  21. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  22. package/dest/interfaces/p2p.d.ts +2 -2
  23. package/dest/interfaces/p2p.d.ts.map +1 -1
  24. package/dest/interfaces/proving-job.d.ts +166 -166
  25. package/dest/interfaces/slasher.d.ts +9 -1
  26. package/dest/interfaces/slasher.d.ts.map +1 -1
  27. package/dest/interfaces/slasher.js +2 -0
  28. package/dest/interfaces/validator.d.ts +16 -2
  29. package/dest/interfaces/validator.d.ts.map +1 -1
  30. package/dest/interfaces/validator.js +4 -1
  31. package/dest/logs/siloed_tag.d.ts +1 -1
  32. package/dest/logs/siloed_tag.d.ts.map +1 -1
  33. package/dest/logs/siloed_tag.js +2 -6
  34. package/dest/messaging/l2_to_l1_membership.d.ts +2 -2
  35. package/dest/messaging/l2_to_l1_membership.js +3 -3
  36. package/dest/note/notes_filter.d.ts +5 -2
  37. package/dest/note/notes_filter.d.ts.map +1 -1
  38. package/dest/p2p/checkpoint_proposal.d.ts +8 -1
  39. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  40. package/dest/p2p/checkpoint_proposal.js +9 -0
  41. package/dest/p2p/constants.d.ts +3 -1
  42. package/dest/p2p/constants.d.ts.map +1 -1
  43. package/dest/p2p/constants.js +1 -0
  44. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +6 -6
  45. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
  46. package/dest/rollup/checkpoint_rollup_public_inputs.js +2 -2
  47. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +2 -2
  48. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
  49. package/dest/rollup/root_rollup_public_inputs.d.ts +6 -6
  50. package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
  51. package/dest/rollup/root_rollup_public_inputs.js +3 -3
  52. package/dest/slashing/empire.d.ts +1 -1
  53. package/dest/slashing/empire.d.ts.map +1 -1
  54. package/dest/slashing/empire.js +2 -0
  55. package/dest/slashing/helpers.d.ts +2 -2
  56. package/dest/slashing/helpers.d.ts.map +1 -1
  57. package/dest/slashing/helpers.js +6 -0
  58. package/dest/slashing/tally.d.ts +2 -1
  59. package/dest/slashing/tally.d.ts.map +1 -1
  60. package/dest/slashing/tally.js +6 -2
  61. package/dest/slashing/types.d.ts +7 -3
  62. package/dest/slashing/types.d.ts.map +1 -1
  63. package/dest/slashing/types.js +13 -1
  64. package/dest/tests/factories.js +3 -3
  65. package/dest/timetable/index.d.ts +37 -0
  66. package/dest/timetable/index.d.ts.map +1 -0
  67. package/dest/timetable/index.js +39 -0
  68. package/dest/trees/public_data_leaf.d.ts +2 -1
  69. package/dest/trees/public_data_leaf.d.ts.map +1 -1
  70. package/dest/trees/public_data_leaf.js +7 -6
  71. package/dest/tx/validator/empty_validator.d.ts +2 -2
  72. package/dest/tx/validator/empty_validator.d.ts.map +1 -1
  73. package/dest/tx/validator/tx_validator.d.ts +2 -2
  74. package/dest/tx/validator/tx_validator.d.ts.map +1 -1
  75. package/dest/validators/schemas.d.ts +30 -30
  76. package/dest/validators/schemas.d.ts.map +1 -1
  77. package/dest/validators/schemas.js +4 -3
  78. package/dest/validators/types.d.ts +3 -3
  79. package/dest/validators/types.d.ts.map +1 -1
  80. package/package.json +11 -10
  81. package/src/abi/function_call.ts +25 -3
  82. package/src/block/in_block.ts +1 -1
  83. package/src/config/index.ts +1 -0
  84. package/src/config/sequencer-config.ts +19 -0
  85. package/src/contract/interfaces/node-info.ts +3 -0
  86. package/src/epoch-helpers/index.ts +3 -0
  87. package/src/hash/hash.ts +4 -0
  88. package/src/interfaces/p2p.ts +1 -1
  89. package/src/interfaces/slasher.ts +4 -0
  90. package/src/interfaces/validator.ts +10 -1
  91. package/src/logs/siloed_tag.ts +2 -3
  92. package/src/messaging/l2_to_l1_membership.ts +3 -3
  93. package/src/note/notes_filter.ts +4 -1
  94. package/src/p2p/checkpoint_proposal.ts +10 -0
  95. package/src/p2p/constants.ts +3 -0
  96. package/src/rollup/checkpoint_rollup_public_inputs.ts +5 -5
  97. package/src/rollup/root_rollup_public_inputs.ts +7 -7
  98. package/src/slashing/empire.ts +3 -1
  99. package/src/slashing/helpers.ts +8 -0
  100. package/src/slashing/tally.ts +8 -2
  101. package/src/slashing/types.ts +14 -0
  102. package/src/tests/factories.ts +5 -5
  103. package/src/timetable/index.ts +66 -0
  104. package/src/trees/public_data_leaf.ts +11 -5
  105. package/src/tx/validator/empty_validator.ts +1 -1
  106. package/src/tx/validator/tx_validator.ts +1 -1
  107. package/src/validators/schemas.ts +8 -1
  108. package/src/validators/types.ts +5 -4
@@ -1,5 +1,5 @@
1
1
  import { BlobAccumulator, FinalBlobBatchingChallenges } from '@aztec/blob-lib/types';
2
- import { AZTEC_MAX_EPOCH_DURATION } from '@aztec/constants';
2
+ import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { bufferSchemaFor } from '@aztec/foundation/schemas';
@@ -38,11 +38,11 @@ export class CheckpointRollupPublicInputs {
38
38
  /**
39
39
  * The hashes of the headers of the constituent checkpoints.
40
40
  */
41
- public checkpointHeaderHashes: Tuple<Fr, typeof AZTEC_MAX_EPOCH_DURATION>,
41
+ public checkpointHeaderHashes: Tuple<Fr, typeof MAX_CHECKPOINTS_PER_EPOCH>,
42
42
  /**
43
43
  * The summed transaction fees and recipients of the constituent checkpoints.
44
44
  */
45
- public fees: Tuple<FeeRecipient, typeof AZTEC_MAX_EPOCH_DURATION>,
45
+ public fees: Tuple<FeeRecipient, typeof MAX_CHECKPOINTS_PER_EPOCH>,
46
46
  /**
47
47
  * Accumulated opening proofs for all blobs before this checkpoint range.
48
48
  */
@@ -65,8 +65,8 @@ export class CheckpointRollupPublicInputs {
65
65
  reader.readObject(AppendOnlyTreeSnapshot),
66
66
  reader.readObject(AppendOnlyTreeSnapshot),
67
67
  reader.readObject(AppendOnlyTreeSnapshot),
68
- reader.readArray(AZTEC_MAX_EPOCH_DURATION, Fr),
69
- reader.readArray(AZTEC_MAX_EPOCH_DURATION, FeeRecipient),
68
+ reader.readArray(MAX_CHECKPOINTS_PER_EPOCH, Fr),
69
+ reader.readArray(MAX_CHECKPOINTS_PER_EPOCH, FeeRecipient),
70
70
  reader.readObject(BlobAccumulator),
71
71
  reader.readObject(BlobAccumulator),
72
72
  reader.readObject(FinalBlobBatchingChallenges),
@@ -1,5 +1,5 @@
1
1
  import { FinalBlobAccumulator } from '@aztec/blob-lib/types';
2
- import { AZTEC_MAX_EPOCH_DURATION } from '@aztec/constants';
2
+ import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
3
3
  import { makeTuple } from '@aztec/foundation/array';
4
4
  import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import { bufferSchemaFor } from '@aztec/foundation/schemas';
@@ -27,8 +27,8 @@ export class RootRollupPublicInputs {
27
27
  */
28
28
  public outHash: Fr,
29
29
  /** Hashes of checkpoint headers for this rollup. */
30
- public checkpointHeaderHashes: Tuple<Fr, typeof AZTEC_MAX_EPOCH_DURATION>,
31
- public fees: Tuple<FeeRecipient, typeof AZTEC_MAX_EPOCH_DURATION>,
30
+ public checkpointHeaderHashes: Tuple<Fr, typeof MAX_CHECKPOINTS_PER_EPOCH>,
31
+ public fees: Tuple<FeeRecipient, typeof MAX_CHECKPOINTS_PER_EPOCH>,
32
32
  public constants: EpochConstantData,
33
33
  public blobPublicInputs: FinalBlobAccumulator,
34
34
  ) {}
@@ -68,8 +68,8 @@ export class RootRollupPublicInputs {
68
68
  Fr.fromBuffer(reader),
69
69
  Fr.fromBuffer(reader),
70
70
  Fr.fromBuffer(reader),
71
- reader.readArray(AZTEC_MAX_EPOCH_DURATION, Fr),
72
- reader.readArray(AZTEC_MAX_EPOCH_DURATION, FeeRecipient),
71
+ reader.readArray(MAX_CHECKPOINTS_PER_EPOCH, Fr),
72
+ reader.readArray(MAX_CHECKPOINTS_PER_EPOCH, FeeRecipient),
73
73
  EpochConstantData.fromBuffer(reader),
74
74
  reader.readObject(FinalBlobAccumulator),
75
75
  );
@@ -99,8 +99,8 @@ export class RootRollupPublicInputs {
99
99
  Fr.random(),
100
100
  Fr.random(),
101
101
  Fr.random(),
102
- makeTuple(AZTEC_MAX_EPOCH_DURATION, Fr.random),
103
- makeTuple(AZTEC_MAX_EPOCH_DURATION, FeeRecipient.random),
102
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH, Fr.random),
103
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH, FeeRecipient.random),
104
104
  new EpochConstantData(Fr.random(), Fr.random(), Fr.random(), Fr.random(), Fr.random()),
105
105
  FinalBlobAccumulator.random(),
106
106
  );
@@ -83,7 +83,9 @@ export function getFirstEligibleRoundForOffense(
83
83
  case OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS:
84
84
  case OffenseType.PROPOSED_INCORRECT_ATTESTATIONS:
85
85
  case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
86
- case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL: {
86
+ case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
87
+ case OffenseType.DUPLICATE_PROPOSAL:
88
+ case OffenseType.DUPLICATE_ATTESTATION: {
87
89
  const slot = offense.epochOrSlot;
88
90
  const detectedSlot = SlotNumber.fromBigInt(slot + 1n);
89
91
  return getRoundForSlot(detectedSlot, constants).round + 1n;
@@ -50,6 +50,8 @@ export function getPenaltyForOffense(
50
50
  SlasherConfig,
51
51
  | 'slashAttestDescendantOfInvalidPenalty'
52
52
  | 'slashBroadcastedInvalidBlockPenalty'
53
+ | 'slashDuplicateProposalPenalty'
54
+ | 'slashDuplicateAttestationPenalty'
53
55
  | 'slashPrunePenalty'
54
56
  | 'slashDataWithholdingPenalty'
55
57
  | 'slashUnknownPenalty'
@@ -71,6 +73,10 @@ export function getPenaltyForOffense(
71
73
  return config.slashAttestDescendantOfInvalidPenalty;
72
74
  case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
73
75
  return config.slashBroadcastedInvalidBlockPenalty;
76
+ case OffenseType.DUPLICATE_PROPOSAL:
77
+ return config.slashDuplicateProposalPenalty;
78
+ case OffenseType.DUPLICATE_ATTESTATION:
79
+ return config.slashDuplicateAttestationPenalty;
74
80
  case OffenseType.UNKNOWN:
75
81
  return config.slashUnknownPenalty;
76
82
  default: {
@@ -85,6 +91,8 @@ export function getTimeUnitForOffense(offense: OffenseType): 'epoch' | 'slot' {
85
91
  switch (offense) {
86
92
  case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
87
93
  case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
94
+ case OffenseType.DUPLICATE_PROPOSAL:
95
+ case OffenseType.DUPLICATE_ATTESTATION:
88
96
  case OffenseType.PROPOSED_INCORRECT_ATTESTATIONS:
89
97
  case OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS:
90
98
  return 'slot';
@@ -1,4 +1,5 @@
1
1
  import { sumBigint } from '@aztec/foundation/bigint';
2
+ import { padArrayEnd } from '@aztec/foundation/collection';
2
3
  import { EthAddress } from '@aztec/foundation/eth-address';
3
4
  import type { PartialBy } from '@aztec/foundation/types';
4
5
 
@@ -20,9 +21,10 @@ export function getSlashConsensusVotesFromOffenses(
20
21
  settings: {
21
22
  slashingAmounts: [bigint, bigint, bigint];
22
23
  epochDuration: number;
24
+ targetCommitteeSize: number;
23
25
  },
24
26
  ): ValidatorSlashVote[] {
25
- const { slashingAmounts } = settings;
27
+ const { slashingAmounts, targetCommitteeSize } = settings;
26
28
 
27
29
  if (committees.length !== epochsForCommittees.length) {
28
30
  throw new Error('committees and epochsForCommittees must have the same length');
@@ -31,7 +33,9 @@ export function getSlashConsensusVotesFromOffenses(
31
33
  const votes = committees.flatMap((committee, committeeIndex) => {
32
34
  const committeeEpoch = epochsForCommittees[committeeIndex];
33
35
 
34
- return committee.map(validator => {
36
+ // Map over actual committee members, then pad to targetCommitteeSize.
37
+ // Padding handles cases where committees may be empty (e.g., when there aren't enough validators to fill the committee size during network startup).
38
+ const votes = committee.map(validator => {
35
39
  // Find offenses for this validator in this specific epoch.
36
40
  // If an offense has no epoch, it is considered for all epochs due to a slashAlways setting.
37
41
  const validatorOffenses = offenses.filter(
@@ -45,6 +49,8 @@ export function getSlashConsensusVotesFromOffenses(
45
49
  const slashUnits = getSlashUnitsForAmount(slashAmount, slashingAmounts);
46
50
  return Number(slashUnits);
47
51
  });
52
+
53
+ return padArrayEnd(votes, 0, targetCommitteeSize);
48
54
  });
49
55
 
50
56
  return votes;
@@ -20,6 +20,10 @@ export enum OffenseType {
20
20
  PROPOSED_INCORRECT_ATTESTATIONS = 6,
21
21
  /** A committee member attested to a block that was built as a descendent of an invalid block (as in a block with invalid attestations) */
22
22
  ATTESTED_DESCENDANT_OF_INVALID = 7,
23
+ /** A proposer sent duplicate proposals for the same position (slot, indexWithinCheckpoint for blocks or slot for checkpoints) */
24
+ DUPLICATE_PROPOSAL = 8,
25
+ /** A validator signed attestations for different proposals at the same slot (equivocation) */
26
+ DUPLICATE_ATTESTATION = 9,
23
27
  }
24
28
 
25
29
  export function getOffenseTypeName(offense: OffenseType) {
@@ -40,6 +44,10 @@ export function getOffenseTypeName(offense: OffenseType) {
40
44
  return 'proposed_incorrect_attestations';
41
45
  case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
42
46
  return 'attested_descendant_of_invalid';
47
+ case OffenseType.DUPLICATE_PROPOSAL:
48
+ return 'duplicate_proposal';
49
+ case OffenseType.DUPLICATE_ATTESTATION:
50
+ return 'duplicate_attestation';
43
51
  default:
44
52
  throw new Error(`Unknown offense type: ${offense}`);
45
53
  }
@@ -56,6 +64,8 @@ export const OffenseToBigInt: Record<OffenseType, bigint> = {
56
64
  [OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS]: 5n,
57
65
  [OffenseType.PROPOSED_INCORRECT_ATTESTATIONS]: 6n,
58
66
  [OffenseType.ATTESTED_DESCENDANT_OF_INVALID]: 7n,
67
+ [OffenseType.DUPLICATE_PROPOSAL]: 8n,
68
+ [OffenseType.DUPLICATE_ATTESTATION]: 9n,
59
69
  };
60
70
 
61
71
  export function bigIntToOffense(offense: bigint): OffenseType {
@@ -76,6 +86,10 @@ export function bigIntToOffense(offense: bigint): OffenseType {
76
86
  return OffenseType.PROPOSED_INCORRECT_ATTESTATIONS;
77
87
  case 7n:
78
88
  return OffenseType.ATTESTED_DESCENDANT_OF_INVALID;
89
+ case 8n:
90
+ return OffenseType.DUPLICATE_PROPOSAL;
91
+ case 9n:
92
+ return OffenseType.DUPLICATE_ATTESTATION;
79
93
  default:
80
94
  throw new Error(`Unknown offense: ${offense}`);
81
95
  }
@@ -7,11 +7,11 @@ import {
7
7
  import {
8
8
  ARCHIVE_HEIGHT,
9
9
  AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
10
- AZTEC_MAX_EPOCH_DURATION,
11
10
  CHONK_PROOF_LENGTH,
12
11
  CONTRACT_CLASS_LOG_SIZE_IN_FIELDS,
13
12
  GeneratorIndex,
14
13
  L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
14
+ MAX_CHECKPOINTS_PER_EPOCH,
15
15
  MAX_CONTRACT_CLASS_LOGS_PER_TX,
16
16
  MAX_ENQUEUED_CALLS_PER_CALL,
17
17
  MAX_ENQUEUED_CALLS_PER_TX,
@@ -851,8 +851,8 @@ export function makeCheckpointRollupPublicInputs(seed = 0) {
851
851
  makeAppendOnlyTreeSnapshot(seed + 0x200),
852
852
  makeAppendOnlyTreeSnapshot(seed + 0x300),
853
853
  makeAppendOnlyTreeSnapshot(seed + 0x350),
854
- makeTuple(AZTEC_MAX_EPOCH_DURATION, () => fr(seed), 0x400),
855
- makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x500),
854
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH, () => fr(seed), 0x400),
855
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH, () => makeFeeRecipient(seed), 0x500),
856
856
  makeBlobAccumulator(seed + 0x600),
857
857
  makeBlobAccumulator(seed + 0x700),
858
858
  makeFinalBlobBatchingChallenges(seed + 0x800),
@@ -888,8 +888,8 @@ export function makeRootRollupPublicInputs(seed = 0): RootRollupPublicInputs {
888
888
  fr(seed + 0x100),
889
889
  fr(seed + 0x200),
890
890
  fr(seed + 0x300),
891
- makeTuple(AZTEC_MAX_EPOCH_DURATION, () => fr(seed), 0x400),
892
- makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x500),
891
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH, () => fr(seed), 0x400),
892
+ makeTuple(MAX_CHECKPOINTS_PER_EPOCH, () => makeFeeRecipient(seed), 0x500),
893
893
  makeEpochConstantData(seed + 0x600),
894
894
  makeFinalBlobAccumulator(seed + 0x700),
895
895
  );
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Timetable constants used for sequencer timing calculations.
3
+ * These define the time budgets for various phases of block production.
4
+ *
5
+ * The sequencer slot is divided into phases:
6
+ * 1. Checkpoint initialization (sync + proposer check)
7
+ * 2. Block building (execution)
8
+ * 3. Checkpoint assembly
9
+ * 4. P2P propagation for proposal and attestations (round-trip)
10
+ * 5. L1 publishing
11
+ */
12
+
13
+ /** Time budget for checkpoint initialization (sync + proposer check) in seconds */
14
+ export const CHECKPOINT_INITIALIZATION_TIME = 1;
15
+
16
+ /** Time budget for assembling a checkpoint after building the last block in seconds */
17
+ export const CHECKPOINT_ASSEMBLE_TIME = 1;
18
+
19
+ /** Default one-way P2P propagation time for proposals and attestations in seconds */
20
+ export const DEFAULT_P2P_PROPAGATION_TIME = 2;
21
+
22
+ /** Default L1 publishing time (matches Ethereum slot duration on mainnet) in seconds */
23
+ export const DEFAULT_L1_PUBLISHING_TIME = 12;
24
+
25
+ /** Minimum execution time for building a block in seconds */
26
+ export const MIN_EXECUTION_TIME = 2;
27
+
28
+ /**
29
+ * Calculates the maximum number of blocks that can be built in a slot.
30
+ * Used by both the sequencer timetable and p2p gossipsub scoring.
31
+ *
32
+ * @param aztecSlotDurationSec - Aztec slot duration in seconds
33
+ * @param blockDurationSec - Duration per block in seconds (undefined = single block mode)
34
+ * @param opts - Optional overrides for timing constants
35
+ * @returns Maximum number of blocks per slot
36
+ */
37
+ export function calculateMaxBlocksPerSlot(
38
+ aztecSlotDurationSec: number,
39
+ blockDurationSec: number | undefined,
40
+ opts: {
41
+ checkpointInitializationTime?: number;
42
+ checkpointAssembleTime?: number;
43
+ p2pPropagationTime?: number;
44
+ l1PublishingTime?: number;
45
+ } = {},
46
+ ): number {
47
+ if (!blockDurationSec) {
48
+ return 1; // Single block per slot
49
+ }
50
+
51
+ const initOffset = opts.checkpointInitializationTime ?? CHECKPOINT_INITIALIZATION_TIME;
52
+ const assembleTime = opts.checkpointAssembleTime ?? CHECKPOINT_ASSEMBLE_TIME;
53
+ const p2pTime = opts.p2pPropagationTime ?? DEFAULT_P2P_PROPAGATION_TIME;
54
+ const l1Time = opts.l1PublishingTime ?? DEFAULT_L1_PUBLISHING_TIME;
55
+
56
+ // Calculate checkpoint finalization time (assembly + round-trip propagation + L1 publishing)
57
+ const checkpointFinalizationTime = assembleTime + p2pTime * 2 + l1Time;
58
+
59
+ // Time reserved at end for last sub-slot (validator re-execution) + finalization
60
+ const timeReservedAtEnd = blockDurationSec + checkpointFinalizationTime;
61
+
62
+ // Time available for building blocks
63
+ const timeAvailableForBlocks = aztecSlotDurationSec - initOffset - timeReservedAtEnd;
64
+
65
+ return Math.max(1, Math.floor(timeAvailableForBlocks / blockDurationSec));
66
+ }
@@ -1,4 +1,5 @@
1
1
  import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer';
2
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import { schemas } from '@aztec/foundation/schemas';
4
5
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
@@ -81,11 +82,15 @@ export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
81
82
  toHashInputs(): Buffer[] {
82
83
  return [
83
84
  ...this.leaf.toHashInputs(),
84
- Buffer.from(toBufferBE(this.nextIndex, 32)),
85
85
  Buffer.from(this.nextKey.toBuffer()),
86
+ Buffer.from(toBufferBE(this.nextIndex, 32)),
86
87
  ];
87
88
  }
88
89
 
90
+ hash(): Promise<Fr> {
91
+ return poseidon2Hash(this.toHashInputs());
92
+ }
93
+
89
94
  clone(): PublicDataTreeLeafPreimage {
90
95
  return new PublicDataTreeLeafPreimage(this.leaf.clone(), this.nextKey, this.nextIndex);
91
96
  }
@@ -104,10 +109,11 @@ export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
104
109
 
105
110
  static fromBuffer(buffer: Buffer | BufferReader): PublicDataTreeLeafPreimage {
106
111
  const reader = BufferReader.asReader(buffer);
107
- const value = PublicDataTreeLeaf.fromBuffer(reader);
108
- const nextIndex = toBigIntBE(reader.readBytes(32));
109
- const nextSlot = Fr.fromBuffer(reader);
110
- return new PublicDataTreeLeafPreimage(value, nextSlot, nextIndex);
112
+ return new PublicDataTreeLeafPreimage(
113
+ PublicDataTreeLeaf.fromBuffer(reader),
114
+ Fr.fromBuffer(reader),
115
+ toBigIntBE(reader.readBytes(32)),
116
+ );
111
117
  }
112
118
 
113
119
  static fromLeaf(leaf: PublicDataTreeLeaf, nextKey: bigint, nextIndex: bigint): PublicDataTreeLeafPreimage {
@@ -1,6 +1,6 @@
1
1
  import type { AnyTx, TxValidationResult, TxValidator } from './tx_validator.js';
2
2
 
3
- export class EmptyTxValidator<T extends AnyTx = AnyTx> implements TxValidator<T> {
3
+ export class EmptyTxValidator<T = AnyTx> implements TxValidator<T> {
4
4
  public validateTx(_tx: T): Promise<TxValidationResult> {
5
5
  return Promise.resolve({ result: 'valid' });
6
6
  }
@@ -20,7 +20,7 @@ export type TxValidationResult =
20
20
  | { result: 'invalid'; reason: string[] }
21
21
  | { result: 'skipped'; reason: string[] };
22
22
 
23
- export interface TxValidator<T extends AnyTx = AnyTx> {
23
+ export interface TxValidator<T = AnyTx> {
24
24
  validateTx(tx: T): Promise<TxValidationResult>;
25
25
  }
26
26
 
@@ -12,7 +12,14 @@ import type {
12
12
  } from './types.js';
13
13
 
14
14
  export const ValidatorStatusInSlotSchema = zodFor<ValidatorStatusInSlot>()(
15
- z.enum(['block-mined', 'block-proposed', 'block-missed', 'attestation-sent', 'attestation-missed']),
15
+ z.enum([
16
+ 'checkpoint-mined',
17
+ 'checkpoint-proposed',
18
+ 'checkpoint-missed',
19
+ 'blocks-missed',
20
+ 'attestation-sent',
21
+ 'attestation-missed',
22
+ ]),
16
23
  );
17
24
 
18
25
  export const ValidatorStatusHistorySchema = zodFor<ValidatorStatusHistory>()(
@@ -1,12 +1,13 @@
1
1
  import type { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
 
4
- export type ValidatorStatusType = 'block' | 'attestation';
4
+ export type ValidatorStatusType = 'proposer' | 'attestation';
5
5
 
6
6
  export type ValidatorStatusInSlot =
7
- | 'block-mined'
8
- | 'block-proposed'
9
- | 'block-missed'
7
+ | 'checkpoint-mined'
8
+ | 'checkpoint-proposed'
9
+ | 'checkpoint-missed'
10
+ | 'blocks-missed'
10
11
  | 'attestation-sent'
11
12
  | 'attestation-missed';
12
13