keeper

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface

func NewQueryServer

func NewQueryServer(k Keeper) types.QueryServer

NewQueryServer creates a new gRPC query server.

Types

type BitmapHelper

type BitmapHelper struct{}

BitmapHelper provides utility functions for bitmap operations

func NewBitmapHelper

func NewBitmapHelper() *BitmapHelper

NewBitmapHelper creates a new bitmap helper

func (*BitmapHelper) AND

func (bh *BitmapHelper) AND(dst, src []byte)

AND performs bitwise AND of two bitmaps

func (*BitmapHelper) Clear

func (bh *BitmapHelper) Clear(bitmap []byte)

Clear sets all bits to 0

func (*BitmapHelper) Copy

func (bh *BitmapHelper) Copy(bitmap []byte) []byte

Copy creates a copy of the bitmap

func (*BitmapHelper) CountInRange

func (bh *BitmapHelper) CountInRange(bitmap []byte, start, end int) int

CountInRange counts set bits in a range [start, end)

func (*BitmapHelper) IsSet

func (bh *BitmapHelper) IsSet(bitmap []byte, index int) bool

IsSet checks if the bit at index is set

func (*BitmapHelper) NewBitmap

func (bh *BitmapHelper) NewBitmap(n int) []byte

NewBitmap creates a new bitmap for n validators

func (*BitmapHelper) OR

func (bh *BitmapHelper) OR(dst, src []byte)

OR performs bitwise OR of two bitmaps

func (*BitmapHelper) PopCount

func (bh *BitmapHelper) PopCount(bitmap []byte) int

PopCount returns the number of set bits

func (*BitmapHelper) SetBit

func (bh *BitmapHelper) SetBit(bitmap []byte, index int)

SetBit sets the bit at index to 1

type Keeper

type Keeper struct {

	// Collections for state management
	ValidatorIndex        collections.Map[string, uint16]
	ValidatorPower        collections.Map[uint16, uint64]
	AttestationBitmap     collections.Map[int64, []byte]
	EpochBitmap           collections.Map[uint64, []byte]
	AttesterSet           collections.KeySet[string]
	Signatures            collections.Map[collections.Pair[int64, string], []byte]
	StoredAttestationInfo collections.Map[int64, types.AttestationBitmap]
	Params                collections.Item[types.Params]
	Schema                collections.Schema
	// contains filtered or unexported fields
}

Keeper of the network store

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	sk types.StakingKeeper,
	ak types.AccountKeeper,
	bk types.BankKeeper,
	authority string,
) Keeper

NewKeeper creates a new network Keeper instance

func (Keeper) BuildValidatorIndexMap

func (k Keeper) BuildValidatorIndexMap(ctx sdk.Context) error

BuildValidatorIndexMap rebuilds the validator index mapping

func (Keeper) CalculateVotedPower

func (k Keeper) CalculateVotedPower(ctx sdk.Context, bitmap []byte) (uint64, error)

CalculateVotedPower calculates the total voted power from a bitmap

func (Keeper) CheckQuorum

func (k Keeper) CheckQuorum(ctx sdk.Context, votedPower, totalPower uint64) (bool, error)

CheckQuorum checks if the voted power meets quorum

func (Keeper) EndBlocker

func (k Keeper) EndBlocker(ctx sdk.Context) error

EndBlocker handles end block logic for the network module

func (Keeper) GetAttestationBitmap

func (k Keeper) GetAttestationBitmap(ctx sdk.Context, height int64) ([]byte, error)

GetAttestationBitmap retrieves the attestation bitmap for a height

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the module authority

func (Keeper) GetCurrentEpoch

func (k Keeper) GetCurrentEpoch(ctx sdk.Context) uint64

GetCurrentEpoch returns the current epoch number

func (Keeper) GetEpochBitmap

func (k Keeper) GetEpochBitmap(ctx sdk.Context, epoch uint64) []byte

GetEpochBitmap retrieves the epoch participation bitmap

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) types.Params

GetParams get all parameters as types.Params

func (Keeper) GetSignature

func (k Keeper) GetSignature(ctx sdk.Context, height int64, validatorAddr string) ([]byte, error)

GetSignature retrieves the vote signature for a given height and validator

func (Keeper) GetTotalPower

func (k Keeper) GetTotalPower(ctx sdk.Context) (uint64, error)

GetTotalPower returns the total staking power

func (Keeper) GetValidatorIndex

func (k Keeper) GetValidatorIndex(ctx sdk.Context, addr string) (uint16, bool)

GetValidatorIndex retrieves the validator index

func (Keeper) GetValidatorPower

func (k Keeper) GetValidatorPower(ctx sdk.Context, index uint16) (uint64, error)

GetValidatorPower retrieves the validator power by index

func (Keeper) HasSignature

func (k Keeper) HasSignature(ctx sdk.Context, height int64, validatorAddr string) (bool, error)

HasSignature checks if a signature exists for a given height and validator

func (Keeper) IsCheckpointHeight

func (k Keeper) IsCheckpointHeight(ctx sdk.Context, height int64) bool

IsCheckpointHeight checks if a height is a checkpoint

func (Keeper) IsInAttesterSet

func (k Keeper) IsInAttesterSet(ctx sdk.Context, addr string) (bool, error)

IsInAttesterSet checks if a validator is in the attester set

func (Keeper) IsSoftConfirmed

func (k Keeper) IsSoftConfirmed(ctx sdk.Context, height int64) (bool, error)

IsSoftConfirmed checks if a block at a given height is soft-confirmed based on the attestation bitmap and quorum rules.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger

func (Keeper) PruneOldBitmaps

func (k Keeper) PruneOldBitmaps(ctx sdk.Context, currentEpoch uint64) error

PruneOldBitmaps removes bitmaps older than PruneAfter epochs

func (Keeper) RemoveAttesterSetMember

func (k Keeper) RemoveAttesterSetMember(ctx sdk.Context, addr string) error

RemoveAttesterSetMember removes a validator from the attester set

func (Keeper) SetAttestationBitmap

func (k Keeper) SetAttestationBitmap(ctx sdk.Context, height int64, bitmap []byte) error

SetAttestationBitmap stores the attestation bitmap for a height

func (Keeper) SetAttesterSetMember

func (k Keeper) SetAttesterSetMember(ctx sdk.Context, addr string) error

SetAttesterSetMember adds a validator to the attester set

func (Keeper) SetEpochBitmap

func (k Keeper) SetEpochBitmap(ctx sdk.Context, epoch uint64, bitmap []byte) error

SetEpochBitmap stores the epoch participation bitmap

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error

SetParams set the params

func (Keeper) SetSignature

func (k Keeper) SetSignature(ctx sdk.Context, height int64, validatorAddr string, signature []byte) error

SetSignature stores the vote signature for a given height and validator

func (Keeper) SetValidatorIndex

func (k Keeper) SetValidatorIndex(ctx sdk.Context, addr string, index uint16, power uint64) error

SetValidatorIndex stores the validator index mapping and power

Jump to

Keyboard shortcuts

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