Skip to content

Conversation

MegaRedHand
Copy link
Contributor

@MegaRedHand MegaRedHand commented Apr 28, 2025

What Changed?

This PR contains the first iteration of the high-level modules.

Each module is implemented in a crate of the same name:

  • crates/aggregator/ for the Aggregator
  • crates/operator/ for the Operator
  • crates/task-generator/ for the Task Spammer
  • crates/challenger/ for the Challenger

Usage examples for each module are included under the examples/ directory.
Links to each example:

Reviewer Checklist

  • New features are tested and documented
  • PR updates the changelog with a description of changes
  • PR has one of the changelog-X labels (if applies)
  • Code deprecates any old functionality before removing it

pablodeymo and others added 17 commits April 7, 2025 13:18
Fixes #

### What Changed?
<!-- Describe the changes made in this pull request -->

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it

---------

Co-authored-by: Damian Ramirez <damian.ramirez@lambdaclass.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
### What Changed?
This PR changed the previous sync RPC server to an async one using the
[tarpc](https://docs.rs/tarpc/latest/tarpc/index.html) crate.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?
This PR adds an example for the aggregator. 

1. Create a contract that emits an event when a task is created.
2. To use the aggregator, you should implement the `TaskProcessor` and
`TaskResponse` traits and create your own logic for processing the task.
3. Deploy the task contract
4. Create an operator set with a total delegated stake quorum
5. Register operators to the operator set
6. Start the aggregator
7. Emit a task with the contract
8. Send an RPC request to the aggregator with the task response and
signature of both operators
9. Since the threshold is reached, the BLS aggregation service will send
the aggregated response to the aggregator

A channel was added to receive the response from the BLS Aggregator and
compare it against a manually signature aggregator.

```rust
    // Aggregate the bls signatures manually
    let quorum_apks_g1 = aggregate_g1_public_keys(&[bls_key_pair.clone(), bls_key_pair_2.clone()]);
    let signers_apk_g2 = aggregate_g2_public_keys(&[bls_key_pair.clone(), bls_key_pair_2.clone()]);
    let signers_agg_sig_g1 =
        aggregate_g1_signatures(&[bls_signature.clone(), bls_signature_2.clone()]);

    // Wait for the aggregator to aggregate the responses and then compare the results
    let aggregated_response = receiver.recv().await.unwrap();
    assert_eq!(aggregated_response.quorum_apks_g1, vec![quorum_apks_g1]);
    assert_eq!(aggregated_response.signers_apk_g2, signers_apk_g2);
    assert_eq!(aggregated_response.signers_agg_sig_g1, signers_agg_sig_g1);
```

---

To run the example:
```sh
cargo run --example aggregator
```


![image](https://github.com/user-attachments/assets/83dbb3cd-432d-4b8a-ab87-da8ed4497832)

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?
This PR adds an `operator` crate to the SDK. Now you can start an
operator, which will subscribe to `TaskEvents` and process them
according to its implementation in the `OperatorTaskProcessor` trait.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
…e `start()` (#437)

### What Changed?

Based on the
[example](#436), asked to
move the creation of the `AvsRegistryChainReader` and the
`ClientAggregator` inside the `start`.


### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it

---------

Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
… parameter in Aggregator (#457)

### What Changed?

This PR removes the parameter that the `start()` function receives since
we already have this value in `AggregatorConfig`.
### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?

This PR adds an example of how to initialize and start a registered
`operator`. The idea is to show what the dev experience would be to have
an operator begin listening for tasks and processing them.

Since I started from this
[PR](#435), the diff
appears quite large + the bindings. The example is located in
`examples/operator`


### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it

---------

Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
### What Changed?
This PR adds a `task-generator` crate to the SDK.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?
This PR adds a `challenger` crate

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it

---------

Co-authored-by: Pablo Deymonnaz <pdeymon@fi.uba.ar>
# DO NOT MERGE UNTIL #442 

### What Changed?

This PR adds a devX example of the `task generator`

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?

- Improve how we were using the builder pattern in the Task Generator.
- Create a trait that simulates the contract—users must implement it to
define and create their tasks.
- Accept a contract generated by the bindings in `TaskGeneratorBuilder`
and use it for task creation.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?

- Removed the `TaskProcessor` trait from `Operator`.  
- `Operator::start` now accepts any event type (`SolEvent`) and any
task-response type (`SolType` + `SolValue`), making it fully generic.
- Now `start()` receives a function as a parameter, where the user
should put their business logic to respond to a task.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?

In #460, we refactored the operator so it no longer uses the
`OperatorTaskProcessor` trait, allowing us to remove this file.

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
# DO NOT MERGE UNTIL #445 

### What Changed?
This PR adds an example of the challenger devX

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What changed
This PR updates the `TaskManagerContract` trait by changing the
signature of `create_new_task`:

- Removes the `SolCall` type.
- `create_new_task` now returns an `impl Future<Output =
Result<N::ReceiptResponse, TaskGeneratorError>> + Send`. Users no need
to use the `SolCall` from the bindings. Now they need to call `.send()`
and `.get_receipt()`.
- Updates the example usage

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?
Rename `Task Generator` to `Task Spammer`

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
### What Changed?
This PR merges the `dev` branch into `v2`
- Regenerated the bindings for the examples
- Fixed the examples to reflect changes in the bindings

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it
@MegaRedHand MegaRedHand changed the base branch from v2 to dev June 27, 2025 14:55
Fixes #

### What Changed?
<!-- Describe the changes made in this pull request -->

### Reviewer Checklist

- [ ] New features are tested and documented
- [ ] PR updates the changelog with a description of changes
- [ ] PR has one of the `changelog-X` labels (if applies)
- [ ] Code deprecates any old functionality before removing it

---------

Co-authored-by: Pablo Deymonnaz <deymonnaz@gmail.com>
Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants