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

refactor(abci): add msg index to event #15845

Merged
merged 33 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8c4cd92
add msg index to event
tac0turtle Apr 14, 2023
424280a
changelog
tac0turtle Apr 14, 2023
b267802
further manual testing
tac0turtle Apr 14, 2023
006035b
address comments
tac0turtle Apr 14, 2023
7d073fe
move comment
tac0turtle Apr 14, 2023
bb7b7b0
Merge branch 'main' into marko/15017
tac0turtle Apr 15, 2023
7298214
Merge branch 'main' into marko/15017
tac0turtle Apr 17, 2023
a8943bd
Merge branch 'main' into marko/15017
tac0turtle Apr 17, 2023
b9c7e0a
Merge branch 'main' into marko/15017
tac0turtle Apr 18, 2023
a56cb3e
add upgrading and docs
tac0turtle Apr 18, 2023
79ef241
fix tests
tac0turtle Apr 18, 2023
6ff441c
fix tests
tac0turtle Apr 18, 2023
313c926
events
tac0turtle Apr 18, 2023
b28eb6d
events
tac0turtle Apr 18, 2023
8a5744c
Merge branch 'main' into marko/15017
tac0turtle Apr 18, 2023
4c0b513
revert comment
tac0turtle Apr 19, 2023
cf63181
fix imports
tac0turtle Apr 19, 2023
a0daa86
fix tests
tac0turtle Apr 19, 2023
eb9fb1d
Merge branch 'main' into marko/15017
tac0turtle Apr 19, 2023
612ff6e
fix tests
tac0turtle Apr 19, 2023
6a535e5
try waiting for the next block to check things
tac0turtle Apr 19, 2023
de66a3c
remove waitfor
tac0turtle Apr 19, 2023
ce7804e
tets
tac0turtle Apr 19, 2023
0b25697
Merge branch 'main' into marko/15017
tac0turtle Apr 20, 2023
4b4b21a
some changes
tac0turtle Apr 20, 2023
fa821d6
Merge branch 'main' into marko/15017
facundomedica Apr 20, 2023
64e55b5
Merge branch 'main' into marko/15017
facundomedica Apr 20, 2023
ccd7e7f
fix group e2e test
facundomedica Apr 20, 2023
47f9ed6
cleaner err check
facundomedica Apr 20, 2023
1d0cb1f
cleaner err check
facundomedica Apr 20, 2023
b5059bd
fix event check
facundomedica Apr 20, 2023
23284d8
Merge branch 'main' into marko/15017
tac0turtle Apr 22, 2023
84f62be
fix auth test case
tac0turtle Apr 24, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (x/staking) [#15701](https://github.com/cosmos/cosmos-sdk/pull/15701) `HistoricalInfoKey` now has a binary format.
* (grpc-web) [#14652](https://github.com/cosmos/cosmos-sdk/pull/14652) Use same port for gRPC-Web and the API server.
* (abci) [#15845](https://github.com/cosmos/cosmos-sdk/pull/15845) Add `msg_index` to all event attributes to associate events and messages
* (abci) [#15845](https://github.com/cosmos/cosmos-sdk/pull/15845) Remove duplicating events in `logs`

### CLI Breaking Changes

Expand Down
16 changes: 10 additions & 6 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package baseapp
import (
"fmt"
"sort"
"strings"
"strconv"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
Expand Down Expand Up @@ -773,7 +773,6 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
// Handler does not exist for a given message route. Otherwise, a reference to a
// Result is returned. The caller must not commit state if an error is returned.
func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*sdk.Result, error) {
msgLogs := make(sdk.ABCIMessageLogs, 0, len(msgs))
events := sdk.EmptyEvents()
var msgResponses []*codectypes.Any

Expand All @@ -797,11 +796,18 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
// create message events
msgEvents := createEvents(msgResult.GetEvents(), msg)

// append message events, data and logs
// append message events and data
//
// Note: Each message result's data must be length-prefixed in order to
// separate each result.
events = events.AppendEvents(msgEvents)
var me = make(sdk.Events, len(msgEvents))

// append message index to all events
for j, event := range msgEvents {
me[j] = event.AppendAttributes(sdk.NewAttribute("msg_index", strconv.Itoa(i)))
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
}

events = events.AppendEvents(me)

// Each individual sdk.Result that went through the MsgServiceRouter
// (which should represent 99% of the Msgs now, since everyone should
Expand All @@ -816,7 +822,6 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s
msgResponses = append(msgResponses, msgResponse)
}

msgLogs = append(msgLogs, sdk.NewABCIMessageLog(uint32(i), msgResult.Log, msgEvents))
}

data, err := makeABCIData(msgResponses)
Expand All @@ -826,7 +831,6 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s

return &sdk.Result{
Data: data,
Log: strings.TrimSpace(msgLogs.String()),
Events: events.ToABCIEvents(),
MsgResponses: msgResponses,
}, nil
Expand Down
4 changes: 4 additions & 0 deletions server/mock/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ func (ms multiStore) LatestVersion() int64 {
panic("not implemented")
}

func (ms multiStore) WorkingHash() []byte {
panic("not implemented")
}

var _ storetypes.KVStore = kvStore{}

type kvStore struct {
Expand Down