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

header/p2p: request head from multiple peers #1046

Merged
merged 9 commits into from
Oct 11, 2022

Conversation

vgonkivs
Copy link
Member

@vgonkivs vgonkivs commented Aug 29, 2022

@vgonkivs vgonkivs self-assigned this Aug 29, 2022
@vgonkivs vgonkivs changed the title Request head from multiple peers header/exchange: request head from multiple peers Aug 29, 2022
@vgonkivs vgonkivs force-pushed the request_head_from_multiple_peers branch from c785d09 to d57e897 Compare August 29, 2022 14:27
@vgonkivs vgonkivs changed the title header/exchange: request head from multiple peers header/p2p: request head from multiple peers Aug 29, 2022
@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2022

Codecov Report

Merging #1046 (4e751fb) into main (b37a844) will increase coverage by 0.69%.
The diff coverage is 83.65%.

@@            Coverage Diff             @@
##             main    #1046      +/-   ##
==========================================
+ Coverage   56.33%   57.02%   +0.69%     
==========================================
  Files         136      141       +5     
  Lines        9170     9488     +318     
==========================================
+ Hits         5166     5411     +245     
- Misses       3465     3526      +61     
- Partials      539      551      +12     
Impacted Files Coverage Δ
header/p2p/request.go 0.00% <0.00%> (ø)
header/p2p/serde.go 0.00% <0.00%> (ø)
service/rpc/das.go 26.66% <33.33%> (-23.34%) ⬇️
das/store.go 61.53% <61.53%> (ø)
header/p2p/server.go 53.70% <69.56%> (+0.44%) ⬆️
das/daser.go 68.60% <74.07%> (-13.22%) ⬇️
header/p2p/pb/extended_header_request.pb.go 40.00% <74.24%> (+7.13%) ⬆️
header/p2p/exchange.go 67.40% <76.36%> (+5.18%) ⬆️
das/done.go 84.61% <84.61%> (ø)
das/subscriber.go 88.23% <88.23%> (ø)
... and 25 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
Member

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

@renaynay shared this PR with me, I hope my comments are helpful.

header/helper.go Outdated Show resolved Hide resolved
header/helper.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/server.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/helper.go Outdated Show resolved Hide resolved
header/helper.go Outdated Show resolved Hide resolved
header/helper.go Outdated Show resolved Hide resolved
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

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

Suggestions in the form of a PR/diff: https://github.com/vgonkivs/celestia-node/pull/50/files

@vgonkivs
Copy link
Member Author

vgonkivs commented Sep 8, 2022

In a discussion with @renaynay and @Wondertan we agreed, that we should take a header with max height that was provided by at least 2 of trusted peers

@vgonkivs vgonkivs force-pushed the request_head_from_multiple_peers branch 3 times, most recently from 41dc56f to 4e751fb Compare September 21, 2022 14:03
@vgonkivs vgonkivs requested a review from renaynay September 21, 2022 14:09
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

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

Looks really good! I still have yet to test it against arabica bc bridge is down.

  • Can we change doRequest to just request since we already have performRequest ?
  • Please format parseHead test like this:
		/*
			Height -> Amount
			headerHeight[0]=1 -> 1
			headerHeight[1]=2 -> 1
			headerHeight[2]=3 -> 1
			result -> headerHeight[2]
		*/
		{
			precondition:   gen,
			expectedHeight: 3,
		},
		/*
			Height -> Amount
			headerHeight[0]=1 -> 2
			headerHeight[1]=2 -> 1
			headerHeight[2]=3 -> 1
			result -> headerHeight[0]
		*/
		{
			precondition: func() []*header.ExtendedHeader {
				res := gen()
				res = append(res, res[0])
				return res
			},
			expectedHeight: 1,
		},
		/*
			Height -> Amount
			headerHeight[0]=1 -> 3
			headerHeight[1]=2 -> 2
			headerHeight[2]=3 -> 1
			result -> headerHeight[1]
		*/
		{
			precondition: func() []*header.ExtendedHeader {
				res := gen()
				res = append(res, res[0])
				res = append(res, res[0])
				res = append(res, res[1])
				return res
			},
			expectedHeight: 2,
		},
  • i would rename parseHeads to bestHead or something like that to indicate that we're looking for the best head according to documented conditions
  • can you add a debug log in the case that inside of parseHeads that you reach the case where no header has at least 2 peers returning it and you have to resort to returning the max height?

header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
@vgonkivs vgonkivs requested a review from renaynay September 22, 2022 09:32
@vgonkivs vgonkivs force-pushed the request_head_from_multiple_peers branch from d2d32ec to 095e3ff Compare September 22, 2022 10:37
walldiss
walldiss previously approved these changes Sep 22, 2022
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Show resolved Hide resolved
header/p2p/exchange.go Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
@vgonkivs vgonkivs force-pushed the request_head_from_multiple_peers branch 2 times, most recently from 63c741a to e44a96e Compare September 29, 2022 10:39
renaynay
renaynay previously approved these changes Sep 29, 2022
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
@vgonkivs vgonkivs dismissed stale reviews from walldiss and distractedm1nd via 514e326 October 10, 2022 11:06
@vgonkivs vgonkivs force-pushed the request_head_from_multiple_peers branch from d091f27 to 514e326 Compare October 10, 2022 11:06
walldiss
walldiss previously approved these changes Oct 10, 2022
MSevey
MSevey previously approved these changes Oct 10, 2022
renaynay
renaynay previously approved these changes Oct 11, 2022
header/p2p/exchange.go Outdated Show resolved Hide resolved
header/p2p/exchange.go Outdated Show resolved Hide resolved
@vgonkivs vgonkivs dismissed stale reviews from renaynay, MSevey, and walldiss via ccf6d62 October 11, 2022 09:07
@vgonkivs vgonkivs requested review from renaynay and walldiss October 11, 2022 09:07
@vgonkivs vgonkivs merged commit e89b628 into celestiaorg:main Oct 11, 2022
@vgonkivs vgonkivs deleted the request_head_from_multiple_peers branch January 9, 2023 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:header Extended header
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

header/p2p: Request Head from multiple trusted peers instead of just one and compare them
7 participants