avalanche

package
v1.97.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockCacheSize           = 6000
	MaxContractGas           = 80000
	GasPriceResolution int64 = 250000000000 // wei per gas unit (250 gwei)

)
View Source
const TxWaitBlocks = 150

This is the number of THORChain blocks to wait before re-broadcasting a stuck tx with more gas. 150 was chosen because the signing period for outbounds is 300 blocks. After 300 blocks the tx will be re-assigned to a different vault, so we want to try to push the tx through before that

Variables

This section is empty.

Functions

func IsAVAX

func IsAVAX(token string) bool

IsAVAX return true if the token address equals to avaxToken address

func LatestAggregatorContracts added in v1.96.1

func LatestAggregatorContracts() []common.Address

Types

type AvalancheClient

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

AvalancheClient is a structure to sign and broadcast tx to the Avalanche C-Chain

func NewAvalancheClient

NewAvalancheClient creates new instance of an AvalancheClient

func (*AvalancheClient) AddSignedTxItem

func (c *AvalancheClient) AddSignedTxItem(hash string, height int64, vaultPubKey string) error

AddSignedTxItem add the transaction to key value store

func (*AvalancheClient) BroadcastTx

func (c *AvalancheClient) BroadcastTx(txOutItem stypes.TxOutItem, hexTx []byte) (string, error)

BroadcastTx decodes tx using rlp and broadcasts to the AVAX C-Chain

func (*AvalancheClient) ConfirmationCountReady

func (c *AvalancheClient) ConfirmationCountReady(txIn stypes.TxIn) bool

ConfirmationCountReady - AVAX C-Chain has instant finality, THORChain can accept the tx instantly

func (*AvalancheClient) GetAccount

func (c *AvalancheClient) GetAccount(pk common.PubKey, height *big.Int) (common.Account, error)

GetAccount gets account by address in avax client

func (*AvalancheClient) GetAccountByAddress

func (c *AvalancheClient) GetAccountByAddress(address string, height *big.Int) (common.Account, error)

GetAccountByAddress return account information

func (*AvalancheClient) GetAddress

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

GetAddress returns the current signer address, it will be bech32 encoded address

func (*AvalancheClient) GetBalance

func (c *AvalancheClient) GetBalance(addr, token string, height *big.Int) (*big.Int, error)

GetBalance call smart contract to find out the balance of the given address and token

func (*AvalancheClient) GetBalances

func (c *AvalancheClient) GetBalances(addr string, height *big.Int) (common.Coins, error)

GetBalances gets all the balances of the given address

func (*AvalancheClient) GetChain

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

GetChain gets chain

func (*AvalancheClient) GetConfig

GetConfig return the configurations used by AVAX chain client

func (*AvalancheClient) GetConfirmationCount

func (c *AvalancheClient) GetConfirmationCount(txIn stypes.TxIn) int64

GetConfirmationCount - AVAX C-Chain has instant finality, so return 0

func (*AvalancheClient) GetGasFee

func (c *AvalancheClient) GetGasFee(gas uint64) common.Gas

GetGasFee gets gas fee

func (*AvalancheClient) GetGasPrice

func (c *AvalancheClient) GetGasPrice() *big.Int

GetGasPrice gets gas price from eth scanner

func (*AvalancheClient) GetHeight

func (c *AvalancheClient) GetHeight() (int64, error)

GetHeight gets height from avax scanner

func (*AvalancheClient) IsBlockScannerHealthy

func (c *AvalancheClient) IsBlockScannerHealthy() bool

IsBlockScannerHealthy returns if the block scanner is healthy or not

func (*AvalancheClient) OnObservedTxIn

func (c *AvalancheClient) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)

OnObservedTxIn gets called from observer when we have a valid observation

func (*AvalancheClient) ReportSolvency

func (c *AvalancheClient) ReportSolvency(avaxBlockHeight int64) error

func (*AvalancheClient) ShouldReportSolvency

func (c *AvalancheClient) ShouldReportSolvency(height int64) bool

ShouldReportSolvency with given block height, should chain client report Solvency to THORNode? AVAX C-Chain blocktime is around 2 seconds

func (*AvalancheClient) SignTx

func (c *AvalancheClient) SignTx(tx stypes.TxOutItem, height int64) ([]byte, error)

SignTx signs the the given TxArrayItem

func (*AvalancheClient) Start

func (c *AvalancheClient) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, globalSolvencyQueue chan stypes.Solvency)

Start to monitor the AVAX C-Chain

func (*AvalancheClient) Stop

func (c *AvalancheClient) Stop()

Stop monitoring the AVAX C-Chain

type AvalancheScanner

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

AvalancheScanner is a scanner that understand how to interact with and scan blocks of the AVAX C-chain

func NewAVAXScanner

func NewAVAXScanner(cfg config.BifrostBlockScannerConfiguration,
	storage blockscanner.ScannerStorage,
	chainID *big.Int,
	ethClient *ethclient.Client,
	ethRpc *evm.EthRPC,
	bridge *thorclient.ThorchainBridge,
	m *metrics.Metrics,
	pubkeyMgr pubkeymanager.PubKeyValidator,
	solvencyReporter SolvencyReporter,
	signerCacheManager *signercache.CacheManager,
) (*AvalancheScanner, error)

Creates a new instance of AvalancheScanner

func (*AvalancheScanner) FetchMemPool

func (a *AvalancheScanner) FetchMemPool(_ int64) (stypes.TxIn, error)

FetchMemPool gets tx from mempool

func (*AvalancheScanner) FetchTxs

func (a *AvalancheScanner) FetchTxs(height int64) (stypes.TxIn, error)

FetchTxs query the AVAX C-Chain to get txs in the given block height

func (*AvalancheScanner) GetGasPrice

func (a *AvalancheScanner) GetGasPrice() *big.Int

GetGasPrice returns current gas price

func (*AvalancheScanner) GetHeight

func (a *AvalancheScanner) GetHeight() (int64, error)

GetHeight return latest block height

func (*AvalancheScanner) GetNonce

func (a *AvalancheScanner) GetNonce(addr string) (uint64, error)

func (*AvalancheScanner) GetTokens

func (a *AvalancheScanner) GetTokens() ([]*evmtypes.TokenMeta, error)

GetTokens return all the token meta data

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