@@ -31,7 +31,6 @@ import (
3131 "github.com/obolnetwork/charon/app/errors"
3232 "github.com/obolnetwork/charon/app/eth2wrap"
3333 "github.com/obolnetwork/charon/app/log"
34- "github.com/obolnetwork/charon/cluster"
3534 "github.com/obolnetwork/charon/core"
3635 "github.com/obolnetwork/charon/testutil"
3736)
@@ -145,35 +144,39 @@ var ValidatorSetA = ValidatorSet{
145144 },
146145}
147146
147+ // mustBuilderRegistration creates a builder registration, panicking on error.
148+ func mustBuilderRegistration (feeRecipient , pubkey , signature string ) * eth2api.VersionedSignedValidatorRegistration {
149+ return & eth2api.VersionedSignedValidatorRegistration {
150+ Version : eth2spec .BuilderVersionV1 ,
151+ V1 : & eth2v1.SignedValidatorRegistration {
152+ Message : & eth2v1.ValidatorRegistration {
153+ FeeRecipient : MustExecutionAddress (feeRecipient ),
154+ GasLimit : 30000000 ,
155+ Timestamp : time .Unix (1609459200 , 0 ), // 2021-01-01 00:00:00 UTC
156+ Pubkey : MustBLSPubKey (pubkey ),
157+ },
158+ Signature : MustBLSSignature (signature ),
159+ },
160+ }
161+ }
162+
148163// BuilderRegistrationSetA defines a set of 3 deterministic builder registrations for ValidatorSetA.
149- var BuilderRegistrationSetA = []cluster.BuilderRegistration {
150- {
151- Message : cluster.Registration {
152- FeeRecipient : MustBytesFromHex ("0x0000000000000000000000000000000000000001" ),
153- GasLimit : 30000000 ,
154- Timestamp : time .Unix (1609459200 , 0 ), // 2021-01-01 00:00:00 UTC
155- PubKey : MustBytesFromHex ("0x914cff835a769156ba43ad50b931083c2dadd94e8359ce394bc7a3e06424d0214922ddf15f81640530b9c25c0bc0d490" ),
156- },
157- Signature : MustBytesFromHex ("0xa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6" ),
158- },
159- {
160- Message : cluster.Registration {
161- FeeRecipient : MustBytesFromHex ("0x0000000000000000000000000000000000000002" ),
162- GasLimit : 30000000 ,
163- Timestamp : time .Unix (1609459200 , 0 ), // 2021-01-01 00:00:00 UTC
164- PubKey : MustBytesFromHex ("0x8dae41352b69f2b3a1c0b05330c1bf65f03730c520273028864b11fcb94d8ce8f26d64f979a0ee3025467f45fd2241ea" ),
165- },
166- Signature : MustBytesFromHex ("0xb2b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6" ),
167- },
168- {
169- Message : cluster.Registration {
170- FeeRecipient : MustBytesFromHex ("0x0000000000000000000000000000000000000003" ),
171- GasLimit : 30000000 ,
172- Timestamp : time .Unix (1609459200 , 0 ), // 2021-01-01 00:00:00 UTC
173- PubKey : MustBytesFromHex ("0x8ee91545183c8c2db86633626f5074fd8ef93c4c9b7a2879ad1768f600c5b5906c3af20d47de42c3b032956fa8db1a76" ),
174- },
175- Signature : MustBytesFromHex ("0xc3b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6" ),
176- },
164+ var BuilderRegistrationSetA = []* eth2api.VersionedSignedValidatorRegistration {
165+ mustBuilderRegistration (
166+ "0x0000000000000000000000000000000000000001" ,
167+ "0x914cff835a769156ba43ad50b931083c2dadd94e8359ce394bc7a3e06424d0214922ddf15f81640530b9c25c0bc0d490" ,
168+ "0xa1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6" ,
169+ ),
170+ mustBuilderRegistration (
171+ "0x0000000000000000000000000000000000000002" ,
172+ "0x8dae41352b69f2b3a1c0b05330c1bf65f03730c520273028864b11fcb94d8ce8f26d64f979a0ee3025467f45fd2241ea" ,
173+ "0xb2b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6" ,
174+ ),
175+ mustBuilderRegistration (
176+ "0x0000000000000000000000000000000000000003" ,
177+ "0x8ee91545183c8c2db86633626f5074fd8ef93c4c9b7a2879ad1768f600c5b5906c3af20d47de42c3b032956fa8db1a76" ,
178+ "0xc3b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6" ,
179+ ),
177180}
178181
179182// WithValidatorSet configures the mock with the provided validator set.
@@ -802,6 +805,36 @@ func mustPKFromHex(pubkeyHex string) eth2p0.BLSPubKey {
802805 return resp
803806}
804807
808+ // must20ByteArray converts a byte slice to a 20-byte array, panicking if wrong size.
809+ func must20ByteArray (b []byte ) [20 ]byte {
810+ if len (b ) != 20 {
811+ panic (fmt .Sprintf ("expected 20 bytes, got %d" , len (b )))
812+ }
813+ var arr [20 ]byte
814+ copy (arr [:], b )
815+ return arr
816+ }
817+
818+ // must48ByteArray converts a byte slice to a 48-byte array, panicking if wrong size.
819+ func must48ByteArray (b []byte ) [48 ]byte {
820+ if len (b ) != 48 {
821+ panic (fmt .Sprintf ("expected 48 bytes, got %d" , len (b )))
822+ }
823+ var arr [48 ]byte
824+ copy (arr [:], b )
825+ return arr
826+ }
827+
828+ // must96ByteArray converts a byte slice to a 96-byte array, panicking if wrong size.
829+ func must96ByteArray (b []byte ) [96 ]byte {
830+ if len (b ) != 96 {
831+ panic (fmt .Sprintf ("expected 96 bytes, got %d" , len (b )))
832+ }
833+ var arr [96 ]byte
834+ copy (arr [:], b )
835+ return arr
836+ }
837+
805838// MustBytesFromHex converts a hex string to bytes, panicking on error.
806839func MustBytesFromHex (hexStr string ) []byte {
807840 hexStr = strings .TrimPrefix (hexStr , "0x" )
@@ -813,3 +846,18 @@ func MustBytesFromHex(hexStr string) []byte {
813846
814847 return b
815848}
849+
850+ // MustExecutionAddress converts a hex string to an execution address (20 bytes), panicking on error.
851+ func MustExecutionAddress (hexStr string ) [20 ]byte {
852+ return must20ByteArray (MustBytesFromHex (hexStr ))
853+ }
854+
855+ // MustBLSPubKey converts a hex string to a BLS public key (48 bytes), panicking on error.
856+ func MustBLSPubKey (hexStr string ) [48 ]byte {
857+ return must48ByteArray (MustBytesFromHex (hexStr ))
858+ }
859+
860+ // MustBLSSignature converts a hex string to a BLS signature (96 bytes), panicking on error.
861+ func MustBLSSignature (hexStr string ) [96 ]byte {
862+ return must96ByteArray (MustBytesFromHex (hexStr ))
863+ }
0 commit comments