ethdeposits

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

package ethdeposits implements an listener that listens to Ethereum events and triggers the creation of deposit events in Kwil.

Index

Constants

View Source
const ListenerName = "eth_deposits"

Variables

This section is empty.

Functions

func Start

func Start(ctx context.Context, service *common.Service, eventStore listeners.EventStore) error

Start starts the eth_deposit listener, which triggers the creation of deposit events in Kwil. It can be configured to listen to a certain smart contract address. It will listen for the EVM event signature "Credit(address,uint256)" and create a deposit event in Kwil when it sees a matching event. It uses the "credit_account" resolution, defined in extensions/resolutions/credit/credit.go, to create the deposit event. It will search for a local extension configuration named "eth_deposit".

Types

type EthDepositConfig

type EthDepositConfig struct {
	// StartingHeight is the Ethereum block height it will start listening from.
	// Any events emitted before this height will be ignored.
	// If not configured, it will start from block 0.
	StartingHeight int64
	// ContractAddress is the Ethereum address of the smart contract it will listen to.
	// It is a required configuration.
	ContractAddress string
	// RequiredConfirmations is the number of Ethereum blocks that must be mined before
	// the listener will create a deposit event in Kwil. This is to protect against Ethereum
	// network reorgs / soft forks. If not configured, it will default to 12.
	// https://www.alchemy.com/overviews/what-is-a-reorg
	RequiredConfirmations int64
	// RPCProvider is the URL of the Ethereum RPC endpoint it will connect to.
	// This would likely be an Infura / Alchemy endpoint.
	// It is a required configuration.
	RPCProvider string
	// ReconnectionInterval is the amount of time in seconds that the listener
	// will wait before resubscribing for new Ethereum Blocks. Reconnects are
	// automatically handled, but a subscription may stall, in which case we
	// will make a new subscription. If the write or read on the connection to
	// the RPC provider errors, the RPC client will reconnect, and we will
	// continue to reestablish a new block subscription. If not configured, it
	// will default to 60s.
	ReconnectionInterval int64
	// MaxRetries is the total number of times the listener will attempt an RPC
	// with the provider before giving up. It will exponentially back off after
	// each try, starting at 1 second and doubling each time. If not configured,
	// it will default to 10.
	MaxRetries int64
	// BlockSyncChunkSize is the number of Ethereum blocks the listener will request from the
	// Ethereum RPC endpoint at a time while catching up to the network. If not configured,
	// it will default to 1,000,000.
	BlockSyncChunkSize int64
}

EthDepositConfig is the configuration for the eth_deposit listener. It can be read in from a map[string]string, which is passed from the node's local configuration.

func (*EthDepositConfig) Map

func (e *EthDepositConfig) Map() map[string]string

Map returns the configuration as a map[string]string. This is used for testing

Jump to

Keyboard shortcuts

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