@obolnetwork/obol-sdk 2.11.4 → 2.11.5-rc.0
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/dist/cjs/src/index.js +17457 -382
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/esm/src/index.js +17424 -361
- package/dist/esm/src/index.js.map +1 -0
- package/dist/types/src/constants.d.ts +1 -2
- package/dist/types/src/eoa/eoaHelpers.d.ts +1 -1
- package/dist/types/src/exits/verificationHelpers.d.ts +0 -2
- package/dist/types/src/incentives/incentiveHelpers.d.ts +1 -1
- package/dist/types/src/splits/splitHelpers.d.ts +3 -3
- package/dist/types/src/utils.d.ts +2 -2
- package/dist/types/src/verification/common.d.ts +0 -2
- package/dist/types/src/verification/signature-validator.d.ts +4 -4
- package/dist/types/src/verification/v1.10.0.d.ts +1 -1
- package/dist/types/src/verification/v1.6.0.d.ts +1 -1
- package/dist/types/src/verification/v1.7.0.d.ts +1 -1
- package/dist/types/src/verification/v1.8.0.d.ts +1 -1
- package/dist/types/test/client/methods.spec.d.ts +17 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/tsup.config.d.ts +2 -0
- package/package.json +79 -54
- package/dist/cjs/package.json +0 -139
- package/dist/cjs/src/abi/BatchDeposit.js +0 -120
- package/dist/cjs/src/abi/MerkleDistributorWithDeadline.js +0 -73
- package/dist/cjs/src/abi/Multicall3.js +0 -253
- package/dist/cjs/src/abi/OVM.js +0 -627
- package/dist/cjs/src/abi/OWR.js +0 -304
- package/dist/cjs/src/abi/SplitMain.js +0 -929
- package/dist/cjs/src/abi/splitV2FactoryAbi.js +0 -420
- package/dist/cjs/src/ajv.js +0 -136
- package/dist/cjs/src/base.js +0 -42
- package/dist/cjs/src/bytecodes.js +0 -19
- package/dist/cjs/src/constants.js +0 -272
- package/dist/cjs/src/eoa/eoa.js +0 -132
- package/dist/cjs/src/eoa/eoaHelpers.js +0 -82
- package/dist/cjs/src/errors.js +0 -11
- package/dist/cjs/src/exits/ethUtils.js +0 -57
- package/dist/cjs/src/exits/exit.js +0 -502
- package/dist/cjs/src/exits/verificationHelpers.js +0 -86
- package/dist/cjs/src/incentives/incentiveHelpers.js +0 -39
- package/dist/cjs/src/incentives/incentives.js +0 -119
- package/dist/cjs/src/schema.js +0 -352
- package/dist/cjs/src/services.js +0 -33
- package/dist/cjs/src/splits/splitHelpers.js +0 -571
- package/dist/cjs/src/splits/splits.js +0 -366
- package/dist/cjs/src/types.js +0 -29
- package/dist/cjs/src/utils.js +0 -77
- package/dist/cjs/src/verification/common.js +0 -355
- package/dist/cjs/src/verification/signature-validator.js +0 -73
- package/dist/cjs/src/verification/sszTypes.js +0 -69
- package/dist/cjs/src/verification/termsAndConditions.js +0 -40
- package/dist/cjs/src/verification/v1.10.0.js +0 -146
- package/dist/cjs/src/verification/v1.6.0.js +0 -149
- package/dist/cjs/src/verification/v1.7.0.js +0 -173
- package/dist/cjs/src/verification/v1.8.0.js +0 -196
- package/dist/cjs/test/client/ajv.spec.js +0 -320
- package/dist/cjs/test/client/methods.spec.js +0 -418
- package/dist/cjs/test/eoa/eoa.spec.js +0 -176
- package/dist/cjs/test/exit/ethUtils.spec.js +0 -83
- package/dist/cjs/test/exit/exit.spec.js +0 -399
- package/dist/cjs/test/exit/verificationHelpers.spec.js +0 -68
- package/dist/cjs/test/fixtures.js +0 -896
- package/dist/cjs/test/incentives/incentives.spec.js +0 -202
- package/dist/cjs/test/splits/splits.spec.js +0 -402
- package/dist/esm/package.json +0 -139
- package/dist/esm/src/abi/BatchDeposit.js +0 -117
- package/dist/esm/src/abi/MerkleDistributorWithDeadline.js +0 -70
- package/dist/esm/src/abi/Multicall3.js +0 -250
- package/dist/esm/src/abi/OVM.js +0 -624
- package/dist/esm/src/abi/OWR.js +0 -301
- package/dist/esm/src/abi/SplitMain.js +0 -926
- package/dist/esm/src/abi/splitV2FactoryAbi.js +0 -417
- package/dist/esm/src/ajv.js +0 -129
- package/dist/esm/src/base.js +0 -38
- package/dist/esm/src/bytecodes.js +0 -16
- package/dist/esm/src/constants.js +0 -238
- package/dist/esm/src/eoa/eoa.js +0 -128
- package/dist/esm/src/eoa/eoaHelpers.js +0 -77
- package/dist/esm/src/errors.js +0 -7
- package/dist/esm/src/exits/ethUtils.js +0 -52
- package/dist/esm/src/exits/exit.js +0 -475
- package/dist/esm/src/exits/verificationHelpers.js +0 -81
- package/dist/esm/src/incentives/incentiveHelpers.js +0 -34
- package/dist/esm/src/incentives/incentives.js +0 -115
- package/dist/esm/src/schema.js +0 -349
- package/dist/esm/src/services.js +0 -29
- package/dist/esm/src/splits/splitHelpers.js +0 -554
- package/dist/esm/src/splits/splits.js +0 -362
- package/dist/esm/src/types.js +0 -26
- package/dist/esm/src/utils.js +0 -68
- package/dist/esm/src/verification/common.js +0 -319
- package/dist/esm/src/verification/signature-validator.js +0 -64
- package/dist/esm/src/verification/sszTypes.js +0 -64
- package/dist/esm/src/verification/termsAndConditions.js +0 -33
- package/dist/esm/src/verification/v1.10.0.js +0 -140
- package/dist/esm/src/verification/v1.6.0.js +0 -142
- package/dist/esm/src/verification/v1.7.0.js +0 -166
- package/dist/esm/src/verification/v1.8.0.js +0 -189
- package/dist/esm/test/client/ajv.spec.js +0 -318
- package/dist/esm/test/client/methods.spec.js +0 -393
- package/dist/esm/test/eoa/eoa.spec.js +0 -174
- package/dist/esm/test/exit/ethUtils.spec.js +0 -81
- package/dist/esm/test/exit/exit.spec.js +0 -374
- package/dist/esm/test/exit/verificationHelpers.spec.js +0 -66
- package/dist/esm/test/fixtures.js +0 -893
- package/dist/esm/test/incentives/incentives.spec.js +0 -177
- package/dist/esm/test/splits/splits.spec.js +0 -400
- package/src/abi/BatchDeposit.ts +0 -117
- package/src/abi/MerkleDistributorWithDeadline.ts +0 -70
- package/src/abi/Multicall3.ts +0 -250
- package/src/abi/OVM.ts +0 -624
- package/src/abi/OWR.ts +0 -302
- package/src/abi/SplitMain.ts +0 -927
- package/src/abi/splitV2FactoryAbi.ts +0 -417
- package/src/ajv.ts +0 -191
- package/src/base.ts +0 -54
- package/src/bytecodes.ts +0 -32
- package/src/constants.ts +0 -309
- package/src/eoa/eoa.ts +0 -153
- package/src/eoa/eoaHelpers.ts +0 -112
- package/src/errors.ts +0 -8
- package/src/exits/ethUtils.ts +0 -49
- package/src/exits/exit.ts +0 -661
- package/src/exits/verificationHelpers.ts +0 -110
- package/src/incentives/incentiveHelpers.ts +0 -55
- package/src/incentives/incentives.ts +0 -153
- package/src/index.ts +0 -614
- package/src/schema.ts +0 -376
- package/src/services.ts +0 -24
- package/src/splits/splitHelpers.ts +0 -1032
- package/src/splits/splits.ts +0 -504
- package/src/types.ts +0 -687
- package/src/utils.ts +0 -88
- package/src/verification/common.ts +0 -532
- package/src/verification/signature-validator.ts +0 -103
- package/src/verification/sszTypes.ts +0 -88
- package/src/verification/termsAndConditions.ts +0 -32
- package/src/verification/v1.10.0.ts +0 -245
- package/src/verification/v1.6.0.ts +0 -256
- package/src/verification/v1.7.0.ts +0 -309
- package/src/verification/v1.8.0.ts +0 -340
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyDVV1X10 = exports.hashClusterLockV1X10 = exports.hashClusterDefinitionV1X10 = exports.clusterDefinitionContainerTypeV1X10 = void 0;
|
|
4
|
-
const uint_1 = require("@chainsafe/ssz/lib/type/uint");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const sszTypes_1 = require("./sszTypes");
|
|
7
|
-
const ssz_1 = require("@chainsafe/ssz");
|
|
8
|
-
const v1_8_0_1 = require("./v1.8.0");
|
|
9
|
-
/**
|
|
10
|
-
* Returns the containerized cluster definition
|
|
11
|
-
* @param cluster ClusterDefinition to calculate the type from
|
|
12
|
-
* @returns SSZ Containerized type of cluster input
|
|
13
|
-
*/
|
|
14
|
-
const clusterDefinitionContainerTypeV1X10 = (configOnly) => {
|
|
15
|
-
let returnedContainerType = {
|
|
16
|
-
uuid: new ssz_1.ByteListType(64),
|
|
17
|
-
name: new ssz_1.ByteListType(256),
|
|
18
|
-
version: new ssz_1.ByteListType(16),
|
|
19
|
-
timestamp: new ssz_1.ByteListType(32),
|
|
20
|
-
num_validators: new uint_1.UintNumberType(8),
|
|
21
|
-
threshold: new uint_1.UintNumberType(8),
|
|
22
|
-
dkg_algorithm: new ssz_1.ByteListType(32),
|
|
23
|
-
fork_version: new ssz_1.ByteVectorType(4),
|
|
24
|
-
operators: new ssz_1.ListCompositeType((0, sszTypes_1.newOperatorContainerType)(configOnly), 256),
|
|
25
|
-
creator: (0, sszTypes_1.newCreatorContainerType)(configOnly),
|
|
26
|
-
validators: new ssz_1.ListCompositeType(sszTypes_1.validatorsContainerType, 65536),
|
|
27
|
-
deposit_amounts: new ssz_1.ListBasicType(new uint_1.UintNumberType(8), 256),
|
|
28
|
-
consensus_protocol: new ssz_1.ByteListType(256),
|
|
29
|
-
target_gas_limit: new uint_1.UintNumberType(8),
|
|
30
|
-
compounding: new ssz_1.BooleanType(),
|
|
31
|
-
};
|
|
32
|
-
if (!configOnly) {
|
|
33
|
-
returnedContainerType = Object.assign(Object.assign({}, returnedContainerType), { config_hash: new ssz_1.ByteVectorType(32) });
|
|
34
|
-
}
|
|
35
|
-
return new ssz_1.ContainerType(returnedContainerType);
|
|
36
|
-
};
|
|
37
|
-
exports.clusterDefinitionContainerTypeV1X10 = clusterDefinitionContainerTypeV1X10;
|
|
38
|
-
const hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
39
|
-
const definitionType = (0, exports.clusterDefinitionContainerTypeV1X10)(configOnly);
|
|
40
|
-
const val = definitionType.defaultValue();
|
|
41
|
-
// order should be same as charon https://github.com/ObolNetwork/charon/blob/main/cluster/ssz.go#L276
|
|
42
|
-
val.uuid = (0, utils_1.strToUint8Array)(cluster.uuid);
|
|
43
|
-
val.name = (0, utils_1.strToUint8Array)(cluster.name);
|
|
44
|
-
val.version = (0, utils_1.strToUint8Array)(cluster.version);
|
|
45
|
-
val.timestamp = (0, utils_1.strToUint8Array)(cluster.timestamp);
|
|
46
|
-
val.num_validators = cluster.num_validators;
|
|
47
|
-
val.threshold = cluster.threshold;
|
|
48
|
-
val.dkg_algorithm = (0, utils_1.strToUint8Array)(cluster.dkg_algorithm);
|
|
49
|
-
val.fork_version = (0, ssz_1.fromHexString)(cluster.fork_version);
|
|
50
|
-
val.operators = cluster.operators.map(operator => {
|
|
51
|
-
return configOnly
|
|
52
|
-
? { address: (0, ssz_1.fromHexString)(operator.address) }
|
|
53
|
-
: {
|
|
54
|
-
address: (0, ssz_1.fromHexString)(operator.address),
|
|
55
|
-
enr: (0, utils_1.strToUint8Array)(operator.enr),
|
|
56
|
-
config_signature: (0, ssz_1.fromHexString)(operator.config_signature),
|
|
57
|
-
enr_signature: (0, ssz_1.fromHexString)(operator.enr_signature),
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
val.creator = configOnly
|
|
61
|
-
? { address: (0, ssz_1.fromHexString)(cluster.creator.address) }
|
|
62
|
-
: {
|
|
63
|
-
address: (0, ssz_1.fromHexString)(cluster.creator.address),
|
|
64
|
-
config_signature: (0, ssz_1.fromHexString)(cluster.creator.config_signature),
|
|
65
|
-
};
|
|
66
|
-
val.validators = cluster.validators.map(validator => {
|
|
67
|
-
return {
|
|
68
|
-
fee_recipient_address: (0, ssz_1.fromHexString)(validator.fee_recipient_address),
|
|
69
|
-
withdrawal_address: (0, ssz_1.fromHexString)(validator.withdrawal_address),
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
if (cluster.deposit_amounts) {
|
|
73
|
-
val.deposit_amounts = cluster.deposit_amounts.map((amount) => {
|
|
74
|
-
return parseInt(amount);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (cluster.consensus_protocol) {
|
|
78
|
-
val.consensus_protocol = (0, utils_1.strToUint8Array)(cluster.consensus_protocol);
|
|
79
|
-
}
|
|
80
|
-
if (cluster.target_gas_limit) {
|
|
81
|
-
val.target_gas_limit = cluster.target_gas_limit;
|
|
82
|
-
}
|
|
83
|
-
if (cluster.compounding) {
|
|
84
|
-
val.compounding = cluster.compounding;
|
|
85
|
-
}
|
|
86
|
-
if (!configOnly) {
|
|
87
|
-
val.config_hash = (0, ssz_1.fromHexString)(cluster.config_hash);
|
|
88
|
-
}
|
|
89
|
-
return val;
|
|
90
|
-
};
|
|
91
|
-
exports.hashClusterDefinitionV1X10 = hashClusterDefinitionV1X10;
|
|
92
|
-
// cluster lock
|
|
93
|
-
const dvContainerTypeV1X10 = new ssz_1.ContainerType({
|
|
94
|
-
distributed_public_key: new ssz_1.ByteVectorType(48),
|
|
95
|
-
public_shares: new ssz_1.ListCompositeType(new ssz_1.ByteVectorType(48), 256),
|
|
96
|
-
partial_deposit_data: new ssz_1.ListCompositeType(sszTypes_1.depositDataContainer, 256),
|
|
97
|
-
builder_registration: sszTypes_1.builderRegistrationContainer,
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* @returns SSZ Containerized type of cluster lock
|
|
101
|
-
*/
|
|
102
|
-
const clusterLockContainerTypeV1X10 = () => {
|
|
103
|
-
return new ssz_1.ContainerType({
|
|
104
|
-
cluster_definition: (0, exports.clusterDefinitionContainerTypeV1X10)(false),
|
|
105
|
-
distributed_validators: new ssz_1.ListCompositeType(dvContainerTypeV1X10, 65536),
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* @param cluster The published cluster lock
|
|
110
|
-
* @returns The lock hash in of the corresponding cluster
|
|
111
|
-
*/
|
|
112
|
-
const hashClusterLockV1X10 = (cluster) => {
|
|
113
|
-
const lockType = clusterLockContainerTypeV1X10();
|
|
114
|
-
const val = lockType.defaultValue();
|
|
115
|
-
// Check if we can replace with definition_hash
|
|
116
|
-
val.cluster_definition = (0, exports.hashClusterDefinitionV1X10)(cluster.cluster_definition, false);
|
|
117
|
-
val.distributed_validators = cluster.distributed_validators.map(dValidator => {
|
|
118
|
-
var _a, _b, _c, _d, _e;
|
|
119
|
-
return {
|
|
120
|
-
distributed_public_key: (0, ssz_1.fromHexString)(dValidator.distributed_public_key),
|
|
121
|
-
public_shares: dValidator.public_shares.map(publicShare => (0, ssz_1.fromHexString)(publicShare)),
|
|
122
|
-
// should be fixed
|
|
123
|
-
partial_deposit_data: dValidator.partial_deposit_data.map(depositData => {
|
|
124
|
-
return {
|
|
125
|
-
pubkey: (0, ssz_1.fromHexString)(depositData.pubkey),
|
|
126
|
-
withdrawal_credentials: (0, ssz_1.fromHexString)(depositData.withdrawal_credentials),
|
|
127
|
-
amount: parseInt(depositData.amount),
|
|
128
|
-
signature: (0, ssz_1.fromHexString)(depositData.signature),
|
|
129
|
-
};
|
|
130
|
-
}),
|
|
131
|
-
builder_registration: {
|
|
132
|
-
message: {
|
|
133
|
-
fee_recipient: (0, ssz_1.fromHexString)((_a = dValidator.builder_registration) === null || _a === void 0 ? void 0 : _a.message.fee_recipient),
|
|
134
|
-
gas_limit: (_b = dValidator.builder_registration) === null || _b === void 0 ? void 0 : _b.message.gas_limit,
|
|
135
|
-
timestamp: (_c = dValidator.builder_registration) === null || _c === void 0 ? void 0 : _c.message.timestamp,
|
|
136
|
-
pubkey: (0, ssz_1.fromHexString)((_d = dValidator.builder_registration) === null || _d === void 0 ? void 0 : _d.message.pubkey),
|
|
137
|
-
},
|
|
138
|
-
signature: (0, ssz_1.fromHexString)((_e = dValidator.builder_registration) === null || _e === void 0 ? void 0 : _e.signature),
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
});
|
|
142
|
-
return '0x' + Buffer.from(lockType.hashTreeRoot(val).buffer).toString('hex');
|
|
143
|
-
};
|
|
144
|
-
exports.hashClusterLockV1X10 = hashClusterLockV1X10;
|
|
145
|
-
// DV verification
|
|
146
|
-
exports.verifyDVV1X10 = v1_8_0_1.verifyDVV1X8;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyDVV1X6 = exports.hashClusterLockV1X6 = exports.hashClusterDefinitionV1X6 = exports.clusterDefinitionContainerTypeV1X6 = void 0;
|
|
4
|
-
const uint_1 = require("@chainsafe/ssz/lib/type/uint");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const sszTypes_1 = require("./sszTypes");
|
|
7
|
-
const ssz_1 = require("@chainsafe/ssz");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
const bls_1 = require("@chainsafe/bls");
|
|
10
|
-
/**
|
|
11
|
-
* Returns the containerized cluster definition
|
|
12
|
-
* @param cluster ClusterDefinition to calculate the type from
|
|
13
|
-
* @returns SSZ Containerized type of cluster input
|
|
14
|
-
*/
|
|
15
|
-
const clusterDefinitionContainerTypeV1X6 = (configOnly) => {
|
|
16
|
-
let returnedContainerType = {
|
|
17
|
-
uuid: new ssz_1.ByteListType(64),
|
|
18
|
-
name: new ssz_1.ByteListType(256),
|
|
19
|
-
version: new ssz_1.ByteListType(16),
|
|
20
|
-
timestamp: new ssz_1.ByteListType(32),
|
|
21
|
-
num_validators: new uint_1.UintNumberType(8),
|
|
22
|
-
threshold: new uint_1.UintNumberType(8),
|
|
23
|
-
dkg_algorithm: new ssz_1.ByteListType(32),
|
|
24
|
-
fork_version: new ssz_1.ByteVectorType(4),
|
|
25
|
-
operators: new ssz_1.ListCompositeType((0, sszTypes_1.newOperatorContainerType)(configOnly), 256),
|
|
26
|
-
creator: (0, sszTypes_1.newCreatorContainerType)(configOnly),
|
|
27
|
-
validators: new ssz_1.ListCompositeType(sszTypes_1.validatorsContainerType, 65536),
|
|
28
|
-
};
|
|
29
|
-
if (!configOnly) {
|
|
30
|
-
returnedContainerType = Object.assign(Object.assign({}, returnedContainerType), { config_hash: new ssz_1.ByteVectorType(32) });
|
|
31
|
-
}
|
|
32
|
-
return new ssz_1.ContainerType(returnedContainerType);
|
|
33
|
-
};
|
|
34
|
-
exports.clusterDefinitionContainerTypeV1X6 = clusterDefinitionContainerTypeV1X6;
|
|
35
|
-
const hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
36
|
-
const definitionType = (0, exports.clusterDefinitionContainerTypeV1X6)(configOnly);
|
|
37
|
-
const val = definitionType.defaultValue();
|
|
38
|
-
// order should be same as charon https://github.com/ObolNetwork/charon/blob/main/cluster/ssz.go#L276
|
|
39
|
-
val.uuid = (0, utils_1.strToUint8Array)(cluster.uuid);
|
|
40
|
-
val.name = (0, utils_1.strToUint8Array)(cluster.name);
|
|
41
|
-
val.version = (0, utils_1.strToUint8Array)(cluster.version);
|
|
42
|
-
val.timestamp = (0, utils_1.strToUint8Array)(cluster.timestamp);
|
|
43
|
-
val.num_validators = cluster.num_validators;
|
|
44
|
-
val.threshold = cluster.threshold;
|
|
45
|
-
val.dkg_algorithm = (0, utils_1.strToUint8Array)(cluster.dkg_algorithm);
|
|
46
|
-
val.fork_version = (0, ssz_1.fromHexString)(cluster.fork_version);
|
|
47
|
-
val.operators = cluster.operators.map(operator => {
|
|
48
|
-
return configOnly
|
|
49
|
-
? { address: (0, ssz_1.fromHexString)(operator.address) }
|
|
50
|
-
: {
|
|
51
|
-
address: (0, ssz_1.fromHexString)(operator.address),
|
|
52
|
-
enr: (0, utils_1.strToUint8Array)(operator.enr),
|
|
53
|
-
config_signature: (0, ssz_1.fromHexString)(operator.config_signature),
|
|
54
|
-
enr_signature: (0, ssz_1.fromHexString)(operator.enr_signature),
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
val.creator = configOnly
|
|
58
|
-
? { address: (0, ssz_1.fromHexString)(cluster.creator.address) }
|
|
59
|
-
: {
|
|
60
|
-
address: (0, ssz_1.fromHexString)(cluster.creator.address),
|
|
61
|
-
config_signature: (0, ssz_1.fromHexString)(cluster.creator.config_signature),
|
|
62
|
-
};
|
|
63
|
-
val.validators = cluster.validators.map(validator => {
|
|
64
|
-
return {
|
|
65
|
-
fee_recipient_address: (0, ssz_1.fromHexString)(validator.fee_recipient_address),
|
|
66
|
-
withdrawal_address: (0, ssz_1.fromHexString)(validator.withdrawal_address),
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
if (!configOnly) {
|
|
70
|
-
val.config_hash = (0, ssz_1.fromHexString)(cluster.config_hash);
|
|
71
|
-
}
|
|
72
|
-
return val;
|
|
73
|
-
};
|
|
74
|
-
exports.hashClusterDefinitionV1X6 = hashClusterDefinitionV1X6;
|
|
75
|
-
// cluster lock
|
|
76
|
-
const dvContainerTypeV1X6 = new ssz_1.ContainerType({
|
|
77
|
-
distributed_public_key: new ssz_1.ByteVectorType(48),
|
|
78
|
-
public_shares: new ssz_1.ListCompositeType(new ssz_1.ByteVectorType(48), 256),
|
|
79
|
-
pubkey: new ssz_1.ByteVectorType(48),
|
|
80
|
-
withdrawal_credentials: new ssz_1.ByteVectorType(32),
|
|
81
|
-
amount: new uint_1.UintNumberType(8),
|
|
82
|
-
signature: new ssz_1.ByteVectorType(96),
|
|
83
|
-
});
|
|
84
|
-
/**
|
|
85
|
-
* @returns SSZ Containerized type of cluster lock
|
|
86
|
-
*/
|
|
87
|
-
const clusterLockContainerTypeV1X6 = () => {
|
|
88
|
-
return new ssz_1.ContainerType({
|
|
89
|
-
cluster_definition: (0, exports.clusterDefinitionContainerTypeV1X6)(false),
|
|
90
|
-
distributed_validators: new ssz_1.ListCompositeType(dvContainerTypeV1X6, 65536),
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* @param cluster The published cluster lock
|
|
95
|
-
* @returns The lock hash in of the corresponding cluster
|
|
96
|
-
*/
|
|
97
|
-
const hashClusterLockV1X6 = (cluster) => {
|
|
98
|
-
const lockType = clusterLockContainerTypeV1X6();
|
|
99
|
-
const val = lockType.defaultValue();
|
|
100
|
-
// Check if we can replace with definition_hash
|
|
101
|
-
val.cluster_definition = (0, exports.hashClusterDefinitionV1X6)(cluster.cluster_definition, false);
|
|
102
|
-
val.distributed_validators = cluster.distributed_validators.map(dValidator => {
|
|
103
|
-
var _a, _b, _c, _d;
|
|
104
|
-
return {
|
|
105
|
-
distributed_public_key: (0, ssz_1.fromHexString)(dValidator.distributed_public_key),
|
|
106
|
-
public_shares: dValidator.public_shares.map(publicShare => (0, ssz_1.fromHexString)(publicShare)),
|
|
107
|
-
pubkey: (0, ssz_1.fromHexString)((_a = dValidator.deposit_data) === null || _a === void 0 ? void 0 : _a.pubkey),
|
|
108
|
-
withdrawal_credentials: (0, ssz_1.fromHexString)((_b = dValidator.deposit_data) === null || _b === void 0 ? void 0 : _b.withdrawal_credentials),
|
|
109
|
-
amount: parseInt((_c = dValidator.deposit_data) === null || _c === void 0 ? void 0 : _c.amount),
|
|
110
|
-
signature: (0, ssz_1.fromHexString)((_d = dValidator.deposit_data) === null || _d === void 0 ? void 0 : _d.signature),
|
|
111
|
-
};
|
|
112
|
-
});
|
|
113
|
-
return '0x' + Buffer.from(lockType.hashTreeRoot(val).buffer).toString('hex');
|
|
114
|
-
};
|
|
115
|
-
exports.hashClusterLockV1X6 = hashClusterLockV1X6;
|
|
116
|
-
// DV verification
|
|
117
|
-
const verifyDVV1X6 = (clusterLock) => {
|
|
118
|
-
var _a;
|
|
119
|
-
const validators = clusterLock.distributed_validators;
|
|
120
|
-
const pubShares = [];
|
|
121
|
-
const pubKeys = [];
|
|
122
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
123
|
-
const blsSignatures = [];
|
|
124
|
-
for (let i = 0; i < validators.length; i++) {
|
|
125
|
-
const validator = validators[i];
|
|
126
|
-
const validatorPublicShares = validator.public_shares;
|
|
127
|
-
const distributedPublicKey = validator.distributed_public_key;
|
|
128
|
-
// Needed in signature_aggregate verification
|
|
129
|
-
for (const element of validatorPublicShares) {
|
|
130
|
-
pubShares.push((0, ssz_1.fromHexString)(element));
|
|
131
|
-
}
|
|
132
|
-
const { isValidDepositData, depositDataMsg } = (0, common_1.verifyDepositData)(distributedPublicKey, validator.deposit_data, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version);
|
|
133
|
-
if (!isValidDepositData) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
pubKeys.push((0, ssz_1.fromHexString)(validator.distributed_public_key));
|
|
137
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
138
|
-
blsSignatures.push((0, ssz_1.fromHexString)((_a = validator.deposit_data) === null || _a === void 0 ? void 0 : _a.signature));
|
|
139
|
-
}
|
|
140
|
-
const aggregateBLSSignature = (0, bls_1.aggregateSignatures)(blsSignatures);
|
|
141
|
-
if (!(0, bls_1.verifyMultiple)(pubKeys, builderRegistrationAndDepositDataMessages, aggregateBLSSignature)) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
if (!(0, bls_1.verifyAggregate)(pubShares, (0, ssz_1.fromHexString)(clusterLock.lock_hash), (0, ssz_1.fromHexString)(clusterLock.signature_aggregate))) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
};
|
|
149
|
-
exports.verifyDVV1X6 = verifyDVV1X6;
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyDVV1X7 = exports.hashClusterLockV1X7 = exports.hashClusterDefinitionV1X7 = exports.clusterDefinitionContainerTypeV1X7 = void 0;
|
|
4
|
-
const uint_1 = require("@chainsafe/ssz/lib/type/uint");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const sszTypes_1 = require("./sszTypes");
|
|
7
|
-
const ssz_1 = require("@chainsafe/ssz");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
const bls_1 = require("@chainsafe/bls");
|
|
10
|
-
/**
|
|
11
|
-
* Returns the containerized cluster definition
|
|
12
|
-
* @param cluster ClusterDefinition to calculate the type from
|
|
13
|
-
* @returns SSZ Containerized type of cluster input
|
|
14
|
-
*/
|
|
15
|
-
const clusterDefinitionContainerTypeV1X7 = (configOnly) => {
|
|
16
|
-
let returnedContainerType = {
|
|
17
|
-
uuid: new ssz_1.ByteListType(64),
|
|
18
|
-
name: new ssz_1.ByteListType(256),
|
|
19
|
-
version: new ssz_1.ByteListType(16),
|
|
20
|
-
timestamp: new ssz_1.ByteListType(32),
|
|
21
|
-
num_validators: new uint_1.UintNumberType(8),
|
|
22
|
-
threshold: new uint_1.UintNumberType(8),
|
|
23
|
-
dkg_algorithm: new ssz_1.ByteListType(32),
|
|
24
|
-
fork_version: new ssz_1.ByteVectorType(4),
|
|
25
|
-
operators: new ssz_1.ListCompositeType((0, sszTypes_1.newOperatorContainerType)(configOnly), 256),
|
|
26
|
-
creator: (0, sszTypes_1.newCreatorContainerType)(configOnly),
|
|
27
|
-
validators: new ssz_1.ListCompositeType(sszTypes_1.validatorsContainerType, 65536),
|
|
28
|
-
};
|
|
29
|
-
if (!configOnly) {
|
|
30
|
-
returnedContainerType = Object.assign(Object.assign({}, returnedContainerType), { config_hash: new ssz_1.ByteVectorType(32) });
|
|
31
|
-
}
|
|
32
|
-
return new ssz_1.ContainerType(returnedContainerType);
|
|
33
|
-
};
|
|
34
|
-
exports.clusterDefinitionContainerTypeV1X7 = clusterDefinitionContainerTypeV1X7;
|
|
35
|
-
const hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
36
|
-
const definitionType = (0, exports.clusterDefinitionContainerTypeV1X7)(configOnly);
|
|
37
|
-
const val = definitionType.defaultValue();
|
|
38
|
-
// order should be same as charon https://github.com/ObolNetwork/charon/blob/main/cluster/ssz.go#L276
|
|
39
|
-
val.uuid = (0, utils_1.strToUint8Array)(cluster.uuid);
|
|
40
|
-
val.name = (0, utils_1.strToUint8Array)(cluster.name);
|
|
41
|
-
val.version = (0, utils_1.strToUint8Array)(cluster.version);
|
|
42
|
-
val.timestamp = (0, utils_1.strToUint8Array)(cluster.timestamp);
|
|
43
|
-
val.num_validators = cluster.num_validators;
|
|
44
|
-
val.threshold = cluster.threshold;
|
|
45
|
-
val.dkg_algorithm = (0, utils_1.strToUint8Array)(cluster.dkg_algorithm);
|
|
46
|
-
val.fork_version = (0, ssz_1.fromHexString)(cluster.fork_version);
|
|
47
|
-
val.operators = cluster.operators.map(operator => {
|
|
48
|
-
return configOnly
|
|
49
|
-
? { address: (0, ssz_1.fromHexString)(operator.address) }
|
|
50
|
-
: {
|
|
51
|
-
address: (0, ssz_1.fromHexString)(operator.address),
|
|
52
|
-
enr: (0, utils_1.strToUint8Array)(operator.enr),
|
|
53
|
-
config_signature: (0, ssz_1.fromHexString)(operator.config_signature),
|
|
54
|
-
enr_signature: (0, ssz_1.fromHexString)(operator.enr_signature),
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
val.creator = configOnly
|
|
58
|
-
? { address: (0, ssz_1.fromHexString)(cluster.creator.address) }
|
|
59
|
-
: {
|
|
60
|
-
address: (0, ssz_1.fromHexString)(cluster.creator.address),
|
|
61
|
-
config_signature: (0, ssz_1.fromHexString)(cluster.creator.config_signature),
|
|
62
|
-
};
|
|
63
|
-
val.validators = cluster.validators.map(validator => {
|
|
64
|
-
return {
|
|
65
|
-
fee_recipient_address: (0, ssz_1.fromHexString)(validator.fee_recipient_address),
|
|
66
|
-
withdrawal_address: (0, ssz_1.fromHexString)(validator.withdrawal_address),
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
if (!configOnly) {
|
|
70
|
-
val.config_hash = (0, ssz_1.fromHexString)(cluster.config_hash);
|
|
71
|
-
}
|
|
72
|
-
return val;
|
|
73
|
-
};
|
|
74
|
-
exports.hashClusterDefinitionV1X7 = hashClusterDefinitionV1X7;
|
|
75
|
-
// cluster lock
|
|
76
|
-
const dvContainerTypeV1X7 = new ssz_1.ContainerType({
|
|
77
|
-
distributed_public_key: new ssz_1.ByteVectorType(48),
|
|
78
|
-
public_shares: new ssz_1.ListCompositeType(new ssz_1.ByteVectorType(48), 256),
|
|
79
|
-
deposit_data: sszTypes_1.depositDataContainer,
|
|
80
|
-
builder_registration: sszTypes_1.builderRegistrationContainer,
|
|
81
|
-
});
|
|
82
|
-
/**
|
|
83
|
-
* @returns SSZ Containerized type of cluster lock
|
|
84
|
-
*/
|
|
85
|
-
const clusterLockContainerTypeV1X7 = () => {
|
|
86
|
-
return new ssz_1.ContainerType({
|
|
87
|
-
cluster_definition: (0, exports.clusterDefinitionContainerTypeV1X7)(false),
|
|
88
|
-
distributed_validators: new ssz_1.ListCompositeType(dvContainerTypeV1X7, 65536),
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* @param cluster The published cluster lock
|
|
93
|
-
* @returns The lock hash in of the corresponding cluster
|
|
94
|
-
*/
|
|
95
|
-
const hashClusterLockV1X7 = (cluster) => {
|
|
96
|
-
const lockType = clusterLockContainerTypeV1X7();
|
|
97
|
-
const val = lockType.defaultValue();
|
|
98
|
-
// Check if we can replace with definition_hash
|
|
99
|
-
val.cluster_definition = (0, exports.hashClusterDefinitionV1X7)(cluster.cluster_definition, false);
|
|
100
|
-
val.distributed_validators = cluster.distributed_validators.map(dValidator => {
|
|
101
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
102
|
-
return {
|
|
103
|
-
distributed_public_key: (0, ssz_1.fromHexString)(dValidator.distributed_public_key),
|
|
104
|
-
public_shares: dValidator.public_shares.map(publicShare => (0, ssz_1.fromHexString)(publicShare)),
|
|
105
|
-
deposit_data: {
|
|
106
|
-
pubkey: (0, ssz_1.fromHexString)((_a = dValidator.deposit_data) === null || _a === void 0 ? void 0 : _a.pubkey),
|
|
107
|
-
withdrawal_credentials: (0, ssz_1.fromHexString)((_b = dValidator.deposit_data) === null || _b === void 0 ? void 0 : _b.withdrawal_credentials),
|
|
108
|
-
amount: parseInt((_c = dValidator.deposit_data) === null || _c === void 0 ? void 0 : _c.amount),
|
|
109
|
-
signature: (0, ssz_1.fromHexString)((_d = dValidator.deposit_data) === null || _d === void 0 ? void 0 : _d.signature),
|
|
110
|
-
},
|
|
111
|
-
builder_registration: {
|
|
112
|
-
message: {
|
|
113
|
-
fee_recipient: (0, ssz_1.fromHexString)((_e = dValidator.builder_registration) === null || _e === void 0 ? void 0 : _e.message.fee_recipient),
|
|
114
|
-
gas_limit: (_f = dValidator.builder_registration) === null || _f === void 0 ? void 0 : _f.message.gas_limit,
|
|
115
|
-
timestamp: (_g = dValidator.builder_registration) === null || _g === void 0 ? void 0 : _g.message.timestamp,
|
|
116
|
-
pubkey: (0, ssz_1.fromHexString)((_h = dValidator.builder_registration) === null || _h === void 0 ? void 0 : _h.message.pubkey),
|
|
117
|
-
},
|
|
118
|
-
signature: (0, ssz_1.fromHexString)((_j = dValidator.builder_registration) === null || _j === void 0 ? void 0 : _j.signature),
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
return '0x' + Buffer.from(lockType.hashTreeRoot(val).buffer).toString('hex');
|
|
123
|
-
};
|
|
124
|
-
exports.hashClusterLockV1X7 = hashClusterLockV1X7;
|
|
125
|
-
// DV verification
|
|
126
|
-
const verifyDVV1X7 = (clusterLock) => {
|
|
127
|
-
var _a, _b;
|
|
128
|
-
const validators = clusterLock.distributed_validators;
|
|
129
|
-
const pubShares = [];
|
|
130
|
-
const pubKeys = [];
|
|
131
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
132
|
-
const blsSignatures = [];
|
|
133
|
-
for (let i = 0; i < validators.length; i++) {
|
|
134
|
-
const validator = validators[i];
|
|
135
|
-
const validatorPublicShares = validator.public_shares;
|
|
136
|
-
const distributedPublicKey = validator.distributed_public_key;
|
|
137
|
-
// Needed in signature_aggregate verification
|
|
138
|
-
for (const element of validatorPublicShares) {
|
|
139
|
-
pubShares.push((0, ssz_1.fromHexString)(element));
|
|
140
|
-
}
|
|
141
|
-
// Deposit Data Verification
|
|
142
|
-
const { isValidDepositData, depositDataMsg } = (0, common_1.verifyDepositData)(distributedPublicKey, validator.deposit_data, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version);
|
|
143
|
-
if (!isValidDepositData) {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
pubKeys.push((0, ssz_1.fromHexString)(distributedPublicKey));
|
|
147
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
148
|
-
blsSignatures.push((0, ssz_1.fromHexString)((_a = validator.deposit_data) === null || _a === void 0 ? void 0 : _a.signature));
|
|
149
|
-
// Builder Registration Verification
|
|
150
|
-
const { isValidBuilderRegistration, builderRegistrationMsg } = (0, common_1.verifyBuilderRegistration)(validator, clusterLock.cluster_definition.validators[i].fee_recipient_address, clusterLock.cluster_definition.fork_version);
|
|
151
|
-
if (!isValidBuilderRegistration) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
pubKeys.push((0, ssz_1.fromHexString)(distributedPublicKey));
|
|
155
|
-
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
156
|
-
blsSignatures.push((0, ssz_1.fromHexString)((_b = validator.builder_registration) === null || _b === void 0 ? void 0 : _b.signature));
|
|
157
|
-
}
|
|
158
|
-
// BLS signatures verification
|
|
159
|
-
const aggregateBLSSignature = (0, bls_1.aggregateSignatures)(blsSignatures);
|
|
160
|
-
if (!(0, bls_1.verifyMultiple)(pubKeys, builderRegistrationAndDepositDataMessages, aggregateBLSSignature)) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
// Node Signatures verification
|
|
164
|
-
if (!(0, common_1.verifyNodeSignatures)(clusterLock)) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
// signature_aggregate verification
|
|
168
|
-
if (!(0, bls_1.verifyAggregate)(pubShares, (0, ssz_1.fromHexString)(clusterLock.lock_hash), (0, ssz_1.fromHexString)(clusterLock.signature_aggregate))) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
return true;
|
|
172
|
-
};
|
|
173
|
-
exports.verifyDVV1X7 = verifyDVV1X7;
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyDVV1X8 = exports.hashClusterLockV1X8 = exports.hashClusterDefinitionV1X8 = exports.clusterDefinitionContainerTypeV1X8 = void 0;
|
|
4
|
-
const uint_1 = require("@chainsafe/ssz/lib/type/uint");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const sszTypes_1 = require("./sszTypes");
|
|
7
|
-
const ssz_1 = require("@chainsafe/ssz");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
const bls_1 = require("@chainsafe/bls");
|
|
10
|
-
/**
|
|
11
|
-
* Returns the containerized cluster definition
|
|
12
|
-
* @param cluster ClusterDefinition to calculate the type from
|
|
13
|
-
* @returns SSZ Containerized type of cluster input
|
|
14
|
-
*/
|
|
15
|
-
const clusterDefinitionContainerTypeV1X8 = (configOnly) => {
|
|
16
|
-
let returnedContainerType = {
|
|
17
|
-
uuid: new ssz_1.ByteListType(64),
|
|
18
|
-
name: new ssz_1.ByteListType(256),
|
|
19
|
-
version: new ssz_1.ByteListType(16),
|
|
20
|
-
timestamp: new ssz_1.ByteListType(32),
|
|
21
|
-
num_validators: new uint_1.UintNumberType(8),
|
|
22
|
-
threshold: new uint_1.UintNumberType(8),
|
|
23
|
-
dkg_algorithm: new ssz_1.ByteListType(32),
|
|
24
|
-
fork_version: new ssz_1.ByteVectorType(4),
|
|
25
|
-
operators: new ssz_1.ListCompositeType((0, sszTypes_1.newOperatorContainerType)(configOnly), 256),
|
|
26
|
-
creator: (0, sszTypes_1.newCreatorContainerType)(configOnly),
|
|
27
|
-
validators: new ssz_1.ListCompositeType(sszTypes_1.validatorsContainerType, 65536),
|
|
28
|
-
deposit_amounts: new ssz_1.ListBasicType(new uint_1.UintNumberType(8), 256),
|
|
29
|
-
};
|
|
30
|
-
if (!configOnly) {
|
|
31
|
-
returnedContainerType = Object.assign(Object.assign({}, returnedContainerType), { config_hash: new ssz_1.ByteVectorType(32) });
|
|
32
|
-
}
|
|
33
|
-
return new ssz_1.ContainerType(returnedContainerType);
|
|
34
|
-
};
|
|
35
|
-
exports.clusterDefinitionContainerTypeV1X8 = clusterDefinitionContainerTypeV1X8;
|
|
36
|
-
const hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
37
|
-
const definitionType = (0, exports.clusterDefinitionContainerTypeV1X8)(configOnly);
|
|
38
|
-
const val = definitionType.defaultValue();
|
|
39
|
-
// order should be same as charon https://github.com/ObolNetwork/charon/blob/main/cluster/ssz.go#L276
|
|
40
|
-
val.uuid = (0, utils_1.strToUint8Array)(cluster.uuid);
|
|
41
|
-
val.name = (0, utils_1.strToUint8Array)(cluster.name);
|
|
42
|
-
val.version = (0, utils_1.strToUint8Array)(cluster.version);
|
|
43
|
-
val.timestamp = (0, utils_1.strToUint8Array)(cluster.timestamp);
|
|
44
|
-
val.num_validators = cluster.num_validators;
|
|
45
|
-
val.threshold = cluster.threshold;
|
|
46
|
-
val.dkg_algorithm = (0, utils_1.strToUint8Array)(cluster.dkg_algorithm);
|
|
47
|
-
val.fork_version = (0, ssz_1.fromHexString)(cluster.fork_version);
|
|
48
|
-
val.operators = cluster.operators.map(operator => {
|
|
49
|
-
return configOnly
|
|
50
|
-
? { address: (0, ssz_1.fromHexString)(operator.address) }
|
|
51
|
-
: {
|
|
52
|
-
address: (0, ssz_1.fromHexString)(operator.address),
|
|
53
|
-
enr: (0, utils_1.strToUint8Array)(operator.enr),
|
|
54
|
-
config_signature: (0, ssz_1.fromHexString)(operator.config_signature),
|
|
55
|
-
enr_signature: (0, ssz_1.fromHexString)(operator.enr_signature),
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
val.creator = configOnly
|
|
59
|
-
? { address: (0, ssz_1.fromHexString)(cluster.creator.address) }
|
|
60
|
-
: {
|
|
61
|
-
address: (0, ssz_1.fromHexString)(cluster.creator.address),
|
|
62
|
-
config_signature: (0, ssz_1.fromHexString)(cluster.creator.config_signature),
|
|
63
|
-
};
|
|
64
|
-
val.validators = cluster.validators.map(validator => {
|
|
65
|
-
return {
|
|
66
|
-
fee_recipient_address: (0, ssz_1.fromHexString)(validator.fee_recipient_address),
|
|
67
|
-
withdrawal_address: (0, ssz_1.fromHexString)(validator.withdrawal_address),
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
if (cluster.deposit_amounts) {
|
|
71
|
-
val.deposit_amounts = cluster.deposit_amounts.map((amount) => {
|
|
72
|
-
return parseInt(amount);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (!configOnly) {
|
|
76
|
-
val.config_hash = (0, ssz_1.fromHexString)(cluster.config_hash);
|
|
77
|
-
}
|
|
78
|
-
return val;
|
|
79
|
-
};
|
|
80
|
-
exports.hashClusterDefinitionV1X8 = hashClusterDefinitionV1X8;
|
|
81
|
-
// cluster lock
|
|
82
|
-
const dvContainerTypeV1X8 = new ssz_1.ContainerType({
|
|
83
|
-
distributed_public_key: new ssz_1.ByteVectorType(48),
|
|
84
|
-
public_shares: new ssz_1.ListCompositeType(new ssz_1.ByteVectorType(48), 256),
|
|
85
|
-
partial_deposit_data: new ssz_1.ListCompositeType(sszTypes_1.depositDataContainer, 256),
|
|
86
|
-
builder_registration: sszTypes_1.builderRegistrationContainer,
|
|
87
|
-
});
|
|
88
|
-
/**
|
|
89
|
-
* @returns SSZ Containerized type of cluster lock
|
|
90
|
-
*/
|
|
91
|
-
const clusterLockContainerTypeV1X8 = () => {
|
|
92
|
-
return new ssz_1.ContainerType({
|
|
93
|
-
cluster_definition: (0, exports.clusterDefinitionContainerTypeV1X8)(false),
|
|
94
|
-
distributed_validators: new ssz_1.ListCompositeType(dvContainerTypeV1X8, 65536),
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* @param cluster The published cluster lock
|
|
99
|
-
* @returns The lock hash in of the corresponding cluster
|
|
100
|
-
*/
|
|
101
|
-
const hashClusterLockV1X8 = (cluster) => {
|
|
102
|
-
const lockType = clusterLockContainerTypeV1X8();
|
|
103
|
-
const val = lockType.defaultValue();
|
|
104
|
-
// Check if we can replace with definition_hash
|
|
105
|
-
val.cluster_definition = (0, exports.hashClusterDefinitionV1X8)(cluster.cluster_definition, false);
|
|
106
|
-
val.distributed_validators = cluster.distributed_validators.map(dValidator => {
|
|
107
|
-
var _a, _b, _c, _d, _e;
|
|
108
|
-
return {
|
|
109
|
-
distributed_public_key: (0, ssz_1.fromHexString)(dValidator.distributed_public_key),
|
|
110
|
-
public_shares: dValidator.public_shares.map(publicShare => (0, ssz_1.fromHexString)(publicShare)),
|
|
111
|
-
// should be fixed
|
|
112
|
-
partial_deposit_data: dValidator.partial_deposit_data.map(depositData => {
|
|
113
|
-
return {
|
|
114
|
-
pubkey: (0, ssz_1.fromHexString)(depositData.pubkey),
|
|
115
|
-
withdrawal_credentials: (0, ssz_1.fromHexString)(depositData.withdrawal_credentials),
|
|
116
|
-
amount: parseInt(depositData.amount),
|
|
117
|
-
signature: (0, ssz_1.fromHexString)(depositData.signature),
|
|
118
|
-
};
|
|
119
|
-
}),
|
|
120
|
-
builder_registration: {
|
|
121
|
-
message: {
|
|
122
|
-
fee_recipient: (0, ssz_1.fromHexString)((_a = dValidator.builder_registration) === null || _a === void 0 ? void 0 : _a.message.fee_recipient),
|
|
123
|
-
gas_limit: (_b = dValidator.builder_registration) === null || _b === void 0 ? void 0 : _b.message.gas_limit,
|
|
124
|
-
timestamp: (_c = dValidator.builder_registration) === null || _c === void 0 ? void 0 : _c.message.timestamp,
|
|
125
|
-
pubkey: (0, ssz_1.fromHexString)((_d = dValidator.builder_registration) === null || _d === void 0 ? void 0 : _d.message.pubkey),
|
|
126
|
-
},
|
|
127
|
-
signature: (0, ssz_1.fromHexString)((_e = dValidator.builder_registration) === null || _e === void 0 ? void 0 : _e.signature),
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
return '0x' + Buffer.from(lockType.hashTreeRoot(val).buffer).toString('hex');
|
|
132
|
-
};
|
|
133
|
-
exports.hashClusterLockV1X8 = hashClusterLockV1X8;
|
|
134
|
-
// DV verification
|
|
135
|
-
const verifyDVV1X8 = (clusterLock) => {
|
|
136
|
-
var _a;
|
|
137
|
-
const validators = clusterLock.distributed_validators;
|
|
138
|
-
const pubShares = [];
|
|
139
|
-
const pubKeys = [];
|
|
140
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
141
|
-
const blsSignatures = [];
|
|
142
|
-
for (let i = 0; i < validators.length; i++) {
|
|
143
|
-
const validator = validators[i];
|
|
144
|
-
const validatorPublicShares = validator.public_shares;
|
|
145
|
-
const distributedPublicKey = validator.distributed_public_key;
|
|
146
|
-
// Needed in signature_aggregate verification
|
|
147
|
-
for (const element of validatorPublicShares) {
|
|
148
|
-
pubShares.push((0, ssz_1.fromHexString)(element));
|
|
149
|
-
}
|
|
150
|
-
// Check deposit amounts match exactly if they are defined
|
|
151
|
-
const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
|
|
152
|
-
if (!!depositAmounts && depositAmounts !== null) {
|
|
153
|
-
const partialDepositAmounts = validator.partial_deposit_data.map(d => d.amount);
|
|
154
|
-
// Check that partialDepositAmounts includes all unique elements of depositAmounts
|
|
155
|
-
const uniqueDepositAmounts = [...new Set(depositAmounts.map(Number))];
|
|
156
|
-
const partialAmountsSet = new Set(partialDepositAmounts.map(Number));
|
|
157
|
-
if (!uniqueDepositAmounts.every(amount => partialAmountsSet.has(amount))) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// Deposit Data Verification
|
|
162
|
-
for (const element of validator.partial_deposit_data) {
|
|
163
|
-
const depositData = element;
|
|
164
|
-
const { isValidDepositData, depositDataMsg } = (0, common_1.verifyDepositData)(distributedPublicKey, depositData, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version, clusterLock.cluster_definition.compounding);
|
|
165
|
-
if (!isValidDepositData) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
pubKeys.push((0, ssz_1.fromHexString)(distributedPublicKey));
|
|
169
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
170
|
-
blsSignatures.push((0, ssz_1.fromHexString)(depositData === null || depositData === void 0 ? void 0 : depositData.signature));
|
|
171
|
-
}
|
|
172
|
-
// Builder Registration Verification
|
|
173
|
-
const { isValidBuilderRegistration, builderRegistrationMsg } = (0, common_1.verifyBuilderRegistration)(validator, clusterLock.cluster_definition.validators[i].fee_recipient_address, clusterLock.cluster_definition.fork_version);
|
|
174
|
-
if (!isValidBuilderRegistration) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
pubKeys.push((0, ssz_1.fromHexString)(distributedPublicKey));
|
|
178
|
-
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
179
|
-
blsSignatures.push((0, ssz_1.fromHexString)((_a = validator.builder_registration) === null || _a === void 0 ? void 0 : _a.signature));
|
|
180
|
-
}
|
|
181
|
-
// BLS signatures verification
|
|
182
|
-
const aggregateBLSSignature = (0, bls_1.aggregateSignatures)(blsSignatures);
|
|
183
|
-
if (!(0, bls_1.verifyMultiple)(pubKeys, builderRegistrationAndDepositDataMessages, aggregateBLSSignature)) {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
// Node Signatures verification
|
|
187
|
-
if (!(0, common_1.verifyNodeSignatures)(clusterLock)) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
// signature_aggregate verification
|
|
191
|
-
if (!(0, bls_1.verifyAggregate)(pubShares, (0, ssz_1.fromHexString)(clusterLock.lock_hash), (0, ssz_1.fromHexString)(clusterLock.signature_aggregate))) {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
return true;
|
|
195
|
-
};
|
|
196
|
-
exports.verifyDVV1X8 = verifyDVV1X8;
|