0

This is a similar to question to this one

I have just setup 2 private nodes on AWS EC2 via geth, which are connected to each other, and have 1 "Hello World" smart contract already mined.

Unfortunately, I had to reset my network and when it went back up online, Node 1 had reset to block 0, while Node 2 was in the latest block (block 2).

I understand that this happened because I shut down incorrectly and that up to 128 blocks can be lost, but is there any way to sync back the 2 nodes again?

I have also ran web3.eth.getBlock() in the geth console of both nodes, and I can see that both Node 1 and 2 have data for all blocks (0, 1, 2).

So I think there must be a way to sync Node 1 back up again?

Many thanks in advance.

1 Answer 1

0

After a lot of trial and error, I finally managed to solve this issue, so I will provide the steps of my solution below, in case anybody else encounter this problem.

Since Node 1 was out of sync with Node 2 in my private chain, I decided to go to the directory where the blockchain data for Node 1 was stored and delete the whole geth folder. This essentially resets the Node 1 stored data and forces it back to Block 0.

After that, I then reinitialized Node 1 with the same genesis block that I had before (by running: geth --datadir "./Node1/" init genesis.json). This recreates the geth directory for Node 1, but the Node is still at Block 0.

After that, I initiliazed the blockchain as normal and connected both nodes to each other via admin.peers or by assigning static peers in their respective directories.

As soon as the nodes connect to each other Node 1 is then able to download all the data from Node 2 and sync back up again.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.