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

[suggestion] DSL for event filters #3068

Closed
appetrosyan opened this issue Jan 19, 2023 · 2 comments
Closed

[suggestion] DSL for event filters #3068

appetrosyan opened this issue Jan 19, 2023 · 2 comments
Assignees
Labels
Enhancement New feature or request iroha2-dev The re-implementation of a BFT hyperledger in RUST UI Something about the interface

Comments

@appetrosyan
Copy link
Contributor

Feature request

I propose designing a small Domain-specific language implemented as a procedural macro crate that generates code that produces the following:

Examples

let asset_filter: FilterBox = filter!(asset "rose##alice@wonderland" added);
let passthrough: FilterBox = filter!(*);
let domain_metadata: FilterBox = filter!(domain metadata["key"])
let account = filter!(asset "rose##alice@wonderland" metadata_inserted);

Motivation

Composing event filters is extremely cumbersome, because the entire hierarchy of the nets must be remembered by the person writing the filter.

Who can help?

@Arjentix

@appetrosyan appetrosyan added Enhancement New feature or request iroha2-dev The re-implementation of a BFT hyperledger in RUST UI Something about the interface labels Jan 19, 2023
@appetrosyan appetrosyan self-assigned this Jan 19, 2023
@DCNick3 DCNick3 self-assigned this Nov 13, 2023
@DCNick3
Copy link
Contributor

DCNick3 commented Dec 25, 2023

I've decided to make the DSL not macro-based, but based on builder pattern. For this I would also like to refactor the events and event filters first to be more orthogonal

DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit to DCNick3/iroha that referenced this issue Dec 25, 2023
DCNick3 added a commit that referenced this issue Dec 25, 2023
Asem-Abdelhady pushed a commit to Asem-Abdelhady/iroha that referenced this issue Jan 22, 2024
Signed-off-by: Nikita Strygin <[email protected]>
Signed-off-by: Asem-Abdelhady <[email protected]>
Asem-Abdelhady pushed a commit to Asem-Abdelhady/iroha that referenced this issue Feb 9, 2024
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 20, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 21, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 29, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 29, 2024
…r-iroha#3068: Add an event matcher proc macro

This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Feb 29, 2024
…r-iroha#3068: Use the auto-generated multi-event matchers instead of handwritten ones

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 1, 2024
…r-iroha#3068: Add an event set proc macro

This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 1, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 1, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 4, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 14, 2024
…r-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] hyperledger-iroha#1981, hyperledger-iroha#4195, hyperledger-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 14, 2024
…r-iroha#3068: Add event filters for PermissionTokenSchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 14, 2024
…r-iroha#3068: Remove some more redundancy when constructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 14, 2024
…r-iroha#3068: Update event filter builder methods naming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 14, 2024
…r-iroha#3068: Remove NotificationEvent

Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Unify various event filter APIs, introduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add an event set proc macro

This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] hyperledger-iroha#1981, hyperledger-iroha#4195, hyperledger-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add event filters for PermissionTokenSchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove some more redundancy when constructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Update event filter builder methods naming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove NotificationEvent

Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add an event set proc macro

This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Use the auto-generated event sets instead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] hyperledger-iroha#1981, hyperledger-iroha#4195, hyperledger-iroha#3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Add event filters for PermissionTokenSchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove some more redundancy when constructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Update event filter builder methods naming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit to DCNick3/iroha that referenced this issue Mar 18, 2024
…r-iroha#3068: Remove NotificationEvent

Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…oduce a fluent builder API

- All event filters implement Debug, Clone, Eq, Ord
- All event filters (except TimeEventFilter) have a similar fluent builder API
    Event filter starts by accepting anything, with each method call limiting the accepted events
- Structs with hidden fields provide getters & builder APIs to create them
- Data event matchers are no longer prefixed with `By` to make them read better inside the `only_events` method call

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
This proc macro generates a wrapper around a bit mask to specifying a set of events to match

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…tead of handwritten matchers

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…n DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>

[refactor] #1981, #4195, #3068: match more exhaustively over events in DataEventFilter

This will produce a compile error in case a new top-level data event is introduced. It will not catch new Domain event types (like Account, Asset, AssetDefinition). Achieving that will require listing all (even non-hierarchical) event types, which is probably too much boilerplate

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…SchemaUpdate, Configuration and Executor events

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…tructing event filters

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
…aming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
DCNick3 added a commit that referenced this issue Mar 18, 2024
Instead of it, expose TriggerCompletedEvent as a top-level event, same as ExecuteTriggerEvent

Signed-off-by: Nikita Strygin <[email protected]>
@DCNick3
Copy link
Contributor

DCNick3 commented Mar 19, 2024

This is mostly addressed with the merge of #4240. Some improvements (#4259, #4356) will follow

@DCNick3 DCNick3 closed this as completed Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request iroha2-dev The re-implementation of a BFT hyperledger in RUST UI Something about the interface
Projects
None yet
Development

No branches or pull requests

2 participants