diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index b65d104df6..f092912132 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -455,7 +455,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { e2etests.TestSPLDepositName, e2etests.TestSPLDepositAndCallName, e2etests.TestSPLWithdrawName, - e2etests.TestSPLWithdrawAndCreateReceiverAtaName, + e2etests.TestSPLWithdrawFailsIfNoReceiverAtaName, e2etests.TestSolanaWhitelistSPLName, } eg.Go(solanaTestRoutine(conf, deployerRunner, verbose, solanaTests...)) diff --git a/contrib/localnet/solana/gateway.so b/contrib/localnet/solana/gateway.so index 0fe82f24f2..9832e55994 100755 Binary files a/contrib/localnet/solana/gateway.so and b/contrib/localnet/solana/gateway.so differ diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index db99a5ce0d..20d1cb8de3 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -65,7 +65,7 @@ const ( TestSPLDepositName = "spl_deposit" TestSPLDepositAndCallName = "spl_deposit_and_call" TestSPLWithdrawName = "spl_withdraw" - TestSPLWithdrawAndCreateReceiverAtaName = "spl_withdraw_and_create_receiver_ata" + TestSPLWithdrawFailsIfNoReceiverAtaName = "spl_withdraw_fails_without_receiver_ata" /** * TON tests @@ -448,12 +448,12 @@ var AllE2ETests = []runner.E2ETest{ TestSPLWithdraw, ), runner.NewE2ETest( - TestSPLWithdrawAndCreateReceiverAtaName, - "withdraw SPL from ZEVM and create receiver ata", + TestSPLWithdrawFailsIfNoReceiverAtaName, + "withdraw SPL from ZEVM fails if no receiver ata", []runner.ArgDefinition{ {Description: "amount in spl tokens", DefaultValue: "1000000"}, }, - TestSPLWithdrawAndCreateReceiverAta, + TestSPLWithdrawFailsIfNoReceiverAta, ), runner.NewE2ETest( TestSolanaDepositAndCallRevertName, diff --git a/e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go b/e2e/e2etests/test_spl_withdraw_fails_if_no_receiver_ata.go similarity index 64% rename from e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go rename to e2e/e2etests/test_spl_withdraw_fails_if_no_receiver_ata.go index 51196c8a46..ed6958cd7f 100644 --- a/e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go +++ b/e2e/e2etests/test_spl_withdraw_fails_if_no_receiver_ata.go @@ -5,7 +5,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/gagliardetto/solana-go" - "github.com/gagliardetto/solana-go/rpc" "github.com/stretchr/testify/require" "github.com/zeta-chain/node/e2e/runner" @@ -13,9 +12,8 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -// TestSPLWithdrawAndCreateReceiverAta withdraws spl, but letting gateway to create receiver ata using rent payer -// instead of providing receiver that has it already created -func TestSPLWithdrawAndCreateReceiverAta(r *runner.E2ERunner, args []string) { +// TestSPLWithdrawFailsIfNoReceiverAta fails to withdraw spl because receiver ata doesn't exist +func TestSPLWithdrawFailsIfNoReceiverAta(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) withdrawAmount := parseBigInt(r, args[0]) @@ -52,28 +50,20 @@ func TestSPLWithdrawAndCreateReceiverAta(r *runner.E2ERunner, args []string) { // withdraw tx := r.WithdrawSPLZRC20(receiverPrivKey.PublicKey(), withdrawAmount, approvedAmount) - // wait for the cctx to be mined + // wait for the cctx to be mined and aborted cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) - utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) + utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted) // get SPL ZRC20 balance after withdraw zrc20BalanceAfter, err := r.SPLZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress()) require.NoError(r, err) r.Logger.Info("runner balance of SPL after withdraw: %d", zrc20BalanceAfter) - // verify receiver ata was created + // verify receiver ata was not created receiverAtaAcc, err = r.SolanaClient.GetAccountInfo(r.Ctx, receiverAta) - require.NoError(r, err) - require.NotNil(r, receiverAtaAcc) - - // verify balances are updated - receiverBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentFinalized) - require.NoError(r, err) - r.Logger.Info("receiver balance of SPL after withdraw: %s", receiverBalanceAfter.Value.Amount) - - // verify amount is added to receiver ata - require.EqualValues(r, withdrawAmount.String(), parseBigInt(r, receiverBalanceAfter.Value.Amount).String()) + require.Error(r, err) + require.Nil(r, receiverAtaAcc) - // verify amount is subtracted on zrc20 - require.EqualValues(r, new(big.Int).Sub(zrc20BalanceBefore, withdrawAmount).String(), zrc20BalanceAfter.String()) + // verify amount is not changed on zrc20 -- TODO: cctx is aborted without revert? + // require.EqualValues(r, zrc20BalanceBefore.String(), zrc20BalanceAfter.String()) } diff --git a/zetaclient/chains/solana/signer/signer.go b/zetaclient/chains/solana/signer/signer.go index 42b9855ab9..b6739751ac 100644 --- a/zetaclient/chains/solana/signer/signer.go +++ b/zetaclient/chains/solana/signer/signer.go @@ -44,9 +44,6 @@ type Signer struct { // pda is the program derived address of the gateway program pda solana.PublicKey - - // rent payer pda is the program derived address of the gateway program to pay rent for creating atas - rentPayerPda solana.PublicKey } // NewSigner creates a new Solana signer @@ -68,19 +65,12 @@ func NewSigner( return nil, errors.Wrapf(err, "cannot parse gateway address %s", chainParams.GatewayAddress) } - // parse rent payer PDA, used in case receiver ATA should be created in gateway - rentPayerPda, err := contracts.RentPayerPDA(gatewayID) - if err != nil { - return nil, errors.Wrapf(err, "cannot parse gateway address %s", chainParams.GatewayAddress) - } - // create Solana signer signer := &Signer{ - Signer: baseSigner, - client: solClient, - gatewayID: gatewayID, - pda: pda, - rentPayerPda: rentPayerPda, + Signer: baseSigner, + client: solClient, + gatewayID: gatewayID, + pda: pda, } // construct Solana private key if present diff --git a/zetaclient/chains/solana/signer/withdraw_spl.go b/zetaclient/chains/solana/signer/withdraw_spl.go index 93303fb5e6..1436cf937c 100644 --- a/zetaclient/chains/solana/signer/withdraw_spl.go +++ b/zetaclient/chains/solana/signer/withdraw_spl.go @@ -105,7 +105,6 @@ func (signer *Signer) signWithdrawSPLTx( solana.Meta(msg.MintAccount()), solana.Meta(msg.To()), solana.Meta(recipientAta).WRITE(), - solana.Meta(signer.rentPayerPda).WRITE(), solana.Meta(solana.TokenProgramID), solana.Meta(solana.SPLAssociatedTokenAccountProgramID), solana.Meta(solana.SystemProgramID),