From 19c3232d2feea2cdbe87de449c4dd3b660883fbb Mon Sep 17 00:00:00 2001 From: Aayush Date: Sat, 10 Sep 2022 10:34:47 -0400 Subject: [PATCH] more fixes --- chain/actors/agen/main.go | 2 +- .../builtin/multisig/message.go.template | 6 ++-- chain/actors/builtin/multisig/message0.go | 4 +-- chain/actors/builtin/multisig/message2.go | 4 +-- chain/actors/builtin/multisig/message3.go | 4 +-- chain/actors/builtin/multisig/message4.go | 4 +-- chain/actors/builtin/multisig/message5.go | 4 +-- chain/actors/builtin/multisig/message6.go | 4 +-- chain/actors/builtin/multisig/message7.go | 4 +-- chain/actors/builtin/multisig/message8.go | 4 +-- chain/actors/builtin/multisig/message9.go | 4 +-- chain/gen/genesis/miners.go | 2 +- cli/chain_test.go | 3 +- cli/filplus.go | 33 ++++++++++++++----- extern/filecoin-ffi | 2 +- itests/deadlines_test.go | 2 +- itests/multisig/suite.go | 2 -- itests/verifreg_test.go | 4 +-- .../ondealsectorcommitted_test.go | 6 ++-- storage/pipeline/precommit_batch.go | 22 +++---------- storage/pipeline/states_sealing.go | 20 ++++++----- storage/pipeline/utils.go | 12 +++++++ 22 files changed, 83 insertions(+), 69 deletions(-) diff --git a/chain/actors/agen/main.go b/chain/actors/agen/main.go index bb2ca8bd3..6797a5ba5 100644 --- a/chain/actors/agen/main.go +++ b/chain/actors/agen/main.go @@ -231,7 +231,7 @@ func generateRegistry(registryPath string) error { return nil // skip } - return xerrors.Errorf("loading builtin template file: %w", err) + return xerrors.Errorf("loading registry template file: %w", err) } tpl := template.Must(template.New("").Funcs(template.FuncMap{ diff --git a/chain/actors/builtin/multisig/message.go.template b/chain/actors/builtin/multisig/message.go.template index 84dd308f4..1e1559968 100644 --- a/chain/actors/builtin/multisig/message.go.template +++ b/chain/actors/builtin/multisig/message.go.template @@ -10,15 +10,13 @@ import ( builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" multisig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig" - builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" {{else}} actorstypes "github.com/filecoin-project/go-state-types/actors" multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}multisig" init{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/init" - builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" {{end}} - + builtintypes "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lotus/chain/actors" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/types" @@ -90,7 +88,7 @@ func (m message{{.v}}) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin{{.latestVersion}}.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message0.go b/chain/actors/builtin/multisig/message0.go index 1431b0366..7dbdf444c 100644 --- a/chain/actors/builtin/multisig/message0.go +++ b/chain/actors/builtin/multisig/message0.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" @@ -67,7 +67,7 @@ func (m message0) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message2.go b/chain/actors/builtin/multisig/message2.go index 5120ae0ee..91ad17b84 100644 --- a/chain/actors/builtin/multisig/message2.go +++ b/chain/actors/builtin/multisig/message2.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" @@ -64,7 +64,7 @@ func (m message2) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message3.go b/chain/actors/builtin/multisig/message3.go index 5194cbcd4..4124e00c8 100644 --- a/chain/actors/builtin/multisig/message3.go +++ b/chain/actors/builtin/multisig/message3.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" @@ -64,7 +64,7 @@ func (m message3) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message4.go b/chain/actors/builtin/multisig/message4.go index cbf3cd841..33449df75 100644 --- a/chain/actors/builtin/multisig/message4.go +++ b/chain/actors/builtin/multisig/message4.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init" multisig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig" @@ -64,7 +64,7 @@ func (m message4) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message5.go b/chain/actors/builtin/multisig/message5.go index beca1690d..46c35dabc 100644 --- a/chain/actors/builtin/multisig/message5.go +++ b/chain/actors/builtin/multisig/message5.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init" multisig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig" @@ -64,7 +64,7 @@ func (m message5) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message6.go b/chain/actors/builtin/multisig/message6.go index 39c2dd3b1..f528cfbb5 100644 --- a/chain/actors/builtin/multisig/message6.go +++ b/chain/actors/builtin/multisig/message6.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init" multisig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig" @@ -64,7 +64,7 @@ func (m message6) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message7.go b/chain/actors/builtin/multisig/message7.go index 5f67df4a2..6e62dad13 100644 --- a/chain/actors/builtin/multisig/message7.go +++ b/chain/actors/builtin/multisig/message7.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init" multisig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig" @@ -64,7 +64,7 @@ func (m message7) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message8.go b/chain/actors/builtin/multisig/message8.go index 8d26d0b58..f627a695f 100644 --- a/chain/actors/builtin/multisig/message8.go +++ b/chain/actors/builtin/multisig/message8.go @@ -6,7 +6,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" @@ -69,7 +69,7 @@ func (m message8) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message9.go b/chain/actors/builtin/multisig/message9.go index 727c6e960..62f6ff558 100644 --- a/chain/actors/builtin/multisig/message9.go +++ b/chain/actors/builtin/multisig/message9.go @@ -6,7 +6,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" - builtin9 "github.com/filecoin-project/go-state-types/builtin" + builtintypes "github.com/filecoin-project/go-state-types/builtin" init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" @@ -69,7 +69,7 @@ func (m message9) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin9.MethodsInit.Exec, + Method: builtintypes.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index 55156fda6..385e89c00 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -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) } diff --git a/cli/chain_test.go b/cli/chain_test.go index 9fd46724e..80af1a6e7 100644 --- a/cli/chain_test.go +++ b/cli/chain_test.go @@ -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) }) } diff --git a/cli/filplus.go b/cli/filplus.go index 5374a9f40..66de32d0c 100644 --- a/cli/filplus.go +++ b/cli/filplus.go @@ -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" @@ -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 } @@ -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) } diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index b3185c5fb..945bc4ae5 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit b3185c5fbe05a1032fde707fee2f95ef117461d0 +Subproject commit 945bc4ae58de63735e430607166d1a9c3c7dd43a diff --git a/itests/deadlines_test.go b/itests/deadlines_test.go index a2b0bde88..a00c33b68 100644 --- a/itests/deadlines_test.go +++ b/itests/deadlines_test.go @@ -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() diff --git a/itests/multisig/suite.go b/itests/multisig/suite.go index 39edfdc4e..9a81d0bf9 100644 --- a/itests/multisig/suite.go +++ b/itests/multisig/suite.go @@ -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= 0 false diff --git a/itests/verifreg_test.go b/itests/verifreg_test.go index 9132cf28b..9b1c71162 100644 --- a/itests/verifreg_test.go +++ b/itests/verifreg_test.go @@ -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" @@ -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{} diff --git a/markets/storageadapter/ondealsectorcommitted_test.go b/markets/storageadapter/ondealsectorcommitted_test.go index 5cb5230b4..2ed1d2f39 100644 --- a/markets/storageadapter/ondealsectorcommitted_test.go +++ b/markets/storageadapter/ondealsectorcommitted_test.go @@ -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}, @@ -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}, @@ -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}, diff --git a/storage/pipeline/precommit_batch.go b/storage/pipeline/precommit_batch.go index 94b8d272f..6ee6aed93 100644 --- a/storage/pipeline/precommit_batch.go +++ b/storage/pipeline/precommit_batch.go @@ -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) @@ -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) } diff --git a/storage/pipeline/states_sealing.go b/storage/pipeline/states_sealing.go index 96e1f5a7e..c31c36335 100644 --- a/storage/pipeline/states_sealing.go +++ b/storage/pipeline/states_sealing.go @@ -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) @@ -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 @@ -418,7 +420,7 @@ 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 { @@ -426,12 +428,12 @@ func (m *Sealing) handleSubmitPreCommitBatch(ctx statemachine.Context, sector Se 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) diff --git a/storage/pipeline/utils.go b/storage/pipeline/utils.go index 69a8f914c..3f8d534cb 100644 --- a/storage/pipeline/utils.go +++ b/storage/pipeline/utils.go @@ -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" @@ -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, + } +}