@lodestar/api 1.35.0-dev.f80d2d52da → 1.35.0-dev.fcf8d024ea

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 (180) hide show
  1. package/lib/beacon/client/beacon.d.ts.map +1 -0
  2. package/lib/beacon/client/config.d.ts.map +1 -0
  3. package/lib/beacon/client/debug.d.ts.map +1 -0
  4. package/lib/beacon/client/events.d.ts.map +1 -0
  5. package/lib/beacon/client/index.d.ts.map +1 -0
  6. package/lib/beacon/client/index.js.map +1 -1
  7. package/lib/beacon/client/lightclient.d.ts.map +1 -0
  8. package/lib/beacon/client/lodestar.d.ts.map +1 -0
  9. package/lib/beacon/client/node.d.ts.map +1 -0
  10. package/lib/beacon/client/proof.d.ts.map +1 -0
  11. package/lib/beacon/client/validator.d.ts.map +1 -0
  12. package/lib/beacon/index.d.ts +1 -1
  13. package/lib/beacon/index.d.ts.map +1 -0
  14. package/lib/beacon/index.js.map +1 -1
  15. package/lib/beacon/routes/beacon/block.d.ts.map +1 -0
  16. package/lib/beacon/routes/beacon/index.d.ts +3 -3
  17. package/lib/beacon/routes/beacon/index.d.ts.map +1 -0
  18. package/lib/beacon/routes/beacon/index.js.map +1 -1
  19. package/lib/beacon/routes/beacon/pool.d.ts +1 -1
  20. package/lib/beacon/routes/beacon/pool.d.ts.map +1 -0
  21. package/lib/beacon/routes/beacon/rewards.d.ts.map +1 -0
  22. package/lib/beacon/routes/beacon/rewards.js.map +1 -1
  23. package/lib/beacon/routes/beacon/state.d.ts +2 -2
  24. package/lib/beacon/routes/beacon/state.d.ts.map +1 -0
  25. package/lib/beacon/routes/config.d.ts +1 -1
  26. package/lib/beacon/routes/config.d.ts.map +1 -0
  27. package/lib/beacon/routes/debug.d.ts.map +1 -0
  28. package/lib/beacon/routes/events.d.ts.map +1 -0
  29. package/lib/beacon/routes/events.js.map +1 -1
  30. package/lib/beacon/routes/index.d.ts.map +1 -0
  31. package/lib/beacon/routes/index.js.map +1 -1
  32. package/lib/beacon/routes/lightclient.d.ts.map +1 -0
  33. package/lib/beacon/routes/lodestar.d.ts.map +1 -0
  34. package/lib/beacon/routes/node.d.ts.map +1 -0
  35. package/lib/beacon/routes/proof.d.ts.map +1 -0
  36. package/lib/beacon/routes/validator.d.ts +1 -1
  37. package/lib/beacon/routes/validator.d.ts.map +1 -0
  38. package/lib/beacon/server/beacon.d.ts.map +1 -0
  39. package/lib/beacon/server/config.d.ts.map +1 -0
  40. package/lib/beacon/server/debug.d.ts.map +1 -0
  41. package/lib/beacon/server/events.d.ts.map +1 -0
  42. package/lib/beacon/server/index.d.ts +1 -1
  43. package/lib/beacon/server/index.d.ts.map +1 -0
  44. package/lib/beacon/server/index.js.map +1 -1
  45. package/lib/beacon/server/lightclient.d.ts.map +1 -0
  46. package/lib/beacon/server/lodestar.d.ts.map +1 -0
  47. package/lib/beacon/server/node.d.ts.map +1 -0
  48. package/lib/beacon/server/proof.d.ts.map +1 -0
  49. package/lib/beacon/server/validator.d.ts.map +1 -0
  50. package/lib/builder/client.d.ts.map +1 -0
  51. package/lib/builder/index.d.ts.map +1 -0
  52. package/lib/builder/index.js.map +1 -1
  53. package/lib/builder/routes.d.ts.map +1 -0
  54. package/lib/builder/routes.js.map +1 -1
  55. package/lib/builder/server/index.d.ts +1 -1
  56. package/lib/builder/server/index.d.ts.map +1 -0
  57. package/lib/index.d.ts +6 -6
  58. package/lib/index.d.ts.map +1 -0
  59. package/lib/index.js +3 -3
  60. package/lib/index.js.map +1 -1
  61. package/lib/keymanager/client.d.ts.map +1 -0
  62. package/lib/keymanager/index.d.ts +2 -2
  63. package/lib/keymanager/index.d.ts.map +1 -0
  64. package/lib/keymanager/index.js +1 -2
  65. package/lib/keymanager/index.js.map +1 -1
  66. package/lib/keymanager/routes.d.ts.map +1 -0
  67. package/lib/keymanager/server/index.d.ts +1 -1
  68. package/lib/keymanager/server/index.d.ts.map +1 -0
  69. package/lib/server/index.d.ts.map +1 -0
  70. package/lib/utils/client/error.d.ts.map +1 -0
  71. package/lib/utils/client/error.js +2 -0
  72. package/lib/utils/client/error.js.map +1 -1
  73. package/lib/utils/client/eventSource.d.ts.map +1 -0
  74. package/lib/utils/client/format.d.ts.map +1 -0
  75. package/lib/utils/client/httpClient.d.ts +1 -2
  76. package/lib/utils/client/httpClient.d.ts.map +1 -0
  77. package/lib/utils/client/httpClient.js +13 -9
  78. package/lib/utils/client/httpClient.js.map +1 -1
  79. package/lib/utils/client/index.d.ts +1 -1
  80. package/lib/utils/client/index.d.ts.map +1 -0
  81. package/lib/utils/client/index.js +1 -1
  82. package/lib/utils/client/index.js.map +1 -1
  83. package/lib/utils/client/method.d.ts.map +1 -0
  84. package/lib/utils/client/metrics.d.ts.map +1 -0
  85. package/lib/utils/client/request.d.ts.map +1 -0
  86. package/lib/utils/client/response.d.ts.map +1 -0
  87. package/lib/utils/client/response.js +6 -0
  88. package/lib/utils/client/response.js.map +1 -1
  89. package/lib/utils/codecs.d.ts.map +1 -0
  90. package/lib/utils/fork.d.ts.map +1 -0
  91. package/lib/utils/headers.d.ts.map +1 -0
  92. package/lib/utils/httpStatusCode.d.ts.map +1 -0
  93. package/lib/utils/index.d.ts.map +1 -0
  94. package/lib/utils/metadata.d.ts.map +1 -0
  95. package/lib/utils/schema.d.ts.map +1 -0
  96. package/lib/utils/serdes.d.ts.map +1 -0
  97. package/lib/utils/server/error.d.ts.map +1 -0
  98. package/lib/utils/server/error.js +1 -0
  99. package/lib/utils/server/error.js.map +1 -1
  100. package/lib/utils/server/handler.d.ts.map +1 -0
  101. package/lib/utils/server/index.d.ts.map +1 -0
  102. package/lib/utils/server/method.d.ts.map +1 -0
  103. package/lib/utils/server/parser.d.ts.map +1 -0
  104. package/lib/utils/server/route.d.ts.map +1 -0
  105. package/lib/utils/server/route.js.map +1 -1
  106. package/lib/utils/types.d.ts.map +1 -0
  107. package/lib/utils/urlFormat.d.ts.map +1 -0
  108. package/lib/utils/wireFormat.d.ts.map +1 -0
  109. package/package.json +17 -11
  110. package/src/beacon/client/beacon.ts +12 -0
  111. package/src/beacon/client/config.ts +12 -0
  112. package/src/beacon/client/debug.ts +12 -0
  113. package/src/beacon/client/events.ts +69 -0
  114. package/src/beacon/client/index.ts +46 -0
  115. package/src/beacon/client/lightclient.ts +12 -0
  116. package/src/beacon/client/lodestar.ts +12 -0
  117. package/src/beacon/client/node.ts +12 -0
  118. package/src/beacon/client/proof.ts +12 -0
  119. package/src/beacon/client/validator.ts +12 -0
  120. package/src/beacon/index.ts +24 -0
  121. package/src/beacon/routes/beacon/block.ts +602 -0
  122. package/src/beacon/routes/beacon/index.ts +66 -0
  123. package/src/beacon/routes/beacon/pool.ts +503 -0
  124. package/src/beacon/routes/beacon/rewards.ts +216 -0
  125. package/src/beacon/routes/beacon/state.ts +588 -0
  126. package/src/beacon/routes/config.ts +114 -0
  127. package/src/beacon/routes/debug.ts +231 -0
  128. package/src/beacon/routes/events.ts +337 -0
  129. package/src/beacon/routes/index.ts +33 -0
  130. package/src/beacon/routes/lightclient.ts +241 -0
  131. package/src/beacon/routes/lodestar.ts +456 -0
  132. package/src/beacon/routes/node.ts +286 -0
  133. package/src/beacon/routes/proof.ts +79 -0
  134. package/src/beacon/routes/validator.ts +1014 -0
  135. package/src/beacon/server/beacon.ts +7 -0
  136. package/src/beacon/server/config.ts +7 -0
  137. package/src/beacon/server/debug.ts +7 -0
  138. package/src/beacon/server/events.ts +73 -0
  139. package/src/beacon/server/index.ts +55 -0
  140. package/src/beacon/server/lightclient.ts +7 -0
  141. package/src/beacon/server/lodestar.ts +7 -0
  142. package/src/beacon/server/node.ts +7 -0
  143. package/src/beacon/server/proof.ts +7 -0
  144. package/src/beacon/server/validator.ts +7 -0
  145. package/src/builder/client.ts +9 -0
  146. package/src/builder/index.ts +26 -0
  147. package/src/builder/routes.ts +227 -0
  148. package/src/builder/server/index.ts +19 -0
  149. package/src/index.ts +19 -0
  150. package/src/keymanager/client.ts +9 -0
  151. package/src/keymanager/index.ts +39 -0
  152. package/src/keymanager/routes.ts +699 -0
  153. package/src/keymanager/server/index.ts +19 -0
  154. package/src/server/index.ts +2 -0
  155. package/src/utils/client/error.ts +10 -0
  156. package/src/utils/client/eventSource.ts +7 -0
  157. package/src/utils/client/format.ts +22 -0
  158. package/src/utils/client/httpClient.ts +444 -0
  159. package/src/utils/client/index.ts +6 -0
  160. package/src/utils/client/method.ts +50 -0
  161. package/src/utils/client/metrics.ts +9 -0
  162. package/src/utils/client/request.ts +113 -0
  163. package/src/utils/client/response.ts +205 -0
  164. package/src/utils/codecs.ts +143 -0
  165. package/src/utils/fork.ts +44 -0
  166. package/src/utils/headers.ts +173 -0
  167. package/src/utils/httpStatusCode.ts +392 -0
  168. package/src/utils/index.ts +3 -0
  169. package/src/utils/metadata.ts +170 -0
  170. package/src/utils/schema.ts +141 -0
  171. package/src/utils/serdes.ts +120 -0
  172. package/src/utils/server/error.ts +9 -0
  173. package/src/utils/server/handler.ts +149 -0
  174. package/src/utils/server/index.ts +5 -0
  175. package/src/utils/server/method.ts +38 -0
  176. package/src/utils/server/parser.ts +15 -0
  177. package/src/utils/server/route.ts +45 -0
  178. package/src/utils/types.ts +161 -0
  179. package/src/utils/urlFormat.ts +112 -0
  180. package/src/utils/wireFormat.ts +24 -0
