Skip to content

Commit

Permalink
feat: new method set_churn_approver (#333)
Browse files Browse the repository at this point in the history
Related to #310

### 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: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.com>
  • Loading branch information
pablodeymo and MegaRedHand authored Feb 13, 2025
1 parent 82425c1 commit 5238c48
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 19 deletions.
64 changes: 49 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ Those changes in added, changed or breaking changes, should include usage exampl

### Added 🎉

* Added new method `set_churn_approver` in `avsregistry/writer` in [#333](https://github.com/Layr-Labs/eigensdk-rs/pull/333).

```rust
let tx_hash = avs_writer
.set_churn_approver(new_churn_approver_address)
.await
.unwrap();
```

### Breaking Changes 🛠

### Deprecated ⚠️
Expand All @@ -31,6 +40,7 @@ Those changes in added, changed or breaking changes, should include usage exampl
## [0.3.0] - 2025-02-11
### Added
* Added new method `set_slashable_stake_lookahead` in `avsregistry/writer` in [#278](https://github.com/Layr-Labs/eigensdk-rs/pull/278).

```rust
let quorum_number = 0_u8;
let lookahead = 10_u32;
Expand All @@ -39,6 +49,7 @@ Those changes in added, changed or breaking changes, should include usage exampl
.await
.unwrap();
```

* Added new method `set_rewards_initiator` in `avsregistry/writer` in [#273](https://github.com/Layr-Labs/eigensdk-rs/pull/273).

```rust
Expand Down Expand Up @@ -365,11 +376,12 @@ Those changes in added, changed or breaking changes, should include usage exampl

### Changed


### Breaking changes

* refactor: update interface on `bls aggregation` in [#254](https://github.com/Layr-Labs/eigensdk-rs/pull/254)
* Introduces a new struct `TaskMetadata` with a constructor `TaskMetadata::new` to initialize a new task and a method `with_window_duration` to set the window duration.
* Refactors `initialize_new_task` and `single_task_aggregator` to accept a `TaskMetadata` struct instead of multiple parameters.

```rust
// BEFORE
bls_agg_service
Expand All @@ -393,8 +405,9 @@ Those changes in added, changed or breaking changes, should include usage exampl
)
bls_agg_service.initialize_new_task(metadata).await.unwrap();
```

* Removes `initialize_new_task_with_window` since `window_duration` can now be set in `TaskMetadata`.

```rust
// BEFORE
bls_agg_service
Expand All @@ -418,9 +431,11 @@ Those changes in added, changed or breaking changes, should include usage exampl
time_to_expiry,
).with_window_duration(window_duration);
bls_agg_service.initialize_new_task(metadata).await.unwrap();
* refactor: encapsulate parameters into `TaskSignature` in [#260](https://github.com/Layr-Labs/eigensdk-rs/pull/260)
* refactor: encapsulate parameters into `TaskSignature` in [#260](https://github.com/Layr-Labs/eigensdk-rs/pull/260)

* Introduced `TaskSignature` struct to encapsulate parameters related to task signatures:
* Updated `process_new_signature` to accept a `TaskSignature` struct instead of multiple parameters.

```rust
// BEFORE
bls_agg_service.process_new_signature(task_index, task_response_digest, bls_signature, operator_id).await.unwrap();
Expand All @@ -434,6 +449,7 @@ Those changes in added, changed or breaking changes, should include usage exampl
);
bls_agg_service.process_new_signature(task_signature).await.unwrap();
```

* Slashing UAM changes in [#248](https://github.com/Layr-Labs/eigensdk-rs/pull/248).

### Removed
Expand Down Expand Up @@ -541,10 +557,13 @@ Those changes in added, changed or breaking changes, should include usage exampl
* ci: split tests and coverage by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/286>

## [0.1.3] - 2024-01-17

### Added 🎉
* feat: add rewards-v2 related functionality by @supernovahs in https://github.com/Layr-Labs/eigensdk-rs/pull/221

* feat: add rewards-v2 related functionality by @supernovahs in <https://github.com/Layr-Labs/eigensdk-rs/pull/221>
* New methods in `ELChainReader`:
* `get_operator_avs_split`

```rust
// Given a chain_reader, an operator_address and an avs_address:

Expand All @@ -553,8 +572,9 @@ Those changes in added, changed or breaking changes, should include usage exampl
.await
.unwrap();
```

* `get_operator_pi_split`

```rust
// Given a chain_reader and an operator_address:

Expand All @@ -567,6 +587,7 @@ Those changes in added, changed or breaking changes, should include usage exampl

* New methods in `ELChainWriter`:
* `set_operator_avs_split`

```rust
// Given a chain_writer, an operator_address, an avs_address and a split:

Expand All @@ -576,7 +597,9 @@ Those changes in added, changed or breaking changes, should include usage exampl
.unwrap();
let receipt = wait_transaction(&http_endpoint, tx_hash).await.unwrap();
```

* `set_operator_pi_split`

```rust
// Given a chain_writer, an operator_address and a split:

Expand All @@ -586,10 +609,12 @@ Those changes in added, changed or breaking changes, should include usage exampl
.unwrap();
let receipt = wait_transaction(&http_endpoint, tx_hash).await.unwrap();
```

* Bindings updated for rewards-v2 core contracts release

### Breaking Changes 🛠
* feat!: remove delegation manager from `ELChainWriter` by @supernovahs in https://github.com/Layr-Labs/eigensdk-rs/pull/214

* feat!: remove delegation manager from `ELChainWriter` by @supernovahs in <https://github.com/Layr-Labs/eigensdk-rs/pull/214>
* `ELChainWriter::new` no longer receives the delegation manager address as first parameter.
Before, a chainWriter was created this way:

Expand All @@ -615,43 +640,52 @@ Those changes in added, changed or breaking changes, should include usage exampl
"bead471191bea97fc3aeac36c9d74c895e8a6242602e144e43152f96219e96e8".to_string(),
);
```
* feat!: change way bindings are generated by @MegaRedHand in https://github.com/Layr-Labs/eigensdk-rs/pull/204

* feat!: change way bindings are generated by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/204>
* `eigen_utils::core` contains bindings related to core contracts
* `eigen_utils::middleware` contains bindings related to middleware contracts
* `eigen_utils::sdk` contains bindings related to the SDK (should only be used for testing)

Now, to update the bindings, run `make bindings`. This command will generate the bindings files in the folder: `crates/utils`.

### Documentation 📚
* docs: add CHANGELOG.md by @lferrigno in https://github.com/Layr-Labs/eigensdk-rs/pull/220

* docs: add CHANGELOG.md by @lferrigno in <https://github.com/Layr-Labs/eigensdk-rs/pull/220>

### Other Changes
* ci: change docker setup action for official one by @MegaRedHand in https://github.com/Layr-Labs/eigensdk-rs/pull/219
* docs: add error message for `cargo test` on darwin by @MegaRedHand in https://github.com/Layr-Labs/eigensdk-rs/pull/215
* test: fix `test_register_and_update_operator` by @ricomateo in https://github.com/Layr-Labs/eigensdk-rs/pull/223
* chore: update way anvil state dump is generated by @ricomateo in https://github.com/Layr-Labs/eigensdk-rs/pull/222
* fix: disable doctests on `eigen-utils` by @MegaRedHand in https://github.com/Layr-Labs/eigensdk-rs/pull/227
* chore: bump version by @MegaRedHand in https://github.com/Layr-Labs/eigensdk-rs/pull/228
* docs: add GitHub release changelog configuration by @MegaRedHand in https://github.com/Layr-Labs/eigensdk-rs/pull/229

* ci: change docker setup action for official one by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/219>
* docs: add error message for `cargo test` on darwin by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/215>
* test: fix `test_register_and_update_operator` by @ricomateo in <https://github.com/Layr-Labs/eigensdk-rs/pull/223>
* chore: update way anvil state dump is generated by @ricomateo in <https://github.com/Layr-Labs/eigensdk-rs/pull/222>
* fix: disable doctests on `eigen-utils` by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/227>
* chore: bump version by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/228>
* docs: add GitHub release changelog configuration by @MegaRedHand in <https://github.com/Layr-Labs/eigensdk-rs/pull/229>

## [0.1.2] - 2025-01-09

### Added

* Added retries with exponential backoff to send transactions in [#158](https://github.com/Layr-Labs/eigensdk-rs/pull/158)
* Added `query_registration_detail` method in [#162](https://github.com/Layr-Labs/eigensdk-rs/pull/162)
* Added clippy lints in `Cargo.toml` in [#159](https://github.com/Layr-Labs/eigensdk-rs/pull/159)
* Added BLS aggregation logger in [#154](https://github.com/Layr-Labs/eigensdk-rs/pull/154)
* Added `common` crate to `eigensdk` crate in [#213](https://github.com/Layr-Labs/eigensdk-rs/pull/213)

### Changed

* Updated `eigenlayer-middleware` to v0.4.3 (rewards release) in [#177](https://github.com/Layr-Labs/eigensdk-rs/pull/177)
* Fixed Holesky RPC provider URL in [#184](https://github.com/Layr-Labs/eigensdk-rs/pull/184)
* Fixed BLS signature logic in [#174](https://github.com/Layr-Labs/eigensdk-rs/pull/174)

### Removed

* Deleted `TxManager` in [#151](https://github.com/Layr-Labs/eigensdk-rs/pull/151)
* Removed `TxManager` crate import in [#211](https://github.com/Layr-Labs/eigensdk-rs/pull/211)
* Removed logs in `operatorsinfo` test in [#185](https://github.com/Layr-Labs/eigensdk-rs/pull/185)

### Documentation

* Added notes for running tests in [#194](https://github.com/Layr-Labs/eigensdk-rs/pull/194)
* Added "Contract Bindings" section to the README in [#178](https://github.com/Layr-Labs/eigensdk-rs/pull/178)
* Added "Branches" section to the README in [#200](https://github.com/Layr-Labs/eigensdk-rs/pull/200)
Expand Down
67 changes: 63 additions & 4 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,39 @@ impl AvsRegistryChainWriter {
.send()
.await
.map_err(AvsRegistryError::AlloyContractError)?;
info!(tx_hash = ?tx, "successfully updated the socket with the AVS's registry coordinator");
info!(tx_hash = ?tx,"successfully updated the socket with the AVS's registry coordinator");
Ok(*tx.tx_hash())
}

/// Set churn approver
///
/// This function sets a new churn approver for the AVS's registry coordinator.
///
/// # Arguments
///
/// * `new_churn_approver` - address of the new churn approver.
///
/// # Returns
///
/// * `TxHash` - hash of the transaction.
pub async fn set_churn_approver(
&self,
new_churn_approver: Address,
) -> Result<TxHash, AvsRegistryError> {
info!("set new churn approver with the AVS's registry coordinator");
let provider = get_signer(&self.signer.clone(), &self.provider);

let contract_registry_coordinator =
RegistryCoordinator::new(self.registry_coordinator_addr, provider);

contract_registry_coordinator.setChurnApprover(new_churn_approver)
.send()
.await
.map_err(AvsRegistryError::AlloyContractError)
.inspect(|tx| info!(tx_hash = ?tx,"successfully updated the new churn approver with the AVS's registry coordinator"))
.map(|tx| *tx.tx_hash())
}

/// Force a deregistration of an operator from one or more quorums
///
/// # Arguments
Expand Down Expand Up @@ -590,10 +619,9 @@ impl AvsRegistryChainWriter {
mod tests {

use super::AvsRegistryChainWriter;
use crate::test_utils::build_avs_registry_chain_reader;
use crate::test_utils::create_operator_set;
use crate::test_utils::{
build_avs_registry_chain_writer, test_deregister_operator, test_register_operator,
build_avs_registry_chain_reader, build_avs_registry_chain_writer, create_operator_set,
test_deregister_operator, test_register_operator,
};
use alloy::primitives::aliases::U96;
use alloy::primitives::U256;
Expand Down Expand Up @@ -784,6 +812,37 @@ mod tests {
assert_eq!(stream_event.socket, new_socket_addr);
}

#[tokio::test]
async fn test_set_churn_approver() {
let (_container, http_endpoint, _ws_endpoint) = start_anvil_container().await;
let private_key = FIRST_PRIVATE_KEY.to_string();
let avs_writer =
build_avs_registry_chain_writer(http_endpoint.clone(), private_key.clone()).await;

let provider = get_signer(&avs_writer.signer.clone(), &avs_writer.provider);

let regcoord = RegistryCoordinator::new(avs_writer.registry_coordinator_addr, &provider);

let current_churn_approver = regcoord.churnApprover().call().await.unwrap()._0;
let new_churn_approver = SECOND_ADDRESS;
assert_ne!(current_churn_approver, new_churn_approver);

let tx_hash = avs_writer
.set_churn_approver(new_churn_approver)
.await
.unwrap();

let tx_status = wait_transaction(&http_endpoint, tx_hash)
.await
.unwrap()
.status();

assert!(tx_status);

let current_churn_approver = regcoord.churnApprover().call().await.unwrap()._0;
assert_eq!(current_churn_approver, new_churn_approver);
}

#[tokio::test]
async fn test_set_account_identifier() {
let (_container, http_endpoint, _ws_endpoint) = start_anvil_container().await;
Expand Down

0 comments on commit 5238c48

Please # to comment.