Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [\#790](https://github.com/cosmos/evm/pull/790) fix panic in historical query due to missing EvmCoinInfo.
- [\#800](https://github.com/cosmos/evm/pull/800) Fix denom exponent validation in virtual fee deduct in vm module.
- [\#817](https://github.com/cosmos/evm/pull/817) Align GetCoinbaseAddress to handle empty proposer address in contexts like CheckTx where proposer doesn't exist.
- [\#814](https://github.com/cosmos/evm/pull/814) Fix duplicated events in post tx processor.
- [\#816](https://github.com/cosmos/evm/pull/816) Avoid nil pointer when RPC requests execute before evmCoinInfo initialization in PreBlock with defaultEvmCoinInfo fallback.

## v0.5.0
Expand Down
15 changes: 14 additions & 1 deletion tests/integration/x/vm/test_state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)

const TestPostProcessingEventType = "test_post_processing_event"

func (s *KeeperTestSuite) TestContextSetConsensusParams() {
// set new value of max gas in consensus params
maxGas := int64(123456789)
Expand Down Expand Up @@ -675,6 +677,7 @@ func (s *KeeperTestSuite) TestApplyTransactionWithTxPostProcessing() {
keeper.NewMultiEvmHooks(
&testHooks{
postProcessing: func(ctx sdk.Context, sender common.Address, msg core.Message, receipt *gethtypes.Receipt) error {
ctx.EventManager().EmitEvent(sdk.NewEvent(TestPostProcessingEventType))
return nil
},
},
Expand Down Expand Up @@ -706,7 +709,17 @@ func (s *KeeperTestSuite) TestApplyTransactionWithTxPostProcessing() {
s.Require().Equal(senderBefore.Sub(sdkmath.NewIntFromBigInt(transferAmt)), senderAfter)
s.Require().Equal(recipientBefore.Add(sdkmath.NewIntFromBigInt(transferAmt)), recipientAfter)
},
func(s *KeeperTestSuite) {},
func(s *KeeperTestSuite) {
// check if the event emitted exactly once
events := s.Network.GetContext().EventManager().Events()
var postProcessingEvents []sdk.Event
for _, event := range events {
if event.Type == TestPostProcessingEventType {
postProcessingEvents = append(postProcessingEvents, event)
}
}
s.Require().Len(postProcessingEvents, 1)
},
},
{
"pass - evm tx succeeds, post processing is called but fails, the balance is unchanged",
Expand Down
7 changes: 0 additions & 7 deletions x/vm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
return nil, errorsmod.Wrap(err, "failed to extract sender address from ethereum transaction")
}

eventsLen := len(tmpCtx.EventManager().Events())

// Only call PostTxProcessing if there are hooks set, to avoid calling commitFn unnecessarily
if !k.HasHooks() {
// If there are no hooks, we can commit the state immediately if the tx is successful
Expand Down Expand Up @@ -297,11 +295,6 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
} else {
res.Logs = types.NewLogsFromEth(receipt.Logs)
}

events := tmpCtx.EventManager().Events()
if len(events) > eventsLen {
ctx.EventManager().EmitEvents(events[eventsLen:])
}
}
}

Expand Down
Loading