Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

PVF prechecking #4209

Closed
wants to merge 60 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f271c09
pvf host: store only compiled artifacts on disk
slumber Sep 22, 2021
554b8a0
Correctly handle failed artifacts
slumber Sep 23, 2021
8bdc7d3
Serialize result of PVF preparation uniquely
slumber Sep 23, 2021
7c0b8ed
Set the artifact state depending on the result
slumber Sep 27, 2021
11de207
Return the result of PVF preparation directly
slumber Sep 27, 2021
d323ac6
Move PrepareError to the error module
slumber Sep 27, 2021
f129cd6
Update doc comments
slumber Sep 27, 2021
cae0540
Update misleading comment
slumber Sep 27, 2021
5c12abb
Commit everything so far
pepyakin Sep 29, 2021
e5e905e
.
pepyakin Sep 29, 2021
574dc40
first revision
pepyakin Oct 1, 2021
9eff8d5
work
pepyakin Oct 2, 2021
c81cdc6
Stuff
pepyakin Oct 3, 2021
67e0395
fix reference counting for rejecting
pepyakin Oct 3, 2021
b8487ed
fixes
pepyakin Oct 4, 2021
a6863ce
rename
pepyakin Oct 4, 2021
d387231
paragenesisargs
pepyakin Oct 4, 2021
33127f4
prepare to pivot
pepyakin Oct 5, 2021
d3f51aa
Restore ParaPastCodeMeta
pepyakin Oct 5, 2021
ce67024
Restore stealing mechanism
pepyakin Oct 5, 2021
ad4fe78
Fix test compilation
pepyakin Oct 5, 2021
efdb781
Fix tests
pepyakin Oct 11, 2021
81bb85d
Update rustdoc for paras
pepyakin Oct 12, 2021
dbe031e
get back validation code length check
pepyakin Oct 12, 2021
6481e26
Merge master
pepyakin Oct 13, 2021
b73f244
small test refactor
pepyakin Oct 13, 2021
a7e9890
General clean up
pepyakin Oct 14, 2021
8af822f
Merge master
pepyakin Oct 14, 2021
0f61c09
Runtime API
pepyakin Oct 14, 2021
8805d5c
Client side implementation
pepyakin Oct 21, 2021
e84d310
pvf host: turn off parallel compilation
slumber Oct 21, 2021
78fad55
pvf host: implement precheck requests
slumber Oct 21, 2021
7e25dc0
Fix warnings
slumber Oct 21, 2021
c90f64f
Unnecessary clone
slumber Oct 22, 2021
57255fa
Add a note about timed out outcome
slumber Oct 22, 2021
2f05716
Revert the pool outcome handling behavior
slumber Oct 22, 2021
66f05c5
Move the prepare result type into error mod
slumber Oct 22, 2021
3cca95a
Merge master
pepyakin Oct 22, 2021
8f51e94
Test prepare done
slumber Oct 22, 2021
b17eb79
Merge remote-tracking branch 'origin/master' into slumber-pvf-host-pr…
slumber Oct 22, 2021
d38e164
fmt
slumber Oct 22, 2021
a6c6f1a
Add an explanation to wasmtime config
slumber Nov 1, 2021
907c4a5
Split pvf host test
slumber Nov 1, 2021
84e1481
Merge remote-tracking branch 'origin/pep-pvfcheck-runtime' into slumb…
slumber Nov 2, 2021
e7001e7
Handle precheck request in candidate validation subsystem
slumber Nov 3, 2021
2751871
Complete runtime impls
slumber Nov 3, 2021
31af008
Merge remote-tracking branch 'origin/master' into slumber-pvf-prechec…
slumber Nov 3, 2021
49cf80c
Integrate node changes
slumber Nov 16, 2021
47e52ba
Expand the debug log
pepyakin Nov 16, 2021
74a1b25
0.9.13 is the current upcoming version
pepyakin Nov 17, 2021
cc09b8f
Pass the outcome
pepyakin Nov 17, 2021
c272f04
Merge master
pepyakin Nov 17, 2021
9f8fe1c
Make paras module backwards compatible with pre-go-ahead runtimes
pepyakin Nov 18, 2021
31b95fd
Fix tests for the backwards compatible approach
pepyakin Nov 18, 2021
7c15bf2
Use non-empty validation code
pepyakin Nov 18, 2021
f49cbf3
fmt
pepyakin Nov 18, 2021
892e7fa
Doc changes
pepyakin Nov 18, 2021
53f4d8c
Drive by comment
pepyakin Nov 23, 2021
7e4ba34
merge master
pepyakin Nov 23, 2021
92d620d
Fix
pepyakin Nov 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Serialize result of PVF preparation uniquely
slumber committed Sep 23, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 8bdc7d3791aec014a3f1dd26b2291add569bc07a
65 changes: 34 additions & 31 deletions node/core/pvf/src/prepare/worker.rs
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ use async_std::{
use futures::FutureExt as _;
use futures_timer::Delay;
use parity_scale_codec::{Decode, Encode};
use sp_core::hexdisplay::HexDisplay;
use std::{sync::Arc, time::Duration};

const NICENESS_BACKGROUND: i32 = 10;
@@ -114,37 +115,39 @@ pub async fn start_work(
let selected = futures::select! {
res = framed_recv(&mut stream).fuse() => {
match res {
Ok(x) if x == &[1u8] => {
tracing::debug!(
target: LOG_TARGET,
worker_pid = %pid,
"promoting WIP artifact {} to {}",
tmp_file.display(),
artifact_path.display(),
);

async_std::fs::rename(&tmp_file, &artifact_path)
.await
.map(|_| Selected::Done(Ok(())))
.unwrap_or_else(|err| {
tracing::warn!(
Ok(response_bytes) => {
// By convention we expect encoded `Result<(), PrepareError>`.
if let Ok(result) =
<Result<(), PrepareError>>::decode(&mut response_bytes.clone().as_slice())
{
if result.is_ok() {
tracing::debug!(
target: LOG_TARGET,
worker_pid = %pid,
"failed to rename the artifact from {} to {}: {:?}",
"promoting WIP artifact {} to {}",
tmp_file.display(),
artifact_path.display(),
err,
);
Selected::IoErr
})
}
Ok(response_bytes) => {
use sp_core::hexdisplay::HexDisplay;
// By convention we expect encoded prepare error.
// If bytes cannot be deserialized, return io error.
if let Ok(error) = PrepareError::decode(&mut response_bytes.clone().as_slice()) {
Selected::Done(Err(error))

async_std::fs::rename(&tmp_file, &artifact_path)
.await
.map(|_| Selected::Done(result))
.unwrap_or_else(|err| {
tracing::warn!(
target: LOG_TARGET,
worker_pid = %pid,
"failed to rename the artifact from {} to {}: {:?}",
tmp_file.display(),
artifact_path.display(),
err,
);
Selected::IoErr
})
} else {
Selected::Done(result)
}
} else {
// We received invalid bytes from the worker.
let bound_bytes = &response_bytes[..response_bytes.len().min(4)];
tracing::warn!(
target: LOG_TARGET,
@@ -282,15 +285,15 @@ pub fn worker_entrypoint(socket_path: &str) {
"worker: preparing artifact",
);

let bytes = match prepare_artifact(&code) {
let result = match prepare_artifact(&code) {
Artifact::Error(err) => {
// Serialized error will be written into the socket.
err.encode()
Err(err)
},
Artifact::Compiled(compiled_artifact) => {
// Write the serialized artifact into a temp file.
// Since a compiled artifact can be heavy, we only send a single
// byte to indicate the success.
// Since a compiled artifact can be heavy, we send an empty
// `Ok` to indicate the success.
let artifact_bytes = compiled_artifact.encode();

tracing::debug!(
@@ -301,11 +304,11 @@ pub fn worker_entrypoint(socket_path: &str) {
);
async_std::fs::write(&dest, &artifact_bytes).await?;

vec![1u8]
Ok(())
},
};

framed_send(&mut stream, &bytes).await?;
framed_send(&mut stream, result.encode().as_slice()).await?;
}
});
}