near / near-indexer-for-explorer

Watch NEAR network and store all the data from NEAR blockchain to PostgreSQL database
https://near-indexers.io/docs/projects/near-indexer-for-explorer
GNU General Public License v3.0
124 stars 56 forks source link

How with near-indexer-for-explorer sync data from 0 block? #379

Open mrkriodev opened 1 year ago

mrkriodev commented 1 year ago

So question is: How with near-indexer-for-explorer sync data from 0 block?

I need to dowload some config file from AWS ?

khorolets commented 1 year ago

I need to dowload some config file from AWS ?

Hey! No, you don't. You need to run the Indexer for Explorer (with your AWS credentials set up) with the command ./indexer <chain_id> from-block --height 0

Please note, that the 0th block is not actually the 0th. For mainnet it's 9820210 and for testnet it's 42376888. You don't have to specify them, 0 will do the trick and will start from the earliest available on S3.

mrkriodev commented 1 year ago
  1. Yes i've noticed this

    Please note, that the 0th block is not actually the 0th. For mainnet it's 9820210 and for testnet it's 42376888. You don't have to specify them, 0 will do the trick and will start from the earliest available on S3.

  2. And how can i retrive data about blocks/transactions/receipts previous 9820210 and sync it to my db ?
khorolets commented 1 year ago

And how can i retrive data about blocks/transactions/receipts previous 9820210 and sync it to my db ?

There is no previous.

During the regenesis, all the current state of the blockchain is dumped into a genesis.json and started from there. After the regenesis (sometimes called hard-fork which is not), the blockchain starts from the "beginning" where previous blockchain state becomes a genesis for this one. To prevent confusion NEAR decided to not start from 0th block after this process. But it seems it doesn't help.

Only for the first run of the Indexer for Explorer you might want to add --store-genesis key to capture the data from the genesis records (initial accounts, access keys, state).

mrkriodev commented 1 year ago

Only for the first run of the Indexer for Explorer you might want to add --store-genesis key to capture the data from the genesis records (initial accounts, access keys, state).

  1. Can you explain again what would be if i add --store-genesis?
  2. And comand should be like this : ./target/release/indexer-explorer --store-genesis mainnet or ./target/release/indexer-explorer --store-genesis mainnet from-block 0 ?
khorolets commented 1 year ago

@mrkriodev I am sorry I have misled you a bit

Your command should look like

./target/release/indexer-explorer mainnet from-genesis

It implicitly will do the thing that --store-genesis used to do.

It will:

  1. Download the genesis.json config for the specified chain id (mainnet in your case)
  2. Will read through the records and store the initial data to the database
  3. Start indexing from the earliest block in the chain (9820210 in your case)
mrkriodev commented 1 year ago
  1. Start indexing from the earliest block in the chain (9820210 in your case) I understand. Thanks

If i install an archival node and sync it from s3://near-protocol-public/backups/testnet/archive/latest then i could get info about receipts from block previously 9820210 with rpc-api of the node?

khorolets commented 1 year ago
  1. Start indexing from the earliest block in the chain (9820210 in your case) I understand. Thanks

If i install an archival node and sync it from s3://near-protocol-public/backups/testnet/archive/latest then i could get info about receipts from block previously 9820210 with rpc-api of the node?

The version of the Indexer for Explorer in master branch is not compatible with the data from nearcore (since the master is built on top of the NEAR Lake framework using S3)

If you are interested in the nearcore-based version you need to have a look at master-nearcore branch which is supported by the community, we don't have enough capacity to support it.