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

Change host API to separate fetching chain from fetching power tables #256

Merged
merged 1 commit into from
May 21, 2024

Conversation

anorth
Copy link
Member

@anorth anorth commented May 21, 2024

Step 1 of #151. This is in preparation for fetching power tables for validation of messages for future instances.

See discussion in #151 about the interface design. The powertable offset parameter is encapsulated by the host, which can respond to a request for the power table to use for some (possibly-future) instance. This capability isn't used yet.

This change also removes fixed beacons in the sim, which was previously using the same beacon for every instance. Now it's generated (by setting it equal to the base tipset key bytes).

@anorth anorth requested review from masih and Kubuxu May 21, 2024 01:16
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2024

Codecov Report

Attention: Patch coverage is 90.62500% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 71.63%. Comparing base (cb0b295) to head (6c21ef9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
- Coverage   71.66%   71.63%   -0.04%     
==========================================
  Files          31       31              
  Lines        2333     2337       +4     
==========================================
+ Hits         1672     1674       +2     
- Misses        532      533       +1     
- Partials      129      130       +1     
Files Coverage Δ
sim/adversary/decide.go 80.00% <100.00%> (ø)
sim/adversary/repeat.go 85.00% <100.00%> (ø)
sim/adversary/withhold.go 84.46% <100.00%> (ø)
sim/ec.go 55.17% <100.00%> (+0.38%) ⬆️
sim/options.go 75.34% <ø> (-0.66%) ⬇️
sim/sim.go 75.51% <100.00%> (-0.49%) ⬇️
gpbft/participant.go 85.71% <85.71%> (+0.60%) ⬆️
sim/host.go 94.73% <81.81%> (-5.27%) ⬇️

@@ -153,10 +156,14 @@ 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)
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

// ReceiveDecision (or known to be final via some other channel).
GetCanonicalChain() (chain ECChain, power PowerTable, beacon []byte)
// Returns the chain to propose for a new GPBFT instance.
// This should be a suffix of the chain finalised by the immediately prior instance.
Copy link
Member

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?

Suggested change
// This should be a suffix of the chain finalised by the immediately prior instance.
// This must be a suffix of the chain finalised by the immediately prior instance.

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.

Copy link
Member Author

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.

sim/host.go Outdated Show resolved Hide resolved
gpbft/api.go Outdated
// or known to be final via some other channel (e.g. when bootstrapping the protocol).
// The offset (how many instances to look back) is determined by the host.
// Returns an error if the power table for the instance is not available.
GetCommitteeForInstance(instance uint64) (power PowerTable, beacon []byte, err error)
Copy link
Member

Choose a reason for hiding this comment

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

Thinking out loud: The phrase Committee seems reasonable. But, unless it is already used elsewhere, I am curious if we can avoid introducing a new terminology. Having said that, I am failing to think of an existing alternative.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is new in the code (though common in the literature). If we generalised to sub-sampling the power table in the future (for scale), this would be exactly the right term.

I went through a similar thought process as you but couldn't come up with anything better.

gpbft/api.go Outdated Show resolved Hide resolved
…, in preparation for using the latter for validation of early messages.
@anorth anorth enabled auto-merge May 21, 2024 21:05
@anorth anorth added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit db09264 May 21, 2024
3 of 4 checks passed
@anorth anorth deleted the anorth/power-api branch May 21, 2024 21:10
Copy link

Fuzz test failed on commit 6c21ef9. To troubleshoot locally, download the seed corpus using GitHub CLI by running:

gh run download 9181466960 -n testdata

Aleternatively, download directly from here.

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.

None yet

4 participants