Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a563e25
make pruning explicit
eagr Oct 17, 2023
f31d354
preserve cache unless stale
eagr Oct 17, 2023
195bbce
barely working
eagr Oct 17, 2023
99aa012
use ArtifactId::from_file_name()
eagr Oct 17, 2023
17973ef
ignore non-unicode file names
eagr Oct 17, 2023
e81b456
generalize concat_const!()
eagr Oct 18, 2023
851a77a
per advices
eagr Oct 18, 2023
a3b0fcf
break on IO error
eagr Oct 18, 2023
b323c28
make pruning sound
eagr Oct 18, 2023
a2808f8
log more events
eagr Oct 18, 2023
0657d41
refactor
eagr Oct 20, 2023
0384ae7
doc
eagr Oct 20, 2023
4b1bb0a
Refactor indentation
mrcnski Oct 21, 2023
a8bcce4
refactor
eagr Oct 21, 2023
50b7ccc
checksum poc
eagr Oct 22, 2023
b6c1a07
Revert "checksum poc"
eagr Oct 30, 2023
2ad5262
redo checksum p1
eagr Oct 30, 2023
3723806
p2
eagr Oct 30, 2023
e44c451
remove corrupted cache
eagr Oct 31, 2023
6c19164
diversify results
eagr Nov 1, 2023
dad5285
fix tests
eagr Nov 1, 2023
1ede201
fix pruning
eagr Nov 1, 2023
2d51b52
fix message serialization
eagr Nov 1, 2023
36a33e8
clean up
eagr Nov 1, 2023
69f6a44
retire path_prefix()
eagr Nov 2, 2023
d3254f5
improve test
eagr Nov 3, 2023
f4d22fa
Merge branch 'master' into preserve-art
mrcnski Nov 12, 2023
39448ff
Fix test
mrcnski Nov 12, 2023
3a2c1cd
cargo fmt
mrcnski Nov 12, 2023
a02cb06
as per advices
eagr Nov 13, 2023
53e4557
tag artifact with runtime version
eagr Nov 13, 2023
d4f3083
fix tests
eagr Nov 13, 2023
9d2142e
Merge branch 'master' into preserve-art
mrcnski Nov 14, 2023
931aae1
upstream build fn to substrate
eagr Nov 15, 2023
5de4e8e
glitch
eagr Nov 15, 2023
a0b71c5
wrong attribution
eagr Nov 15, 2023
c85adfe
as per suggestions
eagr Nov 17, 2023
b897f1c
glitch
eagr Nov 17, 2023
89ada31
prevent `cargo tree` from accessing network
eagr Nov 17, 2023
868426a
glitch
eagr Nov 17, 2023
652bec7
Merge branch 'master' into preserve-art
eagr Nov 19, 2023
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
generalize concat_const!()
  • Loading branch information
eagr committed Oct 18, 2023
commit e81b45666f08035e9708460d27efa163b18362bb
60 changes: 30 additions & 30 deletions polkadot/node/core/pvf/src/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,40 @@ use std::{
};

macro_rules! concat_const {
($x:expr, $y:expr) => {{
// ensure inputs to be strings
const _: &str = $x;
const _: &str = $y;

const X: &[u8] = $x.as_bytes();
const Y: &[u8] = $y.as_bytes();
const XL: usize = X.len();
const YL: usize = Y.len();
const L: usize = XL + YL;

const fn concat() -> [u8; L] {
let mut cat = [0u8; L];
let mut i = 0;
while i < XL {
cat[i] = X[i];
i += 1;
}
while i < L {
cat[i] = Y[i - XL];
i += 1;
}
cat
}

// SAFETY: safe because x and y are ensured to be valid
unsafe { std::str::from_utf8_unchecked(&concat()) }
}};
($($arg:tt),*) => {{
// ensure inputs to be strings
$(const _: &str = $arg;)*

const LEN: usize = 0 $(+ $arg.len())*;

const CAT: [u8; LEN] = {
let mut cat = [0u8; LEN];
// for turning off unused warning
let mut _offset = 0;

$({
const BYTES: &[u8] = $arg.as_bytes();

let mut i = 0;
let len = BYTES.len();
while i < len {
cat[_offset + i] = BYTES[i];
i += 1;
}
_offset += len;
})*

cat
};

// SAFETY: safe because x and y are guaranteed to be valid
unsafe { std::str::from_utf8_unchecked(&CAT) }
}}
}

const RUNTIME_PREFIX: &str = "wasmtime_";
const NODE_PREFIX: &str = "polkadot_v";
const ARTIFACT_PREFIX: &str =
concat_const!(RUNTIME_PREFIX, concat_const!(NODE_PREFIX, NODE_VERSION));
const ARTIFACT_PREFIX: &str = concat_const!(RUNTIME_PREFIX, NODE_PREFIX, NODE_VERSION);

/// Identifier of an artifact. Encodes a code hash of the PVF and a hash of executor parameter set.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand Down