keeper

package
v1.13.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 97 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),
	}

	// TestingGravityParams is a set of gravity params for testing
	TestingGravityParams = types.Params{
		ContractSourceHash:           "62328f7bc12efb28f86111d08c29b39285680a906ea0e524e0209d6f6657b713",
		BridgeEthereumAddress:        "0x8858eeb3dfffa017d4bce9801d340d36cf895ccf",
		BridgeChainId:                11,
		SignedBatchesWindow:          10,
		TargetBatchTimeout:           60001,
		AverageBlockTime:             5000,
		AverageEthereumBlockTime:     15000,
		SlashFractionBatch:           math.LegacyNewDecWithPrec(1, 2),
		SlashFractionBadEthSignature: math.LegacyNewDecWithPrec(1, 2),
	}
)

Functions

func AllInvariants added in v1.8.0

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants collects any defined invariants below

func CheckBatches added in v1.8.0

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 added in v1.8.0

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 gravity vouchers given erc20tokens

func ModuleBalanceInvariant added in v1.8.0

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 NewGravityProposalHandler added in v1.8.0

func NewGravityProposalHandler(k Keeper) govv1beta1types.Handler

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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

AttestationHandler processes `observed` Attestations

func (AttestationHandler) Handle added in v1.8.0

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 added in v1.8.0

func (a AttestationHandler) ValidateMembers()

Check for nil members

type GravityStoreGetter added in v1.8.0

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

func NewGravityStoreGetter added in v1.8.0

func NewGravityStoreGetter(storeKey storetypes.StoreKey) GravityStoreGetter

func (GravityStoreGetter) Store added in v1.8.0

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

	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,
	storeGetter keeperutil.StoreGetter,
	authority string,
	valAddressCodec address.Codec,
) Keeper

NewKeeper returns a new instance of the gravity keeper

func (Keeper) AddToOutgoingPool added in v1.8.0

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) Attest added in v1.8.0

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

func (Keeper) BatchConfirms added in v1.8.0

BatchConfirms returns the batch confirmations by nonce and token contract

func (Keeper) BatchRequestByNonce added in v1.8.0

BatchRequestByNonce queries the BatchRequestByNonce of the gravity module.

func (Keeper) BuildOutgoingTXBatch added in v1.8.0

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 added in v1.8.0

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

CancelOutgoingTXBatch releases all TX in the batch and deletes the batch

func (Keeper) CastAllERC20ToDenoms added in v1.11.0

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

func (Keeper) CheckBadSignatureEvidence added in v1.8.0

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

func (Keeper) DeleteAttestation added in v1.8.0

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

DeleteAttestation deletes the given attestation

func (Keeper) DeleteBatch added in v1.8.0

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

DeleteBatch deletes an outgoing transaction batch

func (Keeper) DeleteBatchConfirms added in v1.8.0

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

DeleteBatchConfirms deletes confirmations for an outgoing transaction batch

func (Keeper) DenomToERC20

DenomToERC20 queries the Paloma Denom that maps to an Ethereum ERC20

func (Keeper) DeserializeValidatorIterator added in v1.8.0

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

DeserializeValidatorIterator returns validators from the validator iterator. Adding here in gravity 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 added in v1.8.0

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

func (Keeper) GetAllERC20ToDenoms added in v1.8.0

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

func (Keeper) GetAttestation added in v1.8.0

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

GetAttestation return an attestation given a nonce

func (Keeper) GetAttestationMapping added in v1.8.0

func (k Keeper) GetAttestationMapping(ctx context.Context) (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 added in v1.8.0

GetAttestations queries the attestation map

func (Keeper) GetAuthority added in v1.13.0

func (k Keeper) GetAuthority() string

func (Keeper) GetBatchConfirm added in v1.8.0

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 added in v1.8.0

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

GetBatchConfirmByNonceAndTokenContract returns the batch confirms

func (Keeper) GetBridgeChainID added in v1.8.0

func (k Keeper) GetBridgeChainID(ctx context.Context) uint64

GetBridgeChainID returns the chain id of the ETH chain we are running against

func (Keeper) GetBridgeContractAddress added in v1.8.0

func (k Keeper) GetBridgeContractAddress(ctx context.Context) (*types.EthAddress, error)

GetBridgeContractAddress returns the bridge contract address on ETH

func (Keeper) GetDenomOfERC20 added in v1.8.0

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

func (Keeper) GetERC20OfDenom added in v1.8.0

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

func (Keeper) GetErc20ToDenoms added in v1.8.0

func (Keeper) GetEthAddressByValidator added in v1.8.0

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 gravity validator

func (Keeper) GetLastEventNonceByValidator added in v1.8.0

func (k Keeper) GetLastEventNonceByValidator(ctx context.Context, validator sdk.ValAddress) (uint64, error)

GetLastEventNonceByValidator returns the latest event nonce for a given validator

func (Keeper) GetLastObservedEthBlock added in v1.8.0

GetLastObservedEthBlock queries the LastObservedEthereumBlockHeight

func (Keeper) GetLastObservedEthNonce added in v1.8.0

GetLastObservedEthNonce queries the LastObservedEventNonce

func (Keeper) GetLastObservedEthereumBlockHeight

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

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

func (Keeper) GetLastObservedEventNonce

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

GetLastObservedEventNonce returns the latest observed event nonce

func (Keeper) GetLastOutgoingBatchByTokenType added in v1.8.0

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) GetLastSlashedBatchBlock added in v1.8.0

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

