Compare commits

...

1 Commits

Author SHA1 Message Date
Raul Jordan
c245c55dc5 add in interfaces 2022-04-16 01:09:26 -04:00
9 changed files with 122 additions and 0 deletions

View File

@@ -270,6 +270,7 @@ func AttestationsDelta(beaconState state.BeaconState, bal *precompute.Balance, v
// Modified in Altair and Bellatrix.
var inactivityDenominator uint64
bias := cfg.InactivityScoreBias
inactivityDenominator := bias * beaconState.InactivityPenaltyQuotient()
switch beaconState.Version() {
case version.Altair:
inactivityDenominator = bias * cfg.InactivityPenaltyQuotientAltair

View File

@@ -16,12 +16,19 @@ import (
type BeaconState interface {
ReadOnlyBeaconState
WriteOnlyBeaconState
SpecConstantsProvider
Copy() BeaconState
HashTreeRoot(ctx context.Context) ([32]byte, error)
FutureForkStub
StateProver
}
// SpecConstantsProvider defines a struct which can provide varying configuration
// values depending on fork versions, such as the beacon state.
type SpecConstantsProvider interface {
InactivityPenaltyQuotient() (uint64, error)
}
// StateProver defines the ability to create Merkle proofs for beacon state fields.
type StateProver interface {
FinalizedRootProof(ctx context.Context) ([][]byte, error)

View File

@@ -0,0 +1,7 @@
package v1
import "github.com/prysmaticlabs/prysm/config/params"
func (b *BeaconState) InactivityPenaltyQuotient() uint64 {
return params.BeaconConfig().InactivityPenaltyQuotient
}

View File

@@ -0,0 +1,7 @@
package v2
import "github.com/prysmaticlabs/prysm/config/params"
func (b *BeaconState) InactivityPenaltyQuotient() uint64 {
return params.BeaconConfig().InactivityPenaltyQuotientAltair
}

View File

@@ -0,0 +1,7 @@
package v3
import "github.com/prysmaticlabs/prysm/config/params"
func (b *BeaconState) InactivityPenaltyQuotient() uint64 {
return params.BeaconConfig().InactivityPenaltyQuotientBellatrix
}

View File

@@ -0,0 +1,7 @@
package v1
import "github.com/prysmaticlabs/prysm/config/params"
func (b *BeaconState) InactivityPenaltyQuotient() uint64 {
return params.BeaconConfig().InactivityPenaltyQuotient
}

View File

@@ -0,0 +1,7 @@
package v1
import "github.com/prysmaticlabs/prysm/config/params"
func (b *BeaconState) InactivityPenaltyQuotient() uint64 {
return params.BeaconConfig().InactivityPenaltyQuotientAltair
}

View File

@@ -0,0 +1,7 @@
package v1
import "github.com/prysmaticlabs/prysm/config/params"
func (b *BeaconState) InactivityPenaltyQuotient() uint64 {
return params.BeaconConfig().InactivityPenaltyQuotientBellatrix
}

View File

@@ -0,0 +1,72 @@
package consensus_types
import (
ssz "github.com/ferranbt/fastssz"
types "github.com/prysmaticlabs/eth2-types"
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"google.golang.org/protobuf/proto"
)
// SSZItem defines a struct which provides Marshal,
// Unmarshal, and HashTreeRoot SSZ operations.
type SSZItem interface {
ssz.Marshaler
ssz.Unmarshaler
ssz.HashRoot
}
// Container defines the base methods required for a consensus
// data structure used in Prysm, containing utilities for SSZ
// as well as conversion methods to a protobuf representation for use
// with Prysm's gRPC API.
type Container interface {
SSZItem
IsNil() bool
Proto() proto.Message
FromProto(m proto.Message)
}
// SignedBeaconBlock describes the method set of a signed beacon block.
type SignedBeaconBlock interface {
Container
Block() BeaconBlock
Signature() []byte
Copy() SignedBeaconBlock
PbGenericBlock() (*ethpb.GenericSignedBeaconBlock, error)
PbPhase0Block() (*ethpb.SignedBeaconBlock, error)
PbAltairBlock() (*ethpb.SignedBeaconBlockAltair, error)
PbBellatrixBlock() (*ethpb.SignedBeaconBlockBellatrix, error)
PbBlindedBellatrixBlock() (*ethpb.SignedBlindedBeaconBlockBellatrix, error)
Header() (*ethpb.SignedBeaconBlockHeader, error)
}
// BeaconBlock describes an interface which states the methods
// employed by an object that is a beacon block.
type BeaconBlock interface {
Container
Slot() types.Slot
ProposerIndex() types.ValidatorIndex
ParentRoot() []byte
StateRoot() []byte
Body() BeaconBlockBody
AsSignRequestObject() validatorpb.SignRequestObject
}
// BeaconBlockBody describes the method set employed by an object
// that is a beacon block body.
type BeaconBlockBody interface {
Container
RandaoReveal() []byte
Eth1Data() *ethpb.Eth1Data
Graffiti() []byte
ProposerSlashings() []*ethpb.ProposerSlashing
AttesterSlashings() []*ethpb.AttesterSlashing
Attestations() []*ethpb.Attestation
Deposits() []*ethpb.Deposit
VoluntaryExits() []*ethpb.SignedVoluntaryExit
SyncAggregate() (*ethpb.SyncAggregate, error)
ExecutionPayload() (*enginev1.ExecutionPayload, error)
ExecutionPayloadHeader() (*ethpb.ExecutionPayloadHeader, error)
}