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

Make connecting to evm code more robust #162

Open
ryardley opened this issue Oct 28, 2024 · 0 comments
Open

Make connecting to evm code more robust #162

ryardley opened this issue Oct 28, 2024 · 0 comments
Labels
Ciphernode Related to the ciphernode package enhancement New feature or request

Comments

@ryardley
Copy link
Contributor

          _:hammer_and_wrench: Refactor suggestion_

Handle potential partial failures when attaching to multiple chains

In the loop attaching EnclaveSolReader and CiphernodeRegistrySol to each enabled chain, any failure in one chain will cause the entire setup to fail due to the use of await?. Consider handling errors for each chain individually, allowing the cipher node to continue operating with the chains that successfully attached.

You might refactor the loop to collect and log errors without stopping the entire setup:

for chain in config
    .chains()
    .iter()
    .filter(|chain| chain.enabled.unwrap_or(true))
{
    let rpc_url = &chain.rpc_url;

    if let Err(e) = EnclaveSolReader::attach(&bus, rpc_url, &chain.contracts.enclave).await {
        // Log the error without returning
        eprintln!("Failed to attach EnclaveSolReader for chain {}: {:?}", chain.name, e);
        continue;
    }

    if let Err(e) = CiphernodeRegistrySol::attach(&bus, rpc_url, &chain.contracts.ciphernode_registry).await {
        // Log the error without returning
        eprintln!("Failed to attach CiphernodeRegistrySol for chain {}: {:?}", chain.name, e);
        continue;
    }
}

This approach ensures that issues with a single chain do not prevent the cipher node from initializing with other available chains.

Originally posted by @coderabbitai[bot] in #156 (comment)

@ryardley ryardley added enhancement New feature or request Ciphernode Related to the ciphernode package labels Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ciphernode Related to the ciphernode package enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant