Skip to content

Commit

Permalink
make some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Aug 21, 2024
1 parent be6f1e3 commit f899d24
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ start-upgrade-v2-migration-test: zetanode-upgrade
@echo "--> Starting v2 migration upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
export E2E_ARGS="--skip-regular --test-v2-migration" && \
export E2E_ARGS="--skip-regular --test-v2-migration --verbose" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d


Expand Down
10 changes: 8 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package local
import (
"context"
"errors"
"math/big"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -240,6 +241,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {

// run the v2 migration
if testV2Migration {
// deposit erc20 to ensure that the custody contract has funds to migrate
oneThousand := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(1000))
erc20Deposit := deployerRunner.DepositERC20WithAmountAndMessage(deployerRunner.EVMAddress(), oneThousand, []byte{})
deployerRunner.WaitForMinedCCTX(erc20Deposit)

deployerRunner.RunV2Migration()
}

Expand Down Expand Up @@ -338,7 +344,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {

// TestMigrateChainSupportName tests EVM chain migration. Currently this test doesn't work with Anvil because pre-EIP1559 txs are not supported
// See issue below for details
// TODO: renenable this test as per the issue below
// TODO: reenable this test as per the issue below
// https://github.com/zeta-chain/node/issues/1980
// e2etests.TestMigrateChainSupportName,
))
Expand Down Expand Up @@ -367,7 +373,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if testV2 {
// update the ERC20 custody contract for v2 tests
// note: not run in testV2Migration because it is already run in the migration process
deployerRunner.UpdateChainParamsERC20CustodyContract()
deployerRunner.UpdateChainParamsV2Contracts()
}

if testV2 || testV2Migration {
Expand Down
15 changes: 11 additions & 4 deletions e2e/runner/accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,18 @@ func (r *E2ERunner) checkERC20TSSBalance() error {
if err != nil {
return err
}
custodyV2Balance, err := r.ERC20.BalanceOf(&bind.CallOpts{}, r.ERC20CustodyV2Addr)
if err != nil {
return err

custodyFullBalance := custodyBalance

// take into account the balance of the new ERC20 custody contract as v2 test use this contract
// if both addresses are equal, then there is no need to check the balance of the new contract
if r.ERC20CustodyAddr.Hex() != r.ERC20CustodyV2Addr.Hex() {
custodyV2Balance, err := r.ERC20.BalanceOf(&bind.CallOpts{}, r.ERC20CustodyV2Addr)
if err != nil {
return err
}
custodyFullBalance = big.NewInt(0).Add(custodyBalance, custodyV2Balance)
}
custodyFullBalance := big.NewInt(0).Add(custodyBalance, custodyV2Balance)

erc20zrc20Supply, err := r.ERC20ZRC20.TotalSupply(&bind.CallOpts{})
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions e2e/runner/v2_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ func (r *E2ERunner) migrateERC20CustodyFunds() {
_, err = r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, msgUnpause)
require.NoError(r, err)

// Part 5: update the ERC20 custody contract in the chain params
r.UpdateChainParamsERC20CustodyContract()
// Part 5: update the ERC20 custody contract in the chain params and in the runner
r.UpdateChainParamsV2Contracts()

r.ERC20CustodyAddr = r.ERC20CustodyV2Addr
}
7 changes: 5 additions & 2 deletions e2e/runner/v2_setup_zeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func (r *E2ERunner) SetZEVMContractsV2() {
ensureTxReceipt(txTestDAppV2, "TestDAppV2 deployment failed")
}

// UpdateChainParamsERC20CustodyContract update the erc20 custody contract in the chain params
// UpdateChainParamsV2Contracts update the erc20 custody contract and gateway address in the chain params
// this operation is used when transitioning to new smart contract architecture where a new ERC20 custody contract is deployed
func (r *E2ERunner) UpdateChainParamsERC20CustodyContract() {
func (r *E2ERunner) UpdateChainParamsV2Contracts() {
res, err := r.ObserverClient.GetChainParams(r.Ctx, &observertypes.QueryGetChainParamsRequest{})
require.NoError(r, err)

Expand All @@ -101,6 +101,9 @@ func (r *E2ERunner) UpdateChainParamsERC20CustodyContract() {
// update with the new ERC20 custody contract address
chainParams.Erc20CustodyContractAddress = r.ERC20CustodyV2Addr.Hex()

// update with the new gateway address
chainParams.GatewayAddress = r.GatewayEVMAddr.Hex()

// update the chain params
_, err = r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, observertypes.NewMsgUpdateChainParams(
r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName),
Expand Down
1 change: 1 addition & 0 deletions e2e/txserver/zeta_tx_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ func (zts ZetaTxServer) UpdateGatewayAddress(account, gatewayAddr string) error
addr.String(),
gatewayAddr,
))

return err
}

Expand Down
6 changes: 5 additions & 1 deletion zetaclient/chains/bitcoin/observer/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"math/big"
"strings"

cosmosmath "cosmossdk.io/math"
"github.com/btcsuite/btcd/btcjson"
Expand Down Expand Up @@ -56,7 +57,10 @@ func (ob *Observer) WatchInbound(ctx context.Context) error {
}
err := ob.ObserveInbound(ctx)
if err != nil {
ob.logger.Inbound.Error().Err(err).Msg("WatchInbound error observing in tx")
// skip showing log for block number 0 as it means Bitcoin is not being observed
if !strings.Contains(err.Error(), "current block number 0 is too low") {
ob.logger.Inbound.Error().Err(err).Msg("WatchInbound error observing in tx")
}
}
ticker.UpdateInterval(ob.GetChainParams().InboundTicker, ob.logger.Inbound)
case <-ob.StopChannel():
Expand Down
5 changes: 4 additions & 1 deletion zetaclient/chains/bitcoin/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math"
"math/big"
"sort"
"strings"
"time"

"github.com/btcsuite/btcd/btcjson"
Expand Down Expand Up @@ -456,7 +457,9 @@ func (ob *Observer) WatchUTXOs(ctx context.Context) error {
}
err := ob.FetchUTXOs(ctx)
if err != nil {
ob.logger.UTXOs.Error().Err(err).Msg("error fetching btc utxos")
if !strings.Contains(err.Error(), "No wallet is loaded") {
ob.logger.UTXOs.Error().Err(err).Msg("error fetching btc utxos")
}
}
ticker.UpdateInterval(ob.GetChainParams().WatchUtxoTicker, ob.logger.UTXOs)
case <-ob.StopChannel():
Expand Down
3 changes: 3 additions & 0 deletions zetaclient/chains/evm/observer/v2_inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func (ob *Observer) ObserveGatewayDeposit(ctx context.Context, startBlock, toBlo
// increment prom counter
metrics.GetFilterLogsPerChain.WithLabelValues(ob.Chain().Name).Inc()

// TODO: remove in this PR
ob.Logger().Inbound.Info().Msgf("ObserveGatewayDeposit: observing deposits with gateway contract %s", gatewayAddr.Hex())

// post to zetacore
lastScanned := uint64(0)
for _, event := range events {
Expand Down

0 comments on commit f899d24

Please sign in to comment.