Skip to content

Commit 291664d

Browse files
authored
fix(crates/runner/src/eigenlayer): update requires_registration (#1227)
* chore: fix registration flow * chore: fix registration flow * chore: fix test ci * chore: fomat code
1 parent 1bcb28f commit 291664d

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

crates/manager/tests/protocol_integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async fn test_eigenlayer_protocol_manager_event_flow() {
150150

151151
// By default we have `incredible-squaring-blueprint-eigenlayer` blueprint spawned
152152
assert!(
153-
active_blueprints.len() == 1,
153+
active_blueprints.is_empty(),
154154
"By default we have `incredible-squaring-blueprint-eigenlayer` blueprint spawned"
155155
);
156156

crates/runner/src/eigenlayer/bls.rs

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ impl BlueprintConfig for EigenlayerBLSConfig {
7676
}
7777

7878
async fn requires_registration_bls_impl(env: &BlueprintEnvironment) -> Result<bool, RunnerError> {
79-
is_operator_registered(env).await
79+
if is_operator_registered(env).await? {
80+
info!("Operator is already registered for Eigenlayer");
81+
Ok(false)
82+
} else {
83+
Ok(true)
84+
}
8085
}
8186

8287
#[allow(clippy::too_many_lines)]
@@ -150,35 +155,40 @@ async fn register_bls_impl(
150155
.eigenlayer()
151156
.map_err(|e| EigenlayerError::Other(e.to_string().into()))?;
152157

153-
let operator_details = Operator {
154-
address: operator_address,
155-
delegation_approver_address,
156-
metadata_url: eigenlayer_settings.metadata_url.clone(),
157-
allocation_delay: Some(eigenlayer_settings.allocation_delay),
158-
_deprecated_earnings_receiver_address: None, // Deprecated in eigensdk-rs v2.0.0
159-
staker_opt_out_window_blocks: Some(eigenlayer_settings.staker_opt_out_window_blocks),
160-
};
161-
162-
let tx_hash = el_writer
163-
.register_as_operator(operator_details)
164-
.await
165-
.map_err(EigenlayerError::ElContracts)?;
166-
let registration_receipt = wait_transaction(env.http_rpc_endpoint.clone(), tx_hash)
167-
.await
168-
.map_err(|e| EigenlayerError::Registration(format!("AVS registration error: {}", e)))?;
169-
if registration_receipt.status() {
170-
info!("Registered as operator {} for Eigenlayer", operator_address);
171-
} else if is_operator_registered(env).await? {
158+
// Check if operator is already registered before attempting registration
159+
if is_operator_registered(env).await? {
172160
info!(
173161
"Operator {} is already registered for Eigenlayer",
174162
operator_address
175163
);
176164
} else {
177-
blueprint_core::error!(
178-
"Operator registration failed for operator {}",
179-
operator_address
180-
);
181-
return Err(EigenlayerError::Registration("Operator registration failed".into()).into());
165+
let operator_details = Operator {
166+
address: operator_address,
167+
delegation_approver_address,
168+
metadata_url: eigenlayer_settings.metadata_url.clone(),
169+
allocation_delay: Some(eigenlayer_settings.allocation_delay),
170+
_deprecated_earnings_receiver_address: None, // Deprecated in eigensdk-rs v2.0.0
171+
staker_opt_out_window_blocks: Some(eigenlayer_settings.staker_opt_out_window_blocks),
172+
};
173+
174+
let tx_hash = el_writer
175+
.register_as_operator(operator_details)
176+
.await
177+
.map_err(EigenlayerError::ElContracts)?;
178+
let registration_receipt = wait_transaction(env.http_rpc_endpoint.clone(), tx_hash)
179+
.await
180+
.map_err(|e| EigenlayerError::Registration(format!("AVS registration error: {}", e)))?;
181+
if registration_receipt.status() {
182+
info!("Registered as operator {} for Eigenlayer", operator_address);
183+
} else {
184+
blueprint_core::error!(
185+
"Operator registration failed for operator {}",
186+
operator_address
187+
);
188+
return Err(
189+
EigenlayerError::Registration("Operator registration failed".into()).into(),
190+
);
191+
}
182192
}
183193

184194
let deposit_amount = U256::from(eigenlayer_settings.deposit_amount);
@@ -320,7 +330,7 @@ async fn is_operator_registered(env: &BlueprintEnvironment) -> Result<bool, Runn
320330
.is_operator_registered(operator_address)
321331
.await
322332
{
323-
Ok(is_registered) => Ok(!is_registered),
333+
Ok(is_registered) => Ok(is_registered),
324334
Err(e) => Err(EigenlayerError::AvsRegistry(e).into()),
325335
}
326336
}

0 commit comments

Comments
 (0)