Skip to content

Commit e19daf8

Browse files
committed
Review fixes:
- remove information removal of non-canonical blocks - update description for schema changes
1 parent 23deac8 commit e19daf8

2 files changed

Lines changed: 42 additions & 17 deletions

File tree

docs/mesa-upgrade/appendix.mdx

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,57 @@ keywords:
1313

1414
## Upgrading archive nodes from Berkeley to Mesa
1515

16-
Below we presents details what was changed in the archive node database schema between Berkeley and Mesa version.
16+
Below we present details of what changed in the archive node database schema between Berkeley and Mesa versions.
1717

18-
**Zkapp_state_nullable additional Columns **
19-
- The `zkapp_state_nullable` table has been modified to include a new columns `element8` to `element31` which are nullable and can store additional state information for zkApps.
18+
### Extended zkApp State Fields
19+
20+
**zkapp_states_nullable table**
21+
- Added columns `element8` through `element31` (nullable integer fields)
22+
- Each new column references `zkapp_field(id)`
23+
- These fields allow zkApps to store additional state information beyond the original 8 elements
2024

2125
```sql
22-
, element8 int REFERENCES zkapp_field(id)
26+
ALTER TABLE zkapp_states_nullable ADD COLUMN IF NOT EXISTS element8 INT REFERENCES zkapp_field(id);
2327
...
24-
, element31 int REFERENCES zkapp_field(id)
25-
);
28+
ALTER TABLE zkapp_states_nullable ADD COLUMN IF NOT EXISTS element31 INT REFERENCES zkapp_field(id);
29+
```
2630

31+
**zkapp_states table**
32+
- Added columns `element8` through `element31` (non-nullable integer fields)
33+
- Each new column references `zkapp_field(id)` with a default value pointing to the zero field
34+
- Unlike the nullable version, these fields are required and default to the zero field ID
35+
36+
```sql
37+
ALTER TABLE zkapp_states ADD COLUMN IF NOT EXISTS element8 INT DEFAULT <zero_field_id> NOT NULL REFERENCES zkapp_field(id);
38+
...
39+
ALTER TABLE zkapp_states ADD COLUMN IF NOT EXISTS element31 INT DEFAULT <zero_field_id> NOT NULL REFERENCES zkapp_field(id);
2740
```
2841

29-
**Version table**
42+
### Migration History Tracking
3043

31-
We also introduced a new table `version` to keep track of the database schema version.
32-
Purpose of this table is to help with future database migrations. Table tracks which migration scripts were applied and when.
33-
Ultimately it helps to determine the current version of the database schema. And helps to avoid applying the same migration script multiple times.
44+
The upgrade introduces a new `migration_history` table to track database schema migrations. This helps manage future upgrades and prevents applying the same migration multiple times.
3445

35-
This table is created if it does not exist already. Rollback and upgrade scripts will insert a new row with the version number and timestamp when the script was applied.
46+
**migration_status enum type**
47+
```sql
48+
CREATE TYPE migration_status AS ENUM ('starting', 'applied', 'failed');
49+
```
3650

51+
**migration_history table**
3752
```sql
38-
CREATE TABLE IF NOT EXISTS version (
39-
version_num INT PRIMARY KEY,
40-
applied_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
53+
CREATE TABLE IF NOT EXISTS migration_history (
54+
commit_start_at TIMESTAMPTZ NOT NULL DEFAULT NOW() PRIMARY KEY,
55+
protocol_version TEXT NOT NULL,
56+
migration_version TEXT NOT NULL,
57+
description TEXT NOT NULL,
58+
status migration_status NOT NULL
4159
);
42-
```
60+
```
61+
62+
The table tracks:
63+
- **commit_start_at**: Timestamp when the migration started
64+
- **protocol_version**: Target protocol version (e.g., '4.0.0' for Mesa)
65+
- **migration_version**: Version of the migration script itself (e.g., '0.0.5')
66+
- **description**: Human-readable description of the migration
67+
- **status**: Current state of the migration (starting, applied, or failed)
68+
69+
The migration script uses protocol version '3.0.0' for Berkeley and '4.0.0' for Mesa, with built-in safety checks to prevent reapplying migrations or running them on incorrect database versions.

docs/mesa-upgrade/upgrade-steps.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ There will be both Docker images and archive node releases available to choose f
100100
- Operators shall import the SQL dump file provided by o1Labs to a freshly created database.
101101
- Operators should direct their Mesa archive process to the newly created database.
102102

103-
**Please note:** both the _trustless_ and _trustful_ migration processes will discard all Mainnet blocks that are not canonical. If you wish to preserve the entire block history, i.e. including non-canonical blocks, you should maintain the Mainnet archive node database for posterior querying needs.
104-
105103
### Exchanges
106104
1. Exchanges shall disable MINA deposits and withdrawals during the entirety of the upgrade downtime, since the _stop-transaction-slot_ until the Mainnet Mesa network is operational.
107105
2. After the Mesa releases are published, exchanges should upgrade their nodes and prepare for the new network to start block production.

0 commit comments

Comments
 (0)