onflow / flow-evm-gateway

FlowEVM Gateway implements an Ethereum-equivalent JSON-RPC API for EVM clients to use
https://developers.flow.com/evm/about
Apache License 2.0
11 stars 10 forks source link

eth_syncing returns incorrect start height #644

Closed peterargue closed 2 days ago

peterargue commented 4 weeks ago

Problem

I was debugging a data issue with a partner and they resynced their node from genesis by deleting the db, and starting up with --init-cadence-height=211176670. After a few minutes of syncing, they queried eth_syncing, and the returned data showed the starting height as block 3. They were able to query blocks 0-2 and received data back, so it appears that there is an issue determining the start height.

m-Peter commented 2 weeks ago

Good catch on this 👌 I was investigating this and found out that it happens from the way we bootstrap the various services. First we start the Event Ingestion Engine, and then the API Server. The API Server will perform a query to the blocks DB, to find the latest indexed EVM height, so we can keep track at which EVM height we are starting, after a restart or deployment, or anything. But since we start the Event Ingestion Engine first, it means that we may have already indexed some new EVM blocks, hence the start height returned by eth_syncing will be off by a few heights.

m-Peter commented 2 days ago

Completed by https://github.com/onflow/flow-evm-gateway/pull/679