diff --git a/pkg/contracts/solana/inbound_test.go b/pkg/contracts/solana/inbound_test.go index a803ebf877..63de780b57 100644 --- a/pkg/contracts/solana/inbound_test.go +++ b/pkg/contracts/solana/inbound_test.go @@ -39,7 +39,7 @@ func LoadSolanaInboundTxResult( func Test_ParseInboundAsDeposit(t *testing.T) { // ARRANGE - txHash := "MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j" + txHash := "8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px" chain := chains.SolanaDevnet txResult := LoadSolanaInboundTxResult(t, txHash) @@ -52,11 +52,15 @@ func Test_ParseInboundAsDeposit(t *testing.T) { require.NoError(t, err) // expected result - sender := "AS48jKNQsDGkEdDvfwu1QpqjtqbCadrAq9nGXjFmdX3Z" + // solana e2e deployer account + sender := "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ" + // solana e2e user evm account + expectedMemo, err := hex.DecodeString("103fd9224f00ce3013e95629e52dfc31d805d68d") + require.NoError(t, err) expectedDeposit := &Deposit{ Sender: sender, - Amount: 100000, - Memo: []byte("0x7F8ae2ABb69A558CE6bAd546f25F0464D9e09e5B4955a3F38ff86ae92A914445099caa8eA2B9bA32"), + Amount: 12000000, + Memo: expectedMemo, Slot: txResult.Slot, Asset: "", } @@ -138,9 +142,114 @@ func Test_ParseInboundAsDeposit(t *testing.T) { }) } +func Test_ParseInboundAsDepositAndCall(t *testing.T) { + // ARRANGE + txHash := "5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa" + chain := chains.SolanaDevnet + + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + // create observer + chainParams := sample.ChainParams(chain.ChainId) + chainParams.GatewayAddress = testutils.OldSolanaGatewayAddressDevnet + require.NoError(t, err) + + // expected result + // solana e2e deployer account + sender := "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ" + // example contract deployed during e2e test, read from tx result + expectedReceiver := []byte{117, 160, 106, 140, 37, 135, 57, 218, 223, 226, 53, 45, 87, 151, 61, 239, 158, 231, 162, 186} + expectedMsg := []byte("hello lamports") + expectedDeposit := &Deposit{ + Sender: sender, + Amount: 1200000, + Memo: append(expectedReceiver, expectedMsg...), + Slot: txResult.Slot, + Asset: "", + } + + t.Run("should parse inbound event deposit SOL and call", func(t *testing.T) { + // ACT + deposit, err := ParseInboundAsDeposit(tx, 0, txResult.Slot) + require.NoError(t, err) + + // ASSERT + require.EqualValues(t, expectedDeposit, deposit) + }) + + t.Run("should skip parsing if wrong discriminator", func(t *testing.T) { + // ARRANGE + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + instruction := tx.Message.Instructions[0] + + // try deserializing instruction as a 'deposit' + var inst DepositInstructionParams + err = borsh.Deserialize(&inst, instruction.Data) + require.NoError(t, err) + + // serialize it back with wrong discriminator + data, err := borsh.Serialize(DepositInstructionParams{ + Amount: inst.Amount, + Discriminator: DiscriminatorDepositSPL, + Receiver: inst.Receiver, + }) + require.NoError(t, err) + + tx.Message.Instructions[0].Data = data + + // ACT + deposit, err := ParseInboundAsDeposit(tx, 0, txResult.Slot) + + // ASSERT + require.NoError(t, err) + require.Nil(t, deposit) + }) + + t.Run("should fail if wrong accounts count", func(t *testing.T) { + // ARRANGE + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + // append one more account to instruction + tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) + tx.Message.Instructions[0].Accounts = append(tx.Message.Instructions[0].Accounts, 4) + + // ACT + deposit, err := ParseInboundAsDeposit(tx, 0, txResult.Slot) + + // ASSERT + require.Error(t, err) + require.Nil(t, deposit) + }) + + t.Run("should fail if first account is not signer", func(t *testing.T) { + // ARRANGE + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + // switch account places + tx.Message.Instructions[0].Accounts[0] = 1 + tx.Message.Instructions[0].Accounts[1] = 0 + + // ACT + deposit, err := ParseInboundAsDeposit(tx, 0, txResult.Slot) + + // ASSERT + require.Error(t, err) + require.Nil(t, deposit) + }) +} + func Test_ParseInboundAsDepositSPL(t *testing.T) { // ARRANGE - txHash := "aY8yLDze6nHSRi7L5REozKAZY1aAyPJ6TfibiqQL5JGwgSBkYux5z5JfXs5ed8LZqpXUy4VijoU3x15mBd66ZGE" + txHash := "5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN" chain := chains.SolanaDevnet txResult := LoadSolanaInboundTxResult(t, txHash) @@ -159,10 +268,114 @@ func Test_ParseInboundAsDepositSPL(t *testing.T) { require.NoError(t, err) expectedDeposit := &Deposit{ Sender: sender, - Amount: 500000, + Amount: 12000000, Memo: expectedMemo, Slot: txResult.Slot, - Asset: "4GddKQ7baJpMyKna7bPPnhh7UQtpzfSGL1FgZ31hj4mp", // SPL address + Asset: "BTmtL9Dh2DcwhPntEbjo3rSWpmz1EhXsmohSC7CGSEWw", // SPL address + } + + t.Run("should parse inbound event deposit SPL", func(t *testing.T) { + // ACT + deposit, err := ParseInboundAsDepositSPL(tx, 0, txResult.Slot) + require.NoError(t, err) + + // ASSERT + require.EqualValues(t, expectedDeposit, deposit) + }) + + t.Run("should skip parsing if wrong discriminator", func(t *testing.T) { + // ARRANGE + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + instruction := tx.Message.Instructions[0] + + // try deserializing instruction as a 'deposit_spl' + var inst DepositSPLInstructionParams + err = borsh.Deserialize(&inst, instruction.Data) + require.NoError(t, err) + + // serialize it back with wrong discriminator + data, err := borsh.Serialize(DepositInstructionParams{ + Amount: inst.Amount, + Discriminator: DiscriminatorDeposit, + Receiver: inst.Receiver, + }) + require.NoError(t, err) + + tx.Message.Instructions[0].Data = data + + // ACT + deposit, err := ParseInboundAsDepositSPL(tx, 0, txResult.Slot) + + // ASSERT + require.NoError(t, err) + require.Nil(t, deposit) + }) + + t.Run("should fail if wrong accounts count", func(t *testing.T) { + // ARRANGE + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + // append one more account to instruction + tx.Message.AccountKeys = append(tx.Message.AccountKeys, solana.MustPublicKeyFromBase58(sample.SolanaAddress(t))) + tx.Message.Instructions[0].Accounts = append(tx.Message.Instructions[0].Accounts, 4) + + // ACT + deposit, err := ParseInboundAsDepositSPL(tx, 0, txResult.Slot) + + // ASSERT + require.Error(t, err) + require.Nil(t, deposit) + }) + + t.Run("should fail if first account is not signer", func(t *testing.T) { + // ARRANGE + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + // switch account places + tx.Message.Instructions[0].Accounts[0] = 1 + tx.Message.Instructions[0].Accounts[1] = 0 + + // ACT + deposit, err := ParseInboundAsDepositSPL(tx, 0, txResult.Slot) + + // ASSERT + require.Error(t, err) + require.Nil(t, deposit) + }) +} + +func Test_ParseInboundAsDepositAndCallSPL(t *testing.T) { + // ARRANGE + txHash := "22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o" + chain := chains.SolanaDevnet + + txResult := LoadSolanaInboundTxResult(t, txHash) + tx, err := txResult.Transaction.GetTransaction() + require.NoError(t, err) + + // create observer + chainParams := sample.ChainParams(chain.ChainId) + chainParams.GatewayAddress = testutils.OldSolanaGatewayAddressDevnet + + // expected result + // solana e2e deployer account + sender := "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ" + // example contract deployed during e2e test, read from tx result + expectedReceiver := []byte{213, 254, 240, 66, 1, 154, 250, 238, 39, 131, 9, 45, 5, 2, 190, 192, 20, 31, 103, 209} + expectedMsg := []byte("hello spl tokens") + expectedDeposit := &Deposit{ + Sender: sender, + Amount: 12000000, + Memo: append(expectedReceiver, expectedMsg...), + Slot: txResult.Slot, + Asset: "7d4ehzE4WNgithQZMyQFDhmHyN6rQNTEC7re1bsRN7TX", // SPL address } t.Run("should parse inbound event deposit SPL", func(t *testing.T) { diff --git a/pkg/contracts/solana/testdata/22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o.json b/pkg/contracts/solana/testdata/22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o.json new file mode 100644 index 0000000000..c6336051b6 --- /dev/null +++ b/pkg/contracts/solana/testdata/22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o.json @@ -0,0 +1,98 @@ +{ + "slot": 1111, + "blockTime": 1733490207, + "transaction": { + "signatures": [ + "22s5ERRRZmZXAuDMRdwUU33VnWZ7m8NHUZM6hyLH52JQPz5R7mXEkFcvHx88ujq3xDnt3z7sZdZ21JK2FC7vPw1o" + ], + "message": { + "accountKeys": [ + "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ", + "9dcAyYG4bawApZocwZSyJBi9Mynf5EuKAJfifXdfkqik", + "EKZTsmjEMAbkStqWdoqyeFh4DkgB9zXr9yxwBHzcy2Sn", + "C2vKeBZ6yeUdeFC22UR82Drnj5AaXe4oKLgFQMJRpeDv", + "2zioTPUGiVwr4XZgDCy34qo2EbHQBU86jTU568rnKKri", + "7d4ehzE4WNgithQZMyQFDhmHyN6rQNTEC7re1bsRN7TX", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "11111111111111111111111111111111", + "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" + ], + "header": { + "numRequiredSignatures": 1, + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 5 + }, + "recentBlockhash": "HXK99VqYfwMDMEaJmxPgLLLygUUYpPry1mPkSJkwekDC", + "instructions": [ + { + "programIdIndex": 8, + "accounts": [ + 0, + 1, + 4, + 5, + 6, + 2, + 3, + 7 + ], + "data": "Q6siP5YLNCNi7eDfNNdsuMhgSAJvKMZiozqaPmi1rzGWxAJNPaUg8WK1a5v9GRriHGnLDuwmBZ9L" + } + ] + } + }, + "meta": { + "err": null, + "fee": 5000, + "preBalances": [ + 99967505600, + 25947680, + 2039280, + 2039280, + 946560, + 1461600, + 929020800, + 1, + 1141440 + ], + "postBalances": [ + 99965500600, + 27947680, + 2039280, + 2039280, + 946560, + 1461600, + 929020800, + 1, + 1141440 + ], + "innerInstructions": [ + { + "index": 0, + "instructions": [] + } + ], + "preTokenBalances": [], + "postTokenBalances": [], + "logMessages": [ + "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d invoke [1] Program log: Instruction: DepositSplTokenAndCall", + "Program 11111111111111111111111111111111 invoke [2]", + "Program 11111111111111111111111111111111 success Program", + "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]", + "Program log: Instruction: Transfer Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 179934 compute units", + "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", + "Program log: deposit spl token successfully", + "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 25580 of 200000 compute units Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d success" + ], + "status": { + "Ok": null + }, + "rewards": [], + "loadedAddresses": { + "readonly": [], + "writable": [] + }, + "computeUnitsConsumed": 274902869112 + }, + "version": 0 +} \ No newline at end of file diff --git a/pkg/contracts/solana/testdata/5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa.json b/pkg/contracts/solana/testdata/5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa.json new file mode 100644 index 0000000000..e25d5d77a4 --- /dev/null +++ b/pkg/contracts/solana/testdata/5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa.json @@ -0,0 +1,77 @@ +{ + "slot": 1111, + "blockTime": 1733490207, + "transaction": { + "signatures": [ + "5b7ShhHf8dvUjUBHgMvgH8FFqpfAd7vAGygZLaeNPhugXtY5fatPSACVkn13o7sw6Awob8EJnrwAuiKYqvi7ZkHa" + ], + "message": { + "accountKeys": [ + "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ", + "9dcAyYG4bawApZocwZSyJBi9Mynf5EuKAJfifXdfkqik", + "11111111111111111111111111111111", + "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" + ], + "header": { + "numRequiredSignatures": 1, + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 2 + }, + "recentBlockhash": "GvTg9tWxC6UUwVESdZnB3s1GHLjSU7yozNvRgNAxinRv", + "instructions": [ + { + "programIdIndex": 3, + "accounts": [ + 0, + 1, + 2 + ], + "data": "6FaQ3EVJmN4pEjM4cxGpTqEDQdfmnwd2p3Eq9k4ZyfqZxp47KXcRDt1NghRzX186nuLHj4Nt1G" + } + ] + } + }, + "meta": { + "err": null, + "fee": 5000, + "preBalances": [ + 99994074880, + 1447680, + 1, + 1141440 + ], + "postBalances": [ + 99990869880, + 4647680, + 1, + 1141440 + ], + "innerInstructions": [ + { + "index": 0, + "instructions": [] + } + ], + "preTokenBalances": [], + "postTokenBalances": [], + "logMessages": [ + "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d invoke [1]", + "Program log: Instruction: DepositAndCall", + "Program 11111111111111111111111111111111 invoke [2]", + "Program 11111111111111111111111111111111 success", + "Program log: 37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ deposits 1200000 lamports to PDA with fee 2000000; receiver [117, 160, 106, 140, 37, 135, 57, 218, 223, 226, 53, 45, 87, 151, 61, 239, 158, 231, 162, 186]", + "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 26765 of 200000 compute units", + "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d success" + ], + "status": { + "Ok": null + }, + "rewards": [], + "loadedAddresses": { + "readonly": [], + "writable": [] + }, + "computeUnitsConsumed": 274902869112 + }, + "version": 0 +} \ No newline at end of file diff --git a/pkg/contracts/solana/testdata/aY8yLDze6nHSRi7L5REozKAZY1aAyPJ6TfibiqQL5JGwgSBkYux5z5JfXs5ed8LZqpXUy4VijoU3x15mBd66ZGE.json b/pkg/contracts/solana/testdata/5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN.json similarity index 66% rename from pkg/contracts/solana/testdata/aY8yLDze6nHSRi7L5REozKAZY1aAyPJ6TfibiqQL5JGwgSBkYux5z5JfXs5ed8LZqpXUy4VijoU3x15mBd66ZGE.json rename to pkg/contracts/solana/testdata/5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN.json index ad4c5e62f5..8f7587d30e 100644 --- a/pkg/contracts/solana/testdata/aY8yLDze6nHSRi7L5REozKAZY1aAyPJ6TfibiqQL5JGwgSBkYux5z5JfXs5ed8LZqpXUy4VijoU3x15mBd66ZGE.json +++ b/pkg/contracts/solana/testdata/5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN.json @@ -1,18 +1,18 @@ { - "slot": 539, - "blockTime": 1730986363, + "slot": 1111, + "blockTime": 1733490207, "transaction": { "signatures": [ - "aY8yLDze6nHSRi7L5REozKAZY1aAyPJ6TfibiqQL5JGwgSBkYux5z5JfXs5ed8LZqpXUy4VijoU3x15mBd66ZGE" + "5bXSQaq6BY1WhhF3Qm4pLHXxuyM9Mz1MrdMeoCFbimxw4uv11raQgAj4HGULPEQExPKB231rMhm6666dQMwf9fNN" ], "message": { "accountKeys": [ "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ", - "HX8BXQKVw1xpoyDXMr9ujyrrpSYRWcFZ4oB3fRHpM8V7", - "5EVPJV5hjwYGYko2pSykSdJG5ZfBbMEDhYci2PrqQmby", "9dcAyYG4bawApZocwZSyJBi9Mynf5EuKAJfifXdfkqik", - "8vquQi8xNxxBTsohf1u8xQHYbo7Fv8BEWCJz63RJSaeE", - "4GddKQ7baJpMyKna7bPPnhh7UQtpzfSGL1FgZ31hj4mp", + "E4mtFD4qnS2LCe3w5Mg89WW9JUutEbV3r5ZLBZfZx7rd", + "2kFYgZBrX221xLxGPQ5ZZ39PRHY5XorAy3ZG3DfASQWb", + "7CTgzWesnoMvLMU6pGgPEht1C4maV4bctBYoSdeunVGv", + "BTmtL9Dh2DcwhPntEbjo3rSWpmz1EhXsmohSC7CGSEWw", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", "11111111111111111111111111111111", "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" @@ -22,21 +22,21 @@ "numReadonlySignedAccounts": 0, "numReadonlyUnsignedAccounts": 5 }, - "recentBlockhash": "5ZB2NWKwp86t47ojCHPjRyd5vMKSWBdhxqDdtSZVPUj", + "recentBlockhash": "EbmoPGUZfc9mMjbQosueT1QLoAnYfv9BKQKG8XnV3G5V", "instructions": [ { "programIdIndex": 8, "accounts": [ 0, - 3, + 1, 4, 5, 6, - 1, 2, + 3, 7 ], - "data": "5JndgWCNHDyr2qQccK9VM1NxJFrVbUDvG2hfAxRC5z6nPPAVPsj7q3A" + "data": "fAzySRSzJpZy3QTj6orjk9erMQpjbB1y9AnSSN1CH74CyovkC" } ] } @@ -45,23 +45,25 @@ "err": null, "fee": 5000, "preBalances": [ - 99992030600, + 99967505600, + 25947680, 2039280, 2039280, - 1447680, 946560, 1461600, 929020800, + 1, 1141440 ], "postBalances": [ - 99992025600, + 99965500600, + 27947680, 2039280, 2039280, - 1447680, 946560, 1461600, 929020800, + 1, 1141440 ], "innerInstructions": [ @@ -75,10 +77,13 @@ "logMessages": [ "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d invoke [1]", "Program log: Instruction: DepositSplToken", + "Program 11111111111111111111111111111111 invoke [2]", + "Program 11111111111111111111111111111111 success", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]", - "Program log: Instruction: Transfer Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 181038 compute units", - "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success Program log: deposit spl token successfully", - "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 24017 of 200000 compute units", + "Program log: Instruction: Transfer", + "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 178636 compute units", + "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", + "Program log: deposit spl token successfully Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 26871 of 200000 compute units", "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d success" ], "status": { diff --git a/pkg/contracts/solana/testdata/MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json b/pkg/contracts/solana/testdata/8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px.json similarity index 50% rename from pkg/contracts/solana/testdata/MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json rename to pkg/contracts/solana/testdata/8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px.json index cf7edb3b81..1b2634c1e6 100644 --- a/pkg/contracts/solana/testdata/MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json +++ b/pkg/contracts/solana/testdata/8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px.json @@ -1,13 +1,13 @@ { - "slot": 321701608, - "blockTime": 1724732369, + "slot": 510, + "blockTime": 1733489933, "transaction": { "signatures": [ - "MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j" + "8UeJoxY6RbMg6bffsUtZ9f79vSnd4HCRdk5EQgNbAEDYQWXNraiKDtGDZBLp91oyF5eQyWdv6pEwW1vcitiB4px" ], "message": { "accountKeys": [ - "AS48jKNQsDGkEdDvfwu1QpqjtqbCadrAq9nGXjFmdX3Z", + "37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ", "9dcAyYG4bawApZocwZSyJBi9Mynf5EuKAJfifXdfkqik", "11111111111111111111111111111111", "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" @@ -17,12 +17,16 @@ "numReadonlySignedAccounts": 0, "numReadonlyUnsignedAccounts": 2 }, - "recentBlockhash": "41txNvjedo2eu6aAofQfyLskAcgtrtgch9RpqnrKcv1a", + "recentBlockhash": "21uLyS3mMAjoDoXuxqQBkin9uD34KQi5KCEjKMJLWGEu", "instructions": [ { "programIdIndex": 3, - "accounts": [0, 1, 2], - "data": "4ALHYcAj3zFsNjmfeq7nDK1E8BsxRQRzhLjrqzmjYzL97Qkiz4rP1iQePmFAehfFEET7uczYLhhEVhtndBYNNm6ekHSkgsLzYDeSD2JSudHa6D5tqhVGjvXZ7qEouPiy9eptZfuYHE9X" + "accounts": [ + 0, + 1, + 2 + ], + "data": "2qe8pjwrUAq1Zb3QcoA54F3X4CLY59fgwDRKuGM4qzy3EutcWx" } ] } @@ -30,16 +34,19 @@ "meta": { "err": null, "fee": 5000, - "preBalances": [9999364000, 1001447680, 1, 1141440], - "postBalances": [9999259000, 1001547680, 1, 1141440], + "preBalances": [99994074880, 1447680, 1, 1141440], + "postBalances": [99980069880, 15447680, 1, 1141440], "innerInstructions": [ { "index": 0, "instructions": [ { "programIdIndex": 2, - "accounts": [0, 1], - "data": "3Bxs4ThwQbE4vyj5" + "accounts": [ + 0, + 1 + ], + "data": "3Bxs4NNUejChDhvX" } ] } @@ -48,17 +55,22 @@ "postTokenBalances": [], "logMessages": [ "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d invoke [1]", - "Program log: Instruction: Deposit", + "Program log: Instruction: Deposit", "Program 11111111111111111111111111111111 invoke [2]", - "Program 11111111111111111111111111111111 success", - "Program log: AS48jKNQsDGkEdDvfwu1QpqjtqbCadrAq9nGXjFmdX3Z deposits 100000 lamports to PDA", - "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 17006 of 200000 compute units", + "Program 11111111111111111111111111111111 success", + "Program log: 37yGiHAnLvWZUNVwu9esp74YQFqxU1qHCbABkDvRddUQ deposits 12000000 lamports to PDA with fee 2000000; receiver [16, 63, 217, 34, 79, 0, 206, 48, 19, 233, 86, 41, 229, 45, 252, 49, 216, 5, 214, 141]", + "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 26307 of 200000 compute units", "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d success" ], - "status": { "Ok": null }, + "status": { + "Ok": null + }, "rewards": [], - "loadedAddresses": { "readonly": [], "writable": [] }, + "loadedAddresses": { + "readonly": [], + "writable": [] + }, "computeUnitsConsumed": 17006 }, "version": 0 -} +} \ No newline at end of file diff --git a/zetaclient/chains/solana/observer/inbound_test.go b/zetaclient/chains/solana/observer/inbound_test.go index 28c31f04db..025d72592a 100644 --- a/zetaclient/chains/solana/observer/inbound_test.go +++ b/zetaclient/chains/solana/observer/inbound_test.go @@ -26,8 +26,8 @@ var ( func Test_FilterInboundEventAndVote(t *testing.T) { // load archived inbound vote tx result - // https://explorer.solana.com/tx/MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j?cluster=devnet - txHash := "MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j" + // https://explorer.solana.com/tx/24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr?cluster=devnet + txHash := "24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr" chain := chains.SolanaDevnet txResult := testutils.LoadSolanaInboundTxResult(t, TestDataDir, chain.ChainId, txHash, false) @@ -62,7 +62,7 @@ func Test_FilterInboundEventAndVote(t *testing.T) { func Test_FilterInboundEvents(t *testing.T) { // load archived inbound deposit tx result // https://explorer.solana.com/tx/MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j?cluster=devnet - txHash := "MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j" + txHash := "24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr" chain := chains.SolanaDevnet txResult := testutils.LoadSolanaInboundTxResult(t, TestDataDir, chain.ChainId, txHash, false) @@ -77,14 +77,15 @@ func Test_FilterInboundEvents(t *testing.T) { require.NoError(t, err) // expected result - sender := "AS48jKNQsDGkEdDvfwu1QpqjtqbCadrAq9nGXjFmdX3Z" + sender := "HgTpiVRvjUPUcWLzdmCgdadu1GceJNgBWLoN9r66p8o3" + expectedMemo := []byte{109, 163, 11, 250, 101, 232, 90, 22, 176, 91, 206, 56, 70, 51, 158, 210, 188, 116, 99, 22} eventExpected := &clienttypes.InboundEvent{ SenderChainID: chain.ChainId, Sender: sender, Receiver: sender, TxOrigin: sender, - Amount: 100000, - Memo: []byte("0x7F8ae2ABb69A558CE6bAd546f25F0464D9e09e5B4955a3F38ff86ae92A914445099caa8eA2B9bA32"), + Amount: 100000000, + Memo: expectedMemo, BlockNumber: txResult.Slot, TxHash: txHash, Index: 0, // not a EVM smart contract call diff --git a/zetaclient/testdata/solana/chain_901_inbound_tx_result_24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr.json b/zetaclient/testdata/solana/chain_901_inbound_tx_result_24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr.json new file mode 100644 index 0000000000..92c3db0852 --- /dev/null +++ b/zetaclient/testdata/solana/chain_901_inbound_tx_result_24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr.json @@ -0,0 +1,102 @@ +{ + "slot": 345001398, + "blockTime": 1733460726, + "transaction": { + "signatures": [ + "24GzWsxYCFcwwJ2rzAsWwWC85aYKot6Rz3jWnBP1GvoAg5A9f1WinYyvyKseYM52q6i3EkotZdJuQomGGq5oxRYr" + ], + "message": { + "accountKeys": [ + "HgTpiVRvjUPUcWLzdmCgdadu1GceJNgBWLoN9r66p8o3", + "2f9SLuUNb7TNeM6gzBwT4ZjbL5ZyKzzHg1Ce9yiquEjj", + "11111111111111111111111111111111", + "ComputeBudget111111111111111111111111111111", + "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" + ], + "header": { + "numRequiredSignatures": 1, + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 3 + }, + "recentBlockhash": "6Fu7CVZSkaSys51PsAJJ5T2UF9HrZo9QksRNWJQfSPK2", + "instructions": [ + { + "programIdIndex": 3, + "accounts": [], + "data": "3gJqkocMWaMm" + }, + { + "programIdIndex": 3, + "accounts": [], + "data": "Fj2Eoy" + }, + { + "programIdIndex": 4, + "accounts": [ + 0, + 1, + 2 + ], + "data": "2qe8pjwrUAq1a3qRZeuPZdkpNS1yz6BHwpJmE23Nou9YcXuyxZ" + } + ] + } + }, + "meta": { + "err": null, + "fee": 25000, + "preBalances": [ + 10000000000, + 21298797680, + 1, + 1, + 1141440 + ], + "postBalances": [ + 9899975000, + 21398797680, + 1, + 1, + 1141440 + ], + "innerInstructions": [ + { + "index": 0, + "instructions": [ + { + "programIdIndex": 2, + "accounts": [ + 0, + 1 + ], + "data": "3Bxs411Dtc7pkFQj" + } + ] + } + ], + "preTokenBalances": [], + "postTokenBalances": [], + "logMessages": [ + "Program ComputeBudget111111111111111111111111111111 invoke [1]", + "Program ComputeBudget111111111111111111111111111111 success", + "Program ComputeBudget111111111111111111111111111111 invoke [1]", + "Program ComputeBudget111111111111111111111111111111 success", + "Program ZETAjseVjuFsxdRxo6MmTCvqFwb3ZHUx56Co3vCmGis invoke [1]", + "Program log: Instruction: Deposit Program 11111111111111111111111111111111 invoke [2]", + "Program 11111111111111111111111111111111 success", + "Program log: HgTpiVRvjUPUcWLzdmCgdadu1GceJNgBWLoN9r66p8o3 deposits 100000000 lamports to PDA; receiver [109, 163, 11, 250, 101, 232, 90, 22, 176, 91, 206, 56, 70, 51, 158, 210, 188, 116, 99, 22]", + "Program ZETAjseVjuFsxdRxo6MmTCvqFwb3ZHUx56Co3vCmGis consumed 23371 of 199700 compute units", + "Program ZETAjseVjuFsxdRxo6MmTCvqFwb3ZHUx56Co3vCmGis success" + ], + "status": { + "Ok": null + }, + "rewards": [], + "loadedAddresses": { + "readonly": [], + "writable": [] + }, + "computeUnitsConsumed": 274899583472 + }, + "version": 0 +} \ No newline at end of file diff --git a/zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json b/zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json deleted file mode 100644 index cf7edb3b81..0000000000 --- a/zetaclient/testdata/solana/chain_901_inbound_tx_result_MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "slot": 321701608, - "blockTime": 1724732369, - "transaction": { - "signatures": [ - "MS3MPLN7hkbyCZFwKqXcg8fmEvQMD74fN6Ps2LSWXJoRxPW5ehaxBorK9q1JFVbqnAvu9jXm6ertj7kT7HpYw1j" - ], - "message": { - "accountKeys": [ - "AS48jKNQsDGkEdDvfwu1QpqjtqbCadrAq9nGXjFmdX3Z", - "9dcAyYG4bawApZocwZSyJBi9Mynf5EuKAJfifXdfkqik", - "11111111111111111111111111111111", - "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" - ], - "header": { - "numRequiredSignatures": 1, - "numReadonlySignedAccounts": 0, - "numReadonlyUnsignedAccounts": 2 - }, - "recentBlockhash": "41txNvjedo2eu6aAofQfyLskAcgtrtgch9RpqnrKcv1a", - "instructions": [ - { - "programIdIndex": 3, - "accounts": [0, 1, 2], - "data": "4ALHYcAj3zFsNjmfeq7nDK1E8BsxRQRzhLjrqzmjYzL97Qkiz4rP1iQePmFAehfFEET7uczYLhhEVhtndBYNNm6ekHSkgsLzYDeSD2JSudHa6D5tqhVGjvXZ7qEouPiy9eptZfuYHE9X" - } - ] - } - }, - "meta": { - "err": null, - "fee": 5000, - "preBalances": [9999364000, 1001447680, 1, 1141440], - "postBalances": [9999259000, 1001547680, 1, 1141440], - "innerInstructions": [ - { - "index": 0, - "instructions": [ - { - "programIdIndex": 2, - "accounts": [0, 1], - "data": "3Bxs4ThwQbE4vyj5" - } - ] - } - ], - "preTokenBalances": [], - "postTokenBalances": [], - "logMessages": [ - "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d invoke [1]", - "Program log: Instruction: Deposit", - "Program 11111111111111111111111111111111 invoke [2]", - "Program 11111111111111111111111111111111 success", - "Program log: AS48jKNQsDGkEdDvfwu1QpqjtqbCadrAq9nGXjFmdX3Z deposits 100000 lamports to PDA", - "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d consumed 17006 of 200000 compute units", - "Program 94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d success" - ], - "status": { "Ok": null }, - "rewards": [], - "loadedAddresses": { "readonly": [], "writable": [] }, - "computeUnitsConsumed": 17006 - }, - "version": 0 -}