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

SYS-3560 Adds event listener feature to the node #418

Merged
merged 34 commits into from
Jun 26, 2024

Conversation

thadouk
Copy link
Contributor

@thadouk thadouk commented Jun 7, 2024

Proposed changes

Extends Ethereum bridge pallet to be bidirectional and listen to events emitted in the bridge contract.
The PR introduces:

  • avn-event-handler service: a thread running in client space that acts as an oracle, discovering information from Ethereum and submitting the information back to the runtime
  • The information is submitted in batches based on an Ethereum block range which is agreed initially from collators and then dictated by the runtime
  • New mechanism is configured to co-exist with ethereum-events and avoid double processing of events in the system.

Type of change/Merge

🚨What type of change is this PR?

Put an x in the boxes that apply

  • Release
    • Increase versions
    • Baseline tests passed
    • Release type:
      • Major release
      • Minor release
      • Patch release

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • You describe the purpose of the PR, e.g.:
    • What does it do?
    • Highlight what important points reviewers should know about;
    • Indicates if there is something left for follow-up PRs.
  • Documentation updated
  • Business logic tested successfully
  • Verify First, Write Last: In Substrate development, it is important that you always ensure preconditions are met and return errors at the beginning. After these checks have completed, then you may begin the function's computation.

Further comments

