@lodestar/types 1.39.0-dev.c151a164f2 → 1.39.0-dev.c630c55067
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/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/array.d.ts +3 -0
- package/lib/utils/array.d.ts.map +1 -0
- package/lib/utils/array.js +11 -0
- package/lib/utils/array.js.map +1 -0
- package/lib/utils/rewards.d.ts +111 -0
- package/lib/utils/rewards.d.ts.map +1 -0
- package/lib/utils/rewards.js +46 -0
- package/lib/utils/rewards.js.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +2 -0
- package/src/utils/array.ts +11 -0
- package/src/utils/rewards.ts +102 -0
package/lib/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import type { SSZTypesFor } from "./sszTypes.js";
|
|
|
3
3
|
import * as ssz from "./sszTypes.js";
|
|
4
4
|
import { sszTypesFor } from "./sszTypes.js";
|
|
5
5
|
export { sszTypesFor, SSZTypesFor, ssz };
|
|
6
|
+
export * from "./utils/array.js";
|
|
6
7
|
export * from "./utils/container.js";
|
|
7
8
|
export { ExecutionAddressType } from "./utils/executionAddress.js";
|
|
9
|
+
export * as rewards from "./utils/rewards.js";
|
|
8
10
|
export { StringType, stringType } from "./utils/stringType.js";
|
|
9
11
|
export * from "./utils/typeguards.js";
|
|
10
12
|
export * from "./utils/validatorStatus.js";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAE,WAAW,EAAE,GAAG,EAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAE3B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAE,WAAW,EAAE,GAAG,EAAC,CAAC;AAEvC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAE7D,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -2,9 +2,11 @@ export * from "./types.js";
|
|
|
2
2
|
import * as ssz from "./sszTypes.js";
|
|
3
3
|
import { sszTypesFor } from "./sszTypes.js";
|
|
4
4
|
export { sszTypesFor, ssz };
|
|
5
|
+
export * from "./utils/array.js";
|
|
5
6
|
// Container utils
|
|
6
7
|
export * from "./utils/container.js";
|
|
7
8
|
export { ExecutionAddressType } from "./utils/executionAddress.js";
|
|
9
|
+
export * as rewards from "./utils/rewards.js";
|
|
8
10
|
// String type
|
|
9
11
|
export { StringType, stringType } from "./utils/stringType.js";
|
|
10
12
|
// Typeguards
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAG3B,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAe,GAAG,EAAC,CAAC;AAEvC,kBAAkB;AAClB,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,cAAc;AACd,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAC7D,aAAa;AACb,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAG3B,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAe,GAAG,EAAC,CAAC;AAEvC,cAAc,kBAAkB,CAAC;AACjC,kBAAkB;AAClB,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,cAAc;AACd,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAC7D,aAAa;AACb,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoC,IAAI,EAA+B,MAAM,gBAAgB,CAAC;AAE/G,wBAAgB,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,SAAW,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAQvG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ListBasicType, ListCompositeType, isBasicType, isCompositeType } from "@chainsafe/ssz";
|
|
2
|
+
export function ArrayOf(elementType, limit = Infinity) {
|
|
3
|
+
if (isCompositeType(elementType)) {
|
|
4
|
+
return new ListCompositeType(elementType, limit);
|
|
5
|
+
}
|
|
6
|
+
if (isBasicType(elementType)) {
|
|
7
|
+
return new ListBasicType(elementType, limit);
|
|
8
|
+
}
|
|
9
|
+
throw Error(`Unknown type ${elementType.typeName}`);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAE,iBAAiB,EAAQ,WAAW,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAE/G,MAAM,UAAU,OAAO,CAAI,WAAoB,EAAE,KAAK,GAAG,QAAQ;IAC/D,IAAI,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAoD,CAAC;IACtG,CAAC;IACD,IAAI,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,CAAoD,CAAC;IAClG,CAAC;IACD,MAAM,KAAK,CAAC,gBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ContainerType, ValueOf } from "@chainsafe/ssz";
|
|
2
|
+
export declare const BlockRewardsType: ContainerType<{
|
|
3
|
+
/** Proposer of the block, the proposer index who receives these rewards */
|
|
4
|
+
proposerIndex: import("@chainsafe/ssz").UintNumberType;
|
|
5
|
+
/** Total block reward, equal to attestations + sync_aggregate + proposer_slashings + attester_slashings */
|
|
6
|
+
total: import("@chainsafe/ssz").UintNumberType;
|
|
7
|
+
/** Block reward component due to included attestations */
|
|
8
|
+
attestations: import("@chainsafe/ssz").UintNumberType;
|
|
9
|
+
/** Block reward component due to included sync_aggregate */
|
|
10
|
+
syncAggregate: import("@chainsafe/ssz").UintNumberType;
|
|
11
|
+
/** Block reward component due to included proposer_slashings */
|
|
12
|
+
proposerSlashings: import("@chainsafe/ssz").UintNumberType;
|
|
13
|
+
/** Block reward component due to included attester_slashings */
|
|
14
|
+
attesterSlashings: import("@chainsafe/ssz").UintNumberType;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const AttestationsRewardType: ContainerType<{
|
|
17
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
18
|
+
head: import("@chainsafe/ssz").UintNumberType;
|
|
19
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
20
|
+
target: import("@chainsafe/ssz").UintNumberType;
|
|
21
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
22
|
+
source: import("@chainsafe/ssz").UintNumberType;
|
|
23
|
+
/** Inclusion delay reward (phase0 only) */
|
|
24
|
+
inclusionDelay: import("@chainsafe/ssz").UintNumberType;
|
|
25
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
26
|
+
inactivity: import("@chainsafe/ssz").UintNumberType;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const IdealAttestationsRewardsType: ContainerType<{
|
|
29
|
+
effectiveBalance: import("@chainsafe/ssz").UintNumberType;
|
|
30
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
31
|
+
head: import("@chainsafe/ssz").UintNumberType;
|
|
32
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
33
|
+
target: import("@chainsafe/ssz").UintNumberType;
|
|
34
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
35
|
+
source: import("@chainsafe/ssz").UintNumberType;
|
|
36
|
+
/** Inclusion delay reward (phase0 only) */
|
|
37
|
+
inclusionDelay: import("@chainsafe/ssz").UintNumberType;
|
|
38
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
39
|
+
inactivity: import("@chainsafe/ssz").UintNumberType;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const TotalAttestationsRewardsType: ContainerType<{
|
|
42
|
+
validatorIndex: import("@chainsafe/ssz").UintNumberType;
|
|
43
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
44
|
+
head: import("@chainsafe/ssz").UintNumberType;
|
|
45
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
46
|
+
target: import("@chainsafe/ssz").UintNumberType;
|
|
47
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
48
|
+
source: import("@chainsafe/ssz").UintNumberType;
|
|
49
|
+
/** Inclusion delay reward (phase0 only) */
|
|
50
|
+
inclusionDelay: import("@chainsafe/ssz").UintNumberType;
|
|
51
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
52
|
+
inactivity: import("@chainsafe/ssz").UintNumberType;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const AttestationsRewardsType: ContainerType<{
|
|
55
|
+
idealRewards: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<import("@chainsafe/ssz").ValueOfFields<{
|
|
56
|
+
effectiveBalance: import("@chainsafe/ssz").UintNumberType;
|
|
57
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
58
|
+
head: import("@chainsafe/ssz").UintNumberType;
|
|
59
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
60
|
+
target: import("@chainsafe/ssz").UintNumberType;
|
|
61
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
62
|
+
source: import("@chainsafe/ssz").UintNumberType;
|
|
63
|
+
/** Inclusion delay reward (phase0 only) */
|
|
64
|
+
inclusionDelay: import("@chainsafe/ssz").UintNumberType;
|
|
65
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
66
|
+
inactivity: import("@chainsafe/ssz").UintNumberType;
|
|
67
|
+
}>>, unknown, unknown>;
|
|
68
|
+
totalRewards: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<import("@chainsafe/ssz").ValueOfFields<{
|
|
69
|
+
validatorIndex: import("@chainsafe/ssz").UintNumberType;
|
|
70
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
71
|
+
head: import("@chainsafe/ssz").UintNumberType;
|
|
72
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
73
|
+
target: import("@chainsafe/ssz").UintNumberType;
|
|
74
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
75
|
+
source: import("@chainsafe/ssz").UintNumberType;
|
|
76
|
+
/** Inclusion delay reward (phase0 only) */
|
|
77
|
+
inclusionDelay: import("@chainsafe/ssz").UintNumberType;
|
|
78
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
79
|
+
inactivity: import("@chainsafe/ssz").UintNumberType;
|
|
80
|
+
}>>, unknown, unknown>;
|
|
81
|
+
}>;
|
|
82
|
+
export declare const SyncCommitteeRewardsType: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<import("@chainsafe/ssz").ValueOfFields<{
|
|
83
|
+
validatorIndex: import("@chainsafe/ssz").UintNumberType;
|
|
84
|
+
reward: import("@chainsafe/ssz").UintNumberType;
|
|
85
|
+
}>>, unknown, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* Rewards info for a single block. Every reward value is in Gwei.
|
|
88
|
+
*/
|
|
89
|
+
export type BlockRewards = ValueOf<typeof BlockRewardsType>;
|
|
90
|
+
/**
|
|
91
|
+
* Rewards for a single set of (ideal or actual depending on usage) attestations. Reward value is in Gwei
|
|
92
|
+
*/
|
|
93
|
+
export type AttestationsReward = ValueOf<typeof AttestationsRewardType>;
|
|
94
|
+
/**
|
|
95
|
+
* Rewards info for ideal attestations ie. Maximum rewards could be earned by making timely head, target and source vote.
|
|
96
|
+
* `effectiveBalance` is in Gwei
|
|
97
|
+
*/
|
|
98
|
+
export type IdealAttestationsReward = ValueOf<typeof IdealAttestationsRewardsType>;
|
|
99
|
+
/**
|
|
100
|
+
* Rewards info for actual attestations
|
|
101
|
+
*/
|
|
102
|
+
export type TotalAttestationsReward = ValueOf<typeof TotalAttestationsRewardsType>;
|
|
103
|
+
export type AttestationsRewards = ValueOf<typeof AttestationsRewardsType>;
|
|
104
|
+
/**
|
|
105
|
+
* Rewards info for sync committee participation. Every reward value is in Gwei.
|
|
106
|
+
* Note: In the case that block proposer is present in `SyncCommitteeRewards`, the reward value only reflects rewards for
|
|
107
|
+
* participating in sync committee. Please refer to `BlockRewards.syncAggregate` for rewards of proposer including sync committee
|
|
108
|
+
* outputs into their block
|
|
109
|
+
*/
|
|
110
|
+
export type SyncCommitteeRewards = ValueOf<typeof SyncCommitteeRewardsType>;
|
|
111
|
+
//# sourceMappingURL=rewards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewards.d.ts","sourceRoot":"","sources":["../../src/utils/rewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAItD,eAAO,MAAM,gBAAgB;IAEzB,2EAA2E;;IAE3E,2GAA2G;;IAE3G,0DAA0D;;IAE1D,4DAA4D;;IAE5D,gEAAgE;;IAEhE,gEAAgE;;EAInE,CAAC;AAEF,eAAO,MAAM,sBAAsB;IAE/B,kEAAkE;;IAElE,oEAAoE;;IAEpE,oEAAoE;;IAEpE,2CAA2C;;IAE3C,0EAA0E;;EAI7E,CAAC;AAEF,eAAO,MAAM,4BAA4B;;IAdrC,kEAAkE;;IAElE,oEAAoE;;IAEpE,oEAAoE;;IAEpE,2CAA2C;;IAE3C,0EAA0E;;EAY7E,CAAC;AAEF,eAAO,MAAM,4BAA4B;;IAtBrC,kEAAkE;;IAElE,oEAAoE;;IAEpE,oEAAoE;;IAEpE,2CAA2C;;IAE3C,0EAA0E;;EAoB7E,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;QA9BhC,kEAAkE;;QAElE,oEAAoE;;QAEpE,oEAAoE;;QAEpE,2CAA2C;;QAE3C,0EAA0E;;;;;QAR1E,kEAAkE;;QAElE,oEAAoE;;QAEpE,oEAAoE;;QAEpE,2CAA2C;;QAE3C,0EAA0E;;;EA4B7E,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;sBAQpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEnF,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ContainerType } from "@chainsafe/ssz";
|
|
2
|
+
import { UintNum64, ValidatorIndex } from "../sszTypes.js";
|
|
3
|
+
import { ArrayOf } from "./array.js";
|
|
4
|
+
export const BlockRewardsType = new ContainerType({
|
|
5
|
+
/** Proposer of the block, the proposer index who receives these rewards */
|
|
6
|
+
proposerIndex: ValidatorIndex,
|
|
7
|
+
/** Total block reward, equal to attestations + sync_aggregate + proposer_slashings + attester_slashings */
|
|
8
|
+
total: UintNum64,
|
|
9
|
+
/** Block reward component due to included attestations */
|
|
10
|
+
attestations: UintNum64,
|
|
11
|
+
/** Block reward component due to included sync_aggregate */
|
|
12
|
+
syncAggregate: UintNum64,
|
|
13
|
+
/** Block reward component due to included proposer_slashings */
|
|
14
|
+
proposerSlashings: UintNum64,
|
|
15
|
+
/** Block reward component due to included attester_slashings */
|
|
16
|
+
attesterSlashings: UintNum64,
|
|
17
|
+
}, { jsonCase: "eth2" });
|
|
18
|
+
export const AttestationsRewardType = new ContainerType({
|
|
19
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
20
|
+
head: UintNum64,
|
|
21
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
22
|
+
target: UintNum64,
|
|
23
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
24
|
+
source: UintNum64,
|
|
25
|
+
/** Inclusion delay reward (phase0 only) */
|
|
26
|
+
inclusionDelay: UintNum64,
|
|
27
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
28
|
+
inactivity: UintNum64,
|
|
29
|
+
}, { jsonCase: "eth2" });
|
|
30
|
+
export const IdealAttestationsRewardsType = new ContainerType({
|
|
31
|
+
...AttestationsRewardType.fields,
|
|
32
|
+
effectiveBalance: UintNum64,
|
|
33
|
+
}, { jsonCase: "eth2" });
|
|
34
|
+
export const TotalAttestationsRewardsType = new ContainerType({
|
|
35
|
+
...AttestationsRewardType.fields,
|
|
36
|
+
validatorIndex: ValidatorIndex,
|
|
37
|
+
}, { jsonCase: "eth2" });
|
|
38
|
+
export const AttestationsRewardsType = new ContainerType({
|
|
39
|
+
idealRewards: ArrayOf(IdealAttestationsRewardsType),
|
|
40
|
+
totalRewards: ArrayOf(TotalAttestationsRewardsType),
|
|
41
|
+
}, { jsonCase: "eth2" });
|
|
42
|
+
export const SyncCommitteeRewardsType = ArrayOf(new ContainerType({
|
|
43
|
+
validatorIndex: ValidatorIndex,
|
|
44
|
+
reward: UintNum64,
|
|
45
|
+
}, { jsonCase: "eth2" }));
|
|
46
|
+
//# sourceMappingURL=rewards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewards.js","sourceRoot":"","sources":["../../src/utils/rewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAU,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,aAAa,CAC/C;IACE,2EAA2E;IAC3E,aAAa,EAAE,cAAc;IAC7B,2GAA2G;IAC3G,KAAK,EAAE,SAAS;IAChB,0DAA0D;IAC1D,YAAY,EAAE,SAAS;IACvB,4DAA4D;IAC5D,aAAa,EAAE,SAAS;IACxB,gEAAgE;IAChE,iBAAiB,EAAE,SAAS;IAC5B,gEAAgE;IAChE,iBAAiB,EAAE,SAAS;CAC7B,EACD,EAAC,QAAQ,EAAE,MAAM,EAAC,CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,aAAa,CACrD;IACE,kEAAkE;IAClE,IAAI,EAAE,SAAS;IACf,oEAAoE;IACpE,MAAM,EAAE,SAAS;IACjB,oEAAoE;IACpE,MAAM,EAAE,SAAS;IACjB,2CAA2C;IAC3C,cAAc,EAAE,SAAS;IACzB,0EAA0E;IAC1E,UAAU,EAAE,SAAS;CACtB,EACD,EAAC,QAAQ,EAAE,MAAM,EAAC,CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,aAAa,CAC3D;IACE,GAAG,sBAAsB,CAAC,MAAM;IAChC,gBAAgB,EAAE,SAAS;CAC5B,EACD,EAAC,QAAQ,EAAE,MAAM,EAAC,CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,aAAa,CAC3D;IACE,GAAG,sBAAsB,CAAC,MAAM;IAChC,cAAc,EAAE,cAAc;CAC/B,EACD,EAAC,QAAQ,EAAE,MAAM,EAAC,CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,aAAa,CACtD;IACE,YAAY,EAAE,OAAO,CAAC,4BAA4B,CAAC;IACnD,YAAY,EAAE,OAAO,CAAC,4BAA4B,CAAC;CACpD,EACD,EAAC,QAAQ,EAAE,MAAM,EAAC,CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAC7C,IAAI,aAAa,CACf;IACE,cAAc,EAAE,cAAc;IAC9B,MAAM,EAAE,SAAS;CAClB,EACD,EAAC,QAAQ,EAAE,MAAM,EAAC,CACnB,CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.39.0-dev.
|
|
14
|
+
"version": "1.39.0-dev.c630c55067",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"types": "lib/index.d.ts",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@chainsafe/ssz": "^1.2.2",
|
|
80
|
-
"@lodestar/params": "1.39.0-dev.
|
|
80
|
+
"@lodestar/params": "1.39.0-dev.c630c55067",
|
|
81
81
|
"ethereum-cryptography": "^2.0.0"
|
|
82
82
|
},
|
|
83
83
|
"keywords": [
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"beacon",
|
|
87
87
|
"blockchain"
|
|
88
88
|
],
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "ead055ee9d3179f198a25ba5c984e8509dea31d7"
|
|
90
90
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,9 +5,11 @@ import * as ssz from "./sszTypes.js";
|
|
|
5
5
|
import {sszTypesFor} from "./sszTypes.js";
|
|
6
6
|
export {sszTypesFor, SSZTypesFor, ssz};
|
|
7
7
|
|
|
8
|
+
export * from "./utils/array.js";
|
|
8
9
|
// Container utils
|
|
9
10
|
export * from "./utils/container.js";
|
|
10
11
|
export {ExecutionAddressType} from "./utils/executionAddress.js";
|
|
12
|
+
export * as rewards from "./utils/rewards.js";
|
|
11
13
|
// String type
|
|
12
14
|
export {StringType, stringType} from "./utils/stringType.js";
|
|
13
15
|
// Typeguards
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {ArrayType, ListBasicType, ListCompositeType, Type, isBasicType, isCompositeType} from "@chainsafe/ssz";
|
|
2
|
+
|
|
3
|
+
export function ArrayOf<T>(elementType: Type<T>, limit = Infinity): ArrayType<Type<T>, unknown, unknown> {
|
|
4
|
+
if (isCompositeType(elementType)) {
|
|
5
|
+
return new ListCompositeType(elementType, limit) as unknown as ArrayType<Type<T>, unknown, unknown>;
|
|
6
|
+
}
|
|
7
|
+
if (isBasicType(elementType)) {
|
|
8
|
+
return new ListBasicType(elementType, limit) as unknown as ArrayType<Type<T>, unknown, unknown>;
|
|
9
|
+
}
|
|
10
|
+
throw Error(`Unknown type ${elementType.typeName}`);
|
|
11
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {ContainerType, ValueOf} from "@chainsafe/ssz";
|
|
2
|
+
import {UintNum64, ValidatorIndex} from "../sszTypes.js";
|
|
3
|
+
import {ArrayOf} from "./array.js";
|
|
4
|
+
|
|
5
|
+
export const BlockRewardsType = new ContainerType(
|
|
6
|
+
{
|
|
7
|
+
/** Proposer of the block, the proposer index who receives these rewards */
|
|
8
|
+
proposerIndex: ValidatorIndex,
|
|
9
|
+
/** Total block reward, equal to attestations + sync_aggregate + proposer_slashings + attester_slashings */
|
|
10
|
+
total: UintNum64,
|
|
11
|
+
/** Block reward component due to included attestations */
|
|
12
|
+
attestations: UintNum64,
|
|
13
|
+
/** Block reward component due to included sync_aggregate */
|
|
14
|
+
syncAggregate: UintNum64,
|
|
15
|
+
/** Block reward component due to included proposer_slashings */
|
|
16
|
+
proposerSlashings: UintNum64,
|
|
17
|
+
/** Block reward component due to included attester_slashings */
|
|
18
|
+
attesterSlashings: UintNum64,
|
|
19
|
+
},
|
|
20
|
+
{jsonCase: "eth2"}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const AttestationsRewardType = new ContainerType(
|
|
24
|
+
{
|
|
25
|
+
/** Reward for head vote. Could be negative to indicate penalty */
|
|
26
|
+
head: UintNum64,
|
|
27
|
+
/** Reward for target vote. Could be negative to indicate penalty */
|
|
28
|
+
target: UintNum64,
|
|
29
|
+
/** Reward for source vote. Could be negative to indicate penalty */
|
|
30
|
+
source: UintNum64,
|
|
31
|
+
/** Inclusion delay reward (phase0 only) */
|
|
32
|
+
inclusionDelay: UintNum64,
|
|
33
|
+
/** Inactivity penalty. Should be a negative number to indicate penalty */
|
|
34
|
+
inactivity: UintNum64,
|
|
35
|
+
},
|
|
36
|
+
{jsonCase: "eth2"}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const IdealAttestationsRewardsType = new ContainerType(
|
|
40
|
+
{
|
|
41
|
+
...AttestationsRewardType.fields,
|
|
42
|
+
effectiveBalance: UintNum64,
|
|
43
|
+
},
|
|
44
|
+
{jsonCase: "eth2"}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const TotalAttestationsRewardsType = new ContainerType(
|
|
48
|
+
{
|
|
49
|
+
...AttestationsRewardType.fields,
|
|
50
|
+
validatorIndex: ValidatorIndex,
|
|
51
|
+
},
|
|
52
|
+
{jsonCase: "eth2"}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export const AttestationsRewardsType = new ContainerType(
|
|
56
|
+
{
|
|
57
|
+
idealRewards: ArrayOf(IdealAttestationsRewardsType),
|
|
58
|
+
totalRewards: ArrayOf(TotalAttestationsRewardsType),
|
|
59
|
+
},
|
|
60
|
+
{jsonCase: "eth2"}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export const SyncCommitteeRewardsType = ArrayOf(
|
|
64
|
+
new ContainerType(
|
|
65
|
+
{
|
|
66
|
+
validatorIndex: ValidatorIndex,
|
|
67
|
+
reward: UintNum64,
|
|
68
|
+
},
|
|
69
|
+
{jsonCase: "eth2"}
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Rewards info for a single block. Every reward value is in Gwei.
|
|
75
|
+
*/
|
|
76
|
+
export type BlockRewards = ValueOf<typeof BlockRewardsType>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Rewards for a single set of (ideal or actual depending on usage) attestations. Reward value is in Gwei
|
|
80
|
+
*/
|
|
81
|
+
export type AttestationsReward = ValueOf<typeof AttestationsRewardType>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Rewards info for ideal attestations ie. Maximum rewards could be earned by making timely head, target and source vote.
|
|
85
|
+
* `effectiveBalance` is in Gwei
|
|
86
|
+
*/
|
|
87
|
+
export type IdealAttestationsReward = ValueOf<typeof IdealAttestationsRewardsType>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Rewards info for actual attestations
|
|
91
|
+
*/
|
|
92
|
+
export type TotalAttestationsReward = ValueOf<typeof TotalAttestationsRewardsType>;
|
|
93
|
+
|
|
94
|
+
export type AttestationsRewards = ValueOf<typeof AttestationsRewardsType>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Rewards info for sync committee participation. Every reward value is in Gwei.
|
|
98
|
+
* Note: In the case that block proposer is present in `SyncCommitteeRewards`, the reward value only reflects rewards for
|
|
99
|
+
* participating in sync committee. Please refer to `BlockRewards.syncAggregate` for rewards of proposer including sync committee
|
|
100
|
+
* outputs into their block
|
|
101
|
+
*/
|
|
102
|
+
export type SyncCommitteeRewards = ValueOf<typeof SyncCommitteeRewardsType>;
|