Genesis miner config actually sets the created miner address now
This commit is contained in:
parent
703bc7e774
commit
3b533ed76c
@ -42,7 +42,7 @@ func TestDealFlow(t *testing.T, b APIBuilder) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
maddr, err := address.NewFromString("t0101")
|
||||
maddr, err := address.NewFromString("t0102")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ func GetParams(storage bool, tests bool) error {
|
||||
ft := &fetch{}
|
||||
|
||||
for name, info := range params {
|
||||
if info.SectorSize != 1024 {
|
||||
continue
|
||||
}
|
||||
if !(SupportedSectorSize(info.SectorSize) || (tests && info.SectorSize == 1<<10)) {
|
||||
continue
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ func init() {
|
||||
type InitActor struct{}
|
||||
|
||||
type InitActorState struct {
|
||||
// TODO: this needs to be a HAMT, its a dumb map for now
|
||||
AddressMap cid.Cid
|
||||
|
||||
NextID uint64
|
||||
|
@ -389,3 +389,11 @@ func (a *Address) UnmarshalCBOR(br io.Reader) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func IDFromAddress(addr Address) (uint64, error) {
|
||||
if addr.Protocol() != ID {
|
||||
return 0, xerrors.Errorf("cannot get id from non id address")
|
||||
}
|
||||
|
||||
return leb128.ToUInt64(addr.Payload()), nil
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func NewGenerator() (*ChainGen, error) {
|
||||
|
||||
// TODO: this is really weird, we have to guess the miner addresses that
|
||||
// will be created in order to preseal data for them
|
||||
maddr1, err := address.NewFromString("t0103")
|
||||
maddr1, err := address.NewFromString("t0300")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -142,7 +142,7 @@ func NewGenerator() (*ChainGen, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
maddr2, err := address.NewFromString("t0104")
|
||||
maddr2, err := address.NewFromString("t0301")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -256,6 +256,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
|
||||
return nil, nil, xerrors.Errorf("get miner worker: %w", err)
|
||||
}
|
||||
|
||||
log.Warnf("compute VRF ROUND: %d %s %s", round, m, worker)
|
||||
vrfout, err := ComputeVRF(ctx, cg.w.Sign, worker, m, DSepTicket, lastTicket.VRFProof)
|
||||
if err != nil {
|
||||
return nil, nil, xerrors.Errorf("compute VRF: %w", err)
|
||||
@ -307,6 +308,7 @@ func (cg *ChainGen) NextTipSetFromMiners(base *types.TipSet, miners []address.Ad
|
||||
}
|
||||
|
||||
if proof != nil {
|
||||
log.Warn("making block, ticket: ", t.VRFProof)
|
||||
fblk, err := cg.makeBlock(base, m, proof, t, uint64(round), msgs)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("making a block for next tipset failed: %w", err)
|
||||
@ -612,6 +614,7 @@ func ComputeVRF(ctx context.Context, sign SignFunc, worker, miner address.Addres
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Warnf("making ticket: %x %s %s %x %x", sig.Data, worker, miner, input, sigInput)
|
||||
|
||||
if sig.Type != types.KTBLS {
|
||||
return nil, fmt.Errorf("miner worker address was not a BLS key")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package gen
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
@ -8,6 +9,7 @@ import (
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
hamt "github.com/ipfs/go-hamt-ipld"
|
||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
bstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
peer "github.com/libp2p/go-libp2p-peer"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
@ -281,11 +283,21 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
||||
return cid.Undef, nil, xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||
}
|
||||
|
||||
maddr, err := address.NewFromBytes(rval)
|
||||
maddrret, err := address.NewFromBytes(rval)
|
||||
if err != nil {
|
||||
return cid.Undef, nil, err
|
||||
}
|
||||
|
||||
_, err = vm.Flush(ctx)
|
||||
if err != nil {
|
||||
return cid.Undef, nil, err
|
||||
}
|
||||
|
||||
cst := hamt.CSTFromBstore(cs.Blockstore())
|
||||
if err := reassignMinerActorAddress(vm, cst, maddrret, maddr); err != nil {
|
||||
return cid.Undef, nil, err
|
||||
}
|
||||
|
||||
power := types.BigMul(types.NewInt(minerParams.SectorSize), types.NewInt(uint64(len(ps.Sectors))))
|
||||
|
||||
params = mustEnc(&actors.UpdateStorageParams{Delta: power})
|
||||
@ -306,7 +318,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
||||
return cid.Undef, nil, xerrors.Errorf("get miner actor failed: %w", err)
|
||||
}
|
||||
|
||||
cst := hamt.CSTFromBstore(cs.Blockstore())
|
||||
var mstate actors.StorageMinerActorState
|
||||
if err := cst.Get(ctx, mact.Head, &mstate); err != nil {
|
||||
return cid.Undef, nil, xerrors.Errorf("getting miner actor state failed: %w", err)
|
||||
@ -341,6 +352,149 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
||||
return c, deals, err
|
||||
}
|
||||
|
||||
func reassignMinerActorAddress(vm *vm.VM, cst *hamt.CborIpldStore, from, to address.Address) error {
|
||||
if from == to {
|
||||
return nil
|
||||
}
|
||||
act, err := vm.StateTree().GetActor(from)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("reassign: failed to get 'from' actor: %w", err)
|
||||
}
|
||||
|
||||
_, err = vm.StateTree().GetActor(to)
|
||||
if err == nil {
|
||||
return xerrors.Errorf("cannot reassign actor, target address taken")
|
||||
}
|
||||
if err := vm.StateTree().SetActor(to, act); err != nil {
|
||||
return xerrors.Errorf("failed to reassign actor: %w", err)
|
||||
}
|
||||
|
||||
if err := adjustStorageMarketTracking(vm, cst, from, to); err != nil {
|
||||
return xerrors.Errorf("adjusting storage market tracking: %w", err)
|
||||
}
|
||||
|
||||
// Now, adjust the tracking in the init actor
|
||||
return initActorReassign(vm, cst, from, to)
|
||||
}
|
||||
|
||||
func adjustStorageMarketTracking(vm *vm.VM, cst *hamt.CborIpldStore, from, to address.Address) error {
|
||||
ctx := context.TODO()
|
||||
act, err := vm.StateTree().GetActor(actors.StoragePowerAddress)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("loading storage power actor: %w", err)
|
||||
}
|
||||
|
||||
var spst actors.StoragePowerState
|
||||
if err := cst.Get(ctx, act.Head, &spst); err != nil {
|
||||
return xerrors.Errorf("loading storage power actor state: %w", err)
|
||||
}
|
||||
|
||||
miners, err := hamt.LoadNode(ctx, cst, spst.Miners)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("loading miner set: %w", err)
|
||||
}
|
||||
|
||||
if err := miners.Delete(ctx, string(from.Bytes())); err != nil {
|
||||
return xerrors.Errorf("deleting from spa set: %w", err)
|
||||
}
|
||||
|
||||
if err := miners.Set(ctx, string(to.Bytes()), uint64(1)); err != nil {
|
||||
return xerrors.Errorf("failed setting miner: %w", err)
|
||||
}
|
||||
|
||||
if err := miners.Flush(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nminerscid, err := cst.Put(ctx, miners)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
spst.Miners = nminerscid
|
||||
|
||||
nhead, err := cst.Put(ctx, &spst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
act.Head = nhead
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initActorReassign(vm *vm.VM, cst *hamt.CborIpldStore, from, to address.Address) error {
|
||||
ctx := context.TODO()
|
||||
initact, err := vm.StateTree().GetActor(actors.InitAddress)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("couldnt get init actor: %w", err)
|
||||
}
|
||||
|
||||
var st actors.InitActorState
|
||||
if err := cst.Get(ctx, initact.Head, &st); err != nil {
|
||||
return xerrors.Errorf("reassign loading init actor state: %w", err)
|
||||
}
|
||||
|
||||
amap, err := hamt.LoadNode(ctx, cst, st.AddressMap)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to load init actor map: %w", err)
|
||||
}
|
||||
|
||||
target, err := address.IDFromAddress(from)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to extract ID: %w", err)
|
||||
}
|
||||
|
||||
var out string
|
||||
halt := xerrors.Errorf("halt")
|
||||
err = amap.ForEach(ctx, func(k string, v interface{}) error {
|
||||
_, val, err := cbg.CborReadHeader(bytes.NewReader(v.(*cbg.Deferred).Raw))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("parsing int in map failed: %w", err)
|
||||
}
|
||||
|
||||
if val == target {
|
||||
out = k
|
||||
return halt
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
return xerrors.Errorf("could not find from address in init ID map")
|
||||
}
|
||||
if !xerrors.Is(err, halt) {
|
||||
return xerrors.Errorf("finding address in ID map failed: %w", err)
|
||||
}
|
||||
|
||||
if err := amap.Delete(ctx, out); err != nil {
|
||||
return xerrors.Errorf("deleting 'from' entry in amap: %w", err)
|
||||
}
|
||||
|
||||
if err := amap.Set(ctx, out, target); err != nil {
|
||||
return xerrors.Errorf("setting 'to' entry in amap: %w", err)
|
||||
}
|
||||
|
||||
if err := amap.Flush(ctx); err != nil {
|
||||
return xerrors.Errorf("failed to flush amap: %w", err)
|
||||
}
|
||||
|
||||
ncid, err := cst.Put(ctx, amap)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
st.AddressMap = ncid
|
||||
|
||||
nacthead, err := cst.Put(ctx, &st)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
initact.Head = nacthead
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func doExec(ctx context.Context, vm *vm.VM, to, from address.Address, method uint64, params []byte) ([]byte, error) {
|
||||
return doExecValue(ctx, vm, to, from, types.NewInt(0), method, params)
|
||||
}
|
||||
@ -397,6 +551,11 @@ func MakeGenesisBlock(bs bstore.Blockstore, balances map[address.Address]types.B
|
||||
return nil, xerrors.Errorf("setup storage market actor: %w", err)
|
||||
}
|
||||
|
||||
stateroot, err = AdjustInitActorStartID(ctx, bs, stateroot, 1000)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to adjust init actor start ID: %w", err)
|
||||
}
|
||||
|
||||
blks := amt.WrapBlockstore(bs)
|
||||
|
||||
emptyroot, err := amt.FromArray(blks, nil)
|
||||
@ -453,3 +612,37 @@ func MakeGenesisBlock(bs bstore.Blockstore, balances map[address.Address]types.B
|
||||
Genesis: b,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func AdjustInitActorStartID(ctx context.Context, bs blockstore.Blockstore, stateroot cid.Cid, val uint64) (cid.Cid, error) {
|
||||
cst := hamt.CSTFromBstore(bs)
|
||||
|
||||
tree, err := state.LoadStateTree(cst, stateroot)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
||||
act, err := tree.GetActor(actors.InitAddress)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
||||
var st actors.InitActorState
|
||||
if err := cst.Get(ctx, act.Head, &st); err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
||||
st.NextID = val
|
||||
|
||||
nstate, err := cst.Put(ctx, &st)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
||||
act.Head = nstate
|
||||
|
||||
if err := tree.SetActor(actors.InitAddress, act); err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
|
||||
return tree.Flush()
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package stmgr
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@ -153,7 +154,7 @@ func GetMinerElectionPeriodStart(ctx context.Context, sm *StateManager, ts *type
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
return 0, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
return 0, xerrors.Errorf("(get eps) failed to load miner actor state: %w", err)
|
||||
}
|
||||
|
||||
return mas.ElectionPeriodStart, nil
|
||||
@ -163,7 +164,7 @@ func GetMinerProvingSet(ctx context.Context, sm *StateManager, ts *types.TipSet,
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
return nil, xerrors.Errorf("(get pset) failed to load miner actor state: %w", err)
|
||||
}
|
||||
|
||||
return LoadSectorsFromSet(ctx, sm.ChainStore().Blockstore(), mas.ProvingSet)
|
||||
@ -173,7 +174,7 @@ func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet,
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
||||
}
|
||||
|
||||
return LoadSectorsFromSet(ctx, sm.ChainStore().Blockstore(), mas.Sectors)
|
||||
@ -203,7 +204,7 @@ func GetMinerSectorSize(ctx context.Context, sm *StateManager, ts *types.TipSet,
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
return 0, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
return 0, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
|
||||
}
|
||||
|
||||
cst := hamt.CSTFromBstore(sm.cs.Blockstore())
|
||||
@ -219,7 +220,7 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
return 0, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||
return 0, xerrors.Errorf("(get mslash) failed to load miner actor state: %w", err)
|
||||
}
|
||||
|
||||
return mas.SlashedAt, nil
|
||||
|
@ -615,11 +615,12 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
||||
})
|
||||
|
||||
tktsCheck := async.Err(func() error {
|
||||
vrfBase := gen.TicketHash(baseTs.MinTicket(), h.Miner)
|
||||
vrfBase := baseTs.MinTicket().VRFProof
|
||||
|
||||
err := gen.VerifyVRF(ctx, waddr, h.Miner, gen.DSepTicket, vrfBase, h.Ticket.VRFProof)
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("BAD TICKET: %d %x %x %s %s %x", h.Height, h.Ticket.VRFProof, vrfBase, waddr, h.Miner, baseTs.MinTicket().VRFProof)
|
||||
return xerrors.Errorf("validating block tickets failed: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
@ -346,7 +346,7 @@ func (tu *syncTestUtil) waitUntilSyncTarget(to int, target *types.TipSet) {
|
||||
}
|
||||
|
||||
func TestSyncSimple(t *testing.T) {
|
||||
H := 50
|
||||
H := 2
|
||||
tu := prepSyncTest(t, H)
|
||||
|
||||
client := tu.addClientNode()
|
||||
|
@ -42,9 +42,13 @@ func newInvoker() *invoker {
|
||||
|
||||
func (inv *invoker) Invoke(act *types.Actor, vmctx types.VMContext, method uint64, params []byte) ([]byte, aerrors.ActorError) {
|
||||
|
||||
if act.Code == actors.AccountCodeCid {
|
||||
return nil, aerrors.Newf(254, "cannot invoke methods on account actors")
|
||||
}
|
||||
|
||||
code, ok := inv.builtInCode[act.Code]
|
||||
if !ok {
|
||||
log.Errorf("no code for actor %s", act.Code)
|
||||
log.Errorf("no code for actor %s (Addr: %s)", act.Code, vmctx.Message().To)
|
||||
return nil, aerrors.Newf(255, "no code for actor %s(%d)(%s)", act.Code, method, hex.EncodeToString(params))
|
||||
}
|
||||
if method >= uint64(len(code)) || code[method] == nil {
|
||||
|
@ -252,7 +252,7 @@ func (st *storage) storeMiners(miners map[minerKey]*minerInfo) error {
|
||||
i.info.SectorSize,
|
||||
i.state.Power.String(),
|
||||
i.state.Active,
|
||||
i.state.ProvingPeriodEnd,
|
||||
i.state.ElectionPeriodStart,
|
||||
i.state.SlashedAt,
|
||||
); err != nil {
|
||||
return err
|
||||
|
@ -320,7 +320,7 @@ func (m *Miner) getMinerWorker(ctx context.Context, addr address.Address, ts *ty
|
||||
|
||||
func (m *Miner) computeTicket(ctx context.Context, addr address.Address, base *MiningBase) (*types.Ticket, error) {
|
||||
|
||||
vrfBase := gen.TicketHash(base.ts.MinTicket(), addr)
|
||||
vrfBase := base.ts.MinTicket().VRFProof
|
||||
|
||||
vrfOut, err := m.computeVRF(ctx, addr, vrfBase)
|
||||
if err != nil {
|
||||
|
@ -4,12 +4,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"golang.org/x/xerrors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-car"
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -29,22 +30,25 @@ import (
|
||||
|
||||
var glog = logging.Logger("genesis")
|
||||
|
||||
func MakeGenesisMem(out io.Writer, minerPid peer.ID) func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis {
|
||||
func MakeGenesisMem(out io.Writer, gmc *gen.GenMinerCfg) func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis {
|
||||
return func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis {
|
||||
return func() (*types.BlockHeader, error) {
|
||||
glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network")
|
||||
// TODO: make an address allocation
|
||||
w, err := w.GenerateKey(types.KTBLS)
|
||||
defk, err := w.GenerateKey(types.KTBLS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
gmc := &gen.GenMinerCfg{
|
||||
PeerIDs: []peer.ID{minerPid},
|
||||
// TODO: Call seal.PreSeal
|
||||
}
|
||||
alloc := map[address.Address]types.BigInt{
|
||||
w: types.FromFil(10000),
|
||||
defk: types.FromFil(1000),
|
||||
}
|
||||
|
||||
for _, genm := range gmc.PreSeals {
|
||||
waddr, err := w.Import(&genm.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
alloc[waddr] = types.FromFil(10000)
|
||||
}
|
||||
|
||||
b, err := gen.MakeGenesisBlock(bs, alloc, gmc, 100000)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"io/ioutil"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
@ -19,7 +20,10 @@ import (
|
||||
"github.com/filecoin-project/lotus/api/test"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||
"github.com/filecoin-project/lotus/genesis"
|
||||
"github.com/filecoin-project/lotus/lib/jsonrpc"
|
||||
"github.com/filecoin-project/lotus/miner"
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
@ -87,7 +91,9 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a
|
||||
|
||||
node.Override(new(api.FullNode), tnd),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to construct node: %v", err)
|
||||
}
|
||||
|
||||
/*// Bootstrap with full node
|
||||
remoteAddrs, err := tnd.NetAddrsListen(ctx)
|
||||
@ -114,10 +120,38 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
|
||||
|
||||
var genbuf bytes.Buffer
|
||||
|
||||
if len(storage) != 1 {
|
||||
panic("need more peer IDs")
|
||||
}
|
||||
// PRESEAL SECTION, TRY TO REPLACE WITH BETTER IN THE FUTURE
|
||||
// TODO: would be great if there was a better way to fake the preseals
|
||||
gmc := &gen.GenMinerCfg{
|
||||
PeerIDs: []peer.ID{minerPid}, // TODO: if we have more miners, need more peer IDs
|
||||
PreSeals: map[string]genesis.GenesisMiner{},
|
||||
}
|
||||
for i := 0; i < len(storage); i++ {
|
||||
maddr, err := address.NewIDAddress(300 + uint64(i))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tdir, err := ioutil.TempDir("", "preseal-memgen")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
genm, err := seed.PreSeal(maddr, 1024, 1, tdir, []byte("make genesis mem random"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
gmc.MinerAddrs = append(gmc.MinerAddrs, maddr)
|
||||
gmc.PreSeals[maddr.String()] = *genm
|
||||
}
|
||||
|
||||
// END PRESEAL SECTION
|
||||
|
||||
for i := 0; i < nFull; i++ {
|
||||
var genesis node.Option
|
||||
if i == 0 {
|
||||
genesis = node.Override(new(modules.Genesis), modtest.MakeGenesisMem(&genbuf, minerPid))
|
||||
genesis = node.Override(new(modules.Genesis), modtest.MakeGenesisMem(&genbuf, gmc))
|
||||
} else {
|
||||
genesis = node.Override(new(modules.Genesis), modules.LoadGenesis(genbuf.Bytes()))
|
||||
}
|
||||
@ -165,7 +199,7 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
|
||||
wa, err := f.WalletDefaultAddress(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
genMiner, err := address.NewFromString("t0101")
|
||||
genMiner, err := address.NewFromString("t0102")
|
||||
require.NoError(t, err)
|
||||
|
||||
storers[i] = testStorageNode(ctx, t, wa, genMiner, pk, f, mn)
|
||||
|
Loading…
Reference in New Issue
Block a user