Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/zeta-chain/node into fix…
Browse files Browse the repository at this point in the history
…-solana-MsgVoteInbound-Receiver-address
  • Loading branch information
ws4charlie committed Dec 10, 2024
2 parents bd2b3de + 1329066 commit 7ebfef6
Show file tree
Hide file tree
Showing 53 changed files with 1,121 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @brewmaster012 @kingpinXD @lumtis @ws4charlie @skosito @swift1337 @fbac
* @zeta-chain/protocol-engineering

.github/** @zeta-chain/devops
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

* [3206](https://github.com/zeta-chain/node/pull/3206) - skip Solana unsupported transaction version to not block inbound observation
* [3184](https://github.com/zeta-chain/node/pull/3184) - zetaclient should not retry if inbound vote message validation fails
* [3230](https://github.com/zeta-chain/node/pull/3230) - update pending nonces when aborting a cctx through MsgAbortStuckCCTX
* [3225](https://github.com/zeta-chain/node/pull/3225) - use separate database file names for btc signet and testnet4
* [3242](https://github.com/zeta-chain/node/pull/3242) - set the `Receiver` of `MsgVoteInbound` to the address pulled from solana memo
* [3253](https://github.com/zeta-chain/node/pull/3253) - fix solana inbound version 0 queries and move tss keysign prior to relayer key checking

## v23.0.0

Expand Down
24 changes: 18 additions & 6 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}))
}

e2eStartHeight, err := deployerRunner.Clients.Zetacore.GetBlockHeight(ctx)
noError(err)

// setting up the networks
if !skipSetup {
logger.Print("⚙️ setting up networks")
Expand Down Expand Up @@ -258,8 +261,6 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
deployerRunner.UpdateChainParamsV2Contracts()
deployerRunner.ERC20CustodyAddr = deployerRunner.ERC20CustodyV2Addr

deployerRunner.MintERC20OnEvm(1e10)

logger.Print("✅ setup completed in %s", time.Since(startTime))
}

Expand All @@ -284,6 +285,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
os.Exit(0)
}

// always mint ERC20 before every test execution
deployerRunner.MintERC20OnEvm(1e10)

// run the v2 migration
if testV2Migration {
deployerRunner.RunV2Migration()
Expand Down Expand Up @@ -368,15 +372,23 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
precompiledContractTests = []string{
e2etests.TestPrecompilesPrototypeName,
e2etests.TestPrecompilesPrototypeThroughContractName,
e2etests.TestPrecompilesStakingName,
// Disabled until further notice, check https://github.com/zeta-chain/node/issues/3005.
// e2etests.TestPrecompilesStakingThroughContractName,
e2etests.TestPrecompilesBankName,
e2etests.TestPrecompilesBankFailName,
e2etests.TestPrecompilesBankThroughContractName,
e2etests.TestPrecompilesDistributeName,
e2etests.TestPrecompilesDistributeNonZRC20Name,
e2etests.TestPrecompilesDistributeThroughContractName,
}
if e2eStartHeight < 100 {
// these tests require a clean system
// since unstaking has an unbonding period
precompiledContractTests = append(precompiledContractTests,
e2etests.TestPrecompilesStakingName,
e2etests.TestPrecompilesDistributeName,
e2etests.TestPrecompilesDistributeNonZRC20Name,
e2etests.TestPrecompilesDistributeThroughContractName,
)
} else {
logger.Print("⚠️ partial precompiled run (unclean state)")
}
}

Expand Down
10 changes: 10 additions & 0 deletions e2e/e2etests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,13 @@ func parseBitcoinWithdrawArgs(r *runner.E2ERunner, args []string, defaultReceive

return receiver, amount
}

// bigAdd is shorthand for new(big.Int).Add(x, y)
func bigAdd(x *big.Int, y *big.Int) *big.Int {
return new(big.Int).Add(x, y)
}

// bigSub is shorthand for new(big.Int).Sub(x, y)
func bigSub(x *big.Int, y *big.Int) *big.Int {
return new(big.Int).Sub(x, y)
}
2 changes: 2 additions & 0 deletions e2e/e2etests/test_deploy_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func deployZEVMTestDApp(r *runner.E2ERunner) (ethcommon.Address, error) {
r.ZEVMAuth,
r.ZEVMClient,
true,
r.GatewayEVMAddr,
)
if err != nil {
return addr, err
Expand All @@ -66,6 +67,7 @@ func deployEVMTestDApp(r *runner.E2ERunner) (ethcommon.Address, error) {
r.EVMAuth,
r.EVMClient,
false,
r.GatewayEVMAddr,
)
if err != nil {
return addr, err
Expand Down
8 changes: 1 addition & 7 deletions e2e/e2etests/test_eth_deposit_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,5 @@ func TestEtherDepositAndCall(r *runner.E2ERunner, args []string) {

r.Logger.Info("Cross-chain call to reverter reverted")

// Check the error carries the revert executed.
// tolerate the error in both the ErrorMessage field and the StatusMessage field
if cctx.CctxStatus.ErrorMessage != "" {
require.Contains(r, cctx.CctxStatus.ErrorMessage, "revert executed")
} else {
require.Contains(r, cctx.CctxStatus.StatusMessage, utils.ErrHashRevertFoo)
}
require.Contains(r, cctx.CctxStatus.ErrorMessage, utils.ErrHashRevertFoo)
}
6 changes: 4 additions & 2 deletions e2e/e2etests/test_eth_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ func TestEtherWithdraw(r *runner.E2ERunner, args []string) {

utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)

withdrawalReceipt := mustFetchEthReceipt(r, cctx)
require.Equal(r, uint8(ethtypes.DynamicFeeTxType), withdrawalReceipt.Type, "receipt type mismatch")
//Skipped due to https://github.com/zeta-chain/node/issues/3221
//withdrawalReceipt := mustFetchEthReceipt(r, cctx)
//require.Equal(r, uint8(ethtypes.DynamicFeeTxType), withdrawalReceipt.Type, "receipt type mismatch")

r.Logger.Info("TestEtherWithdraw completed")
}

// nolint:unused // https://github.com/zeta-chain/node/issues/3221
func mustFetchEthReceipt(r *runner.E2ERunner, cctx *crosschaintypes.CrossChainTx) *ethtypes.Receipt {
hash := cctx.GetCurrentOutboundParam().Hash
require.NotEmpty(r, hash, "outbound hash is empty")
Expand Down
28 changes: 28 additions & 0 deletions e2e/e2etests/test_inbound_trackers.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,32 @@ func TestInboundTrackers(r *runner.E2ERunner, args []string) {
)
addTrackerAndWaitForCCTX(coin.CoinType_NoAssetCall, tx.Hash().Hex())
r.Logger.Print("🍾v2 call observed")

// set value of the payable transactions
previousValue := r.EVMAuth.Value
r.EVMAuth.Value = amount

// send v2 deposit through contract
r.Logger.Print("🏃test v2 deposit through contract")
tx, err := r.TestDAppV2EVM.GatewayDeposit(r.EVMAuth, r.EVMAddress())
require.NoError(r, err)
addTrackerAndWaitForCCTX(coin.CoinType_Gas, tx.Hash().Hex())
r.Logger.Print("🍾v2 deposit through contract observed")

// send v2 deposit and call through contract
r.Logger.Print("🏃test v2 deposit and call through contract")
tx, err = r.TestDAppV2EVM.GatewayDepositAndCall(r.EVMAuth, r.TestDAppV2ZEVMAddr, []byte(randomPayload(r)))
require.NoError(r, err)
addTrackerAndWaitForCCTX(coin.CoinType_Gas, tx.Hash().Hex())
r.Logger.Print("🍾v2 deposit and call through contract observed")

// reset the value of the payable transactions
r.EVMAuth.Value = previousValue

// send v2 call through contract
r.Logger.Print("🏃test v2 call through contract")
tx, err = r.TestDAppV2EVM.GatewayCall(r.EVMAuth, r.TestDAppV2ZEVMAddr, []byte(randomPayload(r)))
require.NoError(r, err)
addTrackerAndWaitForCCTX(coin.CoinType_NoAssetCall, tx.Hash().Hex())
r.Logger.Print("🍾v2 call through contract observed")
}
79 changes: 59 additions & 20 deletions e2e/e2etests/test_precompiles_bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ func TestPrecompilesBank(r *runner.E2ERunner, args []string) {
utils.RequireTxSuccessful(r, receipt, "Resetting balance failed")
}()

// Ensure starting allowance is zero; this is needed when running the tests multiple times
tx, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, bankAddress, big.NewInt(0))
require.NoError(r, err)
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Resetting allowance failed")

// Get ERC20ZRC20.
txHash := r.DepositERC20WithAmountAndMessage(r.EVMAddress(), totalAmount, []byte{})
utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
Expand All @@ -54,15 +60,18 @@ func TestPrecompilesBank(r *runner.E2ERunner, args []string) {
bankContract, err := bank.NewIBank(bank.ContractAddress, r.ZEVMClient)
require.NoError(r, err, "Failed to create bank contract caller")

// Cosmos coin balance should be 0 at this point.
cosmosBalance, err := bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
// get starting balances
startSpenderCosmosBalance, err := bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(0), cosmosBalance.Uint64(), "spender cosmos coin balance should be 0")
startSpenderZRC20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
startBankZRC20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bankAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")

// Approve allowance of 500 ERC20ZRC20 tokens for the bank contract. Should pass.
tx, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, bankAddress, depositAmount)
tx, err = r.ERC20ZRC20.Approve(r.ZEVMAuth, bankAddress, depositAmount)
require.NoError(r, err)
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt, "Approve ETHZRC20 bank allowance tx failed")

// Deposit 501 ERC20ZRC20 tokens to the bank contract.
Expand Down Expand Up @@ -99,17 +108,27 @@ func TestPrecompilesBank(r *runner.E2ERunner, args []string) {
require.Equal(r, depositAmount, eventDeposit.Amount, "Deposit event amount should be 500")

// Spender: cosmos coin balance should be 500 at this point.
cosmosBalance, err = bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
spenderCosmosBalance, err := bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(500), cosmosBalance.Uint64(), "spender cosmos coin balance should be 500")
require.Equal(
r,
startSpenderCosmosBalance.Int64()+500,
spenderCosmosBalance.Int64(),
"spender cosmos coin balance should be +500",
)

// Bank: ERC20ZRC20 balance should be 500 tokens locked.
bankZRC20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bankAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(r, uint64(500), bankZRC20Balance.Uint64(), "bank ERC20ZRC20 balance should be 500")
require.Equal(
r,
startBankZRC20Balance.Int64()+500,
bankZRC20Balance.Int64(),
"bank ERC20ZRC20 balance should be +500",
)

// Try to withdraw 501 ERC20ZRC20 tokens. Should fail.
tx, err = bankContract.Withdraw(r.ZEVMAuth, r.ERC20ZRC20Addr, big.NewInt(501))
// Try to withdraw one more than current balance. Should fail.
tx, err = bankContract.Withdraw(r.ZEVMAuth, r.ERC20ZRC20Addr, new(big.Int).Add(spenderCosmosBalance, big.NewInt(1)))
require.NoError(r, err, "Error calling bank.withdraw()")
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
utils.RequiredTxFailed(r, receipt, "Withdrawing more than cosmos coin balance amount should fail")
Expand All @@ -118,7 +137,12 @@ func TestPrecompilesBank(r *runner.E2ERunner, args []string) {
// No tokens should be unlocked with a failed withdraw.
bankZRC20Balance, err = r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bankAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(r, uint64(500), bankZRC20Balance.Uint64(), "bank ERC20ZRC20 balance should be 500")
require.Equal(
r,
startBankZRC20Balance.Int64()+500,
bankZRC20Balance.Int64(),
"bank ERC20ZRC20 balance should be +500",
)

// Try to withdraw 500 ERC20ZRC20 tokens. Should pass.
tx, err = bankContract.Withdraw(r.ZEVMAuth, r.ERC20ZRC20Addr, depositAmount)
Expand All @@ -133,20 +157,35 @@ func TestPrecompilesBank(r *runner.E2ERunner, args []string) {
require.Equal(r, r.ERC20ZRC20Addr, eventWithdraw.Zrc20Token, "Withdraw event token should be ERC20ZRC20Addr")
require.Equal(r, depositAmount, eventWithdraw.Amount, "Withdraw event amount should be 500")

// Spender: cosmos coin balance should be 0 at this point.
cosmosBalance, err = bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
// Spender: cosmos coin balance should be +0 at this point.
spenderCosmosBalance, err = bankContract.BalanceOf(&bind.CallOpts{Context: r.Ctx}, r.ERC20ZRC20Addr, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(0), cosmosBalance.Uint64(), "spender cosmos coin balance should be 0")
require.Equal(
r,
startSpenderCosmosBalance.Int64(),
spenderCosmosBalance.Int64(),
"spender cosmos coin balance should match starting balance",
)

// Spender: ERC20ZRC20 balance should be 1000 at this point.
zrc20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, spender)
require.NoError(r, err, "Call bank.BalanceOf()")
require.Equal(r, uint64(1000), zrc20Balance.Uint64(), "spender ERC20ZRC20 balance should be 1000")
// Spender: ERC20ZRC20 balance should be +0 at this point.
spenderZRC20Balance, err := r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, spender)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(
r,
startSpenderZRC20Balance.Int64(),
spenderZRC20Balance.Int64(),
"spender ERC20ZRC20 balance should match starting balance",
)

// Bank: ERC20ZRC20 balance should be 0 tokens locked.
// Bank: ERC20ZRC20 balance should be +0 tokens locked.
bankZRC20Balance, err = r.ERC20ZRC20.BalanceOf(&bind.CallOpts{Context: r.Ctx}, bankAddress)
require.NoError(r, err, "Call ERC20ZRC20.BalanceOf")
require.Equal(r, uint64(0), bankZRC20Balance.Uint64(), "bank ERC20ZRC20 balance should be 0")
require.Equal(
r,
startBankZRC20Balance.Int64(),
bankZRC20Balance.Int64(),
"bank ERC20ZRC20 balance should match starting balance",
)
}

func TestPrecompilesBankNonZRC20(r *runner.E2ERunner, args []string) {
Expand Down
Loading

0 comments on commit 7ebfef6

Please sign in to comment.