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

feat(api): Integrate new VM into API server (no tracers) #3033

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

Conversation

slowli
Copy link
Contributor

@slowli slowli commented Oct 8, 2024

What ❔

Integrates the new VM into API server for 3 use cases: gas estimation, calls, and tx execution (without the validation stage).

Why ❔

These use cases do not require tracers and could benefit from faster VM execution (particularly gas estimation, which runs the VM multiple times).

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_supervisor fmt and zk_supervisor lint.

@slowli
Copy link
Contributor Author

slowli commented Oct 8, 2024

With optimized gas estimation and new VM, the CI load test yields around 115 tps (vs 70 tps baseline and approx. 60 tps for the old VM).


/// Fast VM mode to use for gas estimation in the API server.
#[serde(default)]
pub api_fast_vm_mode_for_gas_estimation: FastVmMode,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't added corresponding option for calls and transaction execution; they can be added iteratively. Not sure what's the best approach here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably one variable for all 3 cases is enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Deniallugo What's the best way to set api_fast_vm_mode_for_gas_estimation = SHADOW for integration tests? Create a similar file and call zks config-writer like in the CI load test?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, config-writer is the best effort.
You can create this file on flight

Comment on lines +423 to +425
let handler = DivergenceHandler::new(move |errors, _| {
tracing::error!(transaction, ?mode, "{errors}");
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what the best option for the divergence handler would look like. We probably don't want to panic on divergence, but maybe we want to store a VM dump somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

It does, maybe we can just dump it to local file with some safety measures against spamming files, e.g. limit it to 10 dump files and overwrite/stop dumping when limit is reached?

@slowli slowli marked this pull request as ready for review October 8, 2024 18:21
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.

4 participants