diff --git a/x/auxiliary/keeper/msg_server.go b/x/auxiliary/keeper/msg_server.go index 4ef1b2237..d68d68afe 100644 --- a/x/auxiliary/keeper/msg_server.go +++ b/x/auxiliary/keeper/msg_server.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/axelarnetwork/axelar-core/utils/events" @@ -15,13 +14,11 @@ import ( var _ types.MsgServiceServer = msgServer{} type msgServer struct { - cdc codec.Codec router *baseapp.MsgServiceRouter } -func NewMsgServer(cdc codec.Codec, msgServiceRouter *baseapp.MsgServiceRouter) types.MsgServiceServer { +func NewMsgServer(msgServiceRouter *baseapp.MsgServiceRouter) types.MsgServiceServer { return msgServer{ - cdc, msgServiceRouter, } } diff --git a/x/auxiliary/keeper/msg_server_test.go b/x/auxiliary/keeper/msg_server_test.go index 0e0892e6b..9a20725d0 100644 --- a/x/auxiliary/keeper/msg_server_test.go +++ b/x/auxiliary/keeper/msg_server_test.go @@ -46,7 +46,7 @@ func TestBatching(t *testing.T) { return votetypes.NewVoteRequest(sender, vote.PollID(rand.PosI64()), evmTypes.NewVoteEvents(nexus.ChainName(rand.NormalizedStr(3)))) }, int(rand2.I64Between(2, 10))) - msgServer = keeper.NewMsgServer(appParams.MakeEncodingConfig().Codec, msgServiceRouter) + msgServer = keeper.NewMsgServer(msgServiceRouter) }) withBatchRequest := func() GivenStatement { diff --git a/x/auxiliary/module.go b/x/auxiliary/module.go index eaf5cb29a..b8eb02318 100644 --- a/x/auxiliary/module.go +++ b/x/auxiliary/module.go @@ -119,7 +119,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } - types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrAuxiliary, Logger: logger}, keeper.NewMsgServer(am.cdc, am.router)) + types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrAuxiliary, Logger: logger}, keeper.NewMsgServer(am.router)) } // BeginBlock executes all state transitions this module requires at the beginning of each new block diff --git a/x/auxiliary/types/msg_batch.go b/x/auxiliary/types/msg_batch.go index 158799eff..a9cf1d463 100644 --- a/x/auxiliary/types/msg_batch.go +++ b/x/auxiliary/types/msg_batch.go @@ -42,10 +42,6 @@ func (m BatchRequest) ValidateBasic() error { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message signer mismatch") } - if !equalAccAddresses(msg.GetSigners(), m.GetSigners()) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "message signer mismatch") - } - if err := msg.ValidateBasic(); err != nil { return err } diff --git a/x/auxiliary/types/msg_batch_test.go b/x/auxiliary/types/msg_batch_test.go new file mode 100644 index 000000000..620124aa6 --- /dev/null +++ b/x/auxiliary/types/msg_batch_test.go @@ -0,0 +1,33 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/assert" + + "github.com/axelarnetwork/axelar-core/testutils/rand" + "github.com/axelarnetwork/axelar-core/x/auxiliary/types" + evmtypes "github.com/axelarnetwork/axelar-core/x/evm/types" +) + +func TestBatchRequest_ValidateBasic(t *testing.T) { + t.Run("should fail with nested batch", func(t *testing.T) { + sender := rand.AccAddr() + + linkRequest := evmtypes.NewLinkRequest(sender, rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5)) + batch := types.NewBatchRequest(sender, []sdk.Msg{linkRequest}) + message := types.NewBatchRequest(sender, []sdk.Msg{linkRequest, batch}) + + assert.ErrorContains(t, message.ValidateBasic(), "nested batch") + }) + + t.Run("should fail with different signers", func(t *testing.T) { + + message := types.NewBatchRequest(rand.AccAddr(), []sdk.Msg{ + evmtypes.NewLinkRequest(rand.AccAddr(), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5), rand.NormalizedStr(5)), + }) + + assert.ErrorContains(t, message.ValidateBasic(), "message signer mismatch") + }) +}