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

Pipelining #78

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Pipelining #78

wants to merge 25 commits into from

Conversation

leandernikolaus
Copy link
Contributor

This implements pipelining for chained hotstuff.
Pipelined blocks still form a single chain, but need not include the certificate for their direct parent.

Commit rule is updated to commit requests if there is a depth 3 confirmation chain and all intermediate blocks are confirmed as well.

@leandernikolaus leandernikolaus added the enhancement New feature or request label Oct 3, 2022
@leandernikolaus leandernikolaus self-assigned this Oct 3, 2022
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
types.go Outdated Show resolved Hide resolved
types.go Outdated Show resolved Hide resolved
Copy link
Member

@meling meling left a comment

Choose a reason for hiding this comment

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

Looks good. I've requested some changes. Looks like you already refer to the number of views as the type hotstuff.View:

	// PipelinedViews returns the number of concurrently executed views.
 	PipelinedViews() hotstuff.View

This makes it seem reasonable that the Synchronizer struct should also represent it as a hotstuff.View instead of a uint8.

synchronizer/synchronizer.go Outdated Show resolved Hide resolved
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
synchronizer/synchronizer.go Outdated Show resolved Hide resolved
@meling
Copy link
Member

meling commented Oct 4, 2022

Looks like some of the tests are failing now. Please take a look.

synchronizer/synchronizer.go Outdated Show resolved Hide resolved
twins/network.go Outdated
@@ -130,6 +130,13 @@ func (n *Network) createTwinsNodes(nodes []NodeID, scenario Scenario, consensusN
return err
}

if pipelinedViews < 1 || consensusName != "chainedhotstuff" {
Copy link
Member

Choose a reason for hiding this comment

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

This should not be done in the loop, and it is also more complex than necessary. Adding this at line 124 should suffice:

	if pipelinedViews > 1 && consensusName != "chainedhotstuff" {
		return fmt.Errorf("pipelining currently only supported for chainedhotstuff")
	}
	if pipelinedViews < 1 {
		pipelinedViews = 1
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in fb04815
I also added a similar error in internal/cli/run.go

func checkFlags() error {
	consensus := viper.GetString("consensus")
	pipelinedViews := viper.GetInt("pipelined-views")
	if pipelinedViews > 1 && consensus != "chainedhotstuff" {
		return errors.New("piplining only supported for chainedhotstuff consensus")
	}
	return nil
}

func (mr *MockSynchronizerMockRecorder) PipelinedViews() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PipelinedViews", reflect.TypeOf((*MockSynchronizer)(nil).PipelinedViews))
}
Copy link
Member

Choose a reason for hiding this comment

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

Missing newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in fb04815

@leandernikolaus
Copy link
Contributor Author

In 7e59d24 I revised the approach. Now the synchronizer has both a currentView and nextView.
currentView is advanced on receiving a TC or QC, while nextView is advanced on receiving a block if it lies within the pipeline.
This makes the system run more stable since it no longer reacts to individual timeouts.
However, the consensus module now no longer proposes blocks only in the current view but needs to receive a view, in which it should propose.
This also required updates to Twins.
Based on my analysis and testing, without pipelining, nextView and currentView should always coincide.

@meling
Copy link
Member

meling commented May 4, 2023

@leandernikolaus I tried to merge master into this branch (locally) in an attempt to resolve the conflicts. However, the current synchronizer no longer has a leafBlock field and LeafBlock() method, it wasn't clear to me what needed to be done. This was removed in this commit. Could you try to resolve the conflicts, or let me know what needs to be done to get this back into a good shape. Or let me know if this no longer makes sense to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants