Fix block proposals in the REST validator client (#13116)

* Fix block proposals in the REST validator client

* fix graffiti test

* return empty graffiti

* fallback to old endpoints

* logs

* handle 404

* everything passes

* review from James

* log undecoded value

* test fixes and additions

---------

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Radosław Kapka
2023-10-30 19:15:45 +01:00
committed by GitHub
parent 047613069e
commit 2ef0b3526d
11 changed files with 2612 additions and 226 deletions

View File

@@ -411,7 +411,7 @@ func signVoluntaryExit(
func (v *validator) getGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error) {
// When specified, default graffiti from the command line takes the first priority.
if len(v.graffiti) != 0 {
return v.graffiti, nil
return bytesutil.PadTo(v.graffiti, 32), nil
}
if v.graffitiStruct == nil {
@@ -421,11 +421,11 @@ func (v *validator) getGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubk
// When specified, individual validator specified graffiti takes the second priority.
idx, err := v.validatorClient.ValidatorIndex(ctx, &ethpb.ValidatorIndexRequest{PublicKey: pubKey[:]})
if err != nil {
return []byte{}, err
return nil, err
}
g, ok := v.graffitiStruct.Specific[idx.Index]
if ok {
return []byte(g), nil
return bytesutil.PadTo([]byte(g), 32), nil
}
// When specified, a graffiti from the ordered list in the file take third priority.
@@ -436,7 +436,7 @@ func (v *validator) getGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubk
if err != nil {
return nil, errors.Wrap(err, "failed to update graffiti ordered index")
}
return []byte(graffiti), nil
return bytesutil.PadTo([]byte(graffiti), 32), nil
}
// When specified, a graffiti from the random list in the file take fourth priority.
@@ -444,12 +444,12 @@ func (v *validator) getGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubk
r := rand.NewGenerator()
r.Seed(time.Now().Unix())
i := r.Uint64() % uint64(len(v.graffitiStruct.Random))
return []byte(v.graffitiStruct.Random[i]), nil
return bytesutil.PadTo([]byte(v.graffitiStruct.Random[i]), 32), nil
}
// Finally, default graffiti if specified in the file will be used.
if v.graffitiStruct.Default != "" {
return []byte(v.graffitiStruct.Default), nil
return bytesutil.PadTo([]byte(v.graffitiStruct.Default), 32), nil
}
return []byte{}, nil