forked from dymensionxyz/dymint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initchain.go
33 lines (27 loc) · 851 Bytes
/
initchain.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package block
import (
"context"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
tmtypes "github.com/tendermint/tendermint/types"
)
func (m *Manager) RunInitChain(ctx context.Context) error {
// get the proposer's consensus pubkey
proposer := m.SLClient.GetProposer()
tmPubKey, err := cryptocodec.ToTmPubKeyInterface(proposer.PublicKey)
if err != nil {
return err
}
gensisValSet := []*tmtypes.Validator{tmtypes.NewValidator(tmPubKey, 1)}
// call initChain with both addresses
res, err := m.Executor.InitChain(m.Genesis, gensisValSet)
if err != nil {
return err
}
// update the state with only the consensus pubkey
m.Executor.UpdateStateAfterInitChain(m.State, res, gensisValSet)
m.Executor.UpdateMempoolAfterInitChain(m.State)
if _, err := m.Store.SaveState(m.State, nil); err != nil {
return err
}
return nil
}