ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.49k stars 20.1k forks source link

Management or JSON-RPC API Enhancement: determine the current sync mode #15780

Closed jpitts closed 4 years ago

jpitts commented 6 years ago

Background

geth CLI users as well as dapp browsers depending on geth may wish to get more feedback during the initial download / synchronization.

Enhancement

Add the ability to determine the current type or mode of synchronization to the Management or JSON-RPC API.

Additionally, add a synchronization status code and message. Status codes could include 'syncing' or 'error'. The status code and message would act as a pair. This pair should be expected to change once the underlying condition has changed.

Possible approach using the Management API:

> admin.downloaderStatus

Result:

{ syncMode: 'fast', syncStatus: 'error'. syncMessage: 'Something just went wrong', startingBlock: 0, currentBlock: 0, highestBlock: 0,
}

Possible approach using JSON-RPC:

> eth.syncing

Result:

{ syncMode: 'fast', syncStatus: 'error'. syncMessage: 'Something just went wrong', startingBlock: 0, currentBlock: 0, highestBlock: 0 }

References

Management APIs

JSON-RPC API: eth_syncing

Ethereum_Wallet_Syncing_Problems

evertonfraga commented 6 years ago

Adding my 2 wei:

As the wallet uses --syncmode fast, having only currentBlock and highestBlock is not enough. As the >50M state entries take significant time to sync, this API method could also return some data about state entry download progress — or an overall sync %.

skitzofrenicdev commented 6 years ago

:family_man_man_girl_boy::bikini::mother_christmas:

holiman commented 4 years ago

Adding error message doesn't really make sense, geth continuously connects/disconects with peers, and if a problem occur it will reinitiate sync with other peers. Differentiating between the modes "doing fast-sync" and "caught up to head, now doing block-by-block import" (which is what full-sync does from genesis) is already possible: when fast-sync is still catching up, it will also output the number of states downloaded.

holiman commented 4 years ago

As the >50M state entries take significant time to sync, this API method could also return some data about state entry download progress — or an overall sync %.

It's closer to 300M now. The problem is that it's not really possible to know in advance how many state entries there are :( . Hardcoding it will become wrong. It might be possible to guesstimate it based on trie density, but it's flaky

no-response[bot] commented 4 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have more relevant information or answers to our questions so that we can investigate further.