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

[Merged by Bors] - block certifyer: handle multiple certificates and equivocation #3736

Closed

Conversation

countvonzero
Copy link
Contributor

Motivation

Closes #3467

Changes

  • sql: add table certificates to hold certificates. the reason why the certificate is not a property of a block is that the network will certify a empty layer (using types.EmptyBlockID in certificate) when the hare output an empty set.

  • mesh, tortoise: while multiple valid certificates are stored in the table, when requesting the block to apply/vote for, certificates.GetHareOutput will return types.EmptyBlockID as hare output when there are multiple valid certificates

  • sync, fetcher: only asked peers for certificate when the nodes doesn't have any. only serve a certificate to peers when there is just one

@countvonzero
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Nov 11, 2022
@bors
Copy link

bors bot commented Nov 11, 2022

try

Build succeeded:

Copy link
Member

@fasmat fasmat left a comment

Choose a reason for hiding this comment

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

LGTM, just added a comment for a possible performance improvement.

fetch/handler.go Outdated Show resolved Hide resolved
return nil
}

// GetHareOutput returns the block that's valid as hare output for the spcified layer.
Copy link
Member

Choose a reason for hiding this comment

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

Typo:

Suggested change
// GetHareOutput returns the block that's valid as hare output for the spcified layer.
// GetHareOutput returns the block that's valid as hare output for the specified layer.

// if there are more than one valid blocks, return types.EmptyBlockID.
func GetHareOutput(db sql.Executor, lid types.LayerID) (types.BlockID, error) {
var (
result []types.BlockID
Copy link
Contributor

Choose a reason for hiding this comment

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

result can be just a types.BlockID
if rows > 1 then it can return types.EmptyBlockID

mesh/mesh.go Outdated
if err != nil {
logger.With().Warning("failed to get hare output", layerID, log.Err(err))
return nil, fmt.Errorf("%w: get hare output %v", errMissingHareOutput, err.Error())
}
// hare output an empty layer
// hare output an empty layer, or the network equivocated with multiple valid certificate
Copy link
Contributor

Choose a reason for hiding this comment

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

turns out there is a case when multiple valid certificates can exist even without equivocation, so maybe equivocation can be omitted from this description

800 is an expected number of eligibility (so it can be 802 for example), and then both sides of 50/50 split can succeed in forming valid certs

@countvonzero
Copy link
Contributor Author

bors merge

bors bot pushed a commit that referenced this pull request Nov 12, 2022
## Motivation
<!-- Please mention the issue fixed by this PR or detailed motivation -->
Closes #3467
<!-- `Closes #XXXX, closes #XXXX, ...` links mentioned issues to this PR and automatically closes them when this it's merged -->

## Changes
<!-- Please describe in detail the changes made -->
- sql: add  table `certificates` to hold certificates. the reason why the certificate is not a property of a block is that the network will certify a empty layer (using `types.EmptyBlockID` in certificate) when the hare output an empty set.

- mesh, tortoise: while multiple valid certificates are stored in the table, when requesting the block to apply/vote for, `certificates.GetHareOutput` will return `types.EmptyBlockID` as hare output when there are multiple valid certificates

- sync, fetcher: only asked peers for certificate when the nodes doesn't have any. only serve a certificate to peers when there is just one
@bors
Copy link

bors bot commented Nov 12, 2022

Build failed:

@countvonzero
Copy link
Contributor Author

bors merge

bors bot pushed a commit that referenced this pull request Nov 12, 2022
## Motivation
<!-- Please mention the issue fixed by this PR or detailed motivation -->
Closes #3467
<!-- `Closes #XXXX, closes #XXXX, ...` links mentioned issues to this PR and automatically closes them when this it's merged -->

## Changes
<!-- Please describe in detail the changes made -->
- sql: add  table `certificates` to hold certificates. the reason why the certificate is not a property of a block is that the network will certify a empty layer (using `types.EmptyBlockID` in certificate) when the hare output an empty set.

- mesh, tortoise: while multiple valid certificates are stored in the table, when requesting the block to apply/vote for, `certificates.GetHareOutput` will return `types.EmptyBlockID` as hare output when there are multiple valid certificates

- sync, fetcher: only asked peers for certificate when the nodes doesn't have any. only serve a certificate to peers when there is just one
@bors
Copy link

bors bot commented Nov 12, 2022

Pull request successfully merged into develop.

Build succeeded:

@bors bors bot changed the title block certifyer: handle multiple certificates and equivocation [Merged by Bors] - block certifyer: handle multiple certificates and equivocation Nov 12, 2022
@bors bors bot closed this Nov 12, 2022
@countvonzero countvonzero deleted the handle-multiple-certs branch January 20, 2023 01:43
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.

tortoise: vote for an empty layer if multiple certificate were signed by the same committee
3 participants