Skip to content

Commit

Permalink
go/keymanager: Move master and ephemeral secrets code to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
peternose committed Jan 30, 2024
1 parent 8225aca commit 8399f1a
Show file tree
Hide file tree
Showing 51 changed files with 2,013 additions and 1,734 deletions.
Empty file added .changelog/5544.trivial.md
Empty file.
26 changes: 5 additions & 21 deletions go/consensus/cometbft/apps/keymanager/genesis.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keymanager

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -10,9 +9,9 @@ import (

"github.com/oasisprotocol/oasis-core/go/common"
tmapi "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/api"
keymanagerState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/apps/keymanager/state"
secretsState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/apps/keymanager/secrets/state"
genesis "github.com/oasisprotocol/oasis-core/go/genesis/api"
keymanager "github.com/oasisprotocol/oasis-core/go/keymanager/api"
"github.com/oasisprotocol/oasis-core/go/keymanager/secrets"
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
)

Expand All @@ -24,7 +23,7 @@ func (app *keymanagerApplication) InitChain(ctx *tmapi.Context, _ types.RequestI
"state", string(b),
)

state := keymanagerState.NewMutableState(ctx.State())
state := secretsState.NewMutableState(ctx.State())

if err := state.SetConsensusParameters(ctx, &st.Parameters); err != nil {
return fmt.Errorf("cometbft/keymanager: failed to set consensus parameters: %w", err)
Expand Down Expand Up @@ -54,7 +53,7 @@ func (app *keymanagerApplication) InitChain(ctx *tmapi.Context, _ types.RequestI
}
}

var toEmit []*keymanager.Status
var toEmit []*secrets.Status
for i, v := range st.Statuses {
if v == nil {
return fmt.Errorf("InitChain: Status index %d is nil", i)
Expand Down Expand Up @@ -87,25 +86,10 @@ func (app *keymanagerApplication) InitChain(ctx *tmapi.Context, _ types.RequestI
}

if len(toEmit) > 0 {
ctx.EmitEvent(tmapi.NewEventBuilder(app.Name()).TypedAttribute(&keymanager.StatusUpdateEvent{
ctx.EmitEvent(tmapi.NewEventBuilder(app.Name()).TypedAttribute(&secrets.StatusUpdateEvent{
Statuses: toEmit,
}))
}

return nil
}

func (kq *keymanagerQuerier) Genesis(ctx context.Context) (*keymanager.Genesis, error) {
statuses, err := kq.state.Statuses(ctx)
if err != nil {
return nil, err
}

// Remove the Nodes field of each Status.
for _, status := range statuses {
status.Nodes = nil
}

gen := keymanager.Genesis{Statuses: statuses}
return &gen, nil
}
Loading

0 comments on commit 8399f1a

Please sign in to comment.