Skip to content

Commit

Permalink
docs/node/run-your-node/maintenance: Update state wipe instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
amela committed Oct 19, 2023
1 parent 41f86c8 commit 3115a2d
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions docs/node/run-your-node/maintenance/wiping-node-state.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
# Wiping Node State

In some cases you might want (or need) to do a full redeploy with clean state before deploying a new version of the network. This should never actually be used during a Mainnet unless there is some serious corruption, but your node will have to spend time catching up to the rest of the network.
In certain situations, you may need to do a complete node redeployment with a
clean state. Two common scenarios for this are during a breaking network upgrade
or in cases of severe data corruption. If you need to wipe your node due to
severe corruption, it's important to note that your node will need some time to
catch up with the rest of the network.

The following instructions assume that your `datadir` is defined as `/serverdir/node` in your node's config.
The following instructions are based on the assumption that you have defined
your `datadir` as `/serverdir/node` in your node's configuration.

## State Wipe and Keep Node Identity

:::caution
:::info

Make sure to include the `--preserve.mkvs_database` flag if you are wiping blockchain state on a runtime node and need to preserve runtime state.
Note that by default, the `--preserve.mkvs_database` flag is set to true,
preserving the runtime/paratime state.

:::

1. Stop the `oasis-node` server process (this will depend on your own deployment setup).
2. Remove blockchain state using the `oasis-node unsafe-reset` command:
To wipe a consensus state while preserving the runtime/paratime state follow
these instructions:

1. Stop the `oasis-node` server process (this will depend on your own deployment
setup).
2. Remove consensus state using the `oasis-node unsafe-reset` command:

```bash
# Do a dry run first to see which files will get deleted.
oasis-node unsafe-reset \
--preserve.mkvs_database \
--datadir=/serverdir/node \
--dry_run \
--log.level info

# Delete.
oasis-node unsafe-reset \
--preserve.mkvs_database \
--datadir /serverdir/node \
--log.level info
```
3. Start the `oasis-node` server process.

:::info

`oasis-node` is very strict regarding the ownership of the files. If you encounter the following error:
`oasis-node` is very strict regarding the ownership of the files. If you
encounter the following error:

```
common/Mkdir: path '/serverdir/node' has invalid owner: 1000. Expected owner: 0
```
you need to run the `oasis-node` command as the exact user that owns the files, e.g.:
you need to run the `oasis-node` command as the exact user that owns the files,
e.g.:
```
sudo --user=#1000 -- oasis-node unsafe-reset --datadir=/serverdir/node --dry_run --log.level info
Expand All @@ -51,12 +59,17 @@ sudo --user=#1000 -- oasis-node unsafe-reset --datadir=/serverdir/node --dry_run
:::danger
This is likely not what you want to do. This is destructive and might result in losing private state required to operate the given node. **USE AT YOUR OWN RISK.**
This is likely not what you want to do. This is destructive and will result in
losing private state required to operate the given node. **USE AT YOUR OWN
RISK.** A full state wipe will also mean that you'll need to generate a new node
identity (or copy the old one).
:::
A full state wipe will also mean that you'll need to generate a new node identity (or copy the old one).
To perform a full state wipe follow these steps:
1. Stop the `oasis-node` server process (this will depend on your own deployment setup)
1. Stop the `oasis-node` server process (this will depend on your own deployment
setup)
2. Remove the `/serverdir/node` directory.
3. Redeploy your node. You'll need to copy your Node artifacts or create brand new ones.
3. Redeploy your node. You'll need to copy your Node artifacts or create brand
new ones.

0 comments on commit 3115a2d

Please sign in to comment.