diff --git a/changelog.md b/changelog.md index fc64d51aff..6731cec07b 100644 --- a/changelog.md +++ b/changelog.md @@ -55,6 +55,7 @@ * [3872](https://github.com/zeta-chain/node/pull/3872) - delete testnet ballots for creation height 0 and add a query to list all ballots created at a height. * [3914](https://github.com/zeta-chain/node/pull/3914) - check tx result err in filter inbound events * [3904](https://github.com/zeta-chain/node/pull/3904) - improve observer emissions distribution to maximise pool utilisation +* [3895](https://github.com/zeta-chain/node/pull/3895) - solana call required accounts number condition ### Tests 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)