gaia

package
v1.93.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 50 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// GasUpdatePeriodBlocks is the block interval at which we report gas fee changes.
	GasUpdatePeriodBlocks = 10

	// GasPriceFactor is a multiplier applied to the gas amount before dividing by the gas
	// limit to determine the gas price, and later used as a divisor on the final fee -
	// this avoid the integer division going to zero, and can be thought of as the
	// reciprocal of the gas price precision.
	GasPriceFactor = uint64(1e9)

	// GasLimit is the default gas limit we will use for all outbound transactions.
	GasLimit = 200000

	// GasCacheTransactions is the number of transactions over which we compute an average
	// (mean) gas price to use for outbound transactions. Note that only transactions
	// using the chain fee asset will be considered.
	GasCacheTransactions = 100
)

Variables

View Source
var (
	ErrInvalidScanStorage = errors.New("scan storage is empty or nil")
	ErrInvalidMetrics     = errors.New("metrics is empty or nil")
	ErrEmptyTx            = errors.New("empty tx")
)
View Source
var CosmosAssetMappings = []CosmosAssetMapping{
	{
		CosmosDenom:     "uatom",
		CosmosDecimals:  6,
		THORChainSymbol: "ATOM",
	},
}

CosmosAssetMappings maps a Cosmos denom to a THORChain symbol and provides the asset decimals CHANGEME: define assets that should be observed by THORChain here. This also acts a whitelist.

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 CosmosAssetMapping

type CosmosAssetMapping struct {
	CosmosDenom     string
	CosmosDecimals  int
	THORChainSymbol string
}

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.BlockScannerConfiguration,
	scanStorage blockscanner.ScannerStorage,
	bridge *thorclient.ThorchainBridge,
	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 int64) (types.TxIn, error)

func (*CosmosBlockScanner) GetBlock

func (c *CosmosBlockScanner) GetBlock(height int64) (*tmtypes.Block, error)

GetBlock returns a Tendermint 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 lastest 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 *thorclient.Keys,
	cfg config.ChainConfiguration,
	server *tssp.TssServer,
	thorchainBridge *thorclient.ThorchainBridge,
	m *metrics.Metrics,
) (*CosmosClient, error)

NewCosmosClient creates a new instance of a Cosmos-based chain client

func (*CosmosClient) BroadcastTx

func (c *CosmosClient) BroadcastTx(tx stypes.TxOutItem, txBytes []byte) (string, error)

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 (c *CosmosClient) GetAccount(pkey common.PubKey, _ *big.Int) (common.Account, error)

func (*CosmosClient) GetAccountByAddress

func (c *CosmosClient) GetAccountByAddress(address string, _ *big.Int) (common.Account, error)

func (*CosmosClient) GetAddress

func (c *CosmosClient) GetAddress(poolPubKey common.PubKey) string

GetAddress return current signer address, it will be bech32 encoded address

func (*CosmosClient) GetChain

func (c *CosmosClient) GetChain() common.Chain

func (*CosmosClient) GetConfig

func (c *CosmosClient) GetConfig() config.ChainConfiguration

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) 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 []byte, 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

func (*CosmosClient) Stop

func (c *CosmosClient) Stop()

Stop Cosmos chain client

type CosmosMetaDataStore

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

func NewCosmosMetaDataStore

func NewCosmosMetaDataStore() *CosmosMetaDataStore

func (*CosmosMetaDataStore) Get

func (*CosmosMetaDataStore) GetByAccount

func (b *CosmosMetaDataStore) GetByAccount(acct int64) CosmosMetadata

func (*CosmosMetaDataStore) SeqInc

func (b *CosmosMetaDataStore) SeqInc(pk common.PubKey)

func (*CosmosMetaDataStore) Set

type CosmosMetadata

type CosmosMetadata struct {
	AccountNumber int64
	SeqNumber     int64
	BlockHeight   int64
}

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)
	// 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 MockTmServiceClient

type MockTmServiceClient interface {
	// GetNodeInfo queries the current node info.
	GetNodeInfo(ctx context.Context, in *tmservice.GetNodeInfoRequest, opts ...grpc.CallOption) (*tmservice.GetNodeInfoResponse, error)
	// GetSyncing queries node syncing.
	GetSyncing(ctx context.Context, in *tmservice.GetSyncingRequest, opts ...grpc.CallOption) (*tmservice.GetSyncingResponse, error)
	// GetLatestBlock returns the latest block.
	GetLatestBlock(ctx context.Context, in *tmservice.GetLatestBlockRequest, opts ...grpc.CallOption) (*tmservice.GetLatestBlockResponse, error)
	// GetBlockByHeight queries block for given height.
	GetBlockByHeight(ctx context.Context, in *tmservice.GetBlockByHeightRequest, opts ...grpc.CallOption) (*tmservice.GetBlockByHeightResponse, error)
	// GetLatestValidatorSet queries latest validator-set.
	GetLatestValidatorSet(ctx context.Context, in *tmservice.GetLatestValidatorSetRequest, opts ...grpc.CallOption) (*tmservice.GetLatestValidatorSetResponse, error)
	// GetValidatorSetByHeight queries validator-set at a given height.
	GetValidatorSetByHeight(ctx context.Context, in *tmservice.GetValidatorSetByHeightRequest, opts ...grpc.CallOption) (*tmservice.GetValidatorSetByHeightResponse, error)
}

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMockTmServiceClient

func NewMockTmServiceClient() MockTmServiceClient

type SolvencyReporter

type SolvencyReporter func(int64) error

SolvencyReporter is to report solvency info to THORNode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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