From c00f9644a73f30771a74adeaa15fd9a6ffbdef40 Mon Sep 17 00:00:00 2001 From: lumtis Date: Wed, 4 Dec 2024 15:10:21 +0100 Subject: [PATCH] comments --- x/crosschain/types/status.go | 3 +-- zetaclient/chains/evm/observer/inbound.go | 20 +++++++------------ .../chains/evm/observer/v2_inbound_tracker.go | 19 +++++++++++------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index 8f788209dc..d67ec08ac6 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -13,8 +13,7 @@ func (m *Status) AbortRefunded() { func (m *Status) UpdateStatusAndErrorMessages(newStatus CctxStatus, statusMsg, errorMsg string) { m.UpdateStatus(newStatus, statusMsg) - if errorMsg != "" && - (newStatus == CctxStatus_Aborted || newStatus == CctxStatus_Reverted || newStatus == CctxStatus_PendingRevert) { + if errorMsg != "" { m.UpdateErrorMessage(errorMsg) } } diff --git a/zetaclient/chains/evm/observer/inbound.go b/zetaclient/chains/evm/observer/inbound.go index 5f823bf612..3f59fd8f56 100644 --- a/zetaclient/chains/evm/observer/inbound.go +++ b/zetaclient/chains/evm/observer/inbound.go @@ -146,19 +146,13 @@ func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error { ob.Logger().Inbound.Info().Msgf("checking tracker for inbound %s chain %d", tracker.TxHash, ob.Chain().ChainId) // try processing the tracker for v2 inbound - gatewayAddr, gateway, err := ob.GetGatewayContract() - if err != nil { - ob.Logger().Inbound.Debug().Err(err).Msg("error getting gateway contract for processing inbound tracker") - } - if err == nil && tx != nil { - // filter error if event is not found, in this case we run v1 tracker process - if err := ob.ProcessInboundTrackerV2(ctx, gateway, gatewayAddr, tx, receipt); err != nil && - !errors.Is(err, errEventNotFound) { - return err - } else if err == nil { - // continue with next tracker - continue - } + // filter error if event is not found, in this case we run v1 tracker process + if err := ob.ProcessInboundTrackerV2(ctx, tx, receipt); err != nil && + !errors.Is(err, ErrEventNotFound) && !errors.Is(err, ErrGatewayNotSet) { + return err + } else if err == nil { + // continue with next tracker + continue } // try processing the tracker for v1 inbound diff --git a/zetaclient/chains/evm/observer/v2_inbound_tracker.go b/zetaclient/chains/evm/observer/v2_inbound_tracker.go index 3a755627c7..07adfe78cc 100644 --- a/zetaclient/chains/evm/observer/v2_inbound_tracker.go +++ b/zetaclient/chains/evm/observer/v2_inbound_tracker.go @@ -2,27 +2,32 @@ package observer import ( "context" - "errors" "fmt" - ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/onrik/ethrpc" - "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol" + "github.com/pkg/errors" "github.com/zeta-chain/node/zetaclient/zetacore" ) -var errEventNotFound = errors.New("no gateway event found in inbound tracker") +var ( + ErrEventNotFound = errors.New("event not found") + ErrGatewayNotSet = errors.New("gateway contract not set") +) // ProcessInboundTrackerV2 processes inbound tracker events from the gateway func (ob *Observer) ProcessInboundTrackerV2( ctx context.Context, - gateway *gatewayevm.GatewayEVM, - gatewayAddr ethcommon.Address, tx *ethrpc.Transaction, receipt *ethtypes.Receipt, ) error { + gatewayAddr, gateway, err := ob.GetGatewayContract() + if err != nil { + ob.Logger().Inbound.Debug().Err(err).Msg("error getting gateway contract for processing inbound tracker") + return ErrGatewayNotSet + } + // check confirmations if confirmed := ob.HasEnoughConfirmations(receipt, ob.LastBlock()); !confirmed { return fmt.Errorf( @@ -33,7 +38,7 @@ func (ob *Observer) ProcessInboundTrackerV2( } for _, log := range receipt.Logs { - if log == nil && log.Address != gatewayAddr { + if log == nil || log.Address != gatewayAddr { continue }