keeper

package
v0.0.0-...-2da98db Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPendingCctxs is the maximum number of pending cctxs that can be queried
	MaxPendingCctxs = 500

	// MaxLookbackNonce is the maximum number of nonces to look back to find missed pending cctxs
	MaxLookbackNonce = 1000
)
View Source
const (
	// AbortMessage is the message to abort a stuck CCTX
	AbortMessage = "CCTX aborted with admin cmd"
)
View Source
const InCCTXIndexKey = "inCctxIndex"
View Source
const MaxOutboundTrackerHashes = 5

MaxOutboundTrackerHashes is the maximum number of hashes that can be stored in the outbound transaction tracker

View Source
const (
	// RemainingFeesToStabilityPoolPercent is the percentage of remaining fees used to fund the gas stability pool
	RemainingFeesToStabilityPoolPercent = 95
)

Variables

This section is empty.

Functions

func CheckAndUpdateCctxGasPrice

func CheckAndUpdateCctxGasPrice(
	ctx sdk.Context,
	k Keeper,
	cctx types.CrossChainTx,
	flags observertypes.GasPriceIncreaseFlags,
) (math.Uint, math.Uint, error)

CheckAndUpdateCctxGasPrice checks if the retry interval is reached and updates the gas price if so The function returns the gas price increase and the additional fees paid from the gas stability pool

func EmitEventInboundFinalized

func EmitEventInboundFinalized(ctx sdk.Context, cctx *types.CrossChainTx)

func EmitOutboundFailure

func EmitOutboundFailure(ctx sdk.Context, valueReceived string, oldStatus string, newStatus string, cctxIndex string)

func EmitOutboundSuccess

func EmitOutboundSuccess(ctx sdk.Context, valueReceived string, oldStatus string, newStatus string, cctxIndex string)

func EmitZRCWithdrawCreated

func EmitZRCWithdrawCreated(ctx sdk.Context, cctx types.CrossChainTx)

func EmitZetaWithdrawCreated

func EmitZetaWithdrawCreated(ctx sdk.Context, cctx types.CrossChainTx)

func GetAbortedAmount

func GetAbortedAmount(cctx types.CrossChainTx) sdkmath.Uint

GetAbortedAmount returns the amount to refund for a given CCTX . If the CCTX has an outbound transaction, it returns the amount of the outbound transaction. If OutboundParams is nil or the amount is zero, it returns the amount of the inbound transaction. This is because there might be a case where the transaction is set to be aborted before paying gas or creating an outbound transaction.In such a situation we can refund the entire amount that has been locked in connector or TSS

func GetIndexStringForTssMigration

func GetIndexStringForTssMigration(
	currentTssPubkey, newTssPubkey string,
	chainID int64,
	amount sdkmath.Uint,
	height int64,
) string

func GetRefundAddress

func GetRefundAddress(refundAddress string) (ethcommon.Address, error)

GetRefundAddress gets the proper refund address. For BTC sender chain the refund address is the one provided in the message in the RefundAddress field. For EVM chain with coin type ERC20 the refund address is the sender , but can be overridden by the RefundAddress field in the message. For EVM chain with coin type Zeta the refund address is the tx origin, but can be overridden by the RefundAddress field in the message. For EVM chain with coin type Gas the refund address is the tx origin, but can be overridden by the RefundAddress field in the message.

func IsPending

func IsPending(cctx *types.CrossChainTx) bool

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func ParseZRC20WithdrawalEvent

func ParseZRC20WithdrawalEvent(log ethtypes.Log) (*zrc20.ZRC20Withdrawal, error)

ParseZRC20WithdrawalEvent tries extracting ZRC20Withdrawal event from the input logs using the zrc20 contract; It only returns a not-nil event if the event has been correctly validated as a valid withdrawal event

func ParseZetaSentEvent

func ParseZetaSentEvent(
	log ethtypes.Log,
	connectorZEVM ethcommon.Address,
) (*connectorzevm.ZetaConnectorZEVMZetaSent, error)

ParseZetaSentEvent tries extracting ZetaSent event from connectorZEVM contract; returns error if the log entry is not a ZetaSent event, or is not emitted from connectorZEVM It only returns a not-nil event if all the error checks pass

