Starting point for Foundry
I still need to finish it up, but geth runs properly.
This commit is contained in:
parent
f4b7bd4a14
commit
4704c4416d
1
.gitignore
vendored
1
.gitignore
vendored
@ -47,3 +47,4 @@ profile.cov
|
||||
/dashboard/assets/package-lock.json
|
||||
|
||||
**/yarn-error.log
|
||||
foundry/deployments/local-private-network/geth-linux-amd64
|
||||
|
21
foundry/deployments/local-private-network/Dockerfile
Normal file
21
foundry/deployments/local-private-network/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM frolvlad/alpine-bash
|
||||
|
||||
RUN apk update ; apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ --allow-untrusted ca-certificates curl bash git jshon jq
|
||||
|
||||
#USER guest
|
||||
WORKDIR /root
|
||||
|
||||
# copy all files
|
||||
ADD ./deploy-local-network.sh .
|
||||
ADD ./geth-linux-amd64 /bin/geth
|
||||
ADD ./start-private-network.sh .
|
||||
|
||||
RUN curl -L https://foundry.paradigm.xyz | bash; \
|
||||
/bin/bash -c 'source $HOME/.bashrc'; \
|
||||
/root/.foundry/bin/foundryup
|
||||
|
||||
RUN chmod +x /bin/geth
|
||||
|
||||
EXPOSE 8545
|
||||
EXPOSE 8546
|
||||
ENTRYPOINT ["./start-private-network.sh"]
|
16
foundry/deployments/local-private-network/compile-geth.sh
Executable file
16
foundry/deployments/local-private-network/compile-geth.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
start_path=$(pwd)
|
||||
cd ../../../
|
||||
echo -e "${GREEN}Building geth!${NC}"
|
||||
docker build -t vulcanize/go-ethereum -f Dockerfile .
|
||||
docker run --rm --entrypoint cat vulcanize/go-ethereum /usr/local/bin/geth > foundry/deployments/local-private-network/geth-linux-amd64
|
||||
chmod +x foundry/deployments/local-private-network/geth-linux-amd64
|
||||
|
||||
echo -e "${GREEN}geth build complete!${NC}"
|
||||
cd $start_path
|
187
foundry/deployments/local-private-network/deploy-local-network.sh
Executable file
187
foundry/deployments/local-private-network/deploy-local-network.sh
Executable file
@ -0,0 +1,187 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
OPTS="dapp testnet [<options>] <args>...
|
||||
dapp testnet --help
|
||||
--
|
||||
db-user=name database user
|
||||
db-password=password database password
|
||||
db-name=name database name
|
||||
db-host=address database host
|
||||
db-port=port database port
|
||||
db-write=bool turn on database write mode
|
||||
db-type=name the type of database
|
||||
db-driver=name the driver used for the database
|
||||
db-waitforsync=bool Should the statediff service start once geth has synced to head (default: false)
|
||||
rpc-port=port change RPC port (default: 8545)
|
||||
rpc-addr=address change RPC address (default: 127.0.0.1)
|
||||
chain-id=number change chain ID (default: 99)
|
||||
period=seconds use a block time instead of instamine
|
||||
accounts=number create multiple accounts (default: 1)
|
||||
address=address eth address to add to genesis
|
||||
save=name after finishing, save snapshot
|
||||
load=name start from a previously saved snapshot
|
||||
dir=directory testnet directory
|
||||
"
|
||||
|
||||
eval "$(
|
||||
git rev-parse --parseopt -- "$@" <<<"$OPTS" || echo exit $?
|
||||
)"
|
||||
|
||||
DB_USER=vdbm
|
||||
DB_PASSWORD=password
|
||||
DB_NAME=vulcanize_public
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_TYPE=postgres
|
||||
DB_DRIVER=sqlx
|
||||
DB_WAIT_FOR_SYNC=false
|
||||
RPC_PORT=8545
|
||||
RPC_ADDRESS=127.0.0.1
|
||||
PERIOD=0
|
||||
CHAINID=99
|
||||
ACCOUNTS=0
|
||||
ADDRESS=
|
||||
gethdir=$HOME/testnet
|
||||
|
||||
while [[ $1 ]]; do
|
||||
case $1 in
|
||||
--) shift; break;;
|
||||
--db-user) shift; DB_USER=$1;;
|
||||
--db-password) shift; DB_PASSWORD=$1;;
|
||||
--db-name) shift; DB_NAME=$1;;
|
||||
--db-host) shift; DB_HOST=$1;;
|
||||
--db-port) shift; DB_PORT=$1;;
|
||||
--db-write) shift; DB_WRITE=$1;;
|
||||
--db-type) shift; DB_TYPE=$1;;
|
||||
--db-driver) shift; DB_DRIVER=$1;;
|
||||
--db-waitforsync) shift; DB_WAIT_FOR_SYNC=$1;;
|
||||
--rpc-port) shift; RPC_PORT=$1;;
|
||||
--rpc-addr) shift; RPC_ADDRESS=$1;;
|
||||
--chain-id) shift; CHAINID=$1;;
|
||||
--period) shift; PERIOD=$1;;
|
||||
--accounts) shift; ACCOUNTS=$1;;
|
||||
--save) shift; SAVE=$1;;
|
||||
--address) shift; ADDRESS=$1;;
|
||||
--load) shift; LOAD=$1;;
|
||||
--dir) shift; gethdir=$1;;
|
||||
*) printf "${0##*/}: internal error: %q\\n" "$1"; exit 1
|
||||
esac; shift
|
||||
done
|
||||
|
||||
chaindir=$gethdir/$RPC_PORT
|
||||
#while true; do
|
||||
# if [[ ! -d "$gethdir/$CHAINID" ]]; then break; fi
|
||||
# CHAINID=$((CHAINID + 1))
|
||||
#done
|
||||
|
||||
mkdir -p "$chaindir/config"
|
||||
#if [ -n "$ADDRESS" ]; then
|
||||
# balance+=(-n {} -s "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" -i balance \
|
||||
# -i "$ADDRESS")
|
||||
#fi
|
||||
for i in $(seq 0 "$ACCOUNTS"); do
|
||||
address+=( "$(
|
||||
geth 2>/dev/null account new --datadir "$chaindir" --password=<(exit) 2>/dev/null \
|
||||
| grep -o -E "0x[A-Fa-f0-9]*" )" )
|
||||
# balance+=(-n {} -s "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" -i balance \
|
||||
# -i "${address[i]}")
|
||||
balance+=(' "'"${address[i]}"'": { "balance": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}')
|
||||
done
|
||||
|
||||
#ALLOC_CLEAN=$(echo ${ALLOC} | jq .)
|
||||
EXTRA_DATA="0x3132333400000000000000000000000000000000000000000000000000000000${address[0]#0x}0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
JSON_VAL='{
|
||||
"config": {
|
||||
"chainId": '"$CHAINID"',
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"byzantiumBlock": 0,
|
||||
"constantinopleBlock": 0,
|
||||
"petersburgBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"clique": {
|
||||
"period": '"$PERIOD"',
|
||||
"epoch": 3000
|
||||
}
|
||||
},
|
||||
"difficulty": "0x1",
|
||||
"gaslimit": "0xffffffffffff",
|
||||
"extraData": "'"$EXTRA_DATA"'",
|
||||
"alloc": {'"$balance"'}
|
||||
}'
|
||||
echo $JSON_VAL | jq . > $chaindir/config/genesis.json
|
||||
|
||||
geth 2>/dev/null --datadir "$chaindir" init "$chaindir/config/genesis.json"
|
||||
|
||||
export ETH_RPC_URL=http://$RPC_ADDRESS:$RPC_PORT
|
||||
|
||||
port=$((RPC_PORT + 30000))
|
||||
|
||||
geth version
|
||||
echo >&2 "dapp-testnet: RPC URL: $ETH_RPC_URL"
|
||||
echo >&2 "dapp-testnet: TCP port: $port"
|
||||
echo >&2 "dapp-testnet: Chain ID: $CHAINID"
|
||||
echo >&2 "dapp-testnet: Database: $chaindir"
|
||||
echo >&2 "dapp-testnet: Geth log: $chaindir/geth.log"
|
||||
|
||||
printf "%s\n" "${address[@]}" > "$chaindir/config/account"
|
||||
echo "$ETH_RPC_URL" > "$chaindir/config/rpc-url"
|
||||
echo "$port" > "$chaindir/config/node-port"
|
||||
|
||||
set +m
|
||||
# Uncomment below once waitforsync has been merged
|
||||
# geth \
|
||||
# 2> >(tee "$chaindir/geth.log" | grep --line-buffered Success | sed 's/^/geth: /' >&2) \
|
||||
# --datadir "$chaindir" --networkid "$CHAINID" --port="$port" \
|
||||
# --mine --miner.threads=1 --allow-insecure-unlock \
|
||||
# --http --http.api "web3,eth,net,debug,personal,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
|
||||
# --http.addr="$RPC_ADDRESS" --http.port="$RPC_PORT" --syncmode=full --gcmode=archive \
|
||||
# --statediff --statediff.db.host="$DB_HOST" --statediff.db.port="$DB_PORT" --statediff.db.user="$DB_USER" \
|
||||
# --statediff.db.password="$DB_PASSWORD" --statediff.db.name="$DB_NAME" \
|
||||
# --statediff.db.nodeid 1 --statediff.db.clientname test1 --statediff.writing="$DB_WRITE" \
|
||||
# --statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" --statediff.waitforsync="$DB_WAIT_FOR_SYNC" \
|
||||
# --ws --ws.addr="0.0.0.0" --unlock="$(IFS=,; echo "${address[*]}")" --password=<(exit) &
|
||||
|
||||
geth \
|
||||
2> >(tee "$chaindir/geth.log" | grep --line-buffered Success | sed 's/^/geth: /' >&2) \
|
||||
--datadir "$chaindir" --networkid "$CHAINID" --port="$port" \
|
||||
--mine --miner.threads=1 --allow-insecure-unlock \
|
||||
--http --http.api "web3,eth,net,debug,personal,statediff" --http.corsdomain '*' --http.vhosts '*' --nodiscover \
|
||||
--http.addr="$RPC_ADDRESS" --http.port="$RPC_PORT" --syncmode=full --gcmode=archive \
|
||||
--statediff --statediff.db.host="$DB_HOST" --statediff.db.port="$DB_PORT" --statediff.db.user="$DB_USER" \
|
||||
--statediff.db.password="$DB_PASSWORD" --statediff.db.name="$DB_NAME" \
|
||||
--statediff.db.nodeid 1 --statediff.db.clientname test1 --statediff.writing="$DB_WRITE" \
|
||||
--statediff.db.type="$DB_TYPE" --statediff.db.driver="$DB_DRIVER" \
|
||||
--ws --ws.addr="0.0.0.0" --unlock="$(IFS=,; echo "${address[*]}")" --password=<(exit) &
|
||||
|
||||
gethpid=$!
|
||||
|
||||
clean() {
|
||||
( set -x; kill -INT $gethpid; wait )
|
||||
if [[ $SAVE ]]; then
|
||||
echo >&2 "dapp-testnet: saving $gethdir/snapshots/$SAVE"
|
||||
mkdir -p "$gethdir/snapshots/$SAVE"
|
||||
cp -r "$chaindir/keystore" "$gethdir/snapshots/$SAVE"
|
||||
cp -r "$chaindir/config" "$gethdir/snapshots/$SAVE"
|
||||
geth >/dev/null 2>&1 --datadir "$chaindir" \
|
||||
export "$gethdir/snapshots/$SAVE/backup"
|
||||
fi
|
||||
( set -x; rm -rf "$chaindir" )
|
||||
}
|
||||
trap clean EXIT
|
||||
|
||||
until curl -s "$ETH_RPC_URL"; do sleep 1; done
|
||||
|
||||
# UPDATE
|
||||
#ETH_FROM=$(seth --rpc-url="$ETH_RPC_URL" rpc eth_coinbase)
|
||||
#export ETH_FROM
|
||||
export ETH_KEYSTORE=$chaindir/keystore
|
||||
export ETH_PASSWORD=/dev/null
|
||||
printf 'dapp-testnet: Account: %s (default)\n' "${address[0]}" >&2
|
||||
|
||||
[[ "${#address[@]}" -gt 1 ]] && printf 'dapp-testnet: Account: %s\n' "${address[@]:1}" >&2
|
||||
|
||||
while true; do sleep 3600; done
|
37
foundry/deployments/local-private-network/docker-compose.yml
Normal file
37
foundry/deployments/local-private-network/docker-compose.yml
Normal file
@ -0,0 +1,37 @@
|
||||
version: "3.2"
|
||||
|
||||
services:
|
||||
foundry:
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- ipld-eth-db
|
||||
build: ./
|
||||
environment:
|
||||
DB_USER: vdbm
|
||||
DB_NAME: vulcanize_testing
|
||||
DB_HOST: ipld-eth-db
|
||||
DB_PORT: 5432
|
||||
DB_PASSWORD: password
|
||||
DB_WRITE: "true"
|
||||
DB_TYPE: postgres
|
||||
DB_DRIVER: sqlx
|
||||
DB_WAIT_FOR_SYNC: "true"
|
||||
ports:
|
||||
- "127.0.0.1:8545:8545"
|
||||
- "127.0.0.1:8546:8546"
|
||||
|
||||
ipld-eth-db:
|
||||
restart: always
|
||||
image: vulcanize/ipld-eth-db:v3.0.6
|
||||
environment:
|
||||
POSTGRES_USER: "vdbm"
|
||||
POSTGRES_DB: "vulcanize_testing"
|
||||
POSTGRES_PASSWORD: "password"
|
||||
volumes:
|
||||
- vdb_db_eth_server:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "127.0.0.1:8077:5432"
|
||||
command: ["postgres", "-c", "log_statement=all"]
|
||||
|
||||
volumes:
|
||||
vdb_db_eth_server:
|
36
foundry/deployments/local-private-network/start-private-network.sh
Executable file
36
foundry/deployments/local-private-network/start-private-network.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# clean up
|
||||
trap 'killall geth && rm -rf "$TMPDIR"' EXIT
|
||||
trap "exit 1" SIGINT SIGTERM
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
/bin/bash deploy-local-network.sh --rpc-addr 0.0.0.0 --chain-id 4 --db-user $DB_USER --db-password $DB_PASSWORD --db-name $DB_NAME \
|
||||
--db-host $DB_HOST --db-port $DB_PORT --db-write $DB_WRITE --dir "$TMPDIR" --address $ADDRESS \
|
||||
--db-type $DB_TYPE --db-driver $DB_DRIVER --db-waitforsync $DB_WAIT_FOR_SYNC &
|
||||
echo "sleeping 90 sec"
|
||||
# give it a few secs to start up
|
||||
sleep 90
|
||||
|
||||
#read -r ACC BAL <<< "$(seth ls --keystore "$TMPDIR/8545/keystore")"
|
||||
#echo $ACC
|
||||
#echo $BAL
|
||||
#
|
||||
#
|
||||
## Deploy a contract:
|
||||
#solc --bin --bin-runtime docker/stateful.sol -o "$TMPDIR"
|
||||
#A_ADDR=$(seth send --create "$(<"$TMPDIR"/A.bin)" "constructor(uint y)" 1 --from "$ACC" --keystore "$TMPDIR"/8545/keystore --password /dev/null --gas 0xfffffff)
|
||||
#
|
||||
#echo $A_ADDR
|
||||
#
|
||||
## Call transaction
|
||||
#
|
||||
#TX=$(seth send "$A_ADDR" "off()" --gas 0xffff --password /dev/null --from "$ACC" --keystore "$TMPDIR"/8545/keystore --async)
|
||||
#echo $TX
|
||||
#RESULT=$(seth run-tx "$TX")
|
||||
#echo $RESULT
|
||||
|
||||
# Run forever
|
||||
tail -f /dev/null
|
Loading…
Reference in New Issue
Block a user