-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
How to reproduce:
go get github.com/ethanfrey/tenderize
go test github.com/ethanfrey/tenderize/client/tests
Causes a nice panic. If you want the tendermint logs (I turned them off, too much noise for me), check out main_test.go.
After digging through the source, I think I figured out the issue, not sure I should be bold enough to change core code (even on a fork...). The wrong type is returned when new transactions are appended.
tendermint/tendermint/state/execution.go:78 is guaranteed to fire *tmsp.Response_AppendTx cast to *tmsp.Response
proxyCb := func(req *tmsp.Request, res *tmsp.Response) {
switch r := res.Value.(type) {
case *tmsp.Response_AppendTx:
...
eventCache.FireEvent(types.EventStringTx(req.GetAppendTx().Tx), res)
This behavior is expected and used in the tendermint/tendermint/rpc/core/mempool.go:56-58 (BroadcastTxCommit)
eventSwitch.AddListenerForEvent("rpc", types.EventStringTx(tx), func(data events.EventData) {
appendTxResCh <- data.(*tmsp.Response)
})
However, when we subscribe to this event, it expects a completely different type, namely EventDataTx, which we see here:
tendermint/tendermint/rpc/core/events.go:17-18
tmResult := ctypes.TMResult(&ctypes.ResultEvent{event, types.TMEventData(msg)})
wsCtx.TryWriteRPCResponse(rpctypes.NewRPCResponse(wsCtx.Request.ID+"#event", &tmResult, ""))
It all works good until it tried to serialize 😞
I'm not sure how to transform the structs properly, or if that will break some other code...