Documentation
¶
Index ¶
- Constants
- func EnvVarLatestBlockByChain(chain chains.Chain) string
- func EnvVarLatestTxByChain(chain chains.Chain) string
- func OutboundID(index string, receiverChainID int64, nonce uint64) string
- func OutboundIDFromCCTX(cctx *types.CrossChainTx) string
- type Logger
- type Observer
- func (ob *Observer) BlockCache() *lru.Cache
- func (ob *Observer) Chain() chains.Chain
- func (ob *Observer) ChainParams() observertypes.ChainParams
- func (ob *Observer) DB() *db.DB
- func (ob *Observer) IsBlockConfirmed(blockNumber uint64) bool
- func (ob *Observer) LastBlock() uint64
- func (ob *Observer) LastBlockScanned() uint64
- func (ob *Observer) LastTxScanned() string
- func (ob *Observer) LoadLastBlockScanned(logger zerolog.Logger) error
- func (ob *Observer) LoadLastTxScanned()
- func (ob *Observer) Logger() *ObserverLogger
- func (ob *Observer) Mu() *sync.Mutex
- func (ob *Observer) OutboundID(nonce uint64) string
- func (ob *Observer) PostVoteInbound(ctx context.Context, msg *crosschaintypes.MsgVoteInbound, retryGasLimit uint64) (string, error)
- func (ob *Observer) ReadLastBlockScannedFromDB() (uint64, error)
- func (ob *Observer) ReadLastTxScannedFromDB() (string, error)
- func (ob *Observer) ReportBlockLatency(latestBlockTime time.Time)
- func (ob *Observer) SaveLastBlockScanned(blockNumber uint64) error
- func (ob *Observer) SaveLastTxScanned(txHash string, slot uint64) error
- func (ob *Observer) SetChainParams(params observertypes.ChainParams)
- func (ob *Observer) Start() bool
- func (ob *Observer) Stop()
- func (ob *Observer) StopChannel() chan struct{}
- func (ob *Observer) TSS() interfaces.TSSSigner
- func (ob *Observer) TSSAddressString() string
- func (ob *Observer) TelemetryServer() *metrics.TelemetryServer
- func (ob *Observer) WithLastBlock(lastBlock uint64) *Observer
- func (ob *Observer) WithLastBlockScanned(blockNumber uint64) *Observer
- func (ob *Observer) WithLastTxScanned(txHash string) *Observer
- func (ob *Observer) WriteLastBlockScannedToDB(lastScannedBlock uint64) error
- func (ob *Observer) WriteLastTxScannedToDB(txHash string) error
- func (ob *Observer) ZetacoreClient() interfaces.ZetacoreClient
- type ObserverLogger
- type Signer
- func (s *Signer) Chain() chains.Chain
- func (s *Signer) ClearBeingReportedFlag(hash string)
- func (s *Signer) GetReportedTxList() *map[string]bool
- func (s *Signer) IsOutboundActive(outboundID string) bool
- func (s *Signer) Lock()
- func (s *Signer) Logger() *Logger
- func (s *Signer) MarkOutbound(outboundID string, active bool)
- func (s *Signer) SetBeingReportedFlag(hash string) (alreadySet bool)
- func (s *Signer) TSS() interfaces.TSSSigner
- func (s *Signer) Unlock()
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 )
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.
func OutboundID ¶
OutboundID returns the outbound ID.
func OutboundIDFromCCTX ¶
func OutboundIDFromCCTX(cctx *types.CrossChainTx) string
OutboundIDFromCCTX returns the outbound ID from the cctx.
Types ¶
type Logger ¶
Logger contains the base loggers
func DefaultLogger ¶
func DefaultLogger() Logger
DefaultLogger creates default base loggers for tests
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, zetacore client, tss, lastBlock, db, metrics, loggers etc.
func NewObserver ¶
func NewObserver( chain chains.Chain, chainParams observertypes.ChainParams, zetacoreClient interfaces.ZetacoreClient, tss interfaces.TSSSigner, blockCacheSize int, ts *metrics.TelemetryServer, database *db.DB, logger Logger, ) (*Observer, error)
NewObserver creates a new base observer.
func (*Observer) BlockCache ¶
BlockCache returns the block cache for the observer.
func (*Observer) ChainParams ¶
func (ob *Observer) ChainParams() observertypes.ChainParams
ChainParams returns the chain params for the observer.
func (*Observer) IsBlockConfirmed ¶
IsBlockConfirmed checks if the given block number is confirmed.
Note: block 100 is confirmed if the last block is 100 and confirmation count is 1.
func (*Observer) LastBlockScanned ¶
LastBlockScanned get last block scanned (not necessarily caught up with the chain; could be slow/paused).
func (*Observer) LastTxScanned ¶
LastTxScanned get last transaction scanned.
func (*Observer) LoadLastBlockScanned ¶
LoadLastBlockScanned 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) LoadLastTxScanned ¶
func (ob *Observer) LoadLastTxScanned()
LoadLastTxScanned loads last scanned tx from environment variable or from database. The last scanned tx is the tx hash 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) PostVoteInbound ¶
func (ob *Observer) PostVoteInbound( ctx context.Context, msg *crosschaintypes.MsgVoteInbound, retryGasLimit uint64, ) (string, error)
PostVoteInbound posts a vote for the given vote message and returns the ballot.
func (*Observer) ReadLastBlockScannedFromDB ¶
ReadLastBlockScannedFromDB reads the last scanned block from the database.
func (*Observer) ReadLastTxScannedFromDB ¶
ReadLastTxScannedFromDB reads the last scanned tx hash from the database.
func (*Observer) ReportBlockLatency ¶
ReportBlockLatency records the latency between the current time an the latest block time for a chain as a metric
func (*Observer) SaveLastBlockScanned ¶
SaveLastBlockScanned saves the last scanned block to memory and database.
func (*Observer) SaveLastTxScanned ¶
SaveLastTxScanned saves the last scanned tx hash to memory and database.
func (*Observer) SetChainParams ¶
func (ob *Observer) SetChainParams(params observertypes.ChainParams)
SetChainParams attaches a new chain params to the observer.
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) TSSAddressString ¶
TSSAddressString returns the TSS address for the chain.
Note: all chains uses TSS EVM address except Bitcoin chain.
func (*Observer) TelemetryServer ¶
func (ob *Observer) TelemetryServer() *metrics.TelemetryServer
TelemetryServer returns the telemetry server for the observer.
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) WithLastTxScanned ¶
WithLastTxScanned set last transaction scanned.
func (*Observer) WriteLastBlockScannedToDB ¶
WriteLastBlockScannedToDB saves the last scanned block to the database.
func (*Observer) WriteLastTxScannedToDB ¶
WriteLastTxScannedToDB saves the last scanned tx hash to the database.
func (*Observer) ZetacoreClient ¶
func (ob *Observer) ZetacoreClient() interfaces.ZetacoreClient
ZetacoreClient returns the zetacore client for 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 (*Signer) ClearBeingReportedFlag ¶
ClearBeingReportedFlag clears the being reported flag for the outbound.
func (*Signer) GetReportedTxList ¶
GetReportedTxList returns a list of outboundHash being reported. TODO: investigate pointer usage https://github.com/zeta-chain/node/issues/2084
func (*Signer) IsOutboundActive ¶
func (*Signer) MarkOutbound ¶
MarkOutboundActive marks the outbound as active.
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.