func SortCctxsByHeightAndChainID

func SortCctxsByHeightAndChainID(cctxs []*types.CrossChainTx) []*types.CrossChainTx

SortCctxsByHeightAndChainID sorts the cctxs by height (first come first serve), the chain ID doesn't really matter

Types

type CCTXGateway

type CCTXGateway interface {
	// Initiate a new outbound, this tells the CCTXGateway to carry out the action to execute the outbound.
	// It is the only entry point to initiate an outbound and it returns new CCTX status after it is completed.
	InitiateOutbound(ctx sdk.Context, config InitiateOutboundConfig) (newCCTXStatus types.CctxStatus, err error)
}

CCTXGateway is interface implemented by every gateway. It is one of interfaces used for communication between CCTX gateways and crosschain module, and it is called by crosschain module.

func ResolveCCTXGateway

func ResolveCCTXGateway(c chains.CCTXGateway, keeper Keeper) (CCTXGateway, bool)

ResolveCCTXGateway respolves cctx gateway implementation based on provided cctx gateway

type CCTXGatewayObservers

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

CCTXGatewayObservers is implementation of CCTXGateway interface for observers

func NewCCTXGatewayObservers

func NewCCTXGatewayObservers(crosschainKeeper Keeper) CCTXGatewayObservers

NewCCTXGatewayObservers returns new instance of CCTXGatewayObservers

func (CCTXGatewayObservers) InitiateOutbound

func (c CCTXGatewayObservers) InitiateOutbound(
	ctx sdk.Context,
	config InitiateOutboundConfig,
) (newCCTXStatus types.CctxStatus, err error)

InitiateOutbound updates the store so observers can use the PendingCCTX query:

  • If preprocessing of outbound is successful, the CCTX status is changed to PendingOutbound.

  • if preprocessing of outbound, such as paying the gas fee for the destination fails, the state is reverted to aborted

    We do not return an error from this function, as all changes need to be persisted to the state.

    Instead, we use a temporary context to make changes and then commit the context on for the happy path, i.e cctx is set to PendingOutbound. New CCTX status after preprocessing is returned.

type CCTXGatewayZEVM

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

CCTXGatewayZEVM is implementation of CCTXGateway interface for ZEVM

func NewCCTXGatewayZEVM

func NewCCTXGatewayZEVM(crosschainKeeper Keeper) CCTXGatewayZEVM

NewCCTXGatewayZEVM returns new instance of CCTXGatewayZEVM

func (CCTXGatewayZEVM) InitiateOutbound

func (c CCTXGatewayZEVM) InitiateOutbound(
	ctx sdk.Context,
	config InitiateOutboundConfig,
) (newCCTXStatus types.CctxStatus, err error)

InitiateOutbound handles evm deposit and immediately validates pending outbound

type CheckAndUpdateCctxGasPriceFunc

type CheckAndUpdateCctxGasPriceFunc func(
	ctx sdk.Context,
	k Keeper,
	cctx types.CrossChainTx,
	flags observertypes.GasPriceIncreaseFlags,
) (math.Uint, math.Uint, error)

CheckAndUpdateCctxGasPriceFunc is a function type for checking and updating the gas price of a cctx

type Hooks

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

func (Hooks) PostTxProcessing

func (h Hooks) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error

PostTxProcessing is a wrapper for calling the EVM PostTxProcessing hook on the module keeper

type InitiateOutboundConfig

type InitiateOutboundConfig struct {
	CCTX         *types.CrossChainTx
	ShouldPayGas bool
}

TODO (https://github.com/zeta-chain/node/issues/2345): this is just a tmp solution because some flows require gas payment and others don't. TBD during implementation of issue above if info can be passed to CCTX constructor somehow. and not initialize CCTX using MsgVoteInbound and instead use something like (InboundParams, OutboundParams). Also check if msg.Digest can be replaced to calculate index

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeKey,
	memKey storetypes.StoreKey,
	stakingKeeper types.StakingKeeper,
	authKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	zetaObserverKeeper types.ObserverKeeper,
	fungibleKeeper types.FungibleKeeper,
	authorityKeeper types.AuthorityKeeper,
	lightclientKeeper types.LightclientKeeper,
) *Keeper

