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 false positive in boolean flag #500

Merged
merged 1 commit into from
Sep 9, 2023

Conversation

alextes
Copy link
Contributor

@alextes alextes commented Aug 4, 2023

This caused some head scratching whilst debugging. Not sure about what to do here. Closing this in favor of a different diff is fine by me.

In short, we set a boolean flag WasBidSaved, which we also log as wasBidSavedInRedis as soon as we add a command to store the bid to the pipeline. But, when top bid == prev top bid, we return early and never execute the pipeline, making the flag a false positive. It and WasTopBidUpdated are also false positives in six or so early-return error branches, but currently do not get used in those scenarios.

⚠️ NOTE
Because this flag returned a false positive, Redis would not store the bid, but because we say it did, in handleSubmitNewBlock, memcached would actually store the payload! If I'm not mistaken, this would mean for bids which hit this path, when the proposer asks for a payload, it would not be found in Redis, but get served from memcached instead of postgres. For this narrow case, fixing the false positive would lead to worse performance for "non top bid bids".

Getting rid of the false positive is great, but the location the flag ends up getting set in is rather counter-intuitive. I think it's worth the trade-off, perhaps someone has ideas for how to better set this flag the first time Exec is called which happens to be in another function entirely. Perhaps it was never even the intention to drop the queued commands in the pipeline. Not sure.


✅ I have run these commands

  • make lint. Many errors, none my code.
  • make test-race
  • go mod tidy
  • I have seen and agree to CONTRIBUTING.md

We have several conditions where we don't execute the pipelined
commands. Only set the WasBidSaved flag after we execute the pipeline
successfully. Do note, if the pipeline fails we may or may not have
actually saved the bid.
@alextes alextes changed the title Fix false positive in log flag Fix false positive in boolean flag Aug 4, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #500 (a841455) into main (753275c) will increase coverage by 0.82%.
Report is 6 commits behind head on main.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main     #500      +/-   ##
==========================================
+ Coverage   30.58%   31.41%   +0.82%     
==========================================
  Files          24       24              
  Lines        4783     4854      +71     
==========================================
+ Hits         1463     1525      +62     
- Misses       3121     3136      +15     
+ Partials      199      193       -6     
Flag Coverage Δ
unittests 31.41% <100.00%> (+0.82%) ⬆️

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

Files Changed Coverage Δ
datastore/redis.go 60.28% <100.00%> (+0.08%) ⬆️

... and 6 files with indirect coverage changes

@michaelneuder
Copy link
Collaborator

LGTM!

@metachris metachris merged commit ee62215 into flashbots:main Sep 9, 2023
2 checks passed
michaelneuder pushed a commit that referenced this pull request Sep 21, 2023
fix(redis): move WasBidSaved to after exec

We have several conditions where we don't execute the pipelined
commands. Only set the WasBidSaved flag after we execute the pipeline
successfully. Do note, if the pipeline fails we may or may not have
actually saved the bid.
@alextes alextes deleted the flag-reliability branch October 30, 2023 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants