<aside> 💡

Read the sharding AIP here:

https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-97.md

</aside>

Instructions

Storage sharding is managed through your local node configuration. Since the new storage format is incompatible with the previous one, a full DB wipe is required (by simply delete the DB folder) to proceed.

<aside> 💡

Aptos node version required for sharding upgrade: aptos-node-v1.21.2 or higher

</aside>

Flag to start the format migration:


storage:
	rocksdb_configs:
		enable_storage_sharding: true

  1. Wipe and sync new PFN using the sharding config
    1. Update the node config file to enable sharding.
    2. Wipe the db and start the node again using the sharding config. Make sure it started syncing data, and wait for it to fully sync.
      1. If you are running archival FN (i.e. keep all data since genesis), to speed up the sync, you can choose to start a new node (colocate with your old node) with the sharding enabled, and put your old non-sharding node as it’s upstream peer.
        1. WARNING: Running archival FN is not recommended. With the rapid growth of Aptos ecosystem, you will hit disk space limit in the near future. Please plan accordingly!!!
  2. Internal indexer will be default OFF. The following endpoints will not be supported when internal indexer is off:
  3. If any of the indexer APIs are required, there are 3 options:
    1. Turn on internal indexer

      # Only turn on the APIs you need as they will affect the performance of the node
      indexer_db_config:
          enable_event: true # controls first 2 APIs above
          enable_statekeys: true # controls the 3rd API above
          enable_transaction: true # controls the last 2 APIs above
      
    2. Use Aptos Indexer, check the following links to see if any of them meet your need

      1. https://aptos.dev/en/build/indexer/indexer-api
      2. https://developers.aptoslabs.com/docs/introduction
      3. No code indexing (coming soon)
    3. Run your own indexer, here are some common infra you might need

      1. https://aptos.dev/en/build/indexer/indexer-sdk
      2. https://aptos.dev/en/build/indexer/txn-stream

Recommendation:

We recommend you to revisit the usage of the above APIs, and take this time as an opportunity to see if there are other ways to achieve the same purpose, because each of those APIs have their own problems. For example, the 2 event APIs are not supporting v2 events (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-44.md). The /accounts/{address}/transactions assumes transactions have sequence number which won’t work after we introduce orderless txn (future AIP). The /accounts/{address}/modules and /accounts/{address}/resources can usually be replaced by querying the state you are interested in directly, or call the corresponding view function.

  1. Verify node is on sharding mode
    1. When node is running, go to v1/info endpoint, you should be able to see "new_storage_format":true , you will also be able to see which internal indexers are enabled.

Here is a list of flags (and examples) that might require attention during the migration.


# Note: Replace the address with the upstream you want to use.
seeds:
  D717AF1761645FFACFE5A455FB021052AC0FEFBC1B97FC3681BA61423C043D23:
    addresses:
    - /dns4/pfn0.backup.cloud-a.mainnet.aptoslabs.com/tcp/6182/noise-ik/D717AF1761645FFACFE5A455FB021052AC0FEFBC1B97FC3681BA61423C043D23/handshake/0
    role: Upstream

# Note the following example just to show what syntax is supported.
# You should decide how you want to put the data among multiple disks based on your hardware spec.
storage:
  db_path_overrides:
    ledger_db_path: "/disk0/db"
    state_kv_db_path:
      metadata_path: "/disk0/db"
      shard_paths:
        - shards: "1-3,7"
          path: "/disk1/db"
        - shards: "11-12,15"
          path: "/disk2/db"
    state_merkle_db_path:
      metadata_path: "/disk0/db"
      shard_paths:
        - shards: "0-7"
          path: "/disk3/db"
        - shards: "8-15"
          path: "/disk4/db"