Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events emitted by CanWithdrawInvariant will be saved by tendermint #4868

Closed
4 tasks
whunmr opened this issue Aug 8, 2019 · 2 comments · Fixed by #4873
Closed
4 tasks

Events emitted by CanWithdrawInvariant will be saved by tendermint #4868

whunmr opened this issue Aug 8, 2019 · 2 comments · Fixed by #4873
Labels

Comments

@whunmr
Copy link

whunmr commented Aug 8, 2019

Summary of Bug

In CanWithdrawInvariant we used a cached context, but shared the ctx.eventManager

ctx, _ = ctx.CacheContext()

Then after invariants checks, the emitted events will append into the ctx.eventManager
and finally save by tendermint(saveABCIResponses)

Version

$ git rev-parse HEAD
07a0a1bda6647e9f859d8206b80413b372f8feeb
$ git describe
v0.36.0-rc1

Steps to Reproduce

  • start gaiad app and enable the invariant check in everyblock(--inv-check-period=1)
  • after debugging we can see the event emitted by CanWithdrawInvariant further call WithdrawDelegationRewards will be save by saveABCIResponses.

debugging logs

> github.com/coinexchain/dex/app.(*CetChainApp).EndBlocker() /home/j/lab/dex/app/app.go:549 (PC: 0x1429cc3)
Current event: 65124
   544:		ret := app.mm.EndBlock(ctx, req)
   545:		if app.msgQueProducer.IsOpenToggle() {
   546:			ret.Events = FilterMsgsOnlyKafka(ret.Events)
   547:			app.notifyComplete(ret.Events)
   548:		}
=> 549:		return ret
(dlv) p ret.Events
[]github.com/tendermint/tendermint/abci/types.Event len: 12, cap: 12, [
	{
		Type: "transfer",
		Attributes: []github.com/tendermint/tendermint/libs/common.KVPair len: 1, cap: 1, [
			(*"github.com/tendermint/tendermint/libs/common.KVPair")(0xc0023647d0),
		],
		XXX_NoUnkeyedLiteral: struct {} {},
		XXX_unrecognized: []uint8 len: 0, cap: 0, nil,
		XXX_sizecache: 0,},
……..

	{
		Type: "withdraw_rewards",
		Attributes: []github.com/tendermint/tendermint/libs/common.KVPair len: 2, cap: 2, [
			(*"github.com/tendermint/tendermint/libs/common.KVPair")(0xc0025fdc20),
			(*"github.com/tendermint/tendermint/libs/common.KVPair")(0xc0025fdc70),
		],
		XXX_NoUnkeyedLiteral: struct {} {},
		XXX_unrecognized: []uint8 len: 0, cap: 0, nil,
		XXX_sizecache: 0,},
	{
		Type: "withdraw_rewards",
		Attributes: []github.com/tendermint/tendermint/libs/common.KVPair len: 2, cap: 2, [
			(*"github.com/tendermint/tendermint/libs/common.KVPair")(0xc0025fdd60),
			(*"github.com/tendermint/tendermint/libs/common.KVPair")(0xc0025fddb0),
		],
		XXX_NoUnkeyedLiteral: struct {} {},
		XXX_unrecognized: []uint8 len: 0, cap: 0, nil,
		XXX_sizecache: 0,},
]
(dlv) n

code change proposal

func (c Context) CacheContext() (cc Context, writeCache func()) {
	cms := c.MultiStore().CacheMultiStore()
--      cc = c.WithMultiStore(cms)
++      cc = c.WithMultiStore(cms).WithEventManager(NewEventManager())
	return cc, cms.Write
}

we have debugged the changes, the events emitted in invariants will be dropped .


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@whunmr whunmr changed the title CanWithdrawInvariant will emit events which will be saved by tendermint Events emitted by CanWithdrawInvariant will be saved by tendermint Aug 8, 2019
@alexanderbez
Copy link
Contributor

Great catch @whunmr -- I'm in favor of the solution you proposed.

@whunmr
Copy link
Author

whunmr commented Aug 9, 2019

Thanks for the fix @alexanderbez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants