Documentation ¶
Index ¶
- Constants
- Variables
- type KujiAssetMapping
- type KujiBlockScanner
- type KujiClient
- func (c *KujiClient) BroadcastTx(tx stypes.TxOutItem, txBytes []byte) (string, error)
- func (c *KujiClient) ConfirmationCountReady(txIn stypes.TxIn) bool
- func (c *KujiClient) GetAccount(pkey common.PubKey, _ *big.Int) (common.Account, error)
- func (c *KujiClient) GetAccountByAddress(address string, _ *big.Int) (common.Account, error)
- func (c *KujiClient) GetAddress(poolPubKey common.PubKey) string
- func (c *KujiClient) GetBlockScannerHeight() (int64, error)
- func (c *KujiClient) GetChain() common.Chain
- func (c *KujiClient) GetConfig() config.BifrostChainConfiguration
- func (c *KujiClient) GetConfirmationCount(txIn stypes.TxIn) int64
- func (c *KujiClient) GetHeight() (int64, error)
- func (c *KujiClient) GetLatestTxForVault(vault string) (string, string, error)
- func (c *KujiClient) IsBlockScannerHealthy() bool
- func (c *KujiClient) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)
- func (c *KujiClient) ReportSolvency(blockHeight int64) error
- func (c *KujiClient) ShouldReportSolvency(height int64) bool
- func (c *KujiClient) SignTx(tx stypes.TxOutItem, mayachainHeight int64) (signedTx, _ []byte, _ *stypes.TxInItem, err error)
- func (c *KujiClient) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, ...)
- func (c *KujiClient) Stop()
- type KujiMetadata
- type KujiMetadataStore
- type MockAccountServiceClient
- type MockBankServiceClient
- type MockTmServiceClient
- type SolvencyReporter
Constants ¶
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) // GasPriceResolution is the resolution at which the gas price will be rounded up to. GasPriceResolution = uint64(100000) // ukuji per gas unit // 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 ¶
var ( ErrInvalidScanStorage = errors.New("scan storage is empty or nil") ErrInvalidMetrics = errors.New("metrics is empty or nil") ErrEmptyTx = errors.New("empty tx") )
var KujiAssetMappings = []KujiAssetMapping{
{
KujiDenom: "ukuji",
KujiDecimals: 6,
BASEChainSymbol: "KUJI",
},
{
KujiDenom: "factory/kujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7/uusk",
KujiDecimals: 6,
BASEChainSymbol: "USK",
},
{
KujiDenom: "factory/kujira1ygfxn0er40klcnck8thltuprdxlck6wvnpkf2k/uyum",
KujiDecimals: 6,
BASEChainSymbol: "YUM",
},
{
KujiDenom: "ibc/507BE7E33F06026652F519AD4D36716251F2D34DF04514A905D3B19A7D8130F7",
KujiDecimals: 6,
BASEChainSymbol: "AXLYUM",
},
{
KujiDenom: "ibc/20014F963CC9E6488B299622F87B60C6DE71632864859EC08B4753478DAB2BB8",
KujiDecimals: 6,
BASEChainSymbol: "USDT",
},
{
KujiDenom: "ibc/FE98AAD68F02F03565E9FA39A5E627946699B2B07115889ED812D8BA639576A9",
KujiDecimals: 6,
BASEChainSymbol: "USDC",
},
{
KujiDenom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
KujiDecimals: 6,
BASEChainSymbol: "ATOM",
},
{
KujiDenom: "ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23",
KujiDecimals: 6,
BASEChainSymbol: "OSMO",
},
}
KujiAssetMappings maps a Kuji denom to a BASEChain symbol and provides the asset decimals CHANGEME: define assets that should be observed by BASEChain here. This also acts a whitelist.
var KujiSuccessCodes = map[uint32]bool{ errortypes.SuccessABCICode: true, errortypes.ErrTxInMempoolCache.ABCICode(): true, errortypes.ErrWrongSequence.ABCICode(): true, }
KujiSuccessCodes 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 KujiAssetMapping ¶
func GetAssetByKujiDenom ¶
func GetAssetByKujiDenom(denom string) (KujiAssetMapping, bool)
func GetAssetByMayachainSymbol ¶
func GetAssetByMayachainSymbol(symbol string) (KujiAssetMapping, bool)
type KujiBlockScanner ¶
type KujiBlockScanner struct {
// contains filtered or unexported fields
}
KujiBlockScanner is to scan the blocks
func NewKujiBlockScanner ¶
func NewKujiBlockScanner(cfg config.BifrostBlockScannerConfiguration, scanStorage blockscanner.ScannerStorage, bridge mayaclient.MayachainBridge, m *metrics.Metrics, solvencyReporter SolvencyReporter, ) (*KujiBlockScanner, error)
NewKujiBlockScanner create a new instance of BlockScan
func (*KujiBlockScanner) FetchMemPool ¶
func (c *KujiBlockScanner) FetchMemPool(height int64) (types.TxIn, error)
FetchMemPool returns nothing since we are only concerned about finalized transactions in Cosmos
func (*KujiBlockScanner) FetchTxs ¶
func (c *KujiBlockScanner) FetchTxs(height, chainHeight int64) (types.TxIn, error)
func (*KujiBlockScanner) GetBlock ¶
func (c *KujiBlockScanner) 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 (*KujiBlockScanner) GetHeight ¶
func (c *KujiBlockScanner) 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 KujiClient ¶
type KujiClient struct {
// contains filtered or unexported fields
}
KujiClient is a structure to sign and broadcast tx to Kuji chain used by signer mostly
func NewCosmosClient ¶
func NewCosmosClient( thorKeys *mayaclient.Keys, cfg config.BifrostChainConfiguration, server *tssp.TssServer, mayachainBridge mayaclient.MayachainBridge, m *metrics.Metrics, ) (*KujiClient, error)
NewCosmosClient creates a new instance of a Cosmos-based chain client
func (*KujiClient) BroadcastTx ¶
BroadcastTx is to broadcast the tx to cosmos chain
func (*KujiClient) ConfirmationCountReady ¶
func (c *KujiClient) ConfirmationCountReady(txIn stypes.TxIn) bool
ConfirmationCountReady cosmos chain has almost instant finality, so doesn't need to wait for confirmation
func (*KujiClient) GetAccount ¶
func (*KujiClient) GetAccountByAddress ¶
func (*KujiClient) GetAddress ¶
func (c *KujiClient) GetAddress(poolPubKey common.PubKey) string
GetAddress return current signer address, it will be bech32 encoded address
func (*KujiClient) GetBlockScannerHeight ¶ added in v1.109.0
func (c *KujiClient) GetBlockScannerHeight() (int64, error)
GetBlockScannerHeight returns blockscanner height
func (*KujiClient) GetChain ¶
func (c *KujiClient) GetChain() common.Chain
func (*KujiClient) GetConfig ¶
func (c *KujiClient) GetConfig() config.BifrostChainConfiguration
GetConfig return the configuration used by Kuji chain client
func (*KujiClient) GetConfirmationCount ¶
func (c *KujiClient) 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 (*KujiClient) GetHeight ¶
func (c *KujiClient) GetHeight() (int64, error)
func (*KujiClient) GetLatestTxForVault ¶ added in v1.109.0
func (c *KujiClient) GetLatestTxForVault(vault string) (string, string, error)
func (*KujiClient) IsBlockScannerHealthy ¶
func (c *KujiClient) IsBlockScannerHealthy() bool
func (*KujiClient) OnObservedTxIn ¶
func (c *KujiClient) OnObservedTxIn(txIn stypes.TxInItem, blockHeight int64)
OnObservedTxIn update the signer cache (in case we haven't already)
func (*KujiClient) ReportSolvency ¶
func (c *KujiClient) ReportSolvency(blockHeight int64) error
func (*KujiClient) ShouldReportSolvency ¶
func (c *KujiClient) ShouldReportSolvency(height int64) bool
func (*KujiClient) SignTx ¶
func (c *KujiClient) SignTx(tx stypes.TxOutItem, mayachainHeight int64) (signedTx, _ []byte, _ *stypes.TxInItem, err error)
SignTx sign the the given TxArrayItem
func (*KujiClient) Start ¶
func (c *KujiClient) Start(globalTxsQueue chan stypes.TxIn, globalErrataQueue chan stypes.ErrataBlock, globalSolvencyQueue chan stypes.Solvency)
Start Kuji chain client
type KujiMetadata ¶
type KujiMetadataStore ¶
type KujiMetadataStore struct {
// contains filtered or unexported fields
}
func NewKujiMetaDataStore ¶
func NewKujiMetaDataStore() *KujiMetadataStore
func (*KujiMetadataStore) Get ¶
func (b *KujiMetadataStore) Get(pk common.PubKey) KujiMetadata
func (*KujiMetadataStore) GetByAccount ¶
func (b *KujiMetadataStore) GetByAccount(acct int64) KujiMetadata
func (*KujiMetadataStore) SeqInc ¶
func (b *KujiMetadataStore) SeqInc(pk common.PubKey)
func (*KujiMetadataStore) Set ¶
func (b *KujiMetadataStore) Set(pk common.PubKey, meta KujiMetadata)
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) // 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 ¶
SolvencyReporter is to report solvency info to THORNode