near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.3k stars 600 forks source link

vm: split preparation and running of a contract #11667

Closed nagisa closed 4 days ago

nagisa commented 1 week ago

This is a very exciting step forward! Finally we got up to the point where we can do some work in preparing the contract to run separately from actual running of the contract. And all of this is encapsulated in a very neat API that gives out Send + 'static types for users to pass around between threads or whatever so that they can pipeline these processes.

It will remain to see whether the requirement to have &External and &VMContext in both calls is a problem, and how much of a problem it is, but that might be very well solvable with some scoped threads or smart use of channels, or even just Arc<Mutex>, especially since both of these structures generally tend to be unique to a contract execution...

Part of https://github.com/near/nearcore/issues/11319

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 78.06691% with 59 lines in your changes missing coverage. Please review.

Project coverage is 71.79%. Comparing base (2b6030c) to head (d9154d9). Report is 22 commits behind head on master.

Files Patch % Lines
runtime/near-vm-runner/src/wasmtime_runner.rs 77.64% 16 Missing and 3 partials :warning:
runtime/near-vm-runner/src/wasmer_runner.rs 65.38% 14 Missing and 4 partials :warning:
runtime/near-vm-runner/src/wasmer2_runner.rs 86.79% 4 Missing and 3 partials :warning:
...ntime/runtime-params-estimator/src/gas_metering.rs 53.33% 7 Missing :warning:
runtime/near-vm-runner/fuzz/src/lib.rs 0.00% 3 Missing :warning:
...time/runtime-params-estimator/src/function_call.rs 57.14% 3 Missing :warning:
...untime/near-vm-runner/src/near_vm_runner/runner.rs 97.36% 0 Missing and 1 partial :warning:
runtime/near-vm-runner/src/runner.rs 66.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #11667 +/- ## ========================================== + Coverage 71.62% 71.79% +0.16% ========================================== Files 787 790 +3 Lines 161191 161951 +760 Branches 161191 161951 +760 ========================================== + Hits 115461 116278 +817 + Misses 40697 40636 -61 - Partials 5033 5037 +4 ``` | [Flag](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | Coverage Δ | | |---|---|---| | [backward-compatibility](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (-0.01%)` | :arrow_down: | | [db-migration](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.23% <0.00%> (-0.01%)` | :arrow_down: | | [genesis-check](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.35% <0.00%> (-0.01%)` | :arrow_down: | | [integration-tests](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `37.91% <29.36%> (+0.09%)` | :arrow_up: | | [linux](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `69.15% <78.06%> (+0.14%)` | :arrow_up: | | [linux-nightly](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `71.31% <78.06%> (+0.17%)` | :arrow_up: | | [macos](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `51.02% <72.44%> (-0.36%)` | :arrow_down: | | [pytests](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.58% <0.00%> (-0.01%)` | :arrow_down: | | [sanity-checks](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `1.38% <0.00%> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `66.33% <74.34%> (+0.08%)` | :arrow_up: | | [upgradability](https://app.codecov.io/gh/near/nearcore/pull/11667/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near) | `0.28% <0.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=near#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.