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

remove TimeIotaMs from ABCI consensus params #3403

Merged
merged 7 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions consensus/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,12 @@ func (h *Handshaker) ReplayBlocks(
}

if res.ConsensusParams != nil {
// TimeIotaMs is not exposed to the application.
// Make sure we preserve it.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

timeIotaMs := state.ConsensusParams.Block.TimeIotaMs
state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams)
// TimeIotaMs is not a part of ABCI consensus params but
// of the actual state. Make sure it does not get overwritten.
{
state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like a better approach would be to build this into the PB2TM.ConsensusParams method. Then we know we'll never forget to do this

Copy link
Contributor

Choose a reason for hiding this comment

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

Openned #3432

}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the extra {}-brackets? The new scope doesn't introduce / separate anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2019-03-11 at 22 05 33

It separates reading from state.ConsensusParams and rewriting it with ABCI cs params

state.ConsensusParams.Block.TimeIotaMs = timeIotaMs
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not verify that this is the only place where we do not want ABCI params to potentially overwrite TimeIotaMs. Was this caught by a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, me executing

 rg "PB2TM.ConsensusParams"
consensus/replay.go
328:                            state.ConsensusParams = types.PB2TM.ConsensusParams(res.ConsensusParams)

types/protobuf_test.go
67:     cp2 := PB2TM.ConsensusParams(abciCP)

}
sm.SaveState(h.stateDB, state)
Expand Down
1 change: 1 addition & 0 deletions types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type BlockParams struct {
MaxBytes int64 `json:"max_bytes"`
MaxGas int64 `json:"max_gas"`
// Minimum time increment between consecutive blocks (in milliseconds)
// Not exposed to the application.
TimeIotaMs int64 `json:"time_iota_ms"`
}

Expand Down
2 changes: 1 addition & 1 deletion types/protobuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestABCIConsensusParams(t *testing.T) {
cp := DefaultConsensusParams()
abciCP := TM2PB.ConsensusParams(cp)
cp2 := PB2TM.ConsensusParams(abciCP)
// TimeIotaMs is not a part of ABCI consensus params
// TimeIotaMs is not exposed to the application.
cp2.Block.TimeIotaMs = cp.Block.TimeIotaMs

assert.Equal(t, *cp, cp2)
Expand Down