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

refactor(sdk): Remove NetworkArg + Make functions that accept Network methods of Network #1598

Closed
wants to merge 14 commits into from

Conversation

PatStiles
Copy link
Contributor

@PatStiles PatStiles commented Dec 10, 2024

Important

Closed in favour of #1730

Refactor Network Arg

Description

Refactors the Network struct in the sdk to:

  • Derive ValueEnum and thus remove the need for NetworkArg
  • Refactors functions that accept Network and return addresses to be methods of Network.

Type of change

Please delete options that are not relevant.

  • Refactor

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

@PatStiles PatStiles changed the title refactor(sdk): Remove NetworkArg + Make get_<Address> functions methods of Network refactor(sdk): Remove NetworkArg + Make functions that accept Network methods of Network Dec 10, 2024
Copy link
Collaborator

@MarcosNicolau MarcosNicolau left a comment

Choose a reason for hiding this comment

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

Nice!

pub enum Network {
Devnet,
Holesky,
HoleskyStage,
Mainnet,
}

impl Network {
pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: pass by copy:

Suggested change
pub fn get_batcher_payment_service_address(&self) -> ethers::types::H160 {
pub fn get_batcher_payment_service_address(self) -> ethers::types::H160 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! @Oppen

Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that Custom(String, String) it's no longer a good idea to pass by copy. That's also true for is_proof_verified.

}
}

pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: pass by copy:

Suggested change
pub fn get_aligned_service_manager_address(&self) -> ethers::types::H160 {
pub fn get_aligned_service_manager_address(self) -> ethers::types::H160 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! @Oppen

Copy link
Contributor

@MauroToscano MauroToscano left a comment

Choose a reason for hiding this comment

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

  • It would be better for NetworkArg, requiring clap in the SDK is a bit overkill
  • There needs to be a way to use values that are not the default ones, so in case we lunch another network we can use it without changing the code (Either through a config where you load network names and addresses, or some different input, may need to think a bit this)

@Oppen
Copy link
Collaborator

Oppen commented Jan 6, 2025

  • It would be better for NetworkArg, requiring clap in the SDK is a bit overkill
  • There needs to be a way to use values that are not the default ones, so in case we lunch another network we can use it without changing the code (Either through a config where you load network names and addresses, or some different input, may need to think a bit this)

Maybe a Custom variant that includes the actual parameters? That way, by default you'd just use the name for the known ones, but unexpected upgrades can be done by way of, e.g., passing --network custom --network-rpc ....

@PatStiles PatStiles self-assigned this Jan 8, 2025
pub const BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET: &str =
"0xb0567184A52cB40956df6333510d6eF35B89C8de";
/// AlignedServiceManager
pub const ALIGNED_SERVICE_MANAGER_DEVNET: &str = "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it be 0x851356ae760d987E095750cCeb3bC6014560891C?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

pub const ALIGNED_SERVICE_MANAGER_HOLESKY: &str = "0x58F280BeBE9B34c9939C3C39e0890C81f163B623";
pub const ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE: &str =
"0x9C5231FC88059C086Ea95712d105A2026048c39B";
pub const ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET: &str =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pub const ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET: &str =
pub const ALIGNED_SERVICE_MANAGER_MAINNET: &str =

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

}
let parts: Vec<&str> = s.split_whitespace().collect();

if parts.len() == 3 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also enforce custom to be parts[0].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

Copy link
Collaborator

@JulianVentura JulianVentura left a comment

Choose a reason for hiding this comment

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

Should update documentation to add new custom network parameter on docs/3_guides/0_submitting_proofs.md

@avilagaston9
Copy link
Collaborator

We should also update 9_aligned_cli.md

@PatStiles
Copy link
Contributor Author

For now the deployment of a custom network will be complete via stating "custom BATCHER_PAYMENT_SERVICE ALIGNED_SERVICE_MANAGER" in quotes. This solution is not ideal and we will discuss and implement a better solution in a follow up pr.

@PatStiles PatStiles force-pushed the refactor/network_arg branch 2 times, most recently from 70b2e30 to 413aada Compare January 10, 2025 15:15
@uri-99
Copy link
Contributor

uri-99 commented Jan 15, 2025

Closing in favor of #1730

@uri-99 uri-99 closed this Jan 15, 2025
@uri-99 uri-99 deleted the refactor/network_arg branch January 15, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants