slashings

package
v5.0.1-rc.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

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 state.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 state.ReadOnlyBeaconState,
	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 state.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 state.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 PoolInserter

type PoolInserter interface {
	InsertAttesterSlashing(
		ctx context.Context,
		state state.ReadOnlyBeaconState,
		slashing *ethpb.AttesterSlashing,
	) error
	InsertProposerSlashing(
		ctx context.Context,
		state state.ReadOnlyBeaconState,
		slashing *ethpb.ProposerSlashing,
	) error
}

PoolInserter is capable of inserting new slashing objects into the operations pool.

type PoolManager

type PoolManager interface {
	PoolInserter
	PendingAttesterSlashings(ctx context.Context, state state.ReadOnlyBeaconState, noLimit bool) []*ethpb.AttesterSlashing
	PendingProposerSlashings(ctx context.Context, state state.ReadOnlyBeaconState, noLimit bool) []*ethpb.ProposerSlashing
	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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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