WhiteflagProtocol / whiteflag-api

Reference implementation of the Whiteflag protocol in Node.js that acts as an API to connect applications with the underlying blockchains
https://api.whiteflagprotocol.org
Other
4 stars 5 forks source link

Incorrect handling of Ethereum block numbers when node is resyncing #12

Closed ts5746 closed 4 years ago

ts5746 commented 4 years ago

Description

The Ethereum module does not correctly handle situations where the highest block (of the Ethereum node) is lower than the current block (of the API), e.g. when (re)connecting to a node that is still syncing, or when doing a full resync.

Environment / Versions

Software

Symptoms and Problem details

Step to reproduce

Connect to an Ethereum node that is still syncing and behind.

Expected result

The API should wait until the highest block (of the node) is higher than the current block (of the API).

Actual result

The API tries to retrieve negative block numbers because the node is fully resyncing from 0 resulting in an a warning.

ts5746 commented 4 years ago

Bugfix in commit c45f56b. The module will not try to retrieve (negative) blocks when highest block (on node) is lower than current block. Instead, it waits until the syncing node catches up. Note that the starting block blockRetrievalStart may always be set in the blockchains.toml configuration file to enforce starting from a specific block.