This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully dockerize
cape-demo-docker
(#979)
- Add script to initialize geth with deployed contract. - Build docker image with initialized geth `cape/geth` on github.
- Loading branch information
Showing
9 changed files
with
164 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ __pycache__/ | |
/doc/mdbook | ||
.*.sw* | ||
|
||
demo/ | ||
scratch/ |
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,11 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2022 Espresso Systems (espressosys.com) | ||
# This file is part of the Configurable Asset Privacy for Ethereum (CAPE) library. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
set -eu | ||
|
||
docker build -t cape/geth -f ./demo/geth.Dockerfile . |
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,9 @@ | ||
CAPE_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9 | ||
CAPE_TOKEN_ADDRESS=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 | ||
CAPE_ADDRESS_BOOK_PORT=50000 | ||
CAPE_EQS_PORT=50010 | ||
CAPE_FAUCET_PORT=50030 | ||
CAPE_RELAYER_PORT=50020 | ||
CAPE_WALLET_PORT=50040 | ||
CAPE_RELAYER_WALLET_MNEMONIC="test test test test test test test test test test test junk" | ||
CAPE_FAUCET_WALLET_MNEMONIC="test test test test test test test test test test test junk" |
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,6 @@ | ||
FROM ethereum/client-go:v1.10.15 | ||
COPY demo/start-geth-docker /start-geth-docker | ||
COPY scratch/geth-data-dir /data | ||
ENTRYPOINT [] | ||
CMD ["/bin/sh", "/start-geth-docker"] | ||
EXPOSE 8545 |
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,65 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) 2022 Espresso Systems (espressosys.com) | ||
# This file is part of the Configurable Asset Privacy for Ethereum (CAPE) library. | ||
# | ||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
set -euo pipefail | ||
|
||
RED='\033[0;31m' | ||
GETH_PORT=8545 | ||
|
||
if nc -z localhost $GETH_PORT 2>&1; then | ||
echo -e "${RED}GETH_PORT $GETH_PORT already in use! Aborting" | ||
exit 1 | ||
fi | ||
|
||
# Create a faucet manager wallet and export variables printed to stdout | ||
export CAPE_FAUCET_MANAGER_MNEMONIC="$TEST_MNEMONIC" | ||
source <(cargo run --release --bin faucet-wallet-test-setup) | ||
|
||
# | ||
# Set up a geth chain and deploy the contracts. Then shut it down. | ||
# | ||
GETH_DATA_DIR="scratch/geth-data-dir" | ||
echo "Using keystore dir $GETH_DATA_DIR" | ||
mkdir -p "$GETH_DATA_DIR" | ||
|
||
NUM_KEYS=2 | ||
ADDRESS_LIST=$(hdwallet-derive --mnemonic "$TEST_MNEMONIC" --num-keys $NUM_KEYS --property address | tr '\n' ',') | ||
# Default to 1 second block time | ||
PERIOD=${GETH_PERIOD:-1} | ||
make-genesis-block --addresses $ADDRESS_LIST --period $PERIOD > $GETH_DATA_DIR/genesis.json | ||
|
||
# Import private keys generated by hdwallet-derive script into geth | ||
while IFS= read -r LINE || [[ -n "$LINE" ]]; do | ||
echo "Importing private key $LINE" | ||
geth --verbosity 0 --datadir "$GETH_DATA_DIR" \ | ||
account import --password <(echo "") <(echo $LINE) | ||
done < <(hdwallet-derive --mnemonic "$TEST_MNEMONIC" --num-keys $NUM_KEYS --property private_key) | ||
|
||
echo "Initializing geth with genesis file" | ||
geth --dev init --datadir $GETH_DATA_DIR $GETH_DATA_DIR/genesis.json | ||
|
||
# docker compose will issue lots of warnings if some variables are not set, even | ||
# if these aren't needed to start this particular service. | ||
echo "Starting geth node ..." | ||
geth --http --dev --verbosity 1 \ | ||
--mine --maxpeers 0 --nodiscover \ | ||
--miner.gaslimit 25000000 \ | ||
--allow-insecure-unlock \ | ||
--password <(echo "") \ | ||
--datadir $GETH_DATA_DIR --unlock $ADDRESS_LIST & | ||
geth_pid=$! | ||
|
||
# Deploy contracts (this requires the address/key exported with the | ||
# faucet-wallet-test-setup binary) | ||
hardhat deploy --reset | ||
|
||
# Stop the geth node | ||
echo "Sending TERM signal to geth: PID $geth_pid" | ||
kill -TERM $geth_pid | ||
|
||
echo "Geth DATA_DIR at $GETH_DATA_DIR" |
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,14 @@ | ||
#!/usr/bin/env sh | ||
set -eu | ||
|
||
# Use `hdwallet-derive` to generate the addresses from a mnenmonic | ||
ADDRESS_LIST="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266,0x70997970C51812dc3A010C7d01b50e0d17dc79C8" | ||
|
||
geth --dev \ | ||
--http --http.addr 0.0.0.0 --http.vhosts "*" \ | ||
--verbosity 1 \ | ||
--mine --maxpeers 0 --nodiscover \ | ||
--miner.gaslimit 25000000 \ | ||
--allow-insecure-unlock \ | ||
--password <(echo "") \ | ||
--datadir /data --unlock $ADDRESS_LIST |
Oops, something went wrong.