db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultChainID                      uint64 = 0x90de5e7
	DefaultDepositContractAddressString string = "0xde905175eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
)
View Source
const (
	FarFutureEpoch  uint64 = 0xffffffffffffffff
	StartingBalance uint64 = 32e9
)

Variables

View Source
var (
	// Default config
	DefaultDepositContractAddress common.Address = common.HexToAddress(DefaultDepositContractAddressString)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Basic settings
	ChainID                      uint64
	SecondsPerSlot               uint64
	SlotsPerEpoch                uint64
	EpochsPerSyncCommitteePeriod uint64
	DepositContract              common.Address

	// Genesis info
	GenesisTime           time.Time
	GenesisForkVersion    []byte
	GenesisValidatorsRoot []byte

	// Altair info
	AltairForkVersion []byte
	AltairForkEpoch   uint64

	// Bellatrix info
	BellatrixForkVersion []byte
	BellatrixForkEpoch   uint64

	// Capella info
	CapellaForkVersion []byte
	CapellaForkEpoch   uint64

	// Deneb info
	DenebForkVersion []byte
	DenebForkEpoch   uint64
}

Basic Beacon Chain configuration

func NewDefaultConfig

func NewDefaultConfig() *Config

Creates a new default config instance

func (*Config) Clone

func (c *Config) Clone() *Config

Clones a config into a new instance

type Database

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

Beacon mock database

func NewDatabase

func NewDatabase(logger *slog.Logger) *Database

Create a new database instance

func (*Database) AddValidator

func (db *Database) AddValidator(pubkey beacon.ValidatorPubkey, withdrawalCredentials common.Hash) (*Validator, error)

Add a new validator to the database. Returns an error if the validator already exists.

func (*Database) Clone

func (db *Database) Clone() *Database

Clone the database into a new instance

func (*Database) GetAllValidators

func (db *Database) GetAllValidators() []*Validator

Get all validators

func (*Database) GetCurrentSlot

func (db *Database) GetCurrentSlot() uint64

Get the latest slot

func (*Database) GetHighestSlot

func (db *Database) GetHighestSlot() uint64

Get the highest slot on the chain

func (*Database) GetValidatorByIndex

func (db *Database) GetValidatorByIndex(index uint) *Validator

Get a validator by its index. Returns nil if it doesn't exist.

func (*Database) GetValidatorByPubkey

func (db *Database) GetValidatorByPubkey(pubkey beacon.ValidatorPubkey) *Validator

Get a validator by its pubkey. Returns nil if it doesn't exist.

func (*Database) SetCurrentSlot

func (db *Database) SetCurrentSlot(slot uint64)

Set the current slot - this will also update the highest slot if the new slot is higher

type Validator

type Validator struct {
	Pubkey                     beacon.ValidatorPubkey
	Index                      uint64
	WithdrawalCredentials      common.Hash
	Balance                    uint64
	Status                     beacon.ValidatorState
	EffectiveBalance           uint64
	Slashed                    bool
	ActivationEligibilityEpoch uint64
	ActivationEpoch            uint64
	ExitEpoch                  uint64
	WithdrawableEpoch          uint64
}

func NewValidator

func NewValidator(pubkey beacon.ValidatorPubkey, withdrawalCredentials common.Hash, index uint64) *Validator

func (*Validator) Clone

func (v *Validator) Clone() *Validator

func (*Validator) GetValidatorMeta

func (v *Validator) GetValidatorMeta() client.Validator

func (*Validator) SetBalance

func (v *Validator) SetBalance(balanceGwei uint64)

func (*Validator) SetStatus

func (v *Validator) SetStatus(status beacon.ValidatorState)

func (*Validator) Slash

func (v *Validator) Slash(penaltyGwei uint64) error

Jump to

Keyboard shortcuts

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