Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d366157
add C example, handwritten example, and generic tester
poemm Feb 10, 2019
a27f8aa
typo
poemm Feb 10, 2019
11dc6bf
add corresponding wasm
poemm Feb 10, 2019
905163f
make generator more convenient
poemm Feb 10, 2019
5c12adf
recompile C version
poemm Feb 10, 2019
fb1b2b3
fixes
poemm Feb 11, 2019
3553ea7
add tester footer3.txt
poemm Feb 26, 2019
09d21cd
add workspace
jwasinger Apr 29, 2019
c1e8979
add circleCI support with truffle (WIP)
jwasinger May 4, 2019
aeab86e
.
jwasinger May 4, 2019
e01772e
.
jwasinger May 4, 2019
1461510
add truffle tests (no test generation yet)
jwasinger May 4, 2019
eb37ef4
.
jwasinger May 4, 2019
7545e23
.
jwasinger May 4, 2019
43596d4
.
jwasinger May 4, 2019
5e3cff7
.
jwasinger May 4, 2019
7bcea16
.
jwasinger May 4, 2019
bca28e4
.
jwasinger May 4, 2019
f7a8d11
.
jwasinger May 4, 2019
802d78f
.
jwasinger May 4, 2019
47ae06e
.
jwasinger May 8, 2019
af741d0
.
jwasinger May 10, 2019
9d22eed
f
jwasinger May 17, 2019
d66791e
more updates to pass truffle initial balance test
jwasinger May 20, 2019
0bd7d5a
f
jwasinger May 20, 2019
623529b
f
jwasinger May 20, 2019
674c787
f
jwasinger May 20, 2019
e0a9308
f
jwasinger May 20, 2019
f81737a
f
jwasinger May 20, 2019
71b62e4
f
jwasinger May 20, 2019
ae9bf3b
f
jwasinger May 20, 2019
82e5f9e
f
jwasinger May 21, 2019
50a85c9
f
jwasinger May 21, 2019
ef7c1b9
set correct amount for wrc20 challenge
jwasinger May 21, 2019
25674c0
f
jwasinger May 21, 2019
d76c51f
readme
jwasinger May 21, 2019
9c5acff
fix C contract
jwasinger Jun 1, 2019
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
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
defaults:
create_build_dir: &create_build_dir
run:
name: "create build directory"
command: |
mkdir build

build_c_example: &build_c_example
run:
name: "Build C Example"
command: |
# docker run -v $(pwd)/src/C:/C -t jwasinger/clang-7 bash -c "cd /C && make"
# C contracts need remap-exports support in chisel so skip building C wrc20 during CI
cp src/C/wrc20.wasm build/c.wasm

truffle: &truffle
run:
name: "run tests with truffle"
command: |
bash scripts/test_erc20.sh

