Documentation
¶
Index ¶
- Constants
- Variables
- type BlockInfo
- type CometBFTRPC
- type CosmosAssetMapping
- type CosmosBlockScanner
- type CosmosClient
- func (c *CosmosClient) BroadcastTx(tx stypes.TxOutItem, txBytes []byte) (string, error)
- func (c *CosmosClient) ConfirmationCountReady(txIn stypes.TxIn) bool
- func (c *CosmosClient) GetAccount(pkey common.PubKey, _ *big.Int) (common.Account, error)
- func (c *CosmosClient) GetAccountByAddress(address string, _ *big.Int) (common.Account, error)
- func (c *CosmosClient) GetAddress(poolPubKey common.PubKey) string
- func (c *CosmosClient) GetBlockScannerHeight() (int64, error)
- func (c *CosmosClient) GetChain() common.Chain
- func (c *CosmosClient) GetConfig() config.BifrostChainConfiguration
- func (c *CosmosClient) GetConfirmationCount(txIn stypes.TxIn) int64
- func (c *CosmosClient) GetHeight() (int64, error)
- func (c *CosmosClient) GetLatestTxForVault(vault string) (string, string, error)
- func (c *CosmosClient) IsBlockScannerHealthy() bool
- func (c *CosmosClient) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)
- func (c *CosmosClient) ReportSolvency(blockHeight int64) error
- func (c *CosmosClient) ShouldReportSolvency(height int64) bool
- func (c *CosmosClient) SignTx(tx stypes.TxOutItem, thorchainHeight int64) (signedTx, checkpoint []byte, _ *stypes.TxInItem, err error)
- func (c *CosmosClient) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, ...)
- func (c *CosmosClient) Stop()
- type CosmosMetaDataStore
- type CosmosMetadata
- type EventInfo
- type MockAccountServiceClient
- type MockBankServiceClient
- type NetworkResponse
- type NodeInfo
- type Other
- type ProtocolVersion
- type PubKey
- type SolvencyReporter
- type SyncInfo
- type ThorchainStatusResponse
- type ThorchainStatusResult
- type TxContext
- type TxData
- type TxResult
- type ValidatorInfo
Constants ¶
const ( // FeeUpdatePeriodBlocks is the block interval at which we report gas fee changes. FeeUpdatePeriodBlocks = 10 // Fee Endpoint FeeEndpoint = "/thorchain/network" DefaultFee = 2000000 // GasLimit is the default gas limit we will use for all outbound transactions. GasLimit = 4000000000 )
Variables ¶
var ( ErrInvalidScanStorage = errors.New("scan storage is empty or nil") ErrInvalidMetrics = errors.New("metrics is empty or nil") ErrEmptyTx = errors.New("empty tx") )
var CosmosAssetMappings = []CosmosAssetMapping{
{
CosmosDenom: "rune",
CosmosDecimals: 8,
THORChainSymbol: "RUNE",
},
}
CosmosAssetMappings maps a Cosmos denom to a THORChain symbol and provides the asset decimals
var CosmosSuccessCodes = map[uint32]bool{ errortypes.SuccessABCICode: true, errortypes.ErrTxInMempoolCache.ABCICode(): true, errortypes.ErrWrongSequence.ABCICode(): true, }
CosmosSuccessCodes a transaction is considered successful if it returns 0 or if tx is unauthorized or already in the mempool (another Bifrost already sent it)
Functions ¶
This section is empty.
Types ¶
type BlockInfo ¶ added in v1.115.0
type BlockInfo struct { Height int64 Time time.Time Results *coretypes.ResultBlockResults GasUsed int64 GasWanted int64 }
BlockInfo contains block-specific data and results
type CometBFTRPC ¶ added in v1.115.0
type CometBFTRPC interface { Block(ctx context.Context, height *int64) (*cometbfttypes.ResultBlock, error) BlockResults(ctx context.Context, height *int64) (*cometbfttypes.ResultBlockResults, error) }
type CosmosAssetMapping ¶
func GetAssetByCosmosDenom ¶
func GetAssetByCosmosDenom(denom string) (CosmosAssetMapping, bool)
func GetAssetByThorchainSymbol ¶
func GetAssetByThorchainSymbol(symbol string) (CosmosAssetMapping, bool)
type CosmosBlockScanner ¶
type CosmosBlockScanner struct {
// contains filtered or unexported fields
}
CosmosBlockScanner is to scan the blocks
func NewCosmosBlockScanner ¶
func NewCosmosBlockScanner(cfg config.BifrostBlockScannerConfiguration, scanStorage blockscanner.ScannerStorage, bridge mayaclient.MayachainBridge, m *metrics.Metrics, solvencyReporter SolvencyReporter, ) (*CosmosBlockScanner, error)
NewCosmosBlockScanner create a new instance of BlockScan
func (*CosmosBlockScanner) FetchMemPool ¶
func (c *CosmosBlockScanner) FetchMemPool(height int64) (types.TxIn, error)
FetchMemPool returns nothing since we are only concerned about finalized transactions in Cosmos
func (*CosmosBlockScanner) FetchTxs ¶
func (c *CosmosBlockScanner) FetchTxs(height, chainHeight int64) (types.TxIn, error)
func (*CosmosBlockScanner) GetBlock ¶
func (c *CosmosBlockScanner) GetBlock(height int64) (*cmttypes.Block, error)
GetBlock returns a CometBFT block as a reference to a ResultBlock for a given height. As noted above, this is not necessarily the final state of transactions and must be checked again for success by getting the BlockResults in FetchTxs
func (*CosmosBlockScanner) GetHeight ¶
func (c *CosmosBlockScanner) GetHeight() (int64, error)
GetHeight returns the height from the latest block minus 1 NOTE: we must lag by one block due to a race condition fetching the block results Since the GetLatestBlockRequests tells what transactions will be in the block at T+1
type CosmosClient ¶
type CosmosClient struct {
// contains filtered or unexported fields
}
CosmosClient is a structure to sign and broadcast tx to Cosmos chain used by signer mostly
func NewCosmosClient ¶
func NewCosmosClient( thorKeys *mayaclient.Keys, cfg config.BifrostChainConfiguration, server *tssp.TssServer, mayachainBridge mayaclient.MayachainBridge, m *metrics.Metrics, ) (*CosmosClient, error)
NewCosmosClient creates a new instance of a Cosmos-based chain client
func (*CosmosClient) BroadcastTx ¶
BroadcastTx is to broadcast the tx to cosmos chain
func (*CosmosClient) ConfirmationCountReady ¶
func (c *CosmosClient) ConfirmationCountReady(txIn stypes.TxIn) bool
ConfirmationCountReady cosmos chain has almost instant finality, so doesn't need to wait for confirmation
func (*CosmosClient) GetAccount ¶
func (*CosmosClient) GetAccountByAddress ¶
func (*CosmosClient) GetAddress ¶
func (c *CosmosClient) GetAddress(poolPubKey common.PubKey) string
GetAddress return current signer address, it will be bech32 encoded address
func (*CosmosClient) GetBlockScannerHeight ¶ added in v1.109.0
func (c *CosmosClient) GetBlockScannerHeight() (int64, error)
GetBlockScannerHeight returns blockscanner height
func (*CosmosClient) GetChain ¶
func (c *CosmosClient) GetChain() common.Chain
func (*CosmosClient) GetConfig ¶
func (c *CosmosClient) GetConfig() config.BifrostChainConfiguration
GetConfig return the configuration used by Cosmos chain client
func (*CosmosClient) GetConfirmationCount ¶
func (c *CosmosClient) GetConfirmationCount(txIn stypes.TxIn) int64
GetConfirmationCount determine how many confirmations are required NOTE: Cosmos chains are instant finality, so confirmations are not needed. If the transaction was successful, we know it is included in a block and thus immutable.
func (*CosmosClient) GetHeight ¶
func (c *CosmosClient) GetHeight() (int64, error)
func (*CosmosClient) GetLatestTxForVault ¶ added in v1.109.0
func (c *CosmosClient) GetLatestTxForVault(vault string) (string, string, error)
func (*CosmosClient) IsBlockScannerHealthy ¶
func (c *CosmosClient) IsBlockScannerHealthy() bool
func (*CosmosClient) OnObservedTxIn ¶
func (c *CosmosClient) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)
OnObservedTxIn update the signer cache (in case we haven't already)
func (*CosmosClient) ReportSolvency ¶
func (c *CosmosClient) ReportSolvency(blockHeight int64) error
func (*CosmosClient) ShouldReportSolvency ¶
func (c *CosmosClient) ShouldReportSolvency(height int64) bool
func (*CosmosClient) SignTx ¶
func (c *CosmosClient) SignTx(tx stypes.TxOutItem, thorchainHeight int64) (signedTx, checkpoint []byte, _ *stypes.TxInItem, err error)
SignTx sign the the given TxArrayItem
func (*CosmosClient) Start ¶
func (c *CosmosClient) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, globalSolvencyQueue chan stypes.Solvency)
Start Cosmos chain client
type CosmosMetaDataStore ¶
type CosmosMetaDataStore struct {
// contains filtered or unexported fields
}
func NewCosmosMetaDataStore ¶
func NewCosmosMetaDataStore() *CosmosMetaDataStore
func (*CosmosMetaDataStore) Get ¶
func (b *CosmosMetaDataStore) Get(pk common.PubKey) CosmosMetadata
func (*CosmosMetaDataStore) GetByAccount ¶
func (b *CosmosMetaDataStore) GetByAccount(acct int64) CosmosMetadata
func (*CosmosMetaDataStore) SeqInc ¶
func (b *CosmosMetaDataStore) SeqInc(pk common.PubKey)
func (*CosmosMetaDataStore) Set ¶
func (b *CosmosMetaDataStore) Set(pk common.PubKey, meta CosmosMetadata)
type CosmosMetadata ¶
type MockAccountServiceClient ¶
type MockAccountServiceClient interface { // Accounts returns all the existing accounts // // Since: cosmos-sdk 0.43 Accounts(ctx context.Context, in *atypes.QueryAccountsRequest, opts ...grpc.CallOption) (*atypes.QueryAccountsResponse, error) // Account returns account details based on address. Account(ctx context.Context, in *atypes.QueryAccountRequest, opts ...grpc.CallOption) (*atypes.QueryAccountResponse, error) // Params queries all parameters. Params(ctx context.Context, in *atypes.QueryParamsRequest, opts ...grpc.CallOption) (*atypes.QueryParamsResponse, error) }
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewMockAccountServiceClient ¶
func NewMockAccountServiceClient() MockAccountServiceClient
type MockBankServiceClient ¶
type MockBankServiceClient interface { // Balance queries the balance of a single coin for a single account. Balance(ctx context.Context, in *btypes.QueryBalanceRequest, opts ...grpc.CallOption) (*btypes.QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(ctx context.Context, in *btypes.QueryAllBalancesRequest, opts ...grpc.CallOption) (*btypes.QueryAllBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(ctx context.Context, in *btypes.QueryTotalSupplyRequest, opts ...grpc.CallOption) (*btypes.QueryTotalSupplyResponse, error) // SpendableBalances queries the spenable balance of all coins for a single // account. SpendableBalances(ctx context.Context, in *btypes.QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*btypes.QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. // SupplyOf queries the supply of a single coin. SupplyOf(ctx context.Context, in *btypes.QuerySupplyOfRequest, opts ...grpc.CallOption) (*btypes.QuerySupplyOfResponse, error) // Params queries the parameters of x/bank module. Params(ctx context.Context, in *btypes.QueryParamsRequest, opts ...grpc.CallOption) (*btypes.QueryParamsResponse, error) // DenomsMetadata queries the client metadata of a given coin denomination. DenomMetadata(ctx context.Context, in *btypes.QueryDenomMetadataRequest, opts ...grpc.CallOption) (*btypes.QueryDenomMetadataResponse, error) // DenomsMetadata queries the client metadata for all registered coin denominations. DenomsMetadata(ctx context.Context, in *btypes.QueryDenomsMetadataRequest, opts ...grpc.CallOption) (*btypes.QueryDenomsMetadataResponse, error) }
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewMockBankServiceClient ¶
func NewMockBankServiceClient() MockBankServiceClient
type NetworkResponse ¶ added in v1.108.0
type NetworkResponse struct { // total amount of RUNE awarded to node operators BondRewardRune string `json:"bond_reward_rune"` // total of burned BEP2 RUNE BurnedBep2Rune string `json:"burned_bep_2_rune"` // total of burned ERC20 RUNE BurnedErc20Rune string `json:"burned_erc_20_rune"` // total bonded RUNE TotalBondUnits string `json:"total_bond_units"` // effective security bond used to determine maximum pooled RUNE EffectiveSecurityBond string `json:"effective_security_bond"` // total reserve RUNE TotalReserve string `json:"total_reserve"` // Returns true if there exist RetiringVaults which have not finished migrating funds to new ActiveVaults VaultsMigrating bool `json:"vaults_migrating"` // Sum of the gas the network has spent to send outbounds GasSpentRune string `json:"gas_spent_rune"` // Sum of the gas withheld from users to cover outbound gas GasWithheldRune string `json:"gas_withheld_rune"` // Current outbound fee multiplier, in basis points OutboundFeeMultiplier *string `json:"outbound_fee_multiplier,omitempty"` // the outbound transaction fee in rune, converted from the NativeOutboundFeeUSD mimir (after USD fees are enabled) NativeOutboundFeeRune string `json:"native_outbound_fee_rune"` // the native transaction fee in rune, converted from the NativeTransactionFeeUSD mimir (after USD fees are enabled) NativeTxFeeRune string `json:"native_tx_fee_rune"` // the thorname register fee in rune, converted from the TNSRegisterFeeUSD mimir (after USD fees are enabled) TnsRegisterFeeRune string `json:"tns_register_fee_rune"` // the thorname fee per block in rune, converted from the TNSFeePerBlockUSD mimir (after USD fees are enabled) TnsFeePerBlockRune string `json:"tns_fee_per_block_rune"` // the rune price in tor RunePriceInTor string `json:"rune_price_in_tor"` // the tor price in rune TorPriceInRune string `json:"tor_price_in_rune"` }
NetworkResponse struct for NetworkResponse
type NodeInfo ¶ added in v1.111.0
type NodeInfo struct { ProtocolVersion ProtocolVersion `json:"protocol_version"` ID string `json:"id"` ListenAddr string `json:"listen_addr"` Network string `json:"network"` Version string `json:"version"` Channels string `json:"channels"` Moniker string `json:"moniker"` Other Other `json:"other"` }
type ProtocolVersion ¶ added in v1.111.0
type SolvencyReporter ¶
SolvencyReporter is to report solvency info to THORNode
type SyncInfo ¶ added in v1.111.0
type SyncInfo struct { LatestBlockHash string `json:"latest_block_hash"` LatestAppHash string `json:"latest_app_hash"` LatestBlockHeight string `json:"latest_block_height"` LatestBlockTime string `json:"latest_block_time"` EarliestBlockHash string `json:"earliest_block_hash"` EarliestAppHash string `json:"earliest_app_hash"` EarliestBlockHeight string `json:"earliest_block_height"` EarliestBlockTime string `json:"earliest_block_time"` CatchingUp bool `json:"catching_up"` }
type ThorchainStatusResponse ¶ added in v1.111.0
type ThorchainStatusResponse struct { Jsonrpc string `json:"jsonrpc"` Id int `json:"id"` Result ThorchainStatusResult `json:"result"` }
type ThorchainStatusResult ¶ added in v1.111.0
type ThorchainStatusResult struct { NodeInfo NodeInfo `json:"node_info"` SyncInfo SyncInfo `json:"sync_info"` ValidatorInfo ValidatorInfo `json:"validator_info"` }
type TxData ¶ added in v1.115.0
type TxData struct { Tx TxContext Block BlockInfo TxResult TxResult RawEvents []abcitypes.Event // Original events for custom processing }
TxData contains all context needed for processing messages