diff --git a/scripts/hardfork/create_runtime_config.sh b/scripts/hardfork/create_runtime_config.sh index 6652fc5f50f1..7bb2d6c55609 100755 --- a/scripts/hardfork/create_runtime_config.sh +++ b/scripts/hardfork/create_runtime_config.sh @@ -1,17 +1,24 @@ #!/usr/bin/env bash +# NOTE: This script patches the genesis timestamp of a fork config so a new +# network could be schedueld to genesis in some instant in the future. + set -eo pipefail +# ==================== Inputs to this script ==================== +# The fork config we aim to patch on FORK_CONFIG_JSON=${FORK_CONFIG_JSON:=fork_config.json} +# The hashes file generated by runtime-genesis-ledger LEDGER_HASHES_JSON=${LEDGER_HASHES_JSON:=ledger_hashes.json} +# The "base" config file, needed to know the genesis time of the prefork network FORKING_FROM_CONFIG_JSON=${FORKING_FROM_CONFIG_JSON:=genesis_ledgers/mainnet.json} - -# If not given, the genesis timestamp is set to 10 mins into the future +# Genesis timestamp of the postfork network, defaults to 10mins in the future GENESIS_TIMESTAMP=${GENESIS_TIMESTAMP:=$(date -u +"%Y-%m-%dT%H:%M:%SZ" -d "10 mins")} # Pull the original genesis timestamp from the pre-fork config file ORIGINAL_GENESIS_TIMESTAMP=$(jq -r '.genesis.genesis_state_timestamp' "$FORKING_FROM_CONFIG_JSON") OFFSET=$(jq -r '.proof.fork.global_slot_since_genesis' "$FORKING_FROM_CONFIG_JSON") +# =============================================================== if [[ "$OFFSET" == null ]]; then OFFSET=0 diff --git a/src/app/hardfork_test/src/internal/hardfork/ledger.go b/src/app/hardfork_test/src/internal/hardfork/ledger.go index 36ac1cddb5ec..8d283186c3e2 100644 --- a/src/app/hardfork_test/src/internal/hardfork/ledger.go +++ b/src/app/hardfork_test/src/internal/hardfork/ledger.go @@ -64,7 +64,10 @@ func (t *HardforkTest) GenerateAndValidatePreforkLedgers(analysis *BlockAnalysis return nil } -// GenerateForkConfigAndLedgers generates the fork configuration and ledgers +// GenerateForkConfigAndLedgers does the following: +// 1. generate fork ledgers with runtime-genesis-ledger +// 2. patch the genesis time & slot for fork config with create_runtime_config.sh +// 3. perform some base sanity check on the fork config func (t *HardforkTest) GenerateForkConfigAndLedgers(analysis *BlockAnalysisResult, forkConfigPath, forkLedgersDir, forkHashesFile, configFile, preforkGenesisConfigFile string, forkGenesisTs, mainGenesisTs int64) error { // Generate fork ledgers using fork network executable if err := t.GenerateForkLedgers(t.Config.ForkRuntimeGenesisLedger, forkConfigPath, forkLedgersDir, forkHashesFile); err != nil {