@lodestar/fork-choice 1.44.0-dev.847e824a6a → 1.44.0-dev.848b01419b

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 (69) hide show
  1. package/lib/forkChoice/fastConfirmation/data.d.ts +4 -0
  2. package/lib/forkChoice/fastConfirmation/data.d.ts.map +1 -0
  3. package/lib/forkChoice/fastConfirmation/data.js +31 -0
  4. package/lib/forkChoice/fastConfirmation/data.js.map +1 -0
  5. package/lib/forkChoice/fastConfirmation/fastConfirmationRule.d.ts +17 -0
  6. package/lib/forkChoice/fastConfirmation/fastConfirmationRule.d.ts.map +1 -0
  7. package/lib/forkChoice/fastConfirmation/fastConfirmationRule.js +138 -0
  8. package/lib/forkChoice/fastConfirmation/fastConfirmationRule.js.map +1 -0
  9. package/lib/forkChoice/fastConfirmation/index.d.ts +4 -0
  10. package/lib/forkChoice/fastConfirmation/index.d.ts.map +1 -0
  11. package/lib/forkChoice/fastConfirmation/index.js +4 -0
  12. package/lib/forkChoice/fastConfirmation/index.js.map +1 -0
  13. package/lib/forkChoice/fastConfirmation/metrics.d.ts +24 -0
  14. package/lib/forkChoice/fastConfirmation/metrics.d.ts.map +1 -0
  15. package/lib/forkChoice/fastConfirmation/metrics.js +55 -0
  16. package/lib/forkChoice/fastConfirmation/metrics.js.map +1 -0
  17. package/lib/forkChoice/fastConfirmation/rules.d.ts +9 -0
  18. package/lib/forkChoice/fastConfirmation/rules.d.ts.map +1 -0
  19. package/lib/forkChoice/fastConfirmation/rules.js +110 -0
  20. package/lib/forkChoice/fastConfirmation/rules.js.map +1 -0
  21. package/lib/forkChoice/fastConfirmation/types.d.ts +109 -0
  22. package/lib/forkChoice/fastConfirmation/types.d.ts.map +1 -0
  23. package/lib/forkChoice/fastConfirmation/types.js +12 -0
  24. package/lib/forkChoice/fastConfirmation/types.js.map +1 -0
  25. package/lib/forkChoice/fastConfirmation/utils.d.ts +47 -0
  26. package/lib/forkChoice/fastConfirmation/utils.d.ts.map +1 -0
  27. package/lib/forkChoice/fastConfirmation/utils.js +687 -0
  28. package/lib/forkChoice/fastConfirmation/utils.js.map +1 -0
  29. package/lib/forkChoice/forkChoice.d.ts +20 -2
  30. package/lib/forkChoice/forkChoice.d.ts.map +1 -1
  31. package/lib/forkChoice/forkChoice.js +115 -9
  32. package/lib/forkChoice/forkChoice.js.map +1 -1
  33. package/lib/forkChoice/interface.d.ts +16 -2
  34. package/lib/forkChoice/interface.d.ts.map +1 -1
  35. package/lib/forkChoice/safeBlocks.d.ts +2 -6
  36. package/lib/forkChoice/safeBlocks.d.ts.map +1 -1
  37. package/lib/forkChoice/safeBlocks.js +15 -7
  38. package/lib/forkChoice/safeBlocks.js.map +1 -1
  39. package/lib/forkChoice/store.d.ts +33 -2
  40. package/lib/forkChoice/store.d.ts.map +1 -1
  41. package/lib/forkChoice/store.js +37 -1
  42. package/lib/forkChoice/store.js.map +1 -1
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +1 -0
  46. package/lib/index.js.map +1 -1
  47. package/lib/metrics.d.ts +15 -1
  48. package/lib/metrics.d.ts.map +1 -1
  49. package/lib/metrics.js +2 -0
  50. package/lib/metrics.js.map +1 -1
  51. package/lib/protoArray/protoArray.d.ts +28 -6
  52. package/lib/protoArray/protoArray.d.ts.map +1 -1
  53. package/lib/protoArray/protoArray.js +76 -20
  54. package/lib/protoArray/protoArray.js.map +1 -1
  55. package/package.json +7 -7
  56. package/src/forkChoice/fastConfirmation/data.ts +43 -0
  57. package/src/forkChoice/fastConfirmation/fastConfirmationRule.ts +172 -0
  58. package/src/forkChoice/fastConfirmation/index.ts +3 -0
  59. package/src/forkChoice/fastConfirmation/metrics.ts +57 -0
  60. package/src/forkChoice/fastConfirmation/rules.ts +146 -0
  61. package/src/forkChoice/fastConfirmation/types.ts +120 -0
  62. package/src/forkChoice/fastConfirmation/utils.ts +975 -0
  63. package/src/forkChoice/forkChoice.ts +143 -9
  64. package/src/forkChoice/interface.ts +17 -1
  65. package/src/forkChoice/safeBlocks.ts +15 -7
  66. package/src/forkChoice/store.ts +45 -1
  67. package/src/index.ts +11 -0
  68. package/src/metrics.ts +3 -1
  69. package/src/protoArray/protoArray.ts +88 -19
