Skip to content

Commit

Permalink
test: update tss address on gateway for TSS migration test (#3597)
Browse files Browse the repository at this point in the history
* update tss address on gateway for TSS migration test

* improve comment

* add todo for solana
  • Loading branch information
kingpinXD authored Feb 26, 2025
1 parent e8ae60f commit 4e5c732
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cmd/zetae2e/local/tss_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ func TSSMigration(deployerRunner *runner.E2ERunner, logger *runner.Logger, verbo
logger.Print("❌ tss migration failed")
os.Exit(1)
}

// Update TSS address for contracts in connected chains
// TODO : Update TSS address for other chains if necessary
// https://github.com/zeta-chain/node/issues/3599
deployerRunner.UpdateTSSAddressForConnector()
deployerRunner.UpdateTSSAddressForERC20custody()
deployerRunner.UpdateTSSAddressForGateway()
logger.Print("✅ migration completed in %s ", time.Since(migrationStartTime).String())
}
8 changes: 4 additions & 4 deletions e2e/e2etests/test_migrate_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) {
btcTSSBalanceNew += utxo.Amount
}

r.Logger.Info("BTC Balance Old: %f", btcTSSBalanceOld*1e8)
r.Logger.Info("BTC Balance New: %f", btcTSSBalanceNew*1e8)
r.Logger.Info("BTC TSS Balance Old: %f", btcTSSBalanceOld*1e8)
r.Logger.Info("BTC TSS Balance New: %f", btcTSSBalanceNew*1e8)
r.Logger.Info("Migrator amount : %s", cctxBTC.GetCurrentOutboundParam().Amount)

// btcTSSBalanceNew should be less than btcTSSBalanceOld as there is some loss of funds during migration
Expand All @@ -165,8 +165,8 @@ func TestMigrateTSS(r *runner.E2ERunner, _ []string) {
ethTSSBalanceNew, err := r.EVMClient.BalanceAt(context.Background(), r.TSSAddress, nil)
require.NoError(r, err)

r.Logger.Info("TSS Balance Old: %s", ethTSSBalanceOld.String())
r.Logger.Info("TSS Balance New: %s", ethTSSBalanceNew.String())
r.Logger.Info("ETH TSS Balance Old: %s", ethTSSBalanceOld.String())
r.Logger.Info("ETH TSS Balance New: %s", ethTSSBalanceNew.String())
r.Logger.Info("Migrator amount : %s", cctxETH.GetCurrentOutboundParam().Amount.String())

// ethTSSBalanceNew should be less than ethTSSBalanceOld as there is some loss of funds during migration
Expand Down
17 changes: 17 additions & 0 deletions e2e/runner/admin_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/zeta-chain/node/e2e/utils"
)

// UpdateTSSAddressForConnector updates the TSS address for the connector contract
func (r *E2ERunner) UpdateTSSAddressForConnector() {
require.NoError(r, r.SetTSSAddresses())

Expand All @@ -21,6 +22,7 @@ func (r *E2ERunner) UpdateTSSAddressForConnector() {
require.Equal(r, r.TSSAddress, tssAddressOnConnector)
}

// UpdateTSSAddressForERC20custody updates the TSS address for the ERC20 custody contract
func (r *E2ERunner) UpdateTSSAddressForERC20custody() {
require.NoError(r, r.SetTSSAddresses())

Expand All @@ -35,3 +37,18 @@ func (r *E2ERunner) UpdateTSSAddressForERC20custody() {
require.NoError(r, err)
require.Equal(r, r.TSSAddress, tssAddressOnCustody)
}

// UpdateTSSAddressForGateway updates the TSS address for the gateway contract
func (r *E2ERunner) UpdateTSSAddressForGateway() {
require.NoError(r, r.SetTSSAddresses())

tx, err := r.GatewayEVM.UpdateTSSAddress(r.EVMAuth, r.TSSAddress)
require.NoError(r, err)
r.Logger.Info("TSS Gateway Address Update Tx: %s", tx.Hash().String())
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt)

tssAddressOnGateway, err := r.GatewayEVM.TssAddress(&bind.CallOpts{Context: r.Ctx})
require.NoError(r, err)
require.Equal(r, r.TSSAddress, tssAddressOnGateway)
}
2 changes: 0 additions & 2 deletions e2e/runner/setup_zevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ var EmissionsPoolFunding = big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(2e7))

// SetTSSAddresses set TSS addresses from information queried from ZetaChain
func (r *E2ERunner) SetTSSAddresses() error {
r.Logger.Print("⚙️ setting up TSS address")

btcChainID, err := chains.GetBTCChainIDFromChainParams(r.BitcoinParams)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions zetaclient/chains/bitcoin/signer/outbound_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func NewOutboundData(
}
params := cctx.GetCurrentOutboundParam()

// support gas token only for Bitcoin outbound
if cctx.InboundParams.CoinType != coin.CoinType_Gas {
// support coin type GAS and CMD only
if cctx.InboundParams.CoinType != coin.CoinType_Gas && cctx.InboundParams.CoinType != coin.CoinType_Cmd {
return nil, fmt.Errorf("invalid coin type %s", cctx.InboundParams.CoinType.String())
}

Expand Down

0 comments on commit 4e5c732

Please sign in to comment.