Skip to content

Commit fa2426b

Browse files
authored
Handle wrong withdrawal credentials (#190)
1 parent 09f446d commit fa2426b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

oracle/onchain_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package oracle
22

33
import (
44
"context"
5+
"encoding/hex"
56
"encoding/json"
67
"fmt"
78
"io/ioutil"
@@ -83,6 +84,29 @@ func Test_FetchFromExecution(t *testing.T) {
8384
//require.Equal(t, expectedValue, balance)
8485
}
8586

87+
func Test_GetValidator(t *testing.T) {
88+
if skip {
89+
t.Skip("Skipping test")
90+
}
91+
92+
var cfgOnchain = &config.CliConfig{
93+
ConsensusEndpoint: "http://127.0.0.1:3500",
94+
ExecutionEndpoint: "http://127.0.0.1:8545",
95+
}
96+
onChain, err := NewOnchain(cfgOnchain, nil)
97+
require.NoError(t, err)
98+
99+
vals, err := onChain.GetFinalizedValidators()
100+
require.NoError(t, err)
101+
102+
for _, valEl := range vals {
103+
fmt.Println(valEl.Index)
104+
fmt.Println("raw: ", hex.EncodeToString(valEl.Validator.WithdrawalCredentials[:]))
105+
a, b := GetWithdrawalAndType(valEl)
106+
fmt.Println(valEl.Index, " ", hex.EncodeToString(valEl.Validator.WithdrawalCredentials[:]), " ", a, " ", b)
107+
}
108+
}
109+
86110
func Test_IsAddressWhitelisted(t *testing.T) {
87111
if skip {
88112
t.Skip("Skipping test")

oracle/oracle.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,13 @@ func GetWithdrawalAndType(validator *v1.Validator) (string, WithdrawalType) {
13361336
} else if utils.IsEth1Type(withdrawalCred) {
13371337
return "0x" + withdrawalCred[24:], Eth1Withdrawal
13381338
}
1339-
log.Fatal("withdrawal credentials are not a valid type: ", withdrawalCred)
1339+
// can happen if a validator sets wrong withdrawal credentials (not very likely)
1340+
// aka not respecting the 0x00 or 0x000000000000000000000000 prefixes
1341+
// only concerning if the validator is subscribed to the pool
1342+
log.WithFields(log.Fields{
1343+
"WithdrawalCredentials": withdrawalCred,
1344+
"ValidatorIndex": validator.Index,
1345+
}).Warn("withdrawal credentials are not valid, leaving empty")
13401346
return "", 0
13411347
}
13421348

0 commit comments

Comments
 (0)