Skip to content
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(engine): always push back hooks, add tests #4924

Merged
merged 3 commits into from
Oct 5, 2023

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Oct 5, 2023

Problem

We didn't push hook back to the collection in two cases:

  1. When it's a read-write hook and we can't poll it because another read-write hook is running:
    if hook.db_access_level().is_read_write() &&
    (self.running_hook_with_db_write.is_some() || db_write_active)
    {
    return Poll::Pending
    }
  2. When hook.poll returns an error, and we short-circuit with ?:
    if let Poll::Ready((event, action)) = hook.poll(cx, args)? {

Solution

This PR introduces a helper poll_next_hook_inner method which guarantees that after trying to poll the hook we will either set the read-write hook as running, or push the hook back into collection.

Also, I covered the functionality of both poll_running_hook_with_db_write and poll_next_hook with tests of various scenarios.

@shekhirin shekhirin added C-bug An unexpected or incorrect behavior A-consensus Related to the consensus engine C-test A change that impacts how or what we test labels Oct 5, 2023
@codecov
Copy link

codecov bot commented Oct 5, 2023

Codecov Report

Merging #4924 (d0b4456) into main (1e7d028) will increase coverage by 0.25%.
Report is 2 commits behind head on main.
The diff coverage is 99.48%.

Impacted file tree graph

Files Coverage Δ
...es/consensus/beacon/src/engine/hooks/controller.rs 95.70% <100.00%> (+16.29%) ⬆️
crates/consensus/beacon/src/engine/hooks/mod.rs 66.66% <0.00%> (+11.11%) ⬆️

... and 31 files with indirect coverage changes

Flag Coverage Δ
integration-tests 15.47% <0.00%> (-0.01%) ⬇️
unit-tests 62.90% <99.48%> (+0.25%) ⬆️

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

Components Coverage Δ
reth binary 33.02% <ø> (+0.07%) ⬆️
blockchain tree 80.63% <ø> (+0.08%) ⬆️
pipeline 88.45% <ø> (+<0.01%) ⬆️
storage (db) 74.43% <ø> (+1.14%) ⬆️
trie 94.48% <ø> (ø)
txpool 48.89% <ø> (-0.50%) ⬇️
networking 76.09% <ø> (-0.04%) ⬇️
rpc 57.71% <ø> (+<0.01%) ⬆️
consensus 63.01% <99.48%> (+2.16%) ⬆️
revm 28.47% <ø> (ø)
payload builder 8.14% <ø> (ø)
primitives 85.42% <ø> (+0.04%) ⬆️

@shekhirin shekhirin marked this pull request as ready for review October 5, 2023 16:45
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

crates/consensus/beacon/src/engine/hooks/controller.rs Outdated Show resolved Hide resolved
@shekhirin shekhirin added this pull request to the merge queue Oct 5, 2023
Merged via the queue into main with commit 50b5215 Oct 5, 2023
23 checks passed
@shekhirin shekhirin deleted the alexey/hooks-controller-push-back branch October 5, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine C-bug An unexpected or incorrect behavior C-test A change that impacts how or what we test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants