Block access list changes - BAL construction, execution and validation#32263
Block access list changes - BAL construction, execution and validation#32263jwasinger wants to merge 48 commits intoethereum:masterfrom
Conversation
|
A lot of the comments in the code are straight-up wrong/misleading. There's a lot of notes/reminders I made as I was implementing this, and not all of them have been removed/corrected at this point. |
|
I've pushed parallel execution changes here. Still failing 2 tests (other than modexp repricing ones which will be fixed with a rebase on master): I've been trying to debug these but it's proving to be exceedingly difficult with the parallel execution enabled. The tests seem to relate to behavior of some system contracts on the fork boundaries, so I will just proceed with gathering numbers on mainnet performance for the meantime. |
ab1c562 to
8f200db
Compare
|
Broke the block count on the insertion log statement here. Will try to fix tomorrow. |
|
Getting some empty accounts in the BAL. example: |
869b300 to
e14a463
Compare
lightclient
left a comment
There was a problem hiding this comment.
Looking good so far, just a few comments.
| var resCh chan *ProcessResultWithMetrics | ||
| resCh, err = bc.processor.ProcessWithAccessList(block, statedb, bc.cfg.VmConfig) | ||
| if err != nil { | ||
| // TODO: okay to pass nil here as execution result? |
There was a problem hiding this comment.
Should be fine, we just use it to get out the receipts (if it is non nil).
|
We decided on the EIP breakout call to keep account/storage reads in for now. Basically, without having this information it is possible that a transaction can be crafted which does a ton of storage reads and slow down the processing of the block significantly. So until we can evaluate worst-cases here, account/storage reads are staying in the spec. |
| bc.prefetcher.Prefetch(block, throwaway, vmCfg, &interrupt) | ||
| if block.Body().AccessList == nil { | ||
| // only use the state prefetcher for non-BAL blocks. | ||
| bc.prefetcher.Prefetch(block, throwaway, vmCfg, &interrupt) |
There was a problem hiding this comment.
I previously implemented a state prefetcher for BALs. I deleted it so that the import benchmarks I am running will capture the BAL block processing speed equivalent to a synced node executing blocks at chain head.
We should probably add back the BAL prefetcher and measure the import performance.
|
Also TODO: need to implement validation of storage/account reads against the BAL. |
| // The tx context and all occurred logs in the scope of transaction. | ||
| thash common.Hash | ||
| txIndex int | ||
| sender common.Address |
| // The tx context and all occurred logs in the scope of transaction. | ||
| thash common.Hash | ||
| txIndex int | ||
| sender common.Address |
There was a problem hiding this comment.
Yeah, it's leftover test data for a unit test that no longer exists (but should be updated and added back in).
7d3b230 to
93b4210
Compare
856a882 to
fe61a7a
Compare
74ca164 to
b24306e
Compare
| return nil, err | ||
| vstart := time.Now() | ||
| var err error | ||
| err = bc.validator.ValidateState(block, statedb, resWithMetrics.ProcessResult, false, false) |
There was a problem hiding this comment.
I would like to ask why validate state is needed here. The root has been calculated and compared during parallel processing.
There was a problem hiding this comment.
It's because ValidateState performs some other checks beyond root comparison that we still need to do.
There was a problem hiding this comment.
Got it, thanks.
Since the root is already computed and checked in parallel processing, should ValidateState still call statedb.IntermediateRoot()? Or should it only run the extra checks?
There was a problem hiding this comment.
I thought about optionally-enabling the call to IntermediateRoot via a flag parameter to ValidateState but decided against it because it felt dirtier than just always calling IntermediateRoot and incurring the overhead of an extra hash check. Also, a call to IntermediateRoot caches the result on the statedb instance so calling it a second time is a effectively a no-op.
I have essentially rewritten the BAL code path for state root calculation in order to optimize it. I haven't yet pushed those changes to this branch because I am trying to sort out a bug in them.
…ontract' in the same transaction
…ding state, move readOnly call context check into gas func to avoid unecessary state reads in the gas handler in case where these are called in a static context.
…ate access if the component of the call price which is independent from the state is not sufficient to cover the provided gas.
This PR is an alternative to ethereum#32556. Instead of trying to be smart and reuse `geth init`, we can introduce a new flag `--genesis` that loads the `genesis.json` from file into the `Genesis` object in the same path that the other network flags currently work in. Question: is something like `--genesis` enough to start deprecating `geth init`? -- ```console $ geth --datadir data --hoodi .. INFO [10-06|22:37:11.202] - BPO2: @1762955544 .. $ geth --datadir data --genesis genesis.json .. INFO [10-06|22:37:27.988] - BPO2: @1862955544 .. ``` Pull the genesis [from the specs](https://raw.githubusercontent.com/eth-clients/hoodi/refs/heads/main/metadata/genesis.json) and modify one of the BPO timestamps to simulate a shadow fork. --------- Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
…the Amsterdam tests aren't filled with bpo1/2 activated
… cover the state access costs
…oesn't contain one. remove the new pre/post-tx tracer hooks and use the system contract start/end hooks instead in the bal tracer
1c1ab63 to
158e44a
Compare
|
This got stale and I plan to propose a slightly different set of changes as an initial target for merging EIP-7928 support: we will merge a version that doesn't include the performance improvements initially. |
Change summary:
--experimental.balis enabled:Deviations from EIP-7928:
txindex=0correspond to state reads/changes which occur from system contract execution before transactions.txindx=1..len(block.transactions)correspond to state reads/changes occurring for each transaction.txindex=len(block.transactions)+1correspond to the post-block system contracts and EIP-4895 withdrawals.TODO: