Skip to content

Commit

Permalink
Fix events in 2-hop scenarios (#1857)
Browse files Browse the repository at this point in the history
* Fix events in 2-hop scenarios

* integration test
  • Loading branch information
codchen authored Sep 19, 2024
1 parent 76931f2 commit fa620f1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
8 changes: 8 additions & 0 deletions contracts/test/CW20toERC20PointerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ describe("CW20 to ERC20 Pointer", function () {
const response = await wasmd.execute(pointer, transferBz, coinsBz);
const receipt = await response.wait();
expect(receipt.status).to.equal(1);

const filter = {
fromBlock: receipt["blockNumber"],
toBlock: 'latest',
topics: [ethers.id("Transfer(address,address,uint256)")]
};
const logs = await ethers.provider.getLogs(filter);
expect(logs.length).to.equal(1);
});
});
});
Expand Down
28 changes: 14 additions & 14 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT
return
}
extraSurplus := sdk.ZeroInt()
surplus, ferr := stateDB.Finalize()
if ferr != nil {
err = ferr
ctx.Logger().Error(fmt.Sprintf("failed to finalize EVM stateDB: %s", err))

telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "errors", "stateDB_finalize"},
1,
[]metrics.Label{
telemetry.NewLabel("type", err.Error()),
},
)
return
}
if isWasmdPrecompileCall {
syntheticReceipt, err := server.GetTransientReceipt(ctx, ctx.TxSum())
if err == nil {
Expand Down Expand Up @@ -132,20 +146,6 @@ func (server msgServer) EVMTransaction(goCtx context.Context, msg *types.MsgEVMT
telemetry.IncrCounter(1, "receipt", "status", "success")
}

surplus, ferr := stateDB.Finalize()
if ferr != nil {
err = ferr
ctx.Logger().Error(fmt.Sprintf("failed to finalize EVM stateDB: %s", err))

telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "errors", "stateDB_finalize"},
1,
[]metrics.Label{
telemetry.NewLabel("type", err.Error()),
},
)
return
}
surplus = surplus.Add(extraSurplus)
bloom := ethtypes.Bloom{}
bloom.SetBytes(receipt.LogsBloom)
Expand Down

0 comments on commit fa620f1

Please sign in to comment.