Skip to content

Commit

Permalink
Add env config for fast mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed May 16, 2023
1 parent 70cd451 commit dc488f0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 0 additions & 8 deletions core/init.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env sh

if [[ "$(uname)" == "Darwin" && -z "${IN_NIX_SHELL:-}" ]]; then
alias sed='gsed'
fi

echo "Update submodules"
(cd .. && (git submodule update --init --recursive||true))

Expand All @@ -13,7 +9,3 @@ echo "Install husky hook"
echo "Initialize foundry libraries"
(cd packages/contracts && (forge install||true))

echo "Hack lodestar for faster slot time"
. packages/test/scripts/set-env.sh
preset_minimal_config_file="./node_modules/.pnpm/@lodestar+config@$lodestar_version/node_modules/@lodestar/config/lib/chainConfig/presets/minimal.js"
sed -i "s/SECONDS_PER_SLOT: 6/SECONDS_PER_SLOT: 2/g" $preset_minimal_config_file
1 change: 1 addition & 0 deletions core/packages/test/.envrc-example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ source_up_if_exists
# export BEACON_HTTP_ENDPOINT=https://lodestar-goerli.chainsafe.io
# export ETH_GAS_LIMIT=0 # For real network just uncomment and set as 0 here
# export ACTIVE_SPEC=mainnet # For real network just uncomment and set as mainnet here
# export ETH_FAST_MODE=false # For local setup only, set as true will hack beacon client for fast slot time

# export DEPLOYER_ETH_KEY= # Your private key to deploy contracts
# export BEEFY_RELAY_ETH_KEY= # Your Beefy relayer account private key
Expand Down
15 changes: 15 additions & 0 deletions core/packages/test/scripts/deploy-ethereum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ deploy_contracts()
echo "Exported contract artifacts: $output_dir/contracts.json"
}

hack_beacon_client()
{
echo "Hack lodestar for faster slot time"
preset_minimal_config_file="$core_dir/node_modules/.pnpm/@lodestar+config@$lodestar_version/node_modules/@lodestar/config/lib/chainConfig/presets/minimal.js"
if [[ "$(uname)" == "Darwin" && -z "${IN_NIX_SHELL:-}" ]]; then
gsed -i "s/SECONDS_PER_SLOT: 6/SECONDS_PER_SLOT: 2/g" $preset_minimal_config_file
else
sed -i "s/SECONDS_PER_SLOT: 6/SECONDS_PER_SLOT: 2/g" $preset_minimal_config_file
fi
}

deploy_ethereum()
{
# 1. deploy execution client
Expand All @@ -86,6 +97,10 @@ deploy_ethereum()
echo "Waiting for geth API to be ready"
sleep 3

if [ "$eth_fast_mode" == "true" ]; then
hack_beacon_client
fi

# 2. deploy consensus client
echo "Starting beacon node"
start_lodestar
Expand Down
1 change: 1 addition & 0 deletions core/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ eth_endpoint_http="${ETH_RPC_ENDPOINT:-http://127.0.0.1:8545}/${INFURA_PROJECT_I
eth_endpoint_ws="${ETH_WS_ENDPOINT:-ws://127.0.0.1:8546}/${INFURA_PROJECT_ID:-}"
eth_gas_limit="${ETH_GAS_LIMIT:-5000000}"
eth_chain_id=1
eth_fast_mode="${ETH_FAST_MODE:-false}"

beefy_state_file="${BEEFY_STATE_FILE:-$output_dir/beefy-state.json}"
beefy_start_block="${BEEFY_START_BLOCK:-1}"
Expand Down

0 comments on commit dc488f0

Please sign in to comment.