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

Move migrate state from classic to node running and autogenerate node running how-tos #658

Merged
merged 7 commits into from
Oct 10, 2023
50 changes: 0 additions & 50 deletions arbitrum-docs/migration/state-migration.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion arbitrum-docs/node-running/gentle-introduction-run-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ In order to be able to _interact with_ or _build applications on_ any of the Arb
Here, you can find resources that help you run different types of Arbitrum nodes:

- Step-by-step instructions for running different Arbitrum nodes, including [full Nitro node](./how-tos/running-a-full-node.mdx), [full Classic node](./how-tos/running-a-classic-node.mdx), [local dev node](./how-tos/local-dev-node.mdx), [feed relay](./how-tos/running-a-feed-relay.mdx), and [validator](./how-tos/running-a-validator.mdx)
- Step-by-step instructions for how to [read the sequencer feed](./how-tos/read-sequencer-feed.md), [build the Nitro locally](./how-tos/build-nitro-locally.md), and [run a DAS](../das/daserver-instructions.mdx)
- Step-by-step instructions for how to [read the sequencer feed](./how-tos/read-sequencer-feed.md), [build the Nitro locally](./how-tos/build-nitro-locally.md), and [run a DAS](./how-tos/running-a-daserver.mdx)
- [Command-line options](./command-line-options.md)
- [Troubleshooting page](./troubleshooting-running-nodes.md)
- [Frequently asked questions](./faq.md)
3 changes: 2 additions & 1 deletion arbitrum-docs/node-running/how-tos/build-nitro-locally.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
title: 'How to build Nitro locally (Debian, Ubuntu, MacOS)'
sidebar_label: Build Nitro locally (Debian, Ubuntu, MacOS)
description: This how-to provides step-by-step instructions for building Nitro locally using Docker on Debian, Ubuntu, or MacOS.
author: amsanghi
sidebar_label: Build Nitro locally (Debian, Ubuntu, MacOS)
sidebar_position: 7
content-type: how-to
---

Expand Down
4 changes: 4 additions & 0 deletions arbitrum-docs/node-running/how-tos/local-dev-node.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
title: 'How to run a local dev node'
description: Learn how to run an Arbitrum local dev node on your local machine.
author: jose-franco
sme: jose-franco
sidebar_label: Run a local dev node
sidebar_position: 6
content-type: how-to
---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
title: 'How to migrate state and history from a classic (pre-Nitro) node to a Nitro node'
sidebar_label: Migrate state from Classic to Nitro
description: This how-to provides step-by-step instructions for migrating the state and history from a classic (pre-Nitro) node to a Nitro node
author: jose-franco
sme: jose-franco
target_audience: 'Node runners interested in creating the full state of the Arbitrum One chain on their own (i.e., without an initial database)'
content-type: how-to
sidebar_position: 10
---

