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

chore (pkg/scale): Integrate scale into grandpa library #1694

Closed

Conversation

jimjbrettj
Copy link
Contributor

Changes

  • Integrate new scale pkg into grandpa

Tests

go test ./lib/grandpa -short -v

Issues

@jimjbrettj
Copy link
Contributor Author

Waiting to open this until scale network PR is merged

@jimjbrettj jimjbrettj changed the base branch from development to jimmy/integrateScaleNetwork July 14, 2021 19:20
@jimjbrettj jimjbrettj marked this pull request as ready for review July 14, 2021 19:24
vm := &VoteMessage{}
err = vm.Decode(r)
m = vm
err = scale.Unmarshal(msg.Data, &gossipMessage)
Copy link
Member

Choose a reason for hiding this comment

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

we need to check this error, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have it below the switch, but I can move it up if that's better

Copy link
Member

Choose a reason for hiding this comment

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

would be nice to check the error before the switch, will be easier to relate the error to the Unmarshal

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please handle the error immediately

@jimjbrettj jimjbrettj added the wip label Jul 15, 2021
@@ -842,7 +843,7 @@ func (s *Service) finalise() error {
return err
}

pcj, err := newJustification(s.state.round, bfc.Hash, bfc.Number, pcs).Encode()
pcj, err := scale.Marshal(newJustification(s.state.round, bfc.Hash, bfc.Number, pcs))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: create a local var for the justification on another line

// Type returns voteType
func (v *VoteMessage) Type() byte {
return voteType
}

// Index Returns VDT index
func (v *VoteMessage) Index() uint { return 0 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (v *VoteMessage) Index() uint { return 0 }
func (vm *VoteMessage) Index() uint { return 0 }

Update all the other receiver functions too.

@@ -147,9 +100,12 @@ type NeighbourMessage struct {
Number uint32
}

// Index Returns VDT index
func (m *NeighbourMessage) Index() uint { return 2 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (m *NeighbourMessage) Index() uint { return 2 }
func (nm *NeighbourMessage) Index() uint { return 2 }

return nil
}
// Index Returns VDT index
func (f *CommitMessage) Index() uint { return 1 }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (f *CommitMessage) Index() uint { return 1 }
func (cm *CommitMessage) Index() uint { return 1 }

vm := &VoteMessage{}
err = vm.Decode(r)
m = vm
err = scale.Unmarshal(msg.Data, &gossipMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please handle the error immediately

@@ -33,6 +31,7 @@ var (
grandpaID protocol.ID = "/paritytech/grandpa/1"
messageID = network.ConsensusMsgType
neighbourMessageInterval = time.Minute * 5
gossipMessage = scale.MustNewVaryingDataType(&VoteMessage{}, &CommitMessage{}, &NeighbourMessage{}, &catchUpRequest{}, &catchUpResponse{})
Copy link
Contributor

Choose a reason for hiding this comment

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

don't use the same VaryingDataType in decodeMessage. This isn't thread safe if there are parallel calls to decodeMessage. You will be overwriting the same address repeatedly, which could lead to undesired side effects.

@jimjbrettj jimjbrettj marked this pull request as draft July 19, 2021 20:53
@jimjbrettj jimjbrettj closed this Jul 22, 2021
@jimjbrettj jimjbrettj deleted the jimmy/integrateScaleGrandpa branch October 28, 2021 20:29
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.

4 participants