Documentation ¶
Index ¶
- Constants
- func ParseGatewayInstruction(txResult *rpc.GetTransactionResult, gatewayID solana.PublicKey, ...) (contracts.OutboundInstruction, error)
- type Observer
- func (ob *Observer) BuildInboundVoteMsgFromEvent(event *clienttypes.InboundEvent) *crosschaintypes.MsgVoteInbound
- func (ob *Observer) CheckFinalizedTx(ctx context.Context, txHash string, nonce uint64, coinType coin.CoinType) (*rpc.GetTransactionResult, bool)
- func (ob *Observer) CreateMsgVoteOutbound(cctxIndex string, outboundHash string, txResult *rpc.GetTransactionResult, ...) *crosschaintypes.MsgVoteOutbound
- func (ob *Observer) FilterInboundEvents(txResult *rpc.GetTransactionResult) ([]*clienttypes.InboundEvent, error)
- func (ob *Observer) FilterInboundEventsAndVote(ctx context.Context, txResult *rpc.GetTransactionResult) error
- func (ob *Observer) GetTxResult(nonce uint64) *rpc.GetTransactionResult
- func (ob *Observer) IsEventProcessable(event clienttypes.InboundEvent) bool
- func (ob *Observer) IsTxFinalized(nonce uint64) bool
- func (ob *Observer) LoadLastTxScanned() error
- func (ob *Observer) ObserveInbound(ctx context.Context) error
- func (ob *Observer) PostGasPrice(ctx context.Context) error
- func (ob *Observer) PostVoteOutbound(ctx context.Context, cctxIndex string, outboundHash string, ...)
- func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error
- func (ob *Observer) ProcessOutboundTrackers(ctx context.Context) error
- func (ob *Observer) SetTxResult(nonce uint64, result *rpc.GetTransactionResult)
- func (ob *Observer) SolClient() interfaces.SolanaRPCClient
- func (ob *Observer) Start(ctx context.Context)
- func (ob *Observer) VoteOutboundIfConfirmed(ctx context.Context, cctx *crosschaintypes.CrossChainTx) (bool, error)
- func (ob *Observer) WatchGasPrice(ctx context.Context) error
- func (ob *Observer) WatchInbound(ctx context.Context) error
- func (ob *Observer) WatchInboundTracker(ctx context.Context) error
- func (ob *Observer) WatchOutbound(ctx context.Context) error
- func (ob *Observer) WithSolClient(client interfaces.SolanaRPCClient)
Constants ¶
const ( // SolanaTransactionFee is the static fee per transaction, 5k lamports. SolanaTransactionFee = 5000 // MicroLamportsPerLamport is the number of micro lamports in a lamport. MicroLamportsPerLamport = 1_000_000 // SolanaDefaultComputeBudget is the default compute budget for a transaction. SolanaDefaultComputeBudget = 200_000 // Solana uses micro lamports (0.000001 lamports) as the smallest unit of gas price. // The gas fee formula 'gasFee = gasPrice * gasLimit' won't fit Solana in the ZRC20 SOL contract. // We could use lamports as the unit of gas price and 10K CU as the smallest unit of compute units. // SolanaDefaultGasPrice10KCUs is the default gas price (in lamports) per 10K compute units. SolanaDefaultGasPrice10KCUs = 100 // SolanaDefaultGasLimit is the default compute units (in 10K CU) for a transaction. SolanaDefaultGasLimit10KCU = 50 )
const (
// MaxSignaturesPerTicker is the maximum number of signatures to process on a ticker
MaxSignaturesPerTicker = 100
)
Variables ¶
This section is empty.
Functions ¶
func ParseGatewayInstruction ¶
func ParseGatewayInstruction( txResult *rpc.GetTransactionResult, gatewayID solana.PublicKey, coinType coin.CoinType, ) (contracts.OutboundInstruction, error)
ParseGatewayInstruction parses the outbound instruction from tx result
Types ¶
type Observer ¶
type Observer struct { // base.Observer implements the base chain observer base.Observer // contains filtered or unexported fields }
Observer is the observer for the Solana chain
func NewObserver ¶
func NewObserver( chain chains.Chain, solClient interfaces.SolanaRPCClient, chainParams observertypes.ChainParams, zetacoreClient interfaces.ZetacoreClient, tss interfaces.TSSSigner, rpcAlertLatency int64, db *db.DB, logger base.Logger, ts *metrics.TelemetryServer, ) (*Observer, error)
NewObserver returns a new Solana chain observer
func (*Observer) BuildInboundVoteMsgFromEvent ¶
func (ob *Observer) BuildInboundVoteMsgFromEvent(event *clienttypes.InboundEvent) *crosschaintypes.MsgVoteInbound
BuildInboundVoteMsgFromEvent builds a MsgVoteInbound from an inbound event
func (*Observer) CheckFinalizedTx ¶
func (ob *Observer) CheckFinalizedTx( ctx context.Context, txHash string, nonce uint64, coinType coin.CoinType, ) (*rpc.GetTransactionResult, bool)
CheckFinalizedTx checks if a txHash is finalized for given nonce and coinType returns (tx result, true) if finalized or (nil, false) otherwise
func (*Observer) CreateMsgVoteOutbound ¶
func (ob *Observer) CreateMsgVoteOutbound( cctxIndex string, outboundHash string, txResult *rpc.GetTransactionResult, valueReceived *big.Int, status chains.ReceiveStatus, nonce uint64, coinType coin.CoinType, ) *crosschaintypes.MsgVoteOutbound
CreateMsgVoteOutbound creates a vote outbound message for Solana chain
func (*Observer) FilterInboundEvents ¶
func (ob *Observer) FilterInboundEvents(txResult *rpc.GetTransactionResult) ([]*clienttypes.InboundEvent, error)
FilterInboundEvents filters inbound events from a tx result. Note: for consistency with EVM chains, this method
- takes at one event (the first) per token (SOL or SPL) per transaction.
- takes at most two events (one SOL + one SPL) per transaction.
- ignores exceeding events.
func (*Observer) FilterInboundEventsAndVote ¶
func (ob *Observer) FilterInboundEventsAndVote(ctx context.Context, txResult *rpc.GetTransactionResult) error
FilterInboundEventsAndVote filters inbound events from a txResult and post a vote.
func (*Observer) GetTxResult ¶
func (ob *Observer) GetTxResult(nonce uint64) *rpc.GetTransactionResult
GetTxResult returns the tx result for the given nonce
func (*Observer) IsEventProcessable ¶
func (ob *Observer) IsEventProcessable(event clienttypes.InboundEvent) bool
IsEventProcessable checks if the inbound event is processable
func (*Observer) IsTxFinalized ¶
IsTxFinalized returns true if there is a finalized tx for nonce
func (*Observer) LoadLastTxScanned ¶
LoadLastTxScanned loads the last scanned tx from the database.
func (*Observer) ObserveInbound ¶
ObserveInbound observes the Solana chain for inbounds and post votes to zetacore.
func (*Observer) PostGasPrice ¶
PostGasPrice posts gas price to zetacore
func (*Observer) PostVoteOutbound ¶
func (ob *Observer) PostVoteOutbound( ctx context.Context, cctxIndex string, outboundHash string, txResult *rpc.GetTransactionResult, valueReceived *big.Int, status chains.ReceiveStatus, nonce uint64, coinType coin.CoinType, )
PostVoteOutbound posts vote to zetacore for the finalized outbound
func (*Observer) ProcessInboundTrackers ¶
ProcessInboundTrackers processes inbound trackers
func (*Observer) ProcessOutboundTrackers ¶
ProcessOutboundTrackers processes Solana outbound trackers
func (*Observer) SetTxResult ¶
func (ob *Observer) SetTxResult(nonce uint64, result *rpc.GetTransactionResult)
SetTxResult sets the tx result for the given nonce
func (*Observer) SolClient ¶
func (ob *Observer) SolClient() interfaces.SolanaRPCClient
SolClient returns the solana rpc client
func (*Observer) VoteOutboundIfConfirmed ¶
func (ob *Observer) VoteOutboundIfConfirmed(ctx context.Context, cctx *crosschaintypes.CrossChainTx) (bool, error)
VoteOutboundIfConfirmed checks outbound status and returns (continueKeysign, error)
func (*Observer) WatchGasPrice ¶
WatchGasPrice watches the gas price of the chain and posts it to the zetacore
func (*Observer) WatchInbound ¶
WatchInbound watches Solana chain for inbounds on a ticker.
func (*Observer) WatchInboundTracker ¶
WatchInboundTracker watches zetacore for Solana inbound trackers
func (*Observer) WatchOutbound ¶
WatchOutbound watches solana chain for outgoing txs status TODO(revamp): move ticker function to ticker file
func (*Observer) WithSolClient ¶
func (ob *Observer) WithSolClient(client interfaces.SolanaRPCClient)
WithSolClient attaches a new solana rpc client to the observer