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

vmlogic: split up into two #11643

Merged
merged 2 commits into from
Jun 25, 2024
Merged

vmlogic: split up into two #11643

merged 2 commits into from
Jun 25, 2024

Conversation

nagisa
Copy link
Collaborator

@nagisa nagisa commented Jun 21, 2024

The split boundary has been chosen to be what's necessary to compute a VMOutcome, which now in turn allows us to load a contract without constructing a VMLogic, or contract memory quite yet.

This might very well resolve issues I've been working through by attempting to remove lifetimes and such from VMLogic...? As previous changes this makes quite some sense in isolation regardless of the ongoing projects. While I imagine there are more lines, they will mostly be due to the fact that in many places the previous code now needs to go through an additional field projection to get to types it needs to operate.

@Ekleog-NEAR I think you'll appreciate these as I recall you've struggled with the VMLogic nonsense as well in the past.

Part of #11319

@nagisa nagisa requested a review from Ekleog-NEAR June 21, 2024 11:25
@nagisa nagisa requested a review from a team as a code owner June 21, 2024 11:25
The split boundary has been chosen to be what's necessary to compute a
VMOutcome, which now in turn allows us to load a contract without
constructing a VMLogic, or contract memory quite yet.

This might very well resolve issues I've been working through by
attempting to remove lifetimes and such from `VMLogic`...? As previous
changes this makes quite some sense in isolation regardless of the
ongoing projects. While I imagine there are more lines, they will mostly
be due to the fact that in many places the previous code now needs to go
through an additional field projection to get to types it needs to
operate.
Copy link

codecov bot commented Jun 21, 2024

Codecov Report

Attention: Patch coverage is 73.40206% with 129 lines in your changes missing coverage. Please review.

Project coverage is 71.63%. Comparing base (e95c123) to head (25a6979).
Report is 16 commits behind head on master.

Files Patch % Lines
runtime/near-vm-runner/src/logic/logic.rs 68.10% 13 Missing and 105 partials ⚠️
runtime/near-vm-runner/src/wasmtime_runner.rs 84.21% 4 Missing and 2 partials ⚠️
runtime/near-vm-runner/src/wasmer_runner.rs 83.33% 1 Missing and 3 partials ⚠️
runtime/near-vm-runner/src/wasmer2_runner.rs 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11643      +/-   ##
==========================================
- Coverage   71.64%   71.63%   -0.02%     
==========================================
  Files         787      787              
  Lines      160969   161191     +222     
  Branches   160969   161191     +222     
==========================================
+ Hits       115333   115475     +142     
- Misses      40602    40683      +81     
+ Partials     5034     5033       -1     
Flag Coverage Δ
backward-compatibility 0.23% <0.00%> (-0.01%) ⬇️
db-migration 0.23% <0.00%> (-0.01%) ⬇️
genesis-check 1.36% <0.00%> (-0.01%) ⬇️
integration-tests 37.81% <52.98%> (+0.03%) ⬆️
linux 69.03% <73.40%> (+<0.01%) ⬆️
linux-nightly 71.11% <72.78%> (-0.02%) ⬇️
macos 52.62% <65.19%> (-0.14%) ⬇️
pytests 1.59% <0.00%> (-0.01%) ⬇️
sanity-checks 1.39% <0.00%> (-0.01%) ⬇️
unittests 66.24% <72.78%> (+0.02%) ⬆️
upgradability 0.28% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Ekleog-NEAR Ekleog-NEAR left a comment

Choose a reason for hiding this comment

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

LGTM! It’s great, this change avoids the VMLogic thread-through issues I had been having, by actually creating the things at a more intuitive place :)

/// This is a subset of [`VMLogic`] that's strictly necessary to produce `VMOutcome`s.
pub struct ExecutionResultState {
/// All gas and economic parameters required during contract execution.
config: Arc<Config>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm I’m not sure I get why gas parameters would be required to build a VMOutcome. AFAIU, this is only required in order to actually execute the contract, and not really for the result.

So WDYT about naming this struct ExecutionState rather than ExecutionResultState?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The config (or rather ext_costs within it) is necessary for the profile data computation. Since ext_costs always gets constructed as part of an overall Config, I didn't see a good reason to split it up anyhow. In principle ExecutionResultState::compute_outcome was the guiding factor on what to include here and what to leave back at VMLogic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(The comment also explains why this is specifically a "ResultState" -- it contains things that are strictly only for the eventual computation of a VMOutcome)

runtime/near-vm-runner/src/logic/logic.rs Outdated Show resolved Hide resolved
runtime/near-vm-runner/src/logic/logic.rs Outdated Show resolved Hide resolved
runtime/near-vm-runner/src/logic/logic.rs Outdated Show resolved Hide resolved
runtime/near-vm-runner/src/logic/logic.rs Outdated Show resolved Hide resolved
@nagisa nagisa added this pull request to the merge queue Jun 25, 2024
Merged via the queue into near:master with commit 2b6030c Jun 25, 2024
29 of 30 checks passed
@nagisa nagisa deleted the splits-vmlogic branch June 25, 2024 10:24
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.

2 participants