keeper

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_halo_valsync_keeper_valset_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	txConfig client.TxConfig,
	sKeeper *skeeper.Keeper,
	aKeeper *akeeper.Keeper,
) (Keeper, error)

func (Keeper) ActiveSetByHeight

func (k Keeper) ActiveSetByHeight(ctx context.Context, height uint64) (*types.ValidatorSetResponse, error)

ActiveSetByHeight returns the active cometBFT validator set at the given height. Zero power validators are skipped. Note: This MUST only be used for querying last few sets, it is inefficient otherwise. Note2: We could add an index, but that would be a waste of space.

func (Keeper) EndBlock

func (k Keeper) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error)

EndBlock has two responsibilities:

1. It wraps the staking module EndBlocker, intercepting the resulting validator updates and storing it as the next unattested validator set (to be attested to by current validator set before it can be sent to cometBFT).

2. It checks if any previously unattested validator set has been attested to, marks it as so, and returns its updates to pass along to cometBFT to activate that new set.

func (Keeper) InsertGenesisSet

func (k Keeper) InsertGenesisSet(ctx context.Context) error

InsertGenesisSet inserts the current genesis validator set into the database. This should only be called during InitGenesis AFTER the staking module's InitGenesis.

func (Keeper) ValidatorSet

type Validator

type Validator struct {
	Id       uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`                             // Auto-incremented ID
	ValsetId uint64 `protobuf:"varint,2,opt,name=valset_id,json=valsetId,proto3" json:"valset_id,omitempty"` // ValidatorSet ID to which this validator belongs
	PubKey   []byte `protobuf:"bytes,3,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"`        // Validator public key
	Power    int64  `protobuf:"varint,4,opt,name=power,proto3" json:"power,omitempty"`                       // Voting power of the validator
	Updated  bool   `protobuf:"varint,5,opt,name=updated,proto3" json:"updated,omitempty"`                   // Whether this validator was updated in this set (wrt previous set)
	// contains filtered or unexported fields
}

Validator represents a single validator in a validator set.

func (*Validator) Address

func (v *Validator) Address() (common.Address, error)

Address returns the validator ethereum 20 byte address.

func (*Validator) CometPubkey

func (v *Validator) CometPubkey() crypto.PublicKey

CometPubkey returns the cometBFT public key of the validator.

func (*Validator) Descriptor deprecated

func (*Validator) Descriptor() ([]byte, []int)

Deprecated: Use Validator.ProtoReflect.Descriptor instead.

func (*Validator) GetId

func (x *Validator) GetId() uint64

func (*Validator) GetPower

func (x *Validator) GetPower() int64

func (*Validator) GetPubKey

func (x *Validator) GetPubKey() []byte

func (*Validator) GetUpdated

func (x *Validator) GetUpdated() bool

func (*Validator) GetValsetId

func (x *Validator) GetValsetId() uint64

func (*Validator) ProtoMessage

func (*Validator) ProtoMessage()

func (*Validator) ProtoReflect

func (x *Validator) ProtoReflect() protoreflect.Message

func (*Validator) Reset

func (x *Validator) Reset()

func (*Validator) String

func (x *Validator) String() string

func (*Validator) ValidatorUpdate

func (v *Validator) ValidatorUpdate() abci.ValidatorUpdate

ValidatorUpdate returns the validator as a cometBFT validator update.

type ValidatorIdIndexKey

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

func (ValidatorIdIndexKey) WithId

type ValidatorIndexKey

type ValidatorIndexKey interface {
	// contains filtered or unexported methods
}

type ValidatorIterator

type ValidatorIterator struct {
	ormtable.Iterator
}

func (ValidatorIterator) Value

func (i ValidatorIterator) Value() (*Validator, error)

type ValidatorPrimaryKey

type ValidatorPrimaryKey = ValidatorIdIndexKey

primary key starting index..

type ValidatorSet

type ValidatorSet struct {
	Id              uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`                                                  // Auto-incremented ID
	CreatedHeight   uint64 `protobuf:"varint,2,opt,name=created_height,json=createdHeight,proto3" json:"created_height,omitempty"`       // Height this validator set was created at.
	Attested        bool   `protobuf:"varint,3,opt,name=attested,proto3" json:"attested,omitempty"`                                      // Whether this validator set has been attested to.
	ActivatedHeight uint64 `protobuf:"varint,4,opt,name=activated_height,json=activatedHeight,proto3" json:"activated_height,omitempty"` // Height this validator set is activated in cometBFT (0 while not attested).
	// contains filtered or unexported fields
}

ValidatorSet defines a set of consensus chain validators. The genesis set is created and implicitly attested and activated at height 0.

func (*ValidatorSet) Descriptor deprecated

func (*ValidatorSet) Descriptor() ([]byte, []int)

Deprecated: Use ValidatorSet.ProtoReflect.Descriptor instead.

func (*ValidatorSet) GetActivatedHeight

func (x *ValidatorSet) GetActivatedHeight() uint64

