Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Sep 10, 2022
1 parent 7609019 commit f2a8bd6
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 45 deletions.
2 changes: 1 addition & 1 deletion chain/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
}

rawPow = big.Add(rawPow, big.NewInt(int64(m.SectorSize)))
sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, big.Zero(), big.NewInt(int64(preseal.Deal.PieceSize)))
sectorWeight := builtin.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, big.Zero(), markettypes.DealWeight(&preseal.Deal))
minerInfos[i].sectorWeight = append(minerInfos[i].sectorWeight, sectorWeight)
qaPow = big.Add(qaPow, sectorWeight)
}
Expand Down
3 changes: 2 additions & 1 deletion cli/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ func TestInspectUsage(t *testing.T) {
// check for gas by sender
assert.Contains(t, out, "By Sender")
// check for gas by method
assert.Contains(t, out, "By Method:\nSend")
methodStr := fmt.Sprintf("By Method:\n%d", builtin.MethodSend)
assert.Contains(t, out, methodStr)
})
}

Expand Down
33 changes: 25 additions & 8 deletions cli/filplus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v8/verifreg"
verifregtypes8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg"
verifregtypes9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/blockstore"
Expand Down Expand Up @@ -94,7 +96,7 @@ var filplusVerifyClientCmd = &cli.Command{
}

// TODO: This should be abstracted over actor versions
params, err := actors.SerializeParams(&verifregtypes.AddVerifiedClientParams{Address: target, Allowance: allowance})
params, err := actors.SerializeParams(&verifregtypes9.AddVerifiedClientParams{Address: target, Allowance: allowance})
if err != nil {
return err
}
Expand Down Expand Up @@ -359,15 +361,30 @@ var filplusSignRemoveDataCapProposal = &cli.Command{
}
}

