@aztec/stdlib 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a

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 (140) hide show
  1. package/dest/block/block_hash.d.ts +14 -17
  2. package/dest/block/block_hash.d.ts.map +1 -1
  3. package/dest/block/block_hash.js +21 -34
  4. package/dest/block/block_parameter.d.ts +2 -2
  5. package/dest/block/block_parameter.d.ts.map +1 -1
  6. package/dest/block/in_block.d.ts +5 -5
  7. package/dest/block/in_block.js +2 -2
  8. package/dest/block/l2_block.d.ts +3 -2
  9. package/dest/block/l2_block.d.ts.map +1 -1
  10. package/dest/block/l2_block.js +2 -3
  11. package/dest/block/l2_block_source.d.ts +5 -4
  12. package/dest/block/l2_block_source.d.ts.map +1 -1
  13. package/dest/contract/contract_address.js +1 -1
  14. package/dest/contract/contract_class_id.d.ts +1 -1
  15. package/dest/contract/contract_class_id.js +1 -1
  16. package/dest/contract/private_function.js +1 -1
  17. package/dest/contract/private_function_membership_proof.d.ts +1 -1
  18. package/dest/contract/private_function_membership_proof.js +1 -1
  19. package/dest/database-version/database_version.d.ts +58 -0
  20. package/dest/database-version/database_version.d.ts.map +1 -0
  21. package/dest/database-version/database_version.js +69 -0
  22. package/dest/database-version/version_manager.d.ts +2 -50
  23. package/dest/database-version/version_manager.d.ts.map +1 -1
  24. package/dest/database-version/version_manager.js +1 -66
  25. package/dest/epoch-helpers/index.d.ts +3 -1
  26. package/dest/epoch-helpers/index.d.ts.map +1 -1
  27. package/dest/epoch-helpers/index.js +4 -0
  28. package/dest/hash/hash.js +2 -2
  29. package/dest/hash/map_slot.d.ts +1 -1
  30. package/dest/hash/map_slot.d.ts.map +1 -1
  31. package/dest/hash/map_slot.js +4 -3
  32. package/dest/interfaces/archiver.d.ts +1 -1
  33. package/dest/interfaces/archiver.d.ts.map +1 -1
  34. package/dest/interfaces/archiver.js +4 -3
  35. package/dest/interfaces/aztec-node-admin.d.ts +11 -2
  36. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  37. package/dest/interfaces/aztec-node-admin.js +3 -1
  38. package/dest/interfaces/aztec-node.d.ts +30 -51
  39. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  40. package/dest/interfaces/aztec-node.js +3 -7
  41. package/dest/interfaces/block-builder.d.ts +10 -4
  42. package/dest/interfaces/block-builder.d.ts.map +1 -1
  43. package/dest/interfaces/block-builder.js +7 -0
  44. package/dest/interfaces/get_logs_response.d.ts +14 -7
  45. package/dest/interfaces/get_logs_response.d.ts.map +1 -1
  46. package/dest/interfaces/p2p.d.ts +2 -2
  47. package/dest/interfaces/p2p.d.ts.map +1 -1
  48. package/dest/interfaces/prover-broker.d.ts +16 -1
  49. package/dest/interfaces/prover-broker.d.ts.map +1 -1
  50. package/dest/interfaces/prover-broker.js +4 -1
  51. package/dest/interfaces/prover-client.d.ts +6 -1
  52. package/dest/interfaces/prover-client.d.ts.map +1 -1
  53. package/dest/interfaces/prover-client.js +5 -0
  54. package/dest/interfaces/proving-job.d.ts +34 -34
  55. package/dest/interfaces/slasher.d.ts +5 -1
  56. package/dest/interfaces/slasher.d.ts.map +1 -1
  57. package/dest/interfaces/slasher.js +1 -0
  58. package/dest/interfaces/validator.d.ts +37 -2
  59. package/dest/interfaces/validator.d.ts.map +1 -1
  60. package/dest/interfaces/validator.js +1 -0
  61. package/dest/keys/derivation.d.ts +3 -3
  62. package/dest/keys/derivation.js +8 -8
  63. package/dest/keys/key_types.d.ts +1 -1
  64. package/dest/keys/utils.d.ts +1 -1
  65. package/dest/keys/utils.d.ts.map +1 -1
  66. package/dest/keys/utils.js +7 -3
  67. package/dest/l1-contracts/slash_factory.d.ts +1 -1
  68. package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
  69. package/dest/l1-contracts/slash_factory.js +1 -0
  70. package/dest/logs/extended_public_log.d.ts +12 -6
  71. package/dest/logs/extended_public_log.d.ts.map +1 -1
  72. package/dest/logs/log_id.d.ts +13 -10
  73. package/dest/logs/log_id.d.ts.map +1 -1
  74. package/dest/logs/log_id.js +17 -14
  75. package/dest/logs/siloed_tag.d.ts +1 -1
  76. package/dest/logs/siloed_tag.d.ts.map +1 -1
  77. package/dest/logs/siloed_tag.js +4 -3
  78. package/dest/p2p/checkpoint_proposal.d.ts +8 -1
  79. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  80. package/dest/p2p/checkpoint_proposal.js +9 -0
  81. package/dest/slashing/empire.d.ts +1 -1
  82. package/dest/slashing/empire.d.ts.map +1 -1
  83. package/dest/slashing/empire.js +1 -0
  84. package/dest/slashing/helpers.d.ts +2 -2
  85. package/dest/slashing/helpers.d.ts.map +1 -1
  86. package/dest/slashing/helpers.js +3 -0
  87. package/dest/slashing/tally.d.ts +2 -1
  88. package/dest/slashing/tally.d.ts.map +1 -1
  89. package/dest/slashing/tally.js +6 -2
  90. package/dest/slashing/types.d.ts +5 -3
  91. package/dest/slashing/types.d.ts.map +1 -1
  92. package/dest/slashing/types.js +7 -1
  93. package/dest/stats/stats.d.ts +1 -3
  94. package/dest/stats/stats.d.ts.map +1 -1
  95. package/dest/tx/block_header.js +2 -2
  96. package/dest/tx/in_tx.d.ts +2 -2
  97. package/dest/tx/indexed_tx_effect.d.ts +3 -3
  98. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  99. package/dest/tx/indexed_tx_effect.js +2 -1
  100. package/package.json +22 -11
  101. package/src/block/block_hash.ts +25 -50
  102. package/src/block/in_block.ts +2 -2
  103. package/src/block/l2_block.ts +3 -3
  104. package/src/block/l2_block_source.ts +4 -3
  105. package/src/contract/contract_address.ts +1 -1
  106. package/src/contract/contract_class_id.ts +1 -1
  107. package/src/contract/private_function.ts +1 -1
  108. package/src/contract/private_function_membership_proof.ts +1 -1
  109. package/src/database-version/database_version.ts +87 -0
  110. package/src/database-version/version_manager.ts +1 -77
  111. package/src/epoch-helpers/index.ts +9 -0
  112. package/src/hash/hash.ts +2 -2
  113. package/src/hash/map_slot.ts +3 -2
  114. package/src/interfaces/archiver.ts +4 -3
  115. package/src/interfaces/aztec-node-admin.ts +3 -2
  116. package/src/interfaces/aztec-node.ts +37 -88
  117. package/src/interfaces/block-builder.ts +12 -2
  118. package/src/interfaces/p2p.ts +1 -1
  119. package/src/interfaces/prover-broker.ts +22 -0
  120. package/src/interfaces/prover-client.ts +7 -0
  121. package/src/interfaces/slasher.ts +2 -0
  122. package/src/interfaces/validator.ts +2 -1
  123. package/src/keys/derivation.ts +8 -8
  124. package/src/keys/key_types.ts +1 -1
  125. package/src/keys/utils.ts +7 -3
  126. package/src/l1-contracts/slash_factory.ts +1 -0
  127. package/src/logs/log_id.ts +17 -13
  128. package/src/logs/siloed_tag.ts +3 -2
  129. package/src/p2p/checkpoint_proposal.ts +10 -0
  130. package/src/slashing/empire.ts +2 -1
  131. package/src/slashing/helpers.ts +4 -0
  132. package/src/slashing/tally.ts +8 -2
  133. package/src/slashing/types.ts +7 -0
  134. package/src/stats/stats.ts +0 -2
  135. package/src/tx/block_header.ts +3 -3
  136. package/src/tx/indexed_tx_effect.ts +2 -1
  137. package/dest/database-version/index.d.ts +0 -2
  138. package/dest/database-version/index.d.ts.map +0 -1
  139. package/dest/database-version/index.js +0 -1
  140. package/src/database-version/index.ts +0 -1
