don't send pre-genesis signed validator registration objects to relayers (#12847)

Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
This commit is contained in:
Bharath Vedartham 2023-09-10 00:23:02 +05:30 committed by GitHub
parent af16c71d6e
commit 2a408a0dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View File

@ -1143,6 +1143,10 @@ func (v *validator) buildPrepProposerReqs(ctx context.Context, pubkeys [][fieldp
func (v *validator) buildSignedRegReqs(ctx context.Context, pubkeys [][fieldparams.BLSPubkeyLength]byte /* only active pubkeys */, signer iface.SigningFunc) ([]*ethpb.SignedValidatorRegistrationV1, error) {
var signedValRegRegs []*ethpb.SignedValidatorRegistrationV1
// if the timestamp is pre-genesis, don't create registrations
if v.genesisTime > uint64(time.Now().UTC().Unix()) {
return signedValRegRegs, nil
}
for i, k := range pubkeys {
feeRecipient := common.HexToAddress(params.BeaconConfig().EthBurnAddressHex)
gasLimit := params.BeaconConfig().DefaultBuilderGasLimit

View File

@ -2394,3 +2394,61 @@ func TestValidator_buildSignedRegReqs_SignerOnError(t *testing.T) {
assert.Equal(t, 0, len(actual))
}
func TestValidator_buildSignedRegReqs_TimestampBeforeGenesis(t *testing.T) {
// Public keys
pubkey1 := getPubkeyFromString(t, "0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
// Fee recipients
feeRecipient1 := getFeeRecipientFromString(t, "0x0000000000000000000000000000000000000000")
defaultFeeRecipient := getFeeRecipientFromString(t, "0xdddddddddddddddddddddddddddddddddddddddd")
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctx := context.Background()
client := validatormock.NewMockValidatorClient(ctrl)
signature := blsmock.NewMockSignature(ctrl)
v := validator{
signedValidatorRegistrations: map[[48]byte]*ethpb.SignedValidatorRegistrationV1{},
validatorClient: client,
genesisTime: uint64(time.Now().UTC().Unix() + 1000),
proposerSettings: &validatorserviceconfig.ProposerSettings{
DefaultConfig: &validatorserviceconfig.ProposerOption{
FeeRecipientConfig: &validatorserviceconfig.FeeRecipientConfig{
FeeRecipient: defaultFeeRecipient,
},
BuilderConfig: &validatorserviceconfig.BuilderConfig{
Enabled: true,
GasLimit: 9999,
},
},
ProposeConfig: map[[48]byte]*validatorserviceconfig.ProposerOption{
pubkey1: {
FeeRecipientConfig: &validatorserviceconfig.FeeRecipientConfig{
FeeRecipient: feeRecipient1,
},
BuilderConfig: &validatorserviceconfig.BuilderConfig{
Enabled: true,
GasLimit: 1111,
},
},
},
},
pubkeyToValidatorIndex: make(map[[48]byte]primitives.ValidatorIndex),
}
pubkeys := [][fieldparams.BLSPubkeyLength]byte{pubkey1}
var signer = func(_ context.Context, _ *validatorpb.SignRequest) (bls.Signature, error) {
return signature, nil
}
v.pubkeyToValidatorIndex[pubkey1] = primitives.ValidatorIndex(1)
actual, err := v.buildSignedRegReqs(ctx, pubkeys, signer)
require.NoError(t, err)
assert.Equal(t, 0, len(actual))
}