Skip to content

Commit

Permalink
Merge pull request #3503 from oasisprotocol/kostko/fix/consensus-stat…
Browse files Browse the repository at this point in the history
…us-valset-height

go/consensus/tendermint: Fix early GetStatus with initial height > 1
  • Loading branch information
kostko authored Nov 11, 2020
2 parents f224082 + 98d314d commit 8b23353
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
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

0 comments on commit 8b23353

Please sign in to comment.