evm

package
v1.2.9-rc8 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RPCCallRetry           = 5
	MaxTxFixtures          = 10
	DefaultPollingInterval = time.Second * 30
	MaximumPollTry         = 15
)
View Source
const (
	ErrorLessGas          = "transaction underpriced"
	ErrorLimitLessThanGas = "max fee per gas less than block base fee"
	ErrUnKnown            = "unknown"
	ErrNonceTooLow        = "nonce too low"
	ErrNonceTooHigh       = "nonce too high"
)
View Source
const (
	DefaultFinalityBlock = 10
)

Variables

View Source
var (
	EmitMessage = "Message(string,uint256,bytes)"
	CallMessage = "CallMessage(string,string,uint256,uint256,bytes)"

	EmitMessageHash = crypto.Keccak256Hash([]byte(EmitMessage))
	CallMessageHash = crypto.Keccak256Hash([]byte(CallMessage))
)

All the events

View Source
var (
	// Connection contract
	MethodRecvMessage   = "recvMessage"
	MethodSetAdmin      = "setAdmin"
	MethodRevertMessage = "revertMessage"
	MethodClaimFees     = "claimFees"
	MethodSetFee        = "setFee"
	MethodGetFee        = "getFee"

	// Xcall contract
	MethodExecuteCall = "executeCall"
)

Functions

This section is empty.

Types

type BnOptions

type BnOptions struct {
	StartHeight uint64
	Concurrency uint64
}

type Client

type Client struct {

	// evm chain ID
	EVMChainID *big.Int
	// contains filtered or unexported fields
}

grouped rpc api clients

func (*Client) CallContract

func (cl *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

func (*Client) ClaimFee added in v1.1.0

func (c *Client) ClaimFee(opts *bind.TransactOpts) (*ethTypes.Transaction, error)

ClaimFee

func (*Client) EstimateGas added in v1.1.0

func (c *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

func (*Client) ExecuteCall added in v1.1.0

func (c *Client) ExecuteCall(opts *bind.TransactOpts, reqID *big.Int, data []byte) (*ethTypes.Transaction, error)

func (*Client) ExecuteRollback added in v1.1.0

func (c *Client) ExecuteRollback(opts *bind.TransactOpts, sn *big.Int) (*ethTypes.Transaction, error)

ExecuteRollback

func (*Client) FilterLogs

func (cl *Client) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethTypes.Log, error)

func (*Client) GetBalance

func (cl *Client) GetBalance(ctx context.Context, hexAddr string) (*big.Int, error)

func (*Client) GetBlockByHash

func (cl *Client) GetBlockByHash(hash common.Hash) (*types.Block, error)

func (*Client) GetBlockNumber

func (cl *Client) GetBlockNumber() (uint64, error)

func (*Client) GetChainID

func (c *Client) GetChainID() *big.Int

func (*Client) GetEthClient

func (c *Client) GetEthClient() *ethclient.Client

func (*Client) GetFee added in v1.1.0

func (c *Client) GetFee(opts *bind.CallOpts, networkID string) (*big.Int, error)

GetFee

func (*Client) GetHeaderByHeight

func (cl *Client) GetHeaderByHeight(ctx context.Context, height *big.Int) (*ethTypes.Header, error)

func (*Client) GetLogs

func (cl *Client) GetLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethTypes.Log, error)

func (*Client) Log

func (c *Client) Log() *zap.Logger

func (*Client) MessageReceived

func (c *Client) MessageReceived(opts *bind.CallOpts, srcNetwork string, _connSn *big.Int) (bool, error)

func (*Client) ParseConnectionMessage added in v1.1.0

func (cl *Client) ParseConnectionMessage(log ethTypes.Log) (*bridgeContract.ConnectionMessage, error)

func (*Client) ParseXcallMessage added in v1.1.0

func (c *Client) ParseXcallMessage(log ethTypes.Log) (*bridgeContract.XcallCallMessage, error)

func (*Client) PendingNonceAt added in v1.2.9

func (c *Client) PendingNonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

func (*Client) ReceiveMessage

func (c *Client) ReceiveMessage(opts *bind.TransactOpts, srcNID string, sn *big.Int, msg []byte) (*ethTypes.Transaction, error)

func (*Client) RevertMessage

func (c *Client) RevertMessage(opts *bind.TransactOpts, sn *big.Int) (*ethTypes.Transaction, error)

func (*Client) SendMessage

func (c *Client) SendMessage(opts *bind.TransactOpts, _to string, _svc string, _sn *big.Int, _msg []byte) (*ethTypes.Transaction, error)

func (*Client) SendTransaction

func (c *Client) SendTransaction(ctx context.Context, tx *ethTypes.Transaction) error

func (*Client) SetAdmin

func (c *Client) SetAdmin(opts *bind.TransactOpts, newAdmin common.Address) (*ethTypes.Transaction, error)

func (*Client) SetFee added in v1.1.0

func (c *Client) SetFee(opts *bind.TransactOpts, src string, msg, res *big.Int) (*ethTypes.Transaction, error)

SetFee

func (*Client) Subscribe added in v1.1.2

func (c *Client) Subscribe(ctx context.Context, q ethereum.FilterQuery, ch chan ethTypes.Log) (ethereum.Subscription, error)

Subscribe

func (*Client) SuggestGasPrice

func (cl *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)

func (*Client) SuggestGasTip added in v1.2.9

func (cl *Client) SuggestGasTip(ctx context.Context) (*big.Int, error)

func (*Client) TransactionByHash

func (cl *Client) TransactionByHash(ctx context.Context, blockHash common.Hash) (tx *ethTypes.Transaction, isPending bool, err error)

func (*Client) TransactionReceipt

func (cl *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*ethTypes.Receipt, error)

type Config added in v1.1.0

type Config struct {
	provider.CommonConfig `json:",inline" yaml:",inline"`
	WebsocketUrl          string `json:"websocket-url" yaml:"websocket-url"`
	GasMin                uint64 `json:"gas-min" yaml:"gas-min"`
	GasLimit              uint64 `json:"gas-limit" yaml:"gas-limit"`
	GasAdjustment         uint64 `json:"gas-adjustment" yaml:"gas-adjustment"`
	BlockBatchSize        uint64 `json:"block-batch-size" yaml:"block-batch-size"`
}

func (*Config) Enabled added in v1.2.4

func (c *Config) Enabled() bool

Enabled returns true if the chain is enabled

func (*Config) GetMonitorEventFilters added in v1.1.0

func (p *Config) GetMonitorEventFilters() ethereum.FilterQuery

func (*Config) GetWallet added in v1.1.0

func (p *Config) GetWallet() string

func (*Config) NewProvider added in v1.1.0

func (p *Config) NewProvider(ctx context.Context, log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error)

func (*Config) SetWallet added in v1.1.0

func (p *Config) SetWallet(addr string)

func (*Config) Validate added in v1.1.0

func (p *Config) Validate() error

type IClient

