mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Fix VC DB conversion when no proposer settings is defined and add Experimental
flag in the --enable-minimal-slashing-protection
help. (#13691)
* VC: Allow DB conversion without proposer settings. * `enable-minimal-slashing-protection` flag: Add `Experimental warning`.
This commit is contained in:
parent
ee9274a9bc
commit
21775eed52
@ -97,7 +97,7 @@ var (
|
||||
}
|
||||
EnableMinimalSlashingProtection = &cli.BoolFlag{
|
||||
Name: "enable-minimal-slashing-protection",
|
||||
Usage: "Enables the minimal slashing protection. See EIP-3076 for more details.",
|
||||
Usage: "(Experimental): Enables the minimal slashing protection. See EIP-3076 for more details.",
|
||||
}
|
||||
enableDoppelGangerProtection = &cli.BoolFlag{
|
||||
Name: "enable-doppelganger",
|
||||
|
@ -124,15 +124,20 @@ func ConvertDatabase(ctx context.Context, sourceDataDir string, targetDataDir st
|
||||
// -----------------
|
||||
// Get the proposer settings.
|
||||
proposerSettings, err := sourceDatabase.ProposerSettings(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get proposer settings from source database")
|
||||
}
|
||||
|
||||
switch err {
|
||||
case nil:
|
||||
// Save the proposer settings.
|
||||
if err := targetDatabase.SaveProposerSettings(ctx, proposerSettings); err != nil {
|
||||
return errors.Wrap(err, "could not save proposer settings")
|
||||
}
|
||||
|
||||
case kv.ErrNoProposerSettingsFound, filesystem.ErrNoProposerSettingsFound:
|
||||
// Nothing to do.
|
||||
default:
|
||||
return errors.Wrap(err, "could not get proposer settings from source database")
|
||||
}
|
||||
|
||||
// Attestations
|
||||
// ------------
|
||||
// Get all public keys that have attested.
|
||||
|
@ -49,7 +49,8 @@ func TestDB_ConvertDatabase(t *testing.T) {
|
||||
defaultFeeRecipient := getFeeRecipientFromString(t, defaultFeeRecipientString)
|
||||
customFeeRecipient := getFeeRecipientFromString(t, customFeeRecipientString)
|
||||
|
||||
for _, minimalToComplete := range []bool{false, true} {
|
||||
for _, minimalToComplete := range [...]bool{false, true} {
|
||||
for _, withProposerSettings := range [...]bool{false, true} {
|
||||
t.Run(fmt.Sprintf("minimalToComplete=%v", minimalToComplete), func(t *testing.T) {
|
||||
// Create signing root
|
||||
signingRoot := [fieldparams.RootLength]byte{}
|
||||
@ -99,8 +100,10 @@ func TestDB_ConvertDatabase(t *testing.T) {
|
||||
|
||||
// Save the proposer settings.
|
||||
var relays []string = nil
|
||||
expectedProposerSettings := &proposer.Settings{}
|
||||
|
||||
expectedProposerSettings := &proposer.Settings{
|
||||
if withProposerSettings {
|
||||
expectedProposerSettings = &proposer.Settings{
|
||||
ProposeConfig: map[[fieldparams.BLSPubkeyLength]byte]*proposer.Option{
|
||||
pubkey1: {
|
||||
FeeRecipientConfig: &proposer.FeeRecipientConfig{
|
||||
@ -127,6 +130,7 @@ func TestDB_ConvertDatabase(t *testing.T) {
|
||||
|
||||
err = sourceDatabase.SaveProposerSettings(ctx, expectedProposerSettings)
|
||||
require.NoError(t, err, "could not save proposer settings")
|
||||
}
|
||||
|
||||
// Save some attestations.
|
||||
completeAttestations := []*ethpb.IndexedAttestation{
|
||||
@ -195,7 +199,7 @@ func TestDB_ConvertDatabase(t *testing.T) {
|
||||
require.NoError(t, err, "could not close source database")
|
||||
|
||||
// Source to target DB conversion.
|
||||
// ----------------------------------------
|
||||
// -------------------------------
|
||||
err = ConvertDatabase(ctx, datadir, datadir, minimalToComplete)
|
||||
require.NoError(t, err, "could not convert source to target database")
|
||||
|
||||
@ -224,10 +228,12 @@ func TestDB_ConvertDatabase(t *testing.T) {
|
||||
require.NoError(t, err, "could not get graffiti ordered index from target database")
|
||||
require.Equal(t, expectedGraffitiOrderedIndex, actualGraffitiOrderedIndex, "graffiti ordered index should match")
|
||||
|
||||
if withProposerSettings {
|
||||
// Check the proposer settings.
|
||||
actualProposerSettings, err := targetDatabase.ProposerSettings(ctx)
|
||||
require.NoError(t, err, "could not get proposer settings from target database")
|
||||
require.DeepEqual(t, expectedProposerSettings, actualProposerSettings, "proposer settings should match")
|
||||
}
|
||||
|
||||
// Check the attestations.
|
||||
actualAttestationRecords, err := targetDatabase.AttestationHistoryForPubKey(ctx, pubkey1)
|
||||
@ -262,4 +268,5 @@ func TestDB_ConvertDatabase(t *testing.T) {
|
||||
require.Equal(t, false, existing, "source database should not exist")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user