Skip to content

Commit

Permalink
Capella block support (#92)
Browse files Browse the repository at this point in the history
* VersionedValidatorRegistration

* Add real block and sig data tests for capella
  • Loading branch information
olegshmuelov authored Mar 28, 2023
1 parent 6d20544 commit 8d1395f
Show file tree
Hide file tree
Showing 25 changed files with 502 additions and 215 deletions.
7 changes: 4 additions & 3 deletions core/slashing_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ type SlashingProtector interface {
IsSlashableProposal(pubKey []byte, slot phase0.Slot) (*ProposalSlashStatus, error)
UpdateHighestAttestation(pubKey []byte, attestation *phase0.AttestationData) error
UpdateHighestProposal(pubKey []byte, slot phase0.Slot) error
RetrieveHighestAttestation(pubKey []byte) (*phase0.AttestationData, error)
FetchHighestAttestation(pubKey []byte) (*phase0.AttestationData, bool, error)
FetchHighestProposal(pubKey []byte) (phase0.Slot, bool, error)
}

// SlashingStore represents the behavior of the slashing store
type SlashingStore interface {
SaveHighestAttestation(pubKey []byte, attestation *phase0.AttestationData) error
RetrieveHighestAttestation(pubKey []byte) (*phase0.AttestationData, error)
RetrieveHighestAttestation(pubKey []byte) (*phase0.AttestationData, bool, error)
SaveHighestProposal(pubKey []byte, slot phase0.Slot) error
RetrieveHighestProposal(pubKey []byte) (phase0.Slot, error)
RetrieveHighestProposal(pubKey []byte) (phase0.Slot, bool, error)
}
26 changes: 24 additions & 2 deletions eth1_deposit/eth1_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package eth1deposit

import (
"github.com/attestantio/go-eth2-client/spec/phase0"
ssvtypes "github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
util "github.com/wealdtech/go-eth2-util"

Expand All @@ -17,6 +16,12 @@ const (
BLSWithdrawalPrefixByte = byte(0)
)

// GenesisValidatorsRoot genesis validators root of the chain.
var (
GenesisValidatorsRoot = phase0.Root{}
DomainDeposit = [4]byte{0x03, 0x00, 0x00, 0x00}
)

// IsSupportedDepositNetwork returns true if the given network is supported
var IsSupportedDepositNetwork = func(network core.Network) bool {
return network == core.PyrmontNetwork || network == core.PraterNetwork || network == core.MainNetwork
Expand All @@ -40,7 +45,7 @@ func DepositData(validationKey *core.HDKey, withdrawalPubKey []byte, network cor
}

// Create domain
domain, err := ssvtypes.ComputeETHDomain(ssvtypes.DomainDeposit, network.ForkVersion(), ssvtypes.GenesisValidatorsRoot)
domain, err := ComputeETHDomain(DomainDeposit, network.ForkVersion(), GenesisValidatorsRoot)
if err != nil {
return nil, [32]byte{}, errors.Wrap(err, "failed to calculate domain")
}
Expand Down Expand Up @@ -83,3 +88,20 @@ func withdrawalCredentialsHash(withdrawalPubKey []byte) []byte {
h := util.SHA256(withdrawalPubKey)
return append([]byte{BLSWithdrawalPrefixByte}, h[1:]...)[:32]
}

// ComputeETHDomain returns computed domain
func ComputeETHDomain(domain phase0.DomainType, fork phase0.Version, genesisValidatorRoot phase0.Root) (phase0.Domain, error) {
ret := phase0.Domain{}
copy(ret[0:4], domain[:])

forkData := phase0.ForkData{
CurrentVersion: fork,
GenesisValidatorsRoot: genesisValidatorRoot,
}
forkDataRoot, err := forkData.HashTreeRoot()
if err != nil {
return ret, err
}
copy(ret[4:32], forkDataRoot[0:28])
return ret, nil
}
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.18

require (
github.com/attestantio/go-eth2-client v0.15.2
github.com/bloxapp/ssv-spec v0.2.8-0.20230116160450-3526f3880cb9
github.com/btcsuite/btcd/btcec/v2 v2.2.1
github.com/ferranbt/fastssz v0.1.2
github.com/google/uuid v1.3.0
Expand All @@ -23,7 +22,6 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/ethereum/go-ethereum v1.10.23 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/goccy/go-yaml v1.9.5 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ github.com/attestantio/go-eth2-client v0.15.2/go.mod h1:/Oh6YTuHmHhgLN/ZnQRKHGc7
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bloxapp/ssv-spec v0.2.8-0.20230116160450-3526f3880cb9 h1:2tPKHBFQO8bzESNZPBe5UfrLQiVGajou+4xQ6prTHng=
github.com/bloxapp/ssv-spec v0.2.8-0.20230116160450-3526f3880cb9/go.mod h1:w0GcW7zn+EGU9YTUPM0W9L0w8Q7N3kVjIlO2Ha/htqw=
github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c=
github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E=
github.com/btcsuite/btcd/btcec/v2 v2.2.1/go.mod h1:9/CSmJxmuvqzX9Wh2fXMWToLOHhPd11lSPuIupwTkI8=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand All @@ -62,15 +58,12 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.10.23 h1:Xk8XAT4/UuqcjMLIMF+7imjkg32kfVFKoeyQDaO2yWM=
github.com/ethereum/go-ethereum v1.10.23/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
Expand Down
3 changes: 1 addition & 2 deletions signer/sign_aggregate_and_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/hex"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)

Expand All @@ -23,7 +22,7 @@ func (signer *SimpleSigner) SignAggregateAndProof(agg *phase0.AggregateAndProof,
return nil, nil, err
}

root, err := types.ComputeETHSigningRoot(agg, domain)
root, err := ComputeETHSigningRoot(agg, domain)
if err != nil {
return nil, nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions signer/sign_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/hex"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -47,7 +46,7 @@ func (signer *SimpleSigner) SignBeaconAttestation(attestation *phase0.Attestatio
}

// 6. Prepare and sign data
root, err := types.ComputeETHSigningRoot(attestation, domain)
root, err := ComputeETHSigningRoot(attestation, domain)
if err != nil {
return nil, nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion signer/sign_attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ func TestAttestationSignaturesNoSlashingData(t *testing.T) {
_byteArray32("01000000f071c66c6561d0b939feb15f513a019d99a84bd85635221e3ad42dac"),
_byteArray("95087182937f6982ae99f9b06bd116f463f414513032e33a3d175d9662eddf162101fcf6ca2a9fedaded74b8047c5dcf"))
require.Nil(t, res)
require.EqualError(t, err, "highest attestation data is nil, can't determine if attestation is slashable")
require.Error(t, err)
require.EqualError(t, err, "highest attestation data is not found, can't determine if attestation is slashable")
}

func TestAttestationSignatures(t *testing.T) {
Expand Down
66 changes: 54 additions & 12 deletions signer/sign_beacon_block_test.go

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions signer/sign_blinded_beacon_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package signer

import (
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"testing"

"github.com/attestantio/go-eth2-client/api"
apiv1bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix"
apiv1capella "github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -60,6 +64,49 @@ func TestBenchmarkBlindedBlockProposalBellatrix(t *testing.T) {
require.EqualValues(t, _byteArray(sigByts), sig)
}

// tested against a real block and sig from the Sepolia testnet (slot 1861337)
func TestBenchmarkBlindedBlockProposalCapella(t *testing.T) {
require.NoError(t, core.InitBLS())

// fixture
sk := "17f8b2dbb824318970a9c82b4f5456d598342dac248f89c252dd30bb9e85e43c"
pk := "81d6fc2f01633e8eab3ba4d72588e14f45b00e68ab887bdd4ec5e8558965db21189310df973837106216777b07fc0805"
domain := "0000000047eb72b3be36f08feffcaba760f0a2ed78c1a85f0654941a0d19d0fa"
blkJSON := []byte(`{"slot":"1861337","proposer_index":"1610","parent_root":"0x353f35e506b07b6a20dd5d24c92b6dfda1b9e221848963d7a40cb7fe4e23c35a","state_root":"0x8e9cfedb909c4c9bbc52ca4174b279d31ffe40a667077c7b31a66bbd1a66d0be","body":{"randao_reveal":"0xb019a2ef4b7763c7bd5a9b3dbe00ba38cdfb6ee0fcecfe4a7301687973717f7c193072a3ebd70de3aed153f960b11fc40037b8164542e1364a31489ff7a0a1119ef46bc2ea099886446cba3acc4721a2534c292f6eeb650719f32477707aab3e","eth1_data":{"deposit_root":"0x9df92d765b5aa041fd4bbe8d5878eb89290efa78e444c1a603eecfae2ea05fa4","deposit_count":"403","block_hash":"0x1ee29c95ea816db342e04fbd1f00cb14940a45d025d2d14bf0d33187d8f4d5ea"},"graffiti":"0x626c6f787374616b696e672e636f6d0000000000000000000000000000000000","proposer_slashings":[],"attester_slashings":[],"attestations":[{"aggregation_bits":"0xffffffffffffff37","data":{"slot":"1861336","index":"0","beacon_block_root":"0x353f35e506b07b6a20dd5d24c92b6dfda1b9e221848963d7a40cb7fe4e23c35a","source":{"epoch":"58165","root":"0x5c0a59daecb2f509e0d5a038da44c55ef5827b0b979e6e397cc7f5846f9f3f4c"},"target":{"epoch":"58166","root":"0x835469d3b4348c2f5c2964afaac731acc0117eb0f5cec64bf166ab26847f77a8"}},"signature":"0x991b97e124a8dc672d135c167f030ceff9ab500dfd9a8bb79e199a303bfa54cebc205e396a16466e51d54cb7e0d981eb0eb03295bdb39b69d9559421aeea22838d22732d66ea79d3bebb8a8a335679491b60ad6d815318cbfd92a1a867c70255"}],"deposits":[],"voluntary_exits":[],"sync_aggregate":{"sync_committee_bits":"0xfffffbfffffffffffffffcffffdfffffffffffffffefffffffffffff7ffdffffbfffffffffffefffffebfffffffffffffffffffdff7fffffffffffffffffffff","sync_committee_signature":"0x91713624034f3c1e37baa3de1d082883c6e44cc830f4ecf0ca58cc06153aba97ca4539edfdb0f49a0d18b354f585422e114feb07b689db0a47ee72231d8e6fb2970663f518ca0a3fda0e701cd4662405c4f2fa9fdac0533c790f92404240432e"},"execution_payload_header":{"parent_hash":"0x4b37c3a4f001b91cfcac61b7f6bdfd2218525e4f421a4ab52fa513b00e76ab6f","fee_recipient":"0x0f35b0753e261375c9a6cb44316b4bdc7e765509","state_root":"0xc9d0b31cc38141d01998220dcc0e7830994e6a1d11fa3a26d7d113df82c1a53a","receipts_root":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logs_bloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prev_randao":"0x251fdfd6ebef77085f24016900debbd334e67cf51ee48d959f01ef12698a49a5","block_number":"3031542","gas_limit":"30000000","gas_used":"0","timestamp":"1678069644","extra_data":"0xd883010b02846765746888676f312e32302e31856c696e7578","base_fee_per_gas":"7","block_hash":"0x4cb1ca5a2947972cb018416fe4489b9daf674d5be97fd2ebb6de1a1608226733","transactions_root":"0x7ffe241ea60187fdb0187bfa22de35d1f9bed7ab061d9401fd47e34a54fbede1","withdrawals_root":"0xb8edfc6f0dc2564cff3102471bef1e02db94346c692eb81decf0dec63c1c69f5"},"bls_to_execution_changes":[]}}`)
sigByts := "9321eb1d373e75bb0b746a8c4b6f62285cccb17f2105a1f4f968534902131a29fffd5b54a0012c34c8600639609c46ab05a23fe8f89cdd252df680883ccb94073d9b852680bba6c5f5166edcd6024c9ef489c555d1cde994fdd7010fb394e45d"

// setup KeyVault
store := inmemStorage()
options := &eth2keymanager.KeyVaultOptions{}
options.SetStorage(store)
options.SetWalletType(core.NDWallet)
vault, err := eth2keymanager.NewKeyVault(options)
require.NoError(t, err)
wallet, err := vault.Wallet()
require.NoError(t, err)
k, err := core.NewHDKeyFromPrivateKey(_byteArray(sk), "")
require.NoError(t, err)
acc := wallets.NewValidatorAccount("1", k, nil, "", vault.Context)
require.NoError(t, wallet.AddValidatorAccount(acc))

// setup signer
signer := NewSimpleSigner(wallet, &prot.NoProtection{}, core.PraterNetwork)

// decode block
blk := &apiv1capella.BlindedBeaconBlock{}
require.NoError(t, json.Unmarshal(blkJSON, blk))

versionedBlindedBeaconBlock := &api.VersionedBlindedBeaconBlock{
Version: spec.DataVersionCapella,
Capella: blk,
}

sig, _, err := signer.SignBlindedBeaconBlock(versionedBlindedBeaconBlock, _byteArray32(domain), _byteArray(pk))
fmt.Println(hex.EncodeToString(sig))
require.NoError(t, err)
require.EqualValues(t, _byteArray(sigByts), sig)
}

// Test slashing by signing first beacon block and then blinded beacon block
func TestDoubleProposalsSigning_Regular_Blinded(t *testing.T) {
require.NoError(t, core.InitBLS())
Expand Down
10 changes: 7 additions & 3 deletions signer/sign_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/hex"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"

Expand Down Expand Up @@ -33,15 +32,20 @@ func (signer *SimpleSigner) SignBlock(block ssz.HashRoot, slot phase0.Slot, doma
}

// 4. check we can even sign this
status, err := signer.verifySlashableAndUpdate(pubKey, slot)
status, err := signer.slashingProtector.IsSlashableProposal(pubKey, slot)
if err != nil {
return nil, nil, err
}
if status.Status != core.ValidProposal {
return nil, nil, errors.Errorf("slashable proposal (%s), not signing", status.Status)
}

root, err := types.ComputeETHSigningRoot(block, domain)
// 5. add to protection storage
if err = signer.slashingProtector.UpdateHighestProposal(pubKey, slot); err != nil {
return nil, nil, err
}

root, err := ComputeETHSigningRoot(block, domain)
if err != nil {
return nil, nil, errors.Wrap(err, "could not get signing root")
}
Expand Down
3 changes: 1 addition & 2 deletions signer/sign_epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/hex"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)

Expand All @@ -23,7 +22,7 @@ func (signer *SimpleSigner) SignEpoch(epoch phase0.Epoch, domain phase0.Domain,
return nil, nil, err
}

root, err := types.ComputeETHSigningRoot(types.SSZUint64(epoch), domain)
root, err := ComputeETHSigningRoot(SSZUint64(epoch), domain)
if err != nil {
return nil, nil, err
}
Expand Down
20 changes: 16 additions & 4 deletions signer/sign_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package signer
import (
"encoding/hex"

apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"
)

// SignRegistration signs the given ValidatorRegistration.
func (signer *SimpleSigner) SignRegistration(registration *apiv1.ValidatorRegistration, domain phase0.Domain, pubKey []byte) ([]byte, []byte, error) {
func (signer *SimpleSigner) SignRegistration(registration *api.VersionedValidatorRegistration, domain phase0.Domain, pubKey []byte) ([]byte, []byte, error) {
// Validate the registration.
if registration == nil {
return nil, nil, errors.New("registration data is nil")
Expand All @@ -25,8 +26,19 @@ func (signer *SimpleSigner) SignRegistration(registration *apiv1.ValidatorRegist
return nil, nil, err
}

var reg ssz.HashRoot
switch registration.Version {
case spec.BuilderVersionV1:
if registration.V1 == nil {
return nil, nil, errors.New("no validator registration")
}
reg = registration.V1
default:
return nil, nil, errors.Errorf("unsupported registration version %d", registration.Version)
}

// Produce the signature.
root, err := types.ComputeETHSigningRoot(registration, domain)
root, err := ComputeETHSigningRoot(reg, domain)
if err != nil {
return nil, nil, err
}
Expand Down
14 changes: 10 additions & 4 deletions signer/sign_registration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"github.com/attestantio/go-eth2-client/api"
apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
Expand All @@ -15,16 +16,21 @@ func TestSimpleSigner_SignRegistration(t *testing.T) {
signer, err := setupNoSlashingProtectionSK(_byteArray("659e875e1b062c03f2f2a57332974d475b97df6cfc581d322e79642d39aca8fd"))
require.NoError(t, err)

registrationMock := &apiv1.ValidatorRegistration{
valRegistrationMock := &apiv1.ValidatorRegistration{
GasLimit: 123456,
Timestamp: time.UnixMilli(1658313712),
}
copy(registrationMock.FeeRecipient[:], "9831EeF7A86C19E32bEcDad091c1DbC974cf452a")
copy(registrationMock.Pubkey[:], "a27c45f7afe6c63363acf886cdad282539fb2cf58b304f2caa95f2ea53048b65a5d41d926c3562e3f18b8b61871375af")
copy(valRegistrationMock.FeeRecipient[:], "9831EeF7A86C19E32bEcDad091c1DbC974cf452a")
copy(valRegistrationMock.Pubkey[:], "a27c45f7afe6c63363acf886cdad282539fb2cf58b304f2caa95f2ea53048b65a5d41d926c3562e3f18b8b61871375af")

registrationMock := &api.VersionedValidatorRegistration{
Version: 0,
V1: valRegistrationMock,
}

tests := []struct {
name string
data *apiv1.ValidatorRegistration
data *api.VersionedValidatorRegistration
pubKey []byte
domain [32]byte
expectedError error
Expand Down
4 changes: 1 addition & 3 deletions signer/sign_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/hex"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"

"github.com/pkg/errors"
)

Expand All @@ -24,7 +22,7 @@ func (signer *SimpleSigner) SignSlot(slot phase0.Slot, domain phase0.Domain, pub
return nil, nil, err
}

root, err := types.ComputeETHSigningRoot(types.SSZUint64(slot), domain)
root, err := ComputeETHSigningRoot(SSZUint64(slot), domain)
if err != nil {
return nil, nil, err
}
Expand Down
9 changes: 4 additions & 5 deletions signer/sign_sync_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/bloxapp/ssv-spec/types"
"github.com/pkg/errors"
)

Expand All @@ -26,8 +25,8 @@ func (signer *SimpleSigner) SignSyncCommittee(msgBlockRoot []byte, domain phase0
defer signer.unlock(account.ID(), "sync_committee")

// 3. sign
sszRoot := types.SSZBytes(msgBlockRoot)
root, err := types.ComputeETHSigningRoot(&sszRoot, domain)
sszRoot := SSZBytes(msgBlockRoot)
root, err := ComputeETHSigningRoot(&sszRoot, domain)
if err != nil {
return nil, nil, errors.Wrap(err, "could not get signing root")
}
Expand Down Expand Up @@ -59,7 +58,7 @@ func (signer *SimpleSigner) SignSyncCommitteeSelectionData(data *altair.SyncAggr
if data == nil {
return nil, nil, errors.New("selection data nil")
}
root, err := types.ComputeETHSigningRoot(data, domain)
root, err := ComputeETHSigningRoot(data, domain)
if err != nil {
return nil, nil, errors.Wrap(err, "could not get signing root")
}
Expand Down Expand Up @@ -91,7 +90,7 @@ func (signer *SimpleSigner) SignSyncCommitteeContributionAndProof(contribAndProo
if contribAndProof == nil {
return nil, nil, errors.New("contrib proof data nil")
}
root, err := types.ComputeETHSigningRoot(contribAndProof, domain)
root, err := ComputeETHSigningRoot(contribAndProof, domain)
if err != nil {
return nil, nil, errors.Wrap(err, "could not get signing root")
}
Expand Down
Loading

0 comments on commit 8d1395f

Please sign in to comment.