From 4b1b9e1c1809a60595ef7dbc27a35c278a1d5971 Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 21 May 2025 12:29:04 +0200 Subject: [PATCH 1/2] fix solana call required accounts number condition --- pkg/contracts/solana/gateway.go | 8 ++++++-- pkg/contracts/solana/inbound.go | 4 ++-- pkg/contracts/solana/inbound_test.go | 21 ++++++--------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/pkg/contracts/solana/gateway.go b/pkg/contracts/solana/gateway.go index b556f408a5..8e8b22cfbb 100644 --- a/pkg/contracts/solana/gateway.go +++ b/pkg/contracts/solana/gateway.go @@ -11,13 +11,17 @@ const ( // PDASeed is the seed for the Solana gateway program derived address PDASeed = "meta" - // AccountsNumberOfDeposit is the number of accounts required for Solana gateway deposit instruction + // accountsNumDeposit is the number of accounts required for Solana gateway deposit instruction // [signer, pda, system_program] accountsNumDeposit = 3 - // AccountsNumberOfDeposit is the number of accounts required for Solana gateway deposit spl instruction + // accountsNumberDepositSPL is the number of accounts required for Solana gateway deposit spl instruction // [signer, pda, whitelist_entry, mint_account, token_program, from, to, system_program] accountsNumberDepositSPL = 8 + + // accountsNumberCall is the number of accounts required for Solana gateway call instruction + // [signer] + accountsNumberCall = 1 ) var ( diff --git a/pkg/contracts/solana/inbound.go b/pkg/contracts/solana/inbound.go index c23e830880..f9d183222e 100644 --- a/pkg/contracts/solana/inbound.go +++ b/pkg/contracts/solana/inbound.go @@ -245,8 +245,8 @@ func ParseInboundAsCall( if err != nil { return nil, err } - if len(instructionAccounts) != 1 { - return nil, fmt.Errorf("want only 1 signer account, got %d", len(instructionAccounts)) + if len(instructionAccounts) < accountsNumberCall { + return nil, fmt.Errorf("want required 1 signer account, got %d", len(instructionAccounts)) } // parse receiver diff --git a/pkg/contracts/solana/inbound_test.go b/pkg/contracts/solana/inbound_test.go index d80ace1e22..a894cb07ca 100644 --- a/pkg/contracts/solana/inbound_test.go +++ b/pkg/contracts/solana/inbound_test.go @@ -7,7 +7,6 @@ import ( "path/filepath" "testing" - "github.com/gagliardetto/solana-go" "github.com/gagliardetto/solana-go/rpc" "github.com/near/borsh-go" "github.com/stretchr/testify/require" @@ -111,8 +110,7 @@ func Test_ParseInboundAsDeposit(t *testing.T) { require.NoError(t, err) instruction := tx.Message.Instructions[instructionIndex] - // append one more account to instruction - tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) + // remove account from instruction instruction.Accounts = instruction.Accounts[:len(instruction.Accounts)-1] // ACT @@ -199,8 +197,7 @@ func Test_ParseInboundAsDepositAndCall(t *testing.T) { require.NoError(t, err) instruction := tx.Message.Instructions[instructionIndex] - // append one more account to instruction - tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) + // remove account from instruction instruction.Accounts = instruction.Accounts[:len(instruction.Accounts)-1] // ACT @@ -285,8 +282,7 @@ func Test_ParseInboundAsDepositSPL(t *testing.T) { require.NoError(t, err) instruction := tx.Message.Instructions[instructionIndex] - // append one more account to instruction - tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) + // remove account from instruction instruction.Accounts = instruction.Accounts[:len(instruction.Accounts)-1] // ACT @@ -374,8 +370,7 @@ func Test_ParseInboundAsDepositAndCallSPL(t *testing.T) { require.NoError(t, err) instruction := tx.Message.Instructions[instructionIndex] - // append one more account to instruction - tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) + // remove account from instruction instruction.Accounts = instruction.Accounts[:len(instruction.Accounts)-1] // ACT @@ -460,12 +455,8 @@ func Test_ParseInboundAsCall(t *testing.T) { require.NoError(t, err) instruction := tx.Message.Instructions[instructionIndex] - // append one more account to instruction - tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) - instruction.Accounts = append( - instruction.Accounts, - 1, - ) + // remove account from instruction + instruction.Accounts = instruction.Accounts[:len(instruction.Accounts)-1] // ACT call, err := contracts.ParseInboundAsCall(tx, instruction, txResult.Slot) From 22d660f45d2d77259d9721caf2b7edda101cbb08 Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 21 May 2025 12:30:11 +0200 Subject: [PATCH 2/2] changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 5066907e7f..d5bc120edc 100644 --- a/changelog.md +++ b/changelog.md @@ -48,6 +48,7 @@ * [3850](https://github.com/zeta-chain/node/pull/3850) - broadcast single sui withdraw tx at a time to avoid nonce mismatch failure * [3877](https://github.com/zeta-chain/node/pull/3877) - use multiple SUI coin objects to pay PTB transaction gas fee * [3890](https://github.com/zeta-chain/node/pull/3890) - solana abort address format +* [3895](https://github.com/zeta-chain/node/pull/3895) - solana call required accounts number condition ### Tests