Skip to content

Commit

Permalink
Merge branch 'release/v23' into feat/disable-eip-1559
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Dec 4, 2024
2 parents c80f61b + 0ba4f15 commit a5f6696
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
55 changes: 27 additions & 28 deletions zetaclient/chains/evm/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,35 +145,34 @@ 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)

// if the transaction is sent to the gateway, this is a 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")
// try processing the tracker for v2 inbound
// 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
}
if err == nil && tx != nil && ethcommon.HexToAddress(tx.To) == gatewayAddr {
if err := ob.ProcessInboundTrackerV2(ctx, gateway, tx, receipt); err != nil {
return err
}
} else {
// check and vote on inbound tx
switch tracker.CoinType {
case coin.CoinType_Zeta:
_, err = ob.CheckAndVoteInboundTokenZeta(ctx, tx, receipt, true)
case coin.CoinType_ERC20:
_, err = ob.CheckAndVoteInboundTokenERC20(ctx, tx, receipt, true)
case coin.CoinType_Gas:
_, err = ob.CheckAndVoteInboundTokenGas(ctx, tx, receipt, true)
default:
return fmt.Errorf(
"unknown coin type %s for inbound %s chain %d",
tracker.CoinType,
tx.Hash,
ob.Chain().ChainId,
)
}
if err != nil {
return errors.Wrapf(err, "error checking and voting for inbound %s chain %d", tx.Hash, ob.Chain().ChainId)
}

// try processing the tracker for v1 inbound
switch tracker.CoinType {
case coin.CoinType_Zeta:
_, err = ob.CheckAndVoteInboundTokenZeta(ctx, tx, receipt, true)
case coin.CoinType_ERC20:
_, err = ob.CheckAndVoteInboundTokenERC20(ctx, tx, receipt, true)
case coin.CoinType_Gas:
_, err = ob.CheckAndVoteInboundTokenGas(ctx, tx, receipt, true)
default:
return fmt.Errorf(
"unknown coin type %s for inbound %s chain %d",
tracker.CoinType,
tx.Hash,
ob.Chain().ChainId,
)
}
if err != nil {
return errors.Wrapf(err, "error checking and voting for inbound %s chain %d", tx.Hash, ob.Chain().ChainId)
}
}
return nil
Expand Down
18 changes: 14 additions & 4 deletions zetaclient/chains/evm/observer/v2_inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,28 @@ import (

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("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,
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(
Expand All @@ -28,7 +38,7 @@ func (ob *Observer) ProcessInboundTrackerV2(
}

for _, log := range receipt.Logs {
if log == nil {
if log == nil || log.Address != gatewayAddr {
continue
}

Expand Down Expand Up @@ -84,5 +94,5 @@ func (ob *Observer) ProcessInboundTrackerV2(
}
}

return fmt.Errorf("no gateway event found in inbound tracker %s", tx.Hash)
return errors.Wrapf(ErrEventNotFound, "inbound tracker %s", tx.Hash)
}

0 comments on commit a5f6696

Please sign in to comment.