Skip to content

Commit

Permalink
e2e/runtime/storage-sync: stop using mock epochs
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Apr 22, 2022
1 parent ea656dc commit cb7a0f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ func (sc *storageEarlyStateSyncImpl) Fixture() (*oasis.NetworkFixture, error) {
},
},
}
// Avoid unexpected blocks.
f.Network.SetMockEpoch()
// Enable consensus layer checkpoints.
f.Network.Consensus.Parameters.StateCheckpointInterval = 10
f.Network.Consensus.Parameters.StateCheckpointNumKept = 2
Expand Down Expand Up @@ -97,19 +95,6 @@ func (sc *storageEarlyStateSyncImpl) Fixture() (*oasis.NetworkFixture, error) {
return f, nil
}

func (sc *storageEarlyStateSyncImpl) epochTransition(ctx context.Context) error {
sc.epoch++

sc.Logger.Info("triggering epoch transition",
"epoch", sc.epoch,
)
if err := sc.Net.Controller().SetEpoch(ctx, sc.epoch); err != nil {
return fmt.Errorf("failed to set epoch: %w", err)
}
sc.Logger.Info("epoch transition done")
return nil
}

func (sc *storageEarlyStateSyncImpl) Run(childEnv *env.Env) error { // nolint: gocyclo
if err := sc.Net.Start(); err != nil {
return err
Expand All @@ -128,11 +113,6 @@ func (sc *storageEarlyStateSyncImpl) Run(childEnv *env.Env) error { // nolint: g
}
}

// Perform an initial epoch transition.
if err := sc.epochTransition(ctx); err != nil {
return err
}

// Fetch current epoch.
epoch, err := sc.Net.Controller().Beacon.GetEpoch(ctx, consensus.HeightLatest)
if err != nil {
Expand All @@ -152,14 +132,12 @@ func (sc *storageEarlyStateSyncImpl) Run(childEnv *env.Env) error { // nolint: g
return fmt.Errorf("failed to register compute runtime: %w", err)
}

// Now that the runtime is registered, trigger some epoch transitions.
for i := 0; i < 3; i++ {
if err := sc.epochTransition(ctx); err != nil {
return err
}

// Wait a bit after epoch transitions.
time.Sleep(1 * time.Second)
// Wait some epoch transitions.
sc.Logger.Info("waiting for runtime deployment epoch",
"epoch", epoch+5,
)
if err := sc.Net.Controller().Beacon.WaitEpoch(ctx, epoch+5); err != nil {
return fmt.Errorf("failed to wait for epoch: %w", err)
}

// TODO: Make sure we have enough blocks.
Expand Down Expand Up @@ -213,6 +191,7 @@ func (sc *storageEarlyStateSyncImpl) Run(childEnv *env.Env) error { // nolint: g
if err := worker.Start(); err != nil {
return fmt.Errorf("can't start compute worker: %w", err)
}

readyCtx, cancel := context.WithTimeout(ctx, 120*time.Second)
defer cancel()
if err := worker.WaitReady(readyCtx); err != nil {
Expand Down
16 changes: 3 additions & 13 deletions go/oasis-test-runner/scenario/e2e/runtime/storage_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func (sc *storageSyncImpl) Fixture() (*oasis.NetworkFixture, error) {
return nil, err
}

// Use mock epochtime to ensure syncing starts in the same epoch in which
// new node registers.
f.Network.SetMockEpoch()

// Enable consensus layer checkpoints.
f.Network.Consensus.Parameters.StateCheckpointInterval = 10
f.Network.Consensus.Parameters.StateCheckpointNumKept = 2
Expand Down Expand Up @@ -84,17 +80,10 @@ func (sc *storageSyncImpl) Fixture() (*oasis.NetworkFixture, error) {
}

func (sc *storageSyncImpl) Run(childEnv *env.Env) error { //nolint: gocyclo
var err error
ctx := context.Background()
if err := sc.startNetworkAndTestClient(ctx, childEnv); err != nil {
return err
}

fixture, err := sc.Fixture()
if err != nil {
return err
}

if _, err = sc.initialEpochTransitions(fixture); err != nil {
if err = sc.startNetworkAndTestClient(ctx, childEnv); err != nil {
return err
}

Expand Down Expand Up @@ -256,6 +245,7 @@ func (sc *storageSyncImpl) Run(childEnv *env.Env) error { //nolint: gocyclo
if err = lateWorker.Start(); err != nil {
return fmt.Errorf("can't start second late compute worker: %w", err)
}

if err = lateWorker.WaitReady(ctx); err != nil {
return fmt.Errorf("error waiting for second late compute worker to become ready: %w", err)
}
Expand Down

0 comments on commit cb7a0f4

Please sign in to comment.