Documentation ¶
Overview ¶
Package zetacore provides the client to interact with zetacore node via GRPC.
Index ¶
- Constants
- func GasPriceMultiplier(chain chains.Chain) (float64, error)
- func GetInboundVoteMessage(sender string, senderChain int64, txOrigin string, receiver string, ...) *types.MsgVoteInbound
- func HandleBroadcastError(err error, nonce, toChain, outboundHash string) (bool, bool)
- func WrapMessageWithAuthz(msg sdk.Msg) (sdk.Msg, clientauthz.Signer, error)
- type Client
- func (c *Client) AddOutboundTracker(ctx context.Context, chainID int64, nonce uint64, txHash string, ...) (string, error)
- func (c *Client) Broadcast(ctx context.Context, gasLimit uint64, authzWrappedMsg sdktypes.Msg, ...) (string, error)
- func (c *Client) Chain() chains.Chain
- func (c *Client) GetAbortedZetaAmount(ctx context.Context) (string, error)
- func (c *Client) GetAccountNumberAndSequenceNumber(_ authz.KeyType) (uint64, uint64, error)
- func (c *Client) GetAdditionalChains(ctx context.Context) ([]chains.Chain, error)
- func (c *Client) GetAllCctx(ctx context.Context) ([]*types.CrossChainTx, error)
- func (c *Client) GetAllNodeAccounts(ctx context.Context) ([]*types.NodeAccount, error)
- func (c *Client) GetAllOutboundTrackerByChain(ctx context.Context, chainID int64, order interfaces.Order) ([]types.OutboundTracker, error)
- func (c *Client) GetBTCTSSAddress(ctx context.Context, chainID int64) (string, error)
- func (c *Client) GetBallot(ctx context.Context, ballotIdentifier string) (*types.QueryBallotByIdentifierResponse, error)
- func (c *Client) GetBallotByID(ctx context.Context, id string) (*types.QueryBallotByIdentifierResponse, error)
- func (c *Client) GetBaseGasPrice(ctx context.Context) (int64, error)
- func (c *Client) GetBlockHeaderChainState(ctx context.Context, chainID int64) (*types.ChainState, error)
- func (c *Client) GetBlockHeaderEnabledChains(ctx context.Context) ([]types.HeaderSupportedChain, error)
- func (c *Client) GetBlockHeight(ctx context.Context) (int64, error)
- func (c *Client) GetCctxByHash(ctx context.Context, sendHash string) (*types.CrossChainTx, error)
- func (c *Client) GetCctxByNonce(ctx context.Context, chainID int64, nonce uint64) (*types.CrossChainTx, error)
- func (c *Client) GetChainParams(ctx context.Context) ([]*types.ChainParams, error)
- func (c *Client) GetChainParamsForChainID(ctx context.Context, externalChainID int64) (*types.ChainParams, error)
- func (c *Client) GetCrosschainFlags(ctx context.Context) (types.CrosschainFlags, error)
- func (c *Client) GetCurrentTSS(ctx context.Context) (types.TSS, error)
- func (c *Client) GetEVMTSSAddress(ctx context.Context) (string, error)
- func (c *Client) GetGenesisSupply(ctx context.Context) (sdkmath.Int, error)
- func (c *Client) GetInboundTrackersForChain(ctx context.Context, chainID int64) ([]types.InboundTracker, error)
- func (c *Client) GetKeyGen(ctx context.Context) (*types.Keygen, error)
- func (c *Client) GetKeys() keyinterfaces.ObserverKeys
- func (c *Client) GetLastBlockHeight(ctx context.Context) (uint64, error)
- func (c *Client) GetLatestZetaBlock(ctx context.Context) (*tmservice.Block, error)
- func (c *Client) GetLogger() *zerolog.Logger
- func (c *Client) GetNodeInfo(ctx context.Context) (*tmservice.GetNodeInfoResponse, error)
- func (c *Client) GetNonceByChain(ctx context.Context, chain chains.Chain) (types.ChainNonces, error)
- func (c *Client) GetObserverList(ctx context.Context) ([]string, error)
- func (c *Client) GetOutboundTracker(ctx context.Context, chain chains.Chain, nonce uint64) (*types.OutboundTracker, error)
- func (c *Client) GetPendingNonces(ctx context.Context) (*types.QueryAllPendingNoncesResponse, error)
- func (c *Client) GetPendingNoncesByChain(ctx context.Context, chainID int64) (types.PendingNonces, error)
- func (c *Client) GetRateLimiterFlags(ctx context.Context) (types.RateLimiterFlags, error)
- func (c *Client) GetRateLimiterInput(ctx context.Context, window int64) (*types.QueryRateLimiterInputResponse, error)
- func (c *Client) GetSupportedChains(ctx context.Context) ([]chains.Chain, error)
- func (c *Client) GetTSSHistory(ctx context.Context) ([]types.TSS, error)
- func (c *Client) GetUpgradePlan(ctx context.Context) (*upgradetypes.Plan, error)
- func (c *Client) GetZetaHotKeyBalance(ctx context.Context) (sdkmath.Int, error)
- func (c *Client) GetZetaTokenSupplyOnNode(ctx context.Context) (sdkmath.Int, error)
- func (c *Client) HasVoted(ctx context.Context, ballotIndex string, voterAddress string) (bool, error)
- func (c *Client) ListPendingCCTX(ctx context.Context, chainID int64) ([]*types.CrossChainTx, uint64, error)
- func (c *Client) ListPendingCCTXWithinRateLimit(ctx context.Context) (*types.QueryListPendingCctxWithinRateLimitResponse, error)
- func (c *Client) MonitorVoteInboundResult(ctx context.Context, zetaTxHash string, retryGasLimit uint64, ...) error
- func (c *Client) MonitorVoteOutboundResult(ctx context.Context, zetaTxHash string, retryGasLimit uint64, ...) error
- func (c *Client) OnBeforeStop(callback func())
- func (c *Client) PostVoteBlameData(ctx context.Context, blame *blame.Blame, chainID int64, index string) (string, error)
- func (c *Client) PostVoteBlockHeader(ctx context.Context, chainID int64, blockHash []byte, height int64, ...) (string, error)
- func (c *Client) PostVoteGasPrice(ctx context.Context, chain chains.Chain, gasPrice uint64, supply string, ...) (string, error)
- func (c *Client) PostVoteInbound(ctx context.Context, gasLimit, retryGasLimit uint64, msg *types.MsgVoteInbound) (string, string, error)
- func (c *Client) PostVoteOutbound(ctx context.Context, gasLimit, retryGasLimit uint64, ...) (string, string, error)
- func (c *Client) PostVoteTSS(ctx context.Context, tssPubKey string, keyGenZetaHeight int64, ...) (string, error)
- func (c *Client) Prove(ctx context.Context, blockHash string, txHash string, txIndex int64, ...) (bool, error)
- func (c *Client) QueryTxResult(hash string) (*sdktypes.TxResponse, error)
- func (c *Client) SetAccountNumber(keyType authz.KeyType) error
- func (c *Client) SignTx(txf clienttx.Factory, name string, txBuilder client.TxBuilder, ...) error
- func (c *Client) Stop()
- func (c *Client) UpdateChainID(chainID string) error
- func (c *Client) UpdateZetacoreContext(ctx context.Context, appContext *zctx.AppContext, init bool, ...) error
- func (c *Client) UpdateZetacoreContextWorker(ctx context.Context, app *appcontext.AppContext)
- func (c *Client) WaitForZetacoreToCreateBlocks(ctx context.Context) error
- type Opt
Constants ¶
const ( // DefaultBaseGasPrice is the default base gas price DefaultBaseGasPrice = 1_000_000 // DefaultGasLimit is the default gas limit used for broadcasting txs DefaultGasLimit = 200_000 // PostGasPriceGasLimit is the gas limit for voting new gas price PostGasPriceGasLimit = 1_500_000 // PostVoteInboundGasLimit is the gas limit for voting on observed inbound tx (for zetachain itself) PostVoteInboundGasLimit = 500_000 // PostVoteInboundExecutionGasLimit is the gas limit for voting on observed inbound tx and executing it PostVoteInboundExecutionGasLimit = 4_000_000 // PostVoteInboundMessagePassingExecutionGasLimit is the gas limit for voting on, and executing ,observed inbound tx related to message passing (coin_type == zeta) PostVoteInboundMessagePassingExecutionGasLimit = 4_000_000 // AddOutboundTrackerGasLimit is the gas limit for adding tx hash to out tx tracker AddOutboundTrackerGasLimit = 200_000 // PostBlameDataGasLimit is the gas limit for voting on blames PostBlameDataGasLimit = 200_000 // DefaultRetryCount is the number of retries for broadcasting a tx DefaultRetryCount = 5 // ExtendedRetryCount is an extended number of retries for broadcasting a tx, used in keygen operations ExtendedRetryCount = 15 // DefaultRetryInterval is the interval between retries in seconds DefaultRetryInterval = 5 // PostVoteOutboundGasLimit is the gas limit for voting on observed outbound tx (for zetachain itself) PostVoteOutboundGasLimit = 500_000 // PostVoteOutboundRevertGasLimit is the gas limit for voting on observed outbound tx for revert (when outbound fails) // The value needs to be higher because reverting implies interacting with the EVM to perform swaps for the gas token PostVoteOutboundRevertGasLimit = 1_500_000 )
Variables ¶
This section is empty.
Functions ¶
func GasPriceMultiplier ¶
GasPriceMultiplier returns the gas price multiplier for the given chain
func GetInboundVoteMessage ¶
func GetInboundVoteMessage( sender string, senderChain int64, txOrigin string, receiver string, receiverChain int64, amount math.Uint, message string, inboundHash string, inBlockHeight uint64, gasLimit uint64, coinType coin.CoinType, asset string, signerAddress string, eventIndex uint, ) *types.MsgVoteInbound
GetInboundVoteMessage returns a new MsgVoteInbound TODO(revamp): move to a different file
func HandleBroadcastError ¶
HandleBroadcastError returns whether to retry in a few seconds, and whether to report via AddOutboundTracker returns (bool retry, bool report)
func WrapMessageWithAuthz ¶
WrapMessageWithAuthz wraps a message with an authz message used since a hotkey is used to broadcast the transactions, instead of the operator
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the client to send tx to zetacore
func NewClient ¶
func NewClient( keys keyinterfaces.ObserverKeys, chainIP string, signerName string, chainID string, hsmMode bool, logger zerolog.Logger, opts ...Opt, ) (*Client, error)
NewClient create a new instance of Client
func (*Client) AddOutboundTracker ¶
func (c *Client) AddOutboundTracker( ctx context.Context, chainID int64, nonce uint64, txHash string, proof *proofs.Proof, blockHash string, txIndex int64, ) (string, error)
AddOutboundTracker adds an outbound tracker TODO(revamp): rename to PostAddOutboundTracker
func (*Client) Broadcast ¶
func (c *Client) Broadcast( ctx context.Context, gasLimit uint64, authzWrappedMsg sdktypes.Msg, authzSigner authz.Signer, ) (string, error)
Broadcast Broadcasts tx to ZetaChain. Returns txHash and error
func (*Client) GetAbortedZetaAmount ¶
GetAbortedZetaAmount returns the amount of zeta that has been aborted
func (*Client) GetAccountNumberAndSequenceNumber ¶
GetAccountNumberAndSequenceNumber We do not use multiple KeyType for now , but this can be optionally used in the future to seprate TSS signer from Zetaclient GRantee
func (*Client) GetAdditionalChains ¶
GetAdditionalChains returns the additional chains
func (*Client) GetAllCctx ¶
GetAllCctx returns all cross chain transactions
func (*Client) GetAllNodeAccounts ¶
GetAllNodeAccounts returns all node accounts
func (*Client) GetAllOutboundTrackerByChain ¶
func (c *Client) GetAllOutboundTrackerByChain( ctx context.Context, chainID int64, order interfaces.Order, ) ([]types.OutboundTracker, error)
GetAllOutboundTrackerByChain returns all outbound trackers for a chain
func (*Client) GetBTCTSSAddress ¶
GetBTCTSSAddress returns the BTC TSS address
func (*Client) GetBallot ¶
func (c *Client) GetBallot( ctx context.Context, ballotIdentifier string, ) (*types.QueryBallotByIdentifierResponse, error)
GetBallot returns a ballot by ID
func (*Client) GetBallotByID ¶
func (c *Client) GetBallotByID(ctx context.Context, id string) (*types.QueryBallotByIdentifierResponse, error)
GetBallotByID returns a ballot by ID
func (*Client) GetBaseGasPrice ¶
GetBaseGasPrice returns the base gas price
func (*Client) GetBlockHeaderChainState ¶
func (c *Client) GetBlockHeaderChainState(ctx context.Context, chainID int64) (*types.ChainState, error)
GetBlockHeaderChainState returns the block header chain state
func (*Client) GetBlockHeaderEnabledChains ¶
func (c *Client) GetBlockHeaderEnabledChains(ctx context.Context) ([]types.HeaderSupportedChain, error)
GetBlockHeaderEnabledChains returns the enabled chains for block headers
func (*Client) GetBlockHeight ¶
GetBlockHeight returns the zetachain block height
func (*Client) GetCctxByHash ¶
func (*Client) GetCctxByNonce ¶
func (c *Client) GetCctxByNonce(ctx context.Context, chainID int64, nonce uint64) (*types.CrossChainTx, error)
GetCctxByNonce returns a cross chain transaction by nonce
func (*Client) GetChainParams ¶
GetChainParams returns all the chain params
func (*Client) GetChainParamsForChainID ¶
func (c *Client) GetChainParamsForChainID( ctx context.Context, externalChainID int64, ) (*types.ChainParams, error)
GetChainParamsForChainID returns the chain params for a given chain ID
func (*Client) GetCrosschainFlags ¶
GetCrosschainFlags returns the crosschain flags
func (*Client) GetCurrentTSS ¶
GetCurrentTSS returns the current TSS
func (*Client) GetEVMTSSAddress ¶
GetEVMTSSAddress returns the EVM TSS address.
func (*Client) GetGenesisSupply ¶
GetGenesisSupply returns the genesis supply. NOTE that this method is brittle as it uses STATEFUL connection
func (*Client) GetInboundTrackersForChain ¶
func (c *Client) GetInboundTrackersForChain(ctx context.Context, chainID int64) ([]types.InboundTracker, error)
GetInboundTrackersForChain returns the inbound trackers for a chain
func (*Client) GetKeys ¶
func (c *Client) GetKeys() keyinterfaces.ObserverKeys
func (*Client) GetLastBlockHeight ¶
GetLastBlockHeight returns the zetachain block height
func (*Client) GetLatestZetaBlock ¶
GetLatestZetaBlock returns the latest zeta block
func (*Client) GetNodeInfo ¶
GetNodeInfo returns the node info
func (*Client) GetNonceByChain ¶
func (c *Client) GetNonceByChain(ctx context.Context, chain chains.Chain) (types.ChainNonces, error)
GetNonceByChain returns the nonce by chain
func (*Client) GetObserverList ¶
GetObserverList returns the list of observers
func (*Client) GetOutboundTracker ¶
func (c *Client) GetOutboundTracker( ctx context.Context, chain chains.Chain, nonce uint64, ) (*types.OutboundTracker, error)
GetOutboundTracker returns the outbound tracker for a chain and nonce
func (*Client) GetPendingNonces ¶
func (c *Client) GetPendingNonces(ctx context.Context) (*types.QueryAllPendingNoncesResponse, error)
GetPendingNonces returns the pending nonces
func (*Client) GetPendingNoncesByChain ¶
func (c *Client) GetPendingNoncesByChain(ctx context.Context, chainID int64) (types.PendingNonces, error)
GetPendingNoncesByChain returns the pending nonces for a chain and current tss address
func (*Client) GetRateLimiterFlags ¶
GetRateLimiterFlags returns the rate limiter flags
func (*Client) GetRateLimiterInput ¶
func (c *Client) GetRateLimiterInput(ctx context.Context, window int64) (*types.QueryRateLimiterInputResponse, error)
GetRateLimiterInput returns input data for the rate limit checker
func (*Client) GetSupportedChains ¶
GetSupportedChains returns the supported chains
func (*Client) GetTSSHistory ¶
GetTSSHistory returns the TSS history
func (*Client) GetUpgradePlan ¶
GetUpgradePlan returns the current upgrade plan. if there is no active upgrade plan, plan will be nil, err will be nil as well.
func (*Client) GetZetaHotKeyBalance ¶
GetZetaHotKeyBalance returns the zeta hot key balance
func (*Client) GetZetaTokenSupplyOnNode ¶
GetZetaTokenSupplyOnNode returns the zeta token supply on the node
func (*Client) HasVoted ¶
func (c *Client) HasVoted(ctx context.Context, ballotIndex string, voterAddress string) (bool, error)
HasVoted returns whether an observer has voted
func (*Client) ListPendingCCTX ¶
func (c *Client) ListPendingCCTX(ctx context.Context, chainID int64) ([]*types.CrossChainTx, uint64, error)
ListPendingCCTX returns a list of pending cctxs for a given chainID
- The max size of the list is crosschainkeeper.MaxPendingCctxs
func (*Client) ListPendingCCTXWithinRateLimit ¶
func (c *Client) ListPendingCCTXWithinRateLimit( ctx context.Context, ) (*types.QueryListPendingCctxWithinRateLimitResponse, error)
ListPendingCCTXWithinRateLimit returns a list of pending cctxs that do not exceed the outbound rate limit
- The max size of the list is crosschainkeeper.MaxPendingCctxs
- The returned `rateLimitExceeded` flag indicates if the rate limit is exceeded or not
func (*Client) MonitorVoteInboundResult ¶
func (c *Client) MonitorVoteInboundResult( ctx context.Context, zetaTxHash string, retryGasLimit uint64, msg *types.MsgVoteInbound, ) error
MonitorVoteInboundResult monitors the result of a vote inbound tx retryGasLimit is the gas limit used to resend the tx if it fails because of insufficient gas if retryGasLimit is 0, the tx is not resent
func (*Client) MonitorVoteOutboundResult ¶
func (c *Client) MonitorVoteOutboundResult( ctx context.Context, zetaTxHash string, retryGasLimit uint64, msg *types.MsgVoteOutbound, ) error
MonitorVoteOutboundResult monitors the result of a vote outbound tx retryGasLimit is the gas limit used to resend the tx if it fails because of insufficient gas if retryGasLimit is 0, the tx is not resent
func (*Client) OnBeforeStop ¶
func (c *Client) OnBeforeStop(callback func())
OnBeforeStop adds a callback to be called before the client stops.
func (*Client) PostVoteBlameData ¶
func (c *Client) PostVoteBlameData( ctx context.Context, blame *blame.Blame, chainID int64, index string, ) (string, error)
PostVoteBlameData posts blame data message to zetacore. Returns txHash and error.
func (*Client) PostVoteBlockHeader ¶
func (c *Client) PostVoteBlockHeader( ctx context.Context, chainID int64, blockHash []byte, height int64, header proofs.HeaderData, ) (string, error)
PostVoteBlockHeader posts a vote on an observed block header
func (*Client) PostVoteGasPrice ¶
func (c *Client) PostVoteGasPrice( ctx context.Context, chain chains.Chain, gasPrice uint64, supply string, blockNum uint64, ) (string, error)
PostVoteGasPrice posts a gas price vote. Returns txHash and error.
func (*Client) PostVoteInbound ¶
func (c *Client) PostVoteInbound( ctx context.Context, gasLimit, retryGasLimit uint64, msg *types.MsgVoteInbound, ) (string, string, error)
PostVoteInbound posts a vote on an observed inbound tx retryGasLimit is the gas limit used to resend the tx if it fails because of insufficient gas it is used when the ballot is finalized and the inbound tx needs to be processed
func (*Client) PostVoteOutbound ¶
func (c *Client) PostVoteOutbound( ctx context.Context, gasLimit, retryGasLimit uint64, msg *types.MsgVoteOutbound, ) (string, string, error)
PostVoteOutbound posts a vote on an observed outbound tx from a MsgVoteOutbound. Returns tx hash, ballotIndex, and error.
func (*Client) PostVoteTSS ¶
func (c *Client) PostVoteTSS( ctx context.Context, tssPubKey string, keyGenZetaHeight int64, status chains.ReceiveStatus, ) (string, error)
PostVoteTSS sends message to vote TSS. Returns txHash and error.
func (*Client) Prove ¶
func (c *Client) Prove( ctx context.Context, blockHash string, txHash string, txIndex int64, proof *proofs.Proof, chainID int64, ) (bool, error)
Prove returns whether a proof is valid
func (*Client) QueryTxResult ¶
func (c *Client) QueryTxResult(hash string) (*sdktypes.TxResponse, error)
QueryTxResult query the result of a tx
func (*Client) SetAccountNumber ¶
SetAccountNumber sets the account number and sequence number for the given keyType todo remove method and make it part of the client constructor.
func (*Client) SignTx ¶
func (c *Client) SignTx( txf clienttx.Factory, name string, txBuilder client.TxBuilder, overwriteSig bool, txConfig client.TxConfig, ) error
SignTx signs a tx with the given name
func (*Client) Stop ¶
func (c *Client) Stop()
Stop stops the client and optionally calls the onBeforeStop callbacks.
func (*Client) UpdateChainID ¶
func (*Client) UpdateZetacoreContext ¶
func (c *Client) UpdateZetacoreContext( ctx context.Context, appContext *zctx.AppContext, init bool, sampledLogger zerolog.Logger, ) error
UpdateZetacoreContext updates zetacore context zetacore stores zetacore context for all clients
func (*Client) UpdateZetacoreContextWorker ¶
func (c *Client) UpdateZetacoreContextWorker(ctx context.Context, app *appcontext.AppContext)
UpdateZetacoreContextWorker is a polling goroutine that checks and updates zetacore context at every height. todo implement graceful shutdown and work group
type Opt ¶
type Opt func(cfg *constructOpts)
func WithCustomAccountRetriever ¶
func WithCustomAccountRetriever(ac cosmosclient.AccountRetriever) Opt
WithCustomAccountRetriever sets custom tendermint client
func WithTendermintClient ¶
func WithTendermintClient(client cosmosclient.TendermintRPC) Opt
WithTendermintClient sets custom tendermint client