@lodestar/types 1.45.0-dev.51a1c44b27 → 1.45.0-dev.6568180f96

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.
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  FINALIZED_ROOT_DEPTH_ELECTRA,
3
+ FINALIZED_ROOT_DEPTH_GLOAS,
3
4
  ForkPostBellatrix,
4
5
  ForkPostDeneb,
5
6
  ForkPostElectra,
6
7
  ForkPostGloas,
7
8
  } from "@lodestar/params";
9
+ import {SignedExecutionPayloadEnvelope, SignedExecutionPayloadEnvelopeContents} from "../gloas/types.js";
8
10
  import {
9
11
  Attestation,
10
12
  BeaconBlock,
@@ -90,7 +92,8 @@ export function isElectraLightClientUpdate(update: LightClientUpdate): update is
90
92
  const updatePostElectra = update as LightClientUpdate<ForkPostElectra>;
91
93
  return (
92
94
  updatePostElectra.finalityBranch !== undefined &&
93
- updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_ELECTRA
95
+ (updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_ELECTRA ||
96
+ updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_GLOAS)
94
97
  );
95
98
  }
96
99
 
@@ -100,7 +103,8 @@ export function isELectraLightClientFinalityUpdate(
100
103
  const updatePostElectra = update as LightClientUpdate<ForkPostElectra>;
101
104
  return (
102
105
  updatePostElectra.finalityBranch !== undefined &&
103
- updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_ELECTRA
106
+ (updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_ELECTRA ||
107
+ updatePostElectra.finalityBranch.length === FINALIZED_ROOT_DEPTH_GLOAS)
104
108
  );
105
109
  }
106
110
 
@@ -111,3 +115,9 @@ export function isGloasBeaconBlock(block: BeaconBlock): block is BeaconBlock<For
111
115
  export function isGloasDataColumnSidecar(sidecar: DataColumnSidecar): sidecar is DataColumnSidecar<ForkPostGloas> {
112
116
  return (sidecar as DataColumnSidecar<ForkPostGloas>).beaconBlockRoot !== undefined;
113
117
  }
118
+
119
+ export function isSignedExecutionPayloadEnvelopeContents(
120
+ signedEnvelope: SignedExecutionPayloadEnvelopeContents | SignedExecutionPayloadEnvelope
121
+ ): signedEnvelope is SignedExecutionPayloadEnvelopeContents {
122
+ return (signedEnvelope as SignedExecutionPayloadEnvelopeContents).signedExecutionPayloadEnvelope !== undefined;
123
+ }
@@ -1,5 +1,5 @@
1
1
  import {FAR_FUTURE_EPOCH} from "@lodestar/params";
2
- import {Epoch, phase0} from "../types.js";
2
+ import {Epoch, gloas, phase0} from "../types.js";
3
3
 
4
4
  /**
5
5
  * [Validator status specification](https://hackmd.io/ofFJ5gOmQpu1jjHilHbdQQ)
@@ -53,6 +53,25 @@ export function getValidatorStatus(validator: phase0.Validator, currentEpoch: Ep
53
53
  throw new Error("ValidatorStatus unknown");
54
54
  }
55
55
 
56
+ /**
57
+ * Statuses as defined in https://github.com/ethereum/beacon-APIs/pull/614
58
+ */
59
+ export type BuilderStatus = "pending" | "active" | "exited";
60
+
61
+ /**
62
+ * Get the status of the builder, `finalizedEpoch` refers to `state.finalized_checkpoint.epoch`
63
+ */
64
+ export function getBuilderStatus(builder: gloas.Builder, finalizedEpoch: Epoch): BuilderStatus {
65
+ if (builder.withdrawableEpoch !== FAR_FUTURE_EPOCH) {
66
+ return "exited";
67
+ }
68
+ // Same as is_active_builder check with withdrawable epoch already confirmed to be FAR_FUTURE_EPOCH
69
+ if (builder.depositEpoch < finalizedEpoch) {
70
+ return "active";
71
+ }
72
+ return "pending";
73
+ }
74
+
56
75
  export function mapToGeneralStatus(subStatus: ValidatorStatus): GeneralValidatorStatus {
57
76
  switch (subStatus) {
58
77
  case "active_ongoing":