question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Peers disconnect upon requesting 20 blocks

See original GitHub issue

TL;DR

Running from source (Linux)

sed -i 's%const REQUEST_BLOCKS_PER_MESSAGE.*%const REQUEST_BLOCKS_PER_MESSAGE = 2%' ironfish/src/syncer.ts
yarn start:once start

Running from source (Windows)

  • Open ironfish/src/syncer.ts in Notepad
  • Edit const REQUEST_BLOCKS_PER_MESSAGE = 20 to const REQUEST_BLOCKS_PER_MESSAGE = 2
  • Save the file
  • yarn start:once start

Running from Docker (Linux and Windows)

❗This assumes you did NOT run your container with --rm else the changes are gone on restart!!❗

I expect your container to be run with: docker run -d --name ironfish --network host ghcr.io/iron-fish/ironfish:latest ........

Find NAME_OF_YOUR_DOCKER_CONTAINER with docker ps -a

image

docker exec -t NAME_OF_YOUR_DOCKER_CONTAINER sh -c "sed -i 's%REQUEST_BLOCKS_PER_MESSAGE.*%REQUEST_BLOCKS_PER_MESSAGE = 2%' /usr/src/app/node_modules/ironfish/build/src/syncer.js"
docker restart NAME_OF_YOUR_DOCKER_CONTAINER
docker logs -f NAME_OF_YOUR_DOCKER_CONTAINER

Problem

A lot of issues on GH and Discord about peers disconnecting while syncing. I’ve done some debugging:

Reproduction of the bug: image

My initial start: https://github.com/iron-fish/ironfish/blob/master/ironfish/src/syncer.ts#L358-L362

      this.logger.info(
        `Requesting ${this.blocksPerMessage} blocks starting at ${HashUtils.renderHash(
          head,
        )} (${sequence}) from ${peer.displayName}`,
      )

I noticed blocksPerMessage is 20, being passed in the ctor: https://github.com/iron-fish/ironfish/blob/master/ironfish/src/syncer.ts#L65

My hunch was the peers are timing out sending 20 blocks, so I lowered it to 1:

image

Upon restarting, this solved the problem and my chain is syncing again:

image

Experimenting with a number, I found 10 is still to high, but 5 works.

    this.blocksPerMessage = 5; //options.blocksPerMessage ?? REQUEST_BLOCKS_PER_MESSAGE

image

Short term fix is to use a lower blocksPerMessage, long term fix is to make sure peers dont disconnect when sending blocks over.

I can create the PR for the short term fix if needed.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iephesuscommented, Dec 14, 2021

i use docker image and how to do this?

0reactions
dguenthercommented, Dec 22, 2021

Thanks for the detailed bug reports and reproduction steps on this. A fix for this is available in 0.1.11, so please update your nodes and try again, and if you’re still having further problems related to this, please open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random peer disconnecting · Issue #1335 · paritytech/substrate
Setup a local network with two peers and make one sync off the other. Sometimes the connection is dropped for no good reason....
Read more >
Bitcoin core sync stuck with an error "peer=X is stalling block ...
I have installed bitcoin core (23.0) on a virtual machine (Debian GNU/Linux 10, x86_64) and tried to start the testnet initial block ......
Read more >
Timeout downloading block from peer, disconnecting
I have a master node with 900+ blocks. Now I try to connect a new node, but when it starts syncing up with...
Read more >
Understanding debug isdn q931 Disconnect Cause Codes
Hex Code Cause Description Additional Information 80 Normal Disconnect The call disconnects normally. 82 No route to specified network 90 Normal call clearing
Read more >
BitTorrentSpecification - TheoryOrg - wiki
A block is a portion of data that a client may request from a peer. Two or more blocks make up a whole...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found