keeper

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 106 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MERCURY_UPGRADE_HEIGHT   uint64 = 1282013
	QUERY_ATTESTATIONS_LIMIT uint64 = 1000
)
View Source
const MaxResults = 100
View Source
const OutgoingTxBatchSize = 100

Variables

View Source
var (
	// ConsPrivKeys generate ed25519 ConsPrivKeys to be used for validator operator keys
	ConsPrivKeys = []ccrypto.PrivKey{
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
		ed25519.GenPrivKey(),
	}

	// ConsPubKeys holds the consensus public keys to be used for validator operator keys
	ConsPubKeys = []ccrypto.PubKey{
		ConsPrivKeys[0].PubKey(),
		ConsPrivKeys[1].PubKey(),
		ConsPrivKeys[2].PubKey(),
		ConsPrivKeys[3].PubKey(),
		ConsPrivKeys[4].PubKey(),
	}

	// AccPrivKeys generate secp256k1 pubkeys to be used for account pub keys
	AccPrivKeys = []ccrypto.PrivKey{
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
	}

	// AccPubKeys holds the pub keys for the account keys
	AccPubKeys = []ccrypto.PubKey{
		AccPrivKeys[0].PubKey(),
		AccPrivKeys[1].PubKey(),
		AccPrivKeys[2].PubKey(),
		AccPrivKeys[3].PubKey(),
		AccPrivKeys[4].PubKey(),
	}

	// AccAddrs holds the sdk.AccAddresses
	AccAddrs = []sdk.AccAddress{
		sdk.AccAddress(AccPubKeys[0].Address()),
		sdk.AccAddress(AccPubKeys[1].Address()),
		sdk.AccAddress(AccPubKeys[2].Address()),
		sdk.AccAddress(AccPubKeys[3].Address()),
		sdk.AccAddress(AccPubKeys[4].Address()),
	}

	// ValAddrs holds the sdk.ValAddresses
	ValAddrs = []sdk.ValAddress{
		sdk.ValAddress(AccPubKeys[0].Address()),
		sdk.ValAddress(AccPubKeys[1].Address()),
		sdk.ValAddress(AccPubKeys[2].Address()),
		sdk.ValAddress(AccPubKeys[3].Address()),
		sdk.ValAddress(AccPubKeys[4].Address()),
	}

	// AccPubKeys holds the pub keys for the account keys
	OrchPubKeys = []ccrypto.PubKey{
		OrchPrivKeys[0].PubKey(),
		OrchPrivKeys[1].PubKey(),
		OrchPrivKeys[2].PubKey(),
		OrchPrivKeys[3].PubKey(),
		OrchPrivKeys[4].PubKey(),
	}

	// Orchestrator private keys
	OrchPrivKeys = []ccrypto.PrivKey{
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
		secp256k1.GenPrivKey(),
	}

	// AccAddrs holds the sdk.AccAddresses
	OrchAddrs = []sdk.AccAddress{
		sdk.AccAddress(OrchPubKeys[0].Address()),
		sdk.AccAddress(OrchPubKeys[1].Address()),
		sdk.AccAddress(OrchPubKeys[2].Address()),
		sdk.AccAddress(OrchPubKeys[3].Address()),
		sdk.AccAddress(OrchPubKeys[4].Address()),
	}

	EthPrivKeys = []*ecdsa.PrivateKey{
		ethPrivKey1,
		ethPrivKey2,
		ethPrivKey3,
		ethPrivKey4,
		ethPrivKey5,
	}

	// EthAddrs holds etheruem addresses
	EthAddrs = []gethcommon.Address{
		gethcommon.BytesToAddress(crypto.PubkeyToAddress(EthPrivKeys[0].PublicKey).Bytes()),
		gethcommon.BytesToAddress(crypto.PubkeyToAddress(EthPrivKeys[1].PublicKey).Bytes()),
		gethcommon.BytesToAddress(crypto.PubkeyToAddress(EthPrivKeys[2].PublicKey).Bytes()),
		gethcommon.BytesToAddress(crypto.PubkeyToAddress(EthPrivKeys[3].PublicKey).Bytes()),
		gethcommon.BytesToAddress(crypto.PubkeyToAddress(EthPrivKeys[4].PublicKey).Bytes()),
	}

	// TokenContractAddrs holds example token contract addresses
	TokenContractAddrs = []string{
		"0x6b175474e89094c44da98b954eedeac495271d0f",
		"0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e",
		"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
		"0xc00e94cb662c3520282e6f5717214004a7f26888",
		"0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",
	}

	// InitTokens holds the number of tokens to initialize an account with
	InitTokens = sdk.TokensFromConsensusPower(110, sdk.DefaultPowerReduction)

	// InitCoins holds the number of coins to initialize an account with
	InitCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, InitTokens))

	// StakingAmount holds the staking power to start a validator with
	StakingAmount = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction)

	// StakingCoins holds the staking coins to start a validator with
	StakingCoins = sdk.NewCoins(sdk.NewCoin(TestingStakeParams.BondDenom, StakingAmount))

	// TestingStakeParams is a set of staking params for testing
	TestingStakeParams = stakingtypes.Params{
		UnbondingTime:     100,
		MaxValidators:     10,
		MaxEntries:        10,
		HistoricalEntries: 10000,
		BondDenom:         testDenom,
		MinCommissionRate: math.LegacyNewDecWithPrec(5, 2),
	}

	// TestingSkywayParams is a set of skyway params for testing
	TestingSkywayParams = types.Params{}
)

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants collects any defined invariants below

func CheckBatches

func CheckBatches(ctx sdk.Context, k Keeper) error

CheckBatches checks that all batch related data in the store is appropriate Returns an error string and a boolean indicating an error if true, for use in an invariant

func ExportGenesis

func ExportGenesis(ctx context.Context, k Keeper) types.GenesisState

ExportGenesis exports all the state needed to restart the chain from the current state of the chain

func InitGenesis

func InitGenesis(ctx context.Context, k Keeper, data types.GenesisState)

InitGenesis starts a chain from a genesis state

func MakeTestCodec

func MakeTestCodec() *codec.LegacyAmino

MakeTestCodec creates a legacy amino codec for testing

func MakeTestEncodingConfig

func MakeTestEncodingConfig() chainparams.EncodingConfig

func MakeTestMarshaler

func MakeTestMarshaler() codec.Codec

MakeTestMarshaler creates a proto codec for use in testing

func MintVouchersFromAir

func MintVouchersFromAir(t *testing.T, ctx context.Context, k Keeper, dest sdk.AccAddress, amount types.InternalERC20Token) sdk.Coin

MintVouchersFromAir creates new skyway vouchers given erc20tokens

func ModuleBalanceInvariant

func ModuleBalanceInvariant(k Keeper) sdk.Invariant

ModuleBalanceInvariant checks that the module account's balance is equal to the balance of unbatched transactions and unobserved batches Note that the returned bool should be true if there is an error, e.g. an unexpected module balance

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewSkywayProposalHandler

func NewSkywayProposalHandler(k Keeper) govv1beta1types.Handler

func NewTestMsgCreateValidator

func NewTestMsgCreateValidator(address sdk.ValAddress, pubKey ccrypto.PubKey, amt math.Int) *stakingtypes.MsgCreateValidator

func NewTestMsgUnDelegateValidator

func NewTestMsgUnDelegateValidator(address sdk.ValAddress, amt math.Int) *stakingtypes.MsgUndelegate

func StoreValidityInvariant

func StoreValidityInvariant(k Keeper) sdk.Invariant

StoreValidityInvariant checks that the currently stored objects are not corrupted and all pass ValidateBasic checks Note that the returned bool should be true if there is an error, e.g. an unexpected batch was processed

func ValidateStore

func ValidateStore(ctx sdk.Context, k Keeper) error

ValidateStore checks that all values in the store can be decoded and pass a ValidateBasic check Returns an error string and a boolean indicating an error if true, for use in an invariant nolint: gocyclo

Types

type AttestationHandler

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

AttestationHandler processes `observed` Attestations

func (AttestationHandler) Handle

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 Hooks

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

Wrapper struct

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) AfterUnbondingInitiated

