diff --git a/cmd/zetae2e/config/config.go b/cmd/zetae2e/config/config.go index abb758215c..65e5418f53 100644 --- a/cmd/zetae2e/config/config.go +++ b/cmd/zetae2e/config/config.go @@ -56,7 +56,7 @@ func RunnerFromConfig( func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.Config { // copy contracts from deployer runner conf.Contracts.Solana.GatewayProgramID = r.GatewayProgram.String() - conf.Contracts.Solana.SPL = config.DoubleQuotedString(r.SPLAddr.String()) + conf.Contracts.Solana.SPLAddr = config.DoubleQuotedString(r.SPLAddr.String()) conf.Contracts.EVM.ZetaEthAddr = config.DoubleQuotedString(r.ZetaEthAddr.Hex()) conf.Contracts.EVM.ConnectorEthAddr = config.DoubleQuotedString(r.ConnectorEthAddr.Hex()) diff --git a/cmd/zetae2e/config/contracts.go b/cmd/zetae2e/config/contracts.go index 2fbc69563c..5c46cdc047 100644 --- a/cmd/zetae2e/config/contracts.go +++ b/cmd/zetae2e/config/contracts.go @@ -34,7 +34,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { r.GatewayProgram = solana.MustPublicKeyFromBase58(c) } - if c := conf.Contracts.Solana.SPL; c != "" { + if c := conf.Contracts.Solana.SPLAddr; c != "" { r.SPLAddr = solana.MustPublicKeyFromBase58(c.String()) } diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 9b24fa8cf4..f01b81ac4e 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -413,8 +413,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) { // TODO move under admin tests // https://github.com/zeta-chain/node/issues/3085 e2etests.TestSolanaWhitelistSPLName, - e2etests.TestSolanaDepositSPLName, - e2etests.TestSolanaDepositSPLAndCallName, + e2etests.TestSPLDepositName, + e2etests.TestSPLDepositAndCallName, } eg.Go(solanaTestRoutine(conf, deployerRunner, verbose, solanaTests...)) } diff --git a/e2e/config/config.go b/e2e/config/config.go index 4351e577f6..15ca4a1f2c 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -117,10 +117,10 @@ type Contracts struct { Solana Solana `yaml:"solana"` } -// Solana contains the addresses of predeployed contracts on the Solana chain +// Solana contains the addresses of predeployed contracts and accounts on the Solana chain type Solana struct { GatewayProgramID string `yaml:"gateway_program_id"` - SPL DoubleQuotedString `yaml:"spl"` + SPLAddr DoubleQuotedString `yaml:"spl"` } // EVM contains the addresses of predeployed contracts on the EVM chain diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index ec54933d59..4d0f793509 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -61,8 +61,8 @@ const ( TestSolanaDepositAndCallRefundName = "solana_deposit_and_call_refund" TestSolanaDepositRestrictedName = "solana_deposit_restricted" TestSolanaWithdrawRestrictedName = "solana_withdraw_restricted" - TestSolanaDepositSPLName = "solana_deposit_spl" - TestSolanaDepositSPLAndCallName = "solana_deposit_spl_and_call" + TestSPLDepositName = "spl_deposit" + TestSPLDepositAndCallName = "spl_deposit_and_call" /** * TON tests @@ -465,20 +465,20 @@ var AllE2ETests = []runner.E2ETest{ TestSolanaWhitelistSPL, ), runner.NewE2ETest( - TestSolanaDepositSPLName, + TestSPLDepositName, "deposit SPL into ZEVM", []runner.ArgDefinition{ {Description: "amount of spl tokens", DefaultValue: "500000"}, }, - TestSolanaDepositSPL, + TestSPLDeposit, ), runner.NewE2ETest( - TestSolanaDepositSPLAndCallName, + TestSPLDepositAndCallName, "deposit SPL into ZEVM and call", []runner.ArgDefinition{ {Description: "amount of spl tokens", DefaultValue: "500000"}, }, - TestSolanaDepositSPLAndCall, + TestSPLDepositAndCall, ), /* TON tests diff --git a/e2e/e2etests/test_solana_deposit_spl.go b/e2e/e2etests/test_spl_deposit.go similarity index 97% rename from e2e/e2etests/test_solana_deposit_spl.go rename to e2e/e2etests/test_spl_deposit.go index 16c12051b4..ee5013d16c 100644 --- a/e2e/e2etests/test_solana_deposit_spl.go +++ b/e2e/e2etests/test_spl_deposit.go @@ -13,7 +13,7 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -func TestSolanaDepositSPL(r *runner.E2ERunner, args []string) { +func TestSPLDeposit(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount := parseInt(r, args[0]) diff --git a/e2e/e2etests/test_solana_deposit_and_call_spl.go b/e2e/e2etests/test_spl_deposit_and_call.go similarity index 95% rename from e2e/e2etests/test_solana_deposit_and_call_spl.go rename to e2e/e2etests/test_spl_deposit_and_call.go index 764e2c1423..cdfc94daa1 100644 --- a/e2e/e2etests/test_solana_deposit_and_call_spl.go +++ b/e2e/e2etests/test_spl_deposit_and_call.go @@ -14,7 +14,7 @@ import ( crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" ) -func TestSolanaDepositSPLAndCall(r *runner.E2ERunner, args []string) { +func TestSPLDepositAndCall(r *runner.E2ERunner, args []string) { require.Len(r, args, 1) amount := parseInt(r, args[0]) @@ -53,7 +53,7 @@ func TestSolanaDepositSPLAndCall(r *runner.E2ERunner, args []string) { utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) // check if example contract has been called, bar value should be set to amount - utils.MustHaveCalledExampleContract(r, contract, big.NewInt(500_000)) + utils.MustHaveCalledExampleContract(r, contract, big.NewInt(int64(amount))) // verify balances are updated pdaBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentConfirmed) diff --git a/e2e/runner/solana.go b/e2e/runner/solana.go index 3b01bbcdd7..cf4bcb20c6 100644 --- a/e2e/runner/solana.go +++ b/e2e/runner/solana.go @@ -37,60 +37,53 @@ func (r *E2ERunner) CreateDepositInstruction( data []byte, amount uint64, ) solana.Instruction { - // compute the gateway PDA address - pdaComputed := r.ComputePdaAddress() + pda := r.ComputePdaAddress() programID := r.GatewayProgram - // create 'deposit' instruction - inst := &solana.GenericInstruction{} - accountSlice := []*solana.AccountMeta{} - accountSlice = append(accountSlice, solana.Meta(signer).WRITE().SIGNER()) - accountSlice = append(accountSlice, solana.Meta(pdaComputed).WRITE()) - accountSlice = append(accountSlice, solana.Meta(solana.SystemProgramID)) - inst.ProgID = programID - inst.AccountValues = accountSlice - - var err error - inst.DataBytes, err = borsh.Serialize(solanacontract.DepositInstructionParams{ + depositData, err := borsh.Serialize(solanacontract.DepositInstructionParams{ Discriminator: solanacontract.DiscriminatorDeposit, Amount: amount, Memo: append(receiver.Bytes(), data...), }) require.NoError(r, err) - return inst + return &solana.GenericInstruction{ + ProgID: programID, + DataBytes: depositData, + AccountValues: []*solana.AccountMeta{ + solana.Meta(signer).WRITE().SIGNER(), + solana.Meta(pda).WRITE(), + solana.Meta(solana.SystemProgramID), + }, + } } +// CreateWhitelistSPLMintInstruction creates a 'whitelist_spl_mint' instruction func (r *E2ERunner) CreateWhitelistSPLMintInstruction( - signer solana.PublicKey, - whitelistEntry solana.PublicKey, - whitelistCandidate solana.PublicKey, + signer, whitelistEntry, whitelistCandidate solana.PublicKey, ) solana.Instruction { - // compute the gateway PDA address - pdaComputed := r.ComputePdaAddress() + pda := r.ComputePdaAddress() programID := r.GatewayProgram - // create 'whitelist_spl_mint' instruction - inst := &solana.GenericInstruction{} - accountSlice := []*solana.AccountMeta{} - accountSlice = append(accountSlice, solana.Meta(whitelistEntry).WRITE()) - accountSlice = append(accountSlice, solana.Meta(whitelistCandidate)) - accountSlice = append(accountSlice, solana.Meta(pdaComputed).WRITE()) - accountSlice = append(accountSlice, solana.Meta(signer).WRITE().SIGNER()) - accountSlice = append(accountSlice, solana.Meta(solana.SystemProgramID)) - inst.ProgID = programID - inst.AccountValues = accountSlice - - var err error - inst.DataBytes, err = borsh.Serialize(solanacontract.WhitelistInstructionParams{ + data, err := borsh.Serialize(solanacontract.WhitelistInstructionParams{ Discriminator: solanacontract.DiscriminatorWhitelistSplMint, - // remaining fields are empty because no tss signature is needed if signer is admin account }) require.NoError(r, err) - return inst + return &solana.GenericInstruction{ + ProgID: programID, + DataBytes: data, + AccountValues: []*solana.AccountMeta{ + solana.Meta(whitelistEntry).WRITE(), + solana.Meta(whitelistCandidate), + solana.Meta(pda).WRITE(), + solana.Meta(signer).WRITE().SIGNER(), + solana.Meta(solana.SystemProgramID), + }, + } } +// CreateDepositSPLInstruction creates a 'deposit_spl' instruction func (r *E2ERunner) CreateDepositSPLInstruction( amount uint64, signer solana.PublicKey, @@ -101,32 +94,29 @@ func (r *E2ERunner) CreateDepositSPLInstruction( receiver ethcommon.Address, data []byte, ) solana.Instruction { - // compute the gateway PDA address - pdaComputed := r.ComputePdaAddress() + pda := r.ComputePdaAddress() programID := r.GatewayProgram - // create 'deposit_spl' instruction - inst := &solana.GenericInstruction{} - accountSlice := []*solana.AccountMeta{} - accountSlice = append(accountSlice, solana.Meta(signer).WRITE().SIGNER()) - accountSlice = append(accountSlice, solana.Meta(pdaComputed)) - accountSlice = append(accountSlice, solana.Meta(whitelistEntry)) - accountSlice = append(accountSlice, solana.Meta(mint)) - accountSlice = append(accountSlice, solana.Meta(solana.TokenProgramID)) - accountSlice = append(accountSlice, solana.Meta(from).WRITE()) - accountSlice = append(accountSlice, solana.Meta(to).WRITE()) - inst.ProgID = programID - inst.AccountValues = accountSlice - - var err error - inst.DataBytes, err = borsh.Serialize(solanacontract.DepositInstructionParams{ + depositSPLData, err := borsh.Serialize(solanacontract.DepositInstructionParams{ Discriminator: solanacontract.DiscriminatorDepositSPL, Amount: amount, Memo: append(receiver.Bytes(), data...), }) require.NoError(r, err) - return inst + return &solana.GenericInstruction{ + ProgID: programID, + DataBytes: depositSPLData, + AccountValues: []*solana.AccountMeta{ + solana.Meta(signer).WRITE().SIGNER(), + solana.Meta(pda), + solana.Meta(whitelistEntry), + solana.Meta(mint), + solana.Meta(solana.TokenProgramID), + solana.Meta(from).WRITE(), + solana.Meta(to).WRITE(), + }, + } } // CreateSignedTransaction creates a signed transaction from instructions diff --git a/zetaclient/chains/solana/observer/inbound.go b/zetaclient/chains/solana/observer/inbound.go index 09a1c3d99d..9d73e75106 100644 --- a/zetaclient/chains/solana/observer/inbound.go +++ b/zetaclient/chains/solana/observer/inbound.go @@ -277,7 +277,10 @@ func (ob *Observer) ParseInboundAsDeposit( var inst solanacontracts.DepositInstructionParams err := borsh.Deserialize(&inst, instruction.Data) if err != nil { - return nil, nil + ob.Logger(). + Inbound.Err(err). + Msgf("failed to deserialize instruction data for sig %s instruction %d", tx.Signatures[0], instructionIndex) + return nil, err } // check if the instruction is a deposit or not @@ -291,7 +294,7 @@ func (ob *Observer) ParseInboundAsDeposit( ob.Logger(). Inbound.Err(err). Msgf("unable to get signer for sig %s instruction %d", tx.Signatures[0], instructionIndex) - return nil, nil + return nil, err } // build inbound event @@ -326,7 +329,10 @@ func (ob *Observer) ParseInboundAsDepositSPL( var inst solanacontracts.DepositSPLInstructionParams err := borsh.Deserialize(&inst, instruction.Data) if err != nil { - return nil, nil + ob.Logger(). + Inbound.Err(err). + Msgf("failed to deserialize instruction data for sig %s instruction %d", tx.Signatures[0], instructionIndex) + return nil, err } // check if the instruction is a deposit spl or not @@ -340,7 +346,7 @@ func (ob *Observer) ParseInboundAsDepositSPL( ob.Logger(). Inbound.Err(err). Msgf("unable to get signer and spl for sig %s instruction %d", tx.Signatures[0], instructionIndex) - return nil, nil + return nil, err } // build inbound event