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

feat: new method set_churn_approver #333

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 53 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ Each version will have a separate `Breaking Changes` section as well. To describ
Those changes in added, changed or breaking changes, should include usage examples to add clarity to the sdk user.

## [Unreleased]

### Added

* Added `eigen_common` dependency to the `eigensdk` crate when "full" feature is enabled in [#249](https://github.com/Layr-Labs/eigensdk-rs/pull/249).
* Added bindings for `ECDSAStakeRegistry` and `ECDSAServiceManagerBase` in [#269](https://github.com/Layr-Labs/eigensdk-rs/pull/269).
* Added release-plz in ci in [#275](https://github.com/Layr-Labs/eigensdk-rs/pull/275).
* 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 @@ -25,6 +28,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 @@ -109,7 +113,17 @@ Those changes in added, changed or breaking changes, should include usage exampl
.unwrap();
```

* 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();
```

### Changed

* Changes in the way bindings are generated in [#243](https://github.com/Layr-Labs/eigensdk-rs/pull/243).
* The `bindings` target now generates the bindings using Docker with Foundry v0.3.0.
* The previous `bindings` target was renamed to `bindings_host`, as it runs without Docker. However the `bindings_host` target is for CI use only. To generate the bindings, please use the `bindings` target.
Expand All @@ -118,9 +132,11 @@ Those changes in added, changed or breaking changes, should include usage exampl
* Fixed incorrect package name in Cargo.toml for examples in [#285](https://github.com/Layr-Labs/eigensdk-rs/pull/285).

### 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 @@ -144,8 +160,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 @@ -169,9 +186,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 @@ -185,19 +204,24 @@ 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

* Removed homepage from testing-utils crate in [#266](https://github.com/Layr-Labs/eigensdk-rs/pull/266).
* Removed changelog generation by release-plz in [#281](https://github.com/Layr-Labs/eigensdk-rs/pull/281).
* Removed examples packages from workspace.dependencies in Cargo.toml in [#287](https://github.com/Layr-Labs/eigensdk-rs/pull/287).
* Removed release-plz-pr workflow in release-plz in [#292](https://github.com/Layr-Labs/eigensdk-rs/pull/292).

## [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 @@ -206,8 +230,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 @@ -220,6 +245,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 @@ -229,7 +255,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 @@ -239,10 +267,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 @@ -268,43 +298,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
66 changes: 63 additions & 3 deletions crates/chainio/clients/avsregistry/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,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 is used to set the new churn approver for the AVS's registry coordinator.
///
/// # Arguments
///
/// * `new_churn_approver` - The address of the new churn approver.
///
/// # Returns
///
/// * `TxHash` - The transaction hash of the deregister operator transaction.
Comment on lines +378 to +388
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
/// set Churn Approver
///
/// This function is used to set the new churn approver for the AVS's registry coordinator.
///
/// # Arguments
///
/// * `new_churn_approver` - The address of the new churn approver.
///
/// # Returns
///
/// * `TxHash` - The transaction hash of the deregister operator transaction.
/// 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 @@ -474,9 +503,9 @@ mod tests {
use eigen_testing_utils::anvil::{start_anvil_container, start_m2_anvil_container};
use eigen_testing_utils::anvil_constants::{
get_operator_state_retriever_address, get_registry_coordinator_address,
get_service_manager_address,
get_service_manager_address, FIRST_ADDRESS,
};
use eigen_testing_utils::anvil_constants::{FIRST_ADDRESS, FIRST_PRIVATE_KEY, SECOND_ADDRESS};
use eigen_testing_utils::anvil_constants::{FIRST_PRIVATE_KEY, SECOND_ADDRESS};
use eigen_testing_utils::transaction::wait_transaction;
use eigen_utils::rewardsv2::middleware::servicemanagerbase::ServiceManagerBase;
use eigen_utils::slashing::middleware::registrycoordinator::ISlashingRegistryCoordinatorTypes::OperatorSetParam;
Expand Down Expand Up @@ -716,6 +745,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
Loading