-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix trace error in Polygon | Pass Engin to the Base API #6131
Fix trace error in Polygon | Pass Engin to the Base API #6131
Conversation
// TODO: Replace with correct consensus Engine | ||
engine := ethash.NewFaker() | ||
apiList := commands.APIList(db, borDb, backend, txPool, mining, ff, stateCache, blockReader, agg, *cfg, engine) |
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 would need to be modified in theory, but I wasn't quite sure whether it was worth the extra work (we need extra arguments about Heimdall RPC for Polygon, etc.)
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.
- Any proofs that all current engines are thread-safe?
- if you need only limited amount of methods - lets use smaller interface
I looked a bit at some of the consensus and saw some locks, so I thought it was safe. Looking a bit more carefully, it wasn't actually always the case. Thus, I reduced the |
@ngotchac merge devel plz |
fd54538
to
898f8f1
Compare
Done! |
So there is an issue with tracing certain blocks/transactions on Polygon, for example:
gives the error
first run for txIndex 1 error: insufficient funds for gas * price + value: address 0x10AD27A96CDBffC90ab3b83bF695911426A69f5E have 16927727762862809 want 17594166808296934
The reason is that this transaction is from the author of the block, which doesn't have enough ETH to pay for the gas fee + tx value if he's not the block author receiving transactions fees.
The issue is that currently the APIs are using
ethash.NewFaker()
Engine for running traces, etc. which doesn't know how to get the author for a specific block (which is consensus dependant); as it was noting in several TODO comments.The fix is to pass the Engine to the BaseAPI, which can then be used to create the right Block Context. I chose to split the current Engine interface in 2, with Reader and Writer, so that the BaseAPI only receives the Reader one, which might be safer (even though it's only used for getting the block Author).