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(zk_toolbox): Minimize zkstack dependency on zksync_config (pt. 2) #3543

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

slowli
Copy link
Contributor

@slowli slowli commented Jan 28, 2025

What ❔

  • Completely removes zksync_*config deps in zkstack.
  • Introduces strongly-typed wrappers for configs in zkstack.

Why ❔

Part of preparations for integrating a new config system.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zkstack dev fmt and zkstack dev lint.

@slowli slowli marked this pull request as ready for review January 29, 2025 15:26
@slowli slowli requested a review from a team as a code owner January 29, 2025 15:26
popzxc
popzxc previously approved these changes Jan 30, 2025
Copy link
Member

@popzxc popzxc left a comment

Choose a reason for hiding this comment

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

Nice. As usual, suggest getting extra review from @sanekmelnikov

@slowli slowli requested a review from Deniallugo February 3, 2025 12:06
optional uint32 ws_port = 3; // required; u16
optional string ws_url = 4; // required
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a bit of a controversial change; on the one hand, it's not required for running the server. But it does help for running other tools against the server

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Even if these values would be beneficial in the config files, that doesn't mean that they should be retained in the config definitions. Compare with some wallet and contract params which are similarly not used by the server (but they aren't defined in the config).
  • Are there cases when ws_url / http_url don't use the 127.0.0.1 domain? (I guess somewhere external, because I've replaced all the mentions in the repo, and, judging by CI, it seems to work.) If they are always constructed as (htttp|ws)://127.0.0.1/{corresponding_port}, then these params are redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, we sometimes want to change them. e.g. to ask get some remote server

@@ -105,7 +105,25 @@ impl MainNodeClient for Box<DynClient<L2>> {
}

async fn fetch_genesis_config(&self) -> EnrichedClientResult<GenesisConfig> {
self.genesis_config().rpc_context("genesis_config").await
let dto = self.genesis_config().rpc_context("genesis_config").await?;
Ok(GenesisConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both DTO and non dto?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Single responsibility principle; it's weird to have a single type represent both a configuration and something used by API. More practically, it makes zksync_web3_decl depend on zksync_config, which is unnecessary and makes zkstack transitively depend on zksync_config as well (since it depends on zksync_web3_decl), even if the direct dependency is removed.

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.

3 participants