Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

bzzeth: Phase2 of bzz eth protocol#1919

Merged
zelig merged 8 commits intomasterfrom
bzzethphase2
Nov 15, 2019
Merged

bzzeth: Phase2 of bzz eth protocol#1919
zelig merged 8 commits intomasterfrom
bzzethphase2

Conversation

@jmozah
Copy link
Copy Markdown
Collaborator

@jmozah jmozah commented Oct 31, 2019

The following tasks are in the Phase 2

= Use the actual eth block header and decode it.
= Handle GetBlockHeaders from a light client and serve the stored headers
= Update test cases to use the actual block header and other other stuff
= Test with Trinity client on the other side getting the blocks

@jmozah
Copy link
Copy Markdown
Collaborator Author

jmozah commented Oct 31, 2019

@zelig Unit tested the light client request. But testing the retrieve from another full node looks hard in unit test. But i tested that in the Trinity client case.

Screenshot 2019-10-31 at 1 05 00 PM

@jmozah jmozah mentioned this pull request Oct 31, 2019
@jmozah jmozah requested a review from janos October 31, 2019 07:43
bzzeth/bzzeth.go Outdated
batches := make(chan [][]byte)
defer close(batches)

// deliver in batches, this blocks until total number of requests are delivered or considered not found
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this comment correct?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

almost.. fixed it

bzzeth/bzzeth.go Outdated
continue
}
// initiate request with the chosen peer
req, err := p.getBlockHeaders(ctx, header, deliveryC, giveBackC)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not use just the same delivery channel? why do we need this givebackc?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

these two channels are different...
giveBackC is the actual channel to which we have to give back the header..
deliveryC is the channel for the second leg.. i.e. this Swarm node to Full node from which the header is requested...
so they have to be different..

bzzeth/bzzeth.go Outdated
}

wg.Add(1)
go b.getDelivery(ctx, req, &wg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is this doing? should we not just pipe delivered chunks to the original delivery chan?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As i explained above.. deliveryC takes care of the second leg...
This function just acknowledges the receipt of the header from the full node and updates the req connection .. similar to how we acknowledge in handleNewBlockHeaders

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what more is needed other than open a request and let handleBlockHeaders do the checks and channel responses to the shared deliveryC assigned to req.c?

bzzeth/bzzeth.go Outdated
// - reads requested header hashes from a channel (headerC) and
// - creates batch requests and sends them to an adequate bzzeth peer
// - channels the responses into a delivery channel (deliveries)
func (b *BzzEth) getBlockHeadersEth(ctx context.Context, headersC, giveBackC chan []byte, pwg *sync.WaitGroup, rcvdPeer *Peer) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you passing the requesting peer in order to filter but do we want to allow nodes that can serve as well as get headers?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we want to allow nodes to serve as well as get headers... but a same node can't be the requestor and provider isn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but then this should be read from the peer, so no need to pass it to filter our a requestor

bzzeth/bzzeth.go Outdated
// this loop terminates when batches channel is closed as a result of input headersC being closed
requiredCount := 0
var wg sync.WaitGroup
deliveryC := make(chan []byte)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why this other channel?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

explained above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

still dont get it, you just need one for requests the other for responses that you then sent back to the requesting peer after validation and storage.

Copy link
Copy Markdown
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

It is a bit harder to review channels handling and their correctness. Maybe an interactive review would help.

@jmozah
Copy link
Copy Markdown
Collaborator Author

jmozah commented Nov 1, 2019

It is a bit harder to review channels handling and their correctness. Maybe an interactive review would help.

No issues.. we can do it whenever you are free..

Copy link
Copy Markdown
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

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

the major things are:

  • I believe there is no need for two channels on a request . so we can get rid of givebackC.
  • We can also get rid of passing the peer to getEth since if we have two types of peers, we will never try to request from the one that requested

bzzeth/bzzeth.go Outdated
// - reads requested header hashes from a channel (headerC) and
// - creates batch requests and sends them to an adequate bzzeth peer
// - channels the responses into a delivery channel (deliveries)
func (b *BzzEth) getBlockHeadersEth(ctx context.Context, headersC, giveBackC chan []byte, pwg *sync.WaitGroup, rcvdPeer *Peer) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but then this should be read from the peer, so no need to pass it to filter our a requestor

bzzeth/bzzeth.go Outdated
// this loop terminates when batches channel is closed as a result of input headersC being closed
requiredCount := 0
var wg sync.WaitGroup
deliveryC := make(chan []byte)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

still dont get it, you just need one for requests the other for responses that you then sent back to the requesting peer after validation and storage.

@jmozah
Copy link
Copy Markdown
Collaborator Author

jmozah commented Nov 8, 2019

@zelig I have addressed both of your major comments. Removed the excess channel and removed passing peer to the getPeer function. Also i tried to address most of the other comments also.

@jmozah
Copy link
Copy Markdown
Collaborator Author

jmozah commented Nov 8, 2019

Screenshot 2019-11-08 at 10 18 26 PM

The above screenshot shows the Trinity light client connects with Swarm node... Swarm node connects with the Trinity full node gets the Header... stores it in Swarm.. and Sends it to Trinity light client.

Copy link
Copy Markdown
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

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

really minor last things

bzzeth/bzzeth.go Outdated
@@ -296,7 +311,14 @@ func (b *BzzEth) validateHeader(ctx context.Context, header []byte, req *request
return nil, errDuplicateHeader
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i am just saying there is no need for else since you return in the if clause.


// requestAll requests each hash and channel
func (b *BzzEth) requestAll(ctx context.Context, deliveries chan []byte, hashes []chunk.Address, rcvdPeer *Peer) {
// requestAll requests each hash from Swarm (local or Network) and send t0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

t0 -> to

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

// if this chunk is stored successfully, dont report error for it
if !flag {
continue
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you still do this error checking on line 296 for every iteration. instead just put it before the loop.
and also we should not ignore other errors coming from the db

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Pushed the err outside the loop
Catch other errors also

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

It would be nice to apply minor changes from @zelig comments. LGTM.

@zelig zelig merged commit 815475b into master Nov 15, 2019
acud added a commit that referenced this pull request Nov 18, 2019
@acud acud added this to the 0.5.3 milestone Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants