Documentation
¶
Index ¶
- Constants
- func EnvVarLatestBlockByChain(chain chains.Chain) string
- func EnvVarLatestTxByChain(chain chains.Chain) string
- type Observer
- func (ob *Observer) AlertOnRPCLatency(latestBlockTime time.Time, defaultAlertLatency time.Duration) bool
- func (ob *Observer) AppContext() *corecontext.PellCoreContext
- func (ob *Observer) BlockCache() *lru.Cache
- func (ob *Observer) Chain() chains.Chain
- func (ob *Observer) ChainParams() relayertypes.ChainParams
- func (ob *Observer) DB() *db.DB
- func (ob *Observer) HeaderCache() *lru.Cache
- func (ob *Observer) LastBlock() uint64
- func (ob *Observer) LastBlockScanned() uint64
- func (ob *Observer) LastInboundBlock() uint64
- func (ob *Observer) LoadBlockScanInfo(logger zerolog.Logger) error
- func (ob *Observer) Logger() *ObserverLogger
- func (ob *Observer) Mu() *sync.Mutex
- func (ob *Observer) OutboundID(nonce uint64) string
- func (ob *Observer) PellcoreClient() interfaces.PellCoreBridger
- func (ob *Observer) PostVoteInbound(ctx context.Context, msg *xmsgtypes.MsgVoteOnObservedInboundTx, ...) (string, error)
- func (ob *Observer) PostVoteInboundBlock(ctx context.Context, gasLimit, retryGasLimit uint64, ...) ([]string, []string, error)
- func (ob *Observer) ReadBlockScanInfoFromDB() (uint64, uint64, error)
- func (ob *Observer) SaveScanInfo(blockNumber, lastInboundBlock uint64) error
- func (ob *Observer) Start() bool
- func (ob *Observer) Stop()
- func (ob *Observer) StopChannel() chan struct{}
- func (ob *Observer) TSS() interfaces.TSSSigner
- func (ob *Observer) TelemetryServer() *metrics.TelemetryServer
- func (ob *Observer) WithBlockCache(cache *lru.Cache) *Observer
- func (ob *Observer) WithChain(chain chains.Chain) *Observer
- func (ob *Observer) WithChainParams(params relayertypes.ChainParams) *Observer
- func (ob *Observer) WithHeaderCache(cache *lru.Cache) *Observer
- func (ob *Observer) WithInboundBlock(lastBlock uint64) *Observer
- func (ob *Observer) WithLastBlock(lastBlock uint64) *Observer
- func (ob *Observer) WithLastBlockScanned(blockNumber uint64) *Observer
- func (ob *Observer) WithLogger(logger logs.Logger) *Observer
- func (ob *Observer) WithPellcoreClient(client interfaces.PellCoreBridger) *Observer
- func (ob *Observer) WithTSS(tss interfaces.TSSSigner) *Observer
- func (ob *Observer) WithTelemetryServer(ts *metrics.TelemetryServer) *Observer
- type ObserverLogger
- type Signer
- func (s *Signer) Chain() *chains.Chain
- func (s *Signer) ClearBeingReportedFlag(hash string)
- func (s *Signer) CoreContext() *corecontext.PellCoreContext
- func (s *Signer) GetBeingReportedFlag(hash string) bool
- func (s *Signer) GetReportedTxList() *map[string]bool
- func (s *Signer) Lock()
- func (s *Signer) Logger() *clientlogs.Logger
- func (s *Signer) SetBeingReportedFlag(hash string) (alreadySet bool)
- func (s *Signer) TSS() interfaces.TSSSigner
- func (s *Signer) TelemetryServer() *metrics.TelemetryServer
- func (s *Signer) Unlock()
- func (s *Signer) WithChain(chain chains.Chain) *Signer
- func (s *Signer) WithTSS(tssSigner interfaces.TSSSigner) *Signer
- func (s *Signer) WithTelemetryServer(ts *metrics.TelemetryServer) *Signer
Constants ¶
const ( // EnvVarLatestBlock is the environment variable that forces the observer to scan from the latest block EnvVarLatestBlock = "latest" // DefaultBlockCacheSize is the default number of blocks that the observer will keep in cache for performance (without RPC calls) // Cached blocks can be used to get block information and verify transactions DefaultBlockCacheSize = 1000 // DefaultHeaderCacheSize is the default number of headers that the observer will keep in cache for performance (without RPC calls) // Cached headers can be used to get header information DefaultHeaderCacheSize = 1000 )
Variables ¶
This section is empty.
Functions ¶
func EnvVarLatestBlockByChain ¶
EnvVarLatestBlockByChain returns the environment variable for the last block by chain.
func EnvVarLatestTxByChain ¶
EnvVarLatestTxByChain returns the environment variable for the last tx by chain.
Types ¶
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
Observer is the base structure for chain observers, grouping the common logic for each chain observer client. The common logic includes: chain, chainParams, contexts, pellcore client, tss, lastBlock, db, metrics, loggers etc.
func NewObserver ¶
func NewObserver( coreContext *corecontext.PellCoreContext, chain chains.Chain, chainParams relayertypes.ChainParams, pellcoreClient interfaces.PellCoreBridger, tss interfaces.TSSSigner, blockCacheSize int, headerCacheSize int, rpcAlertLatency int64, ts *metrics.TelemetryServer, database *db.DB, logger logs.Logger, ) (*Observer, error)
NewObserver creates a new base observer.
func (*Observer) AlertOnRPCLatency ¶
func (ob *Observer) AlertOnRPCLatency(latestBlockTime time.Time, defaultAlertLatency time.Duration) bool
AlertOnRPCLatency prints an alert if the RPC latency exceeds the threshold. Returns true if the RPC latency is too high.
func (*Observer) AppContext ¶
func (ob *Observer) AppContext() *corecontext.PellCoreContext
AppContext returns the app context.
func (*Observer) BlockCache ¶
BlockCache returns the block cache for the observer.
func (*Observer) ChainParams ¶
func (ob *Observer) ChainParams() relayertypes.ChainParams
ChainParams returns the chain params for the observer.
func (*Observer) HeaderCache ¶
HeaderCache returns the header cache for the observer.
func (*Observer) LastBlockScanned ¶
LastBlockScanned get last block scanned (not necessarily caught up with the chain; could be slow/paused).
func (*Observer) LastInboundBlock ¶
LastInboundBlock get external last block height.
func (*Observer) LoadBlockScanInfo ¶
LoadBlockScanInfo loads last scanned block from environment variable or from database. The last scanned block is the height from which the observer should continue scanning.
func (*Observer) Logger ¶
func (ob *Observer) Logger() *ObserverLogger
Logger returns the logger for the observer.
func (*Observer) OutboundID ¶
OutboundID returns a unique identifier for the outbound transaction. The identifier is now used as the key for maps that store outbound related data (e.g. transaction, receipt, etc).
func (*Observer) PellcoreClient ¶
func (ob *Observer) PellcoreClient() interfaces.PellCoreBridger
PellcoreClient returns the pellcore client for the observer.
func (*Observer) PostVoteInbound ¶
func (ob *Observer) PostVoteInbound( ctx context.Context, msg *xmsgtypes.MsgVoteOnObservedInboundTx, retryGasLimit uint64, ) (string, error)
PostVoteInbound posts a vote for the given vote message
func (*Observer) PostVoteInboundBlock ¶
func (ob *Observer) PostVoteInboundBlock( ctx context.Context, gasLimit, retryGasLimit uint64, blockProof *xmsgtypes.MsgVoteInboundBlock, events []*xmsgtypes.MsgVoteOnObservedInboundTx, ) ([]string, []string, error)
PostVoteInboundBlock posts a vote for the given inbound block and events aggregates information from a block, including the block proof and event messages, into a single transaction for submission to the blockchain.
func (*Observer) ReadBlockScanInfoFromDB ¶
ReadBlockScanInfoFromDB reads the last scanned block from the database.
func (*Observer) SaveScanInfo ¶
SaveScanInfo saves the last scanned block to memory and database.
func (*Observer) Start ¶
Start starts the observer. Returns true if the observer was already started (noop).
func (*Observer) Stop ¶
func (ob *Observer) Stop()
Stop notifies all goroutines to stop and closes the database.
func (*Observer) StopChannel ¶
func (ob *Observer) StopChannel() chan struct{}
StopChannel returns the stop channel for the observer.
func (*Observer) TSS ¶
func (ob *Observer) TSS() interfaces.TSSSigner
Tss returns the tss signer for the observer.
func (*Observer) TelemetryServer ¶
func (ob *Observer) TelemetryServer() *metrics.TelemetryServer
TelemetryServer returns the telemetry server for the observer.
func (*Observer) WithBlockCache ¶
WithBlockCache attaches a new block cache to the observer.
func (*Observer) WithChainParams ¶
func (ob *Observer) WithChainParams(params relayertypes.ChainParams) *Observer
WithChainParams attaches a new chain params to the observer.
func (*Observer) WithHeaderCache ¶
WithHeaderCache attaches a new header cache to the observer.
func (*Observer) WithInboundBlock ¶
WithLastBlock set external last block height.
func (*Observer) WithLastBlock ¶
WithLastBlock set external last block height.
func (*Observer) WithLastBlockScanned ¶
WithLastBlockScanned set last block scanned (not necessarily caught up with the chain; could be slow/paused).
func (*Observer) WithLogger ¶
WithLogger attaches a new logger to the observer.
func (*Observer) WithPellcoreClient ¶
func (ob *Observer) WithPellcoreClient(client interfaces.PellCoreBridger) *Observer
WithPellcoreClient attaches a new pellcore client to the observer.
func (*Observer) WithTSS ¶
func (ob *Observer) WithTSS(tss interfaces.TSSSigner) *Observer
WithTSS attaches a new tss signer to the observer.
func (*Observer) WithTelemetryServer ¶
func (ob *Observer) WithTelemetryServer(ts *metrics.TelemetryServer) *Observer
WithTelemetryServer attaches a new telemetry server to the observer.
type ObserverLogger ¶
type ObserverLogger struct {
// the parent logger for the chain observer
Chain zerolog.Logger
// the logger for inbound transactions
Inbound zerolog.Logger
// the logger for outbound transactions
Outbound zerolog.Logger
// the logger for the chain's gas price
GasPrice zerolog.Logger
// the logger for block headers
Headers zerolog.Logger
// the logger for the compliance check
Compliance zerolog.Logger
}
ObserverLogger contains the loggers for chain observers
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer is the base structure for grouping the common logic between chain signers. The common logic includes: chain, chainParams, contexts, tss, metrics, loggers etc.
func NewSigner ¶
func NewSigner( chain chains.Chain, tssSigner interfaces.TSSSigner, coreContext *corecontext.PellCoreContext, ts *metrics.TelemetryServer, logger clientlogs.Logger, ) *Signer
NewSigner creates a new base signer.
func (*Signer) ClearBeingReportedFlag ¶
ClearBeingReportedFlag clears the being reported flag for the outbound.
func (*Signer) CoreContext ¶
func (s *Signer) CoreContext() *corecontext.PellCoreContext
CoreContext returns the coreclient
func (*Signer) GetBeingReportedFlag ¶
func (*Signer) GetReportedTxList ¶
GetReportedTxList returns a list of outboundHash being reported. TODO: investigate pointer usage
func (*Signer) Logger ¶
func (s *Signer) Logger() *clientlogs.Logger
Logger returns the logger for the signer.
func (*Signer) SetBeingReportedFlag ¶
SetBeingReportedFlag sets the outbound as being reported if not already set. Returns true if the outbound is already being reported. This method is used by outbound tracker reporter to avoid repeated reporting of same hash.
func (*Signer) TSS ¶
func (s *Signer) TSS() interfaces.TSSSigner
Tss returns the tss signer for the signer.
func (*Signer) TelemetryServer ¶
func (s *Signer) TelemetryServer() *metrics.TelemetryServer
TelemetryServer returns the telemetry server for the signer.
func (*Signer) WithTSS ¶
func (s *Signer) WithTSS(tssSigner interfaces.TSSSigner) *Signer
WithTSS attaches a new tss signer to the signer.
func (*Signer) WithTelemetryServer ¶
func (s *Signer) WithTelemetryServer(ts *metrics.TelemetryServer) *Signer
WithTelemetryServer attaches a new telemetry server to the signer.