Documentation ¶
Overview ¶
Package observer implements the EVM chain observer
Index ¶
- func FetchConnectorContractEth(addr ethcommon.Address, client interfaces.EVMRPCClient) (*zetaconnectoreth.ZetaConnectorEth, error)
- func FetchZetaTokenContract(addr ethcommon.Address, client interfaces.EVMRPCClient) (*zeta.ZetaNonEth, error)
- func ParseAndCheckWithdrawnEvent(cctx *crosschaintypes.CrossChainTx, receipt *ethtypes.Receipt, ...) (*erc20custody.ERC20CustodyWithdrawn, error)
- func ParseAndCheckZetaEvent(cctx *crosschaintypes.CrossChainTx, receipt *ethtypes.Receipt, ...) (*zetaconnector.ZetaConnectorNonEthZetaReceived, ...)
- type Observer
- func (ob *Observer) BlockByNumber(blockNumber int) (*ethrpc.Block, error)
- func (ob *Observer) BuildInboundVoteMsgForDepositedEvent(event *erc20custody.ERC20CustodyDeposited, sender ethcommon.Address) *types.MsgVoteInbound
- func (ob *Observer) BuildInboundVoteMsgForTokenSentToTSS(tx *ethrpc.Transaction, sender ethcommon.Address, blockNumber uint64) *types.MsgVoteInbound
- func (ob *Observer) BuildInboundVoteMsgForZetaSentEvent(appContext *zctx.AppContext, event *zetaconnector.ZetaConnectorNonEthZetaSent) *types.MsgVoteInbound
- func (ob *Observer) CheckAndVoteInboundTokenERC20(ctx context.Context, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, ...) (string, error)
- func (ob *Observer) CheckAndVoteInboundTokenGas(ctx context.Context, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, ...) (string, error)
- func (ob *Observer) CheckAndVoteInboundTokenZeta(ctx context.Context, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, ...) (string, error)
- func (ob *Observer) CheckTxInclusion(tx *ethtypes.Transaction, receipt *ethtypes.Receipt) error
- func (ob *Observer) FilterTSSOutbound(ctx context.Context, startBlock, toBlock uint64)
- func (ob *Observer) FilterTSSOutboundInBlock(ctx context.Context, blockNumber uint64)
- func (ob *Observer) GetBlockByNumberCached(blockNumber uint64) (*ethrpc.Block, error)
- func (ob *Observer) GetBlockHeaderCached(ctx context.Context, blockNumber uint64) (*ethtypes.Header, error)
- func (ob *Observer) GetChainParams() observertypes.ChainParams
- func (ob *Observer) GetConnectorContract() (ethcommon.Address, *zetaconnector.ZetaConnectorNonEth, error)
- func (ob *Observer) GetConnectorContractEth() (ethcommon.Address, *zetaconnectoreth.ZetaConnectorEth, error)
- func (ob *Observer) GetERC20CustodyContract() (ethcommon.Address, *erc20custody.ERC20Custody, error)
- func (ob *Observer) GetERC20CustodyV2Contract() (ethcommon.Address, *erc20custodyv2.ERC20Custody, error)
- func (ob *Observer) GetGatewayContract() (ethcommon.Address, *gatewayevm.GatewayEVM, error)
- func (ob *Observer) GetTxNReceipt(nonce uint64) (*ethtypes.Receipt, *ethtypes.Transaction)
- func (ob *Observer) HasEnoughConfirmations(receipt *ethtypes.Receipt, lastHeight uint64) bool
- func (ob *Observer) IsTxConfirmed(nonce uint64) bool
- func (ob *Observer) LoadLastBlockScanned(ctx context.Context) error
- func (ob *Observer) ObserveERC20Deposited(ctx context.Context, startBlock, toBlock uint64) uint64
- func (ob *Observer) ObserveGatewayCall(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
- func (ob *Observer) ObserveGatewayDeposit(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
- func (ob *Observer) ObserveInbound(ctx context.Context, sampledLogger zerolog.Logger) error
- func (ob *Observer) ObserveTSSReceiveInBlock(ctx context.Context, blockNumber uint64) error
- func (ob *Observer) ObserveZetaSent(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
- func (ob *Observer) ObserverTSSReceive(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
- func (ob *Observer) PostGasPrice(ctx context.Context) error
- func (ob *Observer) PostVoteOutbound(ctx context.Context, cctxIndex string, receipt *ethtypes.Receipt, ...)
- func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error
- func (ob *Observer) ProcessOutboundTrackers(ctx context.Context) error
- func (ob *Observer) RemoveCachedBlock(blockNumber uint64)
- func (ob *Observer) SetChainParams(params observertypes.ChainParams)
- func (ob *Observer) SetTxNReceipt(nonce uint64, receipt *ethtypes.Receipt, transaction *ethtypes.Transaction)
- func (ob *Observer) Start(ctx context.Context)
- func (ob *Observer) TransactionByHash(txHash string) (*ethrpc.Transaction, bool, error)
- func (ob *Observer) VoteOutboundIfConfirmed(ctx context.Context, cctx *crosschaintypes.CrossChainTx) (bool, error)
- func (ob *Observer) WatchGasPrice(ctx context.Context) error
- func (ob *Observer) WatchInbound(ctx context.Context) error
- func (ob *Observer) WatchInboundTracker(ctx context.Context) error
- func (ob *Observer) WatchOutbound(ctx context.Context) error
- func (ob *Observer) WatchRPCStatus(ctx context.Context) error
- func (ob *Observer) WithEvmClient(client interfaces.EVMRPCClient)
- func (ob *Observer) WithEvmJSONRPC(client interfaces.EVMJSONRPCClient)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FetchConnectorContractEth ¶
func FetchConnectorContractEth( addr ethcommon.Address, client interfaces.EVMRPCClient, ) (*zetaconnectoreth.ZetaConnectorEth, error)
FetchConnectorContractEth returns the Eth connector address and binder TODO(revamp): move this to a contract package
func FetchZetaTokenContract ¶
func FetchZetaTokenContract( addr ethcommon.Address, client interfaces.EVMRPCClient, ) (*zeta.ZetaNonEth, error)
FetchZetaTokenContract returns the non-Eth ZETA token binder TODO(revamp): move this to a contract package
func ParseAndCheckWithdrawnEvent ¶
func ParseAndCheckWithdrawnEvent( cctx *crosschaintypes.CrossChainTx, receipt *ethtypes.Receipt, custodyAddr ethcommon.Address, custody *erc20custody.ERC20Custody, ) (*erc20custody.ERC20CustodyWithdrawn, error)
ParseAndCheckWithdrawnEvent parses and checks erc20 Withdrawn event from the outbound receipt
func ParseAndCheckZetaEvent ¶
func ParseAndCheckZetaEvent( cctx *crosschaintypes.CrossChainTx, receipt *ethtypes.Receipt, connectorAddr ethcommon.Address, connector *zetaconnector.ZetaConnectorNonEth, ) (*zetaconnector.ZetaConnectorNonEthZetaReceived, *zetaconnector.ZetaConnectorNonEthZetaReverted, error)
ParseAndCheckZetaEvent parses and checks ZetaReceived/ZetaReverted event from the outbound receipt It either returns an ZetaReceived or an ZetaReverted event, or an error if no event found
Types ¶
type Observer ¶
type Observer struct { // base.Observer implements the base chain observer base.Observer // contains filtered or unexported fields }
Observer is the observer for evm chains
func NewObserver ¶
func NewObserver( ctx context.Context, chain chains.Chain, evmClient interfaces.EVMRPCClient, evmJSONRPC interfaces.EVMJSONRPCClient, chainParams observertypes.ChainParams, zetacoreClient interfaces.ZetacoreClient, tss interfaces.TSSSigner, database *db.DB, logger base.Logger, ts *metrics.TelemetryServer, ) (*Observer, error)
NewObserver returns a new EVM chain observer
func (*Observer) BlockByNumber ¶
BlockByNumber query block by number via JSON-RPC
func (*Observer) BuildInboundVoteMsgForDepositedEvent ¶
func (ob *Observer) BuildInboundVoteMsgForDepositedEvent( event *erc20custody.ERC20CustodyDeposited, sender ethcommon.Address, ) *types.MsgVoteInbound
BuildInboundVoteMsgForDepositedEvent builds a inbound vote message for a Deposited event
func (*Observer) BuildInboundVoteMsgForTokenSentToTSS ¶
func (ob *Observer) BuildInboundVoteMsgForTokenSentToTSS( tx *ethrpc.Transaction, sender ethcommon.Address, blockNumber uint64, ) *types.MsgVoteInbound
BuildInboundVoteMsgForTokenSentToTSS builds a inbound vote message for a token sent to TSS
func (*Observer) BuildInboundVoteMsgForZetaSentEvent ¶
func (ob *Observer) BuildInboundVoteMsgForZetaSentEvent( appContext *zctx.AppContext, event *zetaconnector.ZetaConnectorNonEthZetaSent, ) *types.MsgVoteInbound
BuildInboundVoteMsgForZetaSentEvent builds a inbound vote message for a ZetaSent event
func (*Observer) CheckAndVoteInboundTokenERC20 ¶
func (ob *Observer) CheckAndVoteInboundTokenERC20( ctx context.Context, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, vote bool, ) (string, error)
CheckAndVoteInboundTokenERC20 checks and votes on the given inbound ERC20 token
func (*Observer) CheckAndVoteInboundTokenGas ¶
func (ob *Observer) CheckAndVoteInboundTokenGas( ctx context.Context, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, vote bool, ) (string, error)
CheckAndVoteInboundTokenGas checks and votes on the given inbound gas token
func (*Observer) CheckAndVoteInboundTokenZeta ¶
func (ob *Observer) CheckAndVoteInboundTokenZeta( ctx context.Context, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, vote bool, ) (string, error)
CheckAndVoteInboundTokenZeta checks and votes on the given inbound Zeta token
func (*Observer) CheckTxInclusion ¶
CheckTxInclusion returns nil only if tx is included at the position indicated by the receipt ([block, index])
func (*Observer) FilterTSSOutbound ¶
FilterTSSOutbound filters the outbounds from TSS address to supplement outbound trackers
func (*Observer) FilterTSSOutboundInBlock ¶
FilterTSSOutboundInBlock filters the outbounds in a single block to supplement outbound trackers
func (*Observer) GetBlockByNumberCached ¶
GetBlockByNumberCached get block by number from cache returns block, ethrpc.Block, isFallback, isSkip, error
func (*Observer) GetBlockHeaderCached ¶
func (ob *Observer) GetBlockHeaderCached(ctx context.Context, blockNumber uint64) (*ethtypes.Header, error)
GetBlockHeaderCached get block header by number from cache
func (*Observer) GetChainParams ¶
func (ob *Observer) GetChainParams() observertypes.ChainParams
GetChainParams returns the chain params for the observer Note: chain params is accessed concurrently
func (*Observer) GetConnectorContract ¶
func (ob *Observer) GetConnectorContract() (ethcommon.Address, *zetaconnector.ZetaConnectorNonEth, error)
GetConnectorContract returns the non-Eth connector address and binder
func (*Observer) GetConnectorContractEth ¶
func (ob *Observer) GetConnectorContractEth() (ethcommon.Address, *zetaconnectoreth.ZetaConnectorEth, error)
GetConnectorContractEth returns the Eth connector address and binder
func (*Observer) GetERC20CustodyContract ¶
func (ob *Observer) GetERC20CustodyContract() (ethcommon.Address, *erc20custody.ERC20Custody, error)
GetERC20CustodyContract returns ERC20Custody contract address and binder
func (*Observer) GetERC20CustodyV2Contract ¶
func (ob *Observer) GetERC20CustodyV2Contract() (ethcommon.Address, *erc20custodyv2.ERC20Custody, error)
GetERC20CustodyV2Contract returns ERC20CustodyV2 contract address and binder NOTE: we use the same address as gateway v1 this simplify the migration process v1 will be completely removed in the future currently the ABI for withdraw is identical, therefore both contract instances can be used
func (*Observer) GetGatewayContract ¶
GetGatewayContract returns the gateway contract address and binder
func (*Observer) GetTxNReceipt ¶
GetTxNReceipt gets the receipt and transaction from memory
func (*Observer) HasEnoughConfirmations ¶
HasEnoughConfirmations checks if the given receipt has enough confirmations
func (*Observer) IsTxConfirmed ¶
IsTxConfirmed returns true if there is a confirmed tx for 'nonce'
func (*Observer) LoadLastBlockScanned ¶
LoadLastBlockScanned loads the last scanned block from the database TODO(revamp): move to a db file
func (*Observer) ObserveERC20Deposited ¶
ObserveERC20Deposited queries the ERC20CustodyDeposited event from the ERC20Custody contract and posts to zetacore returns the last block successfully scanned
func (*Observer) ObserveGatewayCall ¶
func (ob *Observer) ObserveGatewayCall(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
ObserveGatewayCall queries the gateway contract for call events returns the last block successfully scanned TODO: there are lot of similarities between this function and ObserveGatewayDeposit logic should be factorized using interfaces and generics https://github.com/zeta-chain/node/issues/2493
func (*Observer) ObserveGatewayDeposit ¶
func (ob *Observer) ObserveGatewayDeposit(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
ObserveGatewayDeposit queries the gateway contract for deposit events returns the last block successfully scanned
func (*Observer) ObserveInbound ¶
ObserveInbound observes the evm chain for inbounds and posts votes to zetacore
func (*Observer) ObserveTSSReceiveInBlock ¶
ObserveTSSReceiveInBlock queries the incoming gas asset to TSS address in a single block and posts votes
func (*Observer) ObserveZetaSent ¶
func (ob *Observer) ObserveZetaSent(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
ObserveZetaSent queries the ZetaSent event from the connector contract and posts to zetacore returns the last block successfully scanned
func (*Observer) ObserverTSSReceive ¶
func (ob *Observer) ObserverTSSReceive(ctx context.Context, startBlock, toBlock uint64) (uint64, error)
ObserverTSSReceive queries the incoming gas asset to TSS address and posts to zetacore returns the last block successfully scanned
func (*Observer) PostGasPrice ¶
PostGasPrice posts gas price to zetacore.
func (*Observer) PostVoteOutbound ¶
func (ob *Observer) PostVoteOutbound( ctx context.Context, cctxIndex string, receipt *ethtypes.Receipt, transaction *ethtypes.Transaction, receiveValue *big.Int, receiveStatus chains.ReceiveStatus, nonce uint64, coinType coin.CoinType, logger zerolog.Logger, )
PostVoteOutbound posts vote to zetacore for the confirmed outbound
func (*Observer) ProcessInboundTrackers ¶
ProcessInboundTrackers processes inbound trackers from zetacore TODO(revamp): move inbound tracker function to a separate file
func (*Observer) ProcessOutboundTrackers ¶
ProcessOutboundTrackers processes outbound trackers
func (*Observer) RemoveCachedBlock ¶
RemoveCachedBlock remove block from cache
func (*Observer) SetChainParams ¶
func (ob *Observer) SetChainParams(params observertypes.ChainParams)
SetChainParams sets the chain params for the observer Note: chain params is accessed concurrently
func (*Observer) SetTxNReceipt ¶
func (ob *Observer) SetTxNReceipt(nonce uint64, receipt *ethtypes.Receipt, transaction *ethtypes.Transaction)
SetTxNReceipt sets the receipt and transaction in memory
func (*Observer) TransactionByHash ¶
TransactionByHash query transaction by hash via JSON-RPC TODO(revamp): update this method as a pure RPC method that takes two parameters (jsonRPC, and txHash) and move to upper package to file rpc.go
func (*Observer) VoteOutboundIfConfirmed ¶
func (ob *Observer) VoteOutboundIfConfirmed( ctx context.Context, cctx *crosschaintypes.CrossChainTx, ) (bool, error)
VoteOutboundIfConfirmed checks outbound status and returns (continueKeysign, error)
func (*Observer) WatchGasPrice ¶
WatchGasPrice watches evm chain for gas prices and post to zetacore TODO(revamp): move inner logic to a separate function
func (*Observer) WatchInbound ¶
WatchInbound watches evm chain for incoming txs and post votes to zetacore TODO(revamp): move ticker function to a separate file
func (*Observer) WatchInboundTracker ¶
WatchInboundTracker gets a list of Inbound tracker suggestions from zeta-core at each tick and tries to check if the in-tx was confirmed. If it was, it tries to broadcast the confirmation vote. If this zeta client has previously broadcast the vote, the tx would be rejected TODO(revamp): move inbound tracker function to a separate file
func (*Observer) WatchOutbound ¶
WatchOutbound watches evm chain for outgoing txs status TODO(revamp): move ticker function to ticker file
func (*Observer) WatchRPCStatus ¶
WatchRPCStatus watches the RPC status of the evm chain TODO(revamp): move ticker to ticker file TODO(revamp): move inner logic to a separate function
func (*Observer) WithEvmClient ¶
func (ob *Observer) WithEvmClient(client interfaces.EVMRPCClient)
WithEvmClient attaches a new evm client to the observer
func (*Observer) WithEvmJSONRPC ¶
func (ob *Observer) WithEvmJSONRPC(client interfaces.EVMJSONRPCClient)
WithEvmJSONRPC attaches a new evm json rpc client to the observer