From 22ba482b586122d37eb028330f7f725e7f16a5f1 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 8 Aug 2022 13:10:32 -0400 Subject: [PATCH 1/2] chore: fee payer event (#12850) * updates * updates * updates (cherry picked from commit a6159feab6772019f3f307c7e591b0d52c3c197b) # Conflicts: # x/auth/ante/fee.go # x/auth/tx/service_test.go --- types/events.go | 1 + x/auth/ante/fee.go | 7 +++++++ x/auth/tx/service_test.go | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/types/events.go b/types/events.go index 9c495a9da2a7..3c372b42b4db 100644 --- a/types/events.go +++ b/types/events.go @@ -228,6 +228,7 @@ var ( AttributeKeyAccountSequence = "acc_seq" AttributeKeySignature = "signature" AttributeKeyFee = "fee" + AttributeKeyFeePayer = "fee_payer" EventTypeMessage = "message" diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 3542136568a0..e676c4de5386 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -116,9 +116,16 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } } +<<<<<<< HEAD events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()), )} +======= + events := sdk.Events{ + sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFee, fee.String())), + sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String())), + } +>>>>>>> a6159feab (chore: fee payer event (#12850)) ctx.EventManager().EmitEvents(events) return next(ctx, tx, simulate) diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index e4b2567deb06..5ddfaed2c95d 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -144,8 +144,19 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() { } else { s.Require().NoError(err) // Check the result and gas used are correct. +<<<<<<< HEAD s.Require().Equal(len(res.GetResult().GetEvents()), 6) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. +======= + // + // The 13 events are: + // - Sending Fee to the pool: coin_spent, coin_received, transfer and message.sender= + // - tx.* events: tx.fee, tx.acc_seq, tx.signature + // - Sending Amount to recipient: coin_spent, coin_received, transfer and message.sender= + // - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend + s.Require().Equal(len(res.GetResult().GetEvents()), 14) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. + s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. +>>>>>>> a6159feab (chore: fee payer event (#12850)) } }) } @@ -185,8 +196,14 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() { err = val.ClientCtx.Codec.UnmarshalJSON(res, &result) s.Require().NoError(err) // Check the result and gas used are correct. +<<<<<<< HEAD s.Require().Equal(len(result.GetResult().GetEvents()), 6) // 1 coin recv, 1 coin spent,1 transfer, 3 messages. s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. +======= + s.Require().Len(result.GetResult().MsgResponses, 1) + s.Require().Equal(len(result.GetResult().GetEvents()), 14) // See TestSimulateTx_GRPC for the 13 events. + s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, jus +>>>>>>> a6159feab (chore: fee payer event (#12850)) } }) } From f46a7859a41a1d5f00450dad09ada640655b9519 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 8 Aug 2022 15:03:52 -0400 Subject: [PATCH 2/2] fix conflicts --- x/auth/ante/fee.go | 8 +------- x/auth/tx/service_test.go | 17 ----------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index e676c4de5386..5d83158daaa9 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -116,16 +116,10 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } } -<<<<<<< HEAD - events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx, - sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()), - )} -======= events := sdk.Events{ - sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFee, fee.String())), + sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String())), sdk.NewEvent(sdk.EventTypeTx, sdk.NewAttribute(sdk.AttributeKeyFeePayer, deductFeesFrom.String())), } ->>>>>>> a6159feab (chore: fee payer event (#12850)) ctx.EventManager().EmitEvents(events) return next(ctx, tx, simulate) diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index 5ddfaed2c95d..e4b2567deb06 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -144,19 +144,8 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() { } else { s.Require().NoError(err) // Check the result and gas used are correct. -<<<<<<< HEAD s.Require().Equal(len(res.GetResult().GetEvents()), 6) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. -======= - // - // The 13 events are: - // - Sending Fee to the pool: coin_spent, coin_received, transfer and message.sender= - // - tx.* events: tx.fee, tx.acc_seq, tx.signature - // - Sending Amount to recipient: coin_spent, coin_received, transfer and message.sender= - // - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend - s.Require().Equal(len(res.GetResult().GetEvents()), 14) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. - s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. ->>>>>>> a6159feab (chore: fee payer event (#12850)) } }) } @@ -196,14 +185,8 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() { err = val.ClientCtx.Codec.UnmarshalJSON(res, &result) s.Require().NoError(err) // Check the result and gas used are correct. -<<<<<<< HEAD s.Require().Equal(len(result.GetResult().GetEvents()), 6) // 1 coin recv, 1 coin spent,1 transfer, 3 messages. s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. -======= - s.Require().Len(result.GetResult().MsgResponses, 1) - s.Require().Equal(len(result.GetResult().GetEvents()), 14) // See TestSimulateTx_GRPC for the 13 events. - s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, jus ->>>>>>> a6159feab (chore: fee payer event (#12850)) } }) }