From ca76cc70346ff31d6c6bba572582f91fcce7ed76 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 5 Dec 2020 20:34:40 +0200 Subject: [PATCH] Support non deterministic account creation in ganache --- docker/README.md | 2 +- docker/env/ganache.env | 1 - docker/ganache/start-blockchain.sh | 43 ++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/docker/README.md b/docker/README.md index 9b54fec..8e690cf 100644 --- a/docker/README.md +++ b/docker/README.md @@ -42,7 +42,7 @@ bellow. | --- | --- | --- | | ACCOUNTS_NUMBER | 10 | Set the number of accounts generated | | ACCOUNTS_ETHER | 10 | Set the amount of ETH assigned to each account | -| MNEMONIC | myth like bonus scare over problem client lizard pioneer submit female collect | The mnemonic phrase sued as a seed for deterministic account generation | +| MNEMONIC | NaN | The mnemonic phrase sued as a seed for deterministic account generation | | HOST | 0.0.0.0 | The hostname to listen on | | PORT | 8545 | The port to listen on | | NETWORK_ID | 5778 | The network id used to identify ganache | diff --git a/docker/env/ganache.env b/docker/env/ganache.env index 90caed3..2d1c080 100644 --- a/docker/env/ganache.env +++ b/docker/env/ganache.env @@ -1,6 +1,5 @@ ACCOUNTS_NUMBER=5 ACCOUNTS_ETHER=1 -MNEMONIC="myth like bonus scare over problem client lizard pioneer submit female collect" HOST=0.0.0.0 PORT=8545 NETWORK_ID=5778 diff --git a/docker/ganache/start-blockchain.sh b/docker/ganache/start-blockchain.sh index 6d3b4c9..36aceea 100644 --- a/docker/ganache/start-blockchain.sh +++ b/docker/ganache/start-blockchain.sh @@ -2,21 +2,36 @@ N_ACCOUNTS="${ACCOUNTS_NUMBER:-10}" ETHER="${ACCOUNTS_ETHER:-10}" -MNEMONIC="${MNEMONIC:-"myth like bonus scare over problem client lizard pioneer submit female collect"}" HOST="${HOST:-"0.0.0.0"}" PORT="${PORT:-8545}" ID="${NETWORK_ID:-5778}" -node /app/ganache-core.docker.cli.js \ - -a "$N_ACCOUNTS" \ - -e "$ETHER" \ - -m "$MNEMONIC" \ - -h "$HOST" \ - -p "$PORT" \ - -i "$ID" \ - --account_keys_path "/home/ganache_keys/keys.json" \ - --db "/home/ganache_db/" \ - --allowUnlimitedContractSize \ - --noVMErrorsOnRPCResponse \ - -d \ - -v +if [ -z "${MNEMONIC}" ]; then + echo "Starting Ganache with non deterministic address generation" + node /app/ganache-core.docker.cli.js \ + --accounts "$N_ACCOUNTS" \ + --defaultBalanceEther "$ETHER" \ + --host "$HOST" \ + --port "$PORT" \ + --networkId "$ID" \ + --account_keys_path "/home/ganache_keys/keys.json" \ + --db "/home/ganache_db/" \ + --allowUnlimitedContractSize \ + --noVMErrorsOnRPCResponse \ + --verbose +else + echo "Starting Ganache with deterministic address generation" + node /app/ganache-core.docker.cli.js \ + --accounts "$N_ACCOUNTS" \ + --defaultBalanceEther "$ETHER" \ + --mnemonic "$MNEMONIC" \ + --host "$HOST" \ + --port "$PORT" \ + --networkId "$ID" \ + --account_keys_path "/home/ganache_keys/keys.json" \ + --db "/home/ganache_db/" \ + --allowUnlimitedContractSize \ + --noVMErrorsOnRPCResponse \ + --deterministic \ + --verbose +fi