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

go/consensus/tendermint: Fix early GetStatus with initial height > 1 #3503

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/3481.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/consensus/tendermint: Fix early GetStatus with initial height > 1
6 changes: 5 additions & 1 deletion go/consensus/tendermint/full/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,11 @@ func (t *fullService) GetStatus(ctx context.Context) (*consensusAPI.Status, erro
status.NodePeers = peers

// Check if the local node is in the validator set for the latest (uncommitted) block.
vals, err := t.stateStore.LoadValidators(status.LatestHeight + 1)
valSetHeight := status.LatestHeight + 1
if valSetHeight < status.GenesisHeight {
valSetHeight = status.GenesisHeight
}
vals, err := t.stateStore.LoadValidators(valSetHeight)
if err != nil {
return nil, fmt.Errorf("failed to load validator set: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions go/oasis-test-runner/scenario/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ func RegisterScenarios() error {
Debond,
// Early query test.
EarlyQuery,
EarlyQueryInitHeight,
// Consensus state sync.
ConsensusStateSync,
// Multiple seeds test.
Expand Down
26 changes: 20 additions & 6 deletions go/oasis-test-runner/scenario/e2e/early_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,30 @@ import (
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/scenario"
)

// EarlyQuery is the early query scenario where we query a validator node before the network
// has started and there are no committed blocks.
var EarlyQuery scenario.Scenario = &earlyQueryImpl{
E2E: *NewE2E("early-query"),
}
var (
// EarlyQuery is the early query scenario where we query a validator node before the network
// has started and there are no committed blocks.
EarlyQuery scenario.Scenario = &earlyQueryImpl{
E2E: *NewE2E("early-query"),
}

// EarlyQueryInitHeight is the same as EarlyQuery scenario but with an initial height set.
EarlyQueryInitHeight scenario.Scenario = &earlyQueryImpl{
E2E: *NewE2E("early-query/init-height"),
initialHeight: 42,
}
)

type earlyQueryImpl struct {
E2E

initialHeight int64
}

func (sc *earlyQueryImpl) Clone() scenario.Scenario {
return &earlyQueryImpl{
E2E: sc.E2E.Clone(),
E2E: sc.E2E.Clone(),
initialHeight: sc.initialHeight,
}
}

Expand All @@ -34,6 +45,9 @@ func (sc *earlyQueryImpl) Fixture() (*oasis.NetworkFixture, error) {
return nil, err
}

// Set initial height.
f.Network.InitialHeight = sc.initialHeight

// Only one validator should actually start to prevent the network from committing any blocks.
f.Validators[1].NoAutoStart = true
f.Validators[2].NoAutoStart = true
Expand Down