func (*ValidatorSet) GetAttested

func (x *ValidatorSet) GetAttested() bool

func (*ValidatorSet) GetCreatedHeight

func (x *ValidatorSet) GetCreatedHeight() uint64

func (*ValidatorSet) GetId

func (x *ValidatorSet) GetId() uint64

func (*ValidatorSet) ProtoMessage

func (*ValidatorSet) ProtoMessage()

func (*ValidatorSet) ProtoReflect

func (x *ValidatorSet) ProtoReflect() protoreflect.Message

func (*ValidatorSet) Reset

func (x *ValidatorSet) Reset()

func (*ValidatorSet) String

func (x *ValidatorSet) String() string

type ValidatorSetAttestedCreatedHeightIndexKey

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

func (ValidatorSetAttestedCreatedHeightIndexKey) WithAttested

func (ValidatorSetAttestedCreatedHeightIndexKey) WithAttestedCreatedHeight

func (this ValidatorSetAttestedCreatedHeightIndexKey) WithAttestedCreatedHeight(attested bool, created_height uint64) ValidatorSetAttestedCreatedHeightIndexKey

type ValidatorSetIdIndexKey

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

func (ValidatorSetIdIndexKey) WithId

type ValidatorSetIndexKey

type ValidatorSetIndexKey interface {
	// contains filtered or unexported methods
}

type ValidatorSetIterator

type ValidatorSetIterator struct {
	ormtable.Iterator
}

func (ValidatorSetIterator) Value

func (i ValidatorSetIterator) Value() (*ValidatorSet, error)

type ValidatorSetPrimaryKey

type ValidatorSetPrimaryKey = ValidatorSetIdIndexKey

primary key starting index..

type ValidatorSetTable

type ValidatorSetTable interface {
	Insert(ctx context.Context, validatorSet *ValidatorSet) error
	InsertReturningId(ctx context.Context, validatorSet *ValidatorSet) (uint64, error)
	LastInsertedSequence(ctx context.Context) (uint64, error)
	Update(ctx context.Context, validatorSet *ValidatorSet) error
	Save(ctx context.Context, validatorSet *ValidatorSet) error
	Delete(ctx context.Context, validatorSet *ValidatorSet) error
	Has(ctx context.Context, id uint64) (found bool, err error)
	// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	Get(ctx context.Context, id uint64) (*ValidatorSet, error)
	HasByAttestedCreatedHeight(ctx context.Context, attested bool, created_height uint64) (found bool, err error)
	// GetByAttestedCreatedHeight returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	GetByAttestedCreatedHeight(ctx context.Context, attested bool, created_height uint64) (*ValidatorSet, error)
	List(ctx context.Context, prefixKey ValidatorSetIndexKey, opts ...ormlist.Option) (ValidatorSetIterator, error)
	ListRange(ctx context.Context, from, to ValidatorSetIndexKey, opts ...ormlist.Option) (ValidatorSetIterator, error)
	DeleteBy(ctx context.Context, prefixKey ValidatorSetIndexKey) error
	DeleteRange(ctx context.Context, from, to ValidatorSetIndexKey) error
	// contains filtered or unexported methods
}

func NewValidatorSetTable

func NewValidatorSetTable(db ormtable.Schema) (ValidatorSetTable, error)

type ValidatorTable

type ValidatorTable interface {
	Insert(ctx context.Context, validator *Validator) error
	InsertReturningId(ctx context.Context, validator *Validator) (uint64, error)
	LastInsertedSequence(ctx context.Context) (uint64, error)
	Update(ctx context.Context, validator *Validator) error
	Save(ctx context.Context, validator *Validator) error
	Delete(ctx context.Context, validator *Validator) error
	Has(ctx context.Context, id uint64) (found bool, err error)
	// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
	Get(ctx context.Context, id uint64) (*Validator, error)
	List(ctx context.Context, prefixKey ValidatorIndexKey, opts ...ormlist.Option) (ValidatorIterator, error)
	ListRange(ctx context.Context, from, to ValidatorIndexKey, opts ...ormlist.Option) (ValidatorIterator, error)
	DeleteBy(ctx context.Context, prefixKey ValidatorIndexKey) error
	DeleteRange(ctx context.Context, from, to ValidatorIndexKey) error
	// contains filtered or unexported methods
}

func NewValidatorTable

func NewValidatorTable(db ormtable.Schema) (ValidatorTable, error)

type ValidatorValsetIdIndexKey

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

func (ValidatorValsetIdIndexKey) WithValsetId

func (this ValidatorValsetIdIndexKey) WithValsetId(valset_id uint64) ValidatorValsetIdIndexKey

type ValsetStore

type ValsetStore interface {
	ValidatorSetTable() ValidatorSetTable
	ValidatorTable() ValidatorTable
	// contains filtered or unexported methods
}

func NewValsetStore

func NewValsetStore(db ormtable.Schema) (ValsetStore, error)

Jump to

Keyboard shortcuts

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