@obolnetwork/obol-sdk 2.2.2 → 2.2.4

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.
@@ -0,0 +1,140 @@
1
+ import { UintNumberType, } from '@chainsafe/ssz/lib/type/uint';
2
+ import { strToUint8Array } from '../utils';
3
+ import { builderRegistrationContainer, depositDataContainer, newCreatorContainerType, newOperatorContainerType, validatorsContainerType, } from './sszTypes';
4
+ import { ByteListType, ByteVectorType, ContainerType, ListBasicType, ListCompositeType, fromHexString, BooleanType, } from '@chainsafe/ssz';
5
+ import { verifyDVV1X8 } from './v1.8.0';
6
+ /**
7
+ * Returns the containerized cluster definition
8
+ * @param cluster ClusterDefinition to calculate the type from
9
+ * @returns SSZ Containerized type of cluster input
10
+ */
11
+ export const clusterDefinitionContainerTypeV1X10 = (configOnly) => {
12
+ let returnedContainerType = {
13
+ uuid: new ByteListType(64),
14
+ name: new ByteListType(256),
15
+ version: new ByteListType(16),
16
+ timestamp: new ByteListType(32),
17
+ num_validators: new UintNumberType(8),
18
+ threshold: new UintNumberType(8),
19
+ dkg_algorithm: new ByteListType(32),
20
+ fork_version: new ByteVectorType(4),
21
+ operators: new ListCompositeType(newOperatorContainerType(configOnly), 256),
22
+ creator: newCreatorContainerType(configOnly),
23
+ validators: new ListCompositeType(validatorsContainerType, 65536),
24
+ deposit_amounts: new ListBasicType(new UintNumberType(8), 256),
25
+ consensus_protocol: new ByteListType(256),
26
+ target_gas_limit: new UintNumberType(8),
27
+ compounding: new BooleanType(),
28
+ };
29
+ if (!configOnly) {
30
+ returnedContainerType = Object.assign(Object.assign({}, returnedContainerType), { config_hash: new ByteVectorType(32) });
31
+ }
32
+ return new ContainerType(returnedContainerType);
33
+ };
34
+ export const hashClusterDefinitionV1X10 = (cluster, configOnly) => {
35
+ const definitionType = clusterDefinitionContainerTypeV1X10(configOnly);
36
+ const val = definitionType.defaultValue();
37
+ // order should be same as charon https://github.com/ObolNetwork/charon/blob/main/cluster/ssz.go#L276
38
+ val.uuid = strToUint8Array(cluster.uuid);
39
+ val.name = strToUint8Array(cluster.name);
40
+ val.version = strToUint8Array(cluster.version);
41
+ val.timestamp = strToUint8Array(cluster.timestamp);
42
+ val.num_validators = cluster.num_validators;
43
+ val.threshold = cluster.threshold;
44
+ val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
45
+ val.fork_version = fromHexString(cluster.fork_version);
46
+ val.operators = cluster.operators.map(operator => {
47
+ return configOnly
48
+ ? { address: fromHexString(operator.address) }
49
+ : {
50
+ address: fromHexString(operator.address),
51
+ enr: strToUint8Array(operator.enr),
52
+ config_signature: fromHexString(operator.config_signature),
53
+ enr_signature: fromHexString(operator.enr_signature),
54
+ };
55
+ });
56
+ val.creator = configOnly
57
+ ? { address: fromHexString(cluster.creator.address) }
58
+ : {
59
+ address: fromHexString(cluster.creator.address),
60
+ config_signature: fromHexString(cluster.creator.config_signature),
61
+ };
62
+ val.validators = cluster.validators.map(validator => {
63
+ return {
64
+ fee_recipient_address: fromHexString(validator.fee_recipient_address),
65
+ withdrawal_address: fromHexString(validator.withdrawal_address),
66
+ };
67
+ });
68
+ if (cluster.deposit_amounts) {
69
+ val.deposit_amounts = cluster.deposit_amounts.map((amount) => {
70
+ return parseInt(amount);
71
+ });
72
+ }
73
+ if (cluster.consensus_protocol) {
74
+ val.consensus_protocol = strToUint8Array(cluster.consensus_protocol);
75
+ }
76
+ if (cluster.target_gas_limit) {
77
+ val.target_gas_limit = cluster.target_gas_limit;
78
+ }
79
+ if (cluster.compounding) {
80
+ val.compounding = cluster.compounding;
81
+ }
82
+ if (!configOnly) {
83
+ val.config_hash = fromHexString(cluster.config_hash);
84
+ }
85
+ return val;
86
+ };
87
+ // cluster lock
88
+ const dvContainerTypeV1X10 = new ContainerType({
89
+ distributed_public_key: new ByteVectorType(48),
90
+ public_shares: new ListCompositeType(new ByteVectorType(48), 256),
91
+ partial_deposit_data: new ListCompositeType(depositDataContainer, 256),
92
+ builder_registration: builderRegistrationContainer,
93
+ });
94
+ /**
95
+ * @returns SSZ Containerized type of cluster lock
96
+ */
97
+ const clusterLockContainerTypeV1X10 = () => {
98
+ return new ContainerType({
99
+ cluster_definition: clusterDefinitionContainerTypeV1X10(false),
100
+ distributed_validators: new ListCompositeType(dvContainerTypeV1X10, 65536),
101
+ });
102
+ };
103
+ /**
104
+ * @param cluster The published cluster lock
105
+ * @returns The lock hash in of the corresponding cluster
106
+ */
107
+ export const hashClusterLockV1X10 = (cluster) => {
108
+ const lockType = clusterLockContainerTypeV1X10();
109
+ const val = lockType.defaultValue();
110
+ // Check if we can replace with definition_hash
111
+ val.cluster_definition = hashClusterDefinitionV1X10(cluster.cluster_definition, false);
112
+ val.distributed_validators = cluster.distributed_validators.map(dValidator => {
113
+ var _a, _b, _c, _d, _e;
114
+ return {
115
+ distributed_public_key: fromHexString(dValidator.distributed_public_key),
116
+ public_shares: dValidator.public_shares.map(publicShare => fromHexString(publicShare)),
117
+ // should be fixed
118
+ partial_deposit_data: dValidator.partial_deposit_data.map(depositData => {
119
+ return {
120
+ pubkey: fromHexString(depositData.pubkey),
121
+ withdrawal_credentials: fromHexString(depositData.withdrawal_credentials),
122
+ amount: parseInt(depositData.amount),
123
+ signature: fromHexString(depositData.signature),
124
+ };
125
+ }),
126
+ builder_registration: {
127
+ message: {
128
+ fee_recipient: fromHexString((_a = dValidator.builder_registration) === null || _a === void 0 ? void 0 : _a.message.fee_recipient),
129
+ gas_limit: (_b = dValidator.builder_registration) === null || _b === void 0 ? void 0 : _b.message.gas_limit,
130
+ timestamp: (_c = dValidator.builder_registration) === null || _c === void 0 ? void 0 : _c.message.timestamp,
131
+ pubkey: fromHexString((_d = dValidator.builder_registration) === null || _d === void 0 ? void 0 : _d.message.pubkey),
132
+ },
133
+ signature: fromHexString((_e = dValidator.builder_registration) === null || _e === void 0 ? void 0 : _e.signature),
134
+ },
135
+ };
136
+ });
137
+ return '0x' + Buffer.from(lockType.hashTreeRoot(val).buffer).toString('hex');
138
+ };
139
+ // DV verification
140
+ export const verifyDVV1X10 = verifyDVV1X8;
@@ -144,7 +144,7 @@ export const verifyDVV1X8 = (clusterLock) => {
144
144
  // Deposit Data Verification
145
145
  for (const element of validator.partial_deposit_data) {
146
146
  const depositData = element;
147
- const { isValidDepositData, depositDataMsg } = verifyDepositData(distributedPublicKey, depositData, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version);
147
+ const { isValidDepositData, depositDataMsg } = verifyDepositData(distributedPublicKey, depositData, clusterLock.cluster_definition.validators[i].withdrawal_address, clusterLock.cluster_definition.fork_version, clusterLock.cluster_definition.compounding);
148
148
  if (!isValidDepositData) {
149
149
  return false;
150
150
  }
@@ -507,3 +507,267 @@ export const clusterLockWithSafe = {
507
507
  '0x4067921a5257efe4ceb103f2129faaa7a502781157b3b54e5efca559c558c2b43b89f30962e87df88fbf62250049a31888fcd62735d54b7553e5dc75c3b6ae0901',
508
508
  ],
509
509
  };
510
+ export const clusterLockV1X10 = {
511
+ cluster_definition: {
512
+ name: 'test',
513
+ creator: {
514
+ address: '',
515
+ config_signature: '',
516
+ },
517
+ operators: [
518
+ {
519
+ address: '',
520
+ enr: 'enr:-HW4QCi1pQaw0sSi6DIY7cR4u7mRjcimz2-3XlTsOUcE_HZAMjlVi0h-KwdjJg8644Zwx6gAe78hV1acRvVUkm0p2auAgmlkgnY0iXNlY3AyNTZrMaEDscvrSedZsyX51TFM1U4641ruU8bkci9mjsz3YA7TZig',
521
+ config_signature: '',
522
+ enr_signature: '',
523
+ },
524
+ {
525
+ address: '',
526
+ enr: 'enr:-HW4QAKHz3KMrMlSFBoUlWNUTIb7_ZfHesv2axtp8wembBFISVA8oUMEeLJFrrQhaftWof73TwaBJvSGWuQY-0h6aNWAgmlkgnY0iXNlY3AyNTZrMaECwse5ClGbpdyD6NIKvIQACZEpJf7ueY2dqwTgQrQkC9I',
527
+ config_signature: '',
528
+ enr_signature: '',
529
+ },
530
+ {
531
+ address: '',
532
+ enr: 'enr:-HW4QIH7JGgINCHlrhJBTc9LMYsVSIH3Wj-NbXeFwWJBphviWbEK4Z17HlTTmHlKKPeTNwnY3sub4oJuveY4dhUWMgOAgmlkgnY0iXNlY3AyNTZrMaEDaC9-4JUFqpvm42dCHKjB2UdR5G_F4WGBu6B8_BrEdHw',
533
+ config_signature: '',
534
+ enr_signature: '',
535
+ },
536
+ {
537
+ address: '',
538
+ enr: 'enr:-HW4QEESZRcjsz_WYXH-i4GIlbs6QydDkfM5FYqoTxpKY4ctX2DbHGNL1R2c560wIyX2BvPQkRzFMao74d31KIeluBmAgmlkgnY0iXNlY3AyNTZrMaECjGDrMWJT1PnNizXTbUQI9kIi-1iMNCaaPmu2aRpP31A',
539
+ config_signature: '',
540
+ enr_signature: '',
541
+ },
542
+ ],
543
+ uuid: 'BB338EAD-08C1-BEAD-D9C6-8568D844D7AE',
544
+ version: 'v1.10.0',
545
+ timestamp: '2025-02-24T11:02:27+01:00',
546
+ num_validators: 2,
547
+ threshold: 3,
548
+ validators: [
549
+ {
550
+ fee_recipient_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
551
+ withdrawal_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
552
+ },
553
+ {
554
+ fee_recipient_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
555
+ withdrawal_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
556
+ },
557
+ ],
558
+ dkg_algorithm: 'default',
559
+ fork_version: '0x01017000',
560
+ deposit_amounts: null,
561
+ consensus_protocol: '',
562
+ target_gas_limit: 36000000,
563
+ compounding: false,
564
+ config_hash: '0xc10f8bf3fb5054c6f3bfde8ce88fe8b29ba2e74fab01ae70033bfc14dc7c6552',
565
+ definition_hash: '0xac37a1e1ab6df855060495c82d0b882315b9275b9ef76987a7834372101f8b00',
566
+ },
567
+ distributed_validators: [
568
+ {
569
+ distributed_public_key: '0xab8ca3ff2a9748d001e95f347c9754c78b218fe8e062b8dd60519d451b2776d9f55dc3150ff49ecc22c78c459f4618c5',
570
+ public_shares: [
571
+ '0x814e8a30c079eb63babb05e82eef3ebd2419019ddfb1e5ccf9d717fa22c6a2f2b8e1afb9b9c127cfd2186eed59b5ce85',
572
+ '0x8471aadd68d2eaf06013ad1965d58bee7bc51aa6fb13b6629097119100c4a13ec7cb2f79c84d56ef17f18494b0458b06',
573
+ '0xb6a92217b7827da24e6612480c0b333388e45ce9e106f8451447833f3b97905dd10b694662a68dae82919da9271ee511',
574
+ '0x8e1c34c8df8958b4be21c055f17257c47b7a1acca7c10becd4423e453ee230e27347355d63f98aa551b413a56522fce0',
575
+ ],
576
+ builder_registration: {
577
+ message: {
578
+ fee_recipient: '0x0d941218c10b055f0907fe1bbe486ccdaa7e332a',
579
+ gas_limit: 36000000,
580
+ timestamp: 1696000704,
581
+ pubkey: '0xab8ca3ff2a9748d001e95f347c9754c78b218fe8e062b8dd60519d451b2776d9f55dc3150ff49ecc22c78c459f4618c5',
582
+ },
583
+ signature: '0x827111972c310bb778e30e5abb71b99de6036901a951c4b31fed24464b005e0db4b748acc517487e7598106ec34d5eaf0b667433bec57c551c51832a463f852ff70a738596f4add097be8e2d254d4d38259b17bb48f0f463f23de05a22245803',
584
+ },
585
+ partial_deposit_data: [
586
+ {
587
+ pubkey: '0xab8ca3ff2a9748d001e95f347c9754c78b218fe8e062b8dd60519d451b2776d9f55dc3150ff49ecc22c78c459f4618c5',
588
+ withdrawal_credentials: '0x0100000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
589
+ amount: '1000000000',
590
+ signature: '0xb63799adec3016e9535845327c319e1a6b17fcf8841ef65de68cb427a91e8e82285c3b0bc45272ab5e898d5d906c3592048a7766f338883a71d5b4bdd697ad2b5d13269a7e7679b6ff5bc8fdabee2f86f1c4f21572e36790f0be784eb82d1c71',
591
+ },
592
+ {
593
+ pubkey: '0xab8ca3ff2a9748d001e95f347c9754c78b218fe8e062b8dd60519d451b2776d9f55dc3150ff49ecc22c78c459f4618c5',
594
+ withdrawal_credentials: '0x0100000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
595
+ amount: '32000000000',
596
+ signature: '0x802f962fa91c361149a60269afa42856ddf97ca507995a703904237458619bd42a9b926b2a0843a50ef9d2707dd4bf59140cec8aa26d301efc720b4f0a7ade32385c808af7afc1f22b5d0a2db0c0f39b29d7e031c8a6b8baea291764e4277354',
597
+ },
598
+ ],
599
+ },
600
+ {
601
+ distributed_public_key: '0x87d41d8acd0d6a334f3cf3ffff324b4513df67d655f5d7c6992ec09faecaad857e7f7ec02fb77809b50b7d27649dda7c',
602
+ public_shares: [
603
+ '0xb16475989aa084029a73179efc489b4f786ebbbdbc949af11041fdb55dd3680424283efc9aa679eea8d6dafccca0ebc7',
604
+ '0xab62feb0624d5c08441343b5b290d9a75d171375dbacc2f2a1d995f6ba3f8881bad14d38e540b229e096310dafce752f',
605
+ '0xa9dd8b82fb6244dbae9a903afdbd1a525772624a8799b358129c28a64355a1c0a5733b1cb094564bc33edcf28e53eacc',
606
+ '0xb47806d895fa3df69eb4155b7d22444d52bca4eb1c537272d3a477faa1982e662ec7aebd914e6d6ab6014a16b966a83a',
607
+ ],
608
+ builder_registration: {
609
+ message: {
610
+ fee_recipient: '0x0d941218c10b055f0907fe1bbe486ccdaa7e332a',
611
+ gas_limit: 36000000,
612
+ timestamp: 1696000704,
613
+ pubkey: '0x87d41d8acd0d6a334f3cf3ffff324b4513df67d655f5d7c6992ec09faecaad857e7f7ec02fb77809b50b7d27649dda7c',
614
+ },
615
+ signature: '0x93d8f818e0e12dcf688c58eba36943dacf575bf30b81a631a62dc5ea45a0f808e013aa3dfec1462bf6670b744900265d107a075f17c91e20fbe3f6f46f278536c823b864c00b78e6bae490a67bfab48edae2c7be47c598ca79e66dbbd316a52a',
616
+ },
617
+ partial_deposit_data: [
618
+ {
619
+ pubkey: '0x87d41d8acd0d6a334f3cf3ffff324b4513df67d655f5d7c6992ec09faecaad857e7f7ec02fb77809b50b7d27649dda7c',
620
+ withdrawal_credentials: '0x0100000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
621
+ amount: '1000000000',
622
+ signature: '0xa3330521d24e30b2b2b98cc64b4c8599ac59dab8f1498f39e71d6deade29671731a0fba68f3f25e04374f8e89531f6ed025b478c270f0e7bfed9a3d80a13656af859d7132a53467a080c0d2b166026fe48eafa95943eccde7fb509c1d218da2e',
623
+ },
624
+ {
625
+ pubkey: '0x87d41d8acd0d6a334f3cf3ffff324b4513df67d655f5d7c6992ec09faecaad857e7f7ec02fb77809b50b7d27649dda7c',
626
+ withdrawal_credentials: '0x0100000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
627
+ amount: '32000000000',
628
+ signature: '0xa1fb379892a13b791a2b6391b14e8bc0ba60f366e349b8de73f108ea997f1eee2d537053b37eb2aba325efee4eaf121512ba869e00e6612afce571ae2b10de0a16826514a33254209b4b8e51bc6f9d05faa2bba95b3ad16a0b14433674653296',
629
+ },
630
+ ],
631
+ },
632
+ ],
633
+ signature_aggregate: '0xa3547b36e4b0953a172815122678b0ce73e09fab7df7e6ce0ffa31924e0f7097e7686affb54816397e160de21b6d3139135e1073f51652e7db5276fce5c0efea2e20c77a7c85bb414c56320cd2adb68a83417e4b453cf04650fc747fa1b766f7',
634
+ lock_hash: '0xcd689de27f3e954b38e44faca15edaf9a484573df696f4363fbff19cdd84a7db',
635
+ node_signatures: [
636
+ '0x3c68ed8e1a13a154e04e8f8824c745ae7df8f408f282448fe514ded85ec12f281dbe50d1612f73737bccf163309f396c7f05971b55b6e3be81df2e17f27ce6b701',
637
+ '0x06d12eb7f6faaf68d0aad60cbd0e877319a6bf8e7bbdba10570de2dd7513938b1650bf267e2aa1d113416c3a21021e1ff63b3697ff199bb59757cafbbb8625ea01',
638
+ '0xaa6d244a1caa5e35f77c1f68c291e7f9714248c1aaf6deddbabdefcb184e14432431477352fa21a0a5f7992ae7392b454600f8cbb8a12bbab0512581f386d3d300',
639
+ '0x932e769d2294a2c7071970458e5f696443fed01c5cb84985cad3c86b2e4fbf67781bc1668a64421fd09228abcd86992a5aa1196a2874026f1a72d184e32f6e9c01',
640
+ ],
641
+ };
642
+ export const clusterLockWithCompoundingWithdrawals = {
643
+ cluster_definition: {
644
+ name: 'test',
645
+ creator: {
646
+ address: '',
647
+ config_signature: '',
648
+ },
649
+ operators: [
650
+ {
651
+ address: '',
652
+ enr: 'enr:-HW4QNcZSicYpnE6PLTNao0kmv5FFTdR-iYh-SdeLlwromZ1DeY7drKAf1mrRoVM1AAVDkkqLxOZXPkDR85A-PdJg9CAgmlkgnY0iXNlY3AyNTZrMaECcdGTKboadTFffnKs9OxuqeZ4oEIUUJ-G1QXkKGHDkNk',
653
+ config_signature: '',
654
+ enr_signature: '',
655
+ },
656
+ {
657
+ address: '',
658
+ enr: 'enr:-HW4QDfvVp6bCS09-yA3NDJ91JdSbgh5wNTE82V1kv5EAebkKCFoXMEE_YY0qIS0_EEH54Hw-4Pc94enfwhpdOdpyAqAgmlkgnY0iXNlY3AyNTZrMaEDgOW8OThKXxluyWiWyLaP-1q_fsyDU0OhSBjO8MyEw3Y',
659
+ config_signature: '',
660
+ enr_signature: '',
661
+ },
662
+ {
663
+ address: '',
664
+ enr: 'enr:-HW4QGOen2twSnIzDuR834D7lPf3aGAw_CdTT9aebhfpKuvMKkIMlUOaYBYhMlaHke1JU_rNGZRr2ixaPpyTAbZRNDyAgmlkgnY0iXNlY3AyNTZrMaECkhQs3kw6C5geIyIAunFqLcyONz7-pWJA9dprq918YUw',
665
+ config_signature: '',
666
+ enr_signature: '',
667
+ },
668
+ {
669
+ address: '',
670
+ enr: 'enr:-HW4QLa2GPP1d34upL70ltxuiAEG_ayAHSwBbLpkFPLV2exoTRyUNBBFiNGe-kwqBvtuU2u2Zq8pUi2oeB3gHRbna7SAgmlkgnY0iXNlY3AyNTZrMaECow8eskA89PSk3pzMwA9BCyFYOrr6UxFGSfi6JQU5HkM',
671
+ config_signature: '',
672
+ enr_signature: '',
673
+ },
674
+ ],
675
+ uuid: '0CB6B203-39FF-3E52-898D-CC50D122694D',
676
+ version: 'v1.10.0',
677
+ timestamp: '2025-02-24T14:29:52+01:00',
678
+ num_validators: 2,
679
+ threshold: 3,
680
+ validators: [
681
+ {
682
+ fee_recipient_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
683
+ withdrawal_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
684
+ },
685
+ {
686
+ fee_recipient_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
687
+ withdrawal_address: '0x0D941218c10b055f0907FE1BbE486ccdAa7e332A',
688
+ },
689
+ ],
690
+ dkg_algorithm: 'default',
691
+ fork_version: '0x01017000',
692
+ deposit_amounts: null,
693
+ consensus_protocol: '',
694
+ target_gas_limit: 36000000,
695
+ compounding: true,
696
+ config_hash: '0x5f779ea58ebfe7b14181b05b281a6526c046eb42d2d03a06ac7d83e52e903ef2',
697
+ definition_hash: '0xd74c102137a44caed014b53edbd069fc5efef37226e0a7f2afbd4a529cec93df',
698
+ },
699
+ distributed_validators: [
700
+ {
701
+ distributed_public_key: '0x85e740354cef367a5216087cbb40a3bb061b6f11969b23e3c3d07828d924f577a39d74775be3a1a56b0d1e385631b160',
702
+ public_shares: [
703
+ '0x96b9d96c2bbc4ebd0650eedf4a4b1d9c4547b72f0585111b7930880795cbfdfc6d69fb02b105092058e830e1859927ba',
704
+ '0xa77071a78064201d4b1f8f3a7f3c71ccae40698385b6e4a344918d11f0523d5f62fc8fe1df0ac153cd5dc6cf9989cdce',
705
+ '0xa9119a315ea2c4729a4cf304f11fa079cb619e347b5150a3430d0bcaf7188510de81bfa4c953467cd6df077d56397726',
706
+ '0xadf3022df7f3f0e048a930bd2f89bf703191e159a20fd7eefa88f4af7487936d317fbd84f673d4f9803a321c20efb614',
707
+ ],
708
+ builder_registration: {
709
+ message: {
710
+ fee_recipient: '0x0d941218c10b055f0907fe1bbe486ccdaa7e332a',
711
+ gas_limit: 36000000,
712
+ timestamp: 1696000704,
713
+ pubkey: '0x85e740354cef367a5216087cbb40a3bb061b6f11969b23e3c3d07828d924f577a39d74775be3a1a56b0d1e385631b160',
714
+ },
715
+ signature: '0x8b81aaf5508ada3fe80d64bd262cb3e647ac8739f22f51cfcd9f2bbe1ea708f2e7a7429da6ae1dc05329becd6283ba6e18535ec254ba16854473683e8cb02cf602f7260ba4bd580079f9451a4ed673be3a40720d48468335a82b1706c595547e',
716
+ },
717
+ partial_deposit_data: [
718
+ {
719
+ pubkey: '0x85e740354cef367a5216087cbb40a3bb061b6f11969b23e3c3d07828d924f577a39d74775be3a1a56b0d1e385631b160',
720
+ withdrawal_credentials: '0x0200000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
721
+ amount: '1000000000',
722
+ signature: '0x805e452eeb66fb1e73fd66178713073bb1b1fe643b6036d0a68f475508dbc2d2b652758902f2daee73ff713c80e10b5808b8d4cf5c88c831ccffcdd4c5a4f866c82fc56b378211dfd291fe8e85213fb9c90e2d1fbbdea9997fdfa932b296d27c',
723
+ },
724
+ {
725
+ pubkey: '0x85e740354cef367a5216087cbb40a3bb061b6f11969b23e3c3d07828d924f577a39d74775be3a1a56b0d1e385631b160',
726
+ withdrawal_credentials: '0x0200000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
727
+ amount: '32000000000',
728
+ signature: '0xb19b91e7c2f11b6a86c252826000c7ef396619d54fe7772cea32c9cc4d2a10214da71b488262e3680e38de79b61aa37b075c1b7bfcf8ec62bb1d19867c434cb59e565c7c861f6412c3e525b7eab740446e1aa98a3d5a637842455b4f07eff6eb',
729
+ },
730
+ ],
731
+ },
732
+ {
733
+ distributed_public_key: '0xad9d4bee633c3107ce5c35cab6304137d5c43f1a0ce929c7f7983b51579cbc6a9b6813e05f5b74682a077c74ec6dd53d',
734
+ public_shares: [
735
+ '0xad574bb713e7b0aa2181b4ea2962834fe3a051e0ca8325b36f8615a99870f252aed701968cb010814dfe1b8c0450a269',
736
+ '0xa58556a322d1acf5ea553a3a0ba5184729589a564bd7bc787b81328b5cd033d421ee98386df623eb176acf98a3fa9bd1',
737
+ '0x95e732e087c43bd316e062d2bb2332efc34de59309d8b6da5ad747f4d842182af9539182a30ed314f8b7ae653d730d65',
738
+ '0xb6067ce37489114b24b59c4cf77fa0653e86bfb184c82935b14ec414c78ee75a43a583bd688ed04f0de2d1281608c87b',
739
+ ],
740
+ builder_registration: {
741
+ message: {
742
+ fee_recipient: '0x0d941218c10b055f0907fe1bbe486ccdaa7e332a',
743
+ gas_limit: 36000000,
744
+ timestamp: 1696000704,
745
+ pubkey: '0xad9d4bee633c3107ce5c35cab6304137d5c43f1a0ce929c7f7983b51579cbc6a9b6813e05f5b74682a077c74ec6dd53d',
746
+ },
747
+ signature: '0x8e2d2f19eb23a93d19fdfbe5e72763d20ea8dd558a01035c8145c3931d705cae6850185be62d6ccd6b94c3faa29914b902032f34483a5c55ba3653bf026193cc0c6076b0031b011fce78faa96234fd17ebe67b972e6f6233a7760cb17451d63d',
748
+ },
749
+ partial_deposit_data: [
750
+ {
751
+ pubkey: '0xad9d4bee633c3107ce5c35cab6304137d5c43f1a0ce929c7f7983b51579cbc6a9b6813e05f5b74682a077c74ec6dd53d',
752
+ withdrawal_credentials: '0x0200000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
753
+ amount: '1000000000',
754
+ signature: '0x90dbbc981e441292441ed2ec1aaed7c8e1d1afc976ea2c5051bb880f3368b75debfcb3fe6a96935838a693ea2ebfadea05c468ced6bc0f2f0b82f2e87a3febda10935691318548c32bbb059a005b6d8fb41b2552c4ede024f789b011377956c7',
755
+ },
756
+ {
757
+ pubkey: '0xad9d4bee633c3107ce5c35cab6304137d5c43f1a0ce929c7f7983b51579cbc6a9b6813e05f5b74682a077c74ec6dd53d',
758
+ withdrawal_credentials: '0x0200000000000000000000000d941218c10b055f0907fe1bbe486ccdaa7e332a',
759
+ amount: '32000000000',
760
+ signature: '0xafd1ade11b8b4c6da2a2b7136604c42c0edb1f37de81c5614adc8ce8da034a6a720ebe1970bf3467c12ffcbcb6fc8514149b6a04c3f13cc2e9d8c99096047af47543c1f3622c15e3400d6929386097b9af9fe5f5b372b0da60dab6edb269d216',
761
+ },
762
+ ],
763
+ },
764
+ ],
765
+ signature_aggregate: '0x8984f35f20e2f8733a5de37ed4d5405548b96f678b8c7a75a348bffbc6c9d795d56456f03e1ba4a207bcca5697a2490e129716fc0344452aa92472ad9fcbd6d7bb5de00eb9a2d41e3b76ab04026b68f3c50723b242da666d804e0b0e42958baf',
766
+ lock_hash: '0x5207f99c483863cb494332bb2c91e9f5260c00d6f49f27036426e5f83ff71b41',
767
+ node_signatures: [
768
+ '0x72eded28a88ef170df2a8b9361fe0ea1f991ba2444e336bd627e3c49179bd4bb7cf1dc7b27574cc08301fb16542135871ee3ea9662b4d177a528bf3df6e8959a00',
769
+ '0xee7051251d28f64fc9972326d0ce53e08a0b07f8959e97bdd2cd177c117bb12d3ced1ba8ac6c5b103b66703263ae17f5914e935eb3efa33ed7c7bf4ae98bab8400',
770
+ '0x57ebc828eb5a27a206f8dbbf6305fad50746c2bb3d882b2651d985661557fba434feba3a3fc5e7247bf3cf8521df6914621e81cb069909d68b5d3e6303f6115b00',
771
+ '0x3e2548c3c35df90bd7af34f9cc439e7ec4e4fa5619f74ca393bde8e05942dfde0c2e5d95249f478533fe11581b794e5de55446452e4dd1648c33b319a987461701',
772
+ ],
773
+ };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { ethers, JsonRpcProvider } from 'ethers';
11
11
  import { Client, validateClusterLock } from '../src/index';
12
- import { clusterConfigV1X7, clusterConfigV1X8, clusterLockV1X6, clusterLockV1X7, clusterLockV1X8, clusterLockWithSafe, nullDepositAmountsClusterLockV1X8, } from './fixtures.js';
12
+ import { clusterConfigV1X7, clusterConfigV1X8, clusterLockV1X10, clusterLockV1X6, clusterLockV1X7, clusterLockV1X8, clusterLockWithCompoundingWithdrawals, clusterLockWithSafe, nullDepositAmountsClusterLockV1X8, } from './fixtures.js';
13
13
  import { SDK_VERSION } from '../src/constants';
14
14
  import { Base } from '../src/base';
15
15
  import { validatePayload } from '../src/ajv';
@@ -185,6 +185,11 @@ describe('Cluster Client without a signer', () => {
185
185
  version: 'Cluster with safe address v1.8.0',
186
186
  clusterLock: clusterLockWithSafe,
187
187
  },
188
+ { version: 'v1.10.0', clusterLock: clusterLockV1X10 },
189
+ {
190
+ version: 'v1.10.0 with compunding withdrawals',
191
+ clusterLock: clusterLockWithCompoundingWithdrawals,
192
+ },
188
193
  ])("$version: 'should return true on verified cluster lock'", ({ clusterLock }) => __awaiter(void 0, void 0, void 0, function* () {
189
194
  const isValidLock = yield validateClusterLock(clusterLock);
190
195
  expect(isValidLock).toEqual(true);
@@ -4,6 +4,7 @@ import { type RewardsSplitPayload, type ClusterDefinition, type ClusterLock, typ
4
4
  export * from './types.js';
5
5
  export * from './services.js';
6
6
  export * from './verification/signature-validator.js';
7
+ export * from './verification/common.js';
7
8
  /**
8
9
  * Obol sdk Client can be used for creating, managing and activating distributed validators.
9
10
  */
@@ -93,6 +93,12 @@ export interface ClusterDefinition extends ClusterPayload {
93
93
  num_validators: number;
94
94
  /** The hash of the cluster definition. */
95
95
  definition_hash?: string;
96
+ /** The consensus protocol e.g qbft. */
97
+ consensus_protocol?: string;
98
+ /** The target gas limit where default is 30M. */
99
+ target_gas_limit?: number;
100
+ /** A withdrawal mechanism with 0x02 withdrawal credentials. */
101
+ compounding?: boolean;
96
102
  }
97
103
  /**
98
104
  * Split Recipient Keys
@@ -19,7 +19,7 @@ export declare const clusterLockHash: (clusterLock: ClusterLock) => string;
19
19
  * @param {string} withdrawalAddress - withdrawal address in definition file.
20
20
  * @returns {boolean} - return if deposit data is valid.
21
21
  */
22
- export declare const verifyDepositData: (distributedPublicKey: string, depositData: Partial<DepositData>, withdrawalAddress: string, forkVersion: string) => {
22
+ export declare const verifyDepositData: (distributedPublicKey: string, depositData: Partial<DepositData>, withdrawalAddress: string, forkVersion: string, compounding?: boolean) => {
23
23
  isValidDepositData: boolean;
24
24
  depositDataMsg: Uint8Array;
25
25
  };
@@ -0,0 +1,38 @@
1
+ import { UintNumberType } from '@chainsafe/ssz/lib/type/uint';
2
+ import { type creatorAddressWrapperType, type creatorContainerType, type operatorAddressWrapperType, type operatorContainerType, validatorsContainerType } from './sszTypes';
3
+ import { ByteListType, ByteVectorType, ContainerType, ListBasicType, ListCompositeType, BooleanType } from '@chainsafe/ssz';
4
+ import { type ValueOfFields } from '@chainsafe/ssz/lib/view/container';
5
+ import { type ClusterDefinition, type ClusterLock } from '../types';
6
+ type DefinitionFieldsV1X10 = {
7
+ uuid: ByteListType;
8
+ name: ByteListType;
9
+ version: ByteListType;
10
+ timestamp: ByteListType;
11
+ num_validators: UintNumberType;
12
+ threshold: UintNumberType;
13
+ dkg_algorithm: ByteListType;
14
+ fork_version: ByteVectorType;
15
+ operators: ListCompositeType<typeof operatorContainerType | typeof operatorAddressWrapperType>;
16
+ creator: typeof creatorContainerType | typeof creatorAddressWrapperType;
17
+ validators: ListCompositeType<typeof validatorsContainerType>;
18
+ deposit_amounts: ListBasicType<UintNumberType>;
19
+ consensus_protocol: ByteListType;
20
+ target_gas_limit: UintNumberType;
21
+ compounding: BooleanType;
22
+ config_hash?: ByteVectorType;
23
+ };
24
+ type DefinitionContainerTypeV1X10 = ContainerType<DefinitionFieldsV1X10>;
25
+ /**
26
+ * Returns the containerized cluster definition
27
+ * @param cluster ClusterDefinition to calculate the type from
28
+ * @returns SSZ Containerized type of cluster input
29
+ */
30
+ export declare const clusterDefinitionContainerTypeV1X10: (configOnly: boolean) => DefinitionContainerTypeV1X10;
31
+ export declare const hashClusterDefinitionV1X10: (cluster: ClusterDefinition, configOnly: boolean) => ValueOfFields<DefinitionFieldsV1X10>;
32
+ /**
33
+ * @param cluster The published cluster lock
34
+ * @returns The lock hash in of the corresponding cluster
35
+ */
36
+ export declare const hashClusterLockV1X10: (cluster: ClusterLock) => string;
37
+ export declare const verifyDVV1X10: (clusterLock: ClusterLock) => boolean;
38
+ export {};
@@ -263,3 +263,111 @@ export declare const clusterLockWithSafe: {
263
263
  lock_hash: string;
264
264
  node_signatures: string[];
265
265
  };
266
+ export declare const clusterLockV1X10: {
267
+ cluster_definition: {
268
+ name: string;
269
+ creator: {
270
+ address: string;
271
+ config_signature: string;
272
+ };
273
+ operators: {
274
+ address: string;
275
+ enr: string;
276
+ config_signature: string;
277
+ enr_signature: string;
278
+ }[];
279
+ uuid: string;
280
+ version: string;
281
+ timestamp: string;
282
+ num_validators: number;
283
+ threshold: number;
284
+ validators: {
285
+ fee_recipient_address: string;
286
+ withdrawal_address: string;
287
+ }[];
288
+ dkg_algorithm: string;
289
+ fork_version: string;
290
+ deposit_amounts: null;
291
+ consensus_protocol: string;
292
+ target_gas_limit: number;
293
+ compounding: boolean;
294
+ config_hash: string;
295
+ definition_hash: string;
296
+ };
297
+ distributed_validators: {
298
+ distributed_public_key: string;
299
+ public_shares: string[];
300
+ builder_registration: {
301
+ message: {
302
+ fee_recipient: string;
303
+ gas_limit: number;
304
+ timestamp: number;
305
+ pubkey: string;
306
+ };
307
+ signature: string;
308
+ };
309
+ partial_deposit_data: {
310
+ pubkey: string;
311
+ withdrawal_credentials: string;
312
+ amount: string;
313
+ signature: string;
314
+ }[];
315
+ }[];
316
+ signature_aggregate: string;
317
+ lock_hash: string;
318
+ node_signatures: string[];
319
+ };
320
+ export declare const clusterLockWithCompoundingWithdrawals: {
321
+ cluster_definition: {
322
+ name: string;
323
+ creator: {
324
+ address: string;
325
+ config_signature: string;
326
+ };
327
+ operators: {
328
+ address: string;
329
+ enr: string;
330
+ config_signature: string;
331
+ enr_signature: string;
332
+ }[];
333
+ uuid: string;
334
+ version: string;
335
+ timestamp: string;
336
+ num_validators: number;
337
+ threshold: number;
338
+ validators: {
339
+ fee_recipient_address: string;
340
+ withdrawal_address: string;
341
+ }[];
342
+ dkg_algorithm: string;
343
+ fork_version: string;
344
+ deposit_amounts: null;
345
+ consensus_protocol: string;
346
+ target_gas_limit: number;
347
+ compounding: boolean;
348
+ config_hash: string;
349
+ definition_hash: string;
350
+ };
351
+ distributed_validators: {
352
+ distributed_public_key: string;
353
+ public_shares: string[];
354
+ builder_registration: {
355
+ message: {
356
+ fee_recipient: string;
357
+ gas_limit: number;
358
+ timestamp: number;
359
+ pubkey: string;
360
+ };
361
+ signature: string;
362
+ };
363
+ partial_deposit_data: {
364
+ pubkey: string;
365
+ withdrawal_credentials: string;
366
+ amount: string;
367
+ signature: string;
368
+ }[];
369
+ }[];
370
+ signature_aggregate: string;
371
+ lock_hash: string;
372
+ node_signatures: string[];
373
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obolnetwork/obol-sdk",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "A package for creating Distributed Validators using the Obol API.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/obolnetwork/obol-sdk/issues"
package/src/index.ts CHANGED
@@ -50,6 +50,7 @@ import { isContractAvailable } from './utils.js';
50
50
  export * from './types.js';
51
51
  export * from './services.js';
52
52
  export * from './verification/signature-validator.js';
53
+ export * from './verification/common.js';
53
54
 
54
55
  /**
55
56
  * Obol sdk Client can be used for creating, managing and activating distributed validators.
package/src/types.ts CHANGED
@@ -138,6 +138,15 @@ export interface ClusterDefinition extends ClusterPayload {
138
138
 
139
139
  /** The hash of the cluster definition. */
140
140
  definition_hash?: string;
141
+
142
+ /** The consensus protocol e.g qbft. */
143
+ consensus_protocol?: string;
144
+
145
+ /** The target gas limit where default is 30M. */
146
+ target_gas_limit?: number;
147
+
148
+ /** A withdrawal mechanism with 0x02 withdrawal credentials. */
149
+ compounding?: boolean;
141
150
  }
142
151
 
143
152
  /**