forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Da eigen implementation docs & backup scripts #289
Merged
juan518munoz
merged 15 commits into
da-eigen-implementation
from
da-eigen-implementation-holesky-docs
Oct 7, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7b2ed4d
initial commit
juan518munoz 8cbaf34
add more steps
juan518munoz 3b1c71e
add backup and restore ecosystem scripts
juan518munoz 4ed4f77
remove unnecessary step
juan518munoz 1153651
improve docs
juan518munoz 29f8a0e
fix docs
juan518munoz 2d8d559
fix the fix docs
juan518munoz 21d9f19
add extra step
juan518munoz 37b986c
fix restore path
juan518munoz 62a092f
simplify restoration note
juan518munoz e4d25fa
more docs
juan518munoz 16b6130
fix paths in backup restoration
juan518munoz f941f28
fix whitespace
juan518munoz 8ecc04d
replacement fixes
juan518munoz 8bff5a4
moved holesky rpc url to env var
juan518munoz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
# Check if the ecosystem name was provided as an argument | ||
if [ -z "$1" ]; then | ||
echo "Usage: ./backup-ecosystem ECOSYSTEM_NAME" | ||
exit 1 | ||
fi | ||
|
||
# Store the first argument as ECOSYSTEM_NAME | ||
ECOSYSTEM_NAME=$1 | ||
|
||
# Prompt for the Postgres password and store it in PGPASSWORD | ||
read -sp "Enter Postgres password: " PGPASSWORD | ||
export PGPASSWORD | ||
|
||
# Path to the secrets.yaml file | ||
SECRETS_FILE="./chains/${ECOSYSTEM_NAME}/configs/secrets.yaml" | ||
|
||
# Check if the secrets.yaml file exists | ||
if [ ! -f "$SECRETS_FILE" ]; then | ||
echo "Error: $SECRETS_FILE does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Extract server_url and prover_url from the secrets.yaml file | ||
SERVER_DB_NAME=$(grep 'server_url' "$SECRETS_FILE" | awk -F'/' '{print $NF}') | ||
PROVER_DB_NAME=$(grep 'prover_url' "$SECRETS_FILE" | awk -F'/' '{print $NF}') | ||
|
||
# Export the database names | ||
echo "Extracted SERVER_DB_NAME: $SERVER_DB_NAME" | ||
echo "Extracted PROVER_DB_NAME: $PROVER_DB_NAME" | ||
|
||
# Create backup directory | ||
mkdir -p "./ecosystem_backups/${ECOSYSTEM_NAME}" | ||
|
||
# Run pg_dump commands | ||
echo "Running pg_dump for $SERVER_DB_NAME..." | ||
pg_dump -U postgres -h localhost "$SERVER_DB_NAME" > "ecosystem_backups/${ECOSYSTEM_NAME}/${SERVER_DB_NAME}_backup.sql" | ||
echo "Running pg_dump for $PROVER_DB_NAME..." | ||
pg_dump -U postgres -h localhost "$PROVER_DB_NAME" > "ecosystem_backups/${ECOSYSTEM_NAME}/${PROVER_DB_NAME}_backup.sql" | ||
|
||
# Unset the PGPASSWORD variable for security | ||
unset PGPASSWORD | ||
|
||
# Copy the chain configuration files | ||
cp -r "./chains/${ECOSYSTEM_NAME}" "./ecosystem_backups/${ECOSYSTEM_NAME}/" | ||
|
||
# Copy the configs directory | ||
cp -r "./configs" "./ecosystem_backups/${ECOSYSTEM_NAME}/" | ||
|
||
echo "Backup completed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/bash | ||
|
||
# Check if the ecosystem name was provided as an argument | ||
if [ -z "$1" ]; then | ||
echo "Usage: ./restore-ecosystem ECOSYSTEM_NAME" | ||
exit 1 | ||
fi | ||
|
||
# Store the first argument as ECOSYSTEM_NAME | ||
ECOSYSTEM_NAME=$1 | ||
|
||
# Prompt for the Postgres password and store it in PGPASSWORD | ||
read -sp "Enter Postgres password: " PGPASSWORD | ||
export PGPASSWORD | ||
|
||
# Check if the chain directory exists | ||
CHAIN_PATH="./chains/${ECOSYSTEM_NAME}" | ||
BACKUP_PATH="./ecosystem_backups/${ECOSYSTEM_NAME}" | ||
|
||
# Check if the backup directory exists | ||
if [ ! -d "$BACKUP_PATH" ]; then | ||
echo "Error: Backup not found at $BACKUP_PATH." | ||
exit 1 | ||
fi | ||
|
||
# Check if the postgres is running | ||
if ! docker ps --filter "name=postgres" --filter "status=running" | grep "postgres" > /dev/null; then | ||
echo "Error: postgres not running, set it up first with 'zk_inception containers'." | ||
exit 1 | ||
fi | ||
|
||
# Fix backup files $ZKSYNC_HOME paths | ||
find_and_replace() { | ||
local target_file=$1 | ||
|
||
sed -i '' -e "s|db_path:.*zksync-era/\./|db_path: $(pwd)/./|g" "$target_file" | ||
sed -i '' -e "s|state_keeper_db_path:.*zksync-era/\./|state_keeper_db_path: $(pwd)/./|g" "$target_file" | ||
sed -i '' -e "s|path:.*zksync-era/\./|path: $(pwd)/./|g" "$target_file" | ||
sed -i '' -e "s|configs:.*zksync-era/\./|configs: $(pwd)/./|g" "$target_file" | ||
} | ||
|
||
# Array of specific files to modify | ||
files=("$BACKUP_PATH/$ECOSYSTEM_NAME/configs/general.yaml" "$BACKUP_PATH/$ECOSYSTEM_NAME/ZkStack.yaml") | ||
|
||
# Loop over the files and perform the find and replace | ||
for file in "${files[@]}"; do | ||
if [ -f "$file" ]; then | ||
find_and_replace "$file" | ||
else | ||
# Exit with error code | ||
echo "ERROR: backup file $file does not exist." | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Copy the ecosystem backup folder to the chains folder, replacing any existing files | ||
echo "Copying backup files to $CHAIN_PATH..." | ||
cp -r "$BACKUP_PATH/$ECOSYSTEM_NAME" "$CHAIN_PATH" | ||
|
||
# Copy the configs folder in the backup to the configs folder in the root of the project | ||
# TODO: it may be suitable to warn the user about overwriting the existing configs | ||
# and ask for confirmation before proceeding | ||
echo "Copying configs folder from backup..." | ||
cp -r "$BACKUP_PATH/configs" "./" | ||
|
||
# Path to the secrets.yaml file | ||
SECRETS_FILE="$CHAIN_PATH/configs/secrets.yaml" | ||
|
||
# Check if the secrets.yaml file exists | ||
if [ ! -f "$SECRETS_FILE" ]; then | ||
echo "Error: $SECRETS_FILE does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Extract server_url and prover_url from the secrets.yaml file | ||
SERVER_DB_NAME=$(grep 'server_url' "$SECRETS_FILE" | awk -F'/' '{print $NF}') | ||
PROVER_DB_NAME=$(grep 'prover_url' "$SECRETS_FILE" | awk -F'/' '{print $NF}') | ||
|
||
# Show the extracted database names | ||
echo "Extracted SERVER_DB_NAME: $SERVER_DB_NAME" | ||
echo "Extracted PROVER_DB_NAME: $PROVER_DB_NAME" | ||
|
||
# Create and restore the server database | ||
echo "Creating database $SERVER_DB_NAME..." | ||
createdb -U postgres -h localhost "$SERVER_DB_NAME" | ||
|
||
echo "Restoring $SERVER_DB_NAME from backup..." | ||
psql -U postgres -h localhost -d "$SERVER_DB_NAME" -f "$BACKUP_PATH/${SERVER_DB_NAME}_backup.sql" | ||
|
||
# Create and restore the prover database | ||
echo "Creating database $PROVER_DB_NAME..." | ||
createdb -U postgres -h localhost "$PROVER_DB_NAME" | ||
|
||
echo "Restoring $PROVER_DB_NAME from backup..." | ||
psql -U postgres -h localhost -d "$PROVER_DB_NAME" -f "$BACKUP_PATH/${PROVER_DB_NAME}_backup.sql" | ||
|
||
# Unset the PGPASSWORD variable for security | ||
unset PGPASSWORD | ||
|
||
echo "Restore completed." |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This then needs a
./bin/zkt