-
Notifications
You must be signed in to change notification settings - Fork 5
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
Change host API to separate fetching chain from fetching power tables #256
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,10 @@ func (p *Participant) ReceiveAlarm() (err error) { | |
} | ||
|
||
func (p *Participant) beginInstance() error { | ||
chain, power, beacon := p.host.GetCanonicalChain() | ||
chain, err := p.host.GetChainForInstance(p.nextInstance) | ||
if err != nil { | ||
return fmt.Errorf("failed fetching chain for instance %d: %w", p.nextInstance, err) | ||
} | ||
// Limit length of the chain to be proposed. | ||
if chain.IsZero() { | ||
return errors.New("canonical chain cannot be zero-valued") | ||
|
@@ -153,11 +156,15 @@ func (p *Participant) beginInstance() error { | |
if err := chain.Validate(); err != nil { | ||
return fmt.Errorf("invalid canonical chain: %w", err) | ||
} | ||
|
||
power, beacon, err := p.host.GetCommitteeForInstance(p.nextInstance) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the next PR, these values will be cached in the participant and used to validate message. So each power table need only be computed once. |
||
if err != nil { | ||
return fmt.Errorf("failed fetching power table for instance %d: %w", p.nextInstance, err) | ||
} | ||
if err := power.Validate(); err != nil { | ||
return fmt.Errorf("invalid power table: %w", err) | ||
} | ||
var err error | ||
if p.granite, err = newInstance(p, p.nextInstance, chain, power, beacon); err != nil { | ||
if p.granite, err = newInstance(p, p.nextInstance, chain, *power, beacon); err != nil { | ||
return fmt.Errorf("failed creating new granite instance: %w", err) | ||
} | ||
p.nextInstance += 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want a stronger wording for chain suffix?
Thinking out loud: It would also be nice to be able to validate this inside F3 but I am not sure how if F3 delegates storage of finalised chains to the host. As is it feels error prone with dire consequences in case of error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is written from the narrow point of view of what does this code need. And in fact it will function correctly whether or not this is true (e.g. at genesis, or in case of a social agreement to re-start somewhere else, etc). This code doesn't need it to be a suffix, we can't write any test that will fail if it isn't, etc. Whether or not the multi-party protocol will make progress if this doesn't hold is a higher level matter.
I'd rather delete the comment than change it to a must.