Skip to content

Commit

Permalink
go/oasis-test-runner: Fix e2e/consensus-state-sync scenario
Browse files Browse the repository at this point in the history
Instead of terminating the validator-to-be-synced immediately and restarting
it later, do not even start it. Early stopping could result in state that
prevents proper state sync later.
  • Loading branch information
kostko committed Aug 18, 2020
1 parent 63ea1a9 commit 73ee743
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changelog/3194.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/oasis-test-runner: Fix e2e/consensus-state-sync scenario

Instead of terminating the validator-to-be-synced immediately and restarting
it later, do not even start it. Early stopping could result in state that
prevents proper state sync later.
15 changes: 5 additions & 10 deletions go/oasis-test-runner/scenario/e2e/consensus_state_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (sc *consensusStateSyncImpl) Fixture() (*oasis.NetworkFixture, error) {
f.Network.Consensus.Parameters.StateCheckpointChunkSize = 1024 * 1024
// Add an extra validator.
f.Validators = append(f.Validators,
oasis.ValidatorFixture{Entity: 1, Consensus: oasis.ConsensusFixture{EnableConsensusRPCWorker: true}},
oasis.ValidatorFixture{NoAutoStart: true, Entity: 1, Consensus: oasis.ConsensusFixture{EnableConsensusRPCWorker: true}},
)

return f, nil
Expand All @@ -53,16 +53,10 @@ func (sc *consensusStateSyncImpl) Run(childEnv *env.Env) error {

sc.Logger.Info("waiting for network to come up")
ctx := context.Background()
if err := sc.Net.Controller().WaitNodesRegistered(ctx, len(sc.Net.Validators())); err != nil {
if err := sc.Net.Controller().WaitNodesRegistered(ctx, len(sc.Net.Validators())-1); err != nil {
return err
}

// Stop one of the validators.
val := sc.Net.Validators()[2]
if err := val.Stop(); err != nil {
return fmt.Errorf("failed to stop validator: %w", err)
}

// Let the network run for 50 blocks. This should generate some checkpoints.
blockCh, blockSub, err := sc.Net.Controller().Consensus.WatchBlocks(ctx)
if err != nil {
Expand All @@ -85,7 +79,7 @@ func (sc *consensusStateSyncImpl) Run(childEnv *env.Env) error {
break
}

sc.Logger.Info("got some blocks, starting the validator back",
sc.Logger.Info("got some blocks, starting the validator that needs to sync",
"trust_height", blk.Height,
"trust_hash", hex.EncodeToString(blk.Hash),
)
Expand Down Expand Up @@ -122,14 +116,15 @@ func (sc *consensusStateSyncImpl) Run(childEnv *env.Env) error {
}

// Configure state sync for the consensus validator.
val := sc.Net.Validators()[2]
val.SetConsensusStateSync(&oasis.ConsensusStateSyncCfg{
ConsensusNodes: consensusNodes,
TrustHeight: uint64(blk.Height),
TrustHash: hex.EncodeToString(blk.Hash),
})

if err = val.Start(); err != nil {
return fmt.Errorf("failed to start validator back: %w", err)
return fmt.Errorf("failed to start validator: %w", err)
}

// Wait for the validator to finish syncing.
Expand Down

0 comments on commit 73ee743

Please sign in to comment.