mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 03:51:29 +00:00
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:
parent
af16c71d6e
commit
2a408a0dd8
@ -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
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user