Consensys / quorum-genesis-tool

The quorum genesis tool creates genesis configs, configuration files, and keys for Hyperledger Besu, GoQuorum and Tessera.
Apache License 2.0
20 stars 18 forks source link

genesis tool should allow users to skip the timestamp suffix behavior in output dir #42

Closed luisnaranjo733 closed 1 year ago

luisnaranjo733 commented 1 year ago

Currently when you run the genesis tool, it allows you to override the output path with user input, but it nests the output inside a subfolder which is named with an arbitrary timestamp (see this line of code)

This seems by design, but it would be great if there was another boolean flag that users could set to bypass this behavior such as --noOutputTimestamp

By setting this flag, users could tell the genesis tool to skip that nested timestamp folder logic and instead output the files directly into the folder the user has already specified

The reason for this change is that the current default behavior makes it hard to consume the output automatically by a script, because that script would need to parse the STDOUT spew to find the subdir time stamp name

luisnaranjo733 commented 1 year ago

Came up with some bash regex to parse this from the STDOUT spew Not pretty but a decent workaround for now

# Generate genesis files, tessera keys, ethereum keys, and node keys
function generate_genesis() {
  echo "Generating genesis files..."
  npx quorum-genesis-tool \
  --outputPath ./output \
  --consensus qbft \
  --chainID 1337 \
  --blockperiod 5 \
  --requestTimeout 10 \
  --epochLength 30000 \
  --difficulty  1 \
  --gasLimit 0xFFFF \
  --coinbase 0x0000000000000000000000000000000000000000 \
  --maxCodeSize 64 \
  --txnSizeLimit 64 \
  --validators 0 \
  --members 4 \
  --bootnodes 0 \
  --accountPassword "" \
  --tesseraEnabled true \
  --tesseraPassword "" \
  --quickstartDevAccounts false
}

GENERATE_GENESIS_OUTPUT=$(generate_genesis)

if [[ $GENERATE_GENESIS_OUTPUT =~ (./output/[-[:digit:]]+)$ ]]; then 
  GENESIS_DIR=${BASH_REMATCH[1]}
  echo "Genesis files generated at $GENESIS_DIR"
else 
    echo "Failed to find the nested output dir from the genesis tool"
    exit 1
fi
Ezzahhh commented 1 year ago

Hi @luisnaranjo733, thank you for opening this issue. I have added your suggestion and released it as is in 0.2.9

luisnaranjo733 commented 1 year ago

Just reviewed the changes - this is exactly what I was hoping for

Thank you!