Documentation
¶
Index ¶
- Constants
- Variables
- func GetEvmChainID(env common.Environment, chainID vaa.ChainID) (uint64, error)
- func GetFinality(env common.Environment, chainID vaa.ChainID) (finalized bool, safe bool, err error)
- func MessageEventsForTransaction(ctx context.Context, ethConn connectors.Connector, contract eth_common.Address, ...) (uint64, []*common.MessagePublication, error)
- func PadAddress(address common.Address) vaa.Address
- func QueryEvmChainID(ctx context.Context, url string) (uint64, error)
- func SupportedInMainnet(chainID vaa.ChainID) bool
- type Block
- type Blocks
- type BlocksByTimestamp
- func (bts *BlocksByTimestamp) AddBatch(blocks Blocks)
- func (bts *BlocksByTimestamp) AddLatest(logger *zap.Logger, timestamp uint64, blockNum uint64)
- func (bts *BlocksByTimestamp) GetRange() (firstBlockNum, firstBlockTime, lastBlockNum, lastBlockTime uint64)
- func (bts *BlocksByTimestamp) LookUp(timestamp uint64) (uint64, uint64, bool)
- type EnvEntry
- type EnvMap
- type EthCallDataIntf
- type EvmCallData
- type Watcher
- func (w *Watcher) GetLatestFinalizedBlockNumber() uint64
- func (w *Watcher) QueryHandler(ctx context.Context, queryRequest *query.PerChainQueryInternal)
- func (w *Watcher) Reobserve(ctx context.Context, chainID vaa.ChainID, txID []byte, customEndpoint string) (uint32, error)
- func (w *Watcher) Run(parentCtx context.Context) error
- func (w *Watcher) SetL1Finalizer(l1Finalizer interfaces.L1Finalizer)
- type WatcherConfig
- func (wc *WatcherConfig) Create(msgC chan<- *common.MessagePublication, ...) (interfaces.L1Finalizer, supervisor.Runnable, interfaces.Reobserver, error)
- func (wc *WatcherConfig) GetChainID() vaa.ChainID
- func (wc *WatcherConfig) GetNetworkID() watchers.NetworkID
- func (wc *WatcherConfig) RequiredL1Finalizer() watchers.NetworkID
- func (wc *WatcherConfig) SetL1Finalizer(l1finalizer interfaces.L1Finalizer)
Constants ¶
const (
BTS_MAX_BLOCKS = 10000
)
const CCQ_BACKFILL_DELAY = 100 * time.Millisecond
const CCQ_MAX_BATCH_SIZE = int64(1000)
const CCQ_TIMESTAMP_RANGE_IN_SECONDS = uint64(30 * 60)
const MaxWaitConfirmations = 60
MaxWaitConfirmations is the maximum number of confirmations to wait before declaring a transaction abandoned.
Variables ¶
var ( ErrInvalidEnv = errors.New("invalid environment") ErrNotFound = errors.New("not found") )
var ( // SECURITY: Hardcoded ABI identifier for the LogMessagePublished topic. When using the watcher, we don't need this // since the node will only hand us pre-filtered events. In this case, we need to manually verify it // since ParseLogMessagePublished will only verify whether it parses. LogMessagePublishedTopic = eth_common.HexToHash("0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2") )
Functions ¶
func GetEvmChainID ¶
GetEvmChainID returns the configured EVM chain ID for the specified environment / chain.
func GetFinality ¶
func GetFinality(env common.Environment, chainID vaa.ChainID) (finalized bool, safe bool, err error)
GetFinality returns the finalized and safe flags for the specified environment / chain. These are used to configure the watcher at run time.
func MessageEventsForTransaction ¶
func MessageEventsForTransaction( ctx context.Context, ethConn connectors.Connector, contract eth_common.Address, chainId vaa.ChainID, tx eth_common.Hash) (uint64, []*common.MessagePublication, error)
MessageEventsForTransaction returns the lockup events for a given transaction. Returns the block number and a list of MessagePublication events.
func PadAddress ¶
PadAddress creates 32-byte VAA.Address from 20-byte Ethereum addresses by adding 12 0-bytes at the left
func QueryEvmChainID ¶
QueryEvmChainID queries the specified RPC for the EVM chain ID.
func SupportedInMainnet ¶
SupportedInMainnet returns true if the chain is configured in Mainnet.
Types ¶
type BlocksByTimestamp ¶
type BlocksByTimestamp struct {
// contains filtered or unexported fields
}
func NewBlocksByTimestamp ¶
func NewBlocksByTimestamp(maxCacheSize int, unsafeDevMode bool) *BlocksByTimestamp
NewBlocksByTimestamp creates an empty cache of blocks by timestamp.
func (*BlocksByTimestamp) AddBatch ¶
func (bts *BlocksByTimestamp) AddBatch(blocks Blocks)
AddBatch adds a batch of blocks to the cache. This is meant to be used for backfilling the cache. It makes sure there are no duplicate blocks and regenerates the cache in the correct order by timestamp.
func (*BlocksByTimestamp) AddLatest ¶
func (bts *BlocksByTimestamp) AddLatest(logger *zap.Logger, timestamp uint64, blockNum uint64)
AddLatest adds a block to the end of the cache. This is meant to be used in the normal scenario when a new latest block is received. If the specified timestamp or block number is less than the latest in the cache (most likely a rollback), the cache will be truncated and the new value inserted.
func (*BlocksByTimestamp) GetRange ¶
func (bts *BlocksByTimestamp) GetRange() (firstBlockNum, firstBlockTime, lastBlockNum, lastBlockTime uint64)
GetRange returns the range covered by the cache for debugging purposes.
func (*BlocksByTimestamp) LookUp ¶
func (bts *BlocksByTimestamp) LookUp(timestamp uint64) (uint64, uint64, bool)
LookUp searches the cache for the specified timestamp and returns the blocks surrounding that timestamp. It also returns true if the results are complete or false if they are not. The following rules apply: - If timestamp is less than the first timestamp in the cache, it returns (0, <theFirstBlockInTheCache>, false) - If timestamp is greater than or equal to the last timestamp in the cache, it returns (<theLastBlockInTheCache>, 0, false) - If timestamp exactly matches one in the cache, it returns (<theLastBlockForThatTimestamp>, <theFirstBlockForTheNextTimestamp>, true) - If timestamp is not in the cache, but there are blocks around it, it returns (<theLastBlockForThePreviousTimestamp>, <theFirstBlockForTheNextTimestamp>, false)
type EnvEntry ¶
type EnvEntry struct { // InstantFinality indicates that the chain has instant finality, meaning finalized and safe blocks can be generated along with the latest block. // Note that if InstantFinality is set to true, Finalized and Safe are for documentation purposes only. InstantFinality bool // Finalized indicates if the chain supports querying for finalized blocks. Finalized bool // Safe indicates if the chain supports querying for safe blocks. Safe bool // EvmChainID is the expected EVM chain ID (what is returned by the `eth_chainId` RPC call). EvmChainID uint64 // PublicRPC is not actually used by the watcher. It's used to verify that the EvmChainID specified here is correct. PublicRPC string }
EnvEntry specifies the config data for a given chain / environment.
type EnvMap ¶
EnvMap defines the config data for a given environment (mainet or testnet).
func GetChainConfigMap ¶
func GetChainConfigMap(env common.Environment) (EnvMap, error)
GetChainConfigMap is a helper that returns the configuration for the specified environment. This is public so the chain verify utility can use it.
type EthCallDataIntf ¶
type EthCallDataIntf interface {
CallDataList() []*query.EthCallData
}
type EvmCallData ¶
type EvmCallData struct { To eth_common.Address Data string CallResult *eth_hexutil.Bytes // contains filtered or unexported fields }
EvmCallData contains the details of a single call in the batch.
func (EvmCallData) String ¶
func (ecd EvmCallData) String() string
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func NewEthWatcher ¶
func NewEthWatcher( url string, contract eth_common.Address, networkName string, chainID vaa.ChainID, msgC chan<- *common.MessagePublication, setC chan<- *common.GuardianSet, obsvReqC <-chan *gossipv1.ObservationRequest, queryReqC <-chan *query.PerChainQueryInternal, queryResponseC chan<- *query.PerChainQueryResponseInternal, env common.Environment, ccqBackfillCache bool, ) *Watcher
func (*Watcher) GetLatestFinalizedBlockNumber ¶
GetLatestFinalizedBlockNumber() implements the L1Finalizer interface and allows other watchers to get the latest finalized block number from this watcher.
func (*Watcher) QueryHandler ¶
func (w *Watcher) QueryHandler(ctx context.Context, queryRequest *query.PerChainQueryInternal)
QueryHandler is the top-level query handler. It breaks out the requests based on the type and calls the appropriate handler.
func (*Watcher) Reobserve ¶
func (w *Watcher) Reobserve(ctx context.Context, chainID vaa.ChainID, txID []byte, customEndpoint string) (uint32, error)
Reobserve is the interface for reobserving using a custom URL. It opens a connection to that URL and does the reobservation on it.
func (*Watcher) SetL1Finalizer ¶
func (w *Watcher) SetL1Finalizer(l1Finalizer interfaces.L1Finalizer)
SetL1Finalizer is used to set the layer one finalizer.
type WatcherConfig ¶
type WatcherConfig struct { NetworkID watchers.NetworkID // human readable name ChainID vaa.ChainID // ChainID Rpc string // RPC URL Contract string // hex representation of the contract address GuardianSetUpdateChain bool // if `true`, we will retrieve the GuardianSet from this chain and watch this chain for GuardianSet updates L1FinalizerRequired watchers.NetworkID // (optional) CcqBackfillCache bool // contains filtered or unexported fields }
func (*WatcherConfig) Create ¶
func (wc *WatcherConfig) Create( msgC chan<- *common.MessagePublication, obsvReqC <-chan *gossipv1.ObservationRequest, queryReqC <-chan *query.PerChainQueryInternal, queryResponseC chan<- *query.PerChainQueryResponseInternal, setC chan<- *common.GuardianSet, env common.Environment, ) (interfaces.L1Finalizer, supervisor.Runnable, interfaces.Reobserver, error)
func (*WatcherConfig) GetChainID ¶
func (wc *WatcherConfig) GetChainID() vaa.ChainID
func (*WatcherConfig) GetNetworkID ¶
func (wc *WatcherConfig) GetNetworkID() watchers.NetworkID
func (*WatcherConfig) RequiredL1Finalizer ¶
func (wc *WatcherConfig) RequiredL1Finalizer() watchers.NetworkID
func (*WatcherConfig) SetL1Finalizer ¶
func (wc *WatcherConfig) SetL1Finalizer(l1finalizer interfaces.L1Finalizer)