Compare commits

...

1 Commits

Author SHA1 Message Date
Raul Jordan
a89a51af06 fix up via interface 2022-06-10 10:42:03 -04:00
6 changed files with 29 additions and 11 deletions

View File

@@ -12,7 +12,6 @@ import (
"github.com/prysmaticlabs/prysm/config/params" "github.com/prysmaticlabs/prysm/config/params"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives" types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1" ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/runtime/version"
"github.com/prysmaticlabs/prysm/time/slots" "github.com/prysmaticlabs/prysm/time/slots"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@@ -75,16 +74,10 @@ func ProcessProposerSlashing(
return nil, errors.Wrap(err, "could not verify proposer slashing") return nil, errors.Wrap(err, "could not verify proposer slashing")
} }
cfg := params.BeaconConfig() cfg := params.BeaconConfig()
var slashingQuotient uint64
switch { slashingQuotient, err := beaconState.MinSlashingPenaltyQuotient()
case beaconState.Version() == version.Phase0: if err != nil {
slashingQuotient = cfg.MinSlashingPenaltyQuotient return nil, err
case beaconState.Version() == version.Altair:
slashingQuotient = cfg.MinSlashingPenaltyQuotientAltair
case beaconState.Version() == version.Bellatrix:
slashingQuotient = cfg.MinSlashingPenaltyQuotientBellatrix
default:
return nil, errors.New("unknown state version")
} }
beaconState, err = slashFunc(ctx, beaconState, slashing.Header_1.Header.ProposerIndex, slashingQuotient, cfg.ProposerRewardQuotient) beaconState, err = slashFunc(ctx, beaconState, slashing.Header_1.Header.ProposerIndex, slashingQuotient, cfg.ProposerRewardQuotient)
if err != nil { if err != nil {

View File

@@ -26,6 +26,7 @@ type BeaconState interface {
// SpecParametersProvider provides fork-specific configuration parameters as // SpecParametersProvider provides fork-specific configuration parameters as
// defined in the consensus specification for the beacon chain. // defined in the consensus specification for the beacon chain.
type SpecParametersProvider interface { type SpecParametersProvider interface {
MinSlashingPenaltyQuotient() (uint64, error)
InactivityPenaltyQuotient() (uint64, error) InactivityPenaltyQuotient() (uint64, error)
ProportionalSlashingMultiplier() (uint64, error) ProportionalSlashingMultiplier() (uint64, error)
} }

View File

@@ -28,3 +28,15 @@ func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) {
} }
return 0, errNotSupported("InactivityPenaltyQuotient()", b.version) return 0, errNotSupported("InactivityPenaltyQuotient()", b.version)
} }
func (b *BeaconState) MinSlashingPenaltyQuotient() (uint64, error) {
switch b.version {
case version.Bellatrix:
return params.BeaconConfig().MinSlashingPenaltyQuotientBellatrix, nil
case version.Altair:
return params.BeaconConfig().MinSlashingPenaltyQuotientAltair, nil
case version.Phase0:
return params.BeaconConfig().MinSlashingPenaltyQuotient, nil
}
return 0, errNotSupported("MinSlashingPenaltyQuotient()", b.version)
}

View File

@@ -9,3 +9,7 @@ func (b *BeaconState) ProportionalSlashingMultiplier() (uint64, error) {
func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) { func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) {
return params.BeaconConfig().InactivityPenaltyQuotient, nil return params.BeaconConfig().InactivityPenaltyQuotient, nil
} }
func (b *BeaconState) MinSlashingPenaltyQuotient() (uint64, error) {
return params.BeaconConfig().MinSlashingPenaltyQuotient, nil
}

View File

@@ -9,3 +9,7 @@ func (b *BeaconState) ProportionalSlashingMultiplier() (uint64, error) {
func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) { func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) {
return params.BeaconConfig().InactivityPenaltyQuotientAltair, nil return params.BeaconConfig().InactivityPenaltyQuotientAltair, nil
} }
func (b *BeaconState) MinSlashingPenaltyQuotient() (uint64, error) {
return params.BeaconConfig().MinSlashingPenaltyQuotientAltair, nil
}

View File

@@ -9,3 +9,7 @@ func (b *BeaconState) ProportionalSlashingMultiplier() (uint64, error) {
func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) { func (b *BeaconState) InactivityPenaltyQuotient() (uint64, error) {
return params.BeaconConfig().InactivityPenaltyQuotientBellatrix, nil return params.BeaconConfig().InactivityPenaltyQuotientBellatrix, nil
} }
func (b *BeaconState) MinSlashingPenaltyQuotient() (uint64, error) {
return params.BeaconConfig().MinSlashingPenaltyQuotientBellatrix, nil
}