Closed TanyaSrivastava-Dipali closed 1 year ago
This can be done with a few tweaks here and there.
Assuming you have an existing localnet node with the default config. It means you're already running an RPC on port :3030
and the nearcore
node on :24567
Indexer for Explorer is a nearcore node too, and in order to be running close to another node on the same machine, it needs a separate set of config.
Assuming your localnet consists of 1 nearcore node that uses a default path ~/.near
you need to initialize another config for indexer-for-explorer.
./target/release/indexer --home-dir ~/.near-indexer init --chain-id localnet
validator_key.json
Your nearcore
node that is already existing is a validator. If running a few validators locally is not your particular case, we should remove validator_key.json
from the newly created config folder
rm ~/.near-indexer/validator_key.json
genesis.json
file contains the data about the initial validator, it is generated on the fly and expects the validator_key.json
key we have just deleted to be a validator. But you already have a validator.
We need to get the genesis.json
file from the existed configs
cp ~/.near/genesis.json ~/.near-indexer/genesis.json
config.json
First of all, we need to change a port for indexer provided RPC from default :3030
Open ~/.near-indexer/config.json
Change
"rpc": {
"addr": "0.0.0.0:3030",
To
"rpc": {
"addr": "0.0.0.0:8080",
Then we need to change network
port
The same ~/.near-indexer/config.json
Change
"network": {
"addr": "0.0.0.0:24567",
To
"network": {
"addr": "0.0.0.0:24568",
Boot nodes are the nodes your node will try to connect first to exchange all the necessary information in order to sync up with the network, set up the peer-to-peer connection, etc.
Boot node value looks like this:
ed25519:4k9csx6zMiXy4waBKMMPTkEtAS2RFKLVScocR5HwN53P@192.168.0.1:24567
Which is basically
ed25519:NODE_PUBLIC_KEY@IP:PORT
Take the public_key
from the existing ~/.near/validator_key.json
~/.near-indexer/config.json
Change
"network": {
"addr": "0.0.0.0:24568",
"external_address": "",
"boot_nodes": "",
TO
"network": {
"addr": "0.0.0.0:24568",
"external_address": "",
"boot_nodes": ["ed25519:public_key@127.0.0.1:24567"],
data
to speed up the syncing processcp -rf ~/.near/data ~/.near-indexer/data
Start your previously existing localnet node before starting the indexer-for-explorer.
Now you can start the indexer-for-explorer
./target/release/indexer --home-dir ~/.near-indexer run --stream-while-syncing start-from-interruption
This should work.
P.S. Anyone who sees this instruction please react with a thumb up if you'd like to see it on https://near-indexers.io React with the heart if you want to see video instruction.
@khorolets I feel the best place would be actually the README file, not the docs.
@TanyaSrivastava-Dipali BTW, you can run indexer
as your validator node, and kill two birds with one stone. Just stop your localnet node and run indexer
with the --home
specified where the localnet validator node was previously.
what to do when we are using nearcore version 1.26.1 which in turn is using protocol version 53 but none of the indexer tag is using nearcore 1.26.1 and logs are showing error.{ thread 'main' panicked at 'The client protocol version is older than the protocol version of the network. Please update nearcore', /home/ubuntu/.cargo/git/checkouts/nearcore-5bf7818cf2261fd0/4ac008b/chain/client/src/client.rs:1063:21}
what to do when we are using nearcore version 1.26.1 which in turn is using protocol version 53 but none of the indexer tag is using nearcore 1.26.1 and logs are showing error.{ thread 'main' panicked at 'The client protocol version is older than the protocol version of the network. Please update nearcore', /home/ubuntu/.cargo/git/checkouts/nearcore-5bf7818cf2261fd0/4ac008b/chain/client/src/client.rs:1063:21}
nearcore 1.26.1
uses the same protocol version as 1.26.0
, 0.10.16
version of the indexer is based on 1.26.0
and they work together.
Please, create a separate issue, your comment does not relate to this issue.
how can I set up near-indexer for existing near localnet?