func (Keeper) AddFinalizedInbound

func (k Keeper) AddFinalizedInbound(ctx sdk.Context, inboundHash string, chainID int64, eventIndex uint64)

func (Keeper) AddZetaAbortedAmount

func (k Keeper) AddZetaAbortedAmount(ctx sdk.Context, amount sdkmath.Uint)

func (Keeper) ChainGasParams

func (k Keeper) ChainGasParams(
	ctx sdk.Context,
	chainID int64,
) (gasZRC20 ethcommon.Address, gasLimit, gasPrice, protocolFee math.Uint, err error)

ChainGasParams returns the params to calculates the fees for gas for a chain tha gas address, the gas limit, gas price and protocol flat fee are returned

func (Keeper) CheckIfTSSMigrationTransfer

func (k Keeper) CheckIfTSSMigrationTransfer(ctx sdk.Context, msg *types.MsgVoteInbound) error

CheckIfTSSMigrationTransfer checks if the sender is a TSS address and returns an error if it is. If the sender is an older TSS address, this means that it is a migration transfer, and we do not need to treat this as a deposit and process the CCTX

func (Keeper) ConvertGasToZeta

func (Keeper) FundGasStabilityPoolFromRemainingFees

func (k Keeper) FundGasStabilityPoolFromRemainingFees(
	ctx sdk.Context,
	OutboundParams types.OutboundParams,
	chainID int64,
) error

FundGasStabilityPoolFromRemainingFees funds the gas stability pool with the remaining fees of an outbound tx

func (Keeper) FundStabilityPool

func (k Keeper) FundStabilityPool(ctx sdk.Context, cctx *types.CrossChainTx)

FundStabilityPool funds the stability pool with the remaining fees of an outbound tx The funds are sent to the gas stability pool associated with the receiver chain This wraps the FundGasStabilityPoolFromRemainingFees function and logs an error if it fails.We do not return an error here. Event if the funding fails, the outbound tx is still processed.

func (Keeper) GetAllCrossChainTx

func (k Keeper) GetAllCrossChainTx(ctx sdk.Context) (list []types.CrossChainTx)

func (Keeper) GetAllFinalizedInbound

func (k Keeper) GetAllFinalizedInbound(ctx sdk.Context) (list []string)

func (Keeper) GetAllForeignCoins

func (k Keeper) GetAllForeignCoins(ctx sdk.Context) []fungibleModuleTypes.ForeignCoins

func (Keeper) GetAllGasPrice

func (k Keeper) GetAllGasPrice(ctx sdk.Context) (list []types.GasPrice)

GetAllGasPrice returns all gasPrice

func (Keeper) GetAllInboundHashToCctx

func (k Keeper) GetAllInboundHashToCctx(ctx sdk.Context) (list []types.InboundHashToCctx)

GetAllInboundHashToCctx returns all inboundHashToCctx

func (Keeper) GetAllInboundTracker

func (k Keeper) GetAllInboundTracker(ctx sdk.Context) (inTxTrackers []types.InboundTracker)

func (Keeper) GetAllInboundTrackerForChain

func (k Keeper) GetAllInboundTrackerForChain(ctx sdk.Context, chainID int64) (list []types.InboundTracker)

func (Keeper) GetAllInboundTrackerForChainPaginated

func (k Keeper) GetAllInboundTrackerForChainPaginated(
	ctx sdk.Context,
	chainID int64,
	pagination *query.PageRequest,
) (inTxTrackers []types.InboundTracker, pageRes *query.PageResponse, err error)

func (Keeper) GetAllInboundTrackerPaginated

func (k Keeper) GetAllInboundTrackerPaginated(
	ctx sdk.Context,
	pagination *query.PageRequest,
) (inTxTrackers []types.InboundTracker, pageRes *query.PageResponse, err error)

func (Keeper) GetAllLastBlockHeight

func (k Keeper) GetAllLastBlockHeight(ctx sdk.Context) (list []types.LastBlockHeight)

GetAllLastBlockHeight returns all lastBlockHeight

func (Keeper) GetAllOutboundTracker

func (k Keeper) GetAllOutboundTracker(ctx sdk.Context) (list []types.OutboundTracker)

GetAllOutboundTracker returns all outbound trackers

