Skip to content
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
Empty file added .changelog/6512.trivial.md
Empty file.
3 changes: 2 additions & 1 deletion go/consensus/cometbft/apps/keymanager/common/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ func RegistryRuntimes(ctx *tmapi.Context, doc *genesis.Document, epoch beacon.Ep
regSt := doc.Registry
rtMap := make(map[common.Namespace]*registry.Runtime)
for _, rt := range regSt.Runtimes {
err := registry.VerifyRuntime(&regSt.Parameters, ctx.Logger(), rt, true, false, epoch, true)
verifyOpts := registry.VerifyRuntimeOptions{IsGenesis: true, IsFeatureVersion242: true}
err := registry.VerifyRuntime(&regSt.Parameters, ctx.Logger(), rt, epoch, verifyOpts)
if err != nil {
ctx.Logger().Error("InitChain: Invalid runtime",
"err", err,
Expand Down
3 changes: 2 additions & 1 deletion go/consensus/cometbft/apps/registry/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func (app *Application) InitChain(ctx *abciAPI.Context, _ types.RequestInitChain
if rt == nil {
return fmt.Errorf("registry: genesis runtime index %d is nil", i)
}
err := registry.VerifyRuntime(&st.Parameters, ctx.Logger(), rt, ctx.IsInitChain(), false, epoch, true)
verifyOpts := registry.VerifyRuntimeOptions{IsGenesis: ctx.IsInitChain(), IsFeatureVersion242: true}
err := registry.VerifyRuntime(&st.Parameters, ctx.Logger(), rt, epoch, verifyOpts)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion go/consensus/cometbft/apps/registry/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ func (app *Application) registerRuntime( // nolint: gocyclo
}
}

if err = registry.VerifyRuntime(params, ctx.Logger(), rt, ctx.IsInitChain(), false, epoch, isFeatureVersion242); err != nil {
verifyOpts := registry.VerifyRuntimeOptions{IsGenesis: ctx.IsInitChain(), IsFeatureVersion242: isFeatureVersion242}
if err = registry.VerifyRuntime(params, ctx.Logger(), rt, epoch, verifyOpts); err != nil {
return nil, err
}

Expand Down
22 changes: 15 additions & 7 deletions go/registry/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,21 +1101,29 @@ func VerifyNodeUpdate(
return nil
}

// VerifyRuntimeOptions contains the options for VerifyRuntime.
type VerifyRuntimeOptions struct {
// IsGenesis is true if the runtime is being verified during genesis.
IsGenesis bool
// IsSanityCheck is true if this is a sanity check and not a live transaction verification.
IsSanityCheck bool
// IsFeatureVersion242 is true if consensus version 24.2 or higher is active.
IsFeatureVersion242 bool
}

// VerifyRuntime verifies the given runtime.
func VerifyRuntime( // nolint: gocyclo
func VerifyRuntime(
params *ConsensusParameters,
logger *logging.Logger,
rt *Runtime,
isGenesis bool,
isSanityCheck bool,
now beacon.EpochTime,
isFeatureVersion242 bool,
opts VerifyRuntimeOptions,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: technically an API change, but don't think this was ever meant as an API/there are downstream users of this function...

) error {
if rt == nil {
return fmt.Errorf("%w: no runtime given", ErrInvalidArgument)
}

if err := rt.ValidateBasic(!isGenesis && !isSanityCheck); err != nil {
if err := rt.ValidateBasic(!opts.IsGenesis && !opts.IsSanityCheck); err != nil {
logger.Error("RegisterRuntime: invalid runtime descriptor",
"runtime", rt,
"err", err,
Expand All @@ -1130,7 +1138,7 @@ func VerifyRuntime( // nolint: gocyclo
return fmt.Errorf("%w: test runtime not allowed", ErrInvalidArgument)
}

if err := rt.Genesis.SanityCheck(isGenesis); err != nil {
if err := rt.Genesis.SanityCheck(opts.IsGenesis); err != nil {
return err
}

Expand All @@ -1154,7 +1162,7 @@ func VerifyRuntime( // nolint: gocyclo

// Validate the deployments. This also handles validating that the
// appropriate TEE configuration is present in each deployment.
if err := rt.ValidateDeployments(now, params, isFeatureVersion242); err != nil {
if err := rt.ValidateDeployments(now, params, opts.IsFeatureVersion242); err != nil {
logger.Error("RegisterRuntime: invalid deployments",
"runtime_id", rt.ID,
"err", err,
Expand Down
Loading
Loading