Fix Sealing in TestAPIDealFlow

This commit is contained in:
Łukasz Magiera 2020-02-23 21:32:14 +01:00
parent 917df9a5b8
commit 1d417685d1
3 changed files with 29 additions and 5 deletions

View File

@ -109,6 +109,8 @@ func (ss *syscallShim) VerifySeal(ssize abi.SectorSize, info abi.SealVerifyInfo)
proof := []byte(info.OnChain.Proof)
seed := []byte(info.InteractiveRandomness)
log.Infof("Werif %d r:%x; d:%x; m:%s; t:%x; s:%x; N:%d; p:%x", ssize, commR, commD, miner, ticket, seed, info.SectorID.Number, proof)
//func(ctx context.Context, maddr address.Address, ssize abi.SectorSize, commD, commR, ticket, proof, seed []byte, sectorID abi.SectorNumber)
ok, err := ss.verifier.VerifySeal(ssize, commR[:], commD[:], miner, ticket, seed, info.SectorID.Number, proof)
if err != nil {

View File

@ -151,8 +151,6 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
minerPid, err := peer.IDFromPrivateKey(pk)
require.NoError(t, err)
_ = minerPid // TODO: what do we do with this now?
var genbuf bytes.Buffer
if len(storage) > 1 {
@ -163,6 +161,8 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
var genms []genesis.Miner
var maddrs []address.Address
var genaccs []genesis.Actor
var keys []*wallet.Key
var presealDirs []string
for i := 0; i < len(storage); i++ {
@ -174,18 +174,32 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
if err != nil {
t.Fatal(err)
}
genm, _, err := seed.PreSeal(maddr, 1024, 0, 2, tdir, []byte("make genesis mem random"), nil)
genm, k, err := seed.PreSeal(maddr, 1024, 0, 2, tdir, []byte("make genesis mem random"), nil)
if err != nil {
t.Fatal(err)
}
genm.PeerId = minerPid
wk, err := wallet.NewKey(*k)
if err != nil {
return nil, nil
}
genaccs = append(genaccs, genesis.Actor{
Type: genesis.TAccount,
Balance: big.NewInt(40000000000),
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
})
keys = append(keys, wk)
presealDirs = append(presealDirs, tdir)
maddrs = append(maddrs, maddr)
genms = append(genms, *genm)
}
templ := &genesis.Template{
Miners: genms,
Accounts: genaccs,
Miners: genms,
}
// END PRESEAL SECTION
@ -225,6 +239,12 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te
}
f := fulls[full]
if _, err := f.FullNode.WalletImport(ctx, &keys[i].KeyInfo); err != nil {
return nil, nil
}
if err := f.FullNode.WalletSetDefault(ctx, keys[i].Address); err != nil {
return nil, nil
}
genMiner := maddrs[i]
wa := genms[i].Worker

View File

@ -106,7 +106,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
SealedCID: commcid.ReplicaCommitmentV1ToCID(sector.CommR),
SealRandEpoch: sector.Ticket.BlockHeight,
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
DealIDs: sector.deals(),
}
enc, aerr := actors.SerializeParams(params)
if aerr != nil {
@ -180,6 +180,8 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) error {
log.Info("scheduling seal proof computation...")
log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorID, sector.Ticket.TicketBytes, sector.Ticket.BlockHeight, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.pieceInfos(), sector.CommR, sector.CommD)
proof, err := m.sb.SealCommit(ctx.Context(), sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.rspco())
if err != nil {
return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed: %w", err)})