ethereum

package
v0.75.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

README

Ethereum event forwarder

This package contains the specific implementation of the event forwarder for Ethereum blockchain.

It reads the logs of Vega's bridge contracts, filters on specific events, translates them to ChainEvent transactions and use the Event Forwarder engine to forward it to the network.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assets

type Assets interface {
	GetVegaIDFromEthereumAddress(string) string
}

Assets ...

type Client

type Client interface {
	ethbind.ContractFilterer

	CurrentHeight(context.Context) (uint64, error)
	HeaderByNumber(context.Context, *big.Int) (*ethtypes.Header, error)
}

type Config

type Config struct {
	// Level specifies the logging level of the Ethereum implementation of the
	// Event Forwarder.
	Level                  encoding.LogLevel `long:"log-level"`
	MaxEthereumBlocks      uint64            `long:"max-ethereum-blocks"`
	PollEventRetryDuration encoding.Duration
}

func NewDefaultConfig added in v0.55.0

func NewDefaultConfig() Config

type Engine

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

func NewEngine

func NewEngine(
	cfg Config,
	log *logging.Logger,
	filterer Filterer,
	forwarder Forwarder,
	stakingDeployment types.EthereumContract,
	vestingDeployment types.EthereumContract,
	multiSigDeployment types.EthereumContract,
) *Engine

func (*Engine) ReloadConf

func (e *Engine) ReloadConf(cfg Config)

func (*Engine) Start

func (e *Engine) Start()

Start starts the polling of the Ethereum bridges, listens to the events they emit and forward it to the network.

func (*Engine) Stop

func (e *Engine) Stop()

Stop stops the engine, its polling and event forwarding.

func (*Engine) UpdateCollateralStartingBlock added in v0.69.0

func (e *Engine) UpdateCollateralStartingBlock(b uint64)

func (*Engine) UpdateMultiSigControlStartingBlock

func (e *Engine) UpdateMultiSigControlStartingBlock(b uint64)

func (*Engine) UpdateStakingStartingBlock

func (e *Engine) UpdateStakingStartingBlock(b uint64)

type Filterer

type Filterer interface {
	FilterCollateralEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)
	FilterStakingEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)
	FilterVestingEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)
	FilterMultisigControlEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)
	CurrentHeight(context.Context) uint64
}

type Forwarder

type Forwarder interface {
	ForwardFromSelf(*commandspb.ChainEvent)
}

type LogFilterer

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

LogFilterer wraps the Ethereum event filterers to return Vega events.

func NewLogFilterer

func NewLogFilterer(
	cfg Config,
	log *logging.Logger,
	ethClient Client,
	collateralBridge types.EthereumContract,
	stakingBridge types.EthereumContract,
	vestingBridge types.EthereumContract,
	multiSigControl types.EthereumContract,
	assets Assets,
) (*LogFilterer, error)

func (*LogFilterer) CurrentHeight

func (f *LogFilterer) CurrentHeight(ctx context.Context) uint64

func (*LogFilterer) FilterCollateralEvents

func (f *LogFilterer) FilterCollateralEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)

FilterCollateralEvents retrieves the events from the collateral bridge on Ethereum starting at startAt, transform them into ChainEvent, and pass it to the OnEventFound callback. The properties startAt and stopAt are inclusive.

func (*LogFilterer) FilterMultisigControlEvents

func (f *LogFilterer) FilterMultisigControlEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)

func (*LogFilterer) FilterStakingEvents

func (f *LogFilterer) FilterStakingEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)

FilterStakingEvents retrieves the events from the staking bridge on Ethereum starting at startAt, transform them into ChainEvent, and pass it to the OnEventFound callback. The properties startAt and stopAt are inclusive.

func (*LogFilterer) FilterVestingEvents

func (f *LogFilterer) FilterVestingEvents(ctx context.Context, startAt, stopAt uint64, cb OnEventFound)

FilterVestingEvents retrieves the events from the vesting bridge on Ethereum starting at startAt, transform them into ChainEvent, and pass it to the OnEventFound callback. The properties startAt and stopAt are inclusive.

type OnEventFound

type OnEventFound func(*commandspb.ChainEvent)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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