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

Deep history updates #694

Merged
merged 17 commits into from
Jan 30, 2024
Merged

Deep history updates #694

merged 17 commits into from
Jan 30, 2024

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented Sep 1, 2023

Description of the pull request (what is new / what has changed)

Simplifications. Document new reconstruction flow for deep-history.

For reference, see: multiversx/mx-deprecated-chain-deep-history#19.

Did you test the changes locally ?

  • yes
  • no

Which category (categories) does this pull request belong to?

  • document new feature
  • update documentation that is not relevant anymore
  • add examples or more information about a component
  • fix grammar issues
  • other

@andreibancioiu andreibancioiu self-assigned this Sep 1, 2023
@andreibancioiu andreibancioiu marked this pull request as ready for review January 26, 2024 14:03
Archives supporting historical lookup are available to download from a Google Cloud Storage bucket.

:::important
Documentation in this section is preliminary and subject to change.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comes in the following PR.

Copy link
Contributor

@bogdan-rosianu bogdan-rosianu left a comment

Choose a reason for hiding this comment

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

🚀

### Downloading non-pruned database
## Observer configuration

A deep history squad has it's observers configured to retain the whole, non-pruned history of the blockchain. That is, the observers must have the following settings in their `prefs.toml`:
Copy link
Contributor

Choose a reason for hiding this comment

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

its

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

:::tip
As of October 2022, a public deep-history squad isn't yet available. The instance is being prepared and should be ready in November 2022.
:::
The observing squads backing the public Gateways, in addition to being full history squads (serving past blocks, transaction and events up until the Genesis), also act as 3-epochs deep-history squads. That is, for **mainnet**, one can use https://gateway.multiversx.com to resolve historical account (state) queries, for the last 3 days. This interval is driven by the configuration parameter `[StoragePruning.NumEpochsToKeep]`, which is set to `4`, by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

serving past blocks, transactions and events

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

FullArchive = true

OverridableConfigTomlValues = [
{ File = "config.toml", Path = "DbLookupExtensions.Enabled", Value = "true" },
Copy link
Contributor

Choose a reason for hiding this comment

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

we might think of defining a node operation for these settings

Copy link
Contributor Author

@andreibancioiu andreibancioiu Jan 30, 2024

Choose a reason for hiding this comment

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

Good point, thanks! Actually, we do have something: full-archive, db-lookup-extension, historical-balances - I will re-check their compatibility.

Edit: currently testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--operation-mode=historical-balances seems perfect 🚀

configs.GeneralConfig.StoragePruning.Enabled = true
configs.GeneralConfig.StoragePruning.ValidatorCleanOldEpochsData = false
configs.GeneralConfig.StoragePruning.ObserverCleanOldEpochsData = false
configs.GeneralConfig.GeneralSettings.StartInEpochEnabled = false
configs.GeneralConfig.StoragePruning.AccountsTrieCleanOldEpochsData = false
configs.GeneralConfig.StateTriesConfig.AccountsStatePruningEnabled = false
configs.GeneralConfig.DbLookupExtensions.Enabled = true
configs.PreferencesConfig.Preferences.FullArchive = true

It does not override SnapshotsEnabled = true and PeerStatePruningEnabled = true, but those are the official default anyway.

Thanks @bogdan-rosianu @iulianpascalau (great simplification)!


[comment]: # (mx-context-auto)
An alternative to downloading the non-pruned history is to reconstruct it locally (on your own infrastructure). The reconstruction process is based on the **[import-db](/validators/import-db/)** feature, which re-processes past blocks - and, while doing so, retains the whole, non-pruned accounts history.
Copy link
Contributor

Choose a reason for hiding this comment

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

We can also add the possibility to sync from the network by using the full archive flag in prefs.toml

Copy link
Contributor Author

@andreibancioiu andreibancioiu Jan 30, 2024

Choose a reason for hiding this comment

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

Added a short note. But now I think that would be easier for users from the community to use a regular sync instead of import-db. In a next PR, we can:

a) drop the details regarding reconstruction using import-db, and only describe the simpler approach (even if it takes a bit more time, depending on the availability of peers, plus the network traffic).

b) have the regular-sync approach described side-by-side with the import-db approach.

Which one should we pick?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would choose b.

git clone https://github.com/multiversx/mx-chain-mainnet-config --branch=$CONFIG_TAG --single-branch --depth=1 config

# In most cases, this should be the tag found in the file "config/binaryVersion":
export BINARY_TAG=v1.6.13
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe get the compatible binary from the binaryVersion file after getting the configs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

:::tip
Downloading the archives and extracting them might take a while.
```
./node --import-db=./import-db --import-db-no-sig-check --log-level=*:INFO --use-log-view --log-save --destination-shard-as-observer 0
Copy link
Contributor

Choose a reason for hiding this comment

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

--use-log-view is deprecated. Will be removed in the upcoming releases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Now, get (download) and extract **two daily archives (snapshots)** for the shard in question (e.g. shard 0): one archive that was created on the epoch preceding the **chosen start epoch** (e.g. the archive created during epoch `1255 - 1 = 1254`); and one archive that was created on the epoch following the **chosen end epoch** (e.g. the archive created during epoch `1260 + 1 = 1261`). You can compute the correct URLs for the two archives manually, given the [**mainnet** Genesis time](https://gateway.multiversx.com/network/config) and the chosen epochs, or you can use the following Python snippet:

```
import datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

We are now ready to start the reconstruction process :rocket:

```
./node --import-db=./import-db --import-db-no-sig-check --log-level=*:INFO --use-log-view --log-save --destination-shard-as-observer 0
Copy link
Contributor

Choose a reason for hiding this comment

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

also here, no --use-log-view

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@andreibancioiu andreibancioiu merged commit 2b8e74e into development Jan 30, 2024
1 check passed
@andreibancioiu andreibancioiu deleted the deep-history-2023-09-01 branch January 30, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants