zksync-era icon indicating copy to clipboard operation
zksync-era copied to clipboard

fix(Validium): Add commitment mode cross check

Open ilitteri opened this issue 1 year ago • 1 comments

What ❔

Adds a cross-check of the local mode with L1 when setting up the server.

Why ❔

It is now possible to run the node with an incorrect config that doesn’t match the L1 config.

We should force the node to ask the pre-deployed contracts on L1 in which mode it should run.

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 zk fmt and zk lint.
  • [ ] Spellcheck has been run via zk spellcheck.
  • [ ] Linkcheck has been run via zk linkcheck.

ilitteri avatar Feb 23 '24 19:02 ilitteri

@ilitteri also btw now that it's extracted to a separate function, it probably should be easy to integrate this check to EN as well (as a separate PR).

popzxc avatar Mar 01 '24 06:03 popzxc

@ilitteri also btw now that it's extracted to a separate function, it probably should be easy to integrate this check to EN as well (as a separate PR).

Thanks a lot for the nits, I'll make new PRs for adding this cross-check to the EN and for the unit test.

ilitteri avatar Mar 01 '24 18:03 ilitteri

@ilitteri also btw now that it's extracted to a separate function, it probably should be easy to integrate this check to EN as well (as a separate PR).

@popzxc I'm currently working on supporting this cross-check in the EN and found out that the main_node_client does not implement EthInterface, thus the method cannot be exactly replicated.

Is it ok to replace the type of the main_node_client for a Arc<dyn EthInterface>? Or is it better to implement EthInterface for HttpClient?

ilitteri avatar Mar 01 '24 19:03 ilitteri

@ilitteri On EN eth_client_url is a part of required config, and you can see it being used e.g. to instantiate the consistency checker. Right now, ConsistencyChecker takes a URL and instantiates QueryClient inside new just to coerce it to Arc<dyn EthInterface>. You can change it so that ConsistencyChecker::new accepts Arc<dyn EthInterface> and QueryClient is instantiated outside -- this way you'll have access to it during ETH initialization logic. Does it make sense?

popzxc avatar Mar 04 '24 07:03 popzxc

@ilitteri On EN eth_client_url is a part of required config, and you can see it being used e.g. to instantiate the consistency checker. Right now, ConsistencyChecker takes a URL and instantiates QueryClient inside new just to coerce it to Arc<dyn EthInterface>. You can change it so that ConsistencyChecker::new accepts Arc<dyn EthInterface> and QueryClient is instantiated outside -- this way you'll have access to it during ETH initialization logic. Does it make sense?

This totally makes sense to me, thanks

ilitteri avatar Mar 04 '24 14:03 ilitteri