func (h Hooks) AfterUnbondingInitiated(ctx context.Context, id uint64) error

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(ctx context.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(_ context.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(ctx context.Context, valAddr sdk.ValAddress) error

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx context.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(_ context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(_ context.Context, _ sdk.AccAddress, _ sdk.ValAddress) error

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(_ context.Context, _ sdk.ValAddress) error

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx context.Context, valAddr sdk.ValAddress, fraction math.LegacyDec) error

type Keeper

type Keeper struct {
	StakingKeeper  types.StakingKeeper
	SlashingKeeper types.SlashingKeeper
	DistKeeper     distrkeeper.Keeper

	EVMKeeper types.EVMKeeper

	AddressCodec address.Codec

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

Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	accKeeper types.AccountKeeper,
	stakingKeeper types.StakingKeeper,
	bankKeeper types.BankKeeper,
	slashingKeeper types.SlashingKeeper,
	distributionKeeper distrkeeper.Keeper,
	ibcTransferKeeper ibctransferkeeper.Keeper,
	evmKeeper types.EVMKeeper,
	consensusKeeper types.ConsensusKeeper,
	palomaKeeper types.PalomaKeeper,
	storeGetter keeperutil.StoreGetter,
	authority string,
	valAddressCodec address.Codec,
) Keeper

NewKeeper returns a new instance of the skyway keeper

func (Keeper) AddToOutgoingPool

func (k Keeper) AddToOutgoingPool(
	ctx context.Context,
	sender sdk.AccAddress,
	counterpartReceiver types.EthAddress,
	amount sdk.Coin,
	chainReferenceID string,
) (uint64, error)

AddToOutgoingPool creates a transaction and adds it to the pool, returns the id of the unbatched transaction - checks a counterpart denominator exists for the given voucher type - burns the voucher for transfer amount - persists an OutgoingTx - adds the TX to the `available` TX pool

func (Keeper) AllBridgeTaxes

func (k Keeper) AllBridgeTaxes(
	ctx context.Context,
) ([]*types.BridgeTax, error)

func (Keeper) AllBridgeTransferLimits

func (k Keeper) AllBridgeTransferLimits(
	ctx context.Context,
) ([]*types.BridgeTransferLimit, error)

func (Keeper) AllLightNodeSaleContracts

func (k Keeper) AllLightNodeSaleContracts(
	ctx context.Context,
) ([]*types.LightNodeSaleContract, error)

func (Keeper) Attest

func (k Keeper) Attest(
	ctx context.Context,
	claim types.EthereumClaim,
	anyClaim *codectypes.Any,
) (*types.Attestation, error)

func (Keeper) BatchConfirms

BatchConfirms returns the batch confirmations by nonce and token contract

func (Keeper) BatchRequestByNonce

BatchRequestByNonce queries the BatchRequestByNonce of the skyway module.

func (Keeper) BridgeTax

func (k Keeper) BridgeTax(
	ctx context.Context,
	token string,
) (*types.BridgeTax, error)

func (Keeper) BridgeTransferLimit

func (k Keeper) BridgeTransferLimit(
	ctx context.Context,
	token string,
) (*types.BridgeTransferLimit, error)

func (Keeper) BridgeTransferUsage

func (k Keeper) BridgeTransferUsage(
	ctx context.Context,
	token string,
) (*types.BridgeTransferUsage, error)

func (Keeper) BuildOutgoingTXBatch

func (k Keeper) BuildOutgoingTXBatch(
	ctx context.Context,
	chainReferenceID string,
	contract types.EthAddress,
	maxElements uint,
) (*types.InternalOutgoingTxBatch, error)

BuildOutgoingTXBatch starts the following process chain: - find bridged denominator for given voucher type - select available transactions from the outgoing transaction pool sorted by nonce desc - persist an outgoing batch object with an incrementing ID = nonce - emit an event

func (Keeper) CancelOutgoingTXBatch

func (k Keeper) CancelOutgoingTXBatch(c context.Context, tokenContract types.EthAddress, nonce uint64) (err error)

CancelOutgoingTXBatch releases all TX in the batch and deletes the batch

func (Keeper) CastAllERC20ToDenoms

func (k Keeper) CastAllERC20ToDenoms(ctx context.Context) ([]evmtypes.ERC20Record, error)

func (Keeper) CastChainERC20ToDenoms

func (k Keeper) CastChainERC20ToDenoms(
	ctx context.Context,
	chainReferenceID string,
) ([]evmtypes.ERC20Record, error)

func (Keeper) CheckBadSignatureEvidence

func (k Keeper) CheckBadSignatureEvidence(
	ctx context.Context,
	msg *types.MsgSubmitBadSignatureEvidence,
	chainReferenceID string,
) error

func (Keeper) DeleteAttestation

func (k Keeper) DeleteAttestation(ctx context.Context, chainReferenceID string, att types.Attestation) error

DeleteAttestation deletes the given attestation

func (Keeper) DeleteBatch

func (k Keeper) DeleteBatch(ctx context.Context, batch types.InternalOutgoingTxBatch) error

DeleteBatch deletes an outgoing transaction batch

func (Keeper) DeleteBatchConfirms

func (k Keeper) DeleteBatchConfirms(ctx context.Context, batch types.InternalOutgoingTxBatch) error

DeleteBatchConfirms deletes confirmations for an outgoing transaction batch

func (Keeper) DeleteBatchGasEstimates

func (k Keeper) DeleteBatchGasEstimates(ctx context.Context, batch types.InternalOutgoingTxBatch) error

func (Keeper) DenomToERC20

DenomToERC20 queries the Paloma Denom that maps to an Ethereum ERC20

func (Keeper) DeserializeValidatorIterator

func (k Keeper) DeserializeValidatorIterator(vals []byte) stakingtypes.ValAddresses

DeserializeValidatorIterator returns validators from the validator iterator. Adding here in skyway keeper as cdc is not available inside endblocker.

func (Keeper) ERC20ToDenom

ERC20ToDenom queries the ERC20 contract that maps to an Ethereum ERC20 if any

func (Keeper) GetAllDenomToERC20s

func (k Keeper) GetAllDenomToERC20s(ctx context.Context) ([]*types.ERC20ToDenom, error)

func (Keeper) GetAllERC20ToDenoms

func (k Keeper) GetAllERC20ToDenoms(ctx context.Context) ([]*types.ERC20ToDenom, error)

func (Keeper) GetAttestation

func (k Keeper) GetAttestation(ctx context.Context, chainReferenceID string, eventNonce uint64, claimHash []byte) *types.Attestation

GetAttestation return an attestation given a nonce

func (Keeper) GetAttestationMapping

func (k Keeper) GetAttestationMapping(ctx context.Context, chainReferenceID string) (attestationMapping map[uint64][]types.Attestation, orderedKeys []uint64, err error)

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) GetAttestations

GetAttestations queries the attestation map

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

func (Keeper) GetBatchConfirm

func (k Keeper) GetBatchConfirm(ctx context.Context, nonce uint64, tokenContract types.EthAddress, validator sdk.AccAddress) (*types.MsgConfirmBatch, error)

GetBatchConfirm returns a batch confirmation given its nonce, the token contract, and a validator address

func (Keeper) GetBatchConfirmByNonceAndTokenContract

func (k Keeper) GetBatchConfirmByNonceAndTokenContract(ctx context.Context, nonce uint64, tokenContract types.EthAddress) (out []types.MsgConfirmBatch, err error)

GetBatchConfirmByNonceAndTokenContract returns the batch confirms

func (Keeper) GetBatchGasEstimate

func (k Keeper) GetBatchGasEstimate(ctx context.Context, nonce uint64, tokenContract types.EthAddress, validator sdk.ValAddress) (*types.MsgEstimateBatchGas, error)

func (Keeper) GetBatchGasEstimateByNonceAndTokenContract

func (k Keeper) GetBatchGasEstimateByNonceAndTokenContract(ctx context.Context, nonce uint64, tokenContract types.EthAddress) (out []types.MsgEstimateBatchGas, err error)

func (Keeper) GetBridgeTaxes

func (k Keeper) GetBridgeTaxes(
	goCtx context.Context,
	_ *emptypb.Empty,
) (*types.QueryBridgeTaxesResponse, error)

func (Keeper) GetBridgeTransferLimits

func (k Keeper) GetBridgeTransferLimits(
	goCtx context.Context,
	_ *emptypb.Empty,
) (*types.QueryBridgeTransferLimitsResponse, error)

func (Keeper) GetChainsWithTokens

func (k Keeper) GetChainsWithTokens(ctx context.Context) []string

GetChainsWithTokens returns a set of chain reference IDs for all chains that currently have tokens deployed on.

func (Keeper) GetDenomOfERC20

func (k Keeper) GetDenomOfERC20(ctx context.Context, chainReferenceId string, tokenContract types.EthAddress) (string, error)

func (Keeper) GetERC20OfDenom

func (k Keeper) GetERC20OfDenom(ctx context.Context, chainReferenceId, denom string) (*types.EthAddress, error)

func (Keeper) GetErc20ToDenoms

func (Keeper) GetEthAddressByValidator

func (k Keeper) GetEthAddressByValidator(ctx context.Context, validator sdk.ValAddress, chainReferenceId string) (ethAddress *types.EthAddress, found bool, err error)

GetEthAddressByValidator returns the eth address for a given skyway validator

func (Keeper) GetLastObservedEthereumBlockHeight

func (k Keeper) GetLastObservedEthereumBlockHeight(ctx context.Context, chainReferenceID string) types.LastObservedEthereumBlockHeight

GetLastObservedEthereumBlockHeight height gets the block height to of the last observed attestation from the store

func (Keeper) GetLastObservedSkywayNonce

func (k Keeper) GetLastObservedSkywayNonce(ctx context.Context, chainReferenceID string) (uint64, error)

GetLastObservedSkywayNonce returns the latest observed event nonce

func (Keeper) GetLastOutgoingBatchByTokenType

func (k Keeper) GetLastOutgoingBatchByTokenType(ctx context.Context, token types.EthAddress) (*types.InternalOutgoingTxBatch, error)

GetLastOutgoingBatchByTokenType gets the latest outgoing tx batch by token type

func (Keeper) GetLastSkywayNonceByValidator

func (k Keeper) GetLastSkywayNonceByValidator(ctx context.Context, validator sdk.ValAddress, chainReferenceID string) (uint64, error)

GetLastSkywayNonceByValidator returns the latest event nonce for a given validator

func (Keeper) GetLastSlashedBatchBlock

func (k Keeper) GetLastSlashedBatchBlock(ctx context.Context) (uint64, error)

GetLastSlashedBatchBlock returns the latest slashed Batch block

func (Keeper) GetLatestCompassID

func (k Keeper) GetLatestCompassID(
	ctx context.Context,
	chainReferenceID string,
) string

GetLatestCompassID returns the latest compass ID on record after message attestation

func (Keeper) GetLightNodeSaleContracts

func (k Keeper) GetLightNodeSaleContracts(
	goCtx context.Context,
	_ *emptypb.Empty,
) (*types.QueryLightNodeSaleContractsResponse, error)

func (Keeper) GetMostRecentAttestations

func (k Keeper) GetMostRecentAttestations(ctx context.Context, chainReferenceID string, limit uint64) ([]types.Attestation, error)

GetMostRecentAttestations returns sorted (by nonce) attestations up to a provided limit number of attestations Note: calls GetAttestationMapping in the hopes that there are potentially many attestations which are distributed between few nonces to minimize sorting time

func (Keeper) GetOrchestratorValidator

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

GetOrchestratorValidator returns the validator key associated with an orchestrator key

func (Keeper) GetOutgoingTXBatch

func (k Keeper) GetOutgoingTXBatch(ctx context.Context, tokenContract types.EthAddress, nonce uint64) (*types.InternalOutgoingTxBatch, error)

GetOutgoingTXBatch loads a batch object. Returns nil when not exists.

func (Keeper) GetOutgoingTxBatches

func (k Keeper) GetOutgoingTxBatches(ctx context.Context) (out []types.InternalOutgoingTxBatch, err error)

GetOutgoingTxBatches returns the outgoing tx batches

func (Keeper) GetOutgoingTxBatchesByNonce

func (k Keeper) GetOutgoingTxBatchesByNonce(ctx context.Context) (map[uint64]types.InternalOutgoingTxBatch, error)

func (Keeper) GetParams

func (k Keeper) GetParams(ctx context.Context) (params types.Params)

GetParams returns the parameters from the store

func (Keeper) GetPastEthSignatureCheckpoint

func (k Keeper) GetPastEthSignatureCheckpoint(ctx context.Context, checkpoint []byte) (found bool)

GetPastEthSignatureCheckpoint tells you whether a given checkpoint has ever existed

func (Keeper) GetStore

func (k Keeper) GetStore(ctx context.Context, chainReferenceID string) storetypes.KVStore

Returns the module store, prefixed with the passed chainReferenceID.

func (Keeper) GetUnSlashedBatches

func (k Keeper) GetUnSlashedBatches(ctx context.Context, maxHeight uint64) (out []types.InternalOutgoingTxBatch, err error)

GetUnSlashedBatches returns all the unslashed batches in state

func (Keeper) GetUnbatchedTransactions

func (k Keeper) GetUnbatchedTransactions(ctx context.Context) ([]*types.InternalOutgoingTransferTx, error)

GetUnbatchedTransactions grabs all transactions from the tx pool, useful for queries or genesis save/load

func (Keeper) GetUnbatchedTransactionsByContract

func (k Keeper) GetUnbatchedTransactionsByContract(ctx context.Context, contractAddress types.EthAddress) ([]*types.InternalOutgoingTransferTx, error)

GetUnbatchedTransactionsByContract grabs all unbatched transactions from the tx pool for the given contract unbatched transactions are sorted by nonce in DESC order

func (Keeper) GetUnbatchedTxByAmountAndId

func (k Keeper) GetUnbatchedTxByAmountAndId(ctx context.Context, token types.InternalERC20Token, txID uint64) (*types.InternalOutgoingTransferTx, error)

GetUnbatchedTxByAmountAndId grabs a tx from the pool given its txID

func (Keeper) GetUnbatchedTxById

func (k Keeper) GetUnbatchedTxById(ctx context.Context, txID uint64) (*types.InternalOutgoingTransferTx, error)

GetUnbatchedTxById grabs a tx from the pool given only the txID note that due to the way unbatched txs are indexed, the GetUnbatchedTxByAmountAndId method is much faster

func (Keeper) GetValidatorByEthAddress

func (k Keeper) GetValidatorByEthAddress(ctx context.Context, ethAddr types.EthAddress, chainReferenceId string) (validator stakingtypes.Validator, found bool, err error)

GetValidatorByEthAddress returns the validator for a given eth address

func (Keeper) HasLastSlashedBatchBlock

func (k Keeper) HasLastSlashedBatchBlock(ctx context.Context) bool

HasLastSlashedBatchBlock returns true if the last slashed batch block has been set in the store

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new skyway hooks

func (Keeper) InvalidSendToRemoteAddress

func (k Keeper) InvalidSendToRemoteAddress(ctx context.Context, addr types.EthAddress, _erc20Addr types.EthAddress) bool

InvalidSendToRemoteAddress Returns true if the provided address is invalid to send to Ethereum this could be for one of several reasons. (1) it is invalid in general like the Zero address, (2) it is invalid for a subset of ERC20 addresses. (2) is not yet implemented Blocking some addresses is technically motivated, if any ERC20 transfers in a batch fail the entire batch becomes impossible to execute.

func (Keeper) IterateAttestations

func (k Keeper) IterateAttestations(ctx context.Context, chainReferenceID string, reverse bool, cb func(key []byte, att types.Attestation) (stop bool)) error

IterateAttestations iterates through all attestations executing a given callback on each discovered attestation If reverse is true, attestations will be returned in descending order by key (aka by event nonce and then claim hash) cb should return true to stop iteration, false to continue

func (Keeper) IterateBatchConfirmByNonceAndTokenContract

func (k Keeper) IterateBatchConfirmByNonceAndTokenContract(ctx context.Context, nonce uint64, tokenContract types.EthAddress, cb func([]byte, types.MsgConfirmBatch) bool) error

IterateBatchConfirmByNonceAndTokenContract iterates through all batch confirmations MARK finish-batches: this is where the key is iterated in the old (presumed working) code TODO: specify which nonce this is

func (Keeper) IterateBatchConfirms

func (k Keeper) IterateBatchConfirms(ctx context.Context, cb func([]byte, types.MsgConfirmBatch) (stop bool))

IterateBatchConfirms iterates through all batch confirmations

func (Keeper) IterateBatchGasEstimateByNonceAndTokenContract

func (k Keeper) IterateBatchGasEstimateByNonceAndTokenContract(ctx context.Context, nonce uint64, tokenContract types.EthAddress, cb func([]byte, types.MsgEstimateBatchGas) bool) error

func (Keeper) IterateBatchGasEstimates

func (k Keeper) IterateBatchGasEstimates(ctx context.Context, cb func([]byte, types.MsgEstimateBatchGas) (stop bool))

TODO: NEEDED?

func (Keeper) IterateClaims

func (k Keeper) IterateClaims(ctx context.Context, chainReferenceID string, reverse bool, claimType types.ClaimType, cb func(key []byte, att types.Attestation, claim types.EthereumClaim) (stop bool)) error

IterateClaims iterates through all attestations, filtering them for claims of a given type If reverse is true, attestations will be returned in descending order by key (aka by event nonce and then claim hash) cb should return true to stop iteration, false to continue

func (Keeper) IterateOutgoingTxBatches

func (k Keeper) IterateOutgoingTxBatches(ctx context.Context, cb func(key []byte, batch types.InternalOutgoingTxBatch) bool) error

IterateOutgoingTxBatches iterates through all outgoing batches in ASC order.

func (Keeper) IteratePastEthSignatureCheckpoints

func (k Keeper) IteratePastEthSignatureCheckpoints(ctx context.Context, cb func(key []byte, value []byte) (stop bool)) error

func (Keeper) IterateUnbatchedTransactions

func (k Keeper) IterateUnbatchedTransactions(ctx context.Context, cb func(key []byte, tx *types.InternalOutgoingTransferTx) (stop bool)) error

IterateUnbatchedTransactions iterates through all unbatched transactions in DESC order, executing the given callback on each discovered Tx. Return true in cb to stop iteration, false to continue. For finer grained control, use filterAndIterateUnbatchedTransactions or one of the above methods

func (Keeper) IterateUnbatchedTransactionsByContract

func (k Keeper) IterateUnbatchedTransactionsByContract(ctx context.Context, contractAddress types.EthAddress, cb func(key []byte, tx *types.InternalOutgoingTransferTx) bool) error

IterateUnbatchedTransactionsByContract iterates through unbatched transactions from the tx pool for the given contract, executing the given callback on each discovered Tx. Return true in cb to stop iteration, false to continue. unbatched transactions are sorted by nonce in DESC order

func (Keeper) IterateValidatorLastEventNonces

func (k Keeper) IterateValidatorLastEventNonces(ctx context.Context, chainReferenceID string, cb func(key []byte, nonce uint64) (stop bool)) error

IterateValidatorLastEventNonces iterates through all batch confirmations

func (Keeper) LastObservedSkywayBlock

LastObservedSkywayBlock returns the last remote chain block height observed by Paloma.

func (Keeper) LastObservedSkywayNonce

LastObservedSkywayNonce returns the last skyway nonce observed by Paloma.

func (Keeper) LastObservedSkywayNonceByAddr

LastObservedSkywayNonceByAddr returns the last skyway nonce for the given validator address, this allows Pigeons to figure out where they left off

func (Keeper) LastPendingBatchRequestByAddr

LastPendingBatchRequestByAddr queries the LastPendingBatchRequestByAddr of the skyway module.

func (Keeper) LightNodeSaleContract

func (k Keeper) LightNodeSaleContract(
	ctx context.Context,
	chain string,
) (*types.LightNodeSaleContract, error)

func (Keeper) Logger

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

Logger returns a module-specific Logger.

func (Keeper) OutgoingTxBatchExecuted

func (k Keeper) OutgoingTxBatchExecuted(c context.Context, tokenContract types.EthAddress, claim types.MsgBatchSendToRemoteClaim) (err error)

OutgoingTxBatchExecuted is run when the Cosmos chain detects that a batch has been executed on Ethereum It frees all the transactions in the batch

func (Keeper) OutgoingTxBatches

OutgoingTxBatches queries the OutgoingTxBatches of the skyway module

func (Keeper) Params

Params queries the params of the skyway module

func (Keeper) RemoveFromOutgoingPoolAndRefund

func (k Keeper) RemoveFromOutgoingPoolAndRefund(ctx context.Context, txId uint64, sender sdk.AccAddress) error

RemoveFromOutgoingPoolAndRefund performs the cancel function for pending Sends To Ethereum - checks that the provided tx actually exists - deletes the unbatched tx from the pool - issues the tokens back to the sender

func (Keeper) SendToCommunityPool

func (k Keeper) SendToCommunityPool(ctx context.Context, coins sdk.Coins) error

SendToCommunityPool handles incorrect SendToPaloma calls to the community pool, since the calls have already been made on Ethereum there's nothing we can do to reverse them, and we should at least make use of the tokens which would otherwise be lost

func (Keeper) SetAllLighNodeSaleContracts

func (k Keeper) SetAllLighNodeSaleContracts(
	ctx context.Context,
	contracts []*types.LightNodeSaleContract,
) error

func (Keeper) SetAttestation

func (k Keeper) SetAttestation(ctx context.Context, chainReferenceID string, eventNonce uint64, claimHash []byte, att *types.Attestation)

SetAttestation sets the attestation in the store

func (Keeper) SetBatchConfirm

func (k Keeper) SetBatchConfirm(ctx context.Context, batch *types.MsgConfirmBatch) ([]byte, error)

SetBatchConfirm sets a batch confirmation by a validator

func (Keeper) SetBatchGasEstimate

func (k Keeper) SetBatchGasEstimate(ctx context.Context, estimate *types.MsgEstimateBatchGas) ([]byte, error)

func (Keeper) SetBridgeTax

func (k Keeper) SetBridgeTax(ctx context.Context, tax *types.BridgeTax) error

func (Keeper) SetBridgeTransferLimit

func (k Keeper) SetBridgeTransferLimit(
	ctx context.Context,
	limit *types.BridgeTransferLimit,
) error

func (Keeper) SetLastObservedEthereumBlockHeight

func (k Keeper) SetLastObservedEthereumBlockHeight(ctx context.Context, chainReferenceID string, ethereumHeight uint64) error

SetLastObservedEthereumBlockHeight sets the block height in the store.

func (Keeper) SetLastSkywayNonceByValidator

func (k Keeper) SetLastSkywayNonceByValidator(ctx context.Context, validator sdk.ValAddress, chainReferenceID string, nonce uint64) error

SetLastSkywayNonceByValidator sets the latest event nonce for a give validator

func (Keeper) SetLastSlashedBatchBlock

func (k Keeper) SetLastSlashedBatchBlock(ctx context.Context, blockHeight uint64) error

SetLastSlashedBatchBlock sets the latest slashed Batch block height this is done by block height instead of nonce because batches could have individual nonces for each token type

func (Keeper) SetParams

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

SetParams sets the parameters in the store

func (Keeper) SetPastEthSignatureCheckpoint

func (k Keeper) SetPastEthSignatureCheckpoint(ctx context.Context, checkpoint []byte)

SetPastEthSignatureCheckpoint puts the checkpoint of a batch into a set in order to prove later that it existed at one point.

func (Keeper) StoreBatch

func (k Keeper) StoreBatch(ctx context.Context, batch types.InternalOutgoingTxBatch) error

StoreBatch stores a transaction batch, it will refuse to overwrite an existing batch and errors instead, once a batch is stored in state signature collection begins so no mutation of a batch in state can ever be valid

func (Keeper) TryAttestation

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

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) UnobservedBlocksByAddr

