configurable remainder account

This commit is contained in:
whyrusleeping 2020-08-18 14:30:49 -07:00
parent 574a22de6c
commit abca69b476
3 changed files with 24 additions and 5 deletions

View File

@ -107,6 +107,17 @@ var DefaultVerifregRootkeyActor = genesis.Actor{
Meta: rootkeyMultisig.ActorMeta(), Meta: rootkeyMultisig.ActorMeta(),
} }
var remAccTestKey, _ = address.NewFromString("t1ceb34gnsc6qk5dt6n7xg6ycwzasjhbxm3iylkiy")
var remAccMeta = genesis.AccountMeta{
Owner: remAccTestKey,
}
var DefaultRemainderAccountActor = genesis.Actor{
Type: genesis.TAccount,
Balance: big.NewInt(0),
Meta: remAccMeta.ActorMeta(),
}
func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) { func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
@ -210,9 +221,10 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
*genm1, *genm1,
*genm2, *genm2,
}, },
VerifregRootKey: DefaultVerifregRootkeyActor, VerifregRootKey: DefaultVerifregRootkeyActor,
NetworkName: "", RemainderAccount: DefaultRemainderAccountActor,
Timestamp: uint64(build.Clock.Now().Add(-500 * time.Duration(build.BlockDelaySecs) * time.Second).Unix()), NetworkName: "",
Timestamp: uint64(build.Clock.Now().Add(-500 * time.Duration(build.BlockDelaySecs) * time.Second).Unix()),
} }
genb, err := genesis2.MakeGenesisBlock(context.TODO(), bs, sys, tpl) genb, err := genesis2.MakeGenesisBlock(context.TODO(), bs, sys, tpl)

View File

@ -3,6 +3,7 @@ package genesis
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
@ -287,6 +288,9 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
return nil, nil, err return nil, nil, err
} }
if err := createAccount(ctx, bs, cst, state, remAccKey, template.RemainderAccount); err != nil {
return nil, nil, err
}
err = state.SetActor(remAccKey, &types.Actor{ err = state.SetActor(remAccKey, &types.Actor{
Code: builtin.AccountActorCodeID, Code: builtin.AccountActorCodeID,
Balance: remainingFil, Balance: remainingFil,
@ -317,6 +321,7 @@ func createAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.IpldStore
if err != nil { if err != nil {
return xerrors.Errorf("setting account from actmap: %w", err) return xerrors.Errorf("setting account from actmap: %w", err)
} }
return nil
} else if info.Type == genesis.TMultisig { } else if info.Type == genesis.TMultisig {
var ainfo genesis.MultisigMeta var ainfo genesis.MultisigMeta
if err := json.Unmarshal(info.Meta, &ainfo); err != nil { if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
@ -346,9 +351,10 @@ func createAccount(ctx context.Context, bs bstore.Blockstore, cst cbor.IpldStore
if err != nil { if err != nil {
return xerrors.Errorf("setting account from actmap: %w", err) return xerrors.Errorf("setting account from actmap: %w", err)
} }
return nil
} }
return nil return fmt.Errorf("failed to create account")
} }
func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template, keyIDs map[address.Address]address.Address) (cid.Cid, error) { func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, stateroot cid.Cid, template genesis.Template, keyIDs map[address.Address]address.Address) (cid.Cid, error) {

View File

@ -79,5 +79,6 @@ type Template struct {
NetworkName string NetworkName string
Timestamp uint64 `json:",omitempty"` Timestamp uint64 `json:",omitempty"`
VerifregRootKey Actor VerifregRootKey Actor
RemainderAccount Actor
} }