evm

package
v0.0.0-...-7be3494 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BTS_MAX_BLOCKS = 10000
)

Variables

This section is empty.

Functions

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

func PadAddress(address common.Address) vaa.Address

PadAddress creates 32-byte VAA.Address from 20-byte Ethereum addresses by adding 12 0-bytes at the left

Types

type Block

type Block struct {
	Timestamp uint64
	BlockNum  uint64
}

func (Block) Cmp

func (lhs Block) Cmp(rhs Block) int

Cmp compares two blocks, returning the usual -1, 0, +1.

type Blocks

type Blocks []Block

func (Blocks) SearchForTimestamp

func (blocks Blocks) SearchForTimestamp(timestamp uint64) int

type BlocksByTimestamp

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

func NewBlocksByTimestamp

func NewBlocksByTimestamp(maxCacheSize int) *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) 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 EthCallDataIntf

type EthCallDataIntf interface {
	CallDataList() []*query.EthCallData
}

type EvmCallData

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

EvmCallData contains the details of a single query in the batch.

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.PhylaxSet,
	obsvReqC <-chan *gossipv1.ObservationRequest,
	queryReqC <-chan *query.PerChainQueryInternal,
	queryResponseC chan<- *query.PerChainQueryResponseInternal,
	unsafeDevMode bool,
) *Watcher

func (*Watcher) GetLatestFinalizedBlockNumber

func (w *Watcher) GetLatestFinalizedBlockNumber() uint64

GetLatestFinalizedBlockNumber() implements the L1Finalizer interface and allows other watchers to get the latest finalized block number from this watcher.

func (*Watcher) Run

func (w *Watcher) Run(parentCtx context.Context) error

func (*Watcher) SetL1Finalizer

func (w *Watcher) SetL1Finalizer(l1Finalizer interfaces.L1Finalizer)

SetL1Finalizer is used to set the layer one finalizer.

func (*Watcher) SetMaxWaitConfirmations

func (w *Watcher) SetMaxWaitConfirmations(maxWaitConfirmations uint64)

SetMaxWaitConfirmations is used to override the maximum number of confirmations to wait before declaring a transaction abandoned.

func (*Watcher) SetRootChainParams

func (w *Watcher) SetRootChainParams(rootChainRpc string, rootChainContract string) error

SetRootChainParams is used to enabled checkpointing (currently only for Polygon). It handles if the feature is either enabled or disabled, but ensures the configuration is valid.

func (*Watcher) SetWaitForConfirmations

func (w *Watcher) SetWaitForConfirmations(waitForConfirmations bool)

SetWaitForConfirmations is used to override whether we should wait for the number of confirmations specified by the consistencyLevel in the message.

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
	PhylaxSetUpdateChain bool               // if `true`, we will retrieve the PhylaxSet from this chain and watch this chain for PhylaxSet updates
	WaitForConfirmations bool               // (optional)
	RootChainRpc         string             // (optional)
	RootChainContract    string             // (optional)
	L1FinalizerRequired  watchers.NetworkID // (optional)
	// 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.PhylaxSet,
	env common.Environment,
) (interfaces.L1Finalizer, supervisor.Runnable, 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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL