adding rootkey to genesis
This commit is contained in:
parent
db92b99ec1
commit
a62edd05de
@ -207,7 +207,6 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
}
|
}
|
||||||
|
|
||||||
// var newAddress address.Address
|
// var newAddress address.Address
|
||||||
|
|
||||||
if (info.Type == genesis.TAccount) {
|
if (info.Type == genesis.TAccount) {
|
||||||
var ainfo genesis.AccountMeta
|
var ainfo genesis.AccountMeta
|
||||||
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
||||||
@ -230,31 +229,9 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
|
||||||
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
|
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
|
||||||
}
|
}
|
||||||
|
if err = createMultisig(ctx, bs, cst, state, ida, info.Balance, ainfo); err != nil {
|
||||||
pending, err := adt.MakeEmptyMap(adt.WrapStore(ctx, cst)).Root()
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("failed to create empty map: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
st, err := cst.Put(ctx, &multisig.State{
|
|
||||||
Signers: ainfo.Signers,
|
|
||||||
NumApprovalsThreshold: uint64(ainfo.Threshold),
|
|
||||||
StartEpoch: abi.ChainEpoch(ainfo.VestingStart),
|
|
||||||
UnlockDuration: abi.ChainEpoch(ainfo.VestingDuration),
|
|
||||||
PendingTxns: pending,
|
|
||||||
InitialBalance: info.Balance,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = state.SetActor(ida, &types.Actor{
|
|
||||||
Code: builtin.MultisigActorCodeID,
|
|
||||||
Balance: info.Balance,
|
|
||||||
Head: st,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("setting account from actmap: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -264,22 +241,40 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
vrst, err := cst.Put(ctx, &account.State{Address: RootVerifierAddr})
|
if err = createMultisig(ctx, bs, cst, state, vregroot, types.NewInt(0), template.VerifregRootKey); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = state.SetActor(vregroot, &types.Actor{
|
return state, nil
|
||||||
Code: builtin.AccountActorCodeID,
|
}
|
||||||
Balance: types.NewInt(0),
|
|
||||||
Head: vrst,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
func createMultisig(ctx context.Context, bs bstore.Blockstore, cst cbor.IpldStore, state *state.StateTree, ida address.Address, balance abi.TokenAmount, ainfo genesis.MultisigMeta) error {
|
||||||
|
|
||||||
|
pending, err := adt.MakeEmptyMap(adt.WrapStore(ctx, cst)).Root()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("setting account from actmap: %w", err)
|
return xerrors.Errorf("failed to create empty map: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return state, nil
|
st, err := cst.Put(ctx, &multisig.State{
|
||||||
|
Signers: ainfo.Signers,
|
||||||
|
NumApprovalsThreshold: uint64(ainfo.Threshold),
|
||||||
|
StartEpoch: abi.ChainEpoch(ainfo.VestingStart),
|
||||||
|
UnlockDuration: abi.ChainEpoch(ainfo.VestingDuration),
|
||||||
|
PendingTxns: pending,
|
||||||
|
InitialBalance: balance,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = state.SetActor(ida, &types.Actor{
|
||||||
|
Code: builtin.MultisigActorCodeID,
|
||||||
|
Balance: balance,
|
||||||
|
Head: st,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("setting account from actmap: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template) (cid.Cid, error) {
|
func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template) (cid.Cid, error) {
|
||||||
|
@ -78,4 +78,6 @@ type Template struct {
|
|||||||
|
|
||||||
NetworkName string
|
NetworkName string
|
||||||
Timestamp uint64 `json:",omitempty"`
|
Timestamp uint64 `json:",omitempty"`
|
||||||
|
|
||||||
|
VerifregRootKey MultisigMeta
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user