Skip to content
This repository was archived by the owner on Feb 14, 2021. It is now read-only.
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
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ rust:
sudo: required
services:
- docker

before_install:
# Install wasm toolchain and put it in the PATH
- WATERFALL_BUILD=31834 ./wasm-install.sh
- export PATH=$PATH:./wasm-install/bin
script:
- rustup target add wasm32-unknown-unknown
- cargo install pwasm-utils --version 0.1
- ./build.sh
- ./build-all.sh
23 changes: 23 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

./build-rust-test.sh alloc
./build-rust-test.sh call
./build-rust-test.sh call_code
./build-rust-test.sh call_static
./build-rust-test.sh creator
./build-rust-test.sh dispersion
./build-rust-test.sh empty
./build-rust-test.sh externs
./build-rust-test.sh events
./build-rust-test.sh identity
./build-rust-test.sh logger
./build-rust-test.sh realloc
./build-rust-test.sh rterr
./build-rust-test.sh keccak
./build-rust-test.sh suicidal
./build-rust-test.sh storage_read
./build-rust-test.sh math
./build-rust-test.sh setter
./build-wat.sh recursive
10 changes: 10 additions & 0 deletions build-rust-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

TEST_NAME=$1

cargo run --manifest-path ./gen/Cargo.toml -- $TEST_NAME
RUSTFLAGS="-C link-arg=-z -C link-arg=stack-size=65536" CARGO_TARGET_DIR=./target cargo build --manifest-path=./target/tests/$TEST_NAME/Cargo.toml --release --target=wasm32-unknown-unknown
wasm-build ./target $TEST_NAME --target wasm32-unknown-unknown
cp ./target/$TEST_NAME.wasm ./compiled
8 changes: 0 additions & 8 deletions build-test.sh

This file was deleted.

11 changes: 11 additions & 0 deletions build-wat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

TEST_NAME=$1

mkdir -p ./target/wasm32-unknown-unknown/release/
wat2wasm src/$TEST_NAME.wat -o ./target/wasm32-unknown-unknown/release/$TEST_NAME.wasm

wasm-build ./target $TEST_NAME --target wasm32-unknown-unknown
cp ./target/$TEST_NAME.wasm ./compiled
20 changes: 0 additions & 20 deletions build.sh

This file was deleted.

Binary file modified compiled/alloc.wasm
Binary file not shown.
Binary file modified compiled/call.wasm
Binary file not shown.
Binary file modified compiled/call_code.wasm
Binary file not shown.
Binary file modified compiled/call_static.wasm
Binary file not shown.
Binary file modified compiled/creator.wasm
Binary file not shown.
Binary file modified compiled/dispersion.wasm
Binary file not shown.
Binary file modified compiled/empty.wasm
Binary file not shown.
Binary file modified compiled/events.wasm
Binary file not shown.
Binary file modified compiled/externs.wasm
Binary file not shown.
Binary file modified compiled/identity.wasm
Binary file not shown.
Binary file modified compiled/keccak.wasm
Binary file not shown.
Binary file modified compiled/logger.wasm
Binary file not shown.
Binary file modified compiled/math.wasm
Binary file not shown.
Binary file modified compiled/realloc.wasm
Binary file not shown.
Binary file added compiled/recursive.wasm
Binary file not shown.
Binary file modified compiled/rterr.wasm
Binary file not shown.
Binary file modified compiled/setter.wasm
Binary file not shown.
Binary file modified compiled/storage_read.wasm
Binary file not shown.
Binary file modified compiled/suicidal.wasm
Binary file not shown.
9 changes: 7 additions & 2 deletions gen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ version = "0.1.0"
authors = ["NikVolf <nikvolf@gmail.com>"]

[dependencies]
pwasm-std = "0.5.0"
pwasm-ethereum = "0.1.0"
pwasm-std = "0.9.0"
pwasm-ethereum = "0.5.0"
bigint = { version = "4", default-features = false }

[lib]
name = "$file_name"
path = "main.rs"
crate-type = ["cdylib"]

[profile.release]
panic = "abort"
lto = true
opt-level = "z"
"#;

let target_toml = toml.replace("$file_name", file_name);
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2018-02-05
nightly-2018-06-28
4 changes: 2 additions & 2 deletions src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use pwasm_std::Vec;
#[no_mangle]
pub fn call() {
ext::ret(&{
let mut data = Vec::with_capacity(450 * 1024);
data.extend_from_slice(&[5u8; 450*1024][..]);
let mut data = Vec::with_capacity(400 * 1024);
data.extend_from_slice(&[5u8; 400*1024][..]);
data
});
}
51 changes: 51 additions & 0 deletions src/recursive.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(module
(import "env" "fetch_input" (func $fetch_input (param i32)))
(import "env" "input_length" (func $input_length (result i32)))


(func (export "call")
;; Assert that input_length is exactly 4 bytes long.
(if
(i32.ne
(call $input_length)
(i32.const 4)
)
(unreachable)
)

;; Load input data at the address 0.
;;
;; It contains only 1 word that represents an iteration count.
(call $fetch_input
(i32.const 0)
)

;; Load the iteration count from the address 0 and then
;; call $recursive with this number.
;; Drop the result (since it's always zero).
(drop
(call $recursive
(i32.load
(i32.const 0)
)
)
)
)

(func $recursive (param i32) (result i32)
block $out (result i32)
get_local 0
get_local 0
i32.eqz
br_if $out

i32.const 1
i32.sub
call $recursive
end
)

(table 0 anyfunc)
(memory 1)
(export "memory" (memory 0))
)
14 changes: 14 additions & 0 deletions wasm-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# this script is intended to be used from .travis.yml.
# Takes an environment variable WATERFALL_BUILD to download a
# specific version of a waterfall build.

set -e

if [ -z ${WATERFALL_BUILD+x} ]; then
echo "the WATERFALL_BUILD environment variable is unset";
exit 1;
fi

curl -sL https://storage.googleapis.com/wasm-llvm/builds/linux/$WATERFALL_BUILD/wasm-binaries.tbz2 | tar xvkj