params := verifregtypes.RemoveDataCapProposal{
RemovalProposalID: id,
DataCapAmount: allowanceToRemove,
VerifiedClient: clientIdAddr,
nv, err := api.StateNetworkVersion(ctx, types.EmptyTSK)
if err != nil {
return xerrors.Errorf("failed to get network version: %w", err)
}

paramBuf := new(bytes.Buffer)
paramBuf.WriteString(verifregtypes.SignatureDomainSeparation_RemoveDataCap)
err = params.MarshalCBOR(paramBuf)
paramBuf.WriteString(verifregtypes9.SignatureDomainSeparation_RemoveDataCap)
if nv <= network.Version16 {
params := verifregtypes8.RemoveDataCapProposal{
RemovalProposalID: id,
DataCapAmount: allowanceToRemove,
VerifiedClient: clientIdAddr,
}

err = params.MarshalCBOR(paramBuf)
} else {
params := verifregtypes9.RemoveDataCapProposal{
RemovalProposalID: verifregtypes9.RmDcProposalID{ProposalID: id},
DataCapAmount: allowanceToRemove,
VerifiedClient: clientIdAddr,
}

err = params.MarshalCBOR(paramBuf)
}
if err != nil {
return xerrors.Errorf("failed to marshall paramBuf: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion itests/deadlines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestDeadlineToggling(t *testing.T) {

//stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001
//stm: @MINER_SECTOR_LIST_001
kit.Expensive(t)
//kit.Expensive(t)

kit.QuietMiningLogs()

Expand Down
2 changes: 0 additions & 2 deletions itests/multisig/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ func RunMultisigTests(t *testing.T, client *kit.TestFullNode) {
require.Regexp(t, regexp.MustCompile("Balance: 0.000000000000001 FIL"), out)
// Expect 1 transaction
require.Regexp(t, regexp.MustCompile(`Transactions:\s*1`), out)
// Expect transaction to be "AddSigner"
require.Regexp(t, regexp.MustCompile(`AddSigner`), out)

// Approve adding the new address
// msig add-approve --from=<addr> <msig> <addr> 0 <addr> false
Expand Down
4 changes: 2 additions & 2 deletions itests/verifreg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
verifregst "github.com/filecoin-project/go-state-types/builtin/v8/verifreg"
verifregst "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
"github.com/filecoin-project/go-state-types/network"

lapi "github.com/filecoin-project/lotus/api"
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestRemoveDataCap(t *testing.T) {
removeProposal := verifregst.RemoveDataCapProposal{
VerifiedClient: verifiedClientID,
DataCapAmount: removeDatacap,
RemovalProposalID: proposalID,
RemovalProposalID: verifregst.RmDcProposalID{ProposalID: proposalID},
}

buf := bytes.Buffer{}
Expand Down
6 changes: 3 additions & 3 deletions markets/storageadapter/ondealsectorcommitted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) {
},
matchStates: []matchState{
{
msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.SectorPreCommitInfo{
msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.PreCommitSectorParams{
SectorNumber: sectorNumber,
SealedCID: sealedCid,
DealIDs: []abi.DealID{dealID},
Expand All @@ -114,7 +114,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) {
},
matchStates: []matchState{
{
msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.SectorPreCommitInfo{
msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.PreCommitSectorParams{
SectorNumber: sectorNumber,
SealedCID: sealedCid,
DealIDs: []abi.DealID{dealID},
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) {
currentDealInfoErr2: errors.New("something went wrong"),
matchStates: []matchState{
{
msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.SectorPreCommitInfo{
msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.PreCommitSectorParams{
SectorNumber: sectorNumber,
SealedCID: sealedCid,
DealIDs: []abi.DealID{dealID},
Expand Down
22 changes: 4 additions & 18 deletions storage/pipeline/precommit_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,15 @@ func (b *PreCommitBatcher) processIndividually(cfg sealiface.Config) ([]sealifac
return res, nil
}

func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi api.MinerInfo, avail *abi.TokenAmount, params *preCommitEntry) (cid.Cid, error) {
msgParams := miner.PreCommitSectorParams{
SealProof: params.pci.SealProof,
SectorNumber: params.pci.SectorNumber,
SealedCID: params.pci.SealedCID,
SealRandEpoch: params.pci.SealRandEpoch,
DealIDs: params.pci.DealIDs,
Expiration: params.pci.Expiration,
}
func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi api.MinerInfo, avail *abi.TokenAmount, entry *preCommitEntry) (cid.Cid, error) {
msgParams := infoToPreCommitSectorParams(entry.pci)
enc := new(bytes.Buffer)

if err := msgParams.MarshalCBOR(enc); err != nil {
return cid.Undef, xerrors.Errorf("marshaling precommit params: %w", err)
}

deposit := params.deposit
deposit := entry.deposit
if cfg.CollateralFromMinerBalance {
c := big.Sub(deposit, *avail)
*avail = big.Sub(*avail, deposit)
Expand Down Expand Up @@ -336,14 +329,7 @@ func (b *PreCommitBatcher) processBatch(cfg sealiface.Config, tsk types.TipSetKe
}

res.Sectors = append(res.Sectors, p.pci.SectorNumber)
params.Sectors = append(params.Sectors, miner.PreCommitSectorParams{
SealProof: p.pci.SealProof,
SectorNumber: p.pci.SectorNumber,
SealedCID: p.pci.SealedCID,
SealRandEpoch: p.pci.SealRandEpoch,
DealIDs: p.pci.DealIDs,
Expiration: p.pci.Expiration,
})
params.Sectors = append(params.Sectors, *infoToPreCommitSectorParams(p.pci))
deposit = big.Add(deposit, p.deposit)
}

Expand Down
20 changes: 11 additions & 9 deletions storage/pipeline/states_sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (m *Sealing) handlePreCommit2(ctx statemachine.Context, sector SectorInfo)
})
}

func (m *Sealing) preCommitParams(ctx statemachine.Context, sector SectorInfo) (*miner.SectorPreCommitInfo, big.Int, types.TipSetKey, error) {
func (m *Sealing) preCommitInfo(ctx statemachine.Context, sector SectorInfo) (*miner.SectorPreCommitInfo, big.Int, types.TipSetKey, error) {
ts, err := m.Api.ChainHead(ctx.Context())
if err != nil {
log.Errorf("handlePreCommitting: api error, not proceeding: %+v", err)
Expand Down Expand Up @@ -381,14 +381,16 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
}
}

params, pcd, tsk, err := m.preCommitParams(ctx, sector)
info, pcd, tsk, err := m.preCommitInfo(ctx, sector)
if err != nil {
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("preCommitParams: %w", err)})
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("preCommitInfo: %w", err)})
}
if params == nil {
return nil // event was sent in preCommitParams
if info == nil {
return nil // event was sent in preCommitInfo
}

params := infoToPreCommitSectorParams(info)

deposit, err := collateralSendAmount(ctx.Context(), m.Api, m.maddr, cfg, pcd)
if err != nil {
return err
Expand Down Expand Up @@ -418,20 +420,20 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)})
}

return ctx.Send(SectorPreCommitted{Message: mcid, PreCommitDeposit: pcd, PreCommitInfo: *params})
return ctx.Send(SectorPreCommitted{Message: mcid, PreCommitDeposit: pcd, PreCommitInfo: *info})
}

func (m *Sealing) handleSubmitPreCommitBatch(ctx statemachine.Context, sector SectorInfo) error {
if sector.CommD == nil || sector.CommR == nil {
return ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("sector had nil commR or commD")})
}

params, deposit, _, err := m.preCommitParams(ctx, sector)
params, deposit, _, err := m.preCommitInfo(ctx, sector)
if err != nil {
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("preCommitParams: %w", err)})
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("preCommitInfo: %w", err)})
}
if params == nil {
return nil // event was sent in preCommitParams
return nil // event was sent in preCommitInfo
}

res, err := m.precommiter.AddPreCommit(ctx.Context(), sector, deposit, params)
Expand Down
12 changes: 12 additions & 0 deletions storage/pipeline/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -111,3 +112,14 @@ func sendMsg(ctx context.Context, sa interface {

return smsg.Cid(), nil
}

func infoToPreCommitSectorParams(info *miner.SectorPreCommitInfo) *miner.PreCommitSectorParams {
return &miner.PreCommitSectorParams{
SealProof: info.SealProof,
SectorNumber: info.SectorNumber,
SealedCID: info.SealedCID,
SealRandEpoch: info.SealRandEpoch,
DealIDs: info.DealIDs,
Expiration: info.Expiration,
}
}

0 comments on commit f2a8bd6

Please sign in to comment.