diff --git a/core/gas/service.go b/core/gas/service.go index 8903b4686bb5..7077ef1a51b9 100644 --- a/core/gas/service.go +++ b/core/gas/service.go @@ -38,6 +38,7 @@ type Meter interface { Consume(amount Gas, descriptor string) error Refund(amount Gas, descriptor string) error Remaining() Gas + Consumed() Gas Limit() Gas } diff --git a/core/testing/gas/service_mocks.go b/core/testing/gas/service_mocks.go index a38e7d5c074d..c328455997a1 100644 --- a/core/testing/gas/service_mocks.go +++ b/core/testing/gas/service_mocks.go @@ -100,6 +100,20 @@ func (mr *MockMeterMockRecorder) Consume(amount, descriptor interface{}) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Consume", reflect.TypeOf((*MockMeter)(nil).Consume), amount, descriptor) } +// Consumed mocks base method. +func (m *MockMeter) Consumed() gas.Gas { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Consumed") + ret0, _ := ret[0].(gas.Gas) + return ret0 +} + +// Consumed indicates an expected call of Consumed. +func (mr *MockMeterMockRecorder) Consumed() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Consumed", reflect.TypeOf((*MockMeter)(nil).Consumed)) +} + // Limit mocks base method. func (m *MockMeter) Limit() gas.Gas { m.ctrl.T.Helper() diff --git a/runtime/gas.go b/runtime/gas.go index 75d711f9f4da..64d564827bbf 100644 --- a/runtime/gas.go +++ b/runtime/gas.go @@ -36,6 +36,10 @@ func (cgm CoreGasmeter) Consume(amount gas.Gas, descriptor string) error { return nil } +func (cgm CoreGasmeter) Consumed() gas.Gas { + return cgm.gm.GasConsumed() +} + func (cgm CoreGasmeter) Refund(amount gas.Gas, descriptor string) error { cgm.gm.RefundGas(amount, descriptor) return nil @@ -55,14 +59,14 @@ type SDKGasMeter struct { } func (gm SDKGasMeter) GasConsumed() storetypes.Gas { - return gm.gm.Remaining() + return gm.gm.Consumed() } func (gm SDKGasMeter) GasConsumedToLimit() storetypes.Gas { if gm.IsPastLimit() { return gm.gm.Limit() } - return gm.gm.Remaining() + return gm.gm.Consumed() } func (gm SDKGasMeter) GasRemaining() storetypes.Gas { diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 2c4eb43ff312..4f4f682a7862 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -1468,10 +1468,10 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { event1.Attributes = append( event1.Attributes, coreevent.Attribute{Key: banktypes.AttributeKeyRecipient, Value: acc2StrAddr}, + coreevent.Attribute{Key: sdk.AttributeKeySender, Value: acc0StrAddr}, + coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}, ) - event1.Attributes = append( - event1.Attributes, - coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}) + event2 := coreevent.Event{ Type: banktypes.EventTypeTransfer, Attributes: []coreevent.Attribute{}, @@ -1479,9 +1479,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { event2.Attributes = append( event2.Attributes, coreevent.Attribute{Key: banktypes.AttributeKeyRecipient, Value: acc3StrAddr}, - ) - event2.Attributes = append( - event2.Attributes, + coreevent.Attribute{Key: sdk.AttributeKeySender, Value: acc0StrAddr}, coreevent.Attribute{Key: sdk.AttributeKeyAmount, Value: newCoins2.String()}, ) // events are shifted due to the funding account events diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 31354c1b8566..063417b6ca03 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -172,6 +172,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input, if err := k.EventService.EventManager(ctx).EmitKV( types.EventTypeTransfer, event.NewAttribute(types.AttributeKeyRecipient, out.Address), + event.NewAttribute(types.AttributeKeySender, input.Address), event.NewAttribute(sdk.AttributeKeyAmount, out.Coins.String()), ); err != nil { return err