kuji

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: 51 Imported by: 0

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)

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

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 KujiAssetMappings = []KujiAssetMapping{
	{
		KujiDenom:       "ukuji",
		KujiDecimals:    6,
		BASEChainSymbol: "KUJI",
	},
	{
		KujiDenom:       "factory/kujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7/uusk",
		KujiDecimals:    6,
		BASEChainSymbol: "USK",
	},
	{
		KujiDenom:       "factory/kujira1ygfxn0er40klcnck8thltuprdxlck6wvnpkf2k/uyum",
		KujiDecimals:    6,
		BASEChainSymbol: "YUM",
	},
}

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.

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

type KujiAssetMapping struct {
	KujiDenom       string
	KujiDecimals    int
	BASEChainSymbol string
}

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

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

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

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

func (*KujiClient) GetAccountByAddress

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

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

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

func (*KujiClient) Stop

func (c *KujiClient) Stop()

Stop Kuji chain client

type KujiMetadata

type KujiMetadata struct {
	AccountNumber int64
	SeqNumber     int64
	BlockHeight   int64
}

type KujiMetadataStore

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

func NewKujiMetaDataStore

func NewKujiMetaDataStore() *KujiMetadataStore

func (*KujiMetadataStore) Get

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

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