When running a Nitro node for the first time on a chain that produced [classic blocks](/for-devs/concepts/public-chains#classic-deprecated) in the past (like Arbitrum One), you need to initialize its database to, at least, the state of the chain after executing the last classic block. The common, and recommended, way of doing that is to provide a database snapshot using the `--init.url` option (as mentioned in [How to run a full node (Nitro)](/node-running/how-tos/running-a-full-node.mdx)). In this how-to we show you an alternative way for doing that, migrating the state and history of the chain from a fully synced classic node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this.


:::info Is this How-to for you?

As mentioned, the recommended way of initializing a Nitro node is by using a pre-initialized database snapshot with the `--init.url` option. This guide is for those that are interested in re-creating the full state of the chain from the genesis block using their own classic node.

Keep in mind that this process only applies to Arbitrum One. Other Arbitrum chains didn't produce classic blocks in the past, they started as Nitro chains.

:::

## Prerequisites

To successfully migrate the state and history of the chain from a classic (pre-Nitro) node to a Nitro node, you'll need:

- A fully synced classic node: you can find instructions on how to run a classic node in [this page](/node-running/how-tos/running-a-classic-node.mdx).
- A clean, uninitialized Nitro node: you can find instructions on how to set up a Nitro node in [this page](/node-running/how-tos/running-a-full-node.mdx).

## Step 1: Enable export options in your classic node

Launch your classic node with the option `--node.rpc.nitroexport.enable=true`. All exported data will be written to directory "nitroexport" under the classic instance directory (e.g. `${HOME}/.arbitrum/mainnet/nitroexport`). Make sure the classic node has read the entire rollup state.

:::caution Caution

Enabling the export options is only recommended for nodes with no public/external interfaces.

:::

:::info Exported file contents are not deterministic

Exporting the state of your own classic node should produce the same state as using files supplied by the Arbitrum Foundation (i.e. the same genesis blockhash). However, multiple exports of the same state will not necessarily create identical intermediate files. For example, state export is done in parallel, so the order of entries in the file is not deterministic.

:::

## Step 2: Export information from your classic node

### Block & transaction history

These are block headers, transactions and receipts executed in the classic node. Nitro node uses the history to be able to answer simple requests, like `eth_getTransactionReceipt`, from the classic history. The last block in the chain is the only one that affects the genesis block: timestamp is copied from the last block, and parentHash is taken from the last block's blockHash.

- Call the RPC method `arb_exportHistory` with parameter `"latest"` to initiate history export. It will return immediately.
- Calling `arb_exportHistoryStatus` will return the latest block exported, or an error if the export failed.
- Data will be stored in the directory `nitroexport/nitro/l2chaindata/ancient`.

### Rollup state

The rollup state is exported as a series of JSON files. State read from these JSON files will be added to Nitro's genesis block.

- Call the RPC method `arb_exportState` with parameter `"latest"` to initiate state export. Unless disconnected, this will only return after the state export is done.
- Data will be stored in the directory `nitroexport/state/<block_number>/`.

### Outbox messages (optional)

This data does not impact consensus and is optional. It allows a Nitro node to provide the information required when executing a withdrawal made on the classic rollup.

- Call the RPC method `arb_exportOutbox` with parameter `"0xffffffffffffffff"` to initiate outbox export. It will return immediately.
- Calling `arb_exportOutboxStatus` will return the latest outbox batch exported, or an error if the export failed.
- Data will be stored in the directory `nitroexport/nitro/classic-msg`.

## Step 3: Initialize your Nitro node importing the exported data

- Place the `l2chaindata` and `classic-msg` (if exported) directories in Nitro's instance directory (e.g. `${HOME}/.arbitrum/arb1-nitro/`).
- Launch the Nitro node with the argument `--init.import-file=/path/to/state/index.json`

:::caution Caution

This state import operation requires more resources than a regular run of a Nitro node.

:::

### Other useful Nitro options

| Flag | Description |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--init.accounts-per-sync` | Allows the node to make partial database writes to hard-disk during initialization, allowing memory to be freed. This should be used if memory load is very high. A reasonable initial value to try would be 100000. Systems with constrained memory might require a lower value. |
| `--init.then-quit` | Causes the node to quit after initialization is done. |
| `--init.force` | For an already-initialized node, forces the node to recalculate Nitro's genesis block. If the genesis blockhash doesn't match what's in the database, the node will panic. |

## See also

- [How to run a full node (Nitro)](/node-running/how-tos/running-a-full-node.mdx)
- [How to run a full node (Classic, pre-Nitro)](/node-running/how-tos/running-a-classic-node.mdx)
4 changes: 4 additions & 0 deletions arbitrum-docs/node-running/how-tos/read-sequencer-feed.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
title: 'How to read the Sequencer feed'
description: Learn how to read the sequencer feed
sidebar_label: Read the sequencer feed
sidebar_position: 9
content-type: how-to
todos:
- Follow convention and style guide
- Communicate "who this is for" and "under which scenarios this is useful".
Expand Down
2 changes: 2 additions & 0 deletions arbitrum-docs/node-running/how-tos/running-a-classic-node.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: 'How to run a Classic node'
description: Learn how to run an classic node on your local machine.
sidebar_label: Run a full node (Classic, pre-Nitro)
sidebar_position: 2
content-type: how-to
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: 'How to run a data availability server (DAS)'
description: This how-to will help you run a data availability server.
author: amsanghi
sidebar_label: Run a Data Availability Server
sidebar_position: 5
content-type: how-to
---

Expand Down
2 changes: 2 additions & 0 deletions arbitrum-docs/node-running/how-tos/running-a-feed-relay.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: 'How to run a feed relay'
description: Learn how to run an Arbitrum feed relay on your local machine.
sidebar_label: Run a feed relay
sidebar_position: 8
content-type: how-to
---

Expand Down
2 changes: 2 additions & 0 deletions arbitrum-docs/node-running/how-tos/running-a-full-node.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: 'How to run a full node (Nitro)'
description: Learn how to run an Arbitrum node on your local machine.
sidebar_label: Run a full node (Nitro)
sidebar_position: 1
content-type: how-to
---

Expand Down
2 changes: 2 additions & 0 deletions arbitrum-docs/node-running/how-tos/running-a-validator.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: 'How to run a validator'
description: Learn how to run an Arbitrum feed relay on your local machine.
sidebar_label: Run a validator
sidebar_position: 4
content-type: how-to
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: 'How to run an archive node'
description: Learn how to run an Arbitrum archive node on your local machine.
author: jason-wanxt
sidebar_label: Run an archive node
sidebar_position: 3
content-type: how-to
---

Expand All @@ -11,7 +13,7 @@ An Arbitrum **archive node** is a full node that maintains an archive of histori

### Before we begin

Before the Nitro upgrade happened, Arbitrum One was running on the Classic stack for about one year (before block height 22207817). Although the Nitro chain uses the latest snapshot of the Classic chain's state as its genesis state (see [state migration](../../migration/state-migration.mdx)), **the Nitro stack can't serve archive requests for pre-Nitro blocks**.
Before the Nitro upgrade happened, Arbitrum One was running on the Classic stack for about one year (before block height 22207817). Although the Nitro chain uses the latest snapshot of the Classic chain's state as its genesis state, **the Nitro stack can't serve archive requests for pre-Nitro blocks**.

Running an Arbitrum One **full node** in **archive mode** lets you access both pre-Nitro and post-Nitro blocks, but it requires you to run **both Classic and Nitro nodes** together. You may not need to do this, depending on your use case:

Expand Down
10 changes: 10 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"destination": "/migration/dapp_migration",
"permanent": false
},
{
"source": "/migration/state-migration",
"destination": "/node-running/how-tos/migrate-state-and-history-from-classic",
"permanent": false
},
{
"source": "/docs/public_chains",
"destination": "/for-devs/concepts/public-chains",
Expand Down Expand Up @@ -374,6 +379,11 @@
"source": "/node-running/running-a-node",
"destination": "/node-running/how-tos/running-a-full-node",
"permanent": false
},
{
"source": "/das/daserver-instructions",
"destination": "/node-running/how-tos/running-a-daserver",
"permanent": false
}
]
}
49 changes: 2 additions & 47 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,6 @@ const sidebars = {
label: 'Migrate from Classic to Nitro (architecture, contracts)',
id: 'migration/dapp_migration',
},
{
type: 'doc',
label: 'Migrate from Classic to Nitro (state)',
id: 'migration/state-migration',
},
],
},
/** {
Expand Down Expand Up @@ -461,48 +456,8 @@ const sidebars = {
collapsed: false,
items: [
{
type: 'doc',
id: 'node-running/how-tos/running-a-full-node',
label: 'Run a full node (Nitro)',
},
{
type: 'doc',
id: 'node-running/how-tos/running-a-classic-node',
label: 'Run a full node (Classic, pre-Nitro)',
},
{
type: 'doc',
id: 'node-running/how-tos/running-an-archive-node',
label: 'Run an archive node',
},
{
type: 'doc',
id: 'node-running/how-tos/local-dev-node',
label: 'Run a local dev node',
},
{
type: 'doc',
id: 'node-running/how-tos/running-a-feed-relay',
label: 'Run a feed relay',
},
{
type: 'doc',
id: 'node-running/how-tos/running-a-validator',
label: 'Run a validator',
},
{
type: 'doc',
id: 'node-running/how-tos/read-sequencer-feed',
label: 'Read the sequencer feed',
},
{
type: 'doc',
id: 'node-running/how-tos/build-nitro-locally',
},
{
type: 'doc',
id: 'das/daserver-instructions',
label: 'Run a Data Availability Server',
type: 'autogenerated',
dirName: 'node-running/how-tos',
},
],
},
Expand Down