Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(deploy, hub): have deployment script compute bootstrap period durati… #69

Merged
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
37 changes: 34 additions & 3 deletions script/deployments/chiadoDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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"
37 changes: 34 additions & 3 deletions script/deployments/gnosisChainDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion script/deployments/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/hub/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading