peggy

package
v0.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ValsetCheckpointABIJSON checks the ETH ABI for compatibility of the Valset update message
	ValsetCheckpointABIJSON = `` /* 747-byte string literal not displayed */

	OutgoingBatchTxConfirmABIJSON = `` /* 863-byte string literal not displayed */

)

Variables

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

Functions

func EncodeTxBatchConfirm

func EncodeTxBatchConfirm(peggyID common.Hash, batch *types.OutgoingTxBatch) common.Hash

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

func EncodeValsetConfirm

func EncodeValsetConfirm(peggyID common.Hash, valset *types.Valset) common.Hash

EncodeValsetConfirm takes the required input data and produces the required signature to confirm a validator set update on the Peggy 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 Peggy contract address
	Address() common.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 common.Address,
		callerAddress common.Address,
	) (*big.Int, error)

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

	GetPeggyID(
		ctx context.Context,
		callerAddress common.Address,
	) (common.Hash, error)

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

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

	// SubscribeToPendingTxs starts a websocket connection to Alchemy's service that listens for new pending txs made
	// to the Peggy 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 NewPeggyContract

func NewPeggyContract(
	logger zerolog.Logger,
	ethCommitter committer.EVMCommitter,
	peggyAddress common.Address,
	ethPeggy *wrappers.Peggy,
) (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 Peggy 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
}

type ValsetArgs

type ValsetArgs struct {
	Validators   []common.Address `protobuf:"bytes,2,rep,name=validators,proto3" json:"validators,omitempty"`
	Powers       []*big.Int       `protobuf:"varint,1,opt,name=powers,proto3" json:"powers,omitempty"`
	ValsetNonce  *big.Int         `protobuf:"varint,3,opt,name=valsetNonce,proto3" json:"valsetNonce,omitempty"`
	RewardAmount *big.Int         `protobuf:"bytes,4,opt,name=rewardAmount,json=rewardAmount,proto3" json:"rewardAmount"`
	// the reward token in it's Ethereum hex address representation
	// nolint: lll
	RewardToken common.Address `protobuf:"bytes,5,opt,name=rewardToken,json=rewardToken,proto3" json:"rewardToken,omitempty"`
}

Jump to

Keyboard shortcuts

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