-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat(profile
): events
#742
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #742 +/- ##
===========================================
- Coverage 11.46% 11.37% -0.09%
===========================================
Files 279 279
Lines 60803 61456 +653
===========================================
+ Hits 6971 6993 +22
- Misses 53667 54300 +633
+ Partials 165 163 -2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm honestly not sure about the create/updated events
This would require context to understand the state change.
For example, if you have a Coordinator Updated event, you can't determine directly from the event data if the address of the coordinator or the coordinator description have been changed, you need to get the previous state of the coordinator
What is the downside of having per-message events?
When any Msg is run in the Cosmos SDK, a basic "action" event is emitted, stating the type of the message. The code can be found here. So, in spnd tx profile create-coordinator --from steve
{"body":{"messages":[{"@type":"/tendermint.spn.profile.MsgCreateCoordinator","address":"spn1mhyps2hlkm0nz6k2puumn69928cnvgg43zlrg7","description":{"identity":"","website":"","details":""}}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}
confirm transaction before signing and broadcasting [y/N]: y
code: 0
codespace: ""
data: 0A320A2C2F74656E6465726D696E742E73706E2E70726F66696C652E4D7367437265617465436F6F7264696E61746F7212020801
events:
- attributes:
- index: true
key: ZmVl
value: ""
type: tx
- attributes:
- index: true
key: YWNjX3NlcQ==
value: c3BuMW1oeXBzMmhsa20wbno2azJwdXVtbjY5OTI4Y252Z2c0M3pscmc3LzA=
type: tx
- attributes:
- index: true
key: c2lnbmF0dXJl
value: RmNpZVRZNEdnbi9UUTdkNjlBR1hqdU9yZnB4TktNSHZTQzlILzlGamtWZC9VODRMVjlMdExVMHRUWFc5UERzTXNZUnNTakN0bXBkMjVNVXhYRisyNkE9PQ==
type: tx
- attributes:
- index: true
key: YWN0aW9u
value: Y3JlYXRlX2Nvb3JkaW5hdG9y
type: message
- attributes:
- index: true
key: Y29vcmRpbmF0b3I=
value: eyJjb29yZGluYXRvcklEIjoiMSIsImFkZHJlc3MiOiJzcG4xbWh5cHMyaGxrbTBuejZrMnB1dW1uNjk5MjhjbnZnZzQzemxyZzciLCJkZXNjcmlwdGlvbiI6eyJpZGVudGl0eSI6IiIsIndlYnNpdGUiOiIiLCJkZXRhaWxzIjoiIn0sImFjdGl2ZSI6dHJ1ZX0=
type: tendermint.spn.profile.EventCoordinatorCreated
gas_used: "62937"
gas_wanted: "200000"
height: "78"
info: ""
logs:
- events:
- attributes:
- key: action
value: create_coordinator
type: message
- attributes:
- key: coordinator
value: '{"coordinatorID":"1","address":"spn1mhyps2hlkm0nz6k2puumn69928cnvgg43zlrg7","description":{"identity":"","website":"","details":""},"active":true}'
type: tendermint.spn.profile.EventCoordinatorCreated
log: ""
msg_index: 0
raw_log: '[{"events":[{"type":"message","attributes":[{"key":"action","value":"create_coordinator"}]},{"type":"tendermint.spn.profile.EventCoordinatorCreated","attributes":[{"key":"coordinator","value":"{\"coordinatorID\":\"1\",\"address\":\"spn1mhyps2hlkm0nz6k2puumn69928cnvgg43zlrg7\",\"description\":{\"identity\":\"\",\"website\":\"\",\"details\":\"\"},\"active\":true}"}]}]}]'
timestamp: ""
tx: null
txhash: 88ED7C296C1359217C1BF2E4909BFB6BD14F4281D28EC540D6DCEB4C5ED61200
My thinking is that we are providing additional events that detail how the state on-chain is being modified. The "context" providing events are already there. |
When fetching or listening for events, can you get the hash of the tx where the event is emitted? If yes, we can actually associate the message name event and custom event to get the full state transition but that still seems more work from the client from my point of view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering we already emit events for messages, I agree with @aljo242's proposal of state-transition events. I would probably make them more informative of what changed though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed my mind. I like the way things are already.
@lubtd as a clarification (hopefully) events are emitted as part of "raw_data" of transactions, which are comprised of a bunch of messages. Events are already bundled together per-message by the event manager, so they should be representing state-transitions that happens as the messages executes rather than be a recap of the message itself (since the data is included in the transaction anyway).
Yes but in the case of |
The state transition happened on the coordinator object so you show how the object has changed (IMHO)
Not sure I follow. could you clarify? what would practically be what you would emit in the event? |
The state transmission is automatically already emitted with the
Events are emitted and associated with transactions already, so associating them with a specific Tx is natural. |
{"key":"action","value":"create_coordinator"} in the example above |
Ok, this is what I wanted to ensure. |
Seems like we have some test errors since last |
Tests pass now - just a CodeCov upload error |
Closes #731
What does this PR does?
Emit typed events for the
profile
module.The events currents are just Create* and Update*. This differs from the Tx that we expose, but the state is still fully covered by these events