voter

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: LGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Sleep = time.Sleep
)

Functions

func ERC20MessageHandler

func ERC20MessageHandler(m *message.Message, handlerAddr, bridgeAddress common.Address) (*proposal.Proposal, error)

func ERC721MessageHandler

func ERC721MessageHandler(msg *message.Message, handlerAddr, bridgeAddress common.Address) (*proposal.Proposal, error)

func GenericMessageHandler

func GenericMessageHandler(msg *message.Message, handlerAddr, bridgeAddress common.Address) (*proposal.Proposal, error)

Types

type BridgeContract

type BridgeContract interface {
	IsProposalVotedBy(by common.Address, p *proposal.Proposal) (bool, error)
	VoteProposal(proposal *proposal.Proposal, opts transactor.TransactOptions) (*common.Hash, error)
	VoteProposals(domainID uint8, depositNonce uint64, resourceID [32]byte, data []byte, signatures [][]byte, opts transactor.TransactOptions) (*common.Hash, error)
	SimulateVoteProposal(proposal *proposal.Proposal) error
	ProposalStatus(p *proposal.Proposal) (message.ProposalStatus, error)
	GetProposal(source uint8, depositNonce uint64, resourceId types.ResourceID, data []byte) (message.ProposalStatus, error)
	GetThreshold() (uint8, error)
	ContractAddress() *common.Address
}

type ChainClient

type ChainClient interface {
	RelayerAddress() common.Address
	CallContract(ctx context.Context, callArgs map[string]interface{}, blockNumber *big.Int) ([]byte, error)
	SubscribePendingTransactions(ctx context.Context, ch chan<- common.Hash) (*rpc.ClientSubscription, error)
	TransactionByHash(ctx context.Context, hash common.Hash) (tx *ethereumTypes.Transaction, isPending bool, err error)
	SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethereumTypes.Log) (ethereum.Subscription, error)
	LatestBlock() (*big.Int, error)
	ChainID(ctx context.Context) (*big.Int, error)
	PrivateKey() *ecdsa.PrivateKey

	calls.ContractCallerDispatcher
}

type EVMMessageHandler

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

func NewEVMMessageHandler

func NewEVMMessageHandler(bridgeContract bridge.BridgeContract) *EVMMessageHandler

NewEVMMessageHandler creates an instance of EVMMessageHandler that contains message handler functions for converting deposit message into a chain specific proposal

func (*EVMMessageHandler) HandleMessage

func (mh *EVMMessageHandler) HandleMessage(m *message.Message) (*proposal.Proposal, error)

func (*EVMMessageHandler) MatchAddressWithHandlerFunc

func (mh *EVMMessageHandler) MatchAddressWithHandlerFunc(addr common.Address) (MessageHandlerFunc, error)

func (*EVMMessageHandler) RegisterMessageHandler

func (mh *EVMMessageHandler) RegisterMessageHandler(address string, handler MessageHandlerFunc)

RegisterEventHandler registers an message handler by associating a handler function to a specified address

type EVMVoter

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

func NewVoter

func NewVoter(config chain.EVMConfig, mh MessageHandler, client ChainClient, bridgeContract BridgeContract, signatureContract SignatureContract, airDropErc20Contract erc20.ERC20Contract, id uint8, t transactor.Transactor) *EVMVoter

NewVoter creates an instance of EVMVoter that votes for proposal on chain.

It is created without pending proposal subscription and is a fallback for nodes that don't support pending transaction subscription and will vote on proposals that already satisfy threshold.

func NewVoterWithSubscription

func NewVoterWithSubscription(config chain.EVMConfig, mh MessageHandler, client ChainClient, bridgeContract BridgeContract, signatureContract SignatureContract, airDropErc20Contract erc20.ERC20Contract, id uint8, relayId uint8, t transactor.Transactor) (*EVMVoter, error)

NewVoterWithSubscription creates an instance of EVMVoter that votes for proposals on chain.

It is created with a pending proposal subscription that listens to pending voteProposal transactions and avoids wasting gas on sending votes for transactions that will fail. Currently, officially supported only by Geth nodes.

func (*EVMVoter) BridgeContractAddress

func (v *EVMVoter) BridgeContractAddress() *common.Address

func (*EVMVoter) ChainID

func (v *EVMVoter) ChainID() (*big.Int, error)

func (*EVMVoter) CheckAndExecuteAirDrop

func (w *EVMVoter) CheckAndExecuteAirDrop(m message.Message)

func (*EVMVoter) CheckAndExecuteAirDropErc20

func (w *EVMVoter) CheckAndExecuteAirDropErc20(m message.Message)

func (*EVMVoter) CheckAndExecuteAirDropNative

func (w *EVMVoter) CheckAndExecuteAirDropNative(m message.Message)

func (*EVMVoter) GetSignatures

func (v *EVMVoter) GetSignatures(m *message.Message) ([][]byte, error)

func (*EVMVoter) ProposalStatusShouldVoteProposals

func (v *EVMVoter) ProposalStatusShouldVoteProposals(m *message.Message) (bool, uint8, error)

func (*EVMVoter) SubmitSignature

func (v *EVMVoter) SubmitSignature(m *message.Message, destChainId *big.Int, destBridgeAddress *common.Address) error

func (*EVMVoter) VoteProposal

func (v *EVMVoter) VoteProposal(m *message.Message) error

VoteProposal checks if relayer already voted and is threshold satisfied and casts a vote if it isn't.

func (*EVMVoter) VoteProposals

func (v *EVMVoter) VoteProposals(m *message.Message, signatures [][]byte, flag *big.Int) error

type MessageHandler

type MessageHandler interface {
	HandleMessage(m *message.Message) (*proposal.Proposal, error)
}

type MessageHandlerFunc

type MessageHandlerFunc func(m *message.Message, handlerAddr, bridgeAddress common.Address) (*proposal.Proposal, error)

type SignatureContract

type SignatureContract interface {
	ContractAddress() *common.Address
	SubmitSignature(originDomainID uint8, destinationDomainID uint8, depositNonce uint64, resourceID [32]byte, data []byte, signature []byte, opts transactor.TransactOptions) (*common.Hash, error)

	GetThreshold(domain uint8) (uint8, error)
	GetSignatures(domainID uint8, destinationDomainID uint8, depositNonce uint64, resourceID [32]byte, data []byte) ([][]byte, error)
}

Directories

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

Jump to

Keyboard shortcuts

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