ironfish: [Bug] Peers disconnect upon requesting 20 blocks
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
toconst 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
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:
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:
Upon restarting, this solved the problem and my chain is syncing again:
Experimenting with a number, I found 10 is still to high, but 5 works.
this.blocksPerMessage = 5; //options.blocksPerMessage ?? REQUEST_BLOCKS_PER_MESSAGE
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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 16 (3 by maintainers)
i use docker image and how to do this?