From ef3f09f408a72a5a57f0e210038894d0d4447ad7 Mon Sep 17 00:00:00 2001 From: Jeremy Wei Date: Fri, 10 Nov 2023 14:16:54 -0500 Subject: [PATCH 1/3] add EventData to ResultEvent --- cmd/tendermint/commands/reset.go | 2 ++ internal/rpc/core/events.go | 7 ++++--- rpc/client/local/local.go | 1 + rpc/coretypes/responses.go | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/tendermint/commands/reset.go b/cmd/tendermint/commands/reset.go index 1c50d7923..9ae5c3c83 100644 --- a/cmd/tendermint/commands/reset.go +++ b/cmd/tendermint/commands/reset.go @@ -1,6 +1,7 @@ package commands import ( + "fmt" "os" "path/filepath" @@ -182,6 +183,7 @@ func ResetPeerStore(dbDir string) error { } func MakeUnsafeResetAllCommand(conf *config.Config, logger log.Logger) *cobra.Command { + fmt.Println("MakeUnsafeResetAllCommand") var keyType string resetAllCmd := &cobra.Command{ diff --git a/internal/rpc/core/events.go b/internal/rpc/core/events.go index 621977c66..6713d218f 100644 --- a/internal/rpc/core/events.go +++ b/internal/rpc/core/events.go @@ -83,9 +83,10 @@ func (env *Environment) Subscribe(ctx context.Context, req *coretypes.RequestSub // We have a message to deliver to the client. resp := callInfo.RPCRequest.MakeResponse(&coretypes.ResultEvent{ - Query: req.Query, - Data: msg.LegacyData(), - Events: msg.Events(), + Query: req.Query, + Data: msg.LegacyData(), + Events: msg.Events(), + EventData: msg.Data(), }) wctx, cancel := context.WithTimeout(opctx, 10*time.Second) err = callInfo.WSConn.WriteRPCResponse(wctx, resp) diff --git a/rpc/client/local/local.go b/rpc/client/local/local.go index 0b2b5205a..d02fd3b15 100644 --- a/rpc/client/local/local.go +++ b/rpc/client/local/local.go @@ -274,6 +274,7 @@ func (c *Local) eventsRoutine(ctx context.Context, sub eventbus.Subscription, su SubscriptionID: msg.SubscriptionID(), Query: qstr, Data: msg.LegacyData(), + EventData: msg.Data(), Events: msg.Events(), }: case <-ctx.Done(): diff --git a/rpc/coretypes/responses.go b/rpc/coretypes/responses.go index cce419b55..203e3ea1c 100644 --- a/rpc/coretypes/responses.go +++ b/rpc/coretypes/responses.go @@ -329,6 +329,7 @@ type ResultEvent struct { Query string Data types.LegacyEventData Events []abci.Event + EventData types.EventData } type resultEventJSON struct { @@ -336,6 +337,7 @@ type resultEventJSON struct { Query string `json:"query"` Data json.RawMessage `json:"data"` Events map[string][]string `json:"events"` + EventData types.EventData `json:"event_data"` } func (r ResultEvent) MarshalJSON() ([]byte, error) { @@ -348,6 +350,7 @@ func (r ResultEvent) MarshalJSON() ([]byte, error) { Query: r.Query, Data: evt, Events: compactEvents(r.Events), + EventData: r.EventData, }) } @@ -362,6 +365,7 @@ func (r *ResultEvent) UnmarshalJSON(data []byte) error { r.SubscriptionID = res.SubscriptionID r.Query = res.Query r.Events = decompactEvents(res.Events) + r.EventData = res.EventData return nil } From f31c31846c491a8a6574acd093e7a775f55fe6b8 Mon Sep 17 00:00:00 2001 From: Jeremy Wei Date: Fri, 10 Nov 2023 14:17:57 -0500 Subject: [PATCH 2/3] remove print --- cmd/tendermint/commands/reset.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/tendermint/commands/reset.go b/cmd/tendermint/commands/reset.go index 9ae5c3c83..1c50d7923 100644 --- a/cmd/tendermint/commands/reset.go +++ b/cmd/tendermint/commands/reset.go @@ -1,7 +1,6 @@ package commands import ( - "fmt" "os" "path/filepath" @@ -183,7 +182,6 @@ func ResetPeerStore(dbDir string) error { } func MakeUnsafeResetAllCommand(conf *config.Config, logger log.Logger) *cobra.Command { - fmt.Println("MakeUnsafeResetAllCommand") var keyType string resetAllCmd := &cobra.Command{ From dad0aea9a6b097c1f308f526aa8da587122b8ff9 Mon Sep 17 00:00:00 2001 From: Jeremy Wei Date: Mon, 13 Nov 2023 17:13:41 -0500 Subject: [PATCH 3/3] deprecate legacy event data --- internal/rpc/core/events.go | 7 +++---- rpc/client/local/local.go | 3 +-- rpc/client/rpc_test.go | 6 ++++-- rpc/coretypes/responses.go | 6 +----- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/internal/rpc/core/events.go b/internal/rpc/core/events.go index 6713d218f..7dfcbd30c 100644 --- a/internal/rpc/core/events.go +++ b/internal/rpc/core/events.go @@ -83,10 +83,9 @@ func (env *Environment) Subscribe(ctx context.Context, req *coretypes.RequestSub // We have a message to deliver to the client. resp := callInfo.RPCRequest.MakeResponse(&coretypes.ResultEvent{ - Query: req.Query, - Data: msg.LegacyData(), - Events: msg.Events(), - EventData: msg.Data(), + Query: req.Query, + Data: msg.Data(), + Events: msg.Events(), }) wctx, cancel := context.WithTimeout(opctx, 10*time.Second) err = callInfo.WSConn.WriteRPCResponse(wctx, resp) diff --git a/rpc/client/local/local.go b/rpc/client/local/local.go index d02fd3b15..51a43eb39 100644 --- a/rpc/client/local/local.go +++ b/rpc/client/local/local.go @@ -273,8 +273,7 @@ func (c *Local) eventsRoutine(ctx context.Context, sub eventbus.Subscription, su case outc <- coretypes.ResultEvent{ SubscriptionID: msg.SubscriptionID(), Query: qstr, - Data: msg.LegacyData(), - EventData: msg.Data(), + Data: msg.Data(), Events: msg.Events(), }: case <-ctx.Done(): diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index 2316b5f58..29fbec3e6 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/base64" + "fmt" "math" "net/http" @@ -21,6 +22,7 @@ import ( "github.com/tendermint/tendermint/crypto/encoding" "github.com/tendermint/tendermint/internal/mempool" rpccore "github.com/tendermint/tendermint/internal/rpc/core" + tmjson "github.com/tendermint/tendermint/libs/json" "github.com/tendermint/tendermint/libs/log" tmmath "github.com/tendermint/tendermint/libs/math" @@ -495,9 +497,9 @@ func TestClientMethodCalls(t *testing.T) { for i := int64(0); i < 3; i++ { event := <-eventCh - blockEvent, ok := event.Data.(types.LegacyEventDataNewBlock) + blockEvent, ok := event.Data.(types.EventDataNewBlock) if !ok { - blockEventPtr, okPtr := event.Data.(*types.LegacyEventDataNewBlock) + blockEventPtr, okPtr := event.Data.(*types.EventDataNewBlock) if okPtr { blockEvent = *blockEventPtr } diff --git a/rpc/coretypes/responses.go b/rpc/coretypes/responses.go index 203e3ea1c..122a679ee 100644 --- a/rpc/coretypes/responses.go +++ b/rpc/coretypes/responses.go @@ -327,9 +327,8 @@ type ( type ResultEvent struct { SubscriptionID string Query string - Data types.LegacyEventData + Data types.EventData Events []abci.Event - EventData types.EventData } type resultEventJSON struct { @@ -337,7 +336,6 @@ type resultEventJSON struct { Query string `json:"query"` Data json.RawMessage `json:"data"` Events map[string][]string `json:"events"` - EventData types.EventData `json:"event_data"` } func (r ResultEvent) MarshalJSON() ([]byte, error) { @@ -350,7 +348,6 @@ func (r ResultEvent) MarshalJSON() ([]byte, error) { Query: r.Query, Data: evt, Events: compactEvents(r.Events), - EventData: r.EventData, }) } @@ -365,7 +362,6 @@ func (r *ResultEvent) UnmarshalJSON(data []byte) error { r.SubscriptionID = res.SubscriptionID r.Query = res.Query r.Events = decompactEvents(res.Events) - r.EventData = res.EventData return nil }