From 87c4792c6884c34eaa4d04c52d17b0621d3d364a Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 4 Dec 2024 11:17:45 -0600 Subject: [PATCH 1/4] use the ZEVM address decoded from memo as Receiver in MsgVoteInbound --- e2e/e2etests/test_solana_deposit.go | 1 + e2e/e2etests/test_solana_deposit_call.go | 1 + e2e/e2etests/test_spl_deposit.go | 1 + e2e/e2etests/test_spl_deposit_and_call.go | 1 + zetaclient/chains/solana/observer/inbound.go | 6 +++--- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e/e2etests/test_solana_deposit.go b/e2e/e2etests/test_solana_deposit.go index d46a56c015..eb238c8c58 100644 --- a/e2e/e2etests/test_solana_deposit.go +++ b/e2e/e2etests/test_solana_deposit.go @@ -29,6 +29,7 @@ func TestSolanaDeposit(r *runner.E2ERunner, args []string) { cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, sig.String(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "solana_deposit") utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) + require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex()) // get ERC20 SOL balance after deposit balanceAfter, err := r.SOLZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress()) diff --git a/e2e/e2etests/test_solana_deposit_call.go b/e2e/e2etests/test_solana_deposit_call.go index 2692936a9e..7719b1c0a3 100644 --- a/e2e/e2etests/test_solana_deposit_call.go +++ b/e2e/e2etests/test_solana_deposit_call.go @@ -29,6 +29,7 @@ func TestSolanaDepositAndCall(r *runner.E2ERunner, args []string) { cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, sig.String(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "solana_deposit_and_call") utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) + require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, contractAddr.Hex()) // check if example contract has been called, bar value should be set to amount utils.MustHaveCalledExampleContract(r, contract, depositAmount) diff --git a/e2e/e2etests/test_spl_deposit.go b/e2e/e2etests/test_spl_deposit.go index e20ff5879a..7bf1ffa7a9 100644 --- a/e2e/e2etests/test_spl_deposit.go +++ b/e2e/e2etests/test_spl_deposit.go @@ -42,6 +42,7 @@ func TestSPLDeposit(r *runner.E2ERunner, args []string) { cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, sig.String(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "solana_deposit_spl") utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) + require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex()) // verify balances are updated pdaBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentFinalized) diff --git a/e2e/e2etests/test_spl_deposit_and_call.go b/e2e/e2etests/test_spl_deposit_and_call.go index d7e11cd999..51730b815e 100644 --- a/e2e/e2etests/test_spl_deposit_and_call.go +++ b/e2e/e2etests/test_spl_deposit_and_call.go @@ -49,6 +49,7 @@ func TestSPLDepositAndCall(r *runner.E2ERunner, args []string) { cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, sig.String(), r.CctxClient, r.Logger, r.CctxTimeout) r.Logger.CCTX(*cctx, "solana_deposit_spl_and_call") utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined) + require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, contractAddr.Hex()) // check if example contract has been called, bar value should be set to amount utils.MustHaveCalledExampleContract(r, contract, big.NewInt(int64(amount))) diff --git a/zetaclient/chains/solana/observer/inbound.go b/zetaclient/chains/solana/observer/inbound.go index 2b30b5818d..6eab1242ac 100644 --- a/zetaclient/chains/solana/observer/inbound.go +++ b/zetaclient/chains/solana/observer/inbound.go @@ -212,7 +212,7 @@ func (ob *Observer) FilterInboundEvents(txResult *rpc.GetTransactionResult) ([]* events = append(events, &clienttypes.InboundEvent{ SenderChainID: ob.Chain().ChainId, Sender: deposit.Sender, - Receiver: deposit.Sender, // receiver is pulled out from memo + Receiver: "", // receiver will be pulled out from memo later TxOrigin: deposit.Sender, Amount: deposit.Amount, Memo: deposit.Memo, @@ -240,7 +240,7 @@ func (ob *Observer) FilterInboundEvents(txResult *rpc.GetTransactionResult) ([]* events = append(events, &clienttypes.InboundEvent{ SenderChainID: ob.Chain().ChainId, Sender: deposit.Sender, - Receiver: deposit.Sender, // receiver is pulled out from memo + Receiver: "", // receiver will be pulled out from memo later TxOrigin: deposit.Sender, Amount: deposit.Amount, Memo: deposit.Memo, @@ -288,7 +288,7 @@ func (ob *Observer) BuildInboundVoteMsgFromEvent(event *clienttypes.InboundEvent event.Sender, event.SenderChainID, event.Sender, - event.Sender, + event.Receiver, ob.ZetacoreClient().Chain().ChainId, cosmosmath.NewUint(event.Amount), hex.EncodeToString(event.Memo), From 01c636ae372a597983d48c6b201b23f1a9ea9847 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 4 Dec 2024 11:33:30 -0600 Subject: [PATCH 2/4] add Receiver check in unit test --- zetaclient/chains/solana/observer/inbound_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zetaclient/chains/solana/observer/inbound_test.go b/zetaclient/chains/solana/observer/inbound_test.go index 0b118ae55e..7f72c33605 100644 --- a/zetaclient/chains/solana/observer/inbound_test.go +++ b/zetaclient/chains/solana/observer/inbound_test.go @@ -123,11 +123,13 @@ func Test_BuildInboundVoteMsgFromEvent(t *testing.T) { t.Run("should return vote msg for valid event", func(t *testing.T) { sender := sample.SolanaAddress(t) - memo := sample.EthAddress().Bytes() - event := sample.InboundEvent(chain.ChainId, sender, sender, 1280, []byte(memo)) + receiver := sample.EthAddress() + event := sample.InboundEvent(chain.ChainId, sender, "", 1280, receiver.Bytes()) msg := ob.BuildInboundVoteMsgFromEvent(event) require.NotNil(t, msg) + require.Equal(t, sender, msg.Sender) + require.Equal(t, receiver.Hex(), msg.Receiver) }) t.Run("should return nil if failed to decode memo", func(t *testing.T) { From 61692ea79783844ad0d84447ac3ce0abfa902f4d Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Wed, 4 Dec 2024 11:37:36 -0600 Subject: [PATCH 3/4] add changelog entry --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 9c482d64f9..6e5294d6d7 100644 --- a/changelog.md +++ b/changelog.md @@ -19,6 +19,7 @@ * [3206](https://github.com/zeta-chain/node/pull/3206) - skip Solana unsupported transaction version to not block inbound observation * [3184](https://github.com/zeta-chain/node/pull/3184) - zetaclient should not retry if inbound vote message validation fails * [3225](https://github.com/zeta-chain/node/pull/3225) - use separate database file names for btc signet and testnet4 +* [3242](https://github.com/zeta-chain/node/pull/3242) - set the `Receiver` of `MsgVoteInbound` to the address pulled from solana memo ## v23.0.0 From bd2b3de17eacf68454b221ba2c2fbab75155d7d2 Mon Sep 17 00:00:00 2001 From: Charlie Chen Date: Mon, 9 Dec 2024 22:55:23 -0600 Subject: [PATCH 4/4] fix unit test --- zetaclient/chains/solana/observer/inbound_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zetaclient/chains/solana/observer/inbound_test.go b/zetaclient/chains/solana/observer/inbound_test.go index 7f72c33605..ff0ad101a2 100644 --- a/zetaclient/chains/solana/observer/inbound_test.go +++ b/zetaclient/chains/solana/observer/inbound_test.go @@ -81,7 +81,7 @@ func Test_FilterInboundEvents(t *testing.T) { eventExpected := &clienttypes.InboundEvent{ SenderChainID: chain.ChainId, Sender: sender, - Receiver: sender, + Receiver: "", TxOrigin: sender, Amount: 100000, Memo: []byte("0x7F8ae2ABb69A558CE6bAd546f25F0464D9e09e5B4955a3F38ff86ae92A914445099caa8eA2B9bA32"),