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

Small fix for ConsensusContext #1413

Closed
wants to merge 1 commit into from
Closed

Conversation

shargon
Copy link
Member

@shargon shargon commented Jan 15, 2020

j must be only increased if the AddSignature was true

@@ -88,8 +88,8 @@ public Block CreateBlock()
for (int i = 0, j = 0; i < Validators.Length && j < M; i++)
{
if (CommitPayloads[i]?.ConsensusMessage.ViewNumber != ViewNumber) continue;
sc.AddSignature(contract, Validators[i], CommitPayloads[i].GetDeserializedMessage<Commit>().Signature);
j++;
if (sc.AddSignature(contract, Validators[i], CommitPayloads[i].GetDeserializedMessage<Commit>().Signature))
Copy link
Contributor

Choose a reason for hiding this comment

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

Under what kind of attack will the addition fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

No attack, just an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

I notice this error with a wrong blockchain imported, and a valid CN open (Related to #1414 )

Copy link
Member

Choose a reason for hiding this comment

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

Imported?

Strange, Shargon, did it really solve the problem?
Because the import does not pass through here, it goes to OnPersist and it is another flow, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't solve the problem of wrong import, only I notice that this variable is increased wrong if signature was not added

Copy link
Member

Choose a reason for hiding this comment

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

I checked this before and I found it strange as well, because some commit could be sent with wrong signature.

But I think this will not be enough in such case, I believe we would need to clean Header and exit the Return Block, right?

@@ -88,8 +88,8 @@ public Block CreateBlock()
for (int i = 0, j = 0; i < Validators.Length && j < M; i++)
{
if (CommitPayloads[i]?.ConsensusMessage.ViewNumber != ViewNumber) continue;
sc.AddSignature(contract, Validators[i], CommitPayloads[i].GetDeserializedMessage<Commit>().Signature);
j++;
if (sc.AddSignature(contract, Validators[i], CommitPayloads[i].GetDeserializedMessage<Commit>().Signature))
Copy link
Member

Choose a reason for hiding this comment

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

It is impossible to return false, I think.

@shargon
Copy link
Member Author

shargon commented Jan 17, 2020

With #1415 I think that it's impossible to return false

@shargon shargon closed this Jan 17, 2020
@shargon shargon deleted the consensuscontext-fix branch January 17, 2020 16:20
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