type IClient interface {
	Log() *zap.Logger
	GetBalance(ctx context.Context, hexAddr string) (*big.Int, error)
	GetBlockNumber() (uint64, error)
	GetBlockByHash(hash common.Hash) (*types.Block, error)
	GetHeaderByHeight(ctx context.Context, height *big.Int) (*ethTypes.Header, error)
	GetLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethTypes.Log, error)
	GetChainID() *big.Int

	// ethClient
	FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethTypes.Log, error)
	SuggestGasPrice(ctx context.Context) (*big.Int, error)
	SuggestGasTip(ctx context.Context) (*big.Int, error)
	PendingNonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	TransactionByHash(ctx context.Context, blockHash common.Hash) (tx *ethTypes.Transaction, isPending bool, err error)
	CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*ethTypes.Receipt, error)
	EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
	SendTransaction(ctx context.Context, tx *ethTypes.Transaction) error
	Subscribe(ctx context.Context, q ethereum.FilterQuery, ch chan ethTypes.Log) (ethereum.Subscription, error)

	// abiContract for connection
	ParseConnectionMessage(log ethTypes.Log) (*bridgeContract.ConnectionMessage, error)
	SendMessage(opts *bind.TransactOpts, _to string, _svc string, _sn *big.Int, _msg []byte) (*ethTypes.Transaction, error)
	ReceiveMessage(opts *bind.TransactOpts, srcNID string, sn *big.Int, msg []byte) (*ethTypes.Transaction, error)
	MessageReceived(opts *bind.CallOpts, srcNetwork string, _connSn *big.Int) (bool, error)
	SetAdmin(opts *bind.TransactOpts, newAdmin common.Address) (*ethTypes.Transaction, error)
	RevertMessage(opts *bind.TransactOpts, sn *big.Int) (*ethTypes.Transaction, error)
	GetFee(opts *bind.CallOpts, networkID string) (*big.Int, error)
	SetFee(opts *bind.TransactOpts, src string, msg, res *big.Int) (*ethTypes.Transaction, error)
	ClaimFee(opts *bind.TransactOpts) (*ethTypes.Transaction, error)

	// abiContract for xcall
	ParseXcallMessage(log ethTypes.Log) (*bridgeContract.XcallCallMessage, error)
	ExecuteCall(opts *bind.TransactOpts, reqID *big.Int, data []byte) (*ethTypes.Transaction, error)
	ExecuteRollback(opts *bind.TransactOpts, sn *big.Int) (*ethTypes.Transaction, error)
}

type Provider added in v1.1.0

type Provider struct {
	StartHeight uint64

	NonceTracker        types.NonceTrackerI
	LastSavedHeightFunc func() uint64
	// contains filtered or unexported fields
}

func (*Provider) ClaimFee added in v1.1.0

func (p *Provider) ClaimFee(ctx context.Context) error

ClaimFees

func (*Provider) Config added in v1.1.0

func (p *Provider) Config() provider.Config

func (*Provider) EstimateGas added in v1.1.0

func (p *Provider) EstimateGas(ctx context.Context, message *providerTypes.Message) (uint64, error)

EstimateGas

func (*Provider) ExecuteRollback added in v1.1.0

func (p *Provider) ExecuteRollback(ctx context.Context, sn *big.Int) error

ExecuteRollback

func (*Provider) FinalityBlock added in v1.1.0

func (p *Provider) FinalityBlock(ctx context.Context) uint64

func (*Provider) FindMessages added in v1.1.0

func (p *Provider) FindMessages(ctx context.Context, lbn *types.BlockNotification) ([]*relayertypes.Message, error)

func (*Provider) GenerateMessages added in v1.1.0

func (p *Provider) GenerateMessages(ctx context.Context, key *types.MessageKeyWithMessageHeight) ([]*types.Message, error)

TODO: may not be need anytime soon so its ok to implement later on

func (*Provider) GetAddressByEventType added in v1.1.0

func (p *Provider) GetAddressByEventType(eventType string) *common.Address

func (*Provider) GetConcurrency added in v1.1.0

func (p *Provider) GetConcurrency(ctx context.Context, startHeight, currentHeight uint64) int

func (*Provider) GetEventName added in v1.1.0

func (p *Provider) GetEventName(sig string) string

func (*Provider) GetFee added in v1.1.0

func (p *Provider) GetFee(ctx context.Context, networkID string, responseFee bool) (uint64, error)

GetFee

func (*Provider) GetLastSavedBlockHeight added in v1.2.6

func (p *Provider) GetLastSavedBlockHeight() uint64

GetLastSavedBlockHeight returns the last saved block height

func (*Provider) GetTransationOpts added in v1.1.0

func (p *Provider) GetTransationOpts(ctx context.Context) (*bind.TransactOpts, error)

func (*Provider) ImportKeystore added in v1.1.0

