-
Notifications
You must be signed in to change notification settings - Fork 15
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
Resolve long time consensus stuck by network and simple refactorings #915
Resolve long time consensus stuck by network and simple refactorings #915
Conversation
f23ce85
to
1a88da6
Compare
lib/node/runner/checker.go
Outdated
Round: blt.VotingBasis().Round, | ||
BallotState: blt.State(), | ||
}, | ||
false, |
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.
In this part, nr.SetSendRecord
should be true
? The expired Ballot is sent, right?
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.
@spikeekips Oh, good question 👍
This false setting is for initializing SendRecord.
Because if SendRecord is true, then this ballot will be discarded in nr.BroadcastBallot().
If it is confusing, I can make this to another method like InitializeSendRecord
.
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.
@Charleslee522 Renaming will be good :)
7923616
to
5620c9a
Compare
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.
Just a few comments, but looks nice
lib/consensus/isaac.go
Outdated
config := is.Conf | ||
opc, _ := ballot.NewCollectTxFeeFromBallot(*newExpiredBallot, config.CommonAccountAddress) | ||
opi, _ := ballot.NewInflationFromBallot(*newExpiredBallot, config.CommonAccountAddress, config.InitialBalance) | ||
ptx, _ := ballot.NewProposerTransactionFromBallot(*newExpiredBallot, opc, opi) |
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.
Do not avoid error checking here
lib/consensus/isaac.go
Outdated
@@ -85,6 +85,25 @@ func (is *ISAAC) SelectProposer(blockHeight uint64, round uint64) string { | |||
return is.proposerSelector.Select(blockHeight, round) | |||
} | |||
|
|||
func (is *ISAAC) GenerateExpiredBallot(basis voting.Basis, state ballot.State) ballot.Ballot { |
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.
Documentation?
|
||
newExpiredBallot.SetProposerTransaction(ptx) | ||
newExpiredBallot.SignByProposer(is.Node.Keypair(), config.NetworkID) | ||
newExpiredBallot.Sign(is.Node.Keypair(), config.NetworkID) |
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.
Since we always need to call Sign
after SignByProposer
, SignByProposer
should probably do it itself.
That will also avoid the double hashing / signature which is expensive.
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.
hm.. already SignByProposer
is called in Sign.
I need more time to think about handing and signing ExpiredBallot
.
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.
@Geod24 How about handling it in the next pr?
I think it is not related with this commit :)
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.
Yes
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.
@@ -2,7 +2,6 @@ package ballot | |||
|
|||
import ( | |||
"encoding/json" | |||
"time" |
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.
I love this commit
@@ -225,14 +225,14 @@ func (is *ISAAC) Vote(b ballot.Ballot) (isNew bool, err error) { | |||
return | |||
} | |||
|
|||
func (is *ISAAC) CanGetVotingResult(b ballot.Ballot) (rv RoundVoteResult, vh voting.Hole, finished bool) { | |||
func (is *ISAAC) CanGetVotingResult(blt ballot.Ballot) (rv RoundVoteResult, vh voting.Hole, finished bool) { |
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.
👍 for using at least 3 char identifiers. Makes the code much more readable IMO.
lib/consensus/ballot_send_record.go
Outdated
@@ -24,11 +24,11 @@ func NewBallotSendRecord(nodeAlias string) *BallotSendRecord { | |||
return p | |||
} | |||
|
|||
func (r *BallotSendRecord) SetSent(state ISAACState) { | |||
func (r *BallotSendRecord) SetSent(state ISAACState, sent bool) { |
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.
Good time to add documentation?
lib/consensus/isaac.go
Outdated
@@ -225,6 +225,52 @@ func (is *ISAAC) Vote(b ballot.Ballot) (isNew bool, err error) { | |||
return | |||
} | |||
|
|||
// RemoveOldBallots checkes that `blt` has valid confirmed and proposed time. |
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.
Whyyyyyy do all golang documentation start with the function name ? Presumable having the doc attached to the symbol should be enough ? Especially given the extra long names of Go functions...
Anyway, you don't have to change it, since it's consistent with the rest. However, "checkes" => "checks"
lib/consensus/isaac.go
Outdated
} | ||
var roundVote *RoundVote | ||
var err error | ||
roundVote, err = runningRound.RoundVote(blt.Proposer()) |
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.
Why not :=
?
lib/consensus/isaac.go
Outdated
} | ||
} | ||
case ballot.StateACCEPT: | ||
for nodeAddr, blt := range roundVote.ACCEPT { |
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.
No way to pull this code together ? They have the same logic, just a different variables (roundVote.{SIGN,ACCEPT}
)
From voting.Hole to ballot.Ballot Because we need ballot proposed time and ballot hash
And documentation related methods
5620c9a
to
2d15378
Compare
@@ -24,6 +24,8 @@ func NewBallotSendRecord(nodeAlias string) *BallotSendRecord { | |||
return p | |||
} | |||
|
|||
// SetSent sets that the ballot of this ISAACState has already been sent. | |||
// This is to prevent one node from retransmitting another result. |
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.
Big big 👍 for documenting what the function is for. It's much more important than what the function do (which one can understand from the code).
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.
LGTM
@spikeekips can i merge it? :) |
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.
@spikeekips can i merge it? :)
Sorry Too late :)
Github Issue
fixes #900
Solution
ps. As usual, please check each commits
@spikeekips Thanks for your awesome design idea :)