Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions scripts/hardfork/create_runtime_config.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/app/hardfork_test/src/internal/hardfork/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down