Cargo.toml Outdated Show resolved Hide resolved
runner.async_run(|config| {
// we don't need any of the components of new_partial, just a runtime, or a task
// manager to do `async_run`.
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
Copy link
Contributor

Choose a reason for hiding this comment

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

you now create the task_manager inside the runner? why is this change needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't compile with the previous code when you enable try-runtime. This is copied from Substrate

pallets/eth-bridge/src/lib.rs Outdated Show resolved Hide resolved
pallets/eth-bridge/src/lib.rs Outdated Show resolved Hide resolved
pallets/eth-bridge/src/lib.rs Show resolved Hide resolved
pallets/eth-bridge/src/tests/incoming_events_tests.rs Outdated Show resolved Hide resolved
@@ -1092,4 +1096,8 @@ impl<T: Config> BridgeInterfaceNotification for Pallet<T> {

Ok(())
}

fn on_incoming_event_processed(event: &EthEvent) -> DispatchResult {
Self::processed_event_handler(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding the feature guard here for Lift and Growth coming via this hook?

Copy link
Contributor Author

@thadouk thadouk Jun 17, 2024

Choose a reason for hiding this comment

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

No, from the pallet point of view we either process events coming from eth-bridge or not.
The runtime defines the filter and the rest of the components are just executing.

primitives/avn-common/src/event_discovery.rs Outdated Show resolved Hide resolved
primitives/avn-common/src/event_discovery.rs Outdated Show resolved Hide resolved
primitives/avn-common/src/event_discovery.rs Show resolved Hide resolved
runtime/avn/src/lib.rs Show resolved Hide resolved
@thadouk thadouk force-pushed the feat/SYS-3560-add-event-listener branch from 226e3ff to 58bf60c Compare June 26, 2024 11:09
ivan-cholakov and others added 19 commits June 26, 2024 12:36
Introduces the data structures and the voting mechanism for accepting
events ranges from ethereum.

Ranges that are too big will be broken down into smaller partitions,
voted upon individually, and accepted as one.

Follow up commit will do the validate unsigned and processing of the
partitions.

Jira tickets:
- SYS-3635
- SYS-3930
Updates the validate unsigned function to support
submit_discovered_events extrinsic.

Jira tickets:
- SYS-3635
- SYS-3930
This PR introduces support for processing votes upon achieving consensus. It extends extrinsics and data structures accordingly.

Once the final vote is cast, the voting round for the Ethereum range partition is finalized, and the partition is processed.

Additionally, this PR extends the subscription mechanism of the eth-bridge pallet. By default, pallets ignore processed events, requiring the implementation of a handler to process them.
Benchmarking for certain actions will be addressed in a separate PR.

Jira Tasks:
- SYS-3930
- SYS-3635
Signed-off-by: Ivan Cholakov <icholakov1@gmail.com>
Co-authored-by: Thanos Doukoudakis <56822898+thadouk@users.noreply.github.com>
Signed-off-by: Ivan Cholakov <icholakov1@gmail.com>
Co-authored-by: Thanos Doukoudakis <56822898+thadouk@users.noreply.github.com>
Adds a new endpoint that allows the chain to reach consenus over the initial ethereum range to be used.
This allows to simplify the voting logic for active ranges, eliminating the special case of the first range.

Jira ticket:
- SYS-3930
Extends the runtime API for initial range consensus mechanism

Jira task
- SYS-3930
Adds basic unit tests that check the submit_ethereum_events interface

Jira task:
- SYS-3930
- SYS-3635
- General cleanup
- Rename of storage items
- Removal of mocks
- Wire up with runtime, implementing different events filters for each runtime.
…397)

This commit includes the integration of the initial range voting functionality with the client.
It ports changes to integrate the runtime API for testing runtime behavior.
Additionally, it refactors the runtime API to improve proof creation by relocating helper
functions to primitive crates.
Fixes genesis config for test runtime.

Jira tasks:
- SYS-3930
- SYS-3635
This commit addresses issues with extrinsic submission in the runtime:

- Registers the extension to the instance submitting the extrinsic.
- Updates signature validation.
- Simplifies interface and error handling via the runtime API, following the report_equivocation style.
…o eth-bridge (#390)

Co-authored-by: Thanos <56822898+thadouk@users.noreply.github.com>
Co-authored-by: nahuseyoum <nahu.seyoum@aventus.io>
This commit allows the avn-event-hanlder to handle more graceful error.
Also applies code formatting.
Signed-off-by: Ivan Cholakov <icholakov1@gmail.com>
Co-authored-by: Ivan Cholakov <icholakov1@gmail.com>
Co-authored-by: Thanos <56822898+thadouk@users.noreply.github.com>
Co-authored-by: Michael <62653655+MBrozhko34@users.noreply.github.com>
Signed-off-by: Ivan Cholakov <icholakov1@gmail.com>
Co-authored-by: Ivan Cholakov <icholakov1@gmail.com>
Co-authored-by: Thanos <56822898+thadouk@users.noreply.github.com>
Co-authored-by: Michael <62653655+MBrozhko34@users.noreply.github.com>
nahuseyoum and others added 15 commits June 26, 2024 12:37
Adds handlers in Token manager and wire up for Runtime to process the first type of events from eth-bridge.

Jira ticket:
- SYS-4072
Use checked fucntions to do the mod calculations.
Updates tests, benchmarks and resto of the code accordingly
Restores batch value to tested.
An event is marked as processed once the event processing logic is completed.
The processing outcome of the pallet does not affect this.
Co-authored-by: Nahu <39748285+nahuseyoum@users.noreply.github.com>
Signed-off-by: Thanos Doukoudakis <56822898+thadouk@users.noreply.github.com>
Deprecates ethereum-events entry points that add manually events in the system.
Moving forward the responsibility will be shifted to eth-bridge event scanning mechanism on Ethereum.
- Fixes an issue where the last block of a range was polled twice and included to the next range as well.
- Addresses feature PR feedback
- cleanup
Adds AvtLowerClaimedData in the types the client scans.
Fixes the way the data field is constructed ensuring the data field is
explicitly set as None when no data is present, to align with the
runtime implementation.
@thadouk thadouk force-pushed the feat/SYS-3560-add-event-listener branch from 58bf60c to 3420b53 Compare June 26, 2024 11:38
@thadouk thadouk merged commit 388193e into main Jun 26, 2024
5 checks passed
@thadouk thadouk deleted the feat/SYS-3560-add-event-listener branch June 26, 2024 15:25
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 this pull request may close these issues.

5 participants