-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
387 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.DS_Store | ||
build/deployments | ||
**/.idea/ | ||
build/devnet/anvil_state.json |
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,33 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Run Anvil in the background | ||
cmd="anvil --host 0.0.0.0 --dump-state anvil_state.json" | ||
eval "${cmd}" &>/dev/null & disown; | ||
|
||
|
||
# Check Anvil is ready | ||
retries=0 | ||
max_retries=50 | ||
while [ $retries -lt $max_retries ]; do | ||
|
||
ready=$(curl -X POST -s -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"net_listening","params":[]}' http://127.0.0.1:8545 | jq '.result') | ||
|
||
if [ "$ready" == "true" ]; then | ||
echo "Anvil is ready" | ||
break | ||
else | ||
sleep 3 | ||
fi | ||
done | ||
|
||
|
||
# Deploy contracts with Foundry | ||
### DEPLOY CONTRACTS HERE ### | ||
|
||
# TEMP : To help debug | ||
# read -n 1 -s -r -p "Press any key to continue" | ||
|
||
sleep 3 | ||
#Kill Anvil ( just exit ) | ||
exit 0 |
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,38 @@ | ||
# syntax=docker.io/docker/dockerfile:1.4 | ||
FROM debian:bookworm-20230814-slim as devnet-base | ||
|
||
# install curl and jq (for healthcheck support) | ||
RUN <<EOF | ||
apt-get update | ||
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends ca-certificates curl git jq xxd | ||
rm -rf /var/lib/apt/lists/* | ||
EOF | ||
|
||
# download pre-compiled binaries | ||
RUN curl -sSL https://github.com/foundry-rs/foundry/releases/download/nightly/foundry_nightly_linux_$(dpkg --print-architecture).tar.gz | \ | ||
tar -zx -C /usr/local/bin | ||
|
||
# healthcheck script using net_listening JSON-RPC method | ||
COPY eth_isready /usr/local/bin | ||
|
||
HEALTHCHECK CMD eth_isready | ||
CMD ["anvil"] | ||
|
||
|
||
FROM devnet-base as devnet-deploy | ||
|
||
WORKDIR /usr/share/cartesi | ||
COPY deploy-rollups-anvil.sh . | ||
|
||
RUN ./deploy-rollups-anvil.sh . | ||
|
||
|
||
FROM devnet-base as devnet | ||
|
||
WORKDIR /usr/share/cartesi | ||
COPY ./entrypoint.sh / | ||
COPY --from=devnet-deploy /usr/share/cartesi/anvil_state.json . | ||
COPY --from=devnet-deploy /usr/share/cartesi/localhost.json . | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["anvil", "--load-state", "/usr/share/cartesi/state.json"] |
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,3 @@ | ||
#!/bin/sh | ||
jq -r '.contracts | to_entries | .[] | "\(.value.address) \(.key)"' < /usr/share/cartesi/localhost.json | ||
exec "$@" |
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 @@ | ||
#!/usr/bin/env sh | ||
|
||
# https://ethereum.org/en/developers/docs/apis/json-rpc/#net_listening | ||
curl -X POST -s -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"1","method":"net_listening","params":[]}' ${RPC_URL:-http://127.0.0.1:8545} | jq '.result' |
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,26 @@ | ||
|
||
# Run Node Devnet infrastrucuture | ||
|
||
## Run infrastructure with sample echo DApp | ||
|
||
``` | ||
docker compose up | ||
``` | ||
|
||
## Send input | ||
|
||
``` | ||
INPUT=0x68656C6C6F206E6F6465 ;\ | ||
INPUT_BOX_ADDRESS=0x59b22D57D4f067708AB0c00552767405926dc768 ;\ | ||
DAPP_ADDRESS=0x70ac08179605AF2D9e75782b8DEcDD3c22aA4D0C ;\ | ||
cast send $INPUT_BOX_ADDRESS "addInput(address,bytes)(bytes32)" $DAPP_ADDRESS $INPUT --mnemonic "test test test test test test test test test test test junk" --rpc-url "http://localhost:8545" | ||
``` | ||
|
||
## query input | ||
|
||
Access `http://localhost:4000/graphql` and execute query | ||
``` | ||
query{ | ||
notices {edges{node{index,payload,input{payload}}}} | ||
} | ||
``` |
Oops, something went wrong.