version: 2
jobs:
build:
machine: true
steps:
- checkout
- *create_build_dir
- *build_c_example
- *truffle
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ function do_transfer() {
}
```

Then simply put it in a directory named after your language and send us a PR.
## Testing

**Dependencies**: Docker, NodeJS(>10)

Run:

```
node truffle/deploy-contract.js --wasm /path/to/yourContract.wasm
cd truffle
truffle test --network dev
```

Tests (currently barebones until WRC20 implementations are passing more tests) are located in http://github.com/ewasm/wrc20-examples/truffle/WRC20.template.js
3 changes: 3 additions & 0 deletions call.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

curl -H "Content-type: application/json" -X POST --data '{ "jsonrpc": "2.0", "id": 1, "method": "eth_call", "params": [ { "from": "0x7976977ecf72519e656a27c16b8c406329e46b78", "gas": "0x6691b7", "gasPrice": "0x4a817c800", "to": "0x8013314ea35839f2bb351c1efd2c163964ec3a3e", "data": "0xe3d670d70000000000000000000000008013314ea35839f2bb351c1efd2c163964ec3a3e" }, "latest" ] }' http://127.0.0.1:8545
2 changes: 2 additions & 0 deletions ci/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.ethash
data
35 changes: 35 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ethereum/cpp-build-env

COPY install_cmake.sh /

RUN bash /install_cmake.sh

ENV PATH="/root/.local/bin:${PATH}"

USER root

RUN curl https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz > go.tar.gz \
&& tar -C /usr/local -xvf go.tar.gz

ENV PATH="/usr/local/go/bin:${PATH}"

# hera 0.2.3 and ewasm-go-ethereum ewasm branch on 5/9/2019
RUN git clone https://github.com/ewasm/hera \
&& cd hera \
&& git reset 3a9b8cd5eda1d00205af1a14fca1dbfa0bddff9b --hard \
&& git submodule update --init \
&& mkdir build \
&& cd build \
&& cmake -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=ON .. \
&& make -j2 \
&& cd ../.. \
&& git clone https://github.com/ewasm/go-ethereum \
&& cd go-ethereum \
&& git reset 2cbecfcb65d428bc5d0ac590a6e4f03f2c12173a --hard \
&& make -j2 \
&& cd .. \
&& cp go-ethereum/build/bin/geth /root/ \
&& cp hera/build/src/libhera.so /root/ \
&& rm -rf go-ethereum hera

ENTRYPOINT ["/root/geth"]
28 changes: 28 additions & 0 deletions ci/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"config": {
"chainId": 66,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"ewasmBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5b79de34",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x87b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"7976977ecf72519e656a27c16b8c406329e46b78": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
10 changes: 10 additions & 0 deletions ci/init_geth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

if [ -d "hera" ]; then rm -Rf hera; fi

mkdir -p hera
(cd hera && wget https://github.com/ewasm/hera/releases/download/v0.2.3/hera-0.2.3-linux-x86_64.tar.gz && tar -xvf hera-0.2.3-linux-x86_64.tar.gz && cp lib/libhera.so .)

mkdir data
docker run -v $(pwd)/genesis.json:/genesis.json -v $(pwd)/data:/data -t jwasinger/client-go:ewasm init /genesis.json --datadir /data
docker run -v $(pwd)/keys:/keys -v $(pwd)/data:/data -t jwasinger/client-go:ewasm --datadir /data account import /keys/faucet/faucet-priv.txt --password /keys/faucet/faucet-pw.txt
51 changes: 51 additions & 0 deletions ci/install_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env sh

# This script downloads the CMake binary and installs it in $PREFIX directory
# (the cmake executable will be in $PREFIX/bin). By default $PREFIX is
# ~/.local but can we changes with --prefix <PREFIX> argument.

# This is mostly suitable for CIs, not end users.

set -e

VERSION=3.12.4

if [ "$1" = "--prefix" ]; then
PREFIX="$2"
else
PREFIX=~/.local
fi

OS=$(uname -s)
case $OS in
Linux) SHA256=486edd6710b5250946b4b199406ccbf8f567ef0e23cfe38f7938b8c78a2ffa5f;;
Darwin) SHA256=95d76c00ccb9ecb5cb51de137de00965c5e8d34b2cf71556cf8ba40577d1cff3;;
esac


BIN=$PREFIX/bin

if test -f $BIN/cmake && ($BIN/cmake --version | grep -q "$VERSION"); then
echo "CMake $VERSION already installed in $BIN"
else
FILE=cmake-$VERSION-$OS-x86_64.tar.gz
URL=https://cmake.org/files/v3.12/$FILE
ERROR=0
TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz)
echo "Downloading CMake ($URL)..."
curl -s "$URL" > "$TMPFILE"

if type -p sha256sum > /dev/null; then
SHASUM="sha256sum"
else
SHASUM="shasum -a256"
fi

if ! ($SHASUM "$TMPFILE" | grep -q "$SHA256"); then
echo "Checksum mismatch ($TMPFILE)"
exit 1
fi
mkdir -p "$PREFIX"
tar xzf "$TMPFILE" -C "$PREFIX" --strip 1
rm $TMPFILE
fi
1 change: 1 addition & 0 deletions ci/keys/faucet/faucet-addr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7976977ecf72519e656a27c16b8c406329e46b78
5 changes: 5 additions & 0 deletions ci/keys/faucet/faucet-info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Address: 0x7976977ecf72519e656a27c16b8c406329e46b78
Address (checksum): 0x7976977eCF72519E656A27c16B8C406329e46b78
ICAP: XE23 E6RZ KK8J CRDJ S26Q 77EX VQXD 6FIF 9FC
Public key: 0x86a8770bafc76140e9c9990630d992234fe691e2a661efd5a7949407ade6fc4ba5881131a31f5bada0ad9228fd39c4cb3655f0eb8329e038156fbff8033d4bec
Private key: 0xcbfee4ca4db6cf6120e50eff7033ed6c65168ae4bd93bb66788ed1f50ff270fb
1 change: 1 addition & 0 deletions ci/keys/faucet/faucet-priv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cbfee4ca4db6cf6120e50eff7033ed6c65168ae4bd93bb66788ed1f50ff270fb
1 change: 1 addition & 0 deletions ci/keys/faucet/faucet-pw.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
Binary file added ci/libhera.so
Binary file not shown.
25 changes: 25 additions & 0 deletions ci/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "geth-docker-example",
"version": "1.0.0",
"description": "### Usage * Have Docker installed * Invoke `init_geth.sh` and then `run.sh` to start the client",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jwasinger/geth-docker-example.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jwasinger/geth-docker-example/issues"
},
"homepage": "https://github.com/jwasinger/geth-docker-example#readme",
"dependencies": {
"chai": "^4.2.0",
"openzeppelin-solidity": "^2.2.0",
"openzeppelin-test-helpers": "^0.3.2",
"web3": "^1.0.0-beta.53"
}
}
6 changes: 6 additions & 0 deletions ci/restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash

docker rm -f $(docker ps -qa)
sudo rm -rf data
./init_geth.sh
docker logs --follow $(./run.sh)
22 changes: 22 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash
set -e

docker run -d --network host -v $(pwd)/.ethash:/root/.ethash:Z -v $(pwd)/data:/data -v $(pwd)/keys:/keys -t jwasinger/client-go:ewasm-hera \
--etherbase $(cat keys/faucet/faucet-addr.txt) \
--mine \
--miner.threads 1 \
--networkid 66 \
--nodiscover \
--vmodule "rpc=12" \
--datadir /data \
--unlock $(cat keys/faucet/faucet-addr.txt) \
--rpc \
--rpcaddr '127.0.0.1' \
--rpcport 8545 \
--rpccorsdomain '*' \
--ws \
--wsaddr '0.0.0.0' \
--wsorigins '*' \
--password /keys/faucet/faucet-pw.txt \
--vm.ewasm="/root/libhera.so,metering=false" \
--vmodule "rpc=5,core/vm=5"
Binary file not shown.
Loading