sealing pipeline: Drop ChainBaseFee, don't wrap StateSectorPartition
This commit is contained in:
parent
db842224b8
commit
06b3e555c5
@ -113,6 +113,10 @@ func (s SealingAPIAdapter) StateComputeDataCommitment(ctx context.Context, maddr
|
||||
return s.delegate.StateComputeDataCID(ctx, maddr, sectorType, deals, tsk)
|
||||
}
|
||||
|
||||
func (s SealingAPIAdapter) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorLocation, error) {
|
||||
return s.delegate.StateSectorPartition(ctx, maddr, sectorNumber, tsk)
|
||||
}
|
||||
|
||||
func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
|
||||
act, err := s.delegate.StateGetActor(ctx, maddr, tsk)
|
||||
@ -146,31 +150,6 @@ func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr a
|
||||
return pci, nil
|
||||
}
|
||||
|
||||
func (s SealingAPIAdapter) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*pipeline.SectorLocation, error) {
|
||||
|
||||
l, err := s.delegate.StateSectorPartition(ctx, maddr, sectorNumber, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if l != nil {
|
||||
return &pipeline.SectorLocation{
|
||||
Deadline: l.Deadline,
|
||||
Partition: l.Partition,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, nil // not found
|
||||
}
|
||||
|
||||
func (s SealingAPIAdapter) ChainBaseFee(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error) {
|
||||
ts, err := s.delegate.ChainGetTipSet(ctx, tsk)
|
||||
if err != nil {
|
||||
return big.Zero(), err
|
||||
}
|
||||
|
||||
return ts.Blocks()[0].ParentBaseFee, nil
|
||||
}
|
||||
|
||||
func (s SealingAPIAdapter) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error) {
|
||||
msg := types.Message{
|
||||
To: to,
|
||||
|
@ -38,7 +38,6 @@ type CommitBatcherApi interface {
|
||||
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error)
|
||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
||||
ChainHead(ctx context.Context) (*types.TipSet, error)
|
||||
ChainBaseFee(context.Context, types.TipSetKey) (abi.TokenAmount, error)
|
||||
|
||||
StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error)
|
||||
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (big.Int, error)
|
||||
@ -220,13 +219,7 @@ func (b *CommitBatcher) maybeStartBatch(notif bool) ([]sealiface.CommitBatchRes,
|
||||
individual := (total < cfg.MinCommitBatch) || (total < miner.MinAggregatedSectors) || blackedOut()
|
||||
|
||||
if !individual && !cfg.AggregateAboveBaseFee.Equals(big.Zero()) {
|
||||
|
||||
bf, err := b.api.ChainBaseFee(b.mctx, ts.Key())
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("couldn't get base fee: %w", err)
|
||||
}
|
||||
|
||||
if bf.LessThan(cfg.AggregateAboveBaseFee) {
|
||||
if ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.AggregateAboveBaseFee) {
|
||||
individual = true
|
||||
}
|
||||
}
|
||||
@ -354,12 +347,7 @@ func (b *CommitBatcher) processBatch(cfg sealiface.Config) ([]sealiface.CommitBa
|
||||
|
||||
maxFee := b.feeCfg.MaxCommitBatchGasFee.FeeForSectors(len(infos))
|
||||
|
||||
bf, err := b.api.ChainBaseFee(b.mctx, ts.Key())
|
||||
if err != nil {
|
||||
return []sealiface.CommitBatchRes{res}, xerrors.Errorf("couldn't get base fee: %w", err)
|
||||
}
|
||||
|
||||
aggFeeRaw, err := policy.AggregateProveCommitNetworkFee(nv, len(infos), bf)
|
||||
aggFeeRaw, err := policy.AggregateProveCommitNetworkFee(nv, len(infos), ts.MinTicketBlock().ParentBaseFee)
|
||||
if err != nil {
|
||||
log.Errorf("getting aggregate commit network fee: %s", err)
|
||||
return []sealiface.CommitBatchRes{res}, xerrors.Errorf("getting aggregate commit network fee: %s", err)
|
||||
|
@ -96,7 +96,7 @@ func TestCommitBatcher(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
addSector := func(sn abi.SectorNumber) action {
|
||||
addSector := func(sn abi.SectorNumber, aboveBalancer bool) action {
|
||||
return func(t *testing.T, s *mocks.MockCommitBatcherApi, pcb *pipeline.CommitBatcher) promise {
|
||||
var pcres sealiface.CommitBatchRes
|
||||
var pcerr error
|
||||
@ -107,7 +107,12 @@ func TestCommitBatcher(t *testing.T) {
|
||||
SectorNumber: sn,
|
||||
}
|
||||
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeTs(t, 1), nil)
|
||||
basefee := types.PicoFil
|
||||
if aboveBalancer {
|
||||
basefee = types.NanoFil
|
||||
}
|
||||
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, basefee, 1), nil)
|
||||
s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version13, nil)
|
||||
s.EXPECT().StateSectorPreCommitInfo(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&minertypes.SectorPreCommitOnChainInfo{
|
||||
PreCommitDeposit: big.Zero(),
|
||||
@ -131,10 +136,10 @@ func TestCommitBatcher(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
addSectors := func(sectors []abi.SectorNumber) action {
|
||||
addSectors := func(sectors []abi.SectorNumber, aboveBalancer bool) action {
|
||||
as := make([]action, len(sectors))
|
||||
for i, sector := range sectors {
|
||||
as[i] = addSector(sector)
|
||||
as[i] = addSector(sector, aboveBalancer)
|
||||
}
|
||||
return actions(as...)
|
||||
}
|
||||
@ -168,17 +173,17 @@ func TestCommitBatcher(t *testing.T) {
|
||||
basefee = types.NanoFil
|
||||
}
|
||||
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeTs(t, 1), nil)
|
||||
if batch {
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, basefee, 1), nil)
|
||||
/*if batch {
|
||||
s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(basefee, nil)
|
||||
}
|
||||
}*/
|
||||
|
||||
if !aboveBalancer {
|
||||
batch = false
|
||||
ti = len(expect)
|
||||
}
|
||||
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeTs(t, 1), nil)
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, basefee, 1), nil)
|
||||
|
||||
pciC := len(expect)
|
||||
if failOnePCI {
|
||||
@ -195,7 +200,7 @@ func TestCommitBatcher(t *testing.T) {
|
||||
|
||||
if batch {
|
||||
s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version13, nil)
|
||||
s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(basefee, nil)
|
||||
//s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(basefee, nil)
|
||||
}
|
||||
|
||||
s.EXPECT().SendMsg(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), funMatcher(func(i interface{}) bool {
|
||||
@ -278,21 +283,21 @@ func TestCommitBatcher(t *testing.T) {
|
||||
}{
|
||||
"addSingle-aboveBalancer": {
|
||||
actions: []action{
|
||||
addSector(0),
|
||||
addSector(0, true),
|
||||
waitPending(1),
|
||||
flush([]abi.SectorNumber{0}, true, false),
|
||||
},
|
||||
},
|
||||
"addTwo-aboveBalancer": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(2)),
|
||||
addSectors(getSectors(2), true),
|
||||
waitPending(2),
|
||||
flush(getSectors(2), true, false),
|
||||
},
|
||||
},
|
||||
"addAte-aboveBalancer": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(8)),
|
||||
addSectors(getSectors(8), true),
|
||||
waitPending(8),
|
||||
flush(getSectors(8), true, false),
|
||||
},
|
||||
@ -300,26 +305,26 @@ func TestCommitBatcher(t *testing.T) {
|
||||
"addMax-aboveBalancer": {
|
||||
actions: []action{
|
||||
expectSend(getSectors(maxBatch), true, false),
|
||||
addSectors(getSectors(maxBatch)),
|
||||
addSectors(getSectors(maxBatch), true),
|
||||
},
|
||||
},
|
||||
"addSingle-belowBalancer": {
|
||||
actions: []action{
|
||||
addSector(0),
|
||||
addSector(0, false),
|
||||
waitPending(1),
|
||||
flush([]abi.SectorNumber{0}, false, false),
|
||||
},
|
||||
},
|
||||
"addTwo-belowBalancer": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(2)),
|
||||
addSectors(getSectors(2), false),
|
||||
waitPending(2),
|
||||
flush(getSectors(2), false, false),
|
||||
},
|
||||
},
|
||||
"addAte-belowBalancer": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(8)),
|
||||
addSectors(getSectors(8), false),
|
||||
waitPending(8),
|
||||
flush(getSectors(8), false, false),
|
||||
},
|
||||
@ -327,20 +332,20 @@ func TestCommitBatcher(t *testing.T) {
|
||||
"addMax-belowBalancer": {
|
||||
actions: []action{
|
||||
expectSend(getSectors(maxBatch), false, false),
|
||||
addSectors(getSectors(maxBatch)),
|
||||
addSectors(getSectors(maxBatch), false),
|
||||
},
|
||||
},
|
||||
|
||||
"addAte-aboveBalancer-failOne": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(8)),
|
||||
addSectors(getSectors(8), true),
|
||||
waitPending(8),
|
||||
flush(getSectors(8), true, true),
|
||||
},
|
||||
},
|
||||
"addAte-belowBalancer-failOne": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(8)),
|
||||
addSectors(getSectors(8), false),
|
||||
waitPending(8),
|
||||
flush(getSectors(8), false, true),
|
||||
},
|
||||
@ -388,7 +393,7 @@ func (f fakeProver) AggregateSealProofs(aggregateInfo prooftypes.AggregateSealVe
|
||||
|
||||
var _ ffiwrapper.Prover = &fakeProver{}
|
||||
|
||||
func makeTs(t *testing.T, h abi.ChainEpoch) *types.TipSet {
|
||||
func makeBFTs(t *testing.T, basefee abi.TokenAmount, h abi.ChainEpoch) *types.TipSet {
|
||||
a, _ := address.NewFromString("t00")
|
||||
dummyCid, _ := cid.Parse("bafkqaaa")
|
||||
|
||||
@ -407,6 +412,8 @@ func makeTs(t *testing.T, h abi.ChainEpoch) *types.TipSet {
|
||||
|
||||
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS},
|
||||
BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS},
|
||||
|
||||
ParentBaseFee: basefee,
|
||||
},
|
||||
})
|
||||
if t != nil {
|
||||
@ -415,3 +422,7 @@ func makeTs(t *testing.T, h abi.ChainEpoch) *types.TipSet {
|
||||
|
||||
return ts
|
||||
}
|
||||
|
||||
func makeTs(t *testing.T, h abi.ChainEpoch) *types.TipSet {
|
||||
return makeBFTs(t, big.NewInt(0), h)
|
||||
}
|
||||
|
@ -8,21 +8,18 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
|
||||
address "github.com/filecoin-project/go-address"
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
big "github.com/filecoin-project/go-state-types/big"
|
||||
market "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
crypto "github.com/filecoin-project/go-state-types/crypto"
|
||||
dline "github.com/filecoin-project/go-state-types/dline"
|
||||
network "github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
api "github.com/filecoin-project/lotus/api"
|
||||
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
types "github.com/filecoin-project/lotus/chain/types"
|
||||
sealing "github.com/filecoin-project/lotus/storage/pipeline"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
// MockSealingAPI is a mock of SealingAPI interface.
|
||||
@ -198,21 +195,6 @@ func (mr *MockSealingAPIMockRecorder) StateMarketStorageDeal(arg0, arg1, arg2 in
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMarketStorageDeal", reflect.TypeOf((*MockSealingAPI)(nil).StateMarketStorageDeal), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateMarketStorageDealProposal mocks base method.
|
||||
func (m *MockSealingAPI) StateMarketStorageDealProposal(arg0 context.Context, arg1 abi.DealID, arg2 types.TipSetKey) (market.DealProposal, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateMarketStorageDealProposal", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(market.DealProposal)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateMarketStorageDealProposal indicates an expected call of StateMarketStorageDealProposal.
|
||||
func (mr *MockSealingAPIMockRecorder) StateMarketStorageDealProposal(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMarketStorageDealProposal", reflect.TypeOf((*MockSealingAPI)(nil).StateMarketStorageDealProposal), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateMinerAvailableBalance mocks base method.
|
||||
func (m *MockSealingAPI) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@ -379,10 +361,10 @@ func (mr *MockSealingAPIMockRecorder) StateSectorGetInfo(arg0, arg1, arg2, arg3
|
||||
}
|
||||
|
||||
// StateSectorPartition mocks base method.
|
||||
func (m *MockSealingAPI) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*sealing.SectorLocation, error) {
|
||||
func (m *MockSealingAPI) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorLocation, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateSectorPartition", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(*sealing.SectorLocation)
|
||||
ret0, _ := ret[0].(*miner0.SectorLocation)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
@ -8,17 +8,15 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
|
||||
address "github.com/filecoin-project/go-address"
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
big "github.com/filecoin-project/go-state-types/big"
|
||||
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
network "github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
api "github.com/filecoin-project/lotus/api"
|
||||
types "github.com/filecoin-project/lotus/chain/types"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
// MockCommitBatcherApi is a mock of CommitBatcherApi interface.
|
||||
@ -44,21 +42,6 @@ func (m *MockCommitBatcherApi) EXPECT() *MockCommitBatcherApiMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ChainBaseFee mocks base method.
|
||||
func (m *MockCommitBatcherApi) ChainBaseFee(arg0 context.Context, arg1 types.TipSetKey) (big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ChainBaseFee", arg0, arg1)
|
||||
ret0, _ := ret[0].(big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ChainBaseFee indicates an expected call of ChainBaseFee.
|
||||
func (mr *MockCommitBatcherApiMockRecorder) ChainBaseFee(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainBaseFee", reflect.TypeOf((*MockCommitBatcherApi)(nil).ChainBaseFee), arg0, arg1)
|
||||
}
|
||||
|
||||
// ChainHead mocks base method.
|
||||
func (m *MockCommitBatcherApi) ChainHead(arg0 context.Context) (*types.TipSet, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -8,16 +8,14 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
|
||||
address "github.com/filecoin-project/go-address"
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
big "github.com/filecoin-project/go-state-types/big"
|
||||
network "github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
api "github.com/filecoin-project/lotus/api"
|
||||
types "github.com/filecoin-project/lotus/chain/types"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
// MockPreCommitBatcherApi is a mock of PreCommitBatcherApi interface.
|
||||
@ -43,21 +41,6 @@ func (m *MockPreCommitBatcherApi) EXPECT() *MockPreCommitBatcherApiMockRecorder
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ChainBaseFee mocks base method.
|
||||
func (m *MockPreCommitBatcherApi) ChainBaseFee(arg0 context.Context, arg1 types.TipSetKey) (big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ChainBaseFee", arg0, arg1)
|
||||
ret0, _ := ret[0].(big.Int)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ChainBaseFee indicates an expected call of ChainBaseFee.
|
||||
func (mr *MockPreCommitBatcherApiMockRecorder) ChainBaseFee(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainBaseFee", reflect.TypeOf((*MockPreCommitBatcherApi)(nil).ChainBaseFee), arg0, arg1)
|
||||
}
|
||||
|
||||
// ChainHead mocks base method.
|
||||
func (m *MockPreCommitBatcherApi) ChainHead(arg0 context.Context) (*types.TipSet, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -32,7 +32,6 @@ type PreCommitBatcherApi interface {
|
||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
||||
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (big.Int, error)
|
||||
ChainHead(ctx context.Context) (*types.TipSet, error)
|
||||
ChainBaseFee(context.Context, types.TipSetKey) (abi.TokenAmount, error)
|
||||
StateNetworkVersion(ctx context.Context, tok types.TipSetKey) (network.Version, error)
|
||||
}
|
||||
|
||||
@ -193,11 +192,6 @@ func (b *PreCommitBatcher) maybeStartBatch(notif bool) ([]sealiface.PreCommitBat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bf, err := b.api.ChainBaseFee(b.mctx, ts.Key())
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("couldn't get base fee: %w", err)
|
||||
}
|
||||
|
||||
// TODO: Drop this once nv14 has come and gone
|
||||
nv, err := b.api.StateNetworkVersion(b.mctx, ts.Key())
|
||||
if err != nil {
|
||||
@ -205,14 +199,14 @@ func (b *PreCommitBatcher) maybeStartBatch(notif bool) ([]sealiface.PreCommitBat
|
||||
}
|
||||
|
||||
individual := false
|
||||
if !cfg.BatchPreCommitAboveBaseFee.Equals(big.Zero()) && bf.LessThan(cfg.BatchPreCommitAboveBaseFee) && nv >= network.Version14 {
|
||||
if !cfg.BatchPreCommitAboveBaseFee.Equals(big.Zero()) && ts.MinTicketBlock().ParentBaseFee.LessThan(cfg.BatchPreCommitAboveBaseFee) && nv >= network.Version14 {
|
||||
individual = true
|
||||
}
|
||||
|
||||
// todo support multiple batches
|
||||
var res []sealiface.PreCommitBatchRes
|
||||
if !individual {
|
||||
res, err = b.processBatch(cfg, ts.Key(), bf, nv)
|
||||
res, err = b.processBatch(cfg, ts.Key(), ts.MinTicketBlock().ParentBaseFee, nv)
|
||||
} else {
|
||||
res, err = b.processIndividually(cfg)
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
addSector := func(sn abi.SectorNumber) action {
|
||||
addSector := func(sn abi.SectorNumber, aboveBalancer bool) action {
|
||||
return func(t *testing.T, s *mocks.MockPreCommitBatcherApi, pcb *pipeline.PreCommitBatcher) promise {
|
||||
var pcres sealiface.PreCommitBatchRes
|
||||
var pcerr error
|
||||
@ -109,7 +109,12 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
SectorNumber: sn,
|
||||
}
|
||||
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeTs(t, 1), nil)
|
||||
basefee := big.NewInt(9999)
|
||||
if aboveBalancer {
|
||||
basefee = big.NewInt(10001)
|
||||
}
|
||||
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, basefee, 1), nil)
|
||||
|
||||
go func() {
|
||||
defer done.Unlock()
|
||||
@ -130,10 +135,10 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
addSectors := func(sectors []abi.SectorNumber) action {
|
||||
addSectors := func(sectors []abi.SectorNumber, aboveBalancer bool) action {
|
||||
as := make([]action, len(sectors))
|
||||
for i, sector := range sectors {
|
||||
as[i] = addSector(sector)
|
||||
as[i] = addSector(sector, aboveBalancer)
|
||||
}
|
||||
return actions(as...)
|
||||
}
|
||||
@ -153,8 +158,7 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
//stm: @CHAIN_STATE_MINER_INFO_001, @CHAIN_STATE_NETWORK_VERSION_001
|
||||
expectSend := func(expect []abi.SectorNumber) action {
|
||||
return func(t *testing.T, s *mocks.MockPreCommitBatcherApi, pcb *pipeline.PreCommitBatcher) promise {
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeTs(t, 1), nil)
|
||||
s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(big.NewInt(10001), nil)
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, big.NewInt(10001), 1), nil)
|
||||
s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version14, nil)
|
||||
|
||||
s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(api.MinerInfo{Owner: t0123, Worker: t0123}, nil)
|
||||
@ -174,8 +178,7 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
//stm: @CHAIN_STATE_MINER_INFO_001, @CHAIN_STATE_NETWORK_VERSION_001
|
||||
expectSendsSingle := func(expect []abi.SectorNumber) action {
|
||||
return func(t *testing.T, s *mocks.MockPreCommitBatcherApi, pcb *pipeline.PreCommitBatcher) promise {
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeTs(t, 1), nil)
|
||||
s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(big.NewInt(9999), nil)
|
||||
s.EXPECT().ChainHead(gomock.Any()).Return(makeBFTs(t, big.NewInt(9999), 1), nil)
|
||||
s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version14, nil)
|
||||
|
||||
s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(api.MinerInfo{Owner: t0123, Worker: t0123}, nil)
|
||||
@ -223,14 +226,14 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
}{
|
||||
"addSingle": {
|
||||
actions: []action{
|
||||
addSector(0),
|
||||
addSector(0, false),
|
||||
waitPending(1),
|
||||
flush([]abi.SectorNumber{0}),
|
||||
},
|
||||
},
|
||||
"addTwo": {
|
||||
actions: []action{
|
||||
addSectors(getSectors(2)),
|
||||
addSectors(getSectors(2), false),
|
||||
waitPending(2),
|
||||
flush(getSectors(2)),
|
||||
},
|
||||
@ -238,13 +241,13 @@ func TestPrecommitBatcher(t *testing.T) {
|
||||
"addMax": {
|
||||
actions: []action{
|
||||
expectSend(getSectors(maxBatch)),
|
||||
addSectors(getSectors(maxBatch)),
|
||||
addSectors(getSectors(maxBatch), true),
|
||||
},
|
||||
},
|
||||
"addMax-belowBaseFee": {
|
||||
actions: []action{
|
||||
expectSendsSingle(getSectors(maxBatch)),
|
||||
addSectors(getSectors(maxBatch)),
|
||||
addSectors(getSectors(maxBatch), false),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -37,11 +37,6 @@ var ErrTooManySectorsSealing = xerrors.New("too many sectors sealing")
|
||||
|
||||
var log = logging.Logger("sectors")
|
||||
|
||||
type SectorLocation struct {
|
||||
Deadline uint64
|
||||
Partition uint64
|
||||
}
|
||||
|
||||
var ErrSectorAllocated = errors.New("sectorNumber is allocated, but PreCommit info wasn't found on chain")
|
||||
|
||||
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/api.go -package=mocks . SealingAPI
|
||||
@ -54,7 +49,7 @@ type SealingAPI interface {
|
||||
// Can return ErrSectorAllocated in case precommit info wasn't found, but the sector number is marked as allocated
|
||||
StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error)
|
||||
StateSectorGetInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*SectorLocation, error)
|
||||
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error)
|
||||
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
||||
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (big.Int, error)
|
||||
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (big.Int, error)
|
||||
@ -68,7 +63,6 @@ type SealingAPI interface {
|
||||
StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tok types.TipSetKey) ([]api.Partition, error)
|
||||
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error)
|
||||
ChainHead(ctx context.Context) (*types.TipSet, error)
|
||||
ChainBaseFee(context.Context, types.TipSetKey) (abi.TokenAmount, error)
|
||||
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
||||
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tok types.TipSetKey) (abi.Randomness, error)
|
||||
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tok types.TipSetKey) (abi.Randomness, error)
|
||||
|
@ -50,7 +50,7 @@ func TestStateRecoverDealIDs(t *testing.T) {
|
||||
}
|
||||
|
||||
//stm: @CHAIN_STATE_MARKET_STORAGE_DEAL_001, @CHAIN_STATE_NETWORK_VERSION_001
|
||||
api.EXPECT().StateMarketStorageDealProposal(ctx, dealId, nil).Return(dealProposal, nil)
|
||||
api.EXPECT().StateMarketStorageDeal(ctx, dealId, nil).Return(&api2.MarketDeal{Proposal: dealProposal}, nil)
|
||||
|
||||
pc := idCid("publishCID")
|
||||
|
||||
|
@ -3,6 +3,7 @@ package sealing
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
@ -24,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
type TerminateBatcherApi interface {
|
||||
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*SectorLocation, error)
|
||||
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error)
|
||||
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error)
|
||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
||||
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
||||
@ -39,7 +40,7 @@ type TerminateBatcher struct {
|
||||
feeCfg config.MinerFeeConfig
|
||||
getConfig GetSealingConfigFunc
|
||||
|
||||
todo map[SectorLocation]*bitfield.BitField // MinerSectorLocation -> BitField
|
||||
todo map[lminer.SectorLocation]*bitfield.BitField // MinerSectorLocation -> BitField
|
||||
|
||||
waiting map[abi.SectorNumber][]chan cid.Cid
|
||||
|
||||
@ -57,7 +58,7 @@ func NewTerminationBatcher(mctx context.Context, maddr address.Address, api Term
|
||||
feeCfg: feeCfg,
|
||||
getConfig: getConfig,
|
||||
|
||||
todo: map[SectorLocation]*bitfield.BitField{},
|
||||
todo: map[lminer.SectorLocation]*bitfield.BitField{},
|
||||
waiting: map[abi.SectorNumber][]chan cid.Cid{},
|
||||
|
||||
notify: make(chan struct{}, 1),
|
||||
@ -228,7 +229,7 @@ func (b *TerminateBatcher) processBatch(notif, after bool) (*cid.Cid, error) {
|
||||
log.Infow("Sent TerminateSectors message", "cid", mcid, "from", from, "terminations", len(params.Terminations))
|
||||
|
||||
for _, t := range params.Terminations {
|
||||
delete(b.todo, SectorLocation{
|
||||
delete(b.todo, lminer.SectorLocation{
|
||||
Deadline: t.Deadline,
|
||||
Partition: t.Partition,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user