Skip to content

Commit

Permalink
add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jul 7, 2024
1 parent 4ff9b04 commit 897fdb3
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 23 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
* [2349](https://github.com/zeta-chain/node/pull/2349) - add TestBitcoinDepositRefund and WithdrawBitcoinMultipleTimes E2E tests
* [2368](https://github.com/zeta-chain/node/pull/2368) - eliminate panic usage across testing suite
* [2369](https://github.com/zeta-chain/node/pull/2369) - fix random cross-chain swap failure caused by using tiny UTXO
* [2440](https://github.com/zeta-chain/node/pull/2440) - Add e2e test for Tss migration


### Fixes
Expand Down
5 changes: 3 additions & 2 deletions cmd/zetaclientd-supervisor/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/hashicorp/go-getter"
"github.com/rs/zerolog"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"google.golang.org/grpc"

observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

Expand Down Expand Up @@ -207,7 +207,8 @@ func (s *zetaclientdSupervisor) handleTssUpdate(ctx context.Context) {
}

tss = tssNew
s.logger.Warn().Msg(fmt.Sprintf("tss address is updated from %s to %s", tss.TSS.TssPubkey, tssNew.TSS.TssPubkey))
s.logger.Warn().
Msg(fmt.Sprintf("tss address is updated from %s to %s", tss.TSS.TssPubkey, tssNew.TSS.TssPubkey))
time.Sleep(6 * time.Second)
s.logger.Info().Msg("restarting zetaclientd to update tss address")
s.restartChan <- syscall.SIGHUP
Expand Down
9 changes: 7 additions & 2 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
tsscommon "github.com/zeta-chain/go-tss/common"
"github.com/zeta-chain/go-tss/keygen"
"github.com/zeta-chain/go-tss/tss"
"github.com/zeta-chain/zetacore/zetaclient/chains/interfaces"
"golang.org/x/crypto/sha3"

"github.com/zeta-chain/zetacore/pkg/chains"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/chains/interfaces"
"github.com/zeta-chain/zetacore/zetaclient/context"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
mc "github.com/zeta-chain/zetacore/zetaclient/tss"
Expand Down Expand Up @@ -120,7 +120,12 @@ func GenerateTss(
// keygenTss generates a new TSS using the keygen request and the TSS server.
// If the keygen is successful, the function returns the new TSS pubkey.
// If the keygen is unsuccessful, the function posts blame and returns an error.
func keygenTss(keyGen observertypes.Keygen, tssServer tss.TssServer, zetacoreClient interfaces.ZetacoreClient, keygenLogger zerolog.Logger) (string, error) {
func keygenTss(
keyGen observertypes.Keygen,
tssServer tss.TssServer,
zetacoreClient interfaces.ZetacoreClient,
keygenLogger zerolog.Logger,
) (string, error) {
keygenLogger.Info().Msgf("Keygen at blocknum %d , TSS signers %s ", keyGen.BlockNumber, keyGen.GranteePubkeys)
var req keygen.Request
req = keygen.NewRequest(keyGen.GranteePubkeys, keyGen.BlockNumber, "0.14.0")
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zeta-chain/go-tss/p2p"
"github.com/zeta-chain/zetacore/pkg/chains"
mc "github.com/zeta-chain/zetacore/zetaclient/tss"

"github.com/zeta-chain/zetacore/pkg/authz"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/constant"
observerTypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/chains/base"
"github.com/zeta-chain/zetacore/zetaclient/config"
"github.com/zeta-chain/zetacore/zetaclient/context"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
"github.com/zeta-chain/zetacore/zetaclient/orchestrator"
mc "github.com/zeta-chain/zetacore/zetaclient/tss"
)

type Multiaddr = core.Multiaddr
Expand Down
8 changes: 6 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"

zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/e2etests"
Expand All @@ -19,7 +21,6 @@ import (
"github.com/zeta-chain/zetacore/testutil"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"golang.org/x/sync/errgroup"
)

const (
Expand Down Expand Up @@ -331,7 +332,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
migrationStartTime := time.Now()
logger.Print("🏁 starting tss migration")

response, err := deployerRunner.CctxClient.LastZetaHeight(migrationCtx, &crosschaintypes.QueryLastZetaHeightRequest{})
response, err := deployerRunner.CctxClient.LastZetaHeight(
migrationCtx,
&crosschaintypes.QueryLastZetaHeightRequest{},
)
require.NoError(deployerRunner, err)
err = zetaTxServer.UpdateKeygen(response.Height)
require.NoError(deployerRunner, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"time"

"github.com/fatih/color"
"github.com/zeta-chain/zetacore/e2e/e2etests"

"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/e2etests"
"github.com/zeta-chain/zetacore/e2e/runner"
)

Expand Down
12 changes: 10 additions & 2 deletions e2e/e2etests/test_migrate_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/btcsuite/btcutil"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"

"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto"
Expand Down Expand Up @@ -87,7 +88,10 @@ func TestMigrateTss(r *runner.E2ERunner, _ []string) {
require.NoError(r, err)

// Fetch migrator cctx for eth migration
migrator, err = r.ObserverClient.TssFundsMigratorInfo(r.Ctx, &observertypes.QueryTssFundsMigratorInfoRequest{ChainId: evmChainID.Int64()})
migrator, err = r.ObserverClient.TssFundsMigratorInfo(
r.Ctx,
&observertypes.QueryTssFundsMigratorInfoRequest{ChainId: evmChainID.Int64()},
)
require.NoError(r, err)
cctxETHMigration := migrator.TssFundsMigrator.MigrationCctxIndex

Expand Down Expand Up @@ -149,7 +153,11 @@ func TestMigrateTss(r *runner.E2ERunner, _ []string) {
r.Logger.Info(fmt.Sprintf("Migrator amount : %s", cctxBTC.GetCurrentOutboundParam().Amount))

// btcTSSBalanceNew should be less than btcTSSBalanceOld as there is some loss of funds during migration
require.Equal(r, strconv.FormatInt(int64(btcTSSBalanceNew*1e8), 10), cctxBTC.GetCurrentOutboundParam().Amount.String())
require.Equal(
r,
strconv.FormatInt(int64(btcTSSBalanceNew*1e8), 10),
cctxBTC.GetCurrentOutboundParam().Amount.String(),
)
require.LessOrEqual(r, btcTSSBalanceNew*1e8, btcTSSBalanceOld*1e8)

// ETH
Expand Down
10 changes: 7 additions & 3 deletions e2e/runner/accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"

zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)
Expand Down Expand Up @@ -42,9 +43,12 @@ func (r *E2ERunner) checkEthTSSBalance() error {
tssTotalBalance := big.NewInt(0)

for _, tssAddress := range allTssAddress.TssList {
evmAddress, err := r.ObserverClient.GetTssAddressByFinalizedHeight(r.Ctx, &observertypes.QueryGetTssAddressByFinalizedHeightRequest{
FinalizedZetaHeight: tssAddress.FinalizedZetaHeight,
})
evmAddress, err := r.ObserverClient.GetTssAddressByFinalizedHeight(
r.Ctx,
&observertypes.QueryGetTssAddressByFinalizedHeightRequest{
FinalizedZetaHeight: tssAddress.FinalizedZetaHeight,
},
)
if err != nil {
continue
}
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/keeper/cctx_orchestrator_validate_inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/crypto"
"github.com/zeta-chain/zetacore/x/crosschain/types"
Expand Down
4 changes: 3 additions & 1 deletion x/crosschain/keeper/msg_server_migrate_tss_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ func (k Keeper) MigrateTSSFundsForChain(
)
}

cctx.GetCurrentOutboundParam().Amount = amount.Sub(evmFee.Add(sdkmath.NewUintFromString(types.TSSMigrationBufferAmountEVM)))
cctx.GetCurrentOutboundParam().Amount = amount.Sub(
evmFee.Add(sdkmath.NewUintFromString(types.TSSMigrationBufferAmountEVM)),
)
}
// Set the sender and receiver addresses for Bitcoin chain
if chains.IsBitcoinChain(chainID, additionalChains) {
Expand Down
3 changes: 2 additions & 1 deletion x/crosschain/keeper/msg_server_migrate_tss_funds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) {
cctx, found := k.GetCrossChainTx(ctx, index)
require.True(t, found)
feeCalculated := sdk.NewUint(cctx.GetCurrentOutboundParam().GasLimit).
Mul(sdkmath.NewUintFromString(cctx.GetCurrentOutboundParam().GasPrice)).Add(sdkmath.NewUintFromString(crosschaintypes.TSSMigrationBufferAmountEVM))
Mul(sdkmath.NewUintFromString(cctx.GetCurrentOutboundParam().GasPrice)).
Add(sdkmath.NewUintFromString(crosschaintypes.TSSMigrationBufferAmountEVM))
require.Equal(t, cctx.GetCurrentOutboundParam().Amount.String(), amount.Sub(feeCalculated).String())
})

Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_remove_outbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"

authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
"github.com/zeta-chain/zetacore/x/crosschain/types"
)

Expand Down
6 changes: 5 additions & 1 deletion x/crosschain/keeper/msg_server_update_tss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) {
}
keepertest.MockCheckAuthorization(&authorityMock.Mock, &msg, nil)
_, err := msgServer.UpdateTssAddress(ctx, &msg)
require.ErrorContains(t, err, "cannot update tss address incorrect number of migrations have been created and completed: unable to update TSS address")
require.ErrorContains(
t,
err,
"cannot update tss address incorrect number of migrations have been created and completed: unable to update TSS address",
)
require.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss)
tss, found := k.GetObserverKeeper().GetTSS(ctx)
require.True(t, found)
Expand Down
7 changes: 5 additions & 2 deletions zetaclient/chains/bitcoin/observer/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func (ob *Observer) IsOutboundProcessed(cctx *crosschaintypes.CrossChainTx, logg
// prevents double spending of same UTXO. However, for nonce 0, we don't have a prior nonce (e.g., -1)
// for the signer to check against when making the payment. Signer treats nonce 0 as a special case in downstream code.
if nonce == 0 {
fmt.Println("IsOutboundProcessed: nonce is zero")
return true, false, nil
}

Expand Down Expand Up @@ -167,7 +166,11 @@ func (ob *Observer) IsOutboundProcessed(cctx *crosschaintypes.CrossChainTx, logg
// It's safe to use cctx's amount to post confirmation because it has already been verified in observeOutbound()
amountInSat := params.Amount.BigInt()
if res.Confirmations < ob.ConfirmationsThreshold(amountInSat) {
fmt.Printf("IsOutboundProcessed: outbound not confirmed yet %d: %d", res.Confirmations, ob.ConfirmationsThreshold(amountInSat))
fmt.Printf(
"IsOutboundProcessed: outbound not confirmed yet %d: %d",
res.Confirmations,
ob.ConfirmationsThreshold(amountInSat),
)

Check warning on line 173 in zetaclient/chains/bitcoin/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/bitcoin/observer/outbound.go#L169-L173

Added lines #L169 - L173 were not covered by tests
return true, false, nil
}

Expand Down
9 changes: 6 additions & 3 deletions zetaclient/chains/evm/observer/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,9 @@ func (ob *Observer) checkConfirmedTx(txHash string, nonce uint64) (*ethtypes.Rec
}
}
if !isOldTssAddress {
log.Error().Msgf("confirmTxByHash: sender %s for outbound %s chain %d is not current or old TSS address. Current TSS %s",
from.Hex(), transaction.Hash().Hex(), ob.Chain().ChainId, ob.TSS().EVMAddress().Hex())
log.Error().
Msgf("confirmTxByHash: sender %s for outbound %s chain %d is not current or old TSS address. Current TSS %s",
from.Hex(), transaction.Hash().Hex(), ob.Chain().ChainId, ob.TSS().EVMAddress().Hex())
return nil, nil, false

Check warning on line 382 in zetaclient/chains/evm/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/outbound.go#L378-L382

Added lines #L378 - L382 were not covered by tests
}
}
Expand Down Expand Up @@ -407,7 +408,9 @@ func (ob *Observer) checkConfirmedTx(txHash string, nonce uint64) (*ethtypes.Rec
// check confirmations
lastHeight, err := ob.evmClient.BlockNumber(context.Background())
if err != nil {
log.Error().Err(err).Msgf("confirmTxByHash: error getting block number for chain %d", ob.GetChainParams().ChainId)
log.Error().
Err(err).
Msgf("confirmTxByHash: error getting block number for chain %d", ob.GetChainParams().ChainId)
return nil, nil, false

Check warning on line 414 in zetaclient/chains/evm/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/outbound.go#L409-L414

Added lines #L409 - L414 were not covered by tests
}
if !ob.HasEnoughConfirmations(receipt, lastHeight) {

Check warning on line 416 in zetaclient/chains/evm/observer/outbound.go

View check run for this annotation

Codecov / codecov/patch

zetaclient/chains/evm/observer/outbound.go#L416

Added line #L416 was not covered by tests
Expand Down

0 comments on commit 897fdb3

Please sign in to comment.