Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions crypto/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,6 @@ const (
ETH1WithdrawalPrefixByte = byte(1)
)

// GetNetworkByFork translates the network fork bytes into name
//
// TODO: once eth2_key_manager implements this we can get rid of it and support all networks ekm supports automatically
func GetNetworkByFork(fork [4]byte) (core.Network, error) {
switch fork {
case [4]byte{0x90, 0x00, 0x00, 0x69}:
return core.SepoliaNetwork, nil
case [4]byte{0x10, 0x00, 0x09, 0x10}:
return core.HoodiNetwork, nil
case [4]byte{0x00, 0x00, 0x10, 0x20}:
return core.PraterNetwork, nil
case [4]byte{0x01, 0x01, 0x70, 0x00}:
return core.HoleskyNetwork, nil
case [4]byte{0, 0, 0, 0}:
return core.MainNetwork, nil
default:
return core.MainNetwork, fmt.Errorf("unknown network")
}
}

func ETH1WithdrawalCredentials(withdrawalAddr []byte) []byte {
withdrawalCredentials := make([]byte, 32)
copy(withdrawalCredentials[:1], []byte{ETH1WithdrawalPrefixByte})
Expand Down Expand Up @@ -107,7 +87,7 @@ func DepositDataRootForFork(
withdrawalCredentials []byte,
amount phase0.Gwei,
) (phase0.Root, error) {
network, err := GetNetworkByFork(fork)
network, err := core.NetworkFromForkVersion(fork)
if err != nil {
return phase0.Root{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/ferranbt/fastssz v0.1.4
github.com/google/uuid v1.6.0
github.com/herumi/bls-eth-go-binary v1.36.4
github.com/ssvlabs/eth2-key-manager v1.5.3
github.com/ssvlabs/eth2-key-manager v1.5.4
github.com/stretchr/testify v1.10.0
github.com/wealdtech/go-eth2-types/v2 v2.8.2
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/ssvlabs/eth2-key-manager v1.5.3 h1:B9U+mrdQpWMWfIEhWGW2m3b95IqvzFv9sLtq7kQEcyI=
github.com/ssvlabs/eth2-key-manager v1.5.3/go.mod h1:yeUzAP+SBJXgeXPiGBrLeLuHIQCpeJZV7Jz3Fwzm/zk=
github.com/ssvlabs/eth2-key-manager v1.5.4 h1:TnKbS3HeWE+txUyxf0n0EhSIxeFWSKpLwm5VfmMeegw=
github.com/ssvlabs/eth2-key-manager v1.5.4/go.mod h1:yeUzAP+SBJXgeXPiGBrLeLuHIQCpeJZV7Jz3Fwzm/zk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
Expand Down
5 changes: 3 additions & 2 deletions result.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
eth_crypto "github.com/ethereum/go-ethereum/crypto"
"github.com/herumi/bls-eth-go-binary/bls"
"github.com/ssvlabs/dkg-spec/crypto"
"github.com/ssvlabs/eth2-key-manager/core"
)

func BuildResult(
Expand Down Expand Up @@ -125,7 +126,7 @@ func ValidateResults(
if err != nil {
return nil, nil, nil, err
}
network, err := crypto.GetNetworkByFork(fork)
network, err := core.NetworkFromForkVersion(fork)
if err != nil {
return nil, nil, nil, err
}
Expand Down Expand Up @@ -286,7 +287,7 @@ func VerifyPartialDepositDataSignatures(
pks []*bls.PublicKey,
amount phase0.Gwei,
) error {
network, err := crypto.GetNetworkByFork(fork)
network, err := core.NetworkFromForkVersion(fork)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion testing/fixtures/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

spec "github.com/ssvlabs/dkg-spec"
"github.com/ssvlabs/dkg-spec/crypto"
"github.com/ssvlabs/eth2-key-manager/core"

"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -116,7 +117,7 @@ func TestSignNonce(t *testing.T) {
}

func TestSignDeposit(t *testing.T) {
network, err := crypto.GetNetworkByFork(TestFork)
network, err := core.NetworkFromForkVersion(TestFork)
require.NoError(t, err)
shareRoot, err := crypto.ComputeDepositMessageSigningRoot(network, &phase0.DepositMessage{
PublicKey: phase0.BLSPubKey(ShareSK(TestValidator13Operators).GetPublicKey().Serialize()),
Expand Down
Loading