slashings

package
v1.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2021 License: GPL-3.0 Imports: 17 Imported by: 40

Documentation

Overview

Package slashings defines an in-memory pool of received slashing events by the beacon node, handling their lifecycle and performing integrity checks before serving them as objects for validators to include in blocks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PendingAttesterSlashing

type PendingAttesterSlashing struct {
	// contains filtered or unexported fields
}

PendingAttesterSlashing represents an attester slashing in the operation pool. Allows for easy binary searching of included validator indexes.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is a concrete implementation of PoolManager.

func NewPool

func NewPool() *Pool

NewPool returns an initialized attester slashing and proposer slashing pool.

func (*Pool) InsertAttesterSlashing

func (p *Pool) InsertAttesterSlashing(
	ctx context.Context,
	state iface.ReadOnlyBeaconState,
	slashing *ethpb.AttesterSlashing,
) error

InsertAttesterSlashing into the pool. This method is a no-op if the attester slashing already exists in the pool, has been included into a block recently, or the validator is already exited.

func (*Pool) InsertProposerSlashing

func (p *Pool) InsertProposerSlashing(
	ctx context.Context,
	state iface.BeaconState,
	slashing *ethpb.ProposerSlashing,
) error

InsertProposerSlashing into the pool. This method is a no-op if the pending slashing already exists, has been included recently, the validator is already exited, or the validator was already slashed.

func (*Pool) MarkIncludedAttesterSlashing

func (p *Pool) MarkIncludedAttesterSlashing(as *ethpb.AttesterSlashing)

MarkIncludedAttesterSlashing is used when an attester slashing has been included in a beacon block. Every block seen by this node that contains proposer slashings should call this method to include the proposer slashings.

func (*Pool) MarkIncludedProposerSlashing

func (p *Pool) MarkIncludedProposerSlashing(ps *ethpb.ProposerSlashing)

MarkIncludedProposerSlashing is used when an proposer slashing has been included in a beacon block. Every block seen by this node that contains proposer slashings should call this method to include the proposer slashings.

func (*Pool) PendingAttesterSlashings

func (p *Pool) PendingAttesterSlashings(ctx context.Context, state iface.ReadOnlyBeaconState, noLimit bool) []*ethpb.AttesterSlashing

PendingAttesterSlashings returns attester slashings that are able to be included into a block. This method will return the amount of pending attester slashings for a block transition unless parameter `noLimit` is true to indicate the request is for noLimit pending items.

func (*Pool) PendingProposerSlashings

func (p *Pool) PendingProposerSlashings(ctx context.Context, state iface.ReadOnlyBeaconState, noLimit bool) []*ethpb.ProposerSlashing

PendingProposerSlashings returns proposer slashings that are able to be included into a block. This method will return the amount of pending proposer slashings for a block transition unless the `noLimit` parameter is set to true to indicate the request is for noLimit pending items.

type PoolManager added in v1.3.1

type PoolManager interface {
	PendingAttesterSlashings(ctx context.Context, state iface.ReadOnlyBeaconState, noLimit bool) []*ethpb.AttesterSlashing
	PendingProposerSlashings(ctx context.Context, state iface.ReadOnlyBeaconState, noLimit bool) []*ethpb.ProposerSlashing
	InsertAttesterSlashing(
		ctx context.Context,
		state iface.ReadOnlyBeaconState,
		slashing *ethpb.AttesterSlashing,
	) error
	InsertProposerSlashing(
		ctx context.Context,
		state iface.BeaconState,
		slashing *ethpb.ProposerSlashing,
	) error
	MarkIncludedAttesterSlashing(as *ethpb.AttesterSlashing)
	MarkIncludedProposerSlashing(ps *ethpb.ProposerSlashing)
}

PoolManager maintains a pool of pending and recently included attester and proposer slashings. This pool is used by proposers to insert data into new blocks.

type PoolMock added in v1.3.1

type PoolMock struct {
	PendingAttSlashings  []*ethpb.AttesterSlashing
	PendingPropSlashings []*ethpb.ProposerSlashing
}

PoolMock is a fake implementation of PoolManager.

func (*PoolMock) InsertAttesterSlashing added in v1.3.1

func (m *PoolMock) InsertAttesterSlashing(_ context.Context, _ iface.ReadOnlyBeaconState, slashing *ethpb.AttesterSlashing) error

InsertAttesterSlashing --

func (*PoolMock) InsertProposerSlashing added in v1.3.1

func (m *PoolMock) InsertProposerSlashing(_ context.Context, _ iface.BeaconState, slashing *ethpb.ProposerSlashing) error

InsertProposerSlashing --

func (*PoolMock) MarkIncludedAttesterSlashing added in v1.3.1

func (m *PoolMock) MarkIncludedAttesterSlashing(_ *ethpb.AttesterSlashing)

MarkIncludedAttesterSlashing --

func (*PoolMock) MarkIncludedProposerSlashing added in v1.3.1

func (m *PoolMock) MarkIncludedProposerSlashing(_ *ethpb.ProposerSlashing)

MarkIncludedProposerSlashing --

func (*PoolMock) PendingAttesterSlashings added in v1.3.1

func (m *PoolMock) PendingAttesterSlashings(_ context.Context, _ iface.ReadOnlyBeaconState, _ bool) []*ethpb.AttesterSlashing

PendingAttesterSlashings --

func (*PoolMock) PendingProposerSlashings added in v1.3.1

func (m *PoolMock) PendingProposerSlashings(_ context.Context, _ iface.ReadOnlyBeaconState, _ bool) []*ethpb.ProposerSlashing

PendingProposerSlashings --

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL