From a54a65d961389f0886ef13a0090505e7fb2f1196 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Wed, 9 Oct 2024 19:24:39 +0100 Subject: [PATCH] (deploy, hub): have deployment script compute bootstrap period duration to have it end 15 nov 2024; update hub to make param public --- script/deployments/chiadoDeploy.sh | 37 +++++++++++++++++++++++-- script/deployments/gnosisChainDeploy.sh | 37 +++++++++++++++++++++++-- script/deployments/package.json | 2 +- src/hub/Hub.sol | 2 +- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/script/deployments/chiadoDeploy.sh b/script/deployments/chiadoDeploy.sh index f33e1f2..052db33 100755 --- a/script/deployments/chiadoDeploy.sh +++ b/script/deployments/chiadoDeploy.sh @@ -74,8 +74,33 @@ V1_HUB_ADDRESS='0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710' # but like on mainnet we want to offset this to midnight to start day zero # on the Feb 1 2023, which has unix time 1675209600 INFLATION_DAY_ZERO=1675209600 -# put a long bootstrap time for testing bootstrap -BOOTSTRAP_ONE_YEAR=31540000 + +# Set the bootstrap end date to Nov 15, 2024 23:59:59 UTC +BOOTSTRAP_END_DATE="2024-11-15 23:59:59" + +# Function to convert UTC date to seconds since epoch +utc_to_seconds() { + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + date -j -u -f "%Y-%m-%d %H:%M:%S" "$1" "+%s" + else + # GNU/Linux + date -u -d "$1" "+%s" + fi +} + +# Calculate the bootstrap period +CURRENT_TIME=$(date -u +"%Y-%m-%d %H:%M:%S") +BOOTSTRAP_END_SECONDS=$(utc_to_seconds "$BOOTSTRAP_END_DATE") +CURRENT_TIME_SECONDS=$(utc_to_seconds "$CURRENT_TIME") +BOOTSTRAP_PERIOD=$((BOOTSTRAP_END_SECONDS - CURRENT_TIME_SECONDS)) + +# Ensure the bootstrap period is not negative +if [ $BOOTSTRAP_PERIOD -lt 0 ]; then + echo "Error: The specified end date is in the past. Please update the BOOTSTRAP_END_DATE." >&2 + exit 1 +fi + # fallback URI URI='https://gateway.aboutcircles.com/v1/circles/{id}.json' @@ -133,7 +158,7 @@ HUB=$(deploy_and_store_details "Hub" $HUB_ADDRESS_01 \ --constructor-args $V1_HUB_ADDRESS \ $NAMEREGISTRY_ADDRESS_03 $MIGRATION_ADDRESS_02 $ERC20LIFT_ADDRESS_04 \ $STANDARD_TREASURY_ADDRESS_05 $INFLATION_DAY_ZERO \ - $BOOTSTRAP_ONE_YEAR $URI) + $BOOTSTRAP_PERIOD $URI) MIGRATION=$(deploy_and_store_details "Migration" $MIGRATION_ADDRESS_02 \ src/migration/Migration.sol:Migration \ @@ -190,4 +215,10 @@ summary_file="${OUT_DIR}/chiado-${identifier}.log" echo "MastercopyDemurrageERC20: ${MC_ERC20_DEMURRAGE}" echo "MastercopyInflationaryERC20: ${MC_ERC20_INFLATION}" echo "MastercopyStandardVault: ${MC_STANDARD_VAULT}" + echo "" + echo "Bootstrap End Date: $BOOTSTRAP_END_DATE UTC" + echo "Current Time: $CURRENT_TIME UTC" + echo "Bootstrap Period: ${BOOTSTRAP_PERIOD} seconds" + echo "Bootstrap End Date (Unix time): $BOOTSTRAP_END_SECONDS" + echo "Current Time (Unix time): $CURRENT_TIME_SECONDS" } >> "$summary_file" diff --git a/script/deployments/gnosisChainDeploy.sh b/script/deployments/gnosisChainDeploy.sh index c34f8e3..9824010 100755 --- a/script/deployments/gnosisChainDeploy.sh +++ b/script/deployments/gnosisChainDeploy.sh @@ -96,8 +96,33 @@ V1_HUB_ADDRESS='0x29b9a7fBb8995b2423a71cC17cf9810798F6C543' # but we want to offset this to midnight to start day zero # on midnight 15 October 2020 INFLATION_DAY_ZERO=1602720000 -# put a long bootstrap time for testing bootstrap to one year -BOOTSTRAP_ONE_YEAR=31540000 + +# Set the bootstrap end date to Nov 15, 2024 23:59:59 UTC +BOOTSTRAP_END_DATE="2024-11-15 23:59:59" + +# Function to convert UTC date to seconds since epoch +utc_to_seconds() { + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + date -j -u -f "%Y-%m-%d %H:%M:%S" "$1" "+%s" + else + # GNU/Linux + date -u -d "$1" "+%s" + fi +} + +# Calculate the bootstrap period +CURRENT_TIME=$(date -u +"%Y-%m-%d %H:%M:%S") +BOOTSTRAP_END_SECONDS=$(utc_to_seconds "$BOOTSTRAP_END_DATE") +CURRENT_TIME_SECONDS=$(utc_to_seconds "$CURRENT_TIME") +BOOTSTRAP_PERIOD=$((BOOTSTRAP_END_SECONDS - CURRENT_TIME_SECONDS)) + +# Ensure the bootstrap period is not negative +if [ $BOOTSTRAP_PERIOD -lt 0 ]; then + echo "Error: The specified end date is in the past. Please update the BOOTSTRAP_END_DATE." >&2 + exit 1 +fi + # fallback URI URI='https://gateway.aboutcircles.com/v1/circles/{id}.json' @@ -160,7 +185,7 @@ HUB=$(deploy_and_store_details "Hub" $HUB_ADDRESS_01 \ --constructor-args $V1_HUB_ADDRESS \ $NAMEREGISTRY_ADDRESS_03 $MIGRATION_ADDRESS_02 $ERC20LIFT_ADDRESS_04 \ $STANDARD_TREASURY_ADDRESS_05 $INFLATION_DAY_ZERO \ - $BOOTSTRAP_ONE_YEAR $URI) + $BOOTSTRAP_PERIOD $URI) NONCE_USED=$((NONCE_USED + 1)) @@ -233,4 +258,10 @@ summary_file="${OUT_DIR}/gnosischain-${identifier}.log" echo "MastercopyDemurrageERC20: ${MC_ERC20_DEMURRAGE}" echo "MastercopyInflationaryERC20: ${MC_ERC20_INFLATION}" echo "MastercopyStandardVault: ${MC_STANDARD_VAULT}" + echo "" + echo "Bootstrap End Date: $BOOTSTRAP_END_DATE UTC" + echo "Current Time: $CURRENT_TIME UTC" + echo "Bootstrap Period: ${BOOTSTRAP_PERIOD} seconds" + echo "Bootstrap End Date (Unix time): $BOOTSTRAP_END_SECONDS" + echo "Current Time (Unix time): $CURRENT_TIME_SECONDS" } >> "$summary_file" diff --git a/script/deployments/package.json b/script/deployments/package.json index 40b01f0..088aaf6 100644 --- a/script/deployments/package.json +++ b/script/deployments/package.json @@ -1,6 +1,6 @@ { "name": "deploy-circles", - "version": "rc-0.3.7-alpha", + "version": "rc-0.3.7-beta", "type": "module", "dependencies": { "dotenv": "^16.4.5", diff --git a/src/hub/Hub.sol b/src/hub/Hub.sol index da4c524..aa48b40 100644 --- a/src/hub/Hub.sol +++ b/src/hub/Hub.sol @@ -73,7 +73,7 @@ contract Hub is Circles, TypeDefinitions, IHubErrors { * new avatars can be invited by registered avatars. After this time * only registered avatars can invite new avatars. */ - uint256 internal immutable invitationOnlyTime; + uint256 public immutable invitationOnlyTime; /** * @notice The standard treasury contract address used when