|
| 1 | +--- |
| 2 | +title: Archive Upgrade |
| 3 | +sidebar_label: Archive Upgrade |
| 4 | +hide_title: true |
| 5 | +description: A guide on how to upgrade your Mina archive node to the Mesa version. |
| 6 | +keywords: |
| 7 | + - Mesa |
| 8 | + - upgrade |
| 9 | + - archive |
| 10 | + - mina archive node |
| 11 | + - archive node |
| 12 | +--- |
| 13 | + |
| 14 | +# Archive Upgrade |
| 15 | + |
| 16 | +To successfully upgrade the archive database into the Mesa version of the Mina network, you must ensure that your environment meets the foundational requirements. |
| 17 | + |
| 18 | +## Migration host |
| 19 | + |
| 20 | +- PostgreSQL database for database server |
| 21 | +- If you use Docker, then any of the supported OS by Mina (bullseye, focal, noble, bookworm or jammy) with at least 32 GB of RAM |
| 22 | +- gsutil application from Google Cloud Suite in version 5 or later |
| 23 | +- (Optional) Docker in version 23.0 or later |
| 24 | + |
| 25 | +## Archive database |
| 26 | + |
| 27 | +One of the most obvious prerequisites is a Mainnet database. If you don't have an existing database with Devnet/Mainnet archive data, |
| 28 | +you can always download it from the O1Labs Google Cloud bucket. |
| 29 | + |
| 30 | +## Upgrade process |
| 31 | + |
| 32 | +### Upgrade script |
| 33 | + |
| 34 | +Assuming that you have a PostgreSQL database with Mainnet archive data, in order to upgrade it to Mesa version, you need to run SQL upgrade script. |
| 35 | +We put all efforts to make the upgrade process as smooth as possible. Script can be run on archive node which is online or offline. |
| 36 | +Script can be run multiple times, it will skip steps that were already completed. It also performs sanity checks before each step to ensure that the upgrade process is successful. |
| 37 | +Finally it creates new table (version) in the database to keep track of the upgrade process. |
| 38 | + |
| 39 | +#### Getting the script |
| 40 | + |
| 41 | +You can find the SQL upgrade script in the Mina repository on GitHub. Make sure to download the latest version of the script before proceeding. |
| 42 | +You can download the script directly using the following command: |
| 43 | + |
| 44 | +```bash |
| 45 | +curl -O https://raw.githubusercontent.com/MinaProtocol/mina/main/src/app/archive_postgres/upgrade/migration.sql |
| 46 | +``` |
| 47 | + |
| 48 | +We also ship the script in the Mina archive Docker image and Debian package. |
| 49 | + |
| 50 | +```bash |
| 51 | +docker run --rm minaprotocol/mina-archive:4.0.0-ae112d3-bullseye-mainnet cat /usr/local/bin/migration.sql > migration.sql |
| 52 | +``` |
| 53 | + |
| 54 | +```bash |
| 55 | + # setup the Mina repository and install the archive package |
| 56 | + |
| 57 | + apt-get install mina-archive |
| 58 | + cat /etc/mina/archive/upgrade-to-mesa.sql |
| 59 | + cat /etc/mina/archive/downgrade-to-berkeley.sql |
| 60 | + |
| 61 | +``` |
| 62 | + |
| 63 | +#### Running the script |
| 64 | + |
| 65 | +To run the rollback script, you need to execute the following command: |
| 66 | + |
| 67 | +```bash |
| 68 | +psql -U <username> -d <database> -f /etc/mina/archive/downgrade-to-berkeley.sql |
| 69 | +``` |
| 70 | + |
| 71 | +Make sure to replace `<username>` and `<database>` with your actual PostgreSQL username and database name. |
| 72 | + |
| 73 | + |
| 74 | +#### Rollback |
| 75 | + |
| 76 | +You can rollback the upgrade process by restoring the database from a backup taken before running the upgrade script. |
| 77 | +Another is to run rollback script which is part of the upgrade script. It will drop all tables and other database objects created by the upgrade script. |
| 78 | +It will also update the version table to reflect the rollback. |
| 79 | + |
| 80 | +##### Running the rollback script |
| 81 | + |
| 82 | +To run the rollback script, you need to execute the following command: |
| 83 | + |
| 84 | +```bash |
| 85 | +psql -U <username> -d <database> -f /etc/mina/archive/downgrade-to-berkeley.sql |
| 86 | +``` |
| 87 | + |
| 88 | +Make sure to replace `<username>` and `<database>` with your actual PostgreSQL username and database name. |
| 89 | + |
| 90 | + |
| 91 | +### Post-upgrade steps |
| 92 | + |
| 93 | +After successfully running the upgrade script, you DO NOT need to restart your archive node or Rosetta API. |
| 94 | +Changes in upgrade script are backward compatible and will be picked up by the archive node and Rosetta API automatically. |
| 95 | + |
| 96 | +### Verification |
| 97 | +To verify that the upgrade was successful, you can check the version table in the PostgreSQL database. |
| 98 | + |
| 99 | +You can do this by running the following command: |
| 100 | +```bash |
| 101 | +psql -U <username> -d <database> -c "SELECT * FROM version;" |
| 102 | +``` |
| 103 | +Make sure to replace `<username>` and `<database>` with your actual PostgreSQL username and database name. |
| 104 | + |
| 105 | +If the upgrade was successful, you should see the new version number in the output. |
| 106 | + |
| 107 | +We put a lot of effort into making the upgrade process as smooth as possible. |
| 108 | +However, if you encounter any issues or need assistance, please reach out to the Mina community on [Discord](https://discord.gg/minaprotocol) or [GitHub Discussions](https://github.com/MinaProtocol/mina/discussions). |
0 commit comments