blueprint_eigenlayer_testing_utils/
env.rs

1use alloy_primitives::Uint;
2use alloy_primitives::{Address, address};
3use blueprint_chain_setup::anvil::get_receipt;
4use blueprint_core::info;
5use blueprint_evm_extra::util::get_provider_http;
6use blueprint_runner::eigenlayer::config::EigenlayerProtocolSettings;
7use eigensdk::utils::slashing::middleware::registry_coordinator::ISlashingRegistryCoordinatorTypes::OperatorSetParam;
8use eigensdk::utils::slashing::middleware::registry_coordinator::IStakeRegistryTypes::StrategyParams;
9use eigensdk::utils::slashing::middleware::registry_coordinator::RegistryCoordinator;
10use url::Url;
11
12/// The default Token address for our Squaring Example
13pub const TOKEN_ADDR: Address = address!("4826533b4897376654bb4d4ad88b7fafd0c98528");
14
15/// Sets up the test environment for the EigenLayer Blueprint for non-empty Anvil testnet
16///
17/// # Description
18/// - Creates a quorum for operator registration
19/// - Returns a [`EigenlayerProtocolSettings`] struct containing the test environment state.
20#[allow(clippy::missing_panics_doc)]
21pub async fn setup_eigenlayer_test_environment<T: TryInto<Url>>(
22    http_endpoint: T,
23) -> EigenlayerProtocolSettings
24where
25    <T as TryInto<Url>>::Error: std::fmt::Debug,
26{
27    let http_endpoint = http_endpoint.try_into().unwrap();
28    let provider = get_provider_http(http_endpoint.clone());
29
30    let default_eigenlayer_protocol_settings = EigenlayerProtocolSettings::default();
31
32    let registry_coordinator = RegistryCoordinator::new(
33        default_eigenlayer_protocol_settings.registry_coordinator_address,
34        provider.clone(),
35    );
36
37    let operator_set_params = OperatorSetParam {
38        maxOperatorCount: 10,
39        kickBIPsOfOperatorStake: 100,
40        kickBIPsOfTotalStake: 1000,
41    };
42    let strategy_params = StrategyParams {
43        strategy: TOKEN_ADDR,
44        multiplier: Uint::from(1),
45    };
46
47    info!("Creating Quorum...");
48    let _receipt = get_receipt(registry_coordinator.createTotalDelegatedStakeQuorum(
49        operator_set_params,
50        Uint::from(0),
51        vec![strategy_params],
52    ))
53    .await
54    .unwrap();
55
56    info!("Setup Eigenlayer test environment");
57
58    default_eigenlayer_protocol_settings
59}