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

Check Last Finalized Epoch #357

Merged
merged 44 commits into from
Aug 7, 2018
Merged

Check Last Finalized Epoch #357

merged 44 commits into from
Aug 7, 2018

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Jul 31, 2018

This pull request will deal with #351 , where we will determine the last finalized epoch of a connected peer and then start our sync from there.

Requirements for Merge

  • Get the last finalized epoch from a peer from a received block
  • This will also involve requesting the crystallized state either from that peer or another peer
  • Tests for this

@nisdas nisdas self-assigned this Jul 31, 2018
@nisdas nisdas added this to In progress in Beacon Chain via automation Jul 31, 2018
@nisdas nisdas added this to the Ruby milestone Jul 31, 2018
Copy link
Contributor

@rawfalafel rawfalafel left a comment

Choose a reason for hiding this comment

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

LGTM

@terencechain
Copy link
Member

@rawfalafel I don't think @nisdas has finished this. He hasn't implemented Get the last finalized epoch from a peer from a received block + tests

Copy link
Contributor

@rawfalafel rawfalafel left a comment

Choose a reason for hiding this comment

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

Whoops, I take this back then

@nisdas nisdas requested a review from rauljordan August 2, 2018 15:18
Copy link
Contributor

@rawfalafel rawfalafel left a comment

Choose a reason for hiding this comment

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

Looks great. Left a few comments.

@@ -197,6 +252,116 @@ func (ss *Service) ReceiveActiveState(data *pb.ActiveStateResponse) error {
return nil
}

// SetBlockForInitalSync sets the first received block as the base finalized
// block for initial sync.
func (ss *Service) SetBlockForInitalSync(data *pb.BeaconBlockResponse) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

SetBlockForInitialSync

blockResponse.SlotNumber = 21
ss.blockBuf <- msg1

time.Sleep(interval)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to use an interval, please pass in the channel rather than putting in a 1 second timeout.


// SetBlockForInitalSync sets the first received block as the base finalized
// block for initial sync.
func (ss *Service) SetBlockForInitalSync(data *pb.BeaconBlockResponse) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

SetBlockForInitialSync


func TestTimeChan(t *testing.T) {
hook := logTest.NewGlobal()
interval := time.Duration(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be avoided by passing the channel into the goroutine. We should really avoid adding extra time to the tests like this. They add up quickly.

if err != nil {
return false, err
}
if !hasActive && !hasCrystallized {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be !hasActive || !hasCrystallized?

switch ss.syncMode {
case 0:
log.Info("Starting initial sync")
go ss.initialSync(ss.ctx.Done())
Copy link
Contributor

Choose a reason for hiding this comment

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

do you disagree with this?

@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

Merging #357 into master will decrease coverage by <.01%.
The diff coverage is 53.28%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #357      +/-   ##
=========================================
- Coverage   49.81%   49.8%   -0.01%     
=========================================
  Files          35      35              
  Lines        2670    2795     +125     
=========================================
+ Hits         1330    1392      +62     
- Misses       1160    1206      +46     
- Partials      180     197      +17
Impacted Files Coverage Δ
shared/p2p/topics.go 100% <ø> (ø) ⬆️
beacon-chain/blockchain/service.go 28.86% <0%> (-4.08%) ⬇️
beacon-chain/blockchain/core.go 66.84% <0%> (-2.94%) ⬇️
beacon-chain/sync/service.go 61.2% <62.39%> (-0.87%) ⬇️
beacon-chain/rpc/service.go 67.74% <0%> (-12.91%) ⬇️
client/proposer/service.go 78.94% <0%> (+3.15%) ⬆️

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 36965be...e3ebefd. Read the comment docs.

Copy link
Contributor

@rawfalafel rawfalafel left a comment

Choose a reason for hiding this comment

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

One comment, then LGTM after builds pass. Awesome 👍

case 0:
log.Info("Starting initial sync")
go ss.initialSync(time.NewTicker(ss.syncPollingInterval).C, ss.ctx.Done())
case 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this

Copy link
Member Author

Choose a reason for hiding this comment

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

done, removed it

@nisdas nisdas merged commit 2cf7fa0 into prysmaticlabs:master Aug 7, 2018
Beacon Chain automation moved this from In progress to Done Aug 7, 2018
@nisdas nisdas deleted the initialsync branch August 23, 2018 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Beacon Chain
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants