Skip to content

Commit

Permalink
update holesky support
Browse files Browse the repository at this point in the history
  • Loading branch information
Lior Rutenberg committed Oct 22, 2023
1 parent 789b108 commit e2b8264
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
14 changes: 14 additions & 0 deletions core/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ func NetworkFromString(n string) Network {
return PyrmontNetwork
case string(PraterNetwork):
return PraterNetwork
case string(HoleskyNetwork):
return HoleskyNetwork
case string(MainNetwork):
return MainNetwork
default:
Expand All @@ -32,6 +34,8 @@ func (n Network) GenesisForkVersion() phase0.Version {
return phase0.Version{0, 0, 32, 9}
case PraterNetwork:
return phase0.Version{0x00, 0x00, 0x10, 0x20}
case HoleskyNetwork:
return phase0.Version{0x01, 0x01, 0x70, 0x00}
case MainNetwork:
return phase0.Version{0, 0, 0, 0}
default:
Expand All @@ -47,6 +51,9 @@ func (n Network) GenesisValidatorsRoot() phase0.Root {
case PraterNetwork:
rootBytes, _ := hex.DecodeString("043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb")
copy(genValidatorsRoot[:], rootBytes)
case HoleskyNetwork:
rootBytes, _ := hex.DecodeString("9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1")
copy(genValidatorsRoot[:], rootBytes)
case MainNetwork:
rootBytes, _ := hex.DecodeString("4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95")
copy(genValidatorsRoot[:], rootBytes)
Expand All @@ -63,6 +70,8 @@ func (n Network) DepositContractAddress() string {
return "0x8c5fecdC472E27Bc447696F431E425D02dd46a8c"
case PraterNetwork:
return "0xff50ed3d0ec03ac01d4c79aad74928bff48a7b2b"
case HoleskyNetwork:
return "0x4242424242424242424242424242424242424242"
case MainNetwork:
return "0x00000000219ab540356cBB839Cbe05303d7705Fa"
default:
Expand All @@ -83,6 +92,8 @@ func (n Network) MinGenesisTime() uint64 {
return 1605700807
case PraterNetwork:
return 1616508000
case HoleskyNetwork:
return 1695902400
case MainNetwork:
return 1606824023
default:
Expand Down Expand Up @@ -134,6 +145,9 @@ const (
// PraterNetwork represents the Prater test network.
PraterNetwork Network = "prater"

// HoleskyNetwork represents the Holesky test network.
HoleskyNetwork Network = "holesky"

// MainNetwork represents the main network.
MainNetwork Network = "mainnet"
)
2 changes: 1 addition & 1 deletion eth1_deposit/eth1_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (

// 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
return network == core.PyrmontNetwork || network == core.PraterNetwork || network == core.HoleskyNetwork || network == core.MainNetwork
}

// DepositData is basically copied from https://github.com/prysmaticlabs/prysm/blob/master/shared/keystore/deposit_input.go
Expand Down
63 changes: 59 additions & 4 deletions eth1_deposit/eth1_deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,65 @@ func TestPraterDepositData(t *testing.T) {
{
network: core.PraterNetwork,
validatorPrivKey: _ignoreErr(hex.DecodeString("175db1c5411459893301c3f2ebe740e5da07db8f17c2df4fa0be6d31a48a4f79")),
withdrawalPubKey: _ignoreErr(hex.DecodeString("b3d50de8d77299da8d830de1edfb34d3ce03c1941846e73870bb33f6de7b8a01383f6b32f55a1d038a4ddcb21a765194")),
expectedWithdrawalCredentials: _ignoreErr(hex.DecodeString("006029659d86cf9f19d53030273372c84b1912d0633cb15381a75cb92850f03a")),
expectedSig: _ignoreErr(hex.DecodeString("a2bcc9d2ac82062cb9806b761e8e8d405963620b8f5356fa70fe543812bf07c3031546482c737401ba1dec01d5690d0600c900ebe7dca5699e804ff4441ed4e25789b389bcdc69c6f4dc25ef40e5694f6de7723bda359c5c2a54e05ae90290ca")),
expectedRoot: _ignoreErr(hex.DecodeString("d243130779e16b4352bb8d2c80765334b4a7bdd4bc42356b37e42380dc47dac5")),
withdrawalPubKey: _ignoreErr(hex.DecodeString("8d176708b908f288cc0e9d43f75674e73c0db94026822c5ce2c3e0f9e773c9ee95fdba824302f1208c225b0ed2d54154")),
expectedWithdrawalCredentials: _ignoreErr(hex.DecodeString("005b55a6c968852666b132a80f53712e5097b0fca86301a16992e695a8e86f16")),
expectedSig: _ignoreErr(hex.DecodeString("a88d0fd588836c5756ec7f2fe2bc8b6fc5723d018c8d31c8f42b239ac6cf7c2f9ae129caafaebb5f2f25e7821678b41819bc24f6eeebe0d8196cea13581f72ac501f3e7e9e4bc596e6a545ac109fb2ff1d7eb03923454dc5258718b43427a757")),
expectedRoot: _ignoreErr(hex.DecodeString("aa940a26af67a676bcd807b0fd3f39aadbfc6862e380e115051683e1fccc0171")),
},
}

require.NoError(t, core.InitBLS())

for _, test := range tests {
t.Run(test.testname, func(t *testing.T) {
val, err := core.NewHDKeyFromPrivateKey(test.validatorPrivKey, "")
require.NoError(t, err)

// create data
depositData, root, err := DepositData(
val,
test.withdrawalPubKey,
test.network,
MaxEffectiveBalanceInGwei,
)
VerifyOperation(t, depositData, test.network)

require.NoError(t, err)
require.Equal(t, val.PublicKey().SerializeToHexStr(), strings.TrimPrefix(depositData.PublicKey.String(), "0x"))
require.Equal(t, test.expectedWithdrawalCredentials, depositData.WithdrawalCredentials)
require.Equal(t, MaxEffectiveBalanceInGwei, depositData.Amount)
require.Equal(t, test.expectedRoot, root[:], hex.EncodeToString(root[:]))
require.Equal(t, hex.EncodeToString(test.expectedSig), strings.TrimPrefix(depositData.Signature.String(), "0x"))

fmt.Printf("pubkey: %s\n", hex.EncodeToString(depositData.PublicKey[:]))
fmt.Printf("WithdrawalCredentials: %s\n", hex.EncodeToString(depositData.WithdrawalCredentials))
fmt.Printf("Amount: %d\n", depositData.Amount)
fmt.Printf("root: %s\n", hex.EncodeToString(root[:]))
fmt.Printf("sig: %s\n", hex.EncodeToString(depositData.Signature[:]))

})
}
}

// tested against eth2.0-deposit-cli V1.1.0
// Mnemonic: sphere attract wide clown fire balcony dance maple sphere seat design dentist eye orbit diet apart noise cinnamon wealth magic inject witness dress divorce
func TestHoleskyDepositData(t *testing.T) {
tests := []struct {
network core.Network
testname string
validatorPrivKey []byte
withdrawalPubKey []byte
expectedWithdrawalCredentials []byte
expectedSig []byte
expectedRoot []byte
}{
{
network: core.HoleskyNetwork,
validatorPrivKey: _ignoreErr(hex.DecodeString("175db1c5411459893301c3f2ebe740e5da07db8f17c2df4fa0be6d31a48a4f79")),
withdrawalPubKey: _ignoreErr(hex.DecodeString("8d176708b908f288cc0e9d43f75674e73c0db94026822c5ce2c3e0f9e773c9ee95fdba824302f1208c225b0ed2d54154")),
expectedWithdrawalCredentials: _ignoreErr(hex.DecodeString("005b55a6c968852666b132a80f53712e5097b0fca86301a16992e695a8e86f16")),
expectedSig: _ignoreErr(hex.DecodeString("836bccc57ceb05353119814a025d8a83a271d6724d1eb760d1c806e9de15a919f389cd6235e6a6b1bda4cfd3c236882c1858bcf4b3141d3a3fba73c158ce59d28adcf2e67dbf05dc00d944a47cfd8db08a8de7a145f2f4c6888714be77b410e2")),
expectedRoot: _ignoreErr(hex.DecodeString("75e81e6fde731d5a2f5360af3baca7d1cb599ed10288df3bd7988e9f7ad8c929")),
},
}

Expand Down

0 comments on commit e2b8264

Please sign in to comment.