func (p *Provider) ImportKeystore(ctx context.Context, keyPath, passphrase string) (string, error)

ImportKeystore imports a keystore from a file

func (*Provider) Init added in v1.1.0

func (p *Provider) Init(ctx context.Context, homePath string, kms kms.KMS) error

func (*Provider) Listener added in v1.1.0

func (p *Provider) Listener(ctx context.Context, lastSavedHeight uint64, blockInfoChan chan *relayertypes.BlockInfo) error

func (*Provider) LogFailedTx added in v1.1.0

func (p *Provider) LogFailedTx(messageKey *providerTypes.MessageKey, result *types.Receipt, err error)

func (*Provider) LogSuccessTx added in v1.1.0

func (p *Provider) LogSuccessTx(message *providerTypes.MessageKey, receipt *types.Receipt)

func (*Provider) MessageReceived added in v1.1.0

func (p *Provider) MessageReceived(ctx context.Context, messageKey *types.MessageKey) (bool, error)

func (*Provider) NID added in v1.1.0

func (p *Provider) NID() string

func (*Provider) Name added in v1.1.0

func (p *Provider) Name() string

func (*Provider) NewKeystore added in v1.1.0

func (p *Provider) NewKeystore(password string) (string, error)

func (*Provider) QueryBalance added in v1.1.0

func (p *Provider) QueryBalance(ctx context.Context, addr string) (*types.Coin, error)

func (*Provider) QueryLatestHeight added in v1.1.0

func (p *Provider) QueryLatestHeight(ctx context.Context) (uint64, error)

func (*Provider) QueryTransactionReceipt added in v1.1.0

func (p *Provider) QueryTransactionReceipt(ctx context.Context, txHash string) (*types.Receipt, error)

func (*Provider) RestoreKeystore added in v1.1.0

func (p *Provider) RestoreKeystore(ctx context.Context) error

func (*Provider) RevertMessage added in v1.1.0

func (p *Provider) RevertMessage(ctx context.Context, sn *big.Int) error

RevertMessage

func (*Provider) Route added in v1.1.0

func (p *Provider) Route(ctx context.Context, message *providerTypes.Message, callback providerTypes.TxResponseFunc) error

this will be executed in go route

func (*Provider) SendTransaction added in v1.1.0

func (p *Provider) SendTransaction(ctx context.Context, opts *bind.TransactOpts, message *providerTypes.Message) (*types.Transaction, error)

func (*Provider) SetAdmin added in v1.1.0

func (p *Provider) SetAdmin(ctx context.Context, admin string) error

SetAdmin sets the admin address of the bridge contract

func (*Provider) SetFee added in v1.1.0

func (p *Provider) SetFee(ctx context.Context, networkID string, msgFee, resFee *big.Int) error

SetFee

func (*Provider) SetLastSavedHeightFunc added in v1.2.6

func (p *Provider) SetLastSavedHeightFunc(f func() uint64)

SetLastSavedBlockHeightFunc sets the function to save the last saved block height

func (*Provider) ShouldReceiveMessage added in v1.1.0

func (p *Provider) ShouldReceiveMessage(ctx context.Context, messagekey *types.Message) (bool, error)

func (*Provider) ShouldSendMessage added in v1.1.0

func (p *Provider) ShouldSendMessage(ctx context.Context, messageKey *types.Message) (bool, error)

func (*Provider) Subscribe added in v1.1.2

func (p *Provider) Subscribe(ctx context.Context, blockInfoChan chan *relayertypes.BlockInfo, resetFunc func()) error

Subscribe listens to new blocks and sends them to the channel

func (*Provider) Type added in v1.1.0

func (p *Provider) Type() string

func (*Provider) WaitForResults added in v1.1.0

func (p *Provider) WaitForResults(ctx context.Context, tx *ethTypes.Transaction) (*coreTypes.Receipt, error)

func (*Provider) WaitForTxResult added in v1.1.0

func (*Provider) Wallet added in v1.1.0

func (p *Provider) Wallet() (*keystore.Key, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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