@@ -0,0 +1,47 @@
1
+ import { IBeaconStateView } from "@lodestar/state-transition";
2
+ import { Epoch, RootHex, Slot, ValidatorIndex } from "@lodestar/types";
3
+ import { Logger } from "@lodestar/utils";
4
+ import { ProtoBlock } from "../../protoArray/interface.ts";
5
+ import { CheckpointWithHex } from "../store.ts";
6
+ import { type BalanceSourceKey, FastConfirmationBalanceSource, FastConfirmationCache, FastConfirmationContext, FastConfirmationSnapshot, IFastConfirmationStore } from "./types.ts";
7
+ export declare function getBlock(ctx: FastConfirmationContext, cache: FastConfirmationCache, root: RootHex): ProtoBlock | null;
8
+ export declare function getUnrealizedJustification(ctx: FastConfirmationContext, cache: FastConfirmationCache, blockRoot: RootHex): CheckpointWithHex | null;
9
+ export declare function getVotingSource(ctx: FastConfirmationContext, cache: FastConfirmationCache, blockRoot: RootHex): CheckpointWithHex | null;
10
+ export declare function getCheckpointForBlock(ctx: FastConfirmationContext, blockRoot: RootHex, epoch: Epoch): CheckpointWithHex | null;
11
+ export declare function getAncestorRoots(ctx: FastConfirmationContext, cache: FastConfirmationCache, blockRoot: RootHex, terminalRoot: RootHex): RootHex[];
12
+ export declare function isAncestor(ctx: FastConfirmationContext, cache: FastConfirmationCache, blockRoot: RootHex, ancestorRoot: RootHex): boolean;
13
+ export declare function getHeadState(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): IBeaconStateView;
14
+ export declare function getPulledUpHeadState(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): IBeaconStateView;
15
+ export declare function getCheckpointState(store: IFastConfirmationStore, cache: FastConfirmationCache, checkpoint: CheckpointWithHex): IBeaconStateView | null;
16
+ export declare function getSlotCommittee(cache: FastConfirmationCache, state: IBeaconStateView, slot: Slot): Set<ValidatorIndex>;
17
+ export declare function getBalanceSource(store: IFastConfirmationStore, cache: FastConfirmationCache, kind: "previous" | "current"): FastConfirmationBalanceSource;
18
+ export declare function getCurrentBalanceSource(store: IFastConfirmationStore, cache: FastConfirmationCache): FastConfirmationBalanceSource;
19
+ export declare function getPreviousBalanceSource(store: IFastConfirmationStore, cache: FastConfirmationCache): FastConfirmationBalanceSource;
20
+ export declare function getTotalActiveBalance(balanceSource: FastConfirmationBalanceSource): number;
21
+ export declare function estimateCommitteeWeightBetweenSlots(balanceSource: FastConfirmationBalanceSource, startSlot: Slot, endSlot: Slot): number;
22
+ export declare function adjustCommitteeWeightEstimateToEnsureSafety(estimate: number): number;
23
+ export declare function isFullValidatorSetCovered(startSlot: Slot, endSlot: Slot): boolean;
24
+ export declare function computeProposerScore(ctx: FastConfirmationContext, balanceSource: FastConfirmationBalanceSource): number;
25
+ export declare function getAttestationScore(ctx: FastConfirmationContext, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, blockRoot: RootHex, sourceKey: BalanceSourceKey): number;
26
+ export declare function getBlockSupportBetweenSlots(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, blockRoot: RootHex, startSlot: Slot, endSlot: Slot): number;
27
+ export declare function getEquivocationScore(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, startSlot: Slot, endSlot: Slot): number;
28
+ export declare function computeAdversarialWeight(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, startSlot: Slot, endSlot: Slot): number;
29
+ export declare function getAdversarialWeight(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, blockRoot: RootHex): number;
30
+ export declare function computeEmptySlotSupportDiscount(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, blockRoot: RootHex): number;
31
+ export declare function computeSafetyThreshold(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, blockRoot: RootHex): {
32
+ threshold: number;
33
+ proposerScore: number;
34
+ maximumSupport: number;
35
+ supportDiscount: number;
36
+ adversarialWeight: number;
37
+ };
38
+ export declare function isOneConfirmed(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, balanceSource: FastConfirmationBalanceSource, blockRoot: RootHex, sourceKey: BalanceSourceKey, logger?: Logger): boolean;
39
+ export declare function getCurrentTarget(ctx: FastConfirmationContext): CheckpointWithHex | null;
40
+ export declare function getCurrentEpochState(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): IBeaconStateView | null;
41
+ export declare function getCurrentTargetScore(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): number;
42
+ export declare function computeHonestFfgSupportForCurrentTarget(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): number;
43
+ export declare function willNoConflictingCheckpointBeJustified(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): boolean;
44
+ export declare function willCurrentTargetBeJustified(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache): boolean;
45
+ export declare function isConfirmedChainSafe(ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, confirmedRoot: RootHex, logger?: Logger): boolean;
46
+ export declare function findLatestConfirmedDescendant(snapshot: FastConfirmationSnapshot, ctx: FastConfirmationContext, store: IFastConfirmationStore, cache: FastConfirmationCache, latestConfirmedRoot: RootHex, logger?: Logger): RootHex;
47
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/forkChoice/fastConfirmation/utils.ts"],"names":[],"mappings":"AACA,OAAO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