-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally require a deposit for registering a runtime
- Loading branch information
Showing
11 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Optionally require a deposit for registering a runtime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package state | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/oasislabs/oasis-core/go/consensus/tendermint/abci" | ||
stakingState "github.com/oasislabs/oasis-core/go/consensus/tendermint/apps/staking/state" | ||
registry "github.com/oasislabs/oasis-core/go/registry/api" | ||
staking "github.com/oasislabs/oasis-core/go/staking/api" | ||
) | ||
|
||
// EnsureSufficientRuntimeStake checks that the given entity has sufficient stake to operate a | ||
// given runtime (with separate thresholds for compute and key manager runtimes). | ||
func EnsureSufficientRuntimeStake(ctx *abci.Context, rt *registry.Runtime) error { | ||
thresholds := []staking.ThresholdKind{ | ||
staking.KindEntity, | ||
} | ||
switch rt.Kind { | ||
case registry.KindCompute: | ||
thresholds = append(thresholds, staking.KindRuntimeCompute) | ||
case registry.KindKeyManager: | ||
thresholds = append(thresholds, staking.KindRuntimeKeyManager) | ||
default: | ||
ctx.Logger().Error("RegisterRuntime: unknown runtime kind", | ||
"runtime_id", rt.ID, | ||
"kind", rt.Kind, | ||
) | ||
return fmt.Errorf("registry: unknown runtime kind (%d)", rt.Kind) | ||
} | ||
return stakingState.EnsureSufficientStake(ctx, rt.EntityID, thresholds) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,9 @@ | |
"0": "0", | ||
"1": "0", | ||
"2": "0", | ||
"3": "0" | ||
"3": "0", | ||
"4": "0", | ||
"5": "0" | ||
} | ||
} | ||
} |