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

accept gzip encoding #365

Merged
merged 6 commits into from
Oct 20, 2022
Merged

accept gzip encoding #365

merged 6 commits into from
Oct 20, 2022

Conversation

dmarzzz
Copy link
Member

@dmarzzz dmarzzz commented Oct 1, 2022

📝 Summary

From a discussion with @zeroecco on how to lower bandwidth on the blocknative relay we came to the idea that we could utilize well known compression like gzip, but only if requests coming from mev-boost specified that.

Minimum transmittable unit is 1500 Bytes total w/ 1250 Bytes realistically usable and a block is around ~12KB, gzip will compress ~60% to ~6Kb which would be a packet reduction from 10 to 5 for the total packet train. This also reduces time to last packet and bandwidth, which could be 1 - 5ms based on response time at this size.

If a system doesn't have this enabled the content-encoding will simply be ignored.
On top of that, this improvement will really only be visible for GetPayload response.

To benefit from this in your relay or other components make sure you configure your reverse proxy [HA Proxy, NGINX, etc] to support gzip!

⛱ Motivation and Context

I want to go fast

📚 References

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding

https://www.rfc-editor.org/rfc/rfc2616#section-3.5

✅ I have run these commands

  • make lint
  • make test-race
  • go mod tidy

@codecov-commenter
Copy link

Codecov Report

Merging #365 (1939207) into main (496bf59) will increase coverage by 0.47%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #365      +/-   ##
==========================================
+ Coverage   80.94%   81.41%   +0.47%     
==========================================
  Files           5        5              
  Lines         677      678       +1     
==========================================
+ Hits          548      552       +4     
+ Misses         99       97       -2     
+ Partials       30       29       -1     
Flag Coverage Δ
unittests 81.41% <100.00%> (+0.47%) ⬆️

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

Impacted Files Coverage Δ
server/utils.go 72.85% <100.00%> (+0.39%) ⬆️
server/service.go 79.15% <0.00%> (+0.74%) ⬆️

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

@metachris
Copy link
Collaborator

Could you add a little bit of context please?

@metachris metachris added discuss in development 🛠️ not yet ready to be merged labels Oct 7, 2022
@zeroecco
Copy link

zeroecco commented Oct 11, 2022

Internally our testing of the [edit] math on whether this would work or not[end edit] did show a time to last packet reduction in deliveries of blocks of roughly 1-5ms depending on the resources of the validator.

Additionally this change can lead to more time for validators to propose on chain and thereby potentially lead fewer missing proposals though more efficient packet transport over the wider internet.

@dmarzzz dmarzzz marked this pull request as ready for review October 11, 2022 21:48
@dmarzzz
Copy link
Member Author

dmarzzz commented Oct 11, 2022

added some more context @metachris , didn't realize drafts showed up in public repos whoops!

@metachris
Copy link
Collaborator

metachris commented Oct 12, 2022

Thanks. It seems gzip would automatically be decoded, but deflate not?

server/utils.go Outdated Show resolved Hide resolved
@metachris
Copy link
Collaborator

Very cool feature btw and just 1 line of code with significant impact. I strongly support this.

@metachris metachris added the next up It's next up label Oct 12, 2022
Co-authored-by: Chris Hager <chris@linuxuser.at>
@dmarzzz
Copy link
Member Author

dmarzzz commented Oct 13, 2022

Awesome good fix! I added a note to the PR as well that for relays and others to enable this make sure you configure your reverse proxy [HA Proxy, NGINX, etc] to support gzip!

@dmarzzz
Copy link
Member Author

dmarzzz commented Oct 13, 2022

The test that lint is tripping up passes for me locally 🤔

@metachris
Copy link
Collaborator

metachris commented Oct 13, 2022

Failing lint step fixed in #374

@metachris
Copy link
Collaborator

@dmarzzz could you add a test where the mockserver returns a gzipped response?

jtraglia
jtraglia previously approved these changes Oct 17, 2022
Copy link
Collaborator

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

LGTM. Nice addition. Thanks!

@metachris
Copy link
Collaborator

Added a test for the gzip response: dmarzzz#1 (needs to be merged by @dmarzzz into his repo to update this PR)

@dmarzzz
Copy link
Member Author

dmarzzz commented Oct 19, 2022

@metachris thanks appreciate it, wasn't able to get to it till this weekend. When I merged it auto dismissed @jtraglia review

@metachris metachris requested a review from jtraglia October 19, 2022 13:53
Copy link
Collaborator

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

No worries. Thanks for the extra test.

@metachris metachris merged commit 9781fab into flashbots:main Oct 20, 2022
screwyprof pushed a commit to screwyprof/mev-boost that referenced this pull request Feb 3, 2023
* accept gzip encoding

* Capitalize and remove deflate

Co-authored-by: Chris Hager <chris@linuxuser.at>

* test for gzip response

Co-authored-by: Chris Hager <chris@linuxuser.at>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss in development 🛠️ not yet ready to be merged next up It's next up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants