Skip to content

Commit

Permalink
chore: add run_geth.sh
Browse files Browse the repository at this point in the history
Added `run_geth.sh` helps to test geth with zktrie or not.

```shell
$ ZK=1 sh run_geth.sh # with zk trie
$ sh run_geth.sh # without zk trie
```
  • Loading branch information
chokobole committed Dec 4, 2022
1 parent 4ced37c commit 06d9c56
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 6 deletions.
6 changes: 3 additions & 3 deletions genesis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"config": {
"chainId": 53077,
"chainId": 7790,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand All @@ -20,13 +20,13 @@
},
"nonce": "0x0",
"timestamp": "0x61bc34a0",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000004cb1ab63af5d8931ce09673ebd8ae2ce16fd65710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000bada1d8e766dbc7c3043007a7186f57c0678e28f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"4cb1ab63af5d8931ce09673ebd8ae2ce16fd6571": {
"bada1d8e766dbc7c3043007a7186f57c0678e28f": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
Expand Down
6 changes: 3 additions & 3 deletions genesis_zktrie.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"config": {
"chainId": 53077,
"chainId": 7790,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand All @@ -20,13 +20,13 @@
},
"nonce": "0x0",
"timestamp": "0x61bc34a0",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000004cb1ab63af5d8931ce09673ebd8ae2ce16fd65710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000bada1d8e766dbc7c3043007a7186f57c0678e28f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x6691b7",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"4cb1ab63af5d8931ce09673ebd8ae2ce16fd6571": {
"bada1d8e766dbc7c3043007a7186f57c0678e28f": {
"balance": "0x56BC75E2D63100000000000000000000000000000000000000000000000000"
}
},
Expand Down
74 changes: 74 additions & 0 deletions run_geth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/sh
set -exu

ZK=${ZK:-0}
if [ $ZK == 1 ]; then
echo "ZK"
GETH_DATA_DIR=./data_zk
GENESIS_FILE_PATH="${GENESIS_FILE_PATH:-./genesis_zktrie.json}"
else
echo "NON-ZK"
GETH_DATA_DIR=./data
GENESIS_FILE_PATH="${GENESIS_FILE_PATH:-./genesis.json}"
fi

VERBOSITY=${GETH_VERBOSITY:-3}
GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata"
GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore"
CHAIN_ID=$(cat "$GENESIS_FILE_PATH" | jq -r .config.chainId)
BLOCK_SIGNER_PRIVATE_KEY="0xec4d17b92a785136c39472014d7c7f5cde6ef5b56cbab8d10fd4d8e7e3e5f96c"
BLOCK_SIGNER_ADDRESS="0xBaDa1d8e766dbC7c3043007a7186F57c0678E28f"
RPC_PORT="${RPC_PORT:-8545}"
WS_PORT="${WS_PORT:-8546}"

mkdir -p $GETH_DATA_DIR

if [ ! -d "$GETH_KEYSTORE_DIR" ]; then
echo "$GETH_KEYSTORE_DIR missing, running account import"
echo "pwd" > "$GETH_DATA_DIR"/password
echo "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key
build/bin/geth account import \
--datadir="$GETH_DATA_DIR" \
--password="$GETH_DATA_DIR"/password \
"$GETH_DATA_DIR"/block-signer-key
else
echo "$GETH_KEYSTORE_DIR exists."
fi

if [ ! -d "$GETH_CHAINDATA_DIR" ]; then
echo "$GETH_CHAINDATA_DIR missing, running init"
echo "Initializing genesis."
build/bin/geth --verbosity="$VERBOSITY" init \
--datadir="$GETH_DATA_DIR" \
"$GENESIS_FILE_PATH"
else
echo "$GETH_CHAINDATA_DIR exists."
fi

# Warning: Archive mode is required, otherwise old trie nodes will be
# pruned within minutes of starting the devnet.

exec build/bin/geth \
--datadir="$GETH_DATA_DIR" \
--verbosity="$VERBOSITY" \
--http \
--http.corsdomain="*" \
--http.vhosts="*" \
--http.addr=0.0.0.0 \
--http.port="$RPC_PORT" \
--http.api=web3,debug,eth,txpool,net,engine,voost \
--ws \
--ws.addr=0.0.0.0 \
--ws.port="$WS_PORT" \
--ws.origins="*" \
--ws.api=debug,eth,txpool,net,engine,voost \
--syncmode=full \
--nodiscover \
--maxpeers=1 \
--networkid=$CHAIN_ID \
--unlock=$BLOCK_SIGNER_ADDRESS \
--mine \
--password="$GETH_DATA_DIR"/password \
--allow-insecure-unlock \
--trace.mptwitness=1 \
"$@"

0 comments on commit 06d9c56

Please sign in to comment.