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

chore(ci): add ci #18

Merged
merged 11 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ insert_final_newline=true

[Makefile]
indent_style=tab

[*.{yml, yaml}]
indent_style = space
indent_size = 2
tab_width = 8
end_of_line = lf
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Check

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

env:
CARGO_TERM_COLOR: always

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Install toolchain targeting RV32E
run: |
curl -sL https://github.com/paritytech/rustc-rv32e-toolchain/releases/download/v1.1.0/rust-rve-nightly-2024-01-05-x86_64-unknown-linux-gnu.tar.zst -o rv32e.tar.zst
tar --zstd -xf rv32e.tar.zst
mv rve-nightly ~/.rustup/toolchains/

- uses: Swatinem/rust-cache@v2

- name: Check format
run: cargo fmt --all -- --check

- name: Install polkatool
run: make tools

- name: Generate poc-guest.polkavm
run: make poc-guest

- name: Custom cargo clippy
run: make clippy
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "vendor/polkavm"]
path = vendor/polkavm
url = https://github.com/koute/polkavm
url = https://github.com/acalanetwork/polkavm
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ tools:
cargo install --git https://github.com/koute/polkavm --force polkatool
cargo install --git https://github.com/paritytech/polkadot-sdk --tag polkadot-v1.9.0 --force staging-chain-spec-builder

fmt:
cargo fmt --all -- --check

check:
cargo check --no-default-features --target=wasm32-unknown-unknown -p poc-executor
SKIP_WASM_BUILD= cargo check
cd poc/guest; cargo check

clippy:
cargo clippy --no-default-features --target=wasm32-unknown-unknown -p poc-executor
SKIP_WASM_BUILD= cargo clippy -- -D warnings
cd poc/guest; cargo clippy

chainspec:
cargo build -p poc-runtime --release
mkdir -p output
cp target/release/wbuild/poc-runtime/poc_runtime.compact.compressed.wasm output
chain-spec-builder -c output/chainspec.json create -n poc-runtime -i poc-runtime -r ./output/poc_runtime.compact.compressed.wasm -s default
cat output/chainspec.json | jq '.properties = {}' > output/chainspec.json.tmp
Expand Down
4 changes: 2 additions & 2 deletions poc/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl<Ctx: XcqExecutorContext> XcqExecutor<Ctx> {
}

pub fn execute(&mut self, raw_blob: &[u8], input: &[u8]) -> Result<Vec<u8>, XcqExecutorError> {
let blob = ProgramBlob::parse(raw_blob)?;
let module = Module::from_blob(&self.engine, &Default::default(), &blob)?;
let blob = ProgramBlob::parse(raw_blob.into())?;
let module = Module::from_blob(&self.engine, &Default::default(), blob)?;
let instance_pre = self.linker.instantiate_pre(&module)?;
let instance = instance_pre.instantiate()?;

Expand Down
4 changes: 2 additions & 2 deletions poc/guest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern "C" fn main(ptr: u32) -> u64 {
let size = core::mem::size_of_val(val);
let val_ptr = val.as_ptr();

(val_ptr as u64) << 32 | size as u64 / core::mem::size_of::<u8>() as u64
(val_ptr as u64) << 32 | (size as u64 / core::mem::size_of::<u8>() as u64)
}
1 => {
let val = unsafe { core::ptr::read_volatile((ptr + 1) as *const u8) };
Expand All @@ -63,7 +63,7 @@ extern "C" fn main(ptr: u32) -> u64 {
host_call(guest_args, &mut ret);
let res = ret.data0 as u32 + 1;
let size = core::mem::size_of_val(&res);
(&res as *const u32 as u64) << 32 | size as u64 / core::mem::size_of::<u32>() as u64
(&res as *const u32 as u64) << 32 | (size as u64 / core::mem::size_of::<u32>() as u64)
}
_ => 0,
}
Expand Down
Loading