func (Keeper) GetAuthKeeper

func (k Keeper) GetAuthKeeper() types.AccountKeeper

func (Keeper) GetAuthorityKeeper

func (k Keeper) GetAuthorityKeeper() types.AuthorityKeeper

func (Keeper) GetBankKeeper

func (k Keeper) GetBankKeeper() types.BankKeeper

func (Keeper) GetCodec

func (k Keeper) GetCodec() codec.Codec

func (Keeper) GetCrossChainTx

func (k Keeper) GetCrossChainTx(ctx sdk.Context, index string) (val types.CrossChainTx, found bool)

GetCrossChainTx returns a send from its index

func (Keeper) GetFungibleKeeper

func (k Keeper) GetFungibleKeeper() types.FungibleKeeper

func (Keeper) GetGasPrice

func (k Keeper) GetGasPrice(ctx sdk.Context, chainID int64) (val types.GasPrice, found bool)

GetGasPrice returns a gasPrice from its index

func (Keeper) GetIBCCrosschainKeeper

func (k Keeper) GetIBCCrosschainKeeper() types.IBCCrosschainKeeper

func (Keeper) GetInboundHashToCctx

func (k Keeper) GetInboundHashToCctx(
	ctx sdk.Context,
	inboundHash string,

) (val types.InboundHashToCctx, found bool)

GetInboundHashToCctx returns a inboundHashToCctx from its index

func (Keeper) GetInboundTracker

func (k Keeper) GetInboundTracker(
	ctx sdk.Context,
	chainID int64,
	txHash string,
) (val types.InboundTracker, found bool)

GetInboundTracker returns a InboundTracker from its index

func (Keeper) GetLastBlockHeight

func (k Keeper) GetLastBlockHeight(ctx sdk.Context, index string) (val types.LastBlockHeight, found bool)

GetLastBlockHeight returns a lastBlockHeight from its index

func (Keeper) GetLightclientKeeper

func (k Keeper) GetLightclientKeeper() types.LightclientKeeper

func (Keeper) GetMedianGasPriceInUint

func (k Keeper) GetMedianGasPriceInUint(ctx sdk.Context, chainID int64) (sdk.Uint, bool)

func (Keeper) GetMemKey

func (k Keeper) GetMemKey() storetypes.StoreKey

func (Keeper) GetObserverKeeper

func (k Keeper) GetObserverKeeper() types.ObserverKeeper

func (Keeper) GetOutboundTracker

func (k Keeper) GetOutboundTracker(
	ctx sdk.Context,
	chainID int64,
	nonce uint64,
) (val types.OutboundTracker, found bool)

GetOutboundTracker returns an outbound tracker from its index

func (Keeper) GetRateLimiterAssetRateList

func (k Keeper) GetRateLimiterAssetRateList(
	ctx sdk.Context,
) (flags types.RateLimiterFlags, assetRates []types.AssetRate, found bool)

GetRateLimiterAssetRateList returns a list of all foreign asset rate

func (Keeper) GetRateLimiterFlags

func (k Keeper) GetRateLimiterFlags(ctx sdk.Context) (val types.RateLimiterFlags, found bool)

GetRateLimiterFlags returns the rate limiter flags

func (Keeper) GetRevertGasLimit

func (k Keeper) GetRevertGasLimit(ctx sdk.Context, cctx types.CrossChainTx) (uint64, error)

GetRevertGasLimit returns the gas limit for the revert transaction in a CCTX It returns 0 if there is no error but the gas limit can't be determined from the CCTX data

func (Keeper) GetStakingKeeper

func (k Keeper) GetStakingKeeper() types.StakingKeeper

func (Keeper) GetStoreKey

func (k Keeper) GetStoreKey() storetypes.StoreKey

func (Keeper) GetZetaAccounting

func (k Keeper) GetZetaAccounting(ctx sdk.Context) (val types.ZetaAccounting, found bool)

func (Keeper) HandleEVMDeposit

func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (bool, error)

HandleEVMDeposit handles a deposit from an inbound tx returns (isContractReverted, err) (true, non-nil) means CallEVM() reverted

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

func (Keeper) InTxHashToCctx

InTxHashToCctx Deprecated(v17): use InboundHashToCctx