func (k Keeper) UnobservedBlocksByAddr(
	ctx context.Context,
	chainReferenceID string,
	valAddr string,
) ([]uint64, error)

UnobservedBlocksByAddr returns the blocks with reported events that are still unobserved and are not yet voted by `valAddr`

func (Keeper) UnpackAttestationClaim

func (k Keeper) UnpackAttestationClaim(att *types.Attestation) (types.EthereumClaim, error)

func (Keeper) UpdateBatchGasEstimate

func (k Keeper) UpdateBatchGasEstimate(c context.Context, batch types.InternalOutgoingTxBatch, estimate uint64) (err error)

UpdateBatchGasEstimate updates the gas estimate for a batch

func (Keeper) UpdateBridgeTransferUsageWithLimit

func (k Keeper) UpdateBridgeTransferUsageWithLimit(
	ctx context.Context,
	sender sdk.AccAddress,
	coin sdk.Coin,
) error

func (Keeper) UpdateValidatorNoncesToLatest

func (k Keeper) UpdateValidatorNoncesToLatest(
	ctx context.Context,
	chainReferenceId string,
) error

UpdateValidatorNoncesToLatest updates all validator nonces to the last observed skyway nonce only if it is higher than the current record

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper *Keeper, legacySubspace exported.Subspace) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate4to5

