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

Add signature verifications #138

Merged
merged 7 commits into from
Jun 9, 2022
Merged

Add signature verifications #138

merged 7 commits into from
Jun 9, 2022

Conversation

0xpanoramix
Copy link
Contributor

@0xpanoramix 0xpanoramix commented Jun 7, 2022

Description:

This PR adds support for signature verifications in the following handlers :

  • registerValidator
  • getHeader
  • getPayload

Problem(s) & goal(s):

See #95 for more context.

I have run these commands:

  • make lint
  • make test
  • make run-mergemock-integration
  • go mod tidy

Additional comments:

For now, mergemock integration tests do not pass because the relay generates a random private key for each run and mev-boost does not have a way to know which one it is.
I've created a PR which allows to provide a private key to mergemock's relay.

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

ok, err := types.VerifySignature(registration.Message, types.DomainBuilder, registration.Message.Pubkey[:], registration.Signature[:])
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should probably log the error (with log.Error), for visibility for the operator

return
}
if !ok {
http.Error(w, errInvalidSignature.Error(), http.StatusBadRequest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above. maybe even wrap the error and add a bit of context 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree, added in a1c0a4d

@@ -218,7 +228,7 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
var wg sync.WaitGroup
for _, relay := range m.relays {
wg.Add(1)
go func(relayAddr string) {
go func(relayAddr string, relayPubKey types.PublicKey) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to pass in the relay alltogether instead of the individual fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This way, we can only read the data. It slows down a little bit the process due to copies but honestly not that much.

@metachris
Copy link
Collaborator

very nice! 🙏

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
@codecov-commenter
Copy link

Codecov Report

Merging #138 (a1c0a4d) into main (ff25f53) will decrease coverage by 2.79%.
The diff coverage is 18.18%.

@@            Coverage Diff             @@
##             main     #138      +/-   ##
==========================================
- Coverage   71.56%   68.77%   -2.80%     
==========================================
  Files           6        6              
  Lines         517      538      +21     
==========================================
  Hits          370      370              
- Misses        121      137      +16     
- Partials       26       31       +5     
Flag Coverage Δ
unittests 68.77% <18.18%> (-2.80%) ⬇️

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

Impacted Files Coverage Δ
server/service.go 69.40% <18.18%> (-5.91%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff25f53...a1c0a4d. Read the comment docs.

@0xpanoramix 0xpanoramix marked this pull request as ready for review June 8, 2022 08:38
Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
@metachris metachris changed the base branch from main to develop June 9, 2022 17:52
@metachris
Copy link
Collaborator

merging into the develop branch

@metachris metachris merged commit b9394bc into flashbots:develop Jun 9, 2022
@metachris metachris mentioned this pull request Jun 9, 2022
7 tasks
metachris pushed a commit that referenced this pull request Jun 10, 2022
* Add signature verification for getHeader response

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Remove typo

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add signature verification for registerValidator request

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Update mergemock integration tests

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Fix typo in flag

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add error logging

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add signature verification tests

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>
metachris added a commit that referenced this pull request Jun 14, 2022
* Add signature verifications (#138)

* Add signature verification for getHeader response

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Remove typo

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add signature verification for registerValidator request

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Update mergemock integration tests

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Fix typo in flag

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add error logging

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add signature verification tests

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Require the relay pubkey (#143)

* mev-boost cli flags for setting genesis fork version, computing correct domain (#148)

* better errors on failed signature validation (#151)

Co-authored-by: Luca G.F <luca.georges-francois@epitech.eu>
screwyprof pushed a commit to screwyprof/mev-boost that referenced this pull request Feb 3, 2023
* Add signature verifications (flashbots#138)

* Add signature verification for getHeader response

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Remove typo

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add signature verification for registerValidator request

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Update mergemock integration tests

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Fix typo in flag

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add error logging

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Add signature verification tests

Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu>

* Require the relay pubkey (flashbots#143)

* mev-boost cli flags for setting genesis fork version, computing correct domain (flashbots#148)

* better errors on failed signature validation (flashbots#151)

Co-authored-by: Luca G.F <luca.georges-francois@epitech.eu>
This pull request was closed.
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.

3 participants