evm

package
v0.0.0-...-753386a Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BTS_MAX_BLOCKS = 10000
)
View Source
const CCQ_BACKFILL_DELAY = 100 * time.Millisecond
View Source
const CCQ_MAX_BATCH_SIZE = int64(1000)
View Source
const CCQ_TIMESTAMP_RANGE_IN_SECONDS = uint64(30 * 60)
View Source
const MaxWaitConfirmations = 60

MaxWaitConfirmations is the maximum number of confirmations to wait before declaring a transaction abandoned.

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, 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 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,
	unsafeDevMode bool,
	ccqBackfillCache 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) 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) 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.

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, 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
finalizers

Jump to

Keyboard shortcuts

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