diff --git a/x/crosschain/client/cli/cli_cctx.go b/x/crosschain/client/cli/cli_cctx.go index 070764ca44..2418efd536 100644 --- a/x/crosschain/client/cli/cli_cctx.go +++ b/x/crosschain/client/cli/cli_cctx.go @@ -166,6 +166,7 @@ func CmdCCTXInboundVoter() *cobra.Command { 250_000, argsCoinType, argsAsset, + 0, ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/crosschain/client/integrationtests/cli_helpers.go b/x/crosschain/client/integrationtests/cli_helpers.go index e86f1021c5..a1c536626f 100644 --- a/x/crosschain/client/integrationtests/cli_helpers.go +++ b/x/crosschain/client/integrationtests/cli_helpers.go @@ -201,6 +201,7 @@ func GetBallotIdentifier(message string) string { 250_000, common.CoinType_Zeta, "", + 0, ) return msg.Digest() } diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index c575598cf1..ebae270dc5 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -150,6 +150,7 @@ func (k Keeper) ProcessZRC20WithdrawalEvent(ctx sdk.Context, event *zrc20.ZRC20W gasLimit.Uint64()+uint64(event.Raw.Index), foreignCoin.CoinType, foreignCoin.Asset, + 0, ) sendHash := msg.Digest() @@ -223,6 +224,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC 90000+uint64(event.Raw.Index), common.CoinType_Zeta, "", + 0, ) sendHash := msg.Digest() diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx.go b/x/crosschain/types/message_vote_on_observed_inbound_tx.go index 12da3a6963..b94b0567a4 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx.go @@ -30,6 +30,7 @@ func NewMsgVoteOnObservedInboundTx( gasLimit uint64, coinType common.CoinType, asset string, + eventIndex uint, ) *MsgVoteOnObservedInboundTx { return &MsgVoteOnObservedInboundTx{ Creator: creator, @@ -45,6 +46,7 @@ func NewMsgVoteOnObservedInboundTx( GasLimit: gasLimit, CoinType: coinType, Asset: asset, + EventIndex: uint64(eventIndex), } } diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go index 9fba3d71bb..777fb6f244 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go @@ -37,6 +37,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, }, { @@ -55,6 +56,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: sdkerrors.ErrInvalidAddress, }, @@ -74,6 +76,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: types.ErrInvalidChainID, }, @@ -93,6 +96,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: types.ErrInvalidChainID, }, @@ -112,6 +116,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, }, err: sdkerrors.ErrInvalidRequest, }, @@ -145,6 +150,7 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { GasLimit: 42, CoinType: common.CoinType_Zeta, Asset: sample.String(), + EventIndex: 42, } hash := msg.Digest() require.NotEmpty(t, hash, "hash should not be empty") @@ -226,4 +232,10 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { msg2.Asset = sample.StringRandom(r, 32) hash2 = msg2.Digest() require.NotEqual(t, hash, hash2, "asset should change hash") + + // event index used + msg2 = msg + msg2.EventIndex = 43 + hash2 = msg2.Digest() + require.NotEqual(t, hash, hash2, "event index should change hash") } diff --git a/zetaclient/tx.go b/zetaclient/tx.go index d5d9c89571..307d8e1681 100644 --- a/zetaclient/tx.go +++ b/zetaclient/tx.go @@ -31,8 +31,38 @@ const ( DefaultRetryInterval = 5 ) -func GetInBoundVoteMessage(sender string, senderChain int64, txOrigin string, receiver string, receiverChain int64, amount math.Uint, message string, inTxHash string, inBlockHeight uint64, gasLimit uint64, coinType common.CoinType, asset string, signerAddress string) *types.MsgVoteOnObservedInboundTx { - msg := types.NewMsgVoteOnObservedInboundTx(signerAddress, sender, senderChain, txOrigin, receiver, receiverChain, amount, message, inTxHash, inBlockHeight, gasLimit, coinType, asset) +// GetInBoundVoteMessage returns a new MsgVoteOnObservedInboundTx +func GetInBoundVoteMessage( + sender string, + senderChain int64, + txOrigin string, + receiver string, + receiverChain int64, + amount math.Uint, + message string, + inTxHash string, + inBlockHeight uint64, + gasLimit uint64, + coinType common.CoinType, + asset string, + signerAddress string, +) *types.MsgVoteOnObservedInboundTx { + msg := types.NewMsgVoteOnObservedInboundTx( + signerAddress, + sender, + senderChain, + txOrigin, + receiver, + receiverChain, + amount, + message, + inTxHash, + inBlockHeight, + gasLimit, + coinType, + asset, + 0, + ) return msg }