ethereum / ethereum/execution-apis
Include finalization information in `eth_getBlockByHash`
- Dominant language
- Io
- Stars
- 1.1k
- Forks
- 530
- Avg merge
- 5d 8h
- Merged PRs (30d)
- 9
Description
I'm conscious that this may be difficult to implement in execution clients, so please consider this issue a request-for-comment rather than a definitive proposal.
Currently I think the best flow for checking if a transaction is finalized is:
1. Get transaction receipt using `eth_getTransactionReceipt`. Save the `blockHash` and `N=blockNumber`.
2. Poll `eth_getBlockByNumber finalized` until the finalized block number is `>= N`. At this point your transaction is _probably_ finalized, but you need to check that your block didn't get re-orged.
3. Call `eth_getBlockByNumber N` and check that the `blockHash` matches the `blockHash` from step 1.
If the EL surfaced finalization information in its responses this could be reduced to a simple poll of `eth_getBlockByHash` until it returns a status indicating that the transaction's block is finalized.
This could be achieved by an extra field in the `Block` that indicates the confirmation status:
- `finalized`: the block is the finalized block or one of its ancestors.
- `safe`: the block is the `safe` block or one of its ancestors (note currently `safe=justified`).
- `canonical`: the block is present in the canonical chain but is not yet `safe` or `finalized`.
- `non_canonical`: the block is non-canonical but compatible with finalization (it hasn't fully permanently yet).
- `orphaned`: the block was re-orged out permanently (part of a non-canonical chain incompatible with finalization).
- others?
Contributor guide
Assessment
This issue has not been assessed yet.