func (Keeper) InTxHashToCctxAll

InTxHashToCctxAll Deprecated(v17): use InboundHashToCctxAll

func (Keeper) InTxHashToCctxData

InTxHashToCctxData Deprecated(v17): use InboundHashToCctxData

func (Keeper) InTxTrackerAll

InTxTrackerAll Deprecated(v17): use InboundTrackerAll

func (Keeper) InTxTrackerAllByChain

InTxTrackerAllByChain Deprecated(v17): use InboundTrackerAllByChain

func (Keeper) InboundHashToCctxData

InboundHashToCctxData queries the data of all cctxs indexed by a in tx hash

func (Keeper) InitiateOutbound

func (k Keeper) InitiateOutbound(ctx sdk.Context, config InitiateOutboundConfig) (types.CctxStatus, error)

InitiateOutbound initiates the outbound for the CCTX depending on the CCTX gateway. It does a conditional dispatch to correct CCTX gateway based on the receiver chain which handles the state changes and error handling.

func (Keeper) IsFinalizedInbound

func (k Keeper) IsFinalizedInbound(ctx sdk.Context, inboundHash string, chainID int64, eventIndex uint64) bool

func (Keeper) IterateAndUpdateCctxGasPrice

func (k Keeper) IterateAndUpdateCctxGasPrice(
	ctx sdk.Context,
	chains []zetachains.Chain,
	updateFunc CheckAndUpdateCctxGasPriceFunc,
) (int, observertypes.GasPriceIncreaseFlags)

IterateAndUpdateCctxGasPrice iterates through all cctx and updates the gas price if pending for too long The function returns the number of cctxs updated and the gas price increase flags used

func (Keeper) ListPendingCctx

ListPendingCctx returns a list of pending cctxs and the total number of pending cctxs a limit for the number of cctxs to return can be specified or the default is MaxPendingCctxs

func (Keeper) ListPendingCctxWithinRateLimit

ListPendingCctxWithinRateLimit returns a list of pending cctxs that do not exceed the outbound rate limit a limit for the number of cctxs to return can be specified or the default is MaxPendingCctxs

func (Keeper) Logger

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

func (Keeper) MigrateTSSFundsForChain

func (k Keeper) MigrateTSSFundsForChain(
	ctx sdk.Context,
	chainID int64,
	amount sdkmath.Uint,
	currentTss observertypes.TSS,
	tssList []observertypes.TSS,
) error

func (Keeper) OutTxTracker

OutTxTracker Deprecated(v17): use OutboundTracker

func (Keeper) OutTxTrackerAll

OutTxTrackerAll Deprecated(v17): use OutboundTrackerAll

func (Keeper) OutTxTrackerAllByChain

OutTxTrackerAllByChain Deprecated(v17): use OutboundTrackerAllByChain

func (Keeper) PayGasAndUpdateCctx

func (k Keeper) PayGasAndUpdateCctx(
	ctx sdk.Context,
	chainID int64,
	cctx *types.CrossChainTx,
	inputAmount math.Uint,
	noEthereumTxEvent bool,
) error

PayGasAndUpdateCctx updates the outbound tx with the new amount after paying the gas fee **Caller should feed temporary ctx into this function** chainID is the outbound chain chain id , this can be receiver chain for regular transactions and sender-chain to reverted transactions

func (Keeper) PayGasInERC20AndUpdateCctx

func (k Keeper) PayGasInERC20AndUpdateCctx(
	ctx sdk.Context,
	chainID int64,
	cctx *types.CrossChainTx,
	inputAmount math.Uint,
	noEthereumTxEvent bool,
) error

PayGasInERC20AndUpdateCctx updates parameter cctx amount subtracting the gas fee the gas fee in ERC20 is calculated by swapping ERC20 -> Zeta -> Gas if the route is not available, the gas payment will fail **Caller should feed temporary ctx into this function**

func (Keeper) PayGasInZetaAndUpdateCctx

func (k Keeper) PayGasInZetaAndUpdateCctx(
	ctx sdk.Context,
	chainID int64,
	cctx *types.CrossChainTx,
	zetaBurnt math.Uint,
	noEthereumTxEvent bool,
) error

