specs-actors: Fis some test compilation errors
This commit is contained in:
parent
7e70536bf1
commit
c0ed0dda8e
@ -8,6 +8,16 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -16,10 +26,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/lib/rlepluslazy"
|
"github.com/filecoin-project/lotus/lib/rlepluslazy"
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMinerCommitSectors(t *testing.T) {
|
func TestMinerCommitSectors(t *testing.T) {
|
||||||
@ -40,7 +46,7 @@ func TestMinerCommitSectors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h := NewHarness(t, opts...)
|
h := NewHarness(t, opts...)
|
||||||
h.vm.Syscalls.ValidatePoRep = func(ctx context.Context, maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, aerrors.ActorError) {
|
h.vm.Syscalls.ValidatePoRep = func(ctx context.Context, maddr address.Address, ssize abi.SectorSize, commD, commR, ticket, proof, seed []byte, sectorID abi.SectorNumber) (bool, aerrors.ActorError) {
|
||||||
// all proofs are valid
|
// all proofs are valid
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@ -53,7 +59,7 @@ func TestMinerCommitSectors(t *testing.T) {
|
|||||||
|
|
||||||
addSectorToMiner(h, t, minerAddr, worker, client, 1)
|
addSectorToMiner(h, t, minerAddr, worker, client, 1)
|
||||||
|
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{1})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{1})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +80,7 @@ var _ rlepluslazy.RunIterator = (*badRuns)(nil)
|
|||||||
|
|
||||||
func TestMinerSubmitBadFault(t *testing.T) {
|
func TestMinerSubmitBadFault(t *testing.T) {
|
||||||
oldSS, oldMin := build.SectorSizes, build.MinimumMinerPower
|
oldSS, oldMin := build.SectorSizes, build.MinimumMinerPower
|
||||||
build.SectorSizes, build.MinimumMinerPower = []uint64{1024}, 1024
|
build.SectorSizes, build.MinimumMinerPower = []abi.SectorSize{1024}, 1024
|
||||||
defer func() {
|
defer func() {
|
||||||
build.SectorSizes, build.MinimumMinerPower = oldSS, oldMin
|
build.SectorSizes, build.MinimumMinerPower = oldSS, oldMin
|
||||||
}()
|
}()
|
||||||
@ -88,7 +94,7 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h := NewHarness(t, opts...)
|
h := NewHarness(t, opts...)
|
||||||
h.vm.Syscalls.ValidatePoRep = func(ctx context.Context, maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, aerrors.ActorError) {
|
h.vm.Syscalls.ValidatePoRep = func(ctx context.Context, maddr address.Address, ssize abi.SectorSize, commD, commR, ticket, proof, seed []byte, sectorID abi.SectorNumber) (bool, aerrors.ActorError) {
|
||||||
// all proofs are valid
|
// all proofs are valid
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@ -101,7 +107,7 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
|
|
||||||
addSectorToMiner(h, t, minerAddr, worker, client, 1)
|
addSectorToMiner(h, t, minerAddr, worker, client, 1)
|
||||||
|
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{1})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{1})
|
||||||
|
|
||||||
bf := types.NewBitField()
|
bf := types.NewBitField()
|
||||||
bf.Set(6)
|
bf.Set(6)
|
||||||
@ -110,7 +116,7 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
|
|
||||||
ret, _ = h.Invoke(t, actors.NetworkAddress, minerAddr, actors.MAMethods.SubmitElectionPoSt, nil)
|
ret, _ = h.Invoke(t, actors.NetworkAddress, minerAddr, actors.MAMethods.SubmitElectionPoSt, nil)
|
||||||
ApplyOK(t, ret)
|
ApplyOK(t, ret)
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{1})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{1})
|
||||||
|
|
||||||
st, err := getMinerState(context.TODO(), h.vm.StateTree(), h.bs, minerAddr)
|
st, err := getMinerState(context.TODO(), h.vm.StateTree(), h.bs, minerAddr)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -130,7 +136,7 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
ret, _ = h.Invoke(t, actors.NetworkAddress, minerAddr, actors.MAMethods.SubmitElectionPoSt, nil)
|
ret, _ = h.Invoke(t, actors.NetworkAddress, minerAddr, actors.MAMethods.SubmitElectionPoSt, nil)
|
||||||
|
|
||||||
ApplyOK(t, ret)
|
ApplyOK(t, ret)
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{1})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{1})
|
||||||
|
|
||||||
st, err = getMinerState(context.TODO(), h.vm.StateTree(), h.bs, minerAddr)
|
st, err = getMinerState(context.TODO(), h.vm.StateTree(), h.bs, minerAddr)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -144,7 +150,7 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
if ret.ExitCode != 3 {
|
if ret.ExitCode != 3 {
|
||||||
t.Errorf("expected exit code 3, got %d: %+v", ret.ExitCode, ret.ActorErr)
|
t.Errorf("expected exit code 3, got %d: %+v", ret.ExitCode, ret.ActorErr)
|
||||||
}
|
}
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{1})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{1})
|
||||||
|
|
||||||
rle, err := rlepluslazy.EncodeRuns(&badRuns{}, []byte{})
|
rle, err := rlepluslazy.EncodeRuns(&badRuns{}, []byte{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -155,7 +161,7 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
if ret.ExitCode != 3 {
|
if ret.ExitCode != 3 {
|
||||||
t.Errorf("expected exit code 3, got %d: %+v", ret.ExitCode, ret.ActorErr)
|
t.Errorf("expected exit code 3, got %d: %+v", ret.ExitCode, ret.ActorErr)
|
||||||
}
|
}
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{1})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{1})
|
||||||
|
|
||||||
bf = types.NewBitField()
|
bf = types.NewBitField()
|
||||||
bf.Set(1)
|
bf.Set(1)
|
||||||
@ -165,17 +171,17 @@ func TestMinerSubmitBadFault(t *testing.T) {
|
|||||||
ret, _ = h.Invoke(t, actors.NetworkAddress, minerAddr, actors.MAMethods.SubmitElectionPoSt, nil)
|
ret, _ = h.Invoke(t, actors.NetworkAddress, minerAddr, actors.MAMethods.SubmitElectionPoSt, nil)
|
||||||
ApplyOK(t, ret)
|
ApplyOK(t, ret)
|
||||||
|
|
||||||
assertSectorIDs(h, t, minerAddr, []uint64{})
|
assertSectorIDs(h, t, minerAddr, []abi.SectorNumber{})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSectorToMiner(h *Harness, t *testing.T, minerAddr, worker, client address.Address, sid uint64) {
|
func addSectorToMiner(h *Harness, t *testing.T, minerAddr, worker, client address.Address, sid abi.SectorNumber) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
s := sectorbuilder.UserBytesForSectorSize(1024)
|
s := abi.PaddedPieceSize(1024).Unpadded()
|
||||||
deal := h.makeFakeDeal(t, minerAddr, worker, client, s)
|
deal := h.makeFakeDeal(t, minerAddr, worker, client, s)
|
||||||
ret, _ := h.Invoke(t, worker, actors.StorageMarketAddress, actors.SMAMethods.PublishStorageDeals,
|
ret, _ := h.Invoke(t, worker, actors.StorageMarketAddress, actors.SMAMethods.PublishStorageDeals,
|
||||||
&actors.PublishStorageDealsParams{
|
&actors.PublishStorageDealsParams{
|
||||||
Deals: []actors.StorageDealProposal{*deal},
|
Deals: []market.ClientDealProposal{*deal},
|
||||||
})
|
})
|
||||||
ApplyOK(t, ret)
|
ApplyOK(t, ret)
|
||||||
var dealIds actors.PublishStorageDealResponse
|
var dealIds actors.PublishStorageDealResponse
|
||||||
@ -183,28 +189,27 @@ func addSectorToMiner(h *Harness, t *testing.T, minerAddr, worker, client addres
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dealid := dealIds.DealIDs[0]
|
dealid := dealIds.IDs[0]
|
||||||
|
|
||||||
ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.PreCommitSector,
|
ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.PreCommitSector,
|
||||||
&actors.SectorPreCommitInfo{
|
&miner.SectorPreCommitInfo{
|
||||||
SectorNumber: sid,
|
SectorNumber: sid,
|
||||||
CommR: []byte("cats"),
|
SealedCID: commcid.ReplicaCommitmentV1ToCID([]byte("cats")),
|
||||||
SealEpoch: 10,
|
SealEpoch: 10,
|
||||||
DealIDs: []uint64{dealid},
|
DealIDs: []abi.DealID{dealid},
|
||||||
})
|
})
|
||||||
ApplyOK(t, ret)
|
ApplyOK(t, ret)
|
||||||
|
|
||||||
h.BlockHeight += 100
|
h.BlockHeight += 100
|
||||||
ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.ProveCommitSector,
|
ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.ProveCommitSector,
|
||||||
&actors.SectorProveCommitInfo{
|
&miner.ProveCommitSectorParams{
|
||||||
Proof: []byte("prooofy"),
|
SectorNumber: sid,
|
||||||
SectorID: sid,
|
Proof: abi.SealProof{ProofBytes: []byte("prooofy")},
|
||||||
DealIDs: []uint64{dealid}, // TODO: weird that i have to pass this again
|
|
||||||
})
|
})
|
||||||
ApplyOK(t, ret)
|
ApplyOK(t, ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertSectorIDs(h *Harness, t *testing.T, maddr address.Address, ids []uint64) {
|
func assertSectorIDs(h *Harness, t *testing.T, maddr address.Address, ids []abi.SectorNumber) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
sectors, err := getMinerSectorSet(context.TODO(), h.vm.StateTree(), h.bs, maddr)
|
sectors, err := getMinerSectorSet(context.TODO(), h.vm.StateTree(), h.bs, maddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -215,7 +220,7 @@ func assertSectorIDs(h *Harness, t *testing.T, maddr address.Address, ids []uint
|
|||||||
t.Fatal("miner has wrong number of sectors in their sector set")
|
t.Fatal("miner has wrong number of sectors in their sector set")
|
||||||
}
|
}
|
||||||
|
|
||||||
all := make(map[uint64]bool)
|
all := make(map[abi.SectorNumber]bool)
|
||||||
for _, s := range sectors {
|
for _, s := range sectors {
|
||||||
all[s.SectorID] = true
|
all[s.SectorID] = true
|
||||||
}
|
}
|
||||||
@ -251,7 +256,7 @@ func getMinerSectorSet(ctx context.Context, st types.StateTree, bs blockstore.Bl
|
|||||||
return stmgr.LoadSectorsFromSet(ctx, bs, mstate.Sectors)
|
return stmgr.LoadSectorsFromSet(ctx, bs, mstate.Sectors)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Harness) makeFakeDeal(t *testing.T, miner, worker, client address.Address, size uint64) *actors.StorageDealProposal {
|
func (h *Harness) makeFakeDeal(t *testing.T, miner, worker, client address.Address, size abi.UnpaddedPieceSize) *market.ClientDealProposal {
|
||||||
data := make([]byte, size)
|
data := make([]byte, size)
|
||||||
rand.Read(data)
|
rand.Read(data)
|
||||||
commP, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(data), size)
|
commP, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(data), size)
|
||||||
@ -259,23 +264,22 @@ func (h *Harness) makeFakeDeal(t *testing.T, miner, worker, client address.Addre
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
prop := actors.StorageDealProposal{
|
prop := market.DealProposal{
|
||||||
PieceRef: commP[:],
|
PieceCID: commcid.PieceCommitmentV1ToCID(commP[:]),
|
||||||
PieceSize: size,
|
PieceSize: size.Padded(),
|
||||||
|
|
||||||
Client: client,
|
Client: client,
|
||||||
Provider: miner,
|
Provider: miner,
|
||||||
|
|
||||||
ProposalExpiration: 10000,
|
StartEpoch: 10000,
|
||||||
Duration: 150,
|
EndEpoch: 10150,
|
||||||
|
|
||||||
StoragePricePerEpoch: types.NewInt(1),
|
StoragePricePerEpoch: types.NewInt(1),
|
||||||
StorageCollateral: types.NewInt(0),
|
ProviderCollateral: types.NewInt(0),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := api.SignWith(context.TODO(), h.w.Sign, client, &prop); err != nil {
|
return &market.ClientDealProposal{
|
||||||
t.Fatal(err)
|
Proposal: prop,
|
||||||
|
ClientSignature: crypto.Signature{}, // TODO: not quite correct
|
||||||
}
|
}
|
||||||
|
|
||||||
return &prop
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -49,7 +51,7 @@ type Harness struct {
|
|||||||
Nonces map[address.Address]uint64
|
Nonces map[address.Address]uint64
|
||||||
GasCharges map[address.Address]types.BigInt
|
GasCharges map[address.Address]types.BigInt
|
||||||
Rand vm.Rand
|
Rand vm.Rand
|
||||||
BlockHeight uint64
|
BlockHeight abi.ChainEpoch
|
||||||
|
|
||||||
lastBalanceCheck map[address.Address]types.BigInt
|
lastBalanceCheck map[address.Address]types.BigInt
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ type fakeMsg struct {
|
|||||||
|
|
||||||
type fakeCS struct {
|
type fakeCS struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
h uint64
|
h abi.ChainEpoch
|
||||||
tsc *tipSetCache
|
tsc *tipSetCache
|
||||||
|
|
||||||
msgs map[cid.Cid]fakeMsg
|
msgs map[cid.Cid]fakeMsg
|
||||||
@ -48,11 +50,11 @@ func (fcs *fakeCS) StateGetActor(ctx context.Context, actor address.Address, ts
|
|||||||
panic("Not Implemented")
|
panic("Not Implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet) (*types.TipSet, error) {
|
func (fcs *fakeCS) ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error) {
|
||||||
panic("Not Implemented")
|
panic("Not Implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet {
|
func makeTs(t *testing.T, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet {
|
||||||
a, _ := address.NewFromString("t00")
|
a, _ := address.NewFromString("t00")
|
||||||
b, _ := address.NewFromString("t02")
|
b, _ := address.NewFromString("t02")
|
||||||
var ts, err = types.NewTipSet([]*types.BlockHeader{
|
var ts, err = types.NewTipSet([]*types.BlockHeader{
|
||||||
@ -206,7 +208,7 @@ func TestAt(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 5, int(ts.Height()))
|
require.Equal(t, 5, int(ts.Height()))
|
||||||
require.Equal(t, 8, int(curH))
|
require.Equal(t, 8, int(curH))
|
||||||
applied = true
|
applied = true
|
||||||
@ -271,7 +273,7 @@ func TestAtDoubleTrigger(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 5, int(ts.Height()))
|
require.Equal(t, 5, int(ts.Height()))
|
||||||
require.Equal(t, 8, int(curH))
|
require.Equal(t, 8, int(curH))
|
||||||
applied = true
|
applied = true
|
||||||
@ -313,8 +315,8 @@ func TestAtNullTrigger(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, uint64(6), ts.Height())
|
require.Equal(t, abi.ChainEpoch(6), ts.Height())
|
||||||
require.Equal(t, 8, int(curH))
|
require.Equal(t, 8, int(curH))
|
||||||
applied = true
|
applied = true
|
||||||
return nil
|
return nil
|
||||||
@ -347,7 +349,7 @@ func TestAtNullConf(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 5, int(ts.Height()))
|
require.Equal(t, 5, int(ts.Height()))
|
||||||
require.Equal(t, 8, int(curH))
|
require.Equal(t, 8, int(curH))
|
||||||
applied = true
|
applied = true
|
||||||
@ -388,7 +390,7 @@ func TestAtStart(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 5, int(ts.Height()))
|
require.Equal(t, 5, int(ts.Height()))
|
||||||
require.Equal(t, 8, int(curH))
|
require.Equal(t, 8, int(curH))
|
||||||
applied = true
|
applied = true
|
||||||
@ -422,7 +424,7 @@ func TestAtStartConfidence(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 5, int(ts.Height()))
|
require.Equal(t, 5, int(ts.Height()))
|
||||||
require.Equal(t, 11, int(curH))
|
require.Equal(t, 11, int(curH))
|
||||||
applied = true
|
applied = true
|
||||||
@ -450,8 +452,8 @@ func TestAtChained(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 10, int(ts.Height()))
|
require.Equal(t, 10, int(ts.Height()))
|
||||||
applied = true
|
applied = true
|
||||||
return nil
|
return nil
|
||||||
@ -486,8 +488,8 @@ func TestAtChainedConfidence(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
return events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
require.Equal(t, 10, int(ts.Height()))
|
require.Equal(t, 10, int(ts.Height()))
|
||||||
applied = true
|
applied = true
|
||||||
return nil
|
return nil
|
||||||
@ -520,7 +522,7 @@ func TestAtChainedConfidenceNull(t *testing.T) {
|
|||||||
var applied bool
|
var applied bool
|
||||||
var reverted bool
|
var reverted bool
|
||||||
|
|
||||||
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH uint64) error {
|
err := events.ChainAt(func(_ context.Context, ts *types.TipSet, curH abi.ChainEpoch) error {
|
||||||
applied = true
|
applied = true
|
||||||
require.Equal(t, 6, int(ts.Height()))
|
require.Equal(t, 6, int(ts.Height()))
|
||||||
return nil
|
return nil
|
||||||
@ -560,11 +562,11 @@ func TestCalled(t *testing.T) {
|
|||||||
var applied, reverted bool
|
var applied, reverted bool
|
||||||
var appliedMsg *types.Message
|
var appliedMsg *types.Message
|
||||||
var appliedTs *types.TipSet
|
var appliedTs *types.TipSet
|
||||||
var appliedH uint64
|
var appliedH abi.ChainEpoch
|
||||||
|
|
||||||
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
||||||
return false, true, nil
|
return false, true, nil
|
||||||
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
|
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
|
||||||
require.Equal(t, false, applied)
|
require.Equal(t, false, applied)
|
||||||
applied = true
|
applied = true
|
||||||
appliedMsg = msg
|
appliedMsg = msg
|
||||||
@ -610,9 +612,9 @@ func TestCalled(t *testing.T) {
|
|||||||
require.Equal(t, false, applied)
|
require.Equal(t, false, applied)
|
||||||
require.Equal(t, false, reverted)
|
require.Equal(t, false, reverted)
|
||||||
|
|
||||||
require.Equal(t, uint64(7), appliedTs.Height())
|
require.Equal(t, abi.ChainEpoch(7), appliedTs.Height())
|
||||||
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
||||||
require.Equal(t, uint64(10), appliedH)
|
require.Equal(t, abi.ChainEpoch(10), appliedH)
|
||||||
require.Equal(t, t0123, appliedMsg.To)
|
require.Equal(t, t0123, appliedMsg.To)
|
||||||
require.Equal(t, uint64(1), appliedMsg.Nonce)
|
require.Equal(t, uint64(1), appliedMsg.Nonce)
|
||||||
require.Equal(t, uint64(5), appliedMsg.Method)
|
require.Equal(t, uint64(5), appliedMsg.Method)
|
||||||
@ -647,9 +649,9 @@ func TestCalled(t *testing.T) {
|
|||||||
require.Equal(t, false, reverted)
|
require.Equal(t, false, reverted)
|
||||||
applied = false
|
applied = false
|
||||||
|
|
||||||
require.Equal(t, uint64(9), appliedTs.Height())
|
require.Equal(t, abi.ChainEpoch(9), appliedTs.Height())
|
||||||
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
||||||
require.Equal(t, uint64(12), appliedH)
|
require.Equal(t, abi.ChainEpoch(12), appliedH)
|
||||||
require.Equal(t, t0123, appliedMsg.To)
|
require.Equal(t, t0123, appliedMsg.To)
|
||||||
require.Equal(t, uint64(2), appliedMsg.Nonce)
|
require.Equal(t, uint64(2), appliedMsg.Nonce)
|
||||||
require.Equal(t, uint64(5), appliedMsg.Method)
|
require.Equal(t, uint64(5), appliedMsg.Method)
|
||||||
@ -668,9 +670,9 @@ func TestCalled(t *testing.T) {
|
|||||||
reverted = false
|
reverted = false
|
||||||
applied = false
|
applied = false
|
||||||
|
|
||||||
require.Equal(t, uint64(11), appliedTs.Height())
|
require.Equal(t, abi.ChainEpoch(11), appliedTs.Height())
|
||||||
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
require.Equal(t, "bafkqaaa", appliedTs.Blocks()[0].Messages.String())
|
||||||
require.Equal(t, uint64(14), appliedH)
|
require.Equal(t, abi.ChainEpoch(14), appliedH)
|
||||||
require.Equal(t, t0123, appliedMsg.To)
|
require.Equal(t, t0123, appliedMsg.To)
|
||||||
require.Equal(t, uint64(2), appliedMsg.Nonce)
|
require.Equal(t, uint64(2), appliedMsg.Nonce)
|
||||||
require.Equal(t, uint64(5), appliedMsg.Method)
|
require.Equal(t, uint64(5), appliedMsg.Method)
|
||||||
@ -765,11 +767,11 @@ func TestCalledTimeout(t *testing.T) {
|
|||||||
|
|
||||||
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
||||||
return false, true, nil
|
return false, true, nil
|
||||||
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
|
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
|
||||||
called = true
|
called = true
|
||||||
require.Nil(t, msg)
|
require.Nil(t, msg)
|
||||||
require.Equal(t, uint64(20), ts.Height())
|
require.Equal(t, abi.ChainEpoch(20), ts.Height())
|
||||||
require.Equal(t, uint64(23), curH)
|
require.Equal(t, abi.ChainEpoch(23), curH)
|
||||||
return false, nil
|
return false, nil
|
||||||
}, func(_ context.Context, ts *types.TipSet) error {
|
}, func(_ context.Context, ts *types.TipSet) error {
|
||||||
t.Fatal("revert on timeout")
|
t.Fatal("revert on timeout")
|
||||||
@ -800,11 +802,11 @@ func TestCalledTimeout(t *testing.T) {
|
|||||||
|
|
||||||
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
||||||
return true, true, nil
|
return true, true, nil
|
||||||
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
|
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
|
||||||
called = true
|
called = true
|
||||||
require.Nil(t, msg)
|
require.Nil(t, msg)
|
||||||
require.Equal(t, uint64(20), ts.Height())
|
require.Equal(t, abi.ChainEpoch(20), ts.Height())
|
||||||
require.Equal(t, uint64(23), curH)
|
require.Equal(t, abi.ChainEpoch(23), curH)
|
||||||
return false, nil
|
return false, nil
|
||||||
}, func(_ context.Context, ts *types.TipSet) error {
|
}, func(_ context.Context, ts *types.TipSet) error {
|
||||||
t.Fatal("revert on timeout")
|
t.Fatal("revert on timeout")
|
||||||
@ -839,14 +841,14 @@ func TestCalledOrder(t *testing.T) {
|
|||||||
|
|
||||||
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
err = events.Called(func(ts *types.TipSet) (d bool, m bool, e error) {
|
||||||
return false, true, nil
|
return false, true, nil
|
||||||
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (bool, error) {
|
}, func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (bool, error) {
|
||||||
switch at {
|
switch at {
|
||||||
case 0:
|
case 0:
|
||||||
require.Equal(t, uint64(1), msg.Nonce)
|
require.Equal(t, uint64(1), msg.Nonce)
|
||||||
require.Equal(t, uint64(4), ts.Height())
|
require.Equal(t, abi.ChainEpoch(4), ts.Height())
|
||||||
case 1:
|
case 1:
|
||||||
require.Equal(t, uint64(2), msg.Nonce)
|
require.Equal(t, uint64(2), msg.Nonce)
|
||||||
require.Equal(t, uint64(5), ts.Height())
|
require.Equal(t, abi.ChainEpoch(5), ts.Height())
|
||||||
default:
|
default:
|
||||||
t.Fatal("apply should only get called twice, at: ", at)
|
t.Fatal("apply should only get called twice, at: ", at)
|
||||||
}
|
}
|
||||||
@ -855,9 +857,9 @@ func TestCalledOrder(t *testing.T) {
|
|||||||
}, func(_ context.Context, ts *types.TipSet) error {
|
}, func(_ context.Context, ts *types.TipSet) error {
|
||||||
switch at {
|
switch at {
|
||||||
case 2:
|
case 2:
|
||||||
require.Equal(t, uint64(5), ts.Height())
|
require.Equal(t, abi.ChainEpoch(5), ts.Height())
|
||||||
case 3:
|
case 3:
|
||||||
require.Equal(t, uint64(4), ts.Height())
|
require.Equal(t, abi.ChainEpoch(4), ts.Height())
|
||||||
default:
|
default:
|
||||||
t.Fatal("revert should only get called twice, at: ", at)
|
t.Fatal("revert should only get called twice, at: ", at)
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -11,12 +12,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestTsCache(t *testing.T) {
|
func TestTsCache(t *testing.T) {
|
||||||
tsc := newTSCache(50, func(context.Context, uint64, *types.TipSet) (*types.TipSet, error) {
|
tsc := newTSCache(50, func(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error) {
|
||||||
t.Fatal("storage call")
|
t.Fatal("storage call")
|
||||||
return &types.TipSet{}, nil
|
return &types.TipSet{}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
h := uint64(75)
|
h := abi.ChainEpoch(75)
|
||||||
|
|
||||||
a, _ := address.NewFromString("t00")
|
a, _ := address.NewFromString("t00")
|
||||||
|
|
||||||
@ -54,12 +55,12 @@ func TestTsCache(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTsCacheNulls(t *testing.T) {
|
func TestTsCacheNulls(t *testing.T) {
|
||||||
tsc := newTSCache(50, func(context.Context, uint64, *types.TipSet) (*types.TipSet, error) {
|
tsc := newTSCache(50, func(context.Context, abi.ChainEpoch, *types.TipSet) (*types.TipSet, error) {
|
||||||
t.Fatal("storage call")
|
t.Fatal("storage call")
|
||||||
return &types.TipSet{}, nil
|
return &types.TipSet{}, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
h := uint64(75)
|
h := abi.ChainEpoch(75)
|
||||||
|
|
||||||
a, _ := address.NewFromString("t00")
|
a, _ := address.NewFromString("t00")
|
||||||
add := func() {
|
add := func() {
|
||||||
|
@ -3,11 +3,13 @@ package gen
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
build.SectorSizes = []uint64{1024}
|
build.SectorSizes = []abi.SectorSize{1024}
|
||||||
build.MinimumMinerPower = 1024
|
build.MinimumMinerPower = 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
@ -26,7 +28,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
build.SectorSizes = []uint64{1024}
|
build.SectorSizes = []abi.SectorSize{1024}
|
||||||
build.MinimumMinerPower = 1024
|
build.MinimumMinerPower = 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +156,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inv.Register(actcid, &testActor{}, &testActorState{})
|
inv.Register(actcid, &testActor{}, &testActorState{})
|
||||||
sm.SetVMConstructor(func(c cid.Cid, h uint64, r vm.Rand, a address.Address, b blockstore.Blockstore, s *types.VMSyscalls) (*vm.VM, error) {
|
sm.SetVMConstructor(func(c cid.Cid, h abi.ChainEpoch, r vm.Rand, a address.Address, b blockstore.Blockstore, s *types.VMSyscalls) (*vm.VM, error) {
|
||||||
nvm, err := vm.NewVM(c, h, r, a, b, s)
|
nvm, err := vm.NewVM(c, h, r, a, b, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -9,11 +9,12 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
build.SectorSizes = []uint64{1024}
|
build.SectorSizes = []abi.SectorSize{1024}
|
||||||
build.MinimumMinerPower = 1024
|
build.MinimumMinerPower = 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||||
@ -27,7 +28,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
build.InsecurePoStValidation = true
|
build.InsecurePoStValidation = true
|
||||||
os.Setenv("TRUST_PARAMS", "1")
|
os.Setenv("TRUST_PARAMS", "1")
|
||||||
build.SectorSizes = []uint64{1024}
|
build.SectorSizes = []abi.SectorSize{1024}
|
||||||
build.MinimumMinerPower = 1024
|
build.MinimumMinerPower = 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +399,7 @@ func TestSyncBadTimestamp(t *testing.T) {
|
|||||||
tu.waitUntilSync(0, client)
|
tu.waitUntilSync(0, client)
|
||||||
|
|
||||||
base := tu.g.CurTipset
|
base := tu.g.CurTipset
|
||||||
tu.g.Timestamper = func(pts *types.TipSet, tl uint64) uint64 {
|
tu.g.Timestamper = func(pts *types.TipSet, tl abi.ChainEpoch) uint64 {
|
||||||
return pts.MinTimestamp() + (build.BlockDelay / 2)
|
return pts.MinTimestamp() + (build.BlockDelay / 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func TestSizeStr(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
assert.Equal(t, c.out, NewInt(c.in).SizeStr(), "input %+v, produced wrong result", c)
|
assert.Equal(t, c.out, SizeStr(NewInt(c.in)), "input %+v, produced wrong result", c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +75,6 @@ func TestSizeStrBig(t *testing.T) {
|
|||||||
ZiB := big.NewInt(50000)
|
ZiB := big.NewInt(50000)
|
||||||
ZiB = ZiB.Lsh(ZiB, 70)
|
ZiB = ZiB.Lsh(ZiB, 70)
|
||||||
|
|
||||||
assert.Equal(t, "5e+04 ZiB", BigInt{Int: ZiB}.SizeStr(), "inout %+v, produced wrong result", ZiB)
|
assert.Equal(t, "5e+04 ZiB", SizeStr(BigInt{Int: ZiB}), "inout %+v, produced wrong result", ZiB)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pcids []cid.Cid
|
var pcids []cid.Cid
|
||||||
var height uint64
|
var height abi.ChainEpoch
|
||||||
weight := types.NewInt(weightInc)
|
weight := types.NewInt(weightInc)
|
||||||
if parents != nil {
|
if parents != nil {
|
||||||
pcids = parents.Cids()
|
pcids = parents.Cids()
|
||||||
|
@ -2,6 +2,9 @@ package validation
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
|
|
||||||
vchain "github.com/filecoin-project/chain-validation/pkg/chain"
|
vchain "github.com/filecoin-project/chain-validation/pkg/chain"
|
||||||
@ -33,7 +36,7 @@ func (a *Applier) ApplyMessage(eCtx *vchain.ExecutionContext, state vstate.Wrapp
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return vchain.MessageReceipt{}, err
|
return vchain.MessageReceipt{}, err
|
||||||
}
|
}
|
||||||
lotusVM, err := vm.NewVM(base, eCtx.Epoch, randSrc, minerAddr, st.bs, vm.Syscalls(sectorbuilder.ProofVerifier))
|
lotusVM, err := vm.NewVM(base, abi.ChainEpoch(eCtx.Epoch), randSrc, minerAddr, st.bs, vm.Syscalls(sectorbuilder.ProofVerifier))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vchain.MessageReceipt{}, err
|
return vchain.MessageReceipt{}, err
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
paramfetch "github.com/filecoin-project/go-paramfetch"
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
@ -32,7 +33,7 @@ import (
|
|||||||
var log = logging.Logger("lotus-bench")
|
var log = logging.Logger("lotus-bench")
|
||||||
|
|
||||||
type BenchResults struct {
|
type BenchResults struct {
|
||||||
SectorSize uint64
|
SectorSize abi.SectorSize
|
||||||
|
|
||||||
SealingResults []SealingResult
|
SealingResults []SealingResult
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sectorSize := uint64(sectorSizeInt)
|
sectorSize := abi.SectorSize(sectorSizeInt)
|
||||||
|
|
||||||
mds := datastore.NewMapDatastore()
|
mds := datastore.NewMapDatastore()
|
||||||
cfg := §orbuilder.Config{
|
cfg := §orbuilder.Config{
|
||||||
@ -155,7 +156,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := paramfetch.GetParams(build.ParametersJson(), sectorSize); err != nil {
|
if err := paramfetch.GetParams(build.ParametersJson(), uint64(sectorSize)); err != nil {
|
||||||
return xerrors.Errorf("getting params: %w", err)
|
return xerrors.Errorf("getting params: %w", err)
|
||||||
}
|
}
|
||||||
sb, err := sectorbuilder.New(cfg, mds)
|
sb, err := sectorbuilder.New(cfg, mds)
|
||||||
@ -163,18 +164,16 @@ func main() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSize := sectorbuilder.UserBytesForSectorSize(sectorSize)
|
|
||||||
|
|
||||||
var sealTimings []SealingResult
|
var sealTimings []SealingResult
|
||||||
var sealedSectors []ffi.PublicSectorInfo
|
var sealedSectors []ffi.PublicSectorInfo
|
||||||
numSectors := uint64(1)
|
numSectors := abi.SectorNumber(1)
|
||||||
for i := uint64(1); i <= numSectors && robench == ""; i++ {
|
for i := abi.SectorNumber(1); i <= numSectors && robench == ""; i++ {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
log.Info("Writing piece into sector...")
|
log.Info("Writing piece into sector...")
|
||||||
|
|
||||||
r := rand.New(rand.NewSource(100 + int64(i)))
|
r := rand.New(rand.NewSource(100 + int64(i)))
|
||||||
|
|
||||||
pi, err := sb.AddPiece(context.TODO(), dataSize, i, r, nil)
|
pi, err := sb.AddPiece(context.TODO(), abi.UnpaddedPieceSize(sectorSize), i, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -197,7 +196,7 @@ func main() {
|
|||||||
|
|
||||||
sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{
|
sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{
|
||||||
CommR: pco.CommR,
|
CommR: pco.CommR,
|
||||||
SectorID: i,
|
SectorID: uint64(i),
|
||||||
})
|
})
|
||||||
|
|
||||||
seed := sectorbuilder.SealSeed{
|
seed := sectorbuilder.SealSeed{
|
||||||
@ -225,7 +224,7 @@ func main() {
|
|||||||
|
|
||||||
if !c.Bool("skip-unseal") {
|
if !c.Bool("skip-unseal") {
|
||||||
log.Info("Unsealing sector")
|
log.Info("Unsealing sector")
|
||||||
rc, err := sb.ReadPieceFromSealedSector(context.TODO(), 1, 0, dataSize, ticket.TicketBytes[:], commD[:])
|
rc, err := sb.ReadPieceFromSealedSector(context.TODO(), 1, 0, uint64(sectorSize), ticket.TicketBytes[:], commD[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -273,14 +272,14 @@ func main() {
|
|||||||
for _, s := range genm.Sectors {
|
for _, s := range genm.Sectors {
|
||||||
sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{
|
sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{
|
||||||
CommR: s.CommR,
|
CommR: s.CommR,
|
||||||
SectorID: s.SectorID,
|
SectorID: uint64(s.SectorID),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("generating election post candidates")
|
log.Info("generating election post candidates")
|
||||||
sinfos := sectorbuilder.NewSortedPublicSectorInfo(sealedSectors)
|
sinfos := sectorbuilder.NewSortedPublicSectorInfo(sealedSectors)
|
||||||
candidates, err := sb.GenerateEPostCandidates(sinfos, challenge, []uint64{})
|
candidates, err := sb.GenerateEPostCandidates(sinfos, challenge, []abi.SectorNumber{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -355,7 +354,7 @@ func main() {
|
|||||||
fmt.Printf("unseal: %s (%s)\n", bo.SealingResults[0].Unseal, bps(bo.SectorSize, bo.SealingResults[0].Unseal))
|
fmt.Printf("unseal: %s (%s)\n", bo.SealingResults[0].Unseal, bps(bo.SectorSize, bo.SealingResults[0].Unseal))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize*uint64(len(bo.SealingResults)), bo.PostGenerateCandidates))
|
fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize*abi.SectorSize(len(bo.SealingResults)), bo.PostGenerateCandidates))
|
||||||
fmt.Printf("compute epost proof (cold): %s\n", bo.PostEProofCold)
|
fmt.Printf("compute epost proof (cold): %s\n", bo.PostEProofCold)
|
||||||
fmt.Printf("compute epost proof (hot): %s\n", bo.PostEProofHot)
|
fmt.Printf("compute epost proof (hot): %s\n", bo.PostEProofHot)
|
||||||
fmt.Printf("verify epost proof (cold): %s\n", bo.VerifyEPostCold)
|
fmt.Printf("verify epost proof (cold): %s\n", bo.VerifyEPostCold)
|
||||||
@ -371,9 +370,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func bps(data uint64, d time.Duration) string {
|
func bps(data abi.SectorSize, d time.Duration) string {
|
||||||
bdata := new(big.Int).SetUint64(data)
|
bdata := new(big.Int).SetUint64(uint64(data))
|
||||||
bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds()))
|
bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds()))
|
||||||
bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds()))
|
bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds()))
|
||||||
return (types.BigInt{bps}).SizeStr() + "/s"
|
return types.SizeStr(types.BigInt{bps}) + "/s"
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -13,7 +12,6 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -267,8 +265,8 @@ create table if not exists deals
|
|||||||
pieceSize bigint not null,
|
pieceSize bigint not null,
|
||||||
client text not null,
|
client text not null,
|
||||||
provider text not null,
|
provider text not null,
|
||||||
expiration decimal not null,
|
start decimal not null,
|
||||||
duration decimal not null,
|
end decimal not null,
|
||||||
epochPrice decimal not null,
|
epochPrice decimal not null,
|
||||||
collateral decimal not null,
|
collateral decimal not null,
|
||||||
constraint deals_pk
|
constraint deals_pk
|
||||||
@ -842,7 +840,7 @@ func (st *storage) storeMpoolInclusions(msgs []api.MpoolUpdate) error {
|
|||||||
return tx.Commit()
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *storage) storeDeals(deals map[string]actors.OnChainDeal) error {
|
func (st *storage) storeDeals(deals map[string]api.MarketDeal) error {
|
||||||
tx, err := st.db.Begin()
|
tx, err := st.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -854,7 +852,7 @@ func (st *storage) storeDeals(deals map[string]actors.OnChainDeal) error {
|
|||||||
return xerrors.Errorf("prep temp: %w", err)
|
return xerrors.Errorf("prep temp: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt, err := tx.Prepare(`copy d (id, pieceref, piecesize, client, "provider", expiration, duration, epochprice, collateral) from stdin `)
|
stmt, err := tx.Prepare(`copy d (id, pieceref, piecesize, client, "provider", "start", "end", epochprice, collateral) from stdin `)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -862,20 +860,20 @@ func (st *storage) storeDeals(deals map[string]actors.OnChainDeal) error {
|
|||||||
var bloat uint64
|
var bloat uint64
|
||||||
|
|
||||||
for id, deal := range deals {
|
for id, deal := range deals {
|
||||||
if len(deal.PieceRef) > 40 {
|
if len(deal.Proposal.PieceCID.String()) > 100 {
|
||||||
bloat += uint64(len(deal.PieceRef))
|
bloat += uint64(len(deal.Proposal.PieceCID.String()))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, err := stmt.Exec(
|
if _, err := stmt.Exec(
|
||||||
id,
|
id,
|
||||||
hex.EncodeToString(deal.PieceRef),
|
deal.Proposal.PieceCID.String(),
|
||||||
deal.PieceSize,
|
deal.Proposal.PieceSize,
|
||||||
deal.Client.String(),
|
deal.Proposal.Client.String(),
|
||||||
deal.Provider.String(),
|
deal.Proposal.Provider.String(),
|
||||||
fmt.Sprint(deal.ProposalExpiration),
|
fmt.Sprint(deal.Proposal.StartEpoch),
|
||||||
fmt.Sprint(deal.Duration),
|
fmt.Sprint(deal.Proposal.EndEpoch),
|
||||||
deal.StoragePricePerEpoch.String(),
|
deal.Proposal.StoragePricePerEpoch.String(),
|
||||||
deal.StorageCollateral.String(),
|
deal.Proposal.ProviderCollateral.String(),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -915,12 +913,12 @@ func (st *storage) storeDeals(deals map[string]actors.OnChainDeal) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for id, deal := range deals {
|
for id, deal := range deals {
|
||||||
if deal.ActivationEpoch == 0 {
|
if deal.State.SectorStartEpoch <= 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, err := stmt.Exec(
|
if _, err := stmt.Exec(
|
||||||
id,
|
id,
|
||||||
deal.ActivationEpoch,
|
deal.State.SectorStartEpoch,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
actors2 "github.com/filecoin-project/lotus/chain/actors"
|
actors2 "github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -114,7 +116,7 @@ func syncHead(ctx context.Context, api api.FullNode, st *storage, ts *types.TipS
|
|||||||
}
|
}
|
||||||
|
|
||||||
for len(allToSync) > 0 {
|
for len(allToSync) > 0 {
|
||||||
minH := uint64(math.MaxUint64)
|
minH := abi.ChainEpoch(math.MaxInt64)
|
||||||
|
|
||||||
for _, header := range allToSync {
|
for _, header := range allToSync {
|
||||||
if header.Height < minH {
|
if header.Height < minH {
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
rice "github.com/GeertJohan/go.rice"
|
rice "github.com/GeertJohan/go.rice"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
peer "github.com/libp2p/go-libp2p-peer"
|
||||||
@ -263,7 +264,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
|||||||
params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{
|
params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
Worker: owner,
|
Worker: owner,
|
||||||
SectorSize: uint64(ssize),
|
SectorSize: abi.SectorSize(ssize),
|
||||||
PeerID: peer.ID("SETME"),
|
PeerID: peer.ID("SETME"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||||
|
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
@ -66,7 +68,7 @@ var preSealCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
&cli.Uint64Flag{
|
&cli.Uint64Flag{
|
||||||
Name: "sector-size",
|
Name: "sector-size",
|
||||||
Value: build.SectorSizes[0],
|
Value: uint64(build.SectorSizes[0]),
|
||||||
Usage: "specify size of sectors to pre-seal",
|
Usage: "specify size of sectors to pre-seal",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
@ -97,7 +99,7 @@ var preSealCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
gm, err := seed.PreSeal(maddr, c.Uint64("sector-size"), c.Uint64("sector-offset"), c.Int("num-sectors"), sbroot, []byte(c.String("ticket-preimage")))
|
gm, err := seed.PreSeal(maddr, abi.SectorSize(c.Uint64("sector-size")), c.Uint64("sector-offset"), c.Int("num-sectors"), sbroot, []byte(c.String("ticket-preimage")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -192,7 +194,7 @@ var aggregateSectorDirsCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
defer agmds.Close()
|
defer agmds.Close()
|
||||||
|
|
||||||
ssize := cctx.Uint64("sector-size")
|
ssize := abi.SectorSize(cctx.Uint64("sector-size"))
|
||||||
|
|
||||||
agsb, err := sectorbuilder.New(§orbuilder.Config{
|
agsb, err := sectorbuilder.New(§orbuilder.Config{
|
||||||
Miner: maddr,
|
Miner: maddr,
|
||||||
@ -205,7 +207,7 @@ var aggregateSectorDirsCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var aggrGenMiner genesis.GenesisMiner
|
var aggrGenMiner genesis.GenesisMiner
|
||||||
var highestSectorID uint64
|
var highestSectorID abi.SectorNumber
|
||||||
for _, dir := range cctx.Args().Slice() {
|
for _, dir := range cctx.Args().Slice() {
|
||||||
dir, err := homedir.Expand(dir)
|
dir, err := homedir.Expand(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -94,15 +94,12 @@ func main() {
|
|||||||
actors.ArbitrateConsensusFaultParams{},
|
actors.ArbitrateConsensusFaultParams{},
|
||||||
actors.PledgeCollateralParams{},
|
actors.PledgeCollateralParams{},
|
||||||
actors.MinerSlashConsensusFault{},
|
actors.MinerSlashConsensusFault{},
|
||||||
actors.StorageParticipantBalance{},
|
|
||||||
actors.StorageMarketState{},
|
actors.StorageMarketState{},
|
||||||
actors.WithdrawBalanceParams{},
|
actors.WithdrawBalanceParams{},
|
||||||
actors.StorageDealProposal{},
|
actors.StorageDealProposal{},
|
||||||
actors.PublishStorageDealsParams{},
|
actors.PublishStorageDealsParams{},
|
||||||
actors.PublishStorageDealResponse{},
|
actors.PublishStorageDealResponse{},
|
||||||
actors.ActivateStorageDealsParams{},
|
actors.ActivateStorageDealsParams{},
|
||||||
actors.ProcessStorageDealsPaymentParams{},
|
|
||||||
actors.OnChainDeal{},
|
|
||||||
actors.ComputeDataCommitmentParams{},
|
actors.ComputeDataCommitmentParams{},
|
||||||
actors.SectorProveCommitInfo{},
|
actors.SectorProveCommitInfo{},
|
||||||
actors.CheckMinerParams{},
|
actors.CheckMinerParams{},
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
"github.com/ipfs/go-datastore/namespace"
|
"github.com/ipfs/go-datastore/namespace"
|
||||||
badger "github.com/ipfs/go-ds-badger2"
|
badger "github.com/ipfs/go-ds-badger2"
|
||||||
@ -43,7 +44,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
_ = logging.SetLogLevel("*", "INFO")
|
_ = logging.SetLogLevel("*", "INFO")
|
||||||
|
|
||||||
build.SectorSizes = []uint64{1024}
|
build.SectorSizes = []abi.SectorSize{1024}
|
||||||
build.MinimumMinerPower = 1024
|
build.MinimumMinerPower = 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -12,7 +13,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PreSeal(ssize uint64, maddr address.Address, sectors int) (*genesis.GenesisMiner, error) {
|
func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis.GenesisMiner, error) {
|
||||||
k, err := wallet.GenerateKey(types.KTBLS)
|
k, err := wallet.GenerateKey(types.KTBLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -28,21 +29,20 @@ func PreSeal(ssize uint64, maddr address.Address, sectors int) (*genesis.Genesis
|
|||||||
|
|
||||||
for i := range genm.Sectors {
|
for i := range genm.Sectors {
|
||||||
preseal := &genesis.PreSeal{}
|
preseal := &genesis.PreSeal{}
|
||||||
sdata := randB(sectorbuilder.UserBytesForSectorSize(ssize))
|
sdata := randB(uint64(abi.PaddedPieceSize(ssize).Unpadded()))
|
||||||
|
|
||||||
preseal.CommD = commD(sdata)
|
preseal.CommD = commD(sdata)
|
||||||
preseal.CommR = commDR(preseal.CommD[:])
|
preseal.CommR = commDR(preseal.CommD[:])
|
||||||
preseal.SectorID = uint64(i + 1)
|
preseal.SectorID = abi.SectorNumber(i + 1)
|
||||||
preseal.Deal = actors.StorageDealProposal{
|
preseal.Deal = actors.StorageDealProposal{
|
||||||
PieceRef: preseal.CommD[:],
|
PieceCID: commcid.PieceCommitmentV1ToCID(preseal.CommD[:]),
|
||||||
PieceSize: sectorbuilder.UserBytesForSectorSize(ssize),
|
PieceSize: abi.PaddedPieceSize(ssize),
|
||||||
Client: maddr,
|
Client: maddr,
|
||||||
Provider: maddr,
|
Provider: maddr,
|
||||||
ProposalExpiration: math.MaxUint64,
|
StartEpoch: 1,
|
||||||
Duration: math.MaxUint64,
|
EndEpoch: math.MaxInt64,
|
||||||
StoragePricePerEpoch: types.NewInt(0),
|
StoragePricePerEpoch: types.NewInt(0),
|
||||||
StorageCollateral: types.NewInt(0),
|
ProviderCollateral: types.NewInt(0),
|
||||||
ProposerSignature: nil,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
genm.Sectors[i] = preseal
|
genm.Sectors[i] = preseal
|
||||||
|
@ -14,13 +14,14 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/go-sectorbuilder/fs"
|
"github.com/filecoin-project/go-sectorbuilder/fs"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SBMock struct {
|
type SBMock struct {
|
||||||
sectors map[uint64]*sectorState
|
sectors map[abi.SectorNumber]*sectorState
|
||||||
sectorSize uint64
|
sectorSize abi.SectorSize
|
||||||
nextSectorID uint64
|
nextSectorID abi.SectorNumber
|
||||||
rateLimit chan struct{}
|
rateLimit chan struct{}
|
||||||
|
|
||||||
lk sync.Mutex
|
lk sync.Mutex
|
||||||
@ -28,9 +29,9 @@ type SBMock struct {
|
|||||||
|
|
||||||
type mockVerif struct{}
|
type mockVerif struct{}
|
||||||
|
|
||||||
func NewMockSectorBuilder(threads int, ssize uint64) *SBMock {
|
func NewMockSectorBuilder(threads int, ssize abi.SectorSize) *SBMock {
|
||||||
return &SBMock{
|
return &SBMock{
|
||||||
sectors: make(map[uint64]*sectorState),
|
sectors: make(map[abi.SectorNumber]*sectorState),
|
||||||
sectorSize: ssize,
|
sectorSize: ssize,
|
||||||
nextSectorID: 5,
|
nextSectorID: 5,
|
||||||
rateLimit: make(chan struct{}, threads),
|
rateLimit: make(chan struct{}, threads),
|
||||||
@ -61,7 +62,7 @@ func (sb *SBMock) RateLimit() func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) AddPiece(ctx context.Context, size uint64, sectorId uint64, r io.Reader, existingPieces []uint64) (sectorbuilder.PublicPieceInfo, error) {
|
func (sb *SBMock) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, sectorId abi.SectorNumber, r io.Reader, existingPieces []abi.UnpaddedPieceSize) (sectorbuilder.PublicPieceInfo, error) {
|
||||||
sb.lk.Lock()
|
sb.lk.Lock()
|
||||||
ss, ok := sb.sectors[sectorId]
|
ss, ok := sb.sectors[sectorId]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -81,16 +82,16 @@ func (sb *SBMock) AddPiece(ctx context.Context, size uint64, sectorId uint64, r
|
|||||||
|
|
||||||
ss.pieces = append(ss.pieces, b)
|
ss.pieces = append(ss.pieces, b)
|
||||||
return sectorbuilder.PublicPieceInfo{
|
return sectorbuilder.PublicPieceInfo{
|
||||||
Size: size,
|
Size: uint64(size),
|
||||||
CommP: commD(b),
|
CommP: commD(b),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) SectorSize() uint64 {
|
func (sb *SBMock) SectorSize() abi.SectorSize {
|
||||||
return sb.sectorSize
|
return sb.sectorSize
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) AcquireSectorId() (uint64, error) {
|
func (sb *SBMock) AcquireSectorId() (abi.SectorNumber, error) {
|
||||||
sb.lk.Lock()
|
sb.lk.Lock()
|
||||||
defer sb.lk.Unlock()
|
defer sb.lk.Unlock()
|
||||||
id := sb.nextSectorID
|
id := sb.nextSectorID
|
||||||
@ -100,7 +101,7 @@ func (sb *SBMock) AcquireSectorId() (uint64, error) {
|
|||||||
|
|
||||||
func (sb *SBMock) Scrub(sectorbuilder.SortedPublicSectorInfo) []*sectorbuilder.Fault {
|
func (sb *SBMock) Scrub(sectorbuilder.SortedPublicSectorInfo) []*sectorbuilder.Fault {
|
||||||
sb.lk.Lock()
|
sb.lk.Lock()
|
||||||
mcopy := make(map[uint64]*sectorState)
|
mcopy := make(map[abi.SectorNumber]*sectorState)
|
||||||
for k, v := range sb.sectors {
|
for k, v := range sb.sectors {
|
||||||
mcopy[k] = v
|
mcopy[k] = v
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ func (sb *SBMock) Scrub(sectorbuilder.SortedPublicSectorInfo) []*sectorbuilder.F
|
|||||||
ss.lk.Lock()
|
ss.lk.Lock()
|
||||||
if ss.failed {
|
if ss.failed {
|
||||||
out = append(out, §orbuilder.Fault{
|
out = append(out, §orbuilder.Fault{
|
||||||
SectorID: sid,
|
SectorID: uint64(sid),
|
||||||
Err: fmt.Errorf("mock sector failed"),
|
Err: fmt.Errorf("mock sector failed"),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -122,11 +123,11 @@ func (sb *SBMock) Scrub(sectorbuilder.SortedPublicSectorInfo) []*sectorbuilder.F
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) GenerateFallbackPoSt(sectorbuilder.SortedPublicSectorInfo, [sectorbuilder.CommLen]byte, []uint64) ([]sectorbuilder.EPostCandidate, []byte, error) {
|
func (sb *SBMock) GenerateFallbackPoSt(sectorbuilder.SortedPublicSectorInfo, [sectorbuilder.CommLen]byte, []abi.SectorNumber) ([]sectorbuilder.EPostCandidate, []byte, error) {
|
||||||
panic("NYI")
|
panic("NYI")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) SealPreCommit(ctx context.Context, sid uint64, ticket sectorbuilder.SealTicket, pieces []sectorbuilder.PublicPieceInfo) (sectorbuilder.RawSealPreCommitOutput, error) {
|
func (sb *SBMock) SealPreCommit(ctx context.Context, sid abi.SectorNumber, ticket sectorbuilder.SealTicket, pieces []sectorbuilder.PublicPieceInfo) (sectorbuilder.RawSealPreCommitOutput, error) {
|
||||||
sb.lk.Lock()
|
sb.lk.Lock()
|
||||||
ss, ok := sb.sectors[sid]
|
ss, ok := sb.sectors[sid]
|
||||||
sb.lk.Unlock()
|
sb.lk.Unlock()
|
||||||
@ -137,13 +138,13 @@ func (sb *SBMock) SealPreCommit(ctx context.Context, sid uint64, ticket sectorbu
|
|||||||
ss.lk.Lock()
|
ss.lk.Lock()
|
||||||
defer ss.lk.Unlock()
|
defer ss.lk.Unlock()
|
||||||
|
|
||||||
ussize := sectorbuilder.UserBytesForSectorSize(sb.sectorSize)
|
ussize := abi.UnpaddedPieceSize(sb.sectorSize)
|
||||||
|
|
||||||
// TODO: verify pieces in sinfo.pieces match passed in pieces
|
// TODO: verify pieces in sinfo.pieces match passed in pieces
|
||||||
|
|
||||||
var sum uint64
|
var sum abi.UnpaddedPieceSize
|
||||||
for _, p := range pieces {
|
for _, p := range pieces {
|
||||||
sum += p.Size
|
sum += abi.UnpaddedPieceSize(p.Size)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sum != ussize {
|
if sum != ussize {
|
||||||
@ -166,7 +167,7 @@ func (sb *SBMock) SealPreCommit(ctx context.Context, sid uint64, ticket sectorbu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commd, err := MockVerifier.GenerateDataCommitment(sb.sectorSize, pis)
|
commd, err := MockVerifier.GenerateDataCommitment(abi.PaddedPieceSize(sb.sectorSize), pis)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sectorbuilder.RawSealPreCommitOutput{}, err
|
return sectorbuilder.RawSealPreCommitOutput{}, err
|
||||||
}
|
}
|
||||||
@ -177,7 +178,7 @@ func (sb *SBMock) SealPreCommit(ctx context.Context, sid uint64, ticket sectorbu
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) SealCommit(ctx context.Context, sid uint64, ticket sectorbuilder.SealTicket, seed sectorbuilder.SealSeed, pieces []sectorbuilder.PublicPieceInfo, precommit sectorbuilder.RawSealPreCommitOutput) ([]byte, error) {
|
func (sb *SBMock) SealCommit(ctx context.Context, sid abi.SectorNumber, ticket sectorbuilder.SealTicket, seed sectorbuilder.SealSeed, pieces []sectorbuilder.PublicPieceInfo, precommit sectorbuilder.RawSealPreCommitOutput) ([]byte, error) {
|
||||||
sb.lk.Lock()
|
sb.lk.Lock()
|
||||||
ss, ok := sb.sectors[sid]
|
ss, ok := sb.sectors[sid]
|
||||||
sb.lk.Unlock()
|
sb.lk.Unlock()
|
||||||
@ -208,7 +209,7 @@ func (sb *SBMock) GetPath(string, string) (string, error) {
|
|||||||
panic("nyi")
|
panic("nyi")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) CanCommit(sectorID uint64) (bool, error) {
|
func (sb *SBMock) CanCommit(sectorID abi.SectorNumber) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +227,7 @@ func (sb *SBMock) TaskDone(context.Context, uint64, sectorbuilder.SealRes) error
|
|||||||
|
|
||||||
// Test Instrumentation Methods
|
// Test Instrumentation Methods
|
||||||
|
|
||||||
func (sb *SBMock) FailSector(sid uint64) error {
|
func (sb *SBMock) FailSector(sid abi.SectorNumber) error {
|
||||||
sb.lk.Lock()
|
sb.lk.Lock()
|
||||||
defer sb.lk.Unlock()
|
defer sb.lk.Unlock()
|
||||||
ss, ok := sb.sectors[sid]
|
ss, ok := sb.sectors[sid]
|
||||||
@ -258,7 +259,7 @@ func (sb *SBMock) ComputeElectionPoSt(sectorInfo sectorbuilder.SortedPublicSecto
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) GenerateEPostCandidates(sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed [sectorbuilder.CommLen]byte, faults []uint64) ([]sectorbuilder.EPostCandidate, error) {
|
func (sb *SBMock) GenerateEPostCandidates(sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed [sectorbuilder.CommLen]byte, faults []abi.SectorNumber) ([]sectorbuilder.EPostCandidate, error) {
|
||||||
if len(faults) > 0 {
|
if len(faults) > 0 {
|
||||||
panic("todo")
|
panic("todo")
|
||||||
}
|
}
|
||||||
@ -285,15 +286,15 @@ func (sb *SBMock) GenerateEPostCandidates(sectorInfo sectorbuilder.SortedPublicS
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) ReadPieceFromSealedSector(ctx context.Context, sectorID uint64, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error) {
|
func (sb *SBMock) ReadPieceFromSealedSector(ctx context.Context, sectorID abi.SectorNumber, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error) {
|
||||||
if len(sb.sectors[sectorID].pieces) > 1 {
|
if len(sb.sectors[sectorID].pieces) > 1 {
|
||||||
panic("implme")
|
panic("implme")
|
||||||
}
|
}
|
||||||
return ioutil.NopCloser(io.LimitReader(bytes.NewReader(sb.sectors[sectorID].pieces[0][offset:]), int64(size))), nil
|
return ioutil.NopCloser(io.LimitReader(bytes.NewReader(sb.sectors[sectorID].pieces[0][offset:]), int64(size))), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) StageFakeData() (uint64, []sectorbuilder.PublicPieceInfo, error) {
|
func (sb *SBMock) StageFakeData() (abi.SectorNumber, []sectorbuilder.PublicPieceInfo, error) {
|
||||||
usize := sectorbuilder.UserBytesForSectorSize(sb.sectorSize)
|
usize := abi.UnpaddedPieceSize(sb.sectorSize)
|
||||||
sid, err := sb.AcquireSectorId()
|
sid, err := sb.AcquireSectorId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
@ -310,19 +311,19 @@ func (sb *SBMock) StageFakeData() (uint64, []sectorbuilder.PublicPieceInfo, erro
|
|||||||
return sid, []sectorbuilder.PublicPieceInfo{pi}, nil
|
return sid, []sectorbuilder.PublicPieceInfo{pi}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) FinalizeSector(context.Context, uint64) error {
|
func (sb *SBMock) FinalizeSector(context.Context, abi.SectorNumber) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) DropStaged(context.Context, uint64) error {
|
func (sb *SBMock) DropStaged(context.Context, abi.SectorNumber) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) SectorPath(typ fs.DataType, sectorID uint64) (fs.SectorPath, error) {
|
func (sb *SBMock) SectorPath(typ fs.DataType, sectorID abi.SectorNumber) (fs.SectorPath, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sb *SBMock) AllocSectorPath(typ fs.DataType, sectorID uint64, cache bool) (fs.SectorPath, error) {
|
func (sb *SBMock) AllocSectorPath(typ fs.DataType, sectorID abi.SectorNumber, cache bool) (fs.SectorPath, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,15 +331,15 @@ func (sb *SBMock) ReleaseSector(fs.DataType, fs.SectorPath) {
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockVerif) VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address) (bool, error) {
|
func (m mockVerif) VerifyElectionPost(ctx context.Context, sectorSize abi.SectorSize, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address) (bool, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockVerif) VerifyFallbackPost(ctx context.Context, sectorSize uint64, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address, faults uint64) (bool, error) {
|
func (m mockVerif) VerifyFallbackPost(ctx context.Context, sectorSize abi.SectorSize, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address, faults uint64) (bool, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockVerif) VerifySeal(sectorSize uint64, commR, commD []byte, proverID address.Address, ticket []byte, seed []byte, sectorID uint64, proof []byte) (bool, error) {
|
func (m mockVerif) VerifySeal(sectorSize abi.SectorSize, commR, commD []byte, proverID address.Address, ticket []byte, seed []byte, sectorID abi.SectorNumber, proof []byte) (bool, error) {
|
||||||
if len(proof) != 32 { // Real ones are longer, but this should be fine
|
if len(proof) != 32 { // Real ones are longer, but this should be fine
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@ -352,11 +353,11 @@ func (m mockVerif) VerifySeal(sectorSize uint64, commR, commD []byte, proverID a
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m mockVerif) GenerateDataCommitment(ssize uint64, pieces []ffi.PublicPieceInfo) ([sectorbuilder.CommLen]byte, error) {
|
func (m mockVerif) GenerateDataCommitment(ssize abi.PaddedPieceSize, pieces []ffi.PublicPieceInfo) ([sectorbuilder.CommLen]byte, error) {
|
||||||
if len(pieces) != 1 {
|
if len(pieces) != 1 {
|
||||||
panic("todo")
|
panic("todo")
|
||||||
}
|
}
|
||||||
if pieces[0].Size != sectorbuilder.UserBytesForSectorSize(ssize) {
|
if pieces[0].Size != uint64(ssize) {
|
||||||
panic("todo")
|
panic("todo")
|
||||||
}
|
}
|
||||||
return pieces[0].CommP, nil
|
return pieces[0].CommP, nil
|
||||||
|
@ -6,6 +6,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ func commDR(in []byte) (out [32]byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func commD(b []byte) [32]byte {
|
func commD(b []byte) [32]byte {
|
||||||
c, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(b), uint64(len(b)))
|
c, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(b), abi.UnpaddedPieceSize(len(b)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
package sealing
|
package sealing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/lotus/storage/sbmock"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/lotus/storage/sbmock"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testFill(t *testing.T, n uint64, exp []uint64) {
|
func testFill(t *testing.T, n abi.UnpaddedPieceSize, exp []abi.UnpaddedPieceSize) {
|
||||||
f, err := fillersFromRem(n)
|
f, err := fillersFromRem(n)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, exp, f)
|
assert.Equal(t, exp, f)
|
||||||
|
|
||||||
var sum uint64
|
var sum abi.UnpaddedPieceSize
|
||||||
for _, u := range f {
|
for _, u := range f {
|
||||||
sum += u
|
sum += u
|
||||||
}
|
}
|
||||||
@ -24,39 +25,39 @@ func testFill(t *testing.T, n uint64, exp []uint64) {
|
|||||||
func TestFillersFromRem(t *testing.T) {
|
func TestFillersFromRem(t *testing.T) {
|
||||||
for i := 8; i < 32; i++ {
|
for i := 8; i < 32; i++ {
|
||||||
// single
|
// single
|
||||||
ub := sectorbuilder.UserBytesForSectorSize(uint64(1) << i)
|
ub := abi.PaddedPieceSize(uint64(1) << i).Unpadded()
|
||||||
testFill(t, ub, []uint64{ub})
|
testFill(t, ub, []abi.UnpaddedPieceSize{ub})
|
||||||
|
|
||||||
// 2
|
// 2
|
||||||
ub = sectorbuilder.UserBytesForSectorSize(uint64(5) << i)
|
ub = abi.PaddedPieceSize(uint64(5) << i).Unpadded()
|
||||||
ub1 := sectorbuilder.UserBytesForSectorSize(uint64(1) << i)
|
ub1 := abi.PaddedPieceSize(uint64(1) << i).Unpadded()
|
||||||
ub3 := sectorbuilder.UserBytesForSectorSize(uint64(4) << i)
|
ub3 := abi.PaddedPieceSize(uint64(4) << i).Unpadded()
|
||||||
testFill(t, ub, []uint64{ub1, ub3})
|
testFill(t, ub, []abi.UnpaddedPieceSize{ub1, ub3})
|
||||||
|
|
||||||
// 4
|
// 4
|
||||||
ub = sectorbuilder.UserBytesForSectorSize(uint64(15) << i)
|
ub = abi.PaddedPieceSize(uint64(15) << i).Unpadded()
|
||||||
ub2 := sectorbuilder.UserBytesForSectorSize(uint64(2) << i)
|
ub2 := abi.PaddedPieceSize(uint64(2) << i).Unpadded()
|
||||||
ub4 := sectorbuilder.UserBytesForSectorSize(uint64(8) << i)
|
ub4 := abi.PaddedPieceSize(uint64(8) << i).Unpadded()
|
||||||
testFill(t, ub, []uint64{ub1, ub2, ub3, ub4})
|
testFill(t, ub, []abi.UnpaddedPieceSize{ub1, ub2, ub3, ub4})
|
||||||
|
|
||||||
// different 2
|
// different 2
|
||||||
ub = sectorbuilder.UserBytesForSectorSize(uint64(9) << i)
|
ub = abi.PaddedPieceSize(uint64(9) << i).Unpadded()
|
||||||
testFill(t, ub, []uint64{ub1, ub4})
|
testFill(t, ub, []abi.UnpaddedPieceSize{ub1, ub4})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFastPledge(t *testing.T) {
|
func TestFastPledge(t *testing.T) {
|
||||||
sz := uint64(16 << 20)
|
sz := abi.PaddedPieceSize(16 << 20)
|
||||||
|
|
||||||
s := Sealing{sb: sbmock.NewMockSectorBuilder(0, sz)}
|
s := Sealing{sb: sbmock.NewMockSectorBuilder(0, abi.SectorSize(sz))}
|
||||||
if _, err := s.fastPledgeCommitment(sectorbuilder.UserBytesForSectorSize(sz), 5); err != nil {
|
if _, err := s.fastPledgeCommitment(sz.Unpadded(), 5); err != nil {
|
||||||
t.Fatalf("%+v", err)
|
t.Fatalf("%+v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sz = uint64(1024)
|
sz = abi.PaddedPieceSize(1024)
|
||||||
|
|
||||||
s = Sealing{sb: sbmock.NewMockSectorBuilder(0, sz)}
|
s = Sealing{sb: sbmock.NewMockSectorBuilder(0, abi.SectorSize(sz))}
|
||||||
if _, err := s.fastPledgeCommitment(sectorbuilder.UserBytesForSectorSize(sz), 64); err != nil {
|
if _, err := s.fastPledgeCommitment(sz.Unpadded(), 64); err != nil {
|
||||||
t.Fatalf("%+v", err)
|
t.Fatalf("%+v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tipsetsCh, err := GetTips(ctx, api, uint64(height))
|
tipsetsCh, err := GetTips(ctx, api, abi.ChainEpoch(height))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
manet "github.com/multiformats/go-multiaddr-net"
|
manet "github.com/multiformats/go-multiaddr-net"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -120,7 +121,7 @@ sync_complete:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTips(ctx context.Context, api api.FullNode, lastHeight uint64) (<-chan *types.TipSet, error) {
|
func GetTips(ctx context.Context, api api.FullNode, lastHeight abi.ChainEpoch) (<-chan *types.TipSet, error) {
|
||||||
chmain := make(chan *types.TipSet)
|
chmain := make(chan *types.TipSet)
|
||||||
|
|
||||||
notif, err := api.ChainNotify(ctx)
|
notif, err := api.ChainNotify(ctx)
|
||||||
@ -175,7 +176,7 @@ func GetTips(ctx context.Context, api api.FullNode, lastHeight uint64) (<-chan *
|
|||||||
return chmain, nil
|
return chmain, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadTipsets(ctx context.Context, api api.FullNode, curr *types.TipSet, lowestHeight uint64) ([]*types.TipSet, error) {
|
func loadTipsets(ctx context.Context, api api.FullNode, curr *types.TipSet, lowestHeight abi.ChainEpoch) ([]*types.TipSet, error) {
|
||||||
tipsets := []*types.TipSet{}
|
tipsets := []*types.TipSet{}
|
||||||
for {
|
for {
|
||||||
if curr.Height() == 0 {
|
if curr.Height() == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user