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

Contracts: Translate .wat fixtures to rust #2654

Merged
merged 78 commits into from
Jan 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
9975e91
compile risc-v
pgherveou Nov 29, 2023
260411f
rm dup
pgherveou Nov 29, 2023
235b1f6
tweaks
pgherveou Nov 30, 2023
619f314
conditional build for riscv
pgherveou Nov 30, 2023
7b3e2fb
check CI & macos
pgherveou Nov 30, 2023
c28c53a
rm macos test
pgherveou Nov 30, 2023
4115768
PR review rm unneeded dep from Cargo.toml
pgherveou Dec 1, 2023
fb7d8fe
update rustup_toolchain
pgherveou Dec 7, 2023
d4533ee
Merge branch 'pg/riscv-fixtures' of https://github.com/paritytech/pol…
pgherveou Dec 7, 2023
3fc102f
Merge branch 'master' into pg/riscv-fixtures
pgherveou Dec 7, 2023
10ef504
fix build
pgherveou Dec 7, 2023
d39ceeb
testing
pgherveou Dec 7, 2023
14f48fc
rm warnings on risc-v
pgherveou Dec 7, 2023
43bb175
specify rustup_home
pgherveou Dec 7, 2023
382042b
Merge branch 'pg/riscv-fixtures' of https://github.com/paritytech/pol…
pgherveou Dec 7, 2023
2c1ea12
rollback toolchain name
pgherveou Dec 7, 2023
7bb8397
Merge branch 'master' into pg/riscv-fixtures
pgherveou Dec 7, 2023
ddbddaf
Test updating openssl
pgherveou Dec 8, 2023
0bd773c
used shared toolchain name
pgherveou Dec 8, 2023
07a4520
fix
pgherveou Dec 8, 2023
0adc1e9
Update toolchain name
pgherveou Dec 11, 2023
366acbd
Update error message
pgherveou Dec 11, 2023
c077e4b
Update .gitlab-ci.yml
pgherveou Dec 12, 2023
29d188d
Apply suggestions from code review
pgherveou Dec 12, 2023
e1f7df1
Update substrate/frame/contracts/fixtures/build.rs
pgherveou Dec 12, 2023
cbf90e5
Apply suggestions from code review
pgherveou Dec 12, 2023
c17cb91
try new ci image
alvicsam Dec 12, 2023
a3b8913
Merge branch 'master' into pg/riscv-fixtures
pgherveou Dec 13, 2023
f501a49
update ci image
alvicsam Dec 13, 2023
7ea4e83
update cargo.lock
alvicsam Dec 13, 2023
6dbc6cc
Fix CI for new ci image (#2701)
alvicsam Dec 13, 2023
2bb8c47
Cargo.lock
alvicsam Dec 13, 2023
65e04fe
Merge branch 'master' into pg/riscv-fixtures
alvicsam Dec 13, 2023
af99fbd
Cargo.lock
alvicsam Dec 14, 2023
f265376
Update to make it work while we are getting the CI toolchain ready
pgherveou Jan 2, 2024
5d50f14
Merge branch 'master' into pg/riscv-fixtures
pgherveou Jan 2, 2024
ead54b4
update lock
pgherveou Jan 2, 2024
547d2e6
clippy fixes
pgherveou Jan 2, 2024
2c46883
fix test
pgherveou Jan 2, 2024
d97459d
revert docker file images
pgherveou Jan 2, 2024
5bf77a3
add comment
pgherveou Jan 2, 2024
a9186b8
fix
pgherveou Jan 2, 2024
d75d5f1
rm comment
pgherveou Jan 3, 2024
71f3249
update
pgherveou Jan 3, 2024
328e450
update
pgherveou Jan 3, 2024
3b34076
Roll back hacks
pgherveou Jan 3, 2024
b0a2d8b
fix
pgherveou Jan 3, 2024
b1ce7f3
fixes
pgherveou Jan 3, 2024
0c7385e
move stuff from pg/add-fixtures in this PR
pgherveou Jan 4, 2024
cfeb1ba
Update substrate/frame/contracts/fixtures/Cargo.toml
pgherveou Jan 4, 2024
bab4839
Update substrate/frame/contracts/fixtures/build/riscv_memory_layout.ld
pgherveou Jan 4, 2024
cf6ca58
Merge branch 'master' into pg/riscv-fixtures
pgherveou Jan 4, 2024
dac377c
update lock
pgherveou Jan 4, 2024
ae228f7
Add fixtures
pgherveou Dec 7, 2023
a9e3b0d
Merge branch 'master' into pg/add-fixtures
pgherveou Jan 4, 2024
3b9149e
clippy lints
pgherveou Jan 4, 2024
cf24a38
PR comment: rm useless cfg
pgherveou Jan 5, 2024
5ef8a26
Leave MaxEncodedLen as marker trait
pgherveou Jan 5, 2024
ba98c6c
fix doc
pgherveou Jan 5, 2024
853e5c3
add back import
pgherveou Jan 5, 2024
4daf1b7
Add regression test
pgherveou Jan 5, 2024
68d7079
add back chain extension stuffs
pgherveou Jan 5, 2024
e4fdea8
use val1
pgherveou Jan 5, 2024
bd6a2cd
bump polkavm
pgherveou Jan 5, 2024
53489f6
Contracts rename riscv-experimental and enable ci tests
pgherveou Jan 8, 2024
cdecb95
Merge branch 'master' into pg/add-fixtures
pgherveou Jan 8, 2024
6b15780
Fix uapi signature s/Option<&mut [u8]>/Option<&mut &mut [u8]>
pgherveou Jan 8, 2024
edb4f1a
Merge branch 'master' into pg/add-fixtures
pgherveou Jan 9, 2024
0143d30
".git/.scripts/commands/fmt/fmt.sh"
Jan 9, 2024
9998a96
Merge branch 'master' into pg/add-fixtures
pgherveou Jan 9, 2024
62f9ae1
fix for new toolchain
pgherveou Jan 9, 2024
0e3cfea
fmt
pgherveou Jan 9, 2024
1ded19f
Try to add back some inline(always) statement to compare contracts size
pgherveou Jan 9, 2024
f9d16f2
Revert "Try to add back some inline(always) statement to compare cont…
pgherveou Jan 10, 2024
9396576
Tweak to reduce sizes
pgherveou Jan 12, 2024
679fa53
fmt
pgherveou Jan 12, 2024
4f4d8eb
Fix
pgherveou Jan 12, 2024
92cfb13
Merge branch 'master' into pg/add-fixtures
pgherveou Jan 12, 2024
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
check CI & macos
  • Loading branch information
pgherveou committed Nov 30, 2023
commit 7b3e2fb04c6438d97c0eb359c419ce0f5b7cbfcd
29 changes: 5 additions & 24 deletions substrate/frame/contracts/fixtures/build.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ fn file_hash(path: &Path) -> String {
let mut hasher = XxHash32::default();
hasher.write(&data);
hasher.write(include_bytes!("build.rs"));
hasher.write(&[is_riscv_supported().into()]);
let hash = hasher.finish();
format!("{:x}", hash)
}
@@ -211,27 +210,8 @@ fn post_process_wasm(input_path: &Path, output_path: &Path) -> Result<()> {
serialize_to_file(output_path, module).map_err(Into::into)
}

/// Check if RISC-V toolchain is installed.
fn is_riscv_supported() -> bool {
use std::sync::OnceLock;
static IS_RISCV_SUPPORTED: OnceLock<bool> = OnceLock::new();
*IS_RISCV_SUPPORTED.get_or_init(|| {
let cmd = Command::new("rustup")
.args(&["toolchain", "list"])
.output()
.expect("failed to execute process");

let stdout = String::from_utf8(cmd.stdout).unwrap();
stdout.contains("riscv32em-nightly-2023-04-05")
})
}

/// Build contracts for RISC-V.
fn invoke_riscv_build(current_dir: &Path) -> Result<()> {
if !is_riscv_supported() {
return Ok(())
}

let encoded_rustflags =
["-Crelocation-model=pie", "-Clink-arg=--emit-relocs", "-Clink-arg=-Tmemory.ld"]
.join("\x1f");
@@ -258,10 +238,6 @@ fn invoke_riscv_build(current_dir: &Path) -> Result<()> {
}
/// Post-process the compiled wasm contracts.
fn post_process_riscv(input_path: &Path, output_path: &Path) -> Result<()> {
if !is_riscv_supported() {
return Ok(())
}

let mut config = polkavm_linker::Config::default();
config.set_strip(true);
let orig = fs::read(input_path).with_context(|| format!("Failed to read {:?}", input_path))?;
@@ -310,6 +286,11 @@ fn find_workspace_root(current_dir: &Path) -> Option<PathBuf> {
}

fn main() -> Result<()> {
// Skip build if CI and macos for now since we don't have the RISC-V toolchain easily available there.
if env::var("CI").is_ok() && cfg!(target_os = "macos") {
return Ok(())
}

let fixtures_dir: PathBuf = env::var("CARGO_MANIFEST_DIR")?.into();
let contracts_dir = fixtures_dir.join("contracts");
let out_dir: PathBuf = env::var("OUT_DIR")?.into();