Commit 0076614f authored by Barnabas Busa's avatar Barnabas Busa Committed by GitHub

feat: add fork activation based on env variables - getting started script update (#11500)

* feat: add configurable fork times for each update

* remove granite for now

* add granite if env var is defined

* add granite if env var is defined

* fix if else

* fix if else

* add debug step

* fix l2name

* remove debug step
parent 2d32f8bf
...@@ -15,6 +15,19 @@ reqenv() { ...@@ -15,6 +15,19 @@ reqenv() {
fi fi
} }
append_with_default() {
json_key="$1"
env_var_name="$2"
default_value="$3"
var_value="${!env_var_name}"
if [ -z "$var_value" ] || [ "$var_value" == "None" ]; then
var_value="$default_value"
fi
echo " \"$json_key\": \"$var_value\"," >> tmp_config.json
}
# Check required environment variables # Check required environment variables
reqenv "GS_ADMIN_ADDRESS" reqenv "GS_ADMIN_ADDRESS"
reqenv "GS_BATCHER_ADDRESS" reqenv "GS_BATCHER_ADDRESS"
...@@ -31,9 +44,11 @@ block=$(cast block latest --rpc-url "$L1_RPC_URL") ...@@ -31,9 +44,11 @@ block=$(cast block latest --rpc-url "$L1_RPC_URL")
timestamp=$(echo "$block" | awk '/timestamp/ { print $2 }') timestamp=$(echo "$block" | awk '/timestamp/ { print $2 }')
blockhash=$(echo "$block" | awk '/hash/ { print $2 }') blockhash=$(echo "$block" | awk '/hash/ { print $2 }')
# Generate the config file # Start generating the config file in a temporary file
config=$(cat << EOL
cat << EOL > tmp_config.json
{ {
"l1StartingBlockTag": "$blockhash", "l1StartingBlockTag": "$blockhash",
"l1ChainID": $L1_CHAIN_ID, "l1ChainID": $L1_CHAIN_ID,
...@@ -82,19 +97,36 @@ config=$(cat << EOL ...@@ -82,19 +97,36 @@ config=$(cat << EOL
"l2GenesisBlockGasLimit": "0x1c9c380", "l2GenesisBlockGasLimit": "0x1c9c380",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00", "l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
"l2GenesisRegolithTimeOffset": "0x0",
"l2GenesisCanyonTimeOffset": "0x0",
"l2GenesisDeltaTimeOffset": "0x0",
"l2GenesisEcotoneTimeOffset": "0x0",
"eip1559Denominator": 50, "eip1559Denominator": 50,
"eip1559DenominatorCanyon": 250, "eip1559DenominatorCanyon": 250,
"eip1559Elasticity": 6, "eip1559Elasticity": 6,
EOL
"l2GenesisEcotoneTimeOffset": "0x0", # Append conditional environment variables with their corresponding default values
"l2GenesisDeltaTimeOffset": "0x0", # Activate granite fork
"l2GenesisCanyonTimeOffset": "0x0", if [ -n "${GRANITE_TIME_OFFSET}" ]; then
append_with_default "l2GenesisGraniteTimeOffset" "GRANITE_TIME_OFFSET" "0x0"
fi
# Activate holocene fork
if [ -n "${HOLOCENE_TIME_OFFSET}" ]; then
append_with_default "l2GenesisHoloceneTimeOffset" "HOLOCENE_TIME_OFFSET" "0x0"
fi
# Activate the interop fork
if [ -n "${INTEROP_TIME_OFFSET}" ]; then
append_with_default "l2GenesisInteropTimeOffset" "INTEROP_TIME_OFFSET" "0x0"
fi
# Already forked updates
append_with_default "l2GenesisFjordTimeOffset" "FJORD_TIME_OFFSET" "0x0"
append_with_default "l2GenesisRegolithTimeOffset" "REGOLITH_TIME_OFFSET" "0x0"
append_with_default "l2GenesisEcotoneTimeOffset" "ECOTONE_TIME_OFFSET" "0x0"
append_with_default "l2GenesisDeltaTimeOffset" "DELTA_TIME_OFFSET" "0x0"
append_with_default "l2GenesisCanyonTimeOffset" "CANYON_TIME_OFFSET" "0x0"
# Continue generating the config file
cat << EOL >> tmp_config.json
"systemConfigStartBlock": 0, "systemConfigStartBlock": 0,
"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000", "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
...@@ -113,7 +145,6 @@ config=$(cat << EOL ...@@ -113,7 +145,6 @@ config=$(cat << EOL
"preimageOracleChallengePeriod": 86400 "preimageOracleChallengePeriod": 86400
} }
EOL EOL
)
# Write the config file # Write the final config file
echo "$config" > "$CONTRACTS_BASE/deploy-config/getting-started.json" mv tmp_config.json "$CONTRACTS_BASE/deploy-config/getting-started.json"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment