-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: eth: optimize eth block loading + eth_feeHistory #10446
Conversation
This optimizes the eth APIs (except the fee history one) to lookup the tipset state/receipts instead of computing the state.
Read the receipts all at once instead of fetching them one-by-one.
Blocked on #10445. |
Now that this API is _much_ faster, we're more likely to "catch up" to the head faster than it can stabilize. I'm pretty sure the test was intended to be written this way anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, about to test it.
After transitioning from using StateCompute to loading receipts, we can no longer handle the 'pending' block without forcing computation. Eth Core Devs are evaluating a proposal to remove support on their end too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I migrated eth_feeHistory
to reading receipts, and dropped support for the pending
block parameter. Fleshed out the description and added numbers. This is ready to go.
@Stebalien can you review my changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't approve but the new changes look correct.
for blocksIncluded < int(params.BlkCount) && ts.Height() > 0 { | ||
compOutput, err := a.StateCompute(ctx, ts.Height(), nil, ts.Key()) | ||
msgs, rcpts, err := messagesAndReceipts(ctx, ts, a.Chain, a.StateAPI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but it isn't great. Ideally we'd just walk the chain backwards as described in #10288.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't the mechanics the same?
It looks like we need to fix the conformance tests to drop the "pending" one. |
feat: eth: optimize eth block loading + eth_feeHistory
feat: eth: optimize eth block loading + eth_feeHistory
How to get correct nonce with pending txs after "pending" param is dropped ? |
|
This doesn't take into transactions in the mempool, which could cause nonce collisions. |
Related Issues
The current implementations of eth_getBlock* and eth_feeHistory have proven computationally expensive due to their usage of full tipset computations (
StateCompute
). This PR replaces the expensive logic with receipt lookups.Proposed Changes
For eth_getBlock* and eth_feeHistory, instead of replaying the tipset:
This also removes support for the
pending
block parameter as it's impossible to handle it without forcing state computes, which are prohibitively expensive. The Eth community is evaluating a proposal to also remove it in their next fork, given its limited applications due to MEV and other reasons.Additional Info
We've gone down from 10 seconds to various minutes (depending on the method and amount of data request) to almost instantaneous responses.
After
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps