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

Update cosmos events #1769

Merged
merged 8 commits into from
Apr 3, 2020
Merged

Update cosmos events #1769

merged 8 commits into from
Apr 3, 2020

Conversation

NicolasMahe
Copy link
Member

@NicolasMahe NicolasMahe commented Apr 2, 2020

closes #1747

  • Use the default cosmos event message, as it should, in the module handler of each module
  • Create dedicated events for each module. Call them in the keeper functions of each module
  • Update the rest of the codebase. Deleted the not really useful stream function from RPC client to allow more flexibility (it forced the event to hash a hash attribute)

Improved event filtering

The new events allow creating queries that exactly match resources we want.
Instead of having to filter possible matching resources, now you should be able to write queries that match them perfectly.
Example that match execution for a specific executor and status (source):

query := fmt.Sprintf("%s.%s='%s' AND %s.%s='%s'",
	executionmodule.EventType, executionmodule.AttributeKeyExecutor, runnerHash.String(),
	executionmodule.EventType, executionmodule.AttributeKeyStatus, execution.Status_InProgress.String(),
eventStream, err := s.rpc.Subscribe(ctx, subscriber, query, 0)
)

Events list

message

All modules emit an event type message when they received a destined message with the following data:

key value
module module name, eg service
sender signer of the tx, eg mesgtestXXX
action msg'stype. managed by the base app, eg create

service

The module service emits an event type service when a service has been created with the following data:

key value
action created
hash service's hash
address service's address

runner

The module runner emits an event type runner when a runner has been created or deleted with the following data:

key value
action created OR deleted
hash runner's hash
address runner's address
instance runner's instance hash

process

The module process emits an event type process when a process has been created or deleted with the following data:

key value
action created OR deleted
hash process hash
address process address

ownership

The module ownership emits an event type ownership when an ownership has been created or deleted with the following data:

key value
action created OR deleted
hash ownership hash
resource_hash ownership's resource hash
ressource_type ownership's resource type
ressource_address ownership's resource address

instance

The module instance emits an event type instance when an instance has been created with the following data:

key value
action created
hash instance's hash
service instance's service hash

execution

The module execution emits an event type execution when an execution has been proposed, created or when a result has been submitted with the following data:

key value
action proposed OR created OR completed OR failed
hash execution's hash
address execution's address
executor execution's executor hash
process optional execution's process hash
instance execution's instance hash

@NicolasMahe NicolasMahe self-assigned this Apr 2, 2020
@NicolasMahe NicolasMahe added this to the next milestone Apr 2, 2020
@NicolasMahe NicolasMahe marked this pull request as ready for review April 2, 2020 12:51
Copy link
Member

@antho1404 antho1404 left a comment

Choose a reason for hiding this comment

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

Everything is good, the execution's events could be improved, now the behavior is a bit weird, I would recommend sending an event for every single mutation of the execution so

  • x events for proposed
  • 1 event for created
  • 0 or 1 event for completed
  • 0 or 1 event for failed

Based on your table:

key value
action proposed OR inProgress (I don't really like in progress could be better created) OR completed OR failed
hash execution's hash
address execution's address
status execution's status
executor execution's executor hash
process optional execution's process hash
instance execution's instance hash

x/execution/internal/keeper/keeper.go Show resolved Hide resolved
x/execution/internal/keeper/keeper.go Show resolved Hide resolved
@NicolasMahe
Copy link
Member Author

Everything is good, the execution's events could be improved, now the behavior is a bit weird, I would recommend sending an event for every single mutation of the execution so

  • x events for proposed
  • 1 event for created
  • 0 or 1 event for completed
  • 0 or 1 event for failed

Based on your table:

key value
action proposed OR inProgress (I don't really like in progress could be better created) OR completed OR failed
hash execution's hash
address execution's address
status execution's status
executor execution's executor hash
process optional execution's process hash
instance execution's instance hash

Execution event updated to:

key value
action proposed OR created OR completed OR failed
hash execution's hash
address execution's address
executor execution's executor hash
process optional execution's process hash
instance execution's instance hash

@NicolasMahe NicolasMahe added the release:change Pull requests that change something existant label Apr 3, 2020
x/execution/internal/keeper/keeper.go Outdated Show resolved Hide resolved
if alreadySeeHashes[attr] {
continue
}
alreadySeeHashes[attr] = true
Copy link
Member

Choose a reason for hiding this comment

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

tiny issue but maybe this should be done only when everything is ok so after we get the execution, before the Filter.Match

Copy link
Member Author

@NicolasMahe NicolasMahe Apr 3, 2020

Choose a reason for hiding this comment

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

The filter match is based on the date of the execution, so even if it's not the right event, the data of the execution will be the same so the filter will work exactly the same way all the time.

@antho1404 antho1404 merged commit d419be3 into dev Apr 3, 2020
@antho1404 antho1404 deleted the feature/cosmos-events branch April 3, 2020 12:50
@NicolasMahe NicolasMahe mentioned this pull request Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:change Pull requests that change something existant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Cosmos events
2 participants