gravity

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsufficientVotingPowerToPass = errors.New("insufficient voting power")
)

Functions

func EncodeTxBatchConfirm

func EncodeTxBatchConfirm(gravityID string, batch types.OutgoingTxBatch) ethcmn.Hash

EncodeTxBatchConfirm takes the required input data and produces the required signature to confirm a transaction batch on the Gravity Ethereum contract. This value will then be signed before being submitted to Cosmos, verified, and then relayed to Ethereum.

func EncodeValsetConfirm

func EncodeValsetConfirm(gravityID string, valset types.Valset) ethcmn.Hash

EncodeValsetConfirm takes the required input data and produces the required signature to confirm a validator set update on the Gravity Ethereum contract. This value will then be signed before being submitted to Cosmos, verified, and then relayed to Ethereum.

Types

type Contract

type Contract interface {
	committer.EVMCommitter

	// Address returns the Gravity contract address
	Address() ethcmn.Address

	// EncodeTransactionBatch encodes a batch into a tx byte data. This is specially helpful for estimating gas and
	// detecting identical transactions in the mempool.
	EncodeTransactionBatch(
		ctx context.Context,
		currentValset types.Valset,
		batch types.OutgoingTxBatch,
		confirms []types.MsgConfirmBatch,
	) ([]byte, error)

	// EncodeValsetUpdate encodes a valset update into a tx byte data. This is specially helpful for estimating gas and
	// detecting identical transactions in the mempool.
	EncodeValsetUpdate(
		ctx context.Context,
		oldValset types.Valset,
		newValset types.Valset,
		confirms []types.MsgValsetConfirm,
	) ([]byte, error)

	GetTxBatchNonce(
		ctx context.Context,
		erc20ContractAddress ethcmn.Address,
		callerAddress ethcmn.Address,
	) (*big.Int, error)

	GetValsetNonce(
		ctx context.Context,
		callerAddress ethcmn.Address,
	) (*big.Int, error)

	GetGravityID(
		ctx context.Context,
		callerAddress ethcmn.Address,
	) (string, error)

	GetERC20Symbol(
		ctx context.Context,
		erc20ContractAddress ethcmn.Address,
		callerAddress ethcmn.Address,
	) (symbol string, err error)

	GetERC20Decimals(
		ctx context.Context,
		erc20ContractAddress ethcmn.Address,
		callerAddress ethcmn.Address,
	) (decimals uint8, err error)

	// SubscribeToPendingTxs starts a websocket connection to Alchemy's service that listens for new pending txs made
	// to the Gravity contract.
	SubscribeToPendingTxs(ctx context.Context, alchemyWebsocketURL string) error

	// IsPendingTxInput returns true if the input data is found in the pending tx list. If the tx is found but the tx is
	// older than pendingTxWaitDuration, we consider it stale and return false, so the validator re-sends it.
	IsPendingTxInput(txData []byte, pendingTxWaitDuration time.Duration) bool

	GetPendingTxInputList() *PendingTxInputList
}

func NewGravityContract

func NewGravityContract(
	logger zerolog.Logger,
	ethCommitter committer.EVMCommitter,
	gravityAddress ethcmn.Address,
	ethGravity *wrappers.Gravity,
) (Contract, error)

type PendingTxInput

type PendingTxInput struct {
	InputData    hexutil.Bytes
	ReceivedTime time.Time
}

PendingTxInput contains the data of a pending transaction and the time we first saw it.

type PendingTxInputList

type PendingTxInputList []PendingTxInput

func (*PendingTxInputList) AddPendingTxInput

func (p *PendingTxInputList) AddPendingTxInput(pendingTx *RPCTransaction)

AddPendingTxInput adds pending submitBatch and updateBatch calls to the Gravity contract to the list of pending transactions, any other transaction is ignored.

type RPCTransaction

type RPCTransaction struct {
	Input hexutil.Bytes `json:"input"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type RepackedSigs

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

Jump to

Keyboard shortcuts

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