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

Improve Cosmos events #1747

Closed
NicolasMahe opened this issue Mar 24, 2020 · 3 comments · Fixed by #1769
Closed

Improve Cosmos events #1747

NicolasMahe opened this issue Mar 24, 2020 · 3 comments · Fixed by #1769
Assignees

Comments

@NicolasMahe
Copy link
Member

Improve the cosmos events by using a standard way but applicable to each module.

Currently, the mesg's events are hard to "query" because they use to much the cosmos sdk attributes:

ctx.EventManager().EmitEvent(
	sdk.NewEvent(
		sdk.EventTypeMessage,
		sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
		sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeCreateRunner),
		sdk.NewAttribute(sdk.AttributeKeySender, msg.Address.String()),
		sdk.NewAttribute(types.AttributeHash, runner.Hash.String()),
	),
)

related to #1639

@NicolasMahe
Copy link
Member Author

@antho1404 we spoke about this somewhere, but I cannot find it. Do you know where?

@antho1404
Copy link
Member

I don't see much things on github, there is a start of discussion here #1626 (comment)

I think we had this discussion mostly offline

@antho1404
Copy link
Member

antho1404 commented Mar 31, 2020

For the events we need a few things:

  • An easy way to identify this type of event (I will call namespace)
  • Enough data to know what's the event is about.

For the data, I would recommend having all the information

  • resource: type of resource related to this event eg: service, process, execution...
  • action: type of action on this resource eg: create, update, delete...
  • hash: id of the resource

For the way to identify the event, we need to remove the use of the namespace from cosmos ("message") this is a cosmos namespace and makes it really complicated to filter.

Something that would be nice is to prefix the namespace with mesg to avoid conflicts first then put the resource and action.

mesg:execution:create [{ key: "hash", value: "xxxx" }, { key: "action", value: "create" }, { key: "resource", value: "execution" }]

This way we will be able to query all resources that has been created/updated and we can always query multiple resources with AND in the query. https://docs.tendermint.com/master/rpc/#/Websocket/subscribe

This would be ideal as we will have all the possibility and we can probably do some queries like
mesg:*:create (with CONTAINS "mesg:" AND CONTAINS ":create") to have all the creation of resources for example

If we are not too picky on the disk space we could actually broadcast the same event on all the different namespaces so it will be easier to query and have all information.

mesg                  [{ key: "hash", value: "xxxx" }, { key: "action", value: "create" }, { key: "resource", value: "execution" }]
mesg:execution        [{ key: "hash", value: "xxxx" }, { key: "action", value: "create" }, { key: "resource", value: "execution" }]
mesg:execution:create [{ key: "hash", value: "xxxx" }, { key: "action", value: "create" }, { key: "resource", value: "execution" }]

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 a pull request may close this issue.

2 participants