platdot

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: LGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Copyright 2020 ChainSafe Systems SPDX-License-Identifier: LGPL-3.0-only

The ethereum package contains the logic for interacting with ethereum chains.

There are 3 major components: the connection, the listener, and the writer. The currently supported transfer types are Fungible (ERC20), Non-Fungible (ERC721), and generic.

Connection

The connection contains the ethereum RPC client and can be accessed by both the writer and listener.

Listener

The listener polls for each new block and looks for deposit events in the bridge contract. If a deposit occurs, the listener will fetch additional information from the handler before constructing a message and forwarding it to the router.

Writer

The writer recieves the message and creates a proposals on-chain. Once a proposal is made, the writer then watches for a finalization event and will attempt to execute the proposal if a matching event occurs. The writer skips over any proposals it has already seen.

Index

Constants

View Source
const DefaultBlockConfirmations = 10
View Source
const DefaultGasLimit = 6721975
View Source
const DefaultGasMultiplier = 1
View Source
const DefaultGasPrice = 20000000000
View Source
const ExecuteBlockWatchLimit = 100

Number of blocks to wait for an finalization event

View Source
const TxRetryInterval = time.Second * 2

Time between retrying a failed tx

View Source
const TxRetryLimit = 10

Maximum number of tx retries before exiting

Variables

View Source
var (
	BridgeOpt             = "bridge"
	Erc20HandlerOpt       = "erc20Handler"
	Erc721HandlerOpt      = "erc721Handler"
	GenericHandlerOpt     = "genericHandler"
	MaxGasPriceOpt        = "maxGasPrice"
	GasLimitOpt           = "gasLimit"
	GasMultiplier         = "gasMultiplier"
	HttpOpt               = "http"
	StartBlockOpt         = "startBlock"
	BlockConfirmationsOpt = "blockConfirmations"
	PrefixOpt             = "prefix"
	NetWorkIdOpt          = "networkId"
)

Chain specific options

View Source
var BlockRetryInterval = time.Second * 5
View Source
var BlockRetryLimit = 5
View Source
var CancelledStatus uint8 = 4
View Source
var ErrFatalPolling = errors.New("listener block polling failed")
View Source
var ErrFatalQuery = errors.New("query of chain state failed")
View Source
var ErrFatalTx = errors.New("submission of transaction failed")
View Source
var ErrNonceTooLow = errors.New("nonce too low")
View Source
var ErrTxUnderpriced = errors.New("replacement transaction underpriced")
View Source
var PassedStatus uint8 = 2
View Source
var TransferredStatus uint8 = 3

Functions

func ConstructErc20ProposalData

func ConstructErc20ProposalData(amount []byte, recipient []byte) []byte

constructErc20ProposalData returns the bytes to construct a proposal suitable for Erc20

func ConstructErc721ProposalData

func ConstructErc721ProposalData(tokenId []byte, recipient []byte, metadata []byte) []byte

constructErc721ProposalData returns the bytes to construct a proposal suitable for Erc721

func ConstructGenericProposalData

func ConstructGenericProposalData(metadata []byte) []byte

constructGenericProposalData returns the bytes to construct a generic proposal

func NewListener

func NewListener(conn Connection, cfg *Config, log log15.Logger, bs blockstore.Blockstorer, stop <-chan int, sysErr chan<- error, m *metrics.ChainMetrics) *listener

NewListener creates and returns a listener

func NewWriter

func NewWriter(conn Connection, cfg *Config, log log15.Logger, stop <-chan int, sysErr chan<- error, m *metrics.ChainMetrics) *writer

NewWriter creates and returns writer

Types

type Chain

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

func InitializeChain

func InitializeChain(chainCfg *core.ChainConfig, logger log15.Logger, sysErr chan<- error, m *metrics.ChainMetrics) (*Chain, error)

func (*Chain) Id

func (c *Chain) Id() msg.ChainId

func (*Chain) LatestBlock

func (c *Chain) LatestBlock() metrics.LatestBlock

func (*Chain) Name

func (c *Chain) Name() string

func (*Chain) SetRouter

func (c *Chain) SetRouter(r *core.Router)

func (*Chain) Start

func (c *Chain) Start() error

func (*Chain) Stop

func (c *Chain) Stop()

Stop signals to any running routines to exit

type Config

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

Config encapsulates all necessary parameters in ethereum compatible forms

type Connection

type Connection interface {
	Connect() error
	Keypair() *secp256k1.Keypair
	Opts() *bind.TransactOpts
	CallOpts() *bind.CallOpts
	LockAndUpdateOpts() error
	UnlockOpts()
	Client() *ethclient.Client
	EnsureHasBytecode(address common.Address) error
	LatestBlock() (*big.Int, error)
	WaitForBlock(block *big.Int, delay *big.Int) error
	Close()
}

Jump to

Keyboard shortcuts

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