PayGasInZetaAndUpdateCctx updates parameter cctx with the gas price and gas fee for the outbound tx; it also makes a trade to fulfill the outbound tx gas fee in ZETA by swapping ZETA for some gas ZRC20 balances The gas ZRC20 balance is subsequently burned to account for the expense of TSS address gas fee payment in the outbound tx. zetaBurnt represents the amount of Zeta that has been burnt for the tx, the final amount for the tx is zetaBurnt - gasFee **Caller should feed temporary ctx into this function**

func (Keeper) PayGasNativeAndUpdateCctx

func (k Keeper) PayGasNativeAndUpdateCctx(
	ctx sdk.Context,
	chainID int64,
	cctx *types.CrossChainTx,
	inputAmount math.Uint,
) error

PayGasNativeAndUpdateCctx updates the outbound tx with the new amount subtracting the gas fee **Caller should feed temporary ctx into this function**

func (Keeper) PostTxProcessing

func (k Keeper) PostTxProcessing(
	ctx sdk.Context,
	msg core.Message,
	receipt *ethtypes.Receipt,
) error

PostTxProcessing implements EvmHooks.PostTxProcessing.

func (Keeper) ProcessLogs

func (k Keeper) ProcessLogs(
	ctx sdk.Context,
	logs []*ethtypes.Log,
	emittingContract ethcommon.Address,
	txOrigin string,
) error

ProcessLogs post-processes logs emitted by a zEVM contract; if the log contains Withdrawal event from registered ZRC20 contract, new CCTX will be created to trigger and track outbound transaction. Returning error from process logs does the following: - revert the whole tx. - clear the logs TODO: implement unit tests https://github.com/zeta-chain/node/issues/1759

func (Keeper) ProcessZRC20WithdrawalEvent

func (k Keeper) ProcessZRC20WithdrawalEvent(
	ctx sdk.Context,
	event *zrc20.ZRC20Withdrawal,
	emittingContract ethcommon.Address,
	txOrigin string,
) error

ProcessZRC20WithdrawalEvent creates a new CCTX to process the withdrawal event error indicates system error and non-recoverable; should abort

func (Keeper) ProcessZetaSentEvent

func (k Keeper) ProcessZetaSentEvent(
	ctx sdk.Context,
	event *connectorzevm.ZetaConnectorZEVMZetaSent,
	emittingContract ethcommon.Address,
	txOrigin string,
) error

func (Keeper) RateLimiterFlags

RateLimiterFlags queries the rate limiter flags

func (Keeper) RateLimiterInput

RateLimiterInput collects the input data for the rate limiter

func (Keeper) RefundAbortedAmountOnZetaChain

func (k Keeper) RefundAbortedAmountOnZetaChain(
	ctx sdk.Context,
	cctx types.CrossChainTx,
	refundAddress ethcommon.Address,
) error

func (Keeper) RefundAmountOnZetaChainERC20

func (k Keeper) RefundAmountOnZetaChainERC20(
	ctx sdk.Context,
	cctx types.CrossChainTx,
	refundAddress ethcommon.Address,
) error

RefundAmountOnZetaChainERC20 refunds the amount of the cctx on ZetaChain in case of aborted cctx NOTE: GetCurrentOutboundParam should contain the last up to date cctx amount Refund address should already be validated before calling this function

func (Keeper) RefundAmountOnZetaChainGas

func (k Keeper) RefundAmountOnZetaChainGas(
	ctx sdk.Context,
	cctx types.CrossChainTx,
	refundAddress ethcommon.Address,
) error

RefundAmountOnZetaChainGas refunds the amount of the cctx on ZetaChain in case of aborted cctx with cointype gas

func (Keeper) RefundAmountOnZetaChainZeta

func (k Keeper) RefundAmountOnZetaChainZeta(
	ctx sdk.Context,
	cctx types.CrossChainTx,
	refundAddress ethcommon.Address,
) error

RefundAmountOnZetaChainZeta refunds the amount of the cctx on ZetaChain in case of aborted cctx with cointype zeta

func (Keeper) RemoveCrossChainTx

func (k Keeper) RemoveCrossChainTx(ctx sdk.Context, index string)

RemoveCrossChainTx removes a send from the store

func (Keeper) RemoveGasPrice