@@ -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,8 @@ 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,
23
25
  }
24
26
 
25
27
  export function getOffenseTypeName(offense: OffenseType) {
@@ -40,6 +42,8 @@ export function getOffenseTypeName(offense: OffenseType) {
40
42
  return 'proposed_incorrect_attestations';
41
43
  case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
42
44
  return 'attested_descendant_of_invalid';
45
+ case OffenseType.DUPLICATE_PROPOSAL:
46
+ return 'duplicate_proposal';
43
47
  default:
44
48
  throw new Error(`Unknown offense type: ${offense}`);
45
49
  }
@@ -56,6 +60,7 @@ export const OffenseToBigInt: Record<OffenseType, bigint> = {
56
60
  [OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS]: 5n,
57
61
  [OffenseType.PROPOSED_INCORRECT_ATTESTATIONS]: 6n,
58
62
  [OffenseType.ATTESTED_DESCENDANT_OF_INVALID]: 7n,
63
+ [OffenseType.DUPLICATE_PROPOSAL]: 8n,
59
64
  };
60
65
 
61
66
  export function bigIntToOffense(offense: bigint): OffenseType {
@@ -76,6 +81,8 @@ export function bigIntToOffense(offense: bigint): OffenseType {
76
81
  return OffenseType.PROPOSED_INCORRECT_ATTESTATIONS;
77
82
  case 7n:
78
83
  return OffenseType.ATTESTED_DESCENDANT_OF_INVALID;
84
+ case 8n:
85
+ return OffenseType.DUPLICATE_PROPOSAL;
79
86
  default:
80
87
  throw new Error(`Unknown offense: ${offense}`);
81
88
  }
@@ -202,8 +202,6 @@ export type L2BlockBuiltStats = {
202
202
  duration: number;
203
203
  /** Time for processing public txs in ms. */
204
204
  publicProcessDuration: number;
205
- /** Time for running rollup circuits in ms. */
206
- rollupCircuitsDuration: number;
207
205
  } & L2BlockStats;
208
206
 
209
207
  /** Stats for an L2 block processed by the world state synchronizer. */
@@ -164,8 +164,8 @@ export class BlockHeader {
164
164
 
165
165
  hash(): Promise<BlockHash> {
166
166
  if (!this._cachedHash) {
167
- this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH).then(fr =>
168
- BlockHash.fromField(fr),
167
+ this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HEADER_HASH).then(
168
+ fr => new BlockHash(fr),
169
169
  );
170
170
  }
171
171
  return this._cachedHash;
@@ -173,7 +173,7 @@ export class BlockHeader {
173
173
 
174
174
  /** Manually set the hash for this block header if already computed */
175
175
  setHash(hashed: Fr) {
176
- this._cachedHash = Promise.resolve(BlockHash.fromField(hashed));
176
+ this._cachedHash = Promise.resolve(new BlockHash(hashed));
177
177
  }
178
178
 
179
179
  static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
@@ -1,4 +1,5 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { schemas } from '@aztec/foundation/schemas';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
 
@@ -26,7 +27,7 @@ export function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer {
26
27
  export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
27
28
  const reader = BufferReader.asReader(buffer);
28
29
 
29
- const l2BlockHash = reader.readObject(BlockHash);
30
+ const l2BlockHash = new BlockHash(reader.readObject(Fr));
30
31
  const l2BlockNumber = BlockNumber(reader.readNumber());
31
32
  const txIndexInBlock = reader.readNumber();
32
33
  const data = reader.readObject(TxEffect);
@@ -1,2 +0,0 @@
1
- export * from './version_manager.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kYXRhYmFzZS12ZXJzaW9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsc0JBQXNCLENBQUMifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database-version/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1 +0,0 @@
1
- export * from './version_manager.js';
@@ -1 +0,0 @@
1
- export * from './version_manager.js';