keeper

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const QUERY_ATTESTATIONS_LIMIT uint64 = 1000

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

Types

type AttestationHandler

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

AttestationHandler processes `observed` Attestations

func (AttestationHandler) Handle

func (a AttestationHandler) Handle(ctx sdk.Context, att types.Attestation, proposal types.BtcProposal) error

Handle is the entry point for Attestation processing, only attestations with sufficient validator submissions should be processed through this function, solidifying their effect in chain state

func (AttestationHandler) ValidateMembers

func (a AttestationHandler) ValidateMembers()

Check for nil members

type Keeper

type Keeper struct {

	// NOTE: If you add anything to this struct, add a nil check to ValidateMembers below!
	StakingKeeper *stakingkeeper.Keeper

	VoltKeeper *voltkeeper.Keeper

	AttestationHandler interface {
		Handle(sdk.Context, types.Attestation, types.BtcProposal) error
	}
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey sdk.StoreKey,
	ps paramtypes.Subspace,
	stakingKeeper *stakingkeeper.Keeper,
	accKeeper *authkeeper.AccountKeeper,
	bankKeeper *bankkeeper.BaseKeeper,
	voltKeeper *voltkeeper.Keeper,
) *Keeper

func (Keeper) Attest

func (k Keeper) Attest(
	ctx sdk.Context,
	proposal types.BtcProposal,
	valAddr sdk.ValAddress,
	anyProposal *codectypes.Any,
) (*types.Attestation, error)

TODO-JT: carefully look at atomicity of this function

func (Keeper) CheckOrchestratorValidatorInSet

func (k Keeper) CheckOrchestratorValidatorInSet(ctx sdk.Context, orchestrator string) error

checkOrchestratorValidatorInSet checks that the orchestrator refers to a validator that is currently in the set

func (Keeper) ClaimHandlerCommon

func (k Keeper) ClaimHandlerCommon(ctx sdk.Context, msgAny *codectypes.Any, valAddr sdk.ValAddress, msg types.BtcProposal) error

claimHandlerCommon is an internal function that provides common code for processing claims once they are translated from the message to the Ethereum claim interface

func (Keeper) GetAttestation

func (k Keeper) GetAttestation(ctx sdk.Context, height uint64, proposalHash []byte) *types.Attestation

GetAttestation return an attestation given a btc block height

func (Keeper) GetAttestationMapping

func (k Keeper) GetAttestationMapping(ctx sdk.Context) (attestationMapping map[uint64][]types.Attestation, orderedKeys []uint64)

GetAttestationMapping returns a mapping of eventnonce -> attestations at that nonce it also returns a pre-sorted array of the keys, this assists callers of this function by providing a deterministic iteration order. You should always iterate over ordered keys if you are iterating this map at all.

func (Keeper) GetBtcPublicKeyByValidator

func (k Keeper) GetBtcPublicKeyByValidator(ctx sdk.Context, validator sdk.ValAddress) (btcPublicKey *types.BtcPublicKey, found bool)

GetBtcAddressByValidator returns the btc public key for a given validator

func (Keeper) GetDelegateKeys

func (k Keeper) GetDelegateKeys(ctx sdk.Context) ([]types.MsgSetDelegateAddresses, error)

GetDelegateKeys iterates both the BtcPublicKey and Orchestrator address indexes to produce a vector of MsgSetOrchestratorAddress entires containing all the delgate keys for state export / import. This may seem at first glance to be excessively complicated, why not combine the BtcPublicKey and Orchestrator address indexes and simply iterate one thing? The answer is that even though we set the BTC Public Key and Orchestrator address in the same place we use them differently we always go from Orchestrator address to Validator address and from validator address to BTC Public Key we want to keep looking up the validator address for various reasons, so a direct Orchestrator to BTC Public Key mapping will mean having to keep two of the same data around just to provide lookups.

For the time being this will serve

func (Keeper) GetLastObservedBlockHeight

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

GetLastObservedBlockHeight returns the latest observed event nonce

func (Keeper) GetOrchestratorValidator

func (k Keeper) GetOrchestratorValidator(ctx sdk.Context, orch sdk.AccAddress) (validator stakingtypes.Validator, found bool)

GetOrchestratorValidator returns the validator key associated with an orchestrator key

func (Keeper) GetParams

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

GetParams get all parameters as types.Params

func (Keeper) GetSweepProposalAttestationsForBtcSweepTx

func (k Keeper) GetSweepProposalAttestationsForBtcSweepTx(ctx sdk.Context, txHash string) (types.Attestation, error)

GetSweepProposalAttestationsForBtcSweepTx finds all attestations for a given given txHash and txHash found in btcSweepTx

func (Keeper) IterateAttestations

func (k Keeper) IterateAttestations(ctx sdk.Context, reverse bool, cb func([]byte, types.Attestation) bool)

IterateAttestations iterates through all attestations

func (Keeper) Params

func (Keeper) SetAttestation

func (k Keeper) SetAttestation(ctx sdk.Context, height uint64, proposalHash []byte, att *types.Attestation)

SetAttestation sets the attestation in the store

func (Keeper) SetBtcPublicKeyForValidator

func (k Keeper) SetBtcPublicKeyForValidator(ctx sdk.Context, validator sdk.ValAddress, btcPk types.BtcPublicKey) ([]byte, error)

SetBtcPublicKeyForValidator sets the btc public key for a given validator

func (Keeper) SetLastBlockHeightByValidator

func (k Keeper) SetLastBlockHeightByValidator(ctx sdk.Context, validator sdk.ValAddress, nonce uint64)

setLastEventNonceByValidator sets the latest event nonce for a give validator

func (Keeper) SetOrchestratorValidator

func (k Keeper) SetOrchestratorValidator(ctx sdk.Context, val sdk.ValAddress, orch sdk.AccAddress)

SetOrchestratorValidator sets the Orchestrator key for a given validator

func (Keeper) SetParams

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

SetParams set the params

func (Keeper) TryAttestation

func (k Keeper) TryAttestation(ctx sdk.Context, att *types.Attestation)

TryAttestation checks if an attestation has enough votes to be applied to the consensus state and has not already been marked Observed, then calls processAttestation to actually apply it to the state, and then marks it Observed and emits an event.

func (Keeper) UnpackAttestationProposal

func (k Keeper) UnpackAttestationProposal(att *types.Attestation) (types.BtcProposal, error)

func (Keeper) ValidateMembers

func (k Keeper) ValidateMembers()

Check for nil members

Jump to

Keyboard shortcuts

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