func (k Keeper) RemoveGasPrice(ctx sdk.Context, index string)

RemoveGasPrice removes a gasPrice from the store

func (Keeper) RemoveInboundHashToCctx

func (k Keeper) RemoveInboundHashToCctx(
	ctx sdk.Context,
	inboundHash string,

)

RemoveInboundHashToCctx removes a inboundHashToCctx from the store

func (Keeper) RemoveInboundTrackerIfExists

func (k Keeper) RemoveInboundTrackerIfExists(ctx sdk.Context, chainID int64, txHash string)

func (Keeper) RemoveLastBlockHeight

func (k Keeper) RemoveLastBlockHeight(ctx sdk.Context, index string)

RemoveLastBlockHeight removes a lastBlockHeight from the store

func (Keeper) RemoveOutboundTrackerFromStore

func (k Keeper) RemoveOutboundTrackerFromStore(
	ctx sdk.Context,
	chainID int64,
	nonce uint64,
)

RemoveOutboundTrackerFromStore removes a outbound tracker from the store

func (Keeper) RemoveZetaAbortedAmount

func (k Keeper) RemoveZetaAbortedAmount(ctx sdk.Context, amount sdkmath.Uint) error

func (Keeper) ResetGasMeterAndConsumeGas

func (k Keeper) ResetGasMeterAndConsumeGas(ctx sdk.Context, gasUsed uint64)

ResetGasMeterAndConsumeGas reset first the gas meter consumed value to zero and set it back to the new value 'gasUsed'

func (Keeper) SaveFailedOutbound

func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, ballotIndex string)

func (Keeper) SaveObservedInboundInformation

func (k Keeper) SaveObservedInboundInformation(ctx sdk.Context, cctx *types.CrossChainTx, eventIndex uint64)

func (Keeper) SaveOutbound

func (k Keeper) SaveOutbound(ctx sdk.Context, cctx *types.CrossChainTx, ballotIndex string)

SaveOutbound saves the outbound transaction.It does the following things in one function:

  1. Set the ballot index for the outbound vote to the cctx

  2. Remove the nonce from the pending nonces

  3. Remove the outbound tx tracker

  4. Set the cctx and nonce to cctx and inboundHash to cctx

func (Keeper) SaveSuccessfulOutbound

func (k Keeper) SaveSuccessfulOutbound(ctx sdk.Context, cctx *types.CrossChainTx, ballotIndex string)

SaveSuccessfulOutbound saves a successful outbound transaction. This function does not set the CCTX status, therefore all successful outbound transactions need to have their status set during processing

func (Keeper) SetCctxAndNonceToCctxAndInboundHashToCctx

func (k Keeper) SetCctxAndNonceToCctxAndInboundHashToCctx(ctx sdk.Context, cctx types.CrossChainTx)

SetCctxAndNonceToCctxAndInboundHashToCctx does the following things in one function: 1. set the cctx in the store 2. set the mapping inboundHash -> cctxIndex , one inboundHash can be connected to multiple cctxindex 3. set the mapping nonce => cctx 4. update the zeta accounting

func (Keeper) SetCrossChainTx

func (k Keeper) SetCrossChainTx(ctx sdk.Context, cctx types.CrossChainTx)

SetCrossChainTx set a specific send in the store from its index

func (Keeper) SetFinalizedInbound

func (k Keeper) SetFinalizedInbound(ctx sdk.Context, finalizedInboundIndex string)

func (Keeper) SetGasPrice

func (k Keeper) SetGasPrice(ctx sdk.Context, gasPrice types.GasPrice)

SetGasPrice set a specific gasPrice in the store from its index

func (*Keeper) SetIBCCrosschainKeeper

func (k *Keeper) SetIBCCrosschainKeeper(ibcCrosschainKeeper types.IBCCrosschainKeeper)

func (Keeper) SetInboundHashToCctx

func (k Keeper) SetInboundHashToCctx(ctx sdk.Context, inboundHashToCctx types.InboundHashToCctx)

SetInboundHashToCctx set a specific inboundHashToCctx in the store from its index

func (Keeper) SetInboundTracker

func (k Keeper) SetInboundTracker(ctx sdk.Context, InboundTracker types.InboundTracker)

