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
- Variables
- func ConstructErc20ProposalDataHash(handler ethCommon.Address, recipient ethCommon.Address, amount *big.Int) [32]byte
- func ConstructErc721ProposalDataHash(handler ethCommon.Address, recipient ethCommon.Address, tokenId *big.Int, ...) [32]byte
- func NewListener(conn Connection, chainDB *chains.ChainDB, cfg *Config, log log15.Logger, ...) *listener
- func NewWriter(conn Connection, cfg *Config, log log.Logger, stop <-chan int, ...) *writer
- type Chain
- type Config
- type Connection
Constants ¶
const BlockRetryLimit = 5
const DefaultBlockConfirmations = 12
const DefaultGasLimit = 6721975
const DefaultGasPrice = 100000000000
const ExecuteBlockWatchLimit = 100
Number of blocks to wait for an finalization event
Variables ¶
var ( BridgeOpt = "bridge" NFTBridgeOpt = "nftBridge" Erc20HandlerOpt = "erc20Handler" Erc721HandlerOpt = "erc721Handler" GenericHandlerOpt = "genericHandler" MaxGasPriceOpt = "maxGasPrice" GasLimitOpt = "gasLimit" HttpOpt = "http" StartBlockOpt = "startBlock" BlockConfirmationsOpt = "blockConfirmations" CommitVotesStartSeqOpt = "commitVotesStartSeq" )
Chain specific options
var BlockRetryInterval = time.Second * 10
var CancelledStatus uint8 = 4
var ErrNonceTooLow = errors.New("nonce too low")
var ErrTxUnderpriced = errors.New("replacement transaction underpriced")
var PassedStatus uint8 = 2
var TransferredStatus uint8 = 3
var WatchDuration = 60 * 60 * 10 // 10 hours
Functions ¶
func NewListener ¶
func NewListener(conn Connection, chainDB *chains.ChainDB, cfg *Config, log log15.Logger, 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 log.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, chainDB *chains.ChainDB, logger log15.Logger, sysErr chan<- error, m *metrics.ChainMetrics) (*Chain, core.ProposalState, error)
func (*Chain) LatestBlock ¶
func (c *Chain) LatestBlock() metrics.LatestBlock
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) error Close() }