-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to manual parsing for validation (#157)
* wasm-parser: remove parity-wasm dependency * wasm-parser: proof of basic idea * wasm-parser: import instruction mappings from parity-wasm * wasm-parser: build and link with kernel * wasm-parser: fix parsing of import entries * wasm-parser: add missing file * kernel: add test script * wasm-parser: minor cleanup * circleci: don't force rebuild of parity-ethereum * kernel: update tests to be more accurate * kernel: update nightly version for alloc crate * circleci: fix error with parity installation * circleci: fix error in previous commit * wasm-parser: reinclude alloc * wasm-parser: merge Cursor and CodeCursor * circleci: add example contract 2 * circleci: set-up environment for test * circleci: fix example_contract_2 build * wasm-parser: properly validate instructions in syscall * wasm-parser: fix import cursor progression * circleci: remove config step from parity * circleci: clear cache
- Loading branch information
1 parent
f912c3d
commit 2f83b1c
Showing
23 changed files
with
3,915 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "example_contract_2" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
pwasm-std = "0.13" | ||
pwasm-ethereum = { version = "0.8", features = ["kip6"] } | ||
pwasm-abi = "0.2" | ||
pwasm-abi-derive = "0.2" | ||
tiny-keccak = "1.4.2" | ||
|
||
[dev-dependencies] | ||
pwasm-test = { git = "https://github.com/paritytech/pwasm-test" } | ||
cap9-build = { path = "../../cap9-build" } | ||
pwasm-utils-cli = "0.7.0" | ||
|
||
[features] | ||
default = [] | ||
std = ["pwasm-std/std", "pwasm-ethereum/std"] | ||
|
||
[lib] | ||
crate-type = ["cdylib"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@echo OFF | ||
|
||
mkdir .\build | ||
|
||
rustup target add wasm32-unknown-unknown | ||
REM cargo install pwasm-utils-cli --bin wasm-build --force | ||
|
||
set contract_name=example_contract_2 | ||
|
||
cargo build --release --target wasm32-unknown-unknown | ||
REM We don't need to use cap9 build here as it contains no syscalls | ||
wasm-build --target=wasm32-unknown-unknown .\target %contract_name% | ||
|
||
copy .\target\*.wasm .\build | ||
copy .\target\json\* .\build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@echo OFF | ||
|
||
mkdir ./build | ||
|
||
rustup target add wasm32-unknown-unknown | ||
REM cargo install pwasm-utils-cli --bin wasm-build --force | ||
cargo install --path ../../cap9-build --bin cap9-build --force | ||
|
||
export contract_name=example_contract_2 | ||
|
||
cargo build --release --target wasm32-unknown-unknown | ||
# We don't need to use cap9 build here as it contains no syscalls | ||
wasm-build --target=wasm32-unknown-unknown ./target $contract_name | ||
|
||
cp ./target/*.wasm ./build | ||
cp ./target/json/* ./build |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#![cfg_attr(not(feature="std"), no_std)] | ||
|
||
#![allow(non_snake_case)] | ||
|
||
extern crate tiny_keccak; | ||
extern crate pwasm_std; | ||
extern crate pwasm_ethereum; | ||
extern crate pwasm_abi; | ||
extern crate pwasm_abi_derive; | ||
|
||
use tiny_keccak::Keccak; | ||
use pwasm_ethereum as eth; | ||
use pwasm_abi::types::*; | ||
use pwasm_abi_derive::eth_abi; | ||
use pwasm_ethereum::Error; | ||
|
||
/// The call function is the main function of the *deployed* contract | ||
#[no_mangle] | ||
pub fn call() { | ||
let mut endpoint = contract::ExampleContract2Endpoint::new(contract::ExampleContract2{}); | ||
pwasm_ethereum::ret(&endpoint.dispatch(&pwasm_ethereum::input())); | ||
} | ||
|
||
// Declares the dispatch and dispatch_ctor methods | ||
use pwasm_abi::eth::EndpointInterface; | ||
|
||
#[no_mangle] | ||
pub fn deploy() { | ||
let mut endpoint = contract::ExampleContract2Endpoint::new(contract::ExampleContract2{}); | ||
endpoint.dispatch_ctor(&pwasm_ethereum::input()); | ||
} | ||
|
||
|
||
pub mod contract { | ||
use super::*; | ||
use pwasm_abi_derive::eth_abi; | ||
|
||
#[eth_abi(ExampleContract2Endpoint, ExampleContract2Client)] | ||
pub trait ExampleContract2Interface { | ||
/// Check if Procedure Contract is Valid | ||
fn check_contract(&mut self, _to: Address) -> bool; | ||
} | ||
|
||
pub struct ExampleContract2; | ||
|
||
impl ExampleContract2Interface for ExampleContract2 { | ||
fn check_contract(&mut self, _target: Address) -> bool { | ||
// unimplemented!() | ||
false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
nightly-2019-04-01 | ||
nightly-2019-06-06 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pushd example_contract_2 | ||
sh ./build.sh | ||
popd | ||
mocha tests/**/**.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.