SetInboundTracker set a specific InboundTracker in the store from its index

func (Keeper) SetLastBlockHeight

func (k Keeper) SetLastBlockHeight(ctx sdk.Context, lastBlockHeight types.LastBlockHeight)

SetLastBlockHeight set a specific lastBlockHeight in the store from its index

func (Keeper) SetObserverOutboundInfo

func (k Keeper) SetObserverOutboundInfo(ctx sdk.Context, receiveChainID int64, cctx *types.CrossChainTx) error

SetObserverOutboundInfo sets the CCTX outbound nonce to the next available nonce for the TSS address, and updates the nonce of blockchain state. It also updates the PendingNonces that is used to track the unfulfilled outbound txs.

func (Keeper) SetOutboundTracker

func (k Keeper) SetOutboundTracker(ctx sdk.Context, outboundTracker types.OutboundTracker)

SetOutboundTracker set a specific outbound tracker in the store from its index

func (Keeper) SetRateLimiterFlags

func (k Keeper) SetRateLimiterFlags(ctx sdk.Context, rateLimiterFlags types.RateLimiterFlags)

SetRateLimiterFlags set the rate limiter flags in the store

func (Keeper) SetZetaAccounting

func (k Keeper) SetZetaAccounting(ctx sdk.Context, abortedZetaAmount types.ZetaAccounting)

func (Keeper) ValidateInbound

func (k Keeper) ValidateInbound(
	ctx sdk.Context,
	msg *types.MsgVoteInbound,
	shouldPayGas bool,
) (*types.CrossChainTx, error)

ValidateInbound is the only entry-point to create new CCTX (eg. when observers voting is done or new inbound event is detected). It creates new CCTX object and calls InitiateOutbound method.

func (Keeper) ValidateOutboundMessage

func (k Keeper) ValidateOutboundMessage(ctx sdk.Context, msg types.MsgVoteOutbound) (types.CrossChainTx, error)

func (Keeper) ValidateOutboundObservers

func (k Keeper) ValidateOutboundObservers(
	ctx sdk.Context,
	cctx *types.CrossChainTx,
	ballotStatus observertypes.BallotStatus,
	valueReceived string,
) error

ValidateOutboundObservers processes the finalization of an outbound transaction based on the ballot status. The state is committed only if the individual steps are successful.

func (Keeper) ValidateOutboundZEVM

func (k Keeper) ValidateOutboundZEVM(
	ctx sdk.Context,
	cctx *types.CrossChainTx,
	depositErr error,
	isContractReverted bool,
) (newCCTXStatus types.CctxStatus)

ValidateOutboundZEVM processes the finalization of an outbound transaction if receiver is ZEVM. It takes deposit error and information if contract revert happened during deposit, to make a decision:

- If the deposit was successful, the CCTX status is changed to OutboundMined.

- If the deposit returned an internal error, but isContractReverted is false, the CCTX status is changed to Aborted.

- If the deposit is reverted, the function tries to create a revert cctx with status PendingRevert.

- If the creation of revert tx also fails it changes the status to Aborted.

Note : Aborted CCTXs are not refunded in this function. The refund is done using a separate refunding mechanism. We do not return an error from this function, as all changes need to be persisted to the state. Instead we use a temporary context to make changes and then commit the context on for the happy path, i.e cctx is set to OutboundMined. New CCTX status after preprocessing is returned.

func (Keeper) ValidateZrc20WithdrawEvent

func (k Keeper) ValidateZrc20WithdrawEvent(ctx sdk.Context, event *zrc20.ZRC20Withdrawal, chainID int64) error

ValidateZrc20WithdrawEvent checks if the ZRC20Withdrawal event is valid It verifies event information for BTC chains and returns an error if the event is invalid

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

NewMigrator returns a new Migrator.

func (Migrator) Migrate1to2

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

Migrate1to2 migrates the store from consensus version 1 to 2

func (Migrator) Migrate2to3

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

Migrate2to3 migrates the store from consensus version 2 to 3

func (Migrator) Migrate3to4

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

Migrate3to4 migrates the store from consensus version 3 to 4

func (Migrator) Migrate4to5

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

Migrate4to5 migrates the store from consensus version 4 to 5

Jump to

Keyboard shortcuts

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