-
Notifications
You must be signed in to change notification settings - Fork 267
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
feat: retrieves timeout propose and timeout commit dynamically per height according to the app version #1494
Changes from 81 commits
f231895
41a2cb0
1fc1edf
597f667
2397315
03fb213
a104580
30bc1c0
7b3618b
fa27abe
6e2fb78
a7d1e1b
0904cd5
0271370
47329db
8ef6666
6a92b18
782efa1
26dfedf
020efac
490189c
852d07f
f1568a6
00d8e1c
3b6cbb3
98feed8
9ecf2d1
063fafd
bbfbd59
77e31ca
b8b7b5a
d48a120
6d53ec3
4d79406
eddd24b
647cd29
ca5cbf6
bf59cd5
585d682
bd49c4c
2c24116
61ea40b
5dca0dc
bebd8d5
4831733
cfdd2c3
e3ae19c
1e08820
f8eaf2d
eff0bb2
9865ebe
6f88a30
3f8320f
d6ecfd4
d8815a3
377751e
598e9be
a34d103
f06eae6
3347fe7
fbe4f62
86bd130
8fe698f
5785b37
f7cda78
66f3f21
0ebf51c
ee9bda2
9f11257
aabf2c6
5e7abef
98e3e13
fc2fc76
30a663f
d7e21f4
d872374
1776442
6211697
122058b
f74d19b
0fd7f5e
10be8b1
363058a
85e92f3
5d399b5
081ecce
f12da04
12639d4
e772715
1ef98d0
23e3fb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -674,9 +674,28 @@ func (cs *State) updateToState(state sm.State) { | |||||||||||||||||||||||||||||
// to be gathered for the first block. | ||||||||||||||||||||||||||||||
// And alternative solution that relies on clocks: | ||||||||||||||||||||||||||||||
// cs.StartTime = state.LastBlockTime.Add(timeoutCommit) | ||||||||||||||||||||||||||||||
cs.StartTime = cs.config.Commit(cmttime.Now()) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
if state.LastBlockHeight == 0 { | ||||||||||||||||||||||||||||||
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. Isn't 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. This was just to be extra sure, didn't see any harm to add an extra check here. If you think it is excessive, I can remove it. 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. If you want to keep this can you compact this into a simpler |
||||||||||||||||||||||||||||||
// state represents the genesis state, hence the StartTime should be set based on the state's TimeoutCommit | ||||||||||||||||||||||||||||||
// we don't use cs.state.TimeoutCommit because that is zero | ||||||||||||||||||||||||||||||
cs.StartTime = cs.config.CommitWithCustomTimeout(cmttime.Now(), state.TimeoutCommit) | ||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
// if state does not represent the genesis state, | ||||||||||||||||||||||||||||||
// we use the cs.state.TimeoutCommit | ||||||||||||||||||||||||||||||
cs.StartTime = cs.config.CommitWithCustomTimeout(cmttime.Now(), cs.state.TimeoutCommit) | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
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. [nit] instead of code comments that distract from the functionality, we can move the comments into code. For example
Suggested change
with the addition of
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. This comment wasn't addressed. |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
cs.StartTime = cs.config.Commit(cs.CommitTime) | ||||||||||||||||||||||||||||||
if state.LastBlockHeight == 0 { | ||||||||||||||||||||||||||||||
// state represents the genesis state, hence the StartTime should be set based on the state's TimeoutCommit | ||||||||||||||||||||||||||||||
// we don't use cs.state.TimeoutCommit because that is zero | ||||||||||||||||||||||||||||||
cs.StartTime = cs.config.CommitWithCustomTimeout(cs.CommitTime, state.TimeoutCommit) | ||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||
// if state does not represent the genesis state, | ||||||||||||||||||||||||||||||
// we use the cs.state.TimeoutCommit | ||||||||||||||||||||||||||||||
cs.StartTime = cs.config.CommitWithCustomTimeout(cs.CommitTime, cs.state.TimeoutCommit) | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
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. [nit] same potential refactor as above |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
cs.Validators = validators | ||||||||||||||||||||||||||||||
|
@@ -1113,7 +1132,7 @@ func (cs *State) enterPropose(height int64, round int32) { | |||||||||||||||||||||||||||||
}() | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// If we don't get the proposal and all block parts quick enough, enterPrevote | ||||||||||||||||||||||||||||||
cs.scheduleTimeout(cs.config.Propose(round), height, round, cstypes.RoundStepPropose) | ||||||||||||||||||||||||||||||
cs.scheduleTimeout(cs.config.ProposeWithCustomTimeout(round, cs.state.TimeoutPropose), height, round, cstypes.RoundStepPropose) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// Nothing more to do if we're not a validator | ||||||||||||||||||||||||||||||
if cs.privValidator == nil { | ||||||||||||||||||||||||||||||
|
@@ -1682,7 +1701,7 @@ func (cs *State) finalizeCommit(height int64) { | |||||||||||||||||||||||||||||
// exists. | ||||||||||||||||||||||||||||||
// | ||||||||||||||||||||||||||||||
// Either way, the State should not be resumed until we | ||||||||||||||||||||||||||||||
// successfully call ApplyBlock (ie. later here, or in Handshake after | ||||||||||||||||||||||||||||||
// successfully call ApplyBlock (i.e., later here, or in Handshake after | ||||||||||||||||||||||||||||||
// restart). | ||||||||||||||||||||||||||||||
endMsg := EndHeightMessage{height} | ||||||||||||||||||||||||||||||
if err := cs.wal.WriteSync(endMsg); err != nil { // NOTE: fsync | ||||||||||||||||||||||||||||||
|
@@ -1698,7 +1717,7 @@ func (cs *State) finalizeCommit(height int64) { | |||||||||||||||||||||||||||||
stateCopy := cs.state.Copy() | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// Execute and commit the block, update and save the state, and update the mempool. | ||||||||||||||||||||||||||||||
// NOTE The block.AppHash wont reflect these txs until the next block. | ||||||||||||||||||||||||||||||
// NOTE The block.AppHash won't reflect these txs until the next block. | ||||||||||||||||||||||||||||||
var ( | ||||||||||||||||||||||||||||||
err error | ||||||||||||||||||||||||||||||
retainHeight int64 | ||||||||||||||||||||||||||||||
|
@@ -1741,7 +1760,7 @@ func (cs *State) finalizeCommit(height int64) { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
fail.Fail() // XXX | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// Private validator might have changed it's key pair => refetch pubkey. | ||||||||||||||||||||||||||||||
// Private validator might have changed its key pair => refetch pubkey. | ||||||||||||||||||||||||||||||
if err := cs.updatePrivValidatorPubKey(); err != nil { | ||||||||||||||||||||||||||||||
logger.Error("failed to get private validator pubkey", "err", err) | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
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.
[nit] the comment wrapping here is weird. If you use VScode, you can use rewrap to format this better.
https://marketplace.visualstudio.com/items?itemName=stkb.rewrap
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.
ahh shoot missed this one
I agree with these comment wrappers, which it was part of the linting rules