Skip to content
Open
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
3 changes: 3 additions & 0 deletions changelog/maradini77_patch-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Prevent validator service from starting with empty Beacon API host lists by filtering and validating endpoints.
16 changes: 14 additions & 2 deletions validator/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ func (v *ValidatorService) Start() {
return
}

u := strings.ReplaceAll(v.conn.GetBeaconApiUrl(), " ", "")
hosts := strings.Split(u, ",")
hosts := sanitizeBeaconAPIHosts(v.conn.GetBeaconApiUrl())
if len(hosts) == 0 {
log.WithError(err).Error("No API hosts provided")
return
Expand Down Expand Up @@ -376,6 +375,19 @@ func ConstructDialOptions(
return dialOpts
}

func sanitizeBeaconAPIHosts(raw string) []string {
u := strings.ReplaceAll(raw, " ", "")
rawHosts := strings.Split(u, ",")
hosts := make([]string, 0, len(rawHosts))
for _, host := range rawHosts {
if host == "" {
continue
}
hosts = append(hosts, host)
}
return hosts
}

func (v *ValidatorService) Graffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
if v.validator == nil {
return nil, errors.New("validator is unavailable")
Expand Down