thorchain

package
v1.109.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
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

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:     "rune",
		CosmosDecimals:  8,
		THORChainSymbol: "RUNE",
	},
}

CosmosAssetMappings maps a Cosmos denom to a THORChain symbol and provides the asset decimals

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

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) (*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 *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

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

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

type SolvencyReporter func(int64) error

SolvencyReporter is to report solvency info to THORNode

Jump to

Keyboard shortcuts

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