Skip to content

abci: Refactor tagigng events using list of lists#3643

Merged
melekes merged 43 commits intotendermint:developfrom
alexanderbez:bez/1859-tags-refactor-list-of-lists
Jun 12, 2019
Merged

abci: Refactor tagigng events using list of lists#3643
melekes merged 43 commits intotendermint:developfrom
alexanderbez:bez/1859-tags-refactor-list-of-lists

Conversation

@alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented May 8, 2019

This PR introduces a fundamental breaking change to the structure of ABCI response and tx tags and the way they're processed. Namely, the SDK can support more complex and aggregated events for distribution and slashing. In addition, block responses can include duplicate keys in events.

  • Implement new Event type. An event has a type and a list of KV pairs (ie. list-of-lists). Typical events may look like:
"rewards": [{"amount": "5000uatom", "validator": "...", "recipient": "..."}]
"sender": [{"address": "...", "balance": "100uatom"}]

The events are indexed by {even.type}.{even.attribute[i].key}/.... In this case a client would subscribe or query for rewards.recipient='...'

  • ABCI response types and related types now include Events []Event instead of Tags []cmn.KVPair.
  • PubSub logic now publishes/matches against map[string][]string instead of map[string]string to support duplicate keys in response events (from Subscribing to tx event works for multiple kvpairs using same key #1385). A match is successful if the value is found in the slice of strings.

closes: #1859
closes: #2905


  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

@codecov-io
Copy link

codecov-io commented May 10, 2019

Codecov Report

Merging #3643 into develop will decrease coverage by 0.04%.
The diff coverage is 78.94%.

@@             Coverage Diff             @@
##           develop    #3643      +/-   ##
===========================================
- Coverage    63.37%   63.33%   -0.05%     
===========================================
  Files          218      218              
  Lines        18247    18220      -27     
===========================================
- Hits         11564    11539      -25     
+ Misses        5709     5705       -4     
- Partials       974      976       +2
Impacted Files Coverage Δ
rpc/core/types/responses.go 36.36% <ø> (ø) ⬆️
rpc/core/events.go 0% <0%> (ø) ⬆️
libs/pubsub/pubsub.go 87.95% <100%> (ø) ⬆️
abci/example/kvstore/kvstore.go 82.85% <100%> (+1.03%) ⬆️
libs/pubsub/query/empty.go 50% <100%> (ø) ⬆️
libs/pubsub/subscription.go 91.3% <50%> (+8.69%) ⬆️
libs/pubsub/query/query.go 70.5% <63.15%> (+0.75%) ⬆️
state/txindex/kv/kv.go 77.29% <87.5%> (+0.96%) ⬆️
privval/signer_service_endpoint.go 80% <0%> (-9.1%) ⬇️
libs/db/remotedb/remotedb.go 35.89% <0%> (-4.94%) ⬇️
... and 6 more

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@xla xla changed the title Tagging Refactor: Events using List of Lists abci: Refactor tagigng events using list of lists Jun 4, 2019
@alexanderbez
Copy link
Contributor Author

@ebuchman @ethanfrey I've updated various tests, implemented new ones, and updated docs. Mind giving this another look?

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@liamsi liamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, too!

I would hold off from merging until
#3643 (comment)
#3643 (comment)
are clarified / resolved.

@melekes melekes merged commit ab08354 into tendermint:develop Jun 12, 2019
melekes added a commit that referenced this pull request Jun 12, 2019
Follow up to #3643

* update changelog

* do not ignore errors returned by PublishWithEvents
@alexanderbez alexanderbez deleted the bez/1859-tags-refactor-list-of-lists branch June 27, 2019 01:20
@crossle
Copy link

crossle commented Oct 8, 2019

if use the github.com/tendermint/tendermint v0.32.3, parse the transaction will error unknown field "tags" in types.ResponseDeliverTx how to compatible?

@melekes
Copy link
Contributor

melekes commented Oct 8, 2019

You will need to switch to a new format (i.e. rename tags to events and change the structure a bit)

events := []types.Event{
		{
			Type: "app",
			Attributes: []cmn.KVPair{
				{Key: []byte("creator"), Value: []byte("Cosmoshi Netowoko")},
				{Key: []byte("key"), Value: key},
			},
		},
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants