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/worker/storage: Disable storage worker when no runtimes configured #5394

Merged
merged 4 commits into from
Oct 11, 2023
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/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