signer

package
v0.0.0-...-2da98db Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package signer implements the ChainSigner interface for EVM chains

Index

Constants

View Source
const (
	MinGasLimit = 100_000
	MaxGasLimit = 1_000_000
)

Variables

This section is empty.

Functions

func ErrorMsg

func ErrorMsg(cctx *types.CrossChainTx) string

ErrorMsg returns a error message for SignOutbound failure with cctx data

func IsSenderZetaChain

func IsSenderZetaChain(
	cctx *types.CrossChainTx,
	zetacoreClient interfaces.ZetacoreClient,
	flags *observertypes.CrosschainFlags,
) bool

IsSenderZetaChain checks if the sender chain is ZetaChain TODO(revamp): move to another package more general for cctx functions

Types

type OutboundData

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

OutboundData is a data structure containing input fields used to construct each type of transaction. This is populated using cctx and other input parameters passed to TryProcessOutbound

func NewOutboundData

func NewOutboundData(
	ctx context.Context,
	cctx *types.CrossChainTx,
	evmObserver *observer.Observer,
	evmRPC interfaces.EVMRPCClient,
	logger zerolog.Logger,
	height uint64,
) (*OutboundData, bool, error)

NewOutboundData populates transaction input fields parsed from the cctx and other parameters returns

  1. New NewOutboundData Data struct or nil if an error occurred.
  2. bool (skipTx) - if the transaction doesn't qualify to be processed the function will return true, meaning that this cctx will be skipped and false otherwise.
  3. error

func (*OutboundData) SetChainAndSender

func (txData *OutboundData) SetChainAndSender(cctx *types.CrossChainTx, logger zerolog.Logger) bool

SetChainAndSender populates the destination address and Chain ID based on the status of the cross chain tx returns true if transaction should be skipped returns false otherwise

func (*OutboundData) SetupGas

func (txData *OutboundData) SetupGas(
	cctx *types.CrossChainTx,
	logger zerolog.Logger,
	client interfaces.EVMRPCClient,
	chain chains.Chain,
) error

SetupGas sets the gas limit and price

type Signer

type Signer struct {
	*base.Signer
	// contains filtered or unexported fields
}

Signer deals with the signing EVM transactions and implements the ChainSigner interface

func NewSigner

func NewSigner(
	ctx context.Context,
	chain chains.Chain,
	tss interfaces.TSSSigner,
	ts *metrics.TelemetryServer,
	logger base.Logger,
	endpoint string,
	zetaConnectorABI string,
	erc20CustodyABI string,
	zetaConnectorAddress ethcommon.Address,
	erc20CustodyAddress ethcommon.Address,
) (*Signer, error)

NewSigner creates a new EVM signer

func (*Signer) Broadcast

func (signer *Signer) Broadcast(tx *ethtypes.Transaction) error

Broadcast takes in signed tx, broadcast to external chain node

func (*Signer) BroadcastOutbound

func (signer *Signer) BroadcastOutbound(
	ctx context.Context,
	tx *ethtypes.Transaction,
	cctx *types.CrossChainTx,
	logger zerolog.Logger,
	myID sdk.AccAddress,
	zetacoreClient interfaces.ZetacoreClient,
	txData *OutboundData,
)

BroadcastOutbound signed transaction through evm rpc client

func (*Signer) EvmClient

func (signer *Signer) EvmClient() interfaces.EVMRPCClient

EvmClient returns the EVM RPC client

func (*Signer) EvmSigner

func (signer *Signer) EvmSigner() ethtypes.Signer

EvmSigner returns the EVM signer object for the signer

func (*Signer) GetERC20CustodyAddress

func (signer *Signer) GetERC20CustodyAddress() ethcommon.Address

GetERC20CustodyAddress returns the erc20 custody address

func (*Signer) GetReportedTxList

func (signer *Signer) GetReportedTxList() *map[string]bool

