erigon icon indicating copy to clipboard operation
erigon copied to clipboard

Add "latestIndexed" defaultBlock param value

Open tsutsu opened this issue 2 years ago • 6 comments

Goal: allow a block to be ignored for purposes of RPC, until all ancillary internal data structures for that block that power other RPC methods have been built (and become available to an external rpcdaemon).

Changes:

  • Add defaultBlock param-value latestIndexed, to refer to the lowest block-height that has passed all stages
  • For chains not driven by CL fork-choice, for which latest currently means latestExecuted, change latest to mean latestIndexed instead.

Making latest mean latestIndexed provides safety by default, and matches geth semantics.

People who want to trade safety for efficiency, to see partially-processed blocks during first sync after restart, can make this desire explicit by passing latestExecuted rather than latest.

tsutsu avatar May 16 '23 22:05 tsutsu

matches geth semantics - what does it mean? I don't see this parameter in geth source code

FYI: some related PR https://github.com/ledgerwatch/erigon/pull/7532

AskAlexSharov avatar May 18 '23 02:05 AskAlexSharov

matches geth semantics - what does it mean? I don't see this parameter in geth source code

Geth's RPC code inherently can't see a block until that block goes through all stages of processing (since in geth, RPC can only get a handle on blocks through the chain head, and that's the last thing to be advanced during block insert.) eth_blockNumber("latest") in geth has the semantics of returning a reference to the highest known "finished" block.

This PR would make Erigon's eth_blockNumber("latest") do the same thing that Geth's eth_blockNumber("latest") does: avoid revealing unfinished blocks.

This PR also introduces an explicit name for this semantics, latestIndexed, to distinguish it from the current semantics, which is also known as latestExecuted. Client software that wants to get a specific semantics, but not fall back to some other semantics if it isn't, can do so by using the explicit name. (I presume that this explicit-ness is the reason that latestExecuted was added, despite latest also being aliased to latestExecuted.)

Changing the meaning of latest is the reason I did the PR. Adding another explicit name isn't so important. (But I'm not sure why you wouldn't add it. Adding values to an enum never breaks API compatibility; existing clients just won't know about those options, and so won't use them.)

tsutsu avatar May 23 '23 11:05 tsutsu

This PR is stale because it has been open for 40 days with no activity.

github-actions[bot] avatar Aug 25 '23 02:08 github-actions[bot]

Hello, We encountered a similar problem and ended up seeing an inconsistent state in the logs. Is there a reason this PR is stale?

gdevanla avatar Nov 29 '23 17:11 gdevanla

@gdevanla what is your version?

AskAlexSharov avatar Nov 30 '23 00:11 AskAlexSharov

@AskAlexSharov We are on erigon version 2.42.0-stable-beb97784

gdevanla avatar Nov 30 '23 05:11 gdevanla

Closing since it's very old

yperbasis avatar Sep 23 '25 14:09 yperbasis