GetLastSlashedBatchBlock returns the latest slashed Batch block

func (Keeper) GetMostRecentAttestations added in v1.8.0

func (k Keeper) GetMostRecentAttestations(ctx context.Context, 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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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

GetOutgoingTxBatches returns the outgoing tx batches

func (Keeper) GetOutgoingTxBatchesByNonce added in v1.8.0

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 added in v1.8.0

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

GetPastEthSignatureCheckpoint tells you whether a given checkpoint has ever existed

func (Keeper) GetPendingSendToEth added in v1.8.0

func (Keeper) GetStore added in v1.8.0

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

func (Keeper) GetUnSlashedBatches added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 gravity hooks

func (Keeper) InvalidSendToEthAddress added in v1.8.0

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

InvalidSendToEthAddress 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 added in v1.8.0

func (k Keeper) IterateAttestations(ctx context.Context, 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 added in v1.8.0

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 added in v1.8.0

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

IterateBatchConfirms iterates through all batch confirmations

func (Keeper) IterateClaims added in v1.8.0

func (k Keeper) IterateClaims(ctx context.Context, 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 added in v1.8.0

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 added in v1.8.0

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

func (Keeper) IterateUnbatchedTransactions added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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

IterateValidatorLastEventNonces iterates through all batch confirmations

func (Keeper) LastEventNonce added in v1.10.0

LastEventNonce returns the last event nonce observed by Paloma.

func (Keeper) LastEventNonceByAddr added in v1.8.0

LastEventNonceByAddr returns the last event nonce for the given validator address, this allows eth oracles to figure out where they left off

func (Keeper) LastPendingBatchRequestByAddr added in v1.8.0

LastPendingBatchRequestByAddr queries the LastPendingBatchRequestByAddr of the gravity module.

func (Keeper) Logger

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

Logger returns a module-specific Logger.

func (Keeper) OutgoingTxBatchExecuted added in v1.8.0

func (k Keeper) OutgoingTxBatchExecuted(ctx context.Context, tokenContract types.EthAddress, claim types.MsgBatchSendToEthClaim) 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 added in v1.8.0

OutgoingTxBatches queries the OutgoingTxBatches of the gravity module

func (Keeper) Params

Params queries the params of the gravity module

func (Keeper) RemoveFromOutgoingPoolAndRefund added in v1.8.0

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 added in v1.8.0

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) SetAttestation added in v1.8.0

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

SetAttestation sets the attestation in the store

func (Keeper) SetBatchConfirm added in v1.8.0

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

SetBatchConfirm sets a batch confirmation by a validator

func (Keeper) SetLastEventNonceByValidator added in v1.8.0

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

SetLastEventNonceByValidator sets the latest event nonce for a give validator

func (Keeper) SetLastObservedEthereumBlockHeight

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

SetLastObservedEthereumBlockHeight sets the block height in the store.

func (Keeper) SetLastSlashedBatchBlock added in v1.8.0

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 added in v1.8.0

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

SetParams sets the parameters in the store

func (Keeper) SetPastEthSignatureCheckpoint added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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) UnpackAttestationClaim added in v1.8.0

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

type Migrator added in v1.13.0

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

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

func NewMigrator added in v1.13.0

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

NewMigrator returns a new Migrator.

func (Migrator) Migrate4to5 added in v1.13.0

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

Migrate4to5 migrates from version 4 to 5.

type TestInput

type TestInput struct {
	GravityKeeper     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
	GravityStoreKey   *storetypes.KVStoreKey
}

TestInput stores the various keepers required to test gravity

func CreateTestEnv

func CreateTestEnv(t *testing.T) TestInput

CreateTestEnv creates the keeper testing environment for gravity

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 added in v1.8.0

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 added in v1.8.0

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