func (m Migrator) Migrate4to5(ctx sdk.Context) error

Migrate4to5 migrates from version 4 to 5.

type SkywayStoreGetter

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

func NewSkywayStoreGetter

func NewSkywayStoreGetter(storeKey storetypes.StoreKey) SkywayStoreGetter

func (SkywayStoreGetter) Store

type TestInput

type TestInput struct {
	SkywayKeeper      Keeper
	AccountKeeper     authkeeper.AccountKeeper
	StakingKeeper     stakingkeeper.Keeper
	ValsetKeeper      valsetkeeper.Keeper
	SlashingKeeper    slashingkeeper.Keeper
	DistKeeper        distrkeeper.Keeper
	BankKeeper        bankkeeper.BaseKeeper
	GovKeeper         govkeeper.Keeper
	IbcTransferKeeper ibctransferkeeper.Keeper
	Context           context.Context
	Marshaler         codec.Codec
	LegacyAmino       *codec.LegacyAmino
	SkywayStoreKey    *storetypes.KVStoreKey
	EvmKeeper         evmkeeper.Keeper
	TreasuryKeeper    *treasurykeeper.Keeper
	MetrixKeeper      metrixmodulekeeper.Keeper
}

TestInput stores the various keepers required to test skyway

func CreateTestEnv

func CreateTestEnv(t *testing.T) TestInput

CreateTestEnv creates the keeper testing environment for skyway

func SetupFiveValChain

func SetupFiveValChain(t *testing.T) (TestInput, context.Context)

SetupFiveValChain does all the initialization for a 5 Validator chain using the keys here

func SetupTestChain

func SetupTestChain(t *testing.T, weights []uint64) (TestInput, context.Context)

SetupTestChain sets up a test environment with the provided validator voting weights

func (TestInput) AssertInvariants

func (t TestInput) AssertInvariants()

AssertInvariants tests each modules invariants individually, this is easier than dealing with all the init required to get the crisis keeper working properly by running appModuleBasic for every module and allowing them to register their invariants

Jump to

Keyboard shortcuts

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