GetReportedTxList returns a list of outboundHash being reported TODO: investigate pointer usage https://github.com/zeta-chain/node/issues/2084

func (*Signer) GetZetaConnectorAddress

func (signer *Signer) GetZetaConnectorAddress() ethcommon.Address

GetZetaConnectorAddress returns the zeta connector address

func (*Signer) SetERC20CustodyAddress

func (signer *Signer) SetERC20CustodyAddress(addr ethcommon.Address)

SetERC20CustodyAddress sets the erc20 custody address

func (*Signer) SetZetaConnectorAddress

func (signer *Signer) SetZetaConnectorAddress(addr ethcommon.Address)

SetZetaConnectorAddress sets the zeta connector address

func (*Signer) Sign

func (signer *Signer) Sign(
	ctx context.Context,
	data []byte,
	to ethcommon.Address,
	amount *big.Int,
	gasLimit uint64,
	gasPrice *big.Int,
	nonce uint64,
	height uint64,
) (*ethtypes.Transaction, []byte, []byte, error)

Sign given data, and metadata (gas, nonce, etc) returns a signed transaction, sig bytes, hash bytes, and error

func (*Signer) SignCancelTx

func (signer *Signer) SignCancelTx(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)

SignCancelTx signs a transaction from TSS address to itself with a zero amount in order to increment the nonce

func (*Signer) SignCommandTx

func (signer *Signer) SignCommandTx(
	ctx context.Context,
	txData *OutboundData,
	cmd string,
	params string,
) (*ethtypes.Transaction, error)

SignCommandTx signs a transaction based on the given command includes:

cmd_whitelist_erc20
cmd_migrate_tss_funds

func (*Signer) SignERC20WithdrawTx

func (signer *Signer) SignERC20WithdrawTx(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)

SignERC20WithdrawTx function withdraw( address recipient, address asset, uint256 amount, ) external onlyTssAddress

func (*Signer) SignMigrateTssFundsCmd

func (signer *Signer) SignMigrateTssFundsCmd(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)

SignMigrateTssFundsCmd signs a migrate TSS funds command TODO(revamp): move the cmd in a specific file

func (*Signer) SignOutbound

func (signer *Signer) SignOutbound(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)

SignOutbound function onReceive(

bytes calldata originSenderAddress,
uint256 originChainId,
address destinationAddress,
uint zetaAmount,
bytes calldata message,
bytes32 internalSendHash

) external virtual {}

func (*Signer) SignRevertTx

func (signer *Signer) SignRevertTx(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)

SignRevertTx function onRevert( address originSenderAddress, uint256 originChainId, bytes calldata destinationAddress, uint256 destinationChainId, uint256 zetaAmount, bytes calldata message, bytes32 internalSendHash ) external override whenNotPaused onlyTssAddress

func (*Signer) SignWhitelistERC20Cmd

func (signer *Signer) SignWhitelistERC20Cmd(
	ctx context.Context,
	txData *OutboundData,
	params string,
) (*ethtypes.Transaction, error)

SignWhitelistERC20Cmd signs a whitelist command for ERC20 token TODO(revamp): move the cmd in a specific file

func (*Signer) SignWithdrawTx

func (signer *Signer) SignWithdrawTx(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)

SignWithdrawTx signs a withdrawal transaction sent from the TSS address to the destination

func (*Signer) TryProcessOutbound

func (signer *Signer) TryProcessOutbound(
	ctx context.Context,
	cctx *types.CrossChainTx,
	outboundProc *outboundprocessor.Processor,
	outboundID string,
	chainObserver interfaces.ChainObserver,
	zetacoreClient interfaces.ZetacoreClient,
	height uint64,
)

TryProcessOutbound - signer interface implementation This function will attempt to build and sign an evm transaction using the TSS signer. It will then broadcast the signed transaction to the outbound chain. TODO(revamp): simplify function

Jump to

Keyboard shortcuts

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