Skip to content

Commit

Permalink
update genesis service
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed Sep 16, 2024
1 parent 8d1014e commit 9fe1020
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions runtime/v2/services/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ type genesisContextKeyType struct{}
var genesisContextKey = genesisContextKeyType{}

type genesisContext struct {
state store.WriterMap
didRun bool
state store.WriterMap
}

func NewGenesisContext(state store.WriterMap) genesisContext {
Expand All @@ -34,7 +33,6 @@ func (g *genesisContext) Run(
if err != nil {
return nil, err
}
g.didRun = true
return g.state, nil
}

Expand Down Expand Up @@ -63,9 +61,6 @@ func (g *GenesisKVStoreServie) OpenKVStore(ctx context.Context) store.KVStore {
if !ok {
panic(fmt.Errorf("unexpected genesis context type: %T", v))

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
if genCtx.didRun {
return g.executionService.OpenKVStore(ctx)
}
state, err := genCtx.state.GetWriter(g.actor)
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
Expand All @@ -83,13 +78,6 @@ func (g *GenesisHeaderService) HeaderInfo(ctx context.Context) header.Info {
if v == nil {
return g.executionService.HeaderInfo(ctx)
}
genCtx, ok := v.(*genesisContext)
if !ok {
panic(fmt.Errorf("unexpected genesis context type: %T", v))
}
if genCtx.didRun {
return g.executionService.HeaderInfo(ctx)
}
return header.Info{}
}

Expand Down

0 comments on commit 9fe1020

Please sign in to comment.