@@ -0,0 +1,216 @@
1
+ import {ContainerType, ValueOf} from "@chainsafe/ssz";
2
+ import {ChainForkConfig} from "@lodestar/config";
3
+ import {Epoch, ssz} from "@lodestar/types";
4
+ import {ArrayOf, JsonOnlyReq} from "../../../utils/codecs.js";
5
+ import {Endpoint, RouteDefinitions, Schema} from "../../../utils/index.js";
6
+ import {ExecutionOptimisticAndFinalizedCodec, ExecutionOptimisticAndFinalizedMeta} from "../../../utils/metadata.js";
7
+ import {fromValidatorIdsStr, toValidatorIdsStr} from "../../../utils/serdes.js";
8
+ import {BlockArgs} from "./block.js";
9
+ import {ValidatorId} from "./state.js";
10
+
11
+ const BlockRewardsType = new ContainerType(
12
+ {
13
+ /** Proposer of the block, the proposer index who receives these rewards */
14
+ proposerIndex: ssz.ValidatorIndex,
15
+ /** Total block reward, equal to attestations + sync_aggregate + proposer_slashings + attester_slashings */
16
+ total: ssz.UintNum64,
17
+ /** Block reward component due to included attestations */
18
+ attestations: ssz.UintNum64,
19
+ /** Block reward component due to included sync_aggregate */
20
+ syncAggregate: ssz.UintNum64,
21
+ /** Block reward component due to included proposer_slashings */
22
+ proposerSlashings: ssz.UintNum64,
23
+ /** Block reward component due to included attester_slashings */
24
+ attesterSlashings: ssz.UintNum64,
25
+ },
26
+ {jsonCase: "eth2"}
27
+ );
28
+
29
+ const AttestationsRewardType = new ContainerType(
30
+ {
31
+ /** Reward for head vote. Could be negative to indicate penalty */
32
+ head: ssz.UintNum64,
33
+ /** Reward for target vote. Could be negative to indicate penalty */
34
+ target: ssz.UintNum64,
35
+ /** Reward for source vote. Could be negative to indicate penalty */
36
+ source: ssz.UintNum64,
37
+ /** Inclusion delay reward (phase0 only) */
38
+ inclusionDelay: ssz.UintNum64,
39
+ /** Inactivity penalty. Should be a negative number to indicate penalty */
40
+ inactivity: ssz.UintNum64,
41
+ },
42
+ {jsonCase: "eth2"}
43
+ );
44
+
45
+ const IdealAttestationsRewardsType = new ContainerType(
46
+ {
47
+ ...AttestationsRewardType.fields,
48
+ effectiveBalance: ssz.UintNum64,
49
+ },
50
+ {jsonCase: "eth2"}
51
+ );
52
+
53
+ const TotalAttestationsRewardsType = new ContainerType(
54
+ {
55
+ ...AttestationsRewardType.fields,
56
+ validatorIndex: ssz.ValidatorIndex,
57
+ },
58
+ {jsonCase: "eth2"}
59
+ );
60
+
61
+ const AttestationsRewardsType = new ContainerType(
62
+ {
63
+ idealRewards: ArrayOf(IdealAttestationsRewardsType),
64
+ totalRewards: ArrayOf(TotalAttestationsRewardsType),
65
+ },
66
+ {jsonCase: "eth2"}
67
+ );
68
+
69
+ const SyncCommitteeRewardsType = ArrayOf(
70
+ new ContainerType(
71
+ {
72
+ validatorIndex: ssz.ValidatorIndex,
73
+ reward: ssz.UintNum64,
74
+ },
75
+ {jsonCase: "eth2"}
76
+ )
77
+ );
78
+
79
+ /**
80
+ * Rewards info for a single block. Every reward value is in Gwei.
81
+ */
82
+ export type BlockRewards = ValueOf<typeof BlockRewardsType>;
83
+
84
+ /**
85
+ * Rewards for a single set of (ideal or actual depending on usage) attestations. Reward value is in Gwei
86
+ */
87
+ export type AttestationsReward = ValueOf<typeof AttestationsRewardType>;
88
+
89
+ /**
90
+ * Rewards info for ideal attestations ie. Maximum rewards could be earned by making timely head, target and source vote.
91
+ * `effectiveBalance` is in Gwei
92
+ */
93
+ export type IdealAttestationsReward = ValueOf<typeof IdealAttestationsRewardsType>;
94
+
95
+ /**
96
+ * Rewards info for actual attestations
97
+ */
98
+ export type TotalAttestationsReward = ValueOf<typeof TotalAttestationsRewardsType>;
99
+
100
+ export type AttestationsRewards = ValueOf<typeof AttestationsRewardsType>;
101
+
102
+ /**
103
+ * Rewards info for sync committee participation. Every reward value is in Gwei.
104
+ * Note: In the case that block proposer is present in `SyncCommitteeRewards`, the reward value only reflects rewards for
105
+ * participating in sync committee. Please refer to `BlockRewards.syncAggregate` for rewards of proposer including sync committee
106
+ * outputs into their block
107
+ */
108
+ export type SyncCommitteeRewards = ValueOf<typeof SyncCommitteeRewardsType>;
109
+
110
+ export type Endpoints = {
111
+ /**
112
+ * Get block rewards
113
+ * Returns the info of rewards received by the block proposer
114
+ */
115
+ getBlockRewards: Endpoint<
116
+ "GET",
117
+ BlockArgs,
118
+ {params: {block_id: string}},
119
+ BlockRewards,
120
+ ExecutionOptimisticAndFinalizedMeta
121
+ >;
122
+
123
+ /**
124
+ * Get attestations rewards
125
+ * Negative values indicate penalties. `inactivity` can only be either 0 or negative number since it is penalty only
126
+ */
127
+ getAttestationsRewards: Endpoint<
128
+ "POST",
129
+ {
130
+ /** The epoch to get rewards info from */
131
+ epoch: Epoch;
132
+ /** List of validator indices or pubkeys to filter in */
133
+ validatorIds?: ValidatorId[];
134
+ },
135
+ {params: {epoch: number}; body: string[]},
136
+ AttestationsRewards,
137
+ ExecutionOptimisticAndFinalizedMeta
138
+ >;
139
+
140
+ /**
141
+ * Get sync committee rewards
142
+ * Returns participant reward value for each sync committee member at the given block.
143
+ */
144
+ getSyncCommitteeRewards: Endpoint<
145
+ "POST",
146
+ BlockArgs & {
147
+ /** List of validator indices or pubkeys to filter in */
148
+ validatorIds?: ValidatorId[];
149
+ },
150
+ {params: {block_id: string}; body: string[]},
151
+ SyncCommitteeRewards,
152
+ ExecutionOptimisticAndFinalizedMeta
153
+ >;
154
+ };
155
+
156
+ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpoints> {
157
+ return {
158
+ getBlockRewards: {
159
+ url: "/eth/v1/beacon/rewards/blocks/{block_id}",
160
+ method: "GET",
161
+ req: {
162
+ writeReq: ({blockId}) => ({params: {block_id: blockId.toString()}}),
163
+ parseReq: ({params}) => ({blockId: params.block_id}),
164
+ schema: {params: {block_id: Schema.StringRequired}},
165
+ },
166
+ resp: {
167
+ data: BlockRewardsType,
168
+ meta: ExecutionOptimisticAndFinalizedCodec,
169
+ },
170
+ },
171
+ getAttestationsRewards: {
172
+ url: "/eth/v1/beacon/rewards/attestations/{epoch}",
173
+ method: "POST",
174
+ req: JsonOnlyReq({
175
+ writeReqJson: ({epoch, validatorIds}) => ({
176
+ params: {epoch},
177
+ body: toValidatorIdsStr(validatorIds) || [],
178
+ }),
179
+ parseReqJson: ({params, body}) => ({
180
+ epoch: params.epoch,
181
+ validatorIds: fromValidatorIdsStr(body),
182
+ }),
183
+ schema: {
184
+ params: {epoch: Schema.UintRequired},
185
+ body: Schema.UintOrStringArray,
186
+ },
187
+ }),
188
+ resp: {
189
+ data: AttestationsRewardsType,
190
+ meta: ExecutionOptimisticAndFinalizedCodec,
191
+ },
192
+ },
193
+ getSyncCommitteeRewards: {
194
+ url: "/eth/v1/beacon/rewards/sync_committee/{block_id}",
195
+ method: "POST",
196
+ req: JsonOnlyReq({
197
+ writeReqJson: ({blockId, validatorIds}) => ({
198
+ params: {block_id: blockId.toString()},
199
+ body: toValidatorIdsStr(validatorIds) || [],
200
+ }),
201
+ parseReqJson: ({params, body}) => ({
202
+ blockId: params.block_id,
203
+ validatorIds: fromValidatorIdsStr(body),
204
+ }),
205
+ schema: {
206
+ params: {block_id: Schema.StringRequired},
207
+ body: Schema.UintOrStringArray,
208
+ },
209
+ }),
210
+ resp: {
211
+ data: SyncCommitteeRewardsType,
212
+ meta: ExecutionOptimisticAndFinalizedCodec,
213
+ },
214
+ },
215
+ };
216
+ }