Skip to content

Commit

Permalink
Merge pull request #5394 from oasisprotocol/kostko/fix/storage-worker…
Browse files Browse the repository at this point in the history
…-nort

go/worker/storage: Disable storage worker when no runtimes configured
  • Loading branch information
kostko authored Oct 11, 2023
2 parents f83b69d + 61eedc8 commit 5c1b894
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .changelog/5394.bugfix.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/oasis-net-runner: Fix SkipPolicy flag in default fixture
1 change: 1 addition & 0 deletions .changelog/5394.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/worker/storage: Disable storage worker when no runtimes configured
2 changes: 1 addition & 1 deletion go/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (m NodeMode) IsClientOnly() bool {
// HasLocalStorage returns true iff the mode is one that has local storage.
func (m NodeMode) HasLocalStorage() bool {
switch m {
case ModeClient, ModeCompute:
case ModeClient, ModeCompute, ModeArchive:
return true
}
return false
Expand Down
7 changes: 7 additions & 0 deletions go/consensus/cometbft/apps/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"golang.org/x/crypto/sha3"

beacon "github.com/oasisprotocol/oasis-core/go/beacon/api"
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
"github.com/oasisprotocol/oasis-core/go/consensus/cometbft/api"
beaconState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/apps/beacon/state"
Expand Down Expand Up @@ -74,6 +75,12 @@ func (app *beaconApplication) ExecuteMessage(*api.Context, interface{}, interfac
}

func (app *beaconApplication) ExecuteTx(ctx *api.Context, tx *transaction.Transaction) error {
if app.backend == nil {
// Executing a transaction before BeginBlock -- likely during transaction simulation or
// checks. Fail the transaction, it may be retried.
return consensus.ErrNoCommittedBlocks
}

state := beaconState.NewMutableState(ctx.State())

params, err := state.ConsensusParameters(ctx)
Expand Down
2 changes: 1 addition & 1 deletion go/oasis-net-runner/fixtures/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func newDefaultFixture() (*oasis.NetworkFixture, error) {
Runtime: 0,
Entity: 1,
Policy: 0,
SkipPolicy: tee != node.TEEHardwareInvalid,
SkipPolicy: tee != node.TEEHardwareIntelSGX,
RuntimeProvisioner: runtimeProvisioner,
},
}
Expand Down
6 changes: 6 additions & 0 deletions go/oasis-test-runner/scenario/e2e/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ func (sc *nodeUpgradeImpl) Run(ctx context.Context, childEnv *env.Env) error { /
return err
}

// Wait for some blocks after the upgrade to make sure we don't query too fast.
_, err = sc.WaitBlocks(ctx, 2)
if err != nil {
return fmt.Errorf("failed to wait for blocks: %w", err)
}

// Run post-upgrade checker.
if err = sc.upgradeChecker.PostUpgradeFn(ctx, sc.Net.Controller()); err != nil {
return err
Expand Down
5 changes: 1 addition & 4 deletions go/worker/storage/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ func New(
commonWorker *workerCommon.Worker,
registration *registration.Worker,
) (*Worker, error) {
enabled := config.GlobalConfig.Mode.HasLocalStorage()
if config.GlobalConfig.Mode == config.ModeArchive && len(commonWorker.GetRuntimes()) > 0 {
enabled = true
}
enabled := config.GlobalConfig.Mode.HasLocalStorage() && len(commonWorker.GetRuntimes()) > 0

s := &Worker{
enabled: enabled,
Expand Down

0 comments on commit 5c1b894

Please sign in to comment.