@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.
- package/lib/beacon/client/beacon.d.ts.map +1 -0
- package/lib/beacon/client/config.d.ts.map +1 -0
- package/lib/beacon/client/debug.d.ts.map +1 -0
- package/lib/beacon/client/events.d.ts.map +1 -0
- package/lib/beacon/client/index.d.ts.map +1 -0
- package/lib/beacon/client/index.js.map +1 -1
- package/lib/beacon/client/lightclient.d.ts.map +1 -0
- package/lib/beacon/client/lodestar.d.ts.map +1 -0
- package/lib/beacon/client/node.d.ts.map +1 -0
- package/lib/beacon/client/proof.d.ts.map +1 -0
- package/lib/beacon/client/validator.d.ts.map +1 -0
- package/lib/beacon/index.d.ts +1 -1
- package/lib/beacon/index.d.ts.map +1 -0
- package/lib/beacon/index.js.map +1 -1
- package/lib/beacon/routes/beacon/block.d.ts.map +1 -0
- package/lib/beacon/routes/beacon/index.d.ts +3 -3
- package/lib/beacon/routes/beacon/index.d.ts.map +1 -0
- package/lib/beacon/routes/beacon/index.js.map +1 -1
- package/lib/beacon/routes/beacon/pool.d.ts +1 -1
- package/lib/beacon/routes/beacon/pool.d.ts.map +1 -0
- package/lib/beacon/routes/beacon/rewards.d.ts.map +1 -0
- package/lib/beacon/routes/beacon/rewards.js.map +1 -1
- package/lib/beacon/routes/beacon/state.d.ts +2 -2
- package/lib/beacon/routes/beacon/state.d.ts.map +1 -0
- package/lib/beacon/routes/config.d.ts +1 -1
- package/lib/beacon/routes/config.d.ts.map +1 -0
- package/lib/beacon/routes/debug.d.ts.map +1 -0
- package/lib/beacon/routes/events.d.ts.map +1 -0
- package/lib/beacon/routes/events.js.map +1 -1
- package/lib/beacon/routes/index.d.ts.map +1 -0
- package/lib/beacon/routes/index.js.map +1 -1
- package/lib/beacon/routes/lightclient.d.ts.map +1 -0
- package/lib/beacon/routes/lodestar.d.ts.map +1 -0
- package/lib/beacon/routes/node.d.ts.map +1 -0
- package/lib/beacon/routes/proof.d.ts.map +1 -0
- package/lib/beacon/routes/validator.d.ts +1 -1
- package/lib/beacon/routes/validator.d.ts.map +1 -0
- package/lib/beacon/server/beacon.d.ts.map +1 -0
- package/lib/beacon/server/config.d.ts.map +1 -0
- package/lib/beacon/server/debug.d.ts.map +1 -0
- package/lib/beacon/server/events.d.ts.map +1 -0
- package/lib/beacon/server/index.d.ts +1 -1
- package/lib/beacon/server/index.d.ts.map +1 -0
- package/lib/beacon/server/index.js.map +1 -1
- package/lib/beacon/server/lightclient.d.ts.map +1 -0
- package/lib/beacon/server/lodestar.d.ts.map +1 -0
- package/lib/beacon/server/node.d.ts.map +1 -0
- package/lib/beacon/server/proof.d.ts.map +1 -0
- package/lib/beacon/server/validator.d.ts.map +1 -0
- package/lib/builder/client.d.ts.map +1 -0
- package/lib/builder/index.d.ts.map +1 -0
- package/lib/builder/index.js.map +1 -1
- package/lib/builder/routes.d.ts.map +1 -0
- package/lib/builder/routes.js.map +1 -1
- package/lib/builder/server/index.d.ts +1 -1
- package/lib/builder/server/index.d.ts.map +1 -0
- package/lib/index.d.ts +6 -6
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/keymanager/client.d.ts.map +1 -0
- package/lib/keymanager/index.d.ts +2 -2
- package/lib/keymanager/index.d.ts.map +1 -0
- package/lib/keymanager/index.js +1 -2
- package/lib/keymanager/index.js.map +1 -1
- package/lib/keymanager/routes.d.ts.map +1 -0
- package/lib/keymanager/server/index.d.ts +1 -1
- package/lib/keymanager/server/index.d.ts.map +1 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/utils/client/error.d.ts.map +1 -0
- package/lib/utils/client/error.js +2 -0
- package/lib/utils/client/error.js.map +1 -1
- package/lib/utils/client/eventSource.d.ts.map +1 -0
- package/lib/utils/client/format.d.ts.map +1 -0
- package/lib/utils/client/httpClient.d.ts +1 -2
- package/lib/utils/client/httpClient.d.ts.map +1 -0
- package/lib/utils/client/httpClient.js +13 -9
- package/lib/utils/client/httpClient.js.map +1 -1
- package/lib/utils/client/index.d.ts +1 -1
- package/lib/utils/client/index.d.ts.map +1 -0
- package/lib/utils/client/index.js +1 -1
- package/lib/utils/client/index.js.map +1 -1
- package/lib/utils/client/method.d.ts.map +1 -0
- package/lib/utils/client/metrics.d.ts.map +1 -0
- package/lib/utils/client/request.d.ts.map +1 -0
- package/lib/utils/client/response.d.ts.map +1 -0
- package/lib/utils/client/response.js +6 -0
- package/lib/utils/client/response.js.map +1 -1
- package/lib/utils/codecs.d.ts.map +1 -0
- package/lib/utils/fork.d.ts.map +1 -0
- package/lib/utils/headers.d.ts.map +1 -0
- package/lib/utils/httpStatusCode.d.ts.map +1 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/metadata.d.ts.map +1 -0
- package/lib/utils/schema.d.ts.map +1 -0
- package/lib/utils/serdes.d.ts.map +1 -0
- package/lib/utils/server/error.d.ts.map +1 -0
- package/lib/utils/server/error.js +1 -0
- package/lib/utils/server/error.js.map +1 -1
- package/lib/utils/server/handler.d.ts.map +1 -0
- package/lib/utils/server/index.d.ts.map +1 -0
- package/lib/utils/server/method.d.ts.map +1 -0
- package/lib/utils/server/parser.d.ts.map +1 -0
- package/lib/utils/server/route.d.ts.map +1 -0
- package/lib/utils/server/route.js.map +1 -1
- package/lib/utils/types.d.ts.map +1 -0
- package/lib/utils/urlFormat.d.ts.map +1 -0
- package/lib/utils/wireFormat.d.ts.map +1 -0
- package/package.json +17 -11
- package/src/beacon/client/beacon.ts +12 -0
- package/src/beacon/client/config.ts +12 -0
- package/src/beacon/client/debug.ts +12 -0
- package/src/beacon/client/events.ts +69 -0
- package/src/beacon/client/index.ts +46 -0
- package/src/beacon/client/lightclient.ts +12 -0
- package/src/beacon/client/lodestar.ts +12 -0
- package/src/beacon/client/node.ts +12 -0
- package/src/beacon/client/proof.ts +12 -0
- package/src/beacon/client/validator.ts +12 -0
- package/src/beacon/index.ts +24 -0
- package/src/beacon/routes/beacon/block.ts +602 -0
- package/src/beacon/routes/beacon/index.ts +66 -0
- package/src/beacon/routes/beacon/pool.ts +503 -0
- package/src/beacon/routes/beacon/rewards.ts +216 -0
- package/src/beacon/routes/beacon/state.ts +588 -0
- package/src/beacon/routes/config.ts +114 -0
- package/src/beacon/routes/debug.ts +231 -0
- package/src/beacon/routes/events.ts +337 -0
- package/src/beacon/routes/index.ts +33 -0
- package/src/beacon/routes/lightclient.ts +241 -0
- package/src/beacon/routes/lodestar.ts +456 -0
- package/src/beacon/routes/node.ts +286 -0
- package/src/beacon/routes/proof.ts +79 -0
- package/src/beacon/routes/validator.ts +1014 -0
- package/src/beacon/server/beacon.ts +7 -0
- package/src/beacon/server/config.ts +7 -0
- package/src/beacon/server/debug.ts +7 -0
- package/src/beacon/server/events.ts +73 -0
- package/src/beacon/server/index.ts +55 -0
- package/src/beacon/server/lightclient.ts +7 -0
- package/src/beacon/server/lodestar.ts +7 -0
- package/src/beacon/server/node.ts +7 -0
- package/src/beacon/server/proof.ts +7 -0
- package/src/beacon/server/validator.ts +7 -0
- package/src/builder/client.ts +9 -0
- package/src/builder/index.ts +26 -0
- package/src/builder/routes.ts +227 -0
- package/src/builder/server/index.ts +19 -0
- package/src/index.ts +19 -0
- package/src/keymanager/client.ts +9 -0
- package/src/keymanager/index.ts +39 -0
- package/src/keymanager/routes.ts +699 -0
- package/src/keymanager/server/index.ts +19 -0
- package/src/server/index.ts +2 -0
- package/src/utils/client/error.ts +10 -0
- package/src/utils/client/eventSource.ts +7 -0
- package/src/utils/client/format.ts +22 -0
- package/src/utils/client/httpClient.ts +444 -0
- package/src/utils/client/index.ts +6 -0
- package/src/utils/client/method.ts +50 -0
- package/src/utils/client/metrics.ts +9 -0
- package/src/utils/client/request.ts +113 -0
- package/src/utils/client/response.ts +205 -0
- package/src/utils/codecs.ts +143 -0
- package/src/utils/fork.ts +44 -0
- package/src/utils/headers.ts +173 -0
- package/src/utils/httpStatusCode.ts +392 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/metadata.ts +170 -0
- package/src/utils/schema.ts +141 -0
- package/src/utils/serdes.ts +120 -0
- package/src/utils/server/error.ts +9 -0
- package/src/utils/server/handler.ts +149 -0
- package/src/utils/server/index.ts +5 -0
- package/src/utils/server/method.ts +38 -0
- package/src/utils/server/parser.ts +15 -0
- package/src/utils/server/route.ts +45 -0
- package/src/utils/types.ts +161 -0
- package/src/utils/urlFormat.ts +112 -0
- 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
|
+
}
|