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] #1903: move event emission to modify_* methods #1931

Merged
merged 28 commits into from
Feb 28, 2022

Conversation

Arjentix
Copy link
Contributor

Description of the Change

  • All WSV modify_ methods are now implemented through each other. New modify_world() is on top
  • Introduce new strongly typed events
  • modify_ methods accepts closures returning strongly typed event
  • Refactor filters for strongly typed events

Issue

Resolves #1892

Benefits

  • Events are emitted only in WSV
  • Now there is no way to call modify_ method without event emitting
  • Decreased chance to emit wrong event

TODO

  • Fix failing tests
  • Add documentation
  • Rebase to the new iroha2-dev commits

@github-actions github-actions bot added the iroha2-dev The re-implementation of a BFT hyperledger in RUST label Feb 21, 2022
@appetrosyan appetrosyan self-requested a review February 21, 2022 15:13
core/src/smartcontracts/isi/query.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/query.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/mod.rs Show resolved Hide resolved
core/src/smartcontracts/isi/account.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/asset.rs Outdated Show resolved Hide resolved
core/src/wsv.rs Outdated Show resolved Hide resolved
core/src/wsv.rs Outdated Show resolved Hide resolved
core/src/wsv.rs Outdated Show resolved Hide resolved
data_model/src/events/data/events.rs Outdated Show resolved Hide resolved
data_model/src/events/data/events.rs Outdated Show resolved Hide resolved
data_model/src/events/data/events.rs Outdated Show resolved Hide resolved
data_model/src/events/data/events.rs Outdated Show resolved Hide resolved
data_model/src/events/data/filters.rs Outdated Show resolved Hide resolved
@appetrosyan appetrosyan changed the title Refactor event emission [refactor] #1903: move event emission to modify_* methods Feb 22, 2022
@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #1931 (45e7fee) into iroha2-dev (9a149ee) will decrease coverage by 0.40%.
The diff coverage is 53.11%.

Impacted file tree graph

@@              Coverage Diff               @@
##           iroha2-dev    #1931      +/-   ##
==============================================
- Coverage       78.04%   77.63%   -0.41%     
==============================================
  Files             164      165       +1     
  Lines           22625    22907     +282     
==============================================
+ Hits            17657    17784     +127     
- Misses           4968     5123     +155     
Impacted Files Coverage Δ
client_cli/src/main.rs 0.32% <0.00%> (ø)
core/src/smartcontracts/mod.rs 100.00% <ø> (ø)
data_model/src/lib.rs 49.03% <ø> (ø)
version/src/lib.rs 35.48% <0.00%> (ø)
data_model/src/events/data/filters.rs 25.20% <25.20%> (ø)
data_model/src/events/data/events.rs 31.66% <31.66%> (ø)
core/src/smartcontracts/isi/domain.rs 48.07% <54.41%> (+4.59%) ⬆️
core/src/smartcontracts/isi/world.rs 58.62% <60.86%> (+8.62%) ⬆️
core/src/smartcontracts/isi/account.rs 53.84% <61.90%> (+1.73%) ⬆️
core/src/smartcontracts/isi/mod.rs 73.63% <66.66%> (-0.36%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a149ee...45e7fee. Read the comment docs.

@appetrosyan appetrosyan marked this pull request as ready for review February 24, 2022 08:08
core/src/wsv.rs Outdated Show resolved Hide resolved
core/src/wsv.rs Outdated Show resolved Hide resolved
appetrosyan
appetrosyan previously approved these changes Feb 24, 2022
appetrosyan
appetrosyan previously approved these changes Feb 25, 2022
appetrosyan
appetrosyan previously approved these changes Feb 25, 2022
core/src/wsv.rs Outdated Show resolved Hide resolved
core/src/wsv.rs Show resolved Hide resolved
data_model/src/events/data/filters.rs Outdated Show resolved Hide resolved
data_model/src/events/data/filters.rs Outdated Show resolved Hide resolved
data_model/src/events/data/events.rs Outdated Show resolved Hide resolved
Signed-off-by: Arjentix <arjentix@gmail.com>
Signed-off-by: Arjentix <arjentix@gmail.com>
Signed-off-by: Arjentix <arjentix@gmail.com>
Signed-off-by: Arjentix <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
Increased(AssetId),
Decreased(AssetId),
MetadataInserted(AssetId),
MetadataRemoved(AssetId),
Copy link
Contributor

@mversic mversic Feb 28, 2022

Choose a reason for hiding this comment

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

I'm not sure this event should be called MetadataInserted. Maybe rather StoreInserted?

Copy link
Contributor

@mversic mversic Feb 28, 2022

Choose a reason for hiding this comment

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

actually, I think there should be only 4 events something like:

pub enum AssetEvent {
    Created(AssetId),
    Deleted(AssetId),
    Added(AssetId),
    Removed(AssetId),
}

Copy link
Contributor Author

@Arjentix Arjentix Feb 28, 2022

Choose a reason for hiding this comment

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

Then what events should be produced by SetKeyValue<Asset, Name, Value> and RemoveKeyValue<Asset, Name>?

Copy link
Contributor

@mversic mversic Feb 28, 2022

Choose a reason for hiding this comment

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

As I see it, asset can be created, deleted, added a quantity or removed a quantity where quantity can be a number or key-value. SetKeyValue is adding a key value to asset which holds key-value entities

Copy link
Contributor

Choose a reason for hiding this comment

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

@Arjentix what happened with this? you just resolved the conversation without a comment

Copy link
Contributor Author

@Arjentix Arjentix Mar 2, 2022

Choose a reason for hiding this comment

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

Sorry, I misunderstood your comment, I've read it as Ah I see it

So do you think, it should be Added and Removed for SetKeyValue and RemoveKeyValue? In this instructions code there are a lot of metadata terminology, is it okay then?

data_model/src/events/data/events.rs Outdated Show resolved Hide resolved
Increased(AssetId),
Decreased(AssetId),
MetadataInserted(AssetId),
MetadataRemoved(AssetId),
Copy link
Contributor

@mversic mversic Feb 28, 2022

Choose a reason for hiding this comment

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

As I see it, asset can be created, deleted, added a quantity or removed a quantity where quantity can be a number or key-value. SetKeyValue is adding a key value to asset which holds key-value entities

core/src/wsv.rs Outdated Show resolved Hide resolved
data_model/src/events/data/events.rs Show resolved Hide resolved
Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
@mversic mversic requested a review from s8sato February 28, 2022 15:00
@Arjentix Arjentix merged commit dc5c724 into hyperledger:iroha2-dev Feb 28, 2022
@Arjentix Arjentix deleted the refactor_event_emission branch February 28, 2022 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants