Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions pkg/contracts/solana/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions pkg/contracts/solana/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 6 additions & 15 deletions pkg/contracts/solana/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down