openethereum / parity-ethereum

The fast, light, and robust client for Ethereum-like networks.
Other
6.81k stars 1.68k forks source link

Parity full node synchronization for read-only purposes with lowest chain reorganisation depth #11807

Closed dariusdev closed 4 years ago

dariusdev commented 4 years ago

Currently we are running history ethereum node which has ability to reorganize the chain. The consequences of that is that transactions are changing their position regarding blocks.

eg: When you are requesting web3.getBlock(x) you receive that transaction y is in latest block.
After few min you request web3.getBlock(latest) again an you receive that the same y transaction is on latest block again. This happens because of our node chain reorganisation.

Is it possible to configure parity node to follow only main chain or longest chain, to reduce this forking depth to the minimum ? Which configuration options can make impact to deal with that?

adria0 commented 4 years ago

Is it possible to configure parity node to follow only main chain or longest chain, to reduce this forking depth to the minimum ?

Chain reorganizations are inherent to the PoW mechanism and openethereum does not give any "helper" for this in its web3 interface for applications, so you should define a strategy to use when chain reorgs happen.

dariusdev commented 4 years ago

It is not about helper or web3. Question is: Is it possible to change node configuration to make node data as close to main chain as possible?

tjayrush commented 4 years ago

I think you misunderstand something.

Every node in the entire system always follows what it currently thinks is the main chain (or saying the same thing: deepest chain). Sometimes, a given node will see a new block that convinces it that is was previously following an 'incorrect chain--i.e. a fork). This will happen if the new block has more POW. If the node sees something like that, even if it previously thought a different chain was the 'main chain', it will switch over to the new chain.

While it is theoretically true that at any time a given node may see a block that causes it to switch forks, it becomes increasingly less likely that this will happen as more blocks pile up.

In direct answer to your question -- there can be NO setting that causes a node to follow the 'main chain' because at every single second every node already IS following its own best guess at what the main chain is.