Skip to content

refactor: Execution Stage owns Executor#1568

Merged
onbjerg merged 10 commits intomainfrom
refactor/stage-executor
Feb 28, 2023
Merged

refactor: Execution Stage owns Executor#1568
onbjerg merged 10 commits intomainfrom
refactor/stage-executor

Conversation

@gakonst
Copy link
Member

@gakonst gakonst commented Feb 26, 2023

Before, we had a weird pattern IMO where we'd call a execut_and_verify_with_receipts function with 5 arguments, and instantiating a new executor each time. That would make it really ugly if we wanted to integrate with the feature from PR #1567 as it'd require that we pass around the configuration for the inspectors. Instead, in this PR we refactor it so that the ExecutionStage now owns an Executor. It makes more sense this way, as we want the stage to basically be a coordinator around the 1-2 functions of the executor that are used across blocks (vs tracking more data than that).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DefaultDB thing is the only thing I don't like. It's necessary because when you instantiate the stage it still doesn't know the type of the database we'll use. It'd be nice if we can avoid it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to avoid this if we get a SubState type that expires part of the cache (in a correct way) since we would be able to instantiate that once as well. For now this has to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a redundant call to make on each iteration. shouldn't this be above along with state provider initialization?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the primary issue rn is that SubState is just a type alias for some wrapper around a StateProvider and revm's CacheDB, so there is no expiry/rotation of the cache. If you executed from block 0 to 10 million you would end up having the entire state in memory, so for now, we have to do this I guess

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @rakita if you have any thoughts on this

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2023

Codecov Report

Merging #1568 (ad8a495) into main (71bc145) will decrease coverage by 0.08%.
The diff coverage is 79.64%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #1568      +/-   ##
==========================================
- Coverage   74.91%   74.84%   -0.08%     
==========================================
  Files         373      373              
  Lines       43939    43946       +7     
==========================================
- Hits        32917    32891      -26     
- Misses      11022    11055      +33     
Flag Coverage Δ
integration-tests 21.25% <0.00%> (-0.02%) ⬇️
unit-tests 69.44% <79.64%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bin/reth/src/chain/import.rs 9.57% <0.00%> (-0.21%) ⬇️
bin/reth/src/dump_stage/execution.rs 0.00% <0.00%> (ø)
bin/reth/src/node/mod.rs 2.88% <0.00%> (-0.02%) ⬇️
bin/reth/src/stage/mod.rs 0.00% <0.00%> (ø)
bin/reth/src/test_eth_chain/runner.rs 0.00% <0.00%> (ø)
crates/revm/src/lib.rs 100.00% <ø> (ø)
crates/stages/src/lib.rs 100.00% <ø> (ø)
crates/stages/src/sets.rs 0.00% <0.00%> (ø)
crates/rpc/rpc-engine-api/src/engine_api.rs 92.72% <16.66%> (+0.35%) ⬆️
crates/stages/src/stages/execution.rs 92.62% <93.10%> (+0.18%) ⬆️
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like error is unrelated?

@onbjerg onbjerg added C-debt A clean up/refactor of existing code A-execution Related to the Execution and EVM labels Feb 27, 2023
Copy link
Member Author

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope sorry good to go.

gakonst and others added 10 commits March 1, 2023 00:18
before, we were only storing a chainspec and not an executor, which resulted
in a weird API with functions with a lot of arguments..this refactors the stage
to be able to be constructed from an executor or a chainspec.

this in turn will allow us to instantiate a stage with an executor that
e.g. is loaded with an inspector and have it be used across all transactions
@onbjerg onbjerg force-pushed the refactor/stage-executor branch from 84bee3a to ad8a495 Compare February 28, 2023 23:35
@onbjerg onbjerg merged commit 4285186 into main Feb 28, 2023
@onbjerg onbjerg deleted the refactor/stage-executor branch February 28, 2023 23:55
@gakonst
Copy link
Member Author

gakonst commented Mar 1, 2023

thx for getting over the line bjerg - my bad for dropping the ball here

@gakonst gakonst mentioned this pull request Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-execution Related to the Execution and EVM C-debt A clean up/refactor of existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants