diff --git a/.circleci/config.yml b/.circleci/config.yml index c218331ee..e99c88099 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,7 +83,6 @@ commands: name: fetch all tags command: | git fetch --all - packer_build: description: "Run a packer build" parameters: @@ -197,6 +196,7 @@ jobs: environment: TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >> SKIP_CONFORMANCE: "1" + LOTUS_SRC_DIR: /home/circleci/project command: | mkdir -p /tmp/test-reports/<< parameters.suite >> mkdir -p /tmp/test-artifacts @@ -223,7 +223,7 @@ jobs: test-conformance: description: | - Run tests using a corpus of interoperable test vectors for Filecoin + Run tests using a corpus of interoperable test vectors for Filecoin implementations to test their correctness and compliance with the Filecoin specifications. parameters: @@ -803,6 +803,11 @@ workflows: suite: itest-deals_concurrent target: "./itests/deals_concurrent_test.go" + - test: + name: test-itest-deals_invalid_utf8_label + suite: itest-deals_invalid_utf8_label + target: "./itests/deals_invalid_utf8_label_test.go" + - test: name: test-itest-deals_max_staging_deals suite: itest-deals_max_staging_deals diff --git a/.circleci/template.yml b/.circleci/template.yml index 233771988..437eec9d3 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -83,7 +83,6 @@ commands: name: fetch all tags command: | git fetch --all - packer_build: description: "Run a packer build" parameters: @@ -197,6 +196,7 @@ jobs: environment: TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >> SKIP_CONFORMANCE: "1" + LOTUS_SRC_DIR: /home/circleci/project command: | mkdir -p /tmp/test-reports/<< parameters.suite >> mkdir -p /tmp/test-artifacts @@ -223,7 +223,7 @@ jobs: test-conformance: description: | - Run tests using a corpus of interoperable test vectors for Filecoin + Run tests using a corpus of interoperable test vectors for Filecoin implementations to test their correctness and compliance with the Filecoin specifications. parameters: diff --git a/.gitignore b/.gitignore index a6fab7331..1db5e2858 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,6 @@ build/paramfetch.sh /darwin /linux *.snap -build/builtin-actors *-fuzz.zip /chain/types/work_msg/ @@ -49,3 +48,6 @@ bin/ipget bin/tmp/* .idea scratchpad + +build/builtin-actors/v* +build/builtin-actors/*.car diff --git a/CHANGELOG.md b/CHANGELOG.md index e4750b4a6..44402d55a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,69 @@ # Lotus changelog +# 1.15.3-rc2 / 2022-05-24 + +This is the second rc of an optional release of lotus, detailed changelog will be updated later. + +- fix: Make deal making logs much less noisy ([filecoin-project/lotus#8622](https://github.com/filecoin-project/lotus/pull/8622)) +- chore: merge releases back into master ([filecoin-project/lotus#8638](https://github.com/filecoin-project/lotus/pull/8638)) +- fix: mpool: avoid deadlock on unsubscribe ([filecoin-project/lotus#8635](https://github.com/filecoin-project/lotus/pull/8635)) +- feat: api: add StateGetNetworkParams api ([filecoin-project/lotus#8546](https://github.com/filecoin-project/lotus/pull/8546)) +- fix: update StatApplied when fvm apply message ([filecoin-project/lotus#8545](https://github.com/filecoin-project/lotus/pull/8545)) +- fix: ci: build macos and linux assets on tagged releases ([filecoin-project/lotus#8597](https://github.com/filecoin-project/lotus/pull/8597)) +- fix: Clean up vanilla proof fetching errors for proper display ([filecoin-project/lotus#8564](https://github.com/filecoin-project/lotus/pull/8564)) +- fix: Make markets logger less noisy when doing retrievals ([filecoin-project/lotus#8604](https://github.com/filecoin-project/lotus/pull/8604)) +- fix: test: Fix flaky TestGatewayWalletMsig ([filecoin-project/lotus#8601](https://github.com/filecoin-project/lotus/pull/8601)) +- chore:ci:make codecov quiet ([filecoin-project/lotus#8600](https://github.com/filecoin-project/lotus/pull/8600)) +- fix: lotus-wallet: correct network in version ([filecoin-project/lotus#8563](https://github.com/filecoin-project/lotus/pull/8563)) +- chore: cli: Alias cli commands for uniformity ([filecoin-project/lotus#8587](https://github.com/filecoin-project/lotus/pull/8587)) +- chore: .gitignore: ignore built in actor bundles ([filecoin-project/lotus#8590](https://github.com/filecoin-project/lotus/pull/8590)) +- fix: worker: Download proofs if PRU2 is enabled ([filecoin-project/lotus#8555](https://github.com/filecoin-project/lotus/pull/8555)) +- ci: deps: macos build deps ([filecoin-project/lotus#8581](https://github.com/filecoin-project/lotus/pull/8581)) +- chore:chore:chore ([filecoin-project/lotus#8586](https://github.com/filecoin-project/lotus/pull/8586)) +- fix: sealing: Finalize snap sectors before submitting proofs ([filecoin-project/lotus#8582](https://github.com/filecoin-project/lotus/pull/8582)) +- feat: vm: add actor error backtraces to FVM ([filecoin-project/lotus#8524](https://github.com/filecoin-project/lotus/pull/8524)) +- sealing: DataCid on workers ([filecoin-project/lotus#8557](https://github.com/filecoin-project/lotus/pull/8557)) +- fix: ux: update `lotus-wallet run` description ([filecoin-project/lotus#8528](https://github.com/filecoin-project/lotus/pull/8528)) +- fix: market: Infer index provider topic from network name by default ([filecoin-project/lotus#8526](https://github.com/filecoin-project/lotus/pull/8526)) +- deps: update go-libp2p@v0.19 ([filecoin-project/lotus#8511](https://github.com/filecoin-project/lotus/pull/8511)) +- chore: fix lint issue ([filecoin-project/lotus#8531](https://github.com/filecoin-project/lotus/pull/8531)) +- chore: ci: update golang and go-ipfs ([filecoin-project/lotus#8512](https://github.com/filecoin-project/lotus/pull/8512)) +- feat: FVM: Support exectraces ([filecoin-project/lotus#8514](https://github.com/filecoin-project/lotus/pull/8514)) +- Feat: API: Implement StateLookupRobustAddress ([filecoin-project/lotus#8486](https://github.com/filecoin-project/lotus/pull/8486)) +- fix:sealing:check index out of bounds against correct param length not return length ([filecoin-project/lotus#8475](https://github.com/filecoin-project/lotus/pull/8475)) +- add 1475 bootstrapper ([filecoin-project/lotus#8495](https://github.com/filecoin-project/lotus/pull/8495)) +- Bump version for xtools ([filecoin-project/lotus#8494](https://github.com/filecoin-project/lotus/pull/8494)) +- fix: storiface: Make FSOverhead numbers more accurate ([filecoin-project/lotus#8481](https://github.com/filecoin-project/lotus/pull/8481)) +- fix: node: fix comment for IndexProvider ([filecoin-project/lotus#8480](https://github.com/filecoin-project/lotus/pull/8480)) +- ux: wallet: update delete usage ([filecoin-project/lotus#8442](https://github.com/filecoin-project/lotus/pull/8442)) +- Fail to add expired precommits to a batch ([filecoin-project/lotus#8479](https://github.com/filecoin-project/lotus/pull/8479)) +- chore: config: default-disable kvlog ([filecoin-project/lotus#8477](https://github.com/filecoin-project/lotus/pull/8477)) +- chore: version: bump the version to v1.15.3-dev ([filecoin-project/lotus#8473](https://github.com/filecoin-project/lotus/pull/8473)) +- github.com/filecoin-project/specs-storage (v0.2.2 -> v0.2.3-0.20220426183226-1a0a63c5990f): + +## Contributors + +| Contributor | Commits | Lines ± | Files Changed | +|-------------|---------|---------|---------------| +| Steven Allen | 4 | +607/-95 | 19 | +| Łukasz Magiera | 9 | +550/-37 | 43 | +| Geoff Stuart | 5 | +279/-219 | 27 | +| simlecode | 1 | +306/-39 | 20 | +| Aayush | 1 | +256/-34 | 10 | +| zenground0 | 11 | +214/-66 | 31 | +| Aayush Rajasekaran | 2 | +149/-99 | 8 | +| vyzo | 3 | +125/-81 | 4 | +| Masih H. Derkani | 1 | +134/-15 | 7 | +| Travis Person | 3 | +24/-32 | 6 | +| Rjan | 6 | +16/-16 | 9 | +| jennijuju | 3 | +9/-8 | 15 | +| Rob Quist | 3 | +12/-4 | 3 | +| Icarus9913 | 1 | +3/-3 | 3 | +| swift-mx | 1 | +3/-0 | 1 | +| Phi-rjan | 1 | +1/-1 | 1 | +| lifei | 1 | +1/-0 | 1 | + + # 1.15.2 / 2022-05-06 This is a highly recommended feature lotus release v1.15.2. This feature release introduces many new features and for SPs, including PoSt workers, sealing scheduler, snap deal queue and so on. diff --git a/Makefile b/Makefile index 1b547e808..a9883afb3 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ CLEAN+=build/.update-modules deps: $(BUILD_DEPS) .PHONY: deps -build-devnets: build lotus-seed lotus-shed lotus-wallet lotus-gateway +build-devnets: build lotus-seed lotus-shed lotus-wallet lotus-gateway lotus-fountain lotus-stats .PHONY: build-devnets debug: GOFLAGS+=-tags=debug @@ -169,7 +169,7 @@ BINS+=lotus-fountain lotus-bench: rm -f lotus-bench - $(GOCC) build -o lotus-bench ./cmd/lotus-bench + $(GOCC) build $(GOFLAGS) -o lotus-bench ./cmd/lotus-bench .PHONY: lotus-bench BINS+=lotus-bench diff --git a/api/api_full.go b/api/api_full.go index 2a113dbaf..7abe419aa 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -20,11 +20,12 @@ import ( "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/storagemarket" + "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" apitypes "github.com/filecoin-project/lotus/api/types" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/power" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -170,14 +171,6 @@ type FullNode interface { // ChainBlockstoreInfo returns some basic information about the blockstore ChainBlockstoreInfo(context.Context) (map[string]interface{}, error) //perm:read - // MethodGroup: Beacon - // The Beacon method group contains methods for interacting with the random beacon (DRAND) - - // BeaconGetEntry returns the beacon entry for the given filecoin epoch. If - // the entry has not yet been produced, the call will block until the entry - // becomes available - BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) //perm:read - // GasEstimateFeeCap estimates gas fee cap GasEstimateFeeCap(context.Context, *types.Message, int64, types.TipSetKey) (types.BigInt, error) //perm:read @@ -443,7 +436,7 @@ type FullNode interface { // StateMinerPower returns the power of the indicated miner StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error) //perm:read // StateMinerInfo returns info about the indicated miner - StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) //perm:read + StateMinerInfo(context.Context, address.Address, types.TipSetKey) (MinerInfo, error) //perm:read // StateMinerDeadlines returns all the proving deadlines for the given miner StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]Deadline, error) //perm:read // StateMinerPartitions returns all partitions in the specified deadline @@ -469,9 +462,9 @@ type FullNode interface { // expiration epoch StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read // StateSectorExpiration returns epoch at which given sector will expire - StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) //perm:read + StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read // StateSectorPartition finds deadline/partition with the specified sector - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) //perm:read + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) //perm:read // StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed // // NOTE: If a replacing message is found on chain, this method will return @@ -517,7 +510,7 @@ type FullNode interface { // StateMarketParticipants returns the Escrow and Locked balances of every participant in the Storage Market StateMarketParticipants(context.Context, types.TipSetKey) (map[string]MarketBalance, error) //perm:read // StateMarketDeals returns information about every deal in the Storage Market - StateMarketDeals(context.Context, types.TipSetKey) (map[string]MarketDeal, error) //perm:read + StateMarketDeals(context.Context, types.TipSetKey) (map[string]*MarketDeal, error) //perm:read // StateMarketStorageDeal returns information about the indicated deal StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*MarketDeal, error) //perm:read // StateLookupID retrieves the ID address of the given address @@ -592,6 +585,11 @@ type FullNode interface { // StateGetRandomnessFromBeacon is used to sample the beacon for randomness. StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read + // StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If + // the entry has not yet been produced, the call will block until the entry + // becomes available + StateGetBeaconEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) //perm:read + // StateGetNetworkParams return current network params StateGetNetworkParams(ctx context.Context) (*NetworkParams, error) //perm:read diff --git a/api/api_gateway.go b/api/api_gateway.go index d02c11a03..6e92c6e0d 100644 --- a/api/api_gateway.go +++ b/api/api_gateway.go @@ -9,8 +9,8 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" apitypes "github.com/filecoin-project/lotus/api/types" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) @@ -56,7 +56,7 @@ type Gateway interface { StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (MarketBalance, error) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*MarketDeal, error) - StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) + StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (MinerInfo, error) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error) StateNetworkVersion(context.Context, types.TipSetKey) (apitypes.NetworkVersion, error) diff --git a/api/api_storage.go b/api/api_storage.go index 9de54ff3e..1985ddd5c 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -5,8 +5,8 @@ import ( "context" "time" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/google/uuid" "github.com/ipfs/go-cid" @@ -15,8 +15,8 @@ import ( "github.com/filecoin-project/go-address" datatransfer "github.com/filecoin-project/go-data-transfer" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin/v8/market" abinetwork "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/go-fil-markets/piecestore" @@ -165,7 +165,7 @@ type StorageMiner interface { StorageStat(ctx context.Context, id storiface.ID) (fsutil.FsStat, error) //perm:admin MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error //perm:write - MarketListDeals(ctx context.Context) ([]MarketDeal, error) //perm:read + MarketListDeals(ctx context.Context) ([]*MarketDeal, error) //perm:read MarketListRetrievalDeals(ctx context.Context) ([]retrievalmarket.ProviderDealState, error) //perm:read MarketGetDealUpdates(ctx context.Context) (<-chan storagemarket.MinerDeal, error) //perm:read MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error) //perm:read @@ -245,7 +245,7 @@ type StorageMiner interface { RuntimeSubsystems(ctx context.Context) (MinerSubsystems, error) //perm:read DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error //perm:admin - DealsList(ctx context.Context) ([]MarketDeal, error) //perm:admin + DealsList(ctx context.Context) ([]*MarketDeal, error) //perm:admin DealsConsiderOnlineStorageDeals(context.Context) (bool, error) //perm:admin DealsSetConsiderOnlineStorageDeals(context.Context, bool) error //perm:admin DealsConsiderOnlineRetrievalDeals(context.Context) (bool, error) //perm:admin diff --git a/api/api_worker.go b/api/api_worker.go index cd4cde151..33668c0b8 100644 --- a/api/api_worker.go +++ b/api/api_worker.go @@ -3,12 +3,12 @@ package api import ( "context" + "github.com/filecoin-project/go-state-types/proof" + "github.com/google/uuid" "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - "github.com/filecoin-project/lotus/extern/sector-storage/sealtasks" "github.com/filecoin-project/lotus/extern/sector-storage/storiface" "github.com/filecoin-project/specs-storage/storage" diff --git a/api/cbor_gen.go b/api/cbor_gen.go index 62e523df1..40982779e 100644 --- a/api/cbor_gen.go +++ b/api/cbor_gen.go @@ -9,8 +9,8 @@ import ( "sort" abi "github.com/filecoin-project/go-state-types/abi" - market "github.com/filecoin-project/specs-actors/actors/builtin/market" - paych "github.com/filecoin-project/specs-actors/actors/builtin/paych" + market "github.com/filecoin-project/go-state-types/builtin/v8/market" + paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" diff --git a/api/docgen/docgen.go b/api/docgen/docgen.go index f11b22c60..cebf15d66 100644 --- a/api/docgen/docgen.go +++ b/api/docgen/docgen.go @@ -146,6 +146,10 @@ func init() { addExample(map[string]api.MarketDeal{ "t026363": ExampleValue("init", reflect.TypeOf(api.MarketDeal{}), nil).(api.MarketDeal), }) + addExample(map[string]*api.MarketDeal{ + "t026363": ExampleValue("init", reflect.TypeOf(&api.MarketDeal{}), nil).(*api.MarketDeal), + }) + addExample(map[string]api.MarketBalance{ "t026363": ExampleValue("init", reflect.TypeOf(api.MarketBalance{}), nil).(api.MarketBalance), }) diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index f8ab754ed..689a67834 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -17,18 +17,18 @@ import ( auth "github.com/filecoin-project/go-jsonrpc/auth" 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" + paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" 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" apitypes "github.com/filecoin-project/lotus/api/types" - miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" types "github.com/filecoin-project/lotus/chain/types" alerting "github.com/filecoin-project/lotus/journal/alerting" dtypes "github.com/filecoin-project/lotus/node/modules/dtypes" imports "github.com/filecoin-project/lotus/node/repo/imports" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - paych "github.com/filecoin-project/specs-actors/actors/builtin/paych" gomock "github.com/golang/mock/gomock" uuid "github.com/google/uuid" cid "github.com/ipfs/go-cid" @@ -91,21 +91,6 @@ func (mr *MockFullNodeMockRecorder) AuthVerify(arg0, arg1 interface{}) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthVerify", reflect.TypeOf((*MockFullNode)(nil).AuthVerify), arg0, arg1) } -// BeaconGetEntry mocks base method. -func (m *MockFullNode) BeaconGetEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BeaconGetEntry", arg0, arg1) - ret0, _ := ret[0].(*types.BeaconEntry) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// BeaconGetEntry indicates an expected call of BeaconGetEntry. -func (mr *MockFullNodeMockRecorder) BeaconGetEntry(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BeaconGetEntry", reflect.TypeOf((*MockFullNode)(nil).BeaconGetEntry), arg0, arg1) -} - // ChainBlockstoreInfo mocks base method. func (m *MockFullNode) ChainBlockstoreInfo(arg0 context.Context) (map[string]interface{}, error) { m.ctrl.T.Helper() @@ -2406,6 +2391,21 @@ func (mr *MockFullNodeMockRecorder) StateGetActor(arg0, arg1, arg2 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetActor", reflect.TypeOf((*MockFullNode)(nil).StateGetActor), arg0, arg1, arg2) } +// StateGetBeaconEntry mocks base method. +func (m *MockFullNode) StateGetBeaconEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StateGetBeaconEntry", arg0, arg1) + ret0, _ := ret[0].(*types.BeaconEntry) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// StateGetBeaconEntry indicates an expected call of StateGetBeaconEntry. +func (mr *MockFullNodeMockRecorder) StateGetBeaconEntry(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetBeaconEntry", reflect.TypeOf((*MockFullNode)(nil).StateGetBeaconEntry), arg0, arg1) +} + // StateGetNetworkParams mocks base method. func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) { m.ctrl.T.Helper() @@ -2542,10 +2542,10 @@ func (mr *MockFullNodeMockRecorder) StateMarketBalance(arg0, arg1, arg2 interfac } // StateMarketDeals mocks base method. -func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]api.MarketDeal, error) { +func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]*api.MarketDeal, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMarketDeals", arg0, arg1) - ret0, _ := ret[0].(map[string]api.MarketDeal) + ret0, _ := ret[0].(map[string]*api.MarketDeal) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -2647,10 +2647,10 @@ func (mr *MockFullNodeMockRecorder) StateMinerFaults(arg0, arg1, arg2 interface{ } // StateMinerInfo mocks base method. -func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (miner.MinerInfo, error) { +func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(miner.MinerInfo) + ret0, _ := ret[0].(api.MinerInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -2662,7 +2662,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{}) } // StateMinerInitialPledgeCollateral mocks base method. -func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { +func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInitialPledgeCollateral", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) @@ -2707,7 +2707,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerPower(arg0, arg1, arg2 interface{} } // StateMinerPreCommitDepositForPower mocks base method. -func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { +func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerPreCommitDepositForPower", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) @@ -2872,10 +2872,10 @@ func (mr *MockFullNodeMockRecorder) StateSearchMsg(arg0, arg1, arg2, arg3, arg4 } // StateSectorExpiration mocks base method. -func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorExpiration, error) { +func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorExpiration, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateSectorExpiration", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*miner.SectorExpiration) + ret0, _ := ret[0].(*miner0.SectorExpiration) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -2902,10 +2902,10 @@ func (mr *MockFullNodeMockRecorder) StateSectorGetInfo(arg0, arg1, arg2, arg3 in } // StateSectorPartition mocks base method. -func (m *MockFullNode) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorLocation, error) { +func (m *MockFullNode) 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].(*miner.SectorLocation) + ret0, _ := ret[0].(*miner0.SectorLocation) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 479f1b9d5..0cbb04751 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -15,13 +15,15 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-jsonrpc/auth" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" abinetwork "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/go-state-types/proof" apitypes "github.com/filecoin-project/lotus/api/types" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/extern/sector-storage/fsutil" "github.com/filecoin-project/lotus/extern/sector-storage/sealtasks" @@ -30,7 +32,6 @@ import ( "github.com/filecoin-project/lotus/journal/alerting" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/repo/imports" - "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" "github.com/google/uuid" "github.com/ipfs/go-cid" @@ -102,8 +103,6 @@ type FullNodeStruct struct { NetStruct Internal struct { - BeaconGetEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"` - ChainBlockstoreInfo func(p0 context.Context) (map[string]interface{}, error) `perm:"read"` ChainCheckBlockstore func(p0 context.Context) error `perm:"admin"` @@ -352,6 +351,8 @@ type FullNodeStruct struct { StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `perm:"read"` + StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"` + StateGetNetworkParams func(p0 context.Context) (*NetworkParams, error) `perm:"read"` StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"` @@ -370,7 +371,7 @@ type FullNodeStruct struct { StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MarketBalance, error) `perm:"read"` - StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]MarketDeal, error) `perm:"read"` + StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]*MarketDeal, error) `perm:"read"` StateMarketParticipants func(p0 context.Context, p1 types.TipSetKey) (map[string]MarketBalance, error) `perm:"read"` @@ -384,7 +385,7 @@ type FullNodeStruct struct { StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `perm:"read"` - StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `perm:"read"` + StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) `perm:"read"` StateMinerInitialPledgeCollateral func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"` @@ -414,11 +415,11 @@ type FullNodeStruct struct { StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) `perm:"read"` - StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"` + StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) `perm:"read"` StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"` - StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"` + StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"` StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"` @@ -540,7 +541,7 @@ type GatewayStruct struct { StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*MarketDeal, error) `` - StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `` + StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) `` StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*MinerPower, error) `` @@ -681,7 +682,7 @@ type StorageMinerStruct struct { DealsImportData func(p0 context.Context, p1 cid.Cid, p2 string) error `perm:"admin"` - DealsList func(p0 context.Context) ([]MarketDeal, error) `perm:"admin"` + DealsList func(p0 context.Context) ([]*MarketDeal, error) `perm:"admin"` DealsPieceCidBlocklist func(p0 context.Context) ([]cid.Cid, error) `perm:"admin"` @@ -719,7 +720,7 @@ type StorageMinerStruct struct { MarketListDataTransfers func(p0 context.Context) ([]DataTransferChannel, error) `perm:"write"` - MarketListDeals func(p0 context.Context) ([]MarketDeal, error) `perm:"read"` + MarketListDeals func(p0 context.Context) ([]*MarketDeal, error) `perm:"read"` MarketListIncompleteDeals func(p0 context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"` @@ -1101,17 +1102,6 @@ func (s *CommonStub) Version(p0 context.Context) (APIVersion, error) { return *new(APIVersion), ErrNotSupported } -func (s *FullNodeStruct) BeaconGetEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) { - if s.Internal.BeaconGetEntry == nil { - return nil, ErrNotSupported - } - return s.Internal.BeaconGetEntry(p0, p1) -} - -func (s *FullNodeStub) BeaconGetEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) { - return nil, ErrNotSupported -} - func (s *FullNodeStruct) ChainBlockstoreInfo(p0 context.Context) (map[string]interface{}, error) { if s.Internal.ChainBlockstoreInfo == nil { return *new(map[string]interface{}), ErrNotSupported @@ -2476,6 +2466,17 @@ func (s *FullNodeStub) StateGetActor(p0 context.Context, p1 address.Address, p2 return nil, ErrNotSupported } +func (s *FullNodeStruct) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) { + if s.Internal.StateGetBeaconEntry == nil { + return nil, ErrNotSupported + } + return s.Internal.StateGetBeaconEntry(p0, p1) +} + +func (s *FullNodeStub) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) { + return nil, ErrNotSupported +} + func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*NetworkParams, error) { if s.Internal.StateGetNetworkParams == nil { return nil, ErrNotSupported @@ -2575,15 +2576,15 @@ func (s *FullNodeStub) StateMarketBalance(p0 context.Context, p1 address.Address return *new(MarketBalance), ErrNotSupported } -func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]MarketDeal, error) { +func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*MarketDeal, error) { if s.Internal.StateMarketDeals == nil { - return *new(map[string]MarketDeal), ErrNotSupported + return *new(map[string]*MarketDeal), ErrNotSupported } return s.Internal.StateMarketDeals(p0, p1) } -func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]MarketDeal, error) { - return *new(map[string]MarketDeal), ErrNotSupported +func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*MarketDeal, error) { + return *new(map[string]*MarketDeal), ErrNotSupported } func (s *FullNodeStruct) StateMarketParticipants(p0 context.Context, p1 types.TipSetKey) (map[string]MarketBalance, error) { @@ -2652,15 +2653,15 @@ func (s *FullNodeStub) StateMinerFaults(p0 context.Context, p1 address.Address, return *new(bitfield.BitField), ErrNotSupported } -func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { +func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) { if s.Internal.StateMinerInfo == nil { - return *new(miner.MinerInfo), ErrNotSupported + return *new(MinerInfo), ErrNotSupported } return s.Internal.StateMinerInfo(p0, p1, p2) } -func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { - return *new(miner.MinerInfo), ErrNotSupported +func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) { + return *new(MinerInfo), ErrNotSupported } func (s *FullNodeStruct) StateMinerInitialPledgeCollateral(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) { @@ -2817,14 +2818,14 @@ func (s *FullNodeStub) StateSearchMsg(p0 context.Context, p1 types.TipSetKey, p2 return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { +func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { if s.Internal.StateSectorExpiration == nil { return nil, ErrNotSupported } return s.Internal.StateSectorExpiration(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { +func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { return nil, ErrNotSupported } @@ -2839,14 +2840,14 @@ func (s *FullNodeStub) StateSectorGetInfo(p0 context.Context, p1 address.Address return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { +func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { if s.Internal.StateSectorPartition == nil { return nil, ErrNotSupported } return s.Internal.StateSectorPartition(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { +func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { return nil, ErrNotSupported } @@ -3455,15 +3456,15 @@ func (s *GatewayStub) StateMarketStorageDeal(p0 context.Context, p1 abi.DealID, return nil, ErrNotSupported } -func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { +func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) { if s.Internal.StateMinerInfo == nil { - return *new(miner.MinerInfo), ErrNotSupported + return *new(MinerInfo), ErrNotSupported } return s.Internal.StateMinerInfo(p0, p1, p2) } -func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { - return *new(miner.MinerInfo), ErrNotSupported +func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) { + return *new(MinerInfo), ErrNotSupported } func (s *GatewayStruct) StateMinerPower(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*MinerPower, error) { @@ -4093,15 +4094,15 @@ func (s *StorageMinerStub) DealsImportData(p0 context.Context, p1 cid.Cid, p2 st return ErrNotSupported } -func (s *StorageMinerStruct) DealsList(p0 context.Context) ([]MarketDeal, error) { +func (s *StorageMinerStruct) DealsList(p0 context.Context) ([]*MarketDeal, error) { if s.Internal.DealsList == nil { - return *new([]MarketDeal), ErrNotSupported + return *new([]*MarketDeal), ErrNotSupported } return s.Internal.DealsList(p0) } -func (s *StorageMinerStub) DealsList(p0 context.Context) ([]MarketDeal, error) { - return *new([]MarketDeal), ErrNotSupported +func (s *StorageMinerStub) DealsList(p0 context.Context) ([]*MarketDeal, error) { + return *new([]*MarketDeal), ErrNotSupported } func (s *StorageMinerStruct) DealsPieceCidBlocklist(p0 context.Context) ([]cid.Cid, error) { @@ -4302,15 +4303,15 @@ func (s *StorageMinerStub) MarketListDataTransfers(p0 context.Context) ([]DataTr return *new([]DataTransferChannel), ErrNotSupported } -func (s *StorageMinerStruct) MarketListDeals(p0 context.Context) ([]MarketDeal, error) { +func (s *StorageMinerStruct) MarketListDeals(p0 context.Context) ([]*MarketDeal, error) { if s.Internal.MarketListDeals == nil { - return *new([]MarketDeal), ErrNotSupported + return *new([]*MarketDeal), ErrNotSupported } return s.Internal.MarketListDeals(p0) } -func (s *StorageMinerStub) MarketListDeals(p0 context.Context) ([]MarketDeal, error) { - return *new([]MarketDeal), ErrNotSupported +func (s *StorageMinerStub) MarketListDeals(p0 context.Context) ([]*MarketDeal, error) { + return *new([]*MarketDeal), ErrNotSupported } func (s *StorageMinerStruct) MarketListIncompleteDeals(p0 context.Context) ([]storagemarket.MinerDeal, error) { diff --git a/api/types.go b/api/types.go index d0b7c7cb9..865ed48a1 100644 --- a/api/types.go +++ b/api/types.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + "github.com/filecoin-project/go-address" + "github.com/libp2p/go-libp2p-core/network" datatransfer "github.com/filecoin-project/go-data-transfer" @@ -286,6 +288,20 @@ type ExportRef struct { DealID retrievalmarket.DealID } +type MinerInfo struct { + Owner address.Address // Must be an ID-address. + Worker address.Address // Must be an ID-address. + NewWorker address.Address // Must be an ID-address. + ControlAddresses []address.Address // Must be an ID-addresses. + WorkerChangeEpoch abi.ChainEpoch + PeerId *peer.ID + Multiaddrs []abi.Multiaddrs + WindowPoStProofType abi.RegisteredPoStProof + SectorSize abi.SectorSize + WindowPoStPartitionSectors uint64 + ConsensusFaultElapsed abi.ChainEpoch +} + type NetworkParams struct { NetworkName dtypes.NetworkName BlockDelaySecs uint64 diff --git a/api/v0api/full.go b/api/v0api/full.go index c1aa69a77..30a0dfb8e 100644 --- a/api/v0api/full.go +++ b/api/v0api/full.go @@ -15,10 +15,11 @@ import ( textselector "github.com/ipld/go-ipld-selector-text-lite" "github.com/libp2p/go-libp2p-core/peer" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/api" apitypes "github.com/filecoin-project/lotus/api/types" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" marketevents "github.com/filecoin-project/lotus/markets/loggers" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -416,7 +417,7 @@ type FullNode interface { // StateMinerPower returns the power of the indicated miner StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) //perm:read // StateMinerInfo returns info about the indicated miner - StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) //perm:read + StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) //perm:read // StateMinerDeadlines returns all the proving deadlines for the given miner StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error) //perm:read // StateMinerPartitions returns all partitions in the specified deadline @@ -442,9 +443,9 @@ type FullNode interface { // expiration epoch StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read // StateSectorExpiration returns epoch at which given sector will expire - StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) //perm:read + StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read // StateSectorPartition finds deadline/partition with the specified sector - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) //perm:read + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) //perm:read // StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed // // NOTE: If a replacing message is found on chain, this method will return @@ -521,7 +522,7 @@ type FullNode interface { // StateMarketParticipants returns the Escrow and Locked balances of every participant in the Storage Market StateMarketParticipants(context.Context, types.TipSetKey) (map[string]api.MarketBalance, error) //perm:read // StateMarketDeals returns information about every deal in the Storage Market - StateMarketDeals(context.Context, types.TipSetKey) (map[string]api.MarketDeal, error) //perm:read + StateMarketDeals(context.Context, types.TipSetKey) (map[string]*api.MarketDeal, error) //perm:read // StateMarketStorageDeal returns information about the indicated deal StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*api.MarketDeal, error) //perm:read // StateLookupID retrieves the ID address of the given address diff --git a/api/v0api/gateway.go b/api/v0api/gateway.go index e3ba56899..e13e92dd3 100644 --- a/api/v0api/gateway.go +++ b/api/v0api/gateway.go @@ -10,8 +10,8 @@ import ( "github.com/filecoin-project/go-state-types/dline" abinetwork "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) @@ -54,7 +54,7 @@ type Gateway interface { StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error) - StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) + StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) StateNetworkVersion(context.Context, types.TipSetKey) (abinetwork.Version, error) diff --git a/api/v0api/proxy_gen.go b/api/v0api/proxy_gen.go index 6ac74904f..bae8ba782 100644 --- a/api/v0api/proxy_gen.go +++ b/api/v0api/proxy_gen.go @@ -11,13 +11,14 @@ import ( "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" abinetwork "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" apitypes "github.com/filecoin-project/lotus/api/types" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" marketevents "github.com/filecoin-project/lotus/markets/loggers" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -285,7 +286,7 @@ type FullNodeStruct struct { StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MarketBalance, error) `perm:"read"` - StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketDeal, error) `perm:"read"` + StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]*api.MarketDeal, error) `perm:"read"` StateMarketParticipants func(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketBalance, error) `perm:"read"` @@ -299,7 +300,7 @@ type FullNodeStruct struct { StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `perm:"read"` - StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `perm:"read"` + StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `perm:"read"` StateMinerInitialPledgeCollateral func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"` @@ -331,11 +332,11 @@ type FullNodeStruct struct { StateSearchMsgLimited func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch) (*api.MsgLookup, error) `perm:"read"` - StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"` + StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) `perm:"read"` StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"` - StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"` + StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"` StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"` @@ -447,7 +448,7 @@ type GatewayStruct struct { StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*api.MarketDeal, error) `` - StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `` + StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `` StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) `` @@ -1847,15 +1848,15 @@ func (s *FullNodeStub) StateMarketBalance(p0 context.Context, p1 address.Address return *new(api.MarketBalance), ErrNotSupported } -func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketDeal, error) { +func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*api.MarketDeal, error) { if s.Internal.StateMarketDeals == nil { - return *new(map[string]api.MarketDeal), ErrNotSupported + return *new(map[string]*api.MarketDeal), ErrNotSupported } return s.Internal.StateMarketDeals(p0, p1) } -func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketDeal, error) { - return *new(map[string]api.MarketDeal), ErrNotSupported +func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*api.MarketDeal, error) { + return *new(map[string]*api.MarketDeal), ErrNotSupported } func (s *FullNodeStruct) StateMarketParticipants(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketBalance, error) { @@ -1924,15 +1925,15 @@ func (s *FullNodeStub) StateMinerFaults(p0 context.Context, p1 address.Address, return *new(bitfield.BitField), ErrNotSupported } -func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { +func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) { if s.Internal.StateMinerInfo == nil { - return *new(miner.MinerInfo), ErrNotSupported + return *new(api.MinerInfo), ErrNotSupported } return s.Internal.StateMinerInfo(p0, p1, p2) } -func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { - return *new(miner.MinerInfo), ErrNotSupported +func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) { + return *new(api.MinerInfo), ErrNotSupported } func (s *FullNodeStruct) StateMinerInitialPledgeCollateral(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) { @@ -2100,14 +2101,14 @@ func (s *FullNodeStub) StateSearchMsgLimited(p0 context.Context, p1 cid.Cid, p2 return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { +func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { if s.Internal.StateSectorExpiration == nil { return nil, ErrNotSupported } return s.Internal.StateSectorExpiration(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) { +func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) { return nil, ErrNotSupported } @@ -2122,14 +2123,14 @@ func (s *FullNodeStub) StateSectorGetInfo(p0 context.Context, p1 address.Address return nil, ErrNotSupported } -func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { +func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { if s.Internal.StateSectorPartition == nil { return nil, ErrNotSupported } return s.Internal.StateSectorPartition(p0, p1, p2, p3) } -func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) { +func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) { return nil, ErrNotSupported } @@ -2683,15 +2684,15 @@ func (s *GatewayStub) StateMarketStorageDeal(p0 context.Context, p1 abi.DealID, return nil, ErrNotSupported } -func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { +func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) { if s.Internal.StateMinerInfo == nil { - return *new(miner.MinerInfo), ErrNotSupported + return *new(api.MinerInfo), ErrNotSupported } return s.Internal.StateMinerInfo(p0, p1, p2) } -func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) { - return *new(miner.MinerInfo), ErrNotSupported +func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) { + return *new(api.MinerInfo), ErrNotSupported } func (s *GatewayStruct) StateMinerPower(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) { diff --git a/api/v0api/v0mocks/mock_full.go b/api/v0api/v0mocks/mock_full.go index 7301b8aec..e807862e6 100644 --- a/api/v0api/v0mocks/mock_full.go +++ b/api/v0api/v0mocks/mock_full.go @@ -17,20 +17,20 @@ import ( auth "github.com/filecoin-project/go-jsonrpc/auth" 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" + paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" 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" apitypes "github.com/filecoin-project/lotus/api/types" v0api "github.com/filecoin-project/lotus/api/v0api" - miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" types "github.com/filecoin-project/lotus/chain/types" alerting "github.com/filecoin-project/lotus/journal/alerting" marketevents "github.com/filecoin-project/lotus/markets/loggers" dtypes "github.com/filecoin-project/lotus/node/modules/dtypes" imports "github.com/filecoin-project/lotus/node/repo/imports" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - paych "github.com/filecoin-project/specs-actors/actors/builtin/paych" gomock "github.com/golang/mock/gomock" uuid "github.com/google/uuid" cid "github.com/ipfs/go-cid" @@ -2411,10 +2411,10 @@ func (mr *MockFullNodeMockRecorder) StateMarketBalance(arg0, arg1, arg2 interfac } // StateMarketDeals mocks base method. -func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]api.MarketDeal, error) { +func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]*api.MarketDeal, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMarketDeals", arg0, arg1) - ret0, _ := ret[0].(map[string]api.MarketDeal) + ret0, _ := ret[0].(map[string]*api.MarketDeal) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -2516,10 +2516,10 @@ func (mr *MockFullNodeMockRecorder) StateMinerFaults(arg0, arg1, arg2 interface{ } // StateMinerInfo mocks base method. -func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (miner.MinerInfo, error) { +func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(miner.MinerInfo) + ret0, _ := ret[0].(api.MinerInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -2531,7 +2531,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{}) } // StateMinerInitialPledgeCollateral mocks base method. -func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { +func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInitialPledgeCollateral", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) @@ -2576,7 +2576,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerPower(arg0, arg1, arg2 interface{} } // StateMinerPreCommitDepositForPower mocks base method. -func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { +func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerPreCommitDepositForPower", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) @@ -2756,10 +2756,10 @@ func (mr *MockFullNodeMockRecorder) StateSearchMsgLimited(arg0, arg1, arg2 inter } // StateSectorExpiration mocks base method. -func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorExpiration, error) { +func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorExpiration, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateSectorExpiration", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*miner.SectorExpiration) + ret0, _ := ret[0].(*miner0.SectorExpiration) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -2786,10 +2786,10 @@ func (mr *MockFullNodeMockRecorder) StateSectorGetInfo(arg0, arg1, arg2, arg3 in } // StateSectorPartition mocks base method. -func (m *MockFullNode) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorLocation, error) { +func (m *MockFullNode) 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].(*miner.SectorLocation) + ret0, _ := ret[0].(*miner0.SectorLocation) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/api/v0api/v1_wrapper.go b/api/v0api/v1_wrapper.go index 769a280ab..d6de6f416 100644 --- a/api/v0api/v1_wrapper.go +++ b/api/v0api/v1_wrapper.go @@ -352,4 +352,8 @@ func (w *WrapperV1Full) ClientQueryAsk(ctx context.Context, p peer.ID, miner add return a.Response, nil } +func (w *WrapperV1Full) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) { + return w.StateGetBeaconEntry(ctx, epoch) +} + var _ FullNode = &WrapperV1Full{} diff --git a/build/README-bundle.md b/build/README-bundle.md new file mode 100644 index 000000000..4dc96c687 --- /dev/null +++ b/build/README-bundle.md @@ -0,0 +1,59 @@ +# Builtin Actor Bundles + +With NV16, builtin actor bundles must be loaded into lotus for the FVM to operate. + +The bundles are specified in build/bundles.toml using the following syntax: +```toml +[[bundles]] +version = X # actors version +release = tag # release tag +``` + +This will add a bundle for version `X`, using the github release `tag` +to fetch the bundles at first startup. + +If you don't want to fetch the bundle from github, you can specify an explicit path to the bundle (which must be appropriate for your network, typically mainnet): +```toml +[[bundles]] +version = X # actors version +release = tag # release tag +path = /path/to/builtin-actors.car +``` + +For development bundles, you can also specify `development = true` so that the bundle is not +recorded in the datastore and reloaded every time the daemon starts up: +```toml +[[bundles]] +version = X # actors version +release = tag # release gag +path = /path/to/builtin-actors.car +development = true +``` + +## Additional Options for Bundles + +- You can also specify a URL, together with a sha256 checksum to avoid downloading from + github. +- You can also specify an environment variable (`LOTUS_BUILTIN_ACTORS_VX_BUNDLE`), to provide the path dynamically at runtime. + +The precedence for bundle fetching/loading is as folllows: +- Check the environment variable `LOTUS_BUILTIN_ACTORS_VX_BUNDLE` for version X bundle; use it if set. +- Check the Path; use the bundle specified by it. +- Check the URL; use the bundle specified by it, and verify the checksum which must be present. +- Otherwise, use the release tag and download from github. + +## Local Storage + +Bundles downloaded from github will be stored in +`$LOTUS_PATH/builtin-actors/vXXX/YYY/builtin-actors-ZZZ.car``, where +`XXX` is the actors version, `YYY` is the release tag, and `ZZZ` is +the network bundle name. + +The sha256 sum of the bundle will be stored next to it, in +`$LOTUS_PATH/builtin-actors/vXXX/YYY/builtin-actors-ZZZ.sha256` + +On startup, if a bundle is recorded as loaded the manifest CID will be +checked for presence in the blockstore. If the manifest is missing, +then the bundle will be reloaded from the local file (if it exists) or +refetched from github. The sha256 sum is always checked before +loading the bundle. diff --git a/build/bootstrap/interopnet.pi b/build/bootstrap/interopnet.pi index 923653d94..2e8ab67a9 100644 --- a/build/bootstrap/interopnet.pi +++ b/build/bootstrap/interopnet.pi @@ -1,2 +1,2 @@ -/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWLGPq9JL1xwL6gHok7HSNxtK1Q5kyfg4Hk69ifRPghn4i -/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWFYS1f31zafv8mqqYu8U3hEqYvaZ6avWzYU3BmZdpyH3h +/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWDY249nj6gxSiBTocNBnkbBBvnfPgkxq5SBUVrccjwRnr +/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWCwFsKt4NyoJQk7vjiACXL9LznBWANXKjCebKJ7MHh3h4 diff --git a/build/builtin_actors.go b/build/builtin_actors.go new file mode 100644 index 000000000..c6ed38c5b --- /dev/null +++ b/build/builtin_actors.go @@ -0,0 +1,27 @@ +package build + +import ( + "bytes" + + "github.com/filecoin-project/lotus/chain/actors" + + "github.com/BurntSushi/toml" +) + +var BuiltinActorReleases map[actors.Version]Bundle + +func init() { + BuiltinActorReleases = make(map[actors.Version]Bundle) + + spec := BundleSpec{} + + r := bytes.NewReader(BuiltinActorBundles) + _, err := toml.DecodeReader(r, &spec) + if err != nil { + panic(err) + } + + for _, b := range spec.Bundles { + BuiltinActorReleases[b.Version] = b + } +} diff --git a/build/bundle.go b/build/bundle.go new file mode 100644 index 000000000..56a9f5bfa --- /dev/null +++ b/build/bundle.go @@ -0,0 +1,36 @@ +package build + +import ( + _ "embed" + + "github.com/filecoin-project/lotus/chain/actors" +) + +//go:embed bundles.toml +var BuiltinActorBundles []byte + +type BundleSpec struct { + Bundles []Bundle +} + +type Bundle struct { + // Version is the actors version in this bundle + Version actors.Version + // Release is the release id + Release string + // Path is the (optional) bundle path; takes precedence over url + Path map[string]string + // URL is the (optional) bundle URL; takes precedence over github release + URL map[string]BundleURL + // Devlopment indicates whether this is a development version; when set, in conjunction with path, + // it will always load the bundle to the blockstore, without recording the manifest CID in the + // datastore. + Development bool +} + +type BundleURL struct { + // URL is the url of the bundle + URL string + // Checksum is the sha256 checksum of the bundle + Checksum string +} diff --git a/build/bundles.toml b/build/bundles.toml new file mode 100644 index 000000000..c99637d53 --- /dev/null +++ b/build/bundles.toml @@ -0,0 +1,3 @@ +[[bundles]] +version = 8 +release = "dev/20220527" \ No newline at end of file diff --git a/build/genesis/interopnet.car b/build/genesis/interopnet.car index 2c7c2a498..4fe69551b 100644 Binary files a/build/genesis/interopnet.car and b/build/genesis/interopnet.car differ diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 78f707561..01c02e14f 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/gateway.json.gz b/build/openrpc/gateway.json.gz index 28620ae07..12a5ebaca 100644 Binary files a/build/openrpc/gateway.json.gz and b/build/openrpc/gateway.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index a99436d5d..b10e9b761 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index b3d7c01d2..155ac591e 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/build/params_2k.go b/build/params_2k.go index 60006cede..d14d977a2 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -11,13 +11,16 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) const BootstrappersFile = "" const GenesisFile = "" -const GenesisNetworkVersion = network.Version15 +var NetworkBundle = "devnet" + +const GenesisNetworkVersion = network.Version16 var UpgradeBreezeHeight = abi.ChainEpoch(-1) @@ -48,6 +51,9 @@ var UpgradeHyperdriveHeight = abi.ChainEpoch(-16) var UpgradeChocolateHeight = abi.ChainEpoch(-17) var UpgradeOhSnapHeight = abi.ChainEpoch(-18) +var UpgradeSkyrHeight = abi.ChainEpoch(100) + +var ActorsCIDs = map[actors.Version]cid.Cid{} var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, @@ -99,6 +105,7 @@ func init() { UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight) UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight) UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight) + UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight) BuildType |= Build2k diff --git a/build/params_butterfly.go b/build/params_butterfly.go index d74e17305..a98ac676f 100644 --- a/build/params_butterfly.go +++ b/build/params_butterfly.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" "github.com/ipfs/go-cid" @@ -18,6 +19,8 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ const GenesisNetworkVersion = network.Version14 +var NetworkBundle = "butterflynet" + const BootstrappersFile = "butterflynet.pi" const GenesisFile = "butterflynet.car" @@ -44,6 +47,13 @@ const UpgradeChocolateHeight = -17 const UpgradeOhSnapHeight = 240 +// 2022-05-31T14:32:00Z +const UpgradeSkyrHeight = abi.ChainEpoch(333258) + +var ActorsCIDs = map[actors.Version]cid.Cid{ + actors.Version8: MustParseCid("bafy2bzacedy4qgxbr6pbyfgcp7s7bdkc2whi5errnw67al5e2tk75j46iucv6"), +} + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, abi.RegisteredSealProof_StackedDrg32GiBV1, diff --git a/build/params_calibnet.go b/build/params_calibnet.go index 5ff8bd853..8683470f7 100644 --- a/build/params_calibnet.go +++ b/build/params_calibnet.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" "github.com/ipfs/go-cid" @@ -18,6 +19,8 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ const GenesisNetworkVersion = network.Version0 +var NetworkBundle = "calibrationnet" + const BootstrappersFile = "calibnet.pi" const GenesisFile = "calibnet.car" @@ -57,6 +60,10 @@ const UpgradeChocolateHeight = 312746 // 2022-02-10T19:23:00Z const UpgradeOhSnapHeight = 682006 +var UpgradeSkyrHeight = abi.ChainEpoch(99999999999999) + +var ActorsCIDs = map[actors.Version]cid.Cid{} + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1, diff --git a/build/params_interop.go b/build/params_interop.go index ad051570c..38cba440c 100644 --- a/build/params_interop.go +++ b/build/params_interop.go @@ -7,19 +7,22 @@ import ( "os" "strconv" - "github.com/ipfs/go-cid" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors/policy" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + "github.com/ipfs/go-cid" ) +var NetworkBundle = "caterpillarnet" + const BootstrappersFile = "interopnet.pi" const GenesisFile = "interopnet.car" -const GenesisNetworkVersion = network.Version13 +const GenesisNetworkVersion = network.Version15 var UpgradeBreezeHeight = abi.ChainEpoch(-1) @@ -48,6 +51,11 @@ var UpgradeTurboHeight = abi.ChainEpoch(-15) var UpgradeHyperdriveHeight = abi.ChainEpoch(-16) var UpgradeChocolateHeight = abi.ChainEpoch(-17) var UpgradeOhSnapHeight = abi.ChainEpoch(-18) +var UpgradeSkyrHeight = abi.ChainEpoch(100) + +var ActorsCIDs = map[actors.Version]cid.Cid{ + actors.Version8: MustParseCid("bafy2bzacebjfypksxfieex7d6rh27lu2dk2m7chnok5mtzigj3txvb7leqbys"), +} var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, @@ -98,6 +106,9 @@ func init() { UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight) UpgradeTurboHeight = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeTurboHeight) UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight) + UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight) + UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight) + UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight) BuildType |= BuildInteropnet SetAddressNetwork(address.Testnet) diff --git a/build/params_mainnet.go b/build/params_mainnet.go index 72e25f2fb..5d52e2bd9 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -1,5 +1,5 @@ -//go:build !debug && !2k && !testground && !calibnet && !nerpanet && !butterflynet && !interopnet -// +build !debug,!2k,!testground,!calibnet,!nerpanet,!butterflynet,!interopnet +//go:build !debug && !2k && !testground && !calibnet && !butterflynet && !interopnet +// +build !debug,!2k,!testground,!calibnet,!butterflynet,!interopnet package build @@ -7,6 +7,9 @@ import ( "math" "os" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/ipfs/go-cid" + "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-address" @@ -19,6 +22,8 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ UpgradeSmokeHeight: DrandMainnet, } +var NetworkBundle = "mainnet" + const GenesisNetworkVersion = network.Version0 const BootstrappersFile = "mainnet.pi" @@ -68,7 +73,11 @@ const UpgradeHyperdriveHeight = 892800 const UpgradeChocolateHeight = 1231620 // 2022-03-01T15:00:00Z -var UpgradeOhSnapHeight = abi.ChainEpoch(1594680) +const UpgradeOhSnapHeight = 1594680 + +var UpgradeSkyrHeight = abi.ChainEpoch(99999999999999) + +var ActorsCIDs = map[actors.Version]cid.Cid{} var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, @@ -83,8 +92,8 @@ func init() { SetAddressNetwork(address.Mainnet) } - if os.Getenv("LOTUS_DISABLE_SNAPDEALS") == "1" { - UpgradeOhSnapHeight = math.MaxInt64 + if os.Getenv("LOTUS_DISABLE_SKYR") == "1" { + UpgradeSkyrHeight = math.MaxInt64 } Devnet = false diff --git a/build/params_nerpanet.go b/build/params_nerpanet.go deleted file mode 100644 index 4621a7271..000000000 --- a/build/params_nerpanet.go +++ /dev/null @@ -1,93 +0,0 @@ -//go:build nerpanet -// +build nerpanet - -package build - -import ( - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/chain/actors/policy" - "github.com/ipfs/go-cid" - - builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" -) - -var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ - 0: DrandMainnet, -} - -const GenesisNetworkVersion = network.Version0 - -const BootstrappersFile = "nerpanet.pi" -const GenesisFile = "nerpanet.car" - -const UpgradeBreezeHeight = -1 -const BreezeGasTampingDuration = 0 - -const UpgradeSmokeHeight = -1 - -const UpgradeIgnitionHeight = -2 -const UpgradeRefuelHeight = -3 - -const UpgradeLiftoffHeight = -5 - -const UpgradeAssemblyHeight = 30 // critical: the network can bootstrap from v1 only -const UpgradeTapeHeight = 60 - -const UpgradeKumquatHeight = 90 - -const UpgradeCalicoHeight = 100 -const UpgradePersianHeight = UpgradeCalicoHeight + (builtin2.EpochsInHour * 1) - -const UpgradeClausHeight = 250 - -const UpgradeOrangeHeight = 300 - -const UpgradeTrustHeight = 600 -const UpgradeNorwegianHeight = 201000 -const UpgradeTurboHeight = 203000 -const UpgradeHyperdriveHeight = 379178 - -const UpgradeChocolateHeight = 999999999 - -var SupportedProofTypes = []abi.RegisteredSealProof{ - abi.RegisteredSealProof_StackedDrg512MiBV1, - abi.RegisteredSealProof_StackedDrg32GiBV1, - abi.RegisteredSealProof_StackedDrg64GiBV1, -} - -// Minimum block production power is set to 4 TiB -// Rationale is to discourage small-scale miners from trying to take over the network -// One needs to invest in ~2.3x the compute to break consensus, making it not worth it -// -// DOWNSIDE: the fake-seals need to be kept alive/protected, otherwise network will seize -// -var ConsensusMinerMinPower = abi.NewStoragePower(4 << 40) -var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) - -// Lower the most time-consuming parts of PoRep -var PreCommitChallengeDelay = abi.ChainEpoch(10) - -func init() { - policy.SetSupportedProofTypes(SupportedProofTypes...) - policy.SetConsensusMinerMinPower(ConsensusMinerMinPower) - policy.SetMinVerifiedDealSize(MinVerifiedDealSize) - policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay) - - // TODO - make this a variable - //miner.WPoStChallengeLookback = abi.ChainEpoch(2) - - Devnet = false - - BuildType = BuildNerpanet - -} - -const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds) - -const PropagationDelaySecs = uint64(6) - -// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start -const BootstrapPeerThreshold = 4 - -var WhitelistedBlock = cid.Undef diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index 704c84639..d8d0a5382 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -34,7 +34,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}} /* inline-gen start */ -const NewestNetworkVersion = network.Version15 +const NewestNetworkVersion = network.Version16 /* inline-gen end */ diff --git a/build/params_testground.go b/build/params_testground.go index 46e90f494..5e2dde3b0 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -17,6 +17,7 @@ import ( builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -106,12 +107,14 @@ var ( UpgradeHyperdriveHeight abi.ChainEpoch = -15 UpgradeChocolateHeight abi.ChainEpoch = -16 UpgradeOhSnapHeight abi.ChainEpoch = -17 + UpgradeSkyrHeight abi.ChainEpoch = -18 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, } GenesisNetworkVersion = network.Version0 + NetworkBundle = "devnet" NewestNetworkVersion = network.Version15 ActorUpgradeNetworkVersion = network.Version15 @@ -125,3 +128,5 @@ var ( ) const BootstrapPeerThreshold = 1 + +var ActorsCIDs = map[actors.Version]cid.Cid{} diff --git a/build/version.go b/build/version.go index 24da6355e..6ca22acc9 100644 --- a/build/version.go +++ b/build/version.go @@ -37,7 +37,7 @@ func BuildTypeString() string { } // BuildVersion is the local build version -const BuildVersion = "1.15.4-dev" +const BuildVersion = "1.17.0-dev" func UserVersion() string { if os.Getenv("LOTUS_VERSION_IGNORE_COMMIT") == "1" { diff --git a/chain/actors/agen/main.go b/chain/actors/agen/main.go index 9a3b8fd20..d07c039dd 100644 --- a/chain/actors/agen/main.go +++ b/chain/actors/agen/main.go @@ -3,6 +3,7 @@ package main import ( "bytes" "fmt" + "go/format" "io/ioutil" "os" "path/filepath" @@ -77,7 +78,12 @@ func generateAdapters() error { return err } - if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), b.Bytes(), 0666); err != nil { + fmted, err := format.Source(b.Bytes()) + if err != nil { + return err + } + + if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), fmted, 0666); err != nil { return err } } diff --git a/chain/actors/builtin/account/account.go b/chain/actors/builtin/account/account.go index 57ea510bb..04bdc3920 100644 --- a/chain/actors/builtin/account/account.go +++ b/chain/actors/builtin/account/account.go @@ -6,10 +6,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -25,42 +23,26 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" ) -func init() { - - builtin.RegisterActorState(builtin0.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - -var Methods = builtin4.MethodsAccount +var Methods = builtin8.MethodsAccount func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.AccountKey { + return nil, xerrors.Errorf("actor code is not account: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.AccountActorCodeID: @@ -85,6 +67,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -112,39 +95,13 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, case actors.Version7: return make7(store, addr) + case actors.Version8: + return make8(store, addr) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.AccountActorCodeID, nil - - case actors.Version2: - return builtin2.AccountActorCodeID, nil - - case actors.Version3: - return builtin3.AccountActorCodeID, nil - - case actors.Version4: - return builtin4.AccountActorCodeID, nil - - case actors.Version5: - return builtin5.AccountActorCodeID, nil - - case actors.Version6: - return builtin6.AccountActorCodeID, nil - - case actors.Version7: - return builtin7.AccountActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/account/actor.go.template b/chain/actors/builtin/account/actor.go.template index 53962cc94..7aff20d42 100644 --- a/chain/actors/builtin/account/actor.go.template +++ b/chain/actors/builtin/account/actor.go.template @@ -6,32 +6,45 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - -var Methods = builtin4.MethodsAccount +var Methods = builtin{{.latestVersion}}.MethodsAccount func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.AccountKey { + return nil, xerrors.Errorf("actor code is not account: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.AccountActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.AccountActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -45,17 +58,6 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.AccountActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/account/state.go.template b/chain/actors/builtin/account/state.go.template index 5be262ece..93e7dc0db 100644 --- a/chain/actors/builtin/account/state.go.template +++ b/chain/actors/builtin/account/state.go.template @@ -6,7 +6,11 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" +{{if (le .v 7)}} account{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/account" +{{else}} + account{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}account" +{{end}} ) var _ State = (*state{{.v}})(nil) diff --git a/chain/actors/builtin/account/v8.go b/chain/actors/builtin/account/v8.go new file mode 100644 index 000000000..d8ef52c00 --- /dev/null +++ b/chain/actors/builtin/account/v8.go @@ -0,0 +1,40 @@ +package account + +import ( + "github.com/filecoin-project/go-address" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + account8 "github.com/filecoin-project/go-state-types/builtin/v8/account" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store, addr address.Address) (State, error) { + out := state8{store: store} + out.State = account8.State{Address: addr} + return &out, nil +} + +type state8 struct { + account8.State + store adt.Store +} + +func (s *state8) PubkeyAddress() (address.Address, error) { + return s.Address, nil +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index febbca479..6d707ba03 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -6,128 +6,70 @@ import ( "golang.org/x/xerrors" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" - smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" - smoothing3 "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" - smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" - smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" - smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing" + + builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/cbor" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/proof" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/chain/actors" - miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" ) -var SystemActorAddr = builtin7.SystemActorAddr -var BurntFundsActorAddr = builtin7.BurntFundsActorAddr -var CronActorAddr = builtin7.CronActorAddr +var SystemActorAddr = builtin.SystemActorAddr +var BurntFundsActorAddr = builtin.BurntFundsActorAddr +var CronActorAddr = builtin.CronActorAddr var SaftAddress = makeAddress("t0122") var ReserveAddress = makeAddress("t090") var RootVerifierAddress = makeAddress("t080") var ( - ExpectedLeadersPerEpoch = builtin7.ExpectedLeadersPerEpoch + ExpectedLeadersPerEpoch = builtin.ExpectedLeadersPerEpoch ) const ( - EpochDurationSeconds = builtin7.EpochDurationSeconds - EpochsInDay = builtin7.EpochsInDay - SecondsInDay = builtin7.SecondsInDay + EpochDurationSeconds = builtin.EpochDurationSeconds + EpochsInDay = builtin.EpochsInDay + SecondsInDay = builtin.SecondsInDay ) const ( - MethodSend = builtin7.MethodSend - MethodConstructor = builtin7.MethodConstructor + MethodSend = builtin.MethodSend + MethodConstructor = builtin.MethodConstructor ) // These are all just type aliases across actor versions. In the future, that might change // and we might need to do something fancier. -type SectorInfo = proof7.SectorInfo -type ExtendedSectorInfo = proof7.ExtendedSectorInfo -type PoStProof = proof7.PoStProof -type FilterEstimate = smoothing0.FilterEstimate +type SectorInfo = proof.SectorInfo +type ExtendedSectorInfo = proof.ExtendedSectorInfo +type PoStProof = proof.PoStProof +type FilterEstimate = smoothingtypes.FilterEstimate func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower { - return miner7.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) -} - -func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v0) //nolint:unconvert - -} - -func FromV2FilterEstimate(v2 smoothing2.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v2) - -} - -func FromV3FilterEstimate(v3 smoothing3.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v3) - -} - -func FromV4FilterEstimate(v4 smoothing4.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v4) - -} - -func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v5) - -} - -func FromV6FilterEstimate(v6 smoothing6.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v6) - -} - -func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate { - - return (FilterEstimate)(v7) - -} - -type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) - -var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader) - -func RegisterActorState(code cid.Cid, loader ActorStateLoader) { - ActorStateLoaders[code] = loader -} - -func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) { - loader, found := ActorStateLoaders[act.Code] - if !found { - return nil, xerrors.Errorf("unknown actor code %s", act.Code) - } - return loader(store, act.Head) + return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) } func ActorNameByCode(c cid.Cid) string { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name + } + switch { case builtin0.IsBuiltinActor(c): @@ -151,12 +93,19 @@ func ActorNameByCode(c cid.Cid) string { case builtin7.IsBuiltinActor(c): return builtin7.ActorNameByCode(c) + case builtin8.IsBuiltinActor(c): + return builtin8.ActorNameByCode(c) + default: return "" } } func IsBuiltinActor(c cid.Cid) bool { + _, _, ok := actors.GetActorMetaByCode(c) + if ok { + return true + } if builtin0.IsBuiltinActor(c) { return true @@ -189,7 +138,44 @@ func IsBuiltinActor(c cid.Cid) bool { return false } +func GetAccountActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.AccountKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.AccountActorCodeID, nil + + case actors.Version2: + return builtin2.AccountActorCodeID, nil + + case actors.Version3: + return builtin3.AccountActorCodeID, nil + + case actors.Version4: + return builtin4.AccountActorCodeID, nil + + case actors.Version5: + return builtin5.AccountActorCodeID, nil + + case actors.Version6: + return builtin6.AccountActorCodeID, nil + + case actors.Version7: + return builtin7.AccountActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsAccountActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == "account" + } if c == builtin0.AccountActorCodeID { return true @@ -222,7 +208,143 @@ func IsAccountActor(c cid.Cid) bool { return false } +func GetCronActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.CronKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.CronActorCodeID, nil + + case actors.Version2: + return builtin2.CronActorCodeID, nil + + case actors.Version3: + return builtin3.CronActorCodeID, nil + + case actors.Version4: + return builtin4.CronActorCodeID, nil + + case actors.Version5: + return builtin5.CronActorCodeID, nil + + case actors.Version6: + return builtin6.CronActorCodeID, nil + + case actors.Version7: + return builtin7.CronActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetInitActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.InitKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.InitActorCodeID, nil + + case actors.Version2: + return builtin2.InitActorCodeID, nil + + case actors.Version3: + return builtin3.InitActorCodeID, nil + + case actors.Version4: + return builtin4.InitActorCodeID, nil + + case actors.Version5: + return builtin5.InitActorCodeID, nil + + case actors.Version6: + return builtin6.InitActorCodeID, nil + + case actors.Version7: + return builtin7.InitActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetMarketActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.MarketKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.StorageMarketActorCodeID, nil + + case actors.Version2: + return builtin2.StorageMarketActorCodeID, nil + + case actors.Version3: + return builtin3.StorageMarketActorCodeID, nil + + case actors.Version4: + return builtin4.StorageMarketActorCodeID, nil + + case actors.Version5: + return builtin5.StorageMarketActorCodeID, nil + + case actors.Version6: + return builtin6.StorageMarketActorCodeID, nil + + case actors.Version7: + return builtin7.StorageMarketActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetMinerActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.MinerKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.StorageMinerActorCodeID, nil + + case actors.Version2: + return builtin2.StorageMinerActorCodeID, nil + + case actors.Version3: + return builtin3.StorageMinerActorCodeID, nil + + case actors.Version4: + return builtin4.StorageMinerActorCodeID, nil + + case actors.Version5: + return builtin5.StorageMinerActorCodeID, nil + + case actors.Version6: + return builtin6.StorageMinerActorCodeID, nil + + case actors.Version7: + return builtin7.StorageMinerActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsStorageMinerActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == actors.MinerKey + } if c == builtin0.StorageMinerActorCodeID { return true @@ -255,7 +377,44 @@ func IsStorageMinerActor(c cid.Cid) bool { return false } +func GetMultisigActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.MultisigKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.MultisigActorCodeID, nil + + case actors.Version2: + return builtin2.MultisigActorCodeID, nil + + case actors.Version3: + return builtin3.MultisigActorCodeID, nil + + case actors.Version4: + return builtin4.MultisigActorCodeID, nil + + case actors.Version5: + return builtin5.MultisigActorCodeID, nil + + case actors.Version6: + return builtin6.MultisigActorCodeID, nil + + case actors.Version7: + return builtin7.MultisigActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsMultisigActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == actors.MultisigKey + } if c == builtin0.MultisigActorCodeID { return true @@ -288,7 +447,44 @@ func IsMultisigActor(c cid.Cid) bool { return false } +func GetPaymentChannelActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.PaychKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.PaymentChannelActorCodeID, nil + + case actors.Version2: + return builtin2.PaymentChannelActorCodeID, nil + + case actors.Version3: + return builtin3.PaymentChannelActorCodeID, nil + + case actors.Version4: + return builtin4.PaymentChannelActorCodeID, nil + + case actors.Version5: + return builtin5.PaymentChannelActorCodeID, nil + + case actors.Version6: + return builtin6.PaymentChannelActorCodeID, nil + + case actors.Version7: + return builtin7.PaymentChannelActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsPaymentChannelActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == "paymentchannel" + } if c == builtin0.PaymentChannelActorCodeID { return true @@ -321,6 +517,138 @@ func IsPaymentChannelActor(c cid.Cid) bool { return false } +func GetPowerActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.PowerKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.StoragePowerActorCodeID, nil + + case actors.Version2: + return builtin2.StoragePowerActorCodeID, nil + + case actors.Version3: + return builtin3.StoragePowerActorCodeID, nil + + case actors.Version4: + return builtin4.StoragePowerActorCodeID, nil + + case actors.Version5: + return builtin5.StoragePowerActorCodeID, nil + + case actors.Version6: + return builtin6.StoragePowerActorCodeID, nil + + case actors.Version7: + return builtin7.StoragePowerActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetRewardActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.RewardKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.RewardActorCodeID, nil + + case actors.Version2: + return builtin2.RewardActorCodeID, nil + + case actors.Version3: + return builtin3.RewardActorCodeID, nil + + case actors.Version4: + return builtin4.RewardActorCodeID, nil + + case actors.Version5: + return builtin5.RewardActorCodeID, nil + + case actors.Version6: + return builtin6.RewardActorCodeID, nil + + case actors.Version7: + return builtin7.RewardActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetSystemActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.SystemKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.SystemActorCodeID, nil + + case actors.Version2: + return builtin2.SystemActorCodeID, nil + + case actors.Version3: + return builtin3.SystemActorCodeID, nil + + case actors.Version4: + return builtin4.SystemActorCodeID, nil + + case actors.Version5: + return builtin5.SystemActorCodeID, nil + + case actors.Version6: + return builtin6.SystemActorCodeID, nil + + case actors.Version7: + return builtin7.SystemActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetVerifregActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.VerifregKey); ok { + return c, nil + } + + switch av { + + case actors.Version0: + return builtin0.VerifiedRegistryActorCodeID, nil + + case actors.Version2: + return builtin2.VerifiedRegistryActorCodeID, nil + + case actors.Version3: + return builtin3.VerifiedRegistryActorCodeID, nil + + case actors.Version4: + return builtin4.VerifiedRegistryActorCodeID, nil + + case actors.Version5: + return builtin5.VerifiedRegistryActorCodeID, nil + + case actors.Version6: + return builtin6.VerifiedRegistryActorCodeID, nil + + case actors.Version7: + return builtin7.VerifiedRegistryActorCodeID, nil + + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func makeAddress(addr string) address.Address { ret, err := address.NewFromString(addr) if err != nil { diff --git a/chain/actors/builtin/builtin.go.template b/chain/actors/builtin/builtin.go.template index f5d5eb77b..bfa5d9ec2 100644 --- a/chain/actors/builtin/builtin.go.template +++ b/chain/actors/builtin/builtin.go.template @@ -5,136 +5,336 @@ import ( "github.com/ipfs/go-cid" "golang.org/x/xerrors" - {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" - smoothing{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/util/smoothing" - {{end}} +{{range .versions}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" +{{end}} "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/cbor" + "github.com/filecoin-project/go-state-types/proof" + "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/chain/actors" - miner{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/miner" - proof{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/runtime/proof" + miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v8/miner" + smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" ) -var SystemActorAddr = builtin{{.latestVersion}}.SystemActorAddr -var BurntFundsActorAddr = builtin{{.latestVersion}}.BurntFundsActorAddr -var CronActorAddr = builtin{{.latestVersion}}.CronActorAddr +var SystemActorAddr = builtin.SystemActorAddr +var BurntFundsActorAddr = builtin.BurntFundsActorAddr +var CronActorAddr = builtin.CronActorAddr var SaftAddress = makeAddress("t0122") var ReserveAddress = makeAddress("t090") var RootVerifierAddress = makeAddress("t080") var ( - ExpectedLeadersPerEpoch = builtin{{.latestVersion}}.ExpectedLeadersPerEpoch + ExpectedLeadersPerEpoch = builtin.ExpectedLeadersPerEpoch ) const ( - EpochDurationSeconds = builtin{{.latestVersion}}.EpochDurationSeconds - EpochsInDay = builtin{{.latestVersion}}.EpochsInDay - SecondsInDay = builtin{{.latestVersion}}.SecondsInDay + EpochDurationSeconds = builtin.EpochDurationSeconds + EpochsInDay = builtin.EpochsInDay + SecondsInDay = builtin.SecondsInDay ) const ( - MethodSend = builtin{{.latestVersion}}.MethodSend - MethodConstructor = builtin{{.latestVersion}}.MethodConstructor + MethodSend = builtin.MethodSend + MethodConstructor = builtin.MethodConstructor ) // These are all just type aliases across actor versions. In the future, that might change // and we might need to do something fancier. -type SectorInfo = proof{{.latestVersion}}.SectorInfo -type ExtendedSectorInfo = proof{{.latestVersion}}.ExtendedSectorInfo -type PoStProof = proof{{.latestVersion}}.PoStProof -type FilterEstimate = smoothing0.FilterEstimate +type SectorInfo = proof.SectorInfo +type ExtendedSectorInfo = proof.ExtendedSectorInfo +type PoStProof = proof.PoStProof +type FilterEstimate = smoothingtypes.FilterEstimate func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower { return miner{{.latestVersion}}.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) } -{{range .versions}} - func FromV{{.}}FilterEstimate(v{{.}} smoothing{{.}}.FilterEstimate) FilterEstimate { - {{if (eq . 0)}} - return (FilterEstimate)(v{{.}}) //nolint:unconvert - {{else}} - return (FilterEstimate)(v{{.}}) - {{end}} - } -{{end}} - -type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) - -var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader) - -func RegisterActorState(code cid.Cid, loader ActorStateLoader) { - ActorStateLoaders[code] = loader -} - -func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) { - loader, found := ActorStateLoaders[act.Code] - if !found { - return nil, xerrors.Errorf("unknown actor code %s", act.Code) - } - return loader(store, act.Head) -} - func ActorNameByCode(c cid.Cid) string { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name + } + switch { - {{range .versions}} - case builtin{{.}}.IsBuiltinActor(c): - return builtin{{.}}.ActorNameByCode(c) - {{end}} + {{range .versions}} + case builtin{{.}}.IsBuiltinActor(c): + return builtin{{.}}.ActorNameByCode(c) + {{end}} default: return "" } } func IsBuiltinActor(c cid.Cid) bool { + _, _, ok := actors.GetActorMetaByCode(c) + if ok { + return true + } + {{range .versions}} - if builtin{{.}}.IsBuiltinActor(c) { - return true - } + {{if (le . 7)}} + if builtin{{.}}.IsBuiltinActor(c) { + return true + } + {{end}} {{end}} return false } +func GetAccountActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.AccountKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.AccountActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsAccountActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == "account" + } + {{range .versions}} - if c == builtin{{.}}.AccountActorCodeID { - return true - } + {{if (le . 7)}} + if c == builtin{{.}}.AccountActorCodeID { + return true + } + {{end}} {{end}} return false } +func GetCronActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.CronKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.CronActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetInitActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.InitKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.InitActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetMarketActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.MarketKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.StorageMarketActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetMinerActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.MinerKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.StorageMinerActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsStorageMinerActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == actors.MinerKey + } + {{range .versions}} - if c == builtin{{.}}.StorageMinerActorCodeID { - return true - } + {{if (le . 7)}} + if c == builtin{{.}}.StorageMinerActorCodeID { + return true + } + {{end}} {{end}} return false } +func GetMultisigActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.MultisigKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.MultisigActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsMultisigActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == actors.MultisigKey + } + {{range .versions}} - if c == builtin{{.}}.MultisigActorCodeID { - return true - } + {{if (le . 7)}} + if c == builtin{{.}}.MultisigActorCodeID { + return true + } + {{end}} {{end}} return false } +func GetPaymentChannelActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.PaychKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.PaymentChannelActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func IsPaymentChannelActor(c cid.Cid) bool { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name == "paymentchannel" + } + {{range .versions}} - if c == builtin{{.}}.PaymentChannelActorCodeID { - return true - } + {{if (le . 7)}} + if c == builtin{{.}}.PaymentChannelActorCodeID { + return true + } + {{end}} {{end}} return false } +func GetPowerActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.PowerKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.StoragePowerActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetRewardActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.RewardKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.RewardActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetSystemActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.SystemKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.SystemActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + +func GetVerifregActorCodeID(av actors.Version) (cid.Cid, error) { + if c, ok := actors.GetActorCodeID(av, actors.VerifregKey); ok { + return c, nil + } + + switch av { + {{range .versions}} + {{if (le . 7)}} + case actors.Version{{.}}: + return builtin{{.}}.VerifiedRegistryActorCodeID, nil + {{end}} + {{end}} + } + + return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + func makeAddress(addr string) address.Address { ret, err := address.NewFromString(addr) if err != nil { diff --git a/chain/actors/builtin/cron/actor.go.template b/chain/actors/builtin/cron/actor.go.template index d73808556..fb70f314a 100644 --- a/chain/actors/builtin/cron/actor.go.template +++ b/chain/actors/builtin/cron/actor.go.template @@ -4,12 +4,45 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "golang.org/x/xerrors" - "github.com/ipfs/go-cid" + "github.com/filecoin-project/lotus/chain/types" + {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} ) +func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.CronKey { + return nil, xerrors.Errorf("actor code is not cron: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + + switch act.Code { +{{range .versions}} + {{if (le . 7)}} + case builtin{{.}}.CronActorCodeID: + return load{{.}}(store, act.Head) + {{end}} +{{end}} + } + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) +} + func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { {{range .versions}} @@ -20,17 +53,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.CronActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - var ( Address = builtin{{.latestVersion}}.CronActorAddr Methods = builtin{{.latestVersion}}.MethodsCron diff --git a/chain/actors/builtin/cron/cron.go b/chain/actors/builtin/cron/cron.go index f27a14ac7..1a9c32c81 100644 --- a/chain/actors/builtin/cron/cron.go +++ b/chain/actors/builtin/cron/cron.go @@ -3,7 +3,7 @@ package cron import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/ipfs/go-cid" + "github.com/filecoin-project/lotus/chain/types" "golang.org/x/xerrors" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -19,8 +19,52 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" ) +func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.CronKey { + return nil, xerrors.Errorf("actor code is not cron: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + + switch act.Code { + + case builtin0.CronActorCodeID: + return load0(store, act.Head) + + case builtin2.CronActorCodeID: + return load2(store, act.Head) + + case builtin3.CronActorCodeID: + return load3(store, act.Head) + + case builtin4.CronActorCodeID: + return load4(store, act.Head) + + case builtin5.CronActorCodeID: + return load5(store, act.Head) + + case builtin6.CronActorCodeID: + return load6(store, act.Head) + + case builtin7.CronActorCodeID: + return load7(store, act.Head) + + } + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) +} + func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { @@ -45,42 +89,16 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version7: return make7(store) + case actors.Version8: + return make8(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.CronActorCodeID, nil - - case actors.Version2: - return builtin2.CronActorCodeID, nil - - case actors.Version3: - return builtin3.CronActorCodeID, nil - - case actors.Version4: - return builtin4.CronActorCodeID, nil - - case actors.Version5: - return builtin5.CronActorCodeID, nil - - case actors.Version6: - return builtin6.CronActorCodeID, nil - - case actors.Version7: - return builtin7.CronActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - var ( - Address = builtin7.CronActorAddr - Methods = builtin7.MethodsCron + Address = builtin8.CronActorAddr + Methods = builtin8.MethodsCron ) type State interface { diff --git a/chain/actors/builtin/cron/state.go.template b/chain/actors/builtin/cron/state.go.template index 99a06d7f8..13cdc46c9 100644 --- a/chain/actors/builtin/cron/state.go.template +++ b/chain/actors/builtin/cron/state.go.template @@ -5,7 +5,11 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" +{{if (le .v 7)}} cron{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/cron" +{{else}} + cron{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}cron" +{{end}} ) var _ State = (*state{{.v}})(nil) diff --git a/chain/actors/builtin/cron/v8.go b/chain/actors/builtin/cron/v8.go new file mode 100644 index 000000000..00b22fcbf --- /dev/null +++ b/chain/actors/builtin/cron/v8.go @@ -0,0 +1,35 @@ +package cron + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store) (State, error) { + out := state8{store: store} + out.State = *cron8.ConstructState(cron8.BuiltInEntries()) + return &out, nil +} + +type state8 struct { + cron8.State + store adt.Store +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/init/actor.go.template b/chain/actors/builtin/init/actor.go.template index f825eb9fa..e27c66fbb 100644 --- a/chain/actors/builtin/init/actor.go.template +++ b/chain/actors/builtin/init/actor.go.template @@ -10,33 +10,47 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - var ( Address = builtin{{.latestVersion}}.InitActorAddr Methods = builtin{{.latestVersion}}.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.InitKey { + return nil, xerrors.Errorf("actor code is not init: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.InitActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.InitActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -50,17 +64,6 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.InitActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/init/init.go b/chain/actors/builtin/init/init.go index 737241ffe..9ba412cf1 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -10,7 +10,6 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -27,45 +26,29 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" ) -func init() { - - builtin.RegisterActorState(builtin0.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - var ( - Address = builtin7.InitActorAddr - Methods = builtin7.MethodsInit + Address = builtin8.InitActorAddr + Methods = builtin8.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.InitKey { + return nil, xerrors.Errorf("actor code is not init: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.InitActorCodeID: @@ -90,6 +73,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -117,39 +101,13 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e case actors.Version7: return make7(store, networkName) + case actors.Version8: + return make8(store, networkName) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.InitActorCodeID, nil - - case actors.Version2: - return builtin2.InitActorCodeID, nil - - case actors.Version3: - return builtin3.InitActorCodeID, nil - - case actors.Version4: - return builtin4.InitActorCodeID, nil - - case actors.Version5: - return builtin5.InitActorCodeID, nil - - case actors.Version6: - return builtin6.InitActorCodeID, nil - - case actors.Version7: - return builtin7.InitActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/init/state.go.template b/chain/actors/builtin/init/state.go.template index 482ad4df5..0e56f5da4 100644 --- a/chain/actors/builtin/init/state.go.template +++ b/chain/actors/builtin/init/state.go.template @@ -10,12 +10,17 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" -{{if (ge .v 3)}} - builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" -{{end}} - +{{if (le .v 7)}} + {{if (ge .v 3)}} + builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + {{end}} init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + init{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}init" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" +{{end}} ) var _ State = (*state{{.v}})(nil) diff --git a/chain/actors/builtin/init/v8.go b/chain/actors/builtin/init/v8.go new file mode 100644 index 000000000..919819549 --- /dev/null +++ b/chain/actors/builtin/init/v8.go @@ -0,0 +1,113 @@ +package init + +import ( + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store, networkName string) (State, error) { + out := state8{store: store} + + s, err := init8.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state8 struct { + init8.State + store adt.Store +} + +func (s *state8) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state8) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state8) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth) + if err != nil { + return err + } + var actorID cbg.CborInt + return addrs.ForEach(&actorID, func(key string) error { + addr, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(abi.ActorID(actorID), addr) + }) +} + +func (s *state8) NetworkName() (dtypes.NetworkName, error) { + return dtypes.NetworkName(s.State.NetworkName), nil +} + +func (s *state8) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state8) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state8) Remove(addrs ...address.Address) (err error) { + m, err := adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth) + if err != nil { + return err + } + for _, addr := range addrs { + if err = m.Delete(abi.AddrKey(addr)); err != nil { + return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err) + } + } + amr, err := m.Root() + if err != nil { + return xerrors.Errorf("failed to get address map root: %w", err) + } + s.State.AddressMap = amr + return nil +} + +func (s *state8) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state8) AddressMap() (adt.Map, error) { + return adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index f0366e300..a96c62e43 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -1,6 +1,8 @@ package market import ( + "unicode/utf8" + "github.com/filecoin-project/go-state-types/network" "golang.org/x/xerrors" @@ -8,39 +10,52 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" + market{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}market" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - var ( Address = builtin{{.latestVersion}}.StorageMarketActorAddr Methods = builtin{{.latestVersion}}.MethodsMarket ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.MarketKey { + return nil, xerrors.Errorf("actor code is not market: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.StorageMarketActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.StorageMarketActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -54,17 +69,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.StorageMarketActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler BalancesChanged(State) (bool, error) @@ -96,14 +100,13 @@ type DealStates interface { } type DealProposals interface { - ForEach(cb func(id abi.DealID, dp DealProposal) error) error - Get(id abi.DealID) (*DealProposal, bool, error) + ForEach(cb func(id abi.DealID, dp market{{.latestVersion}}.DealProposal) error) error + Get(id abi.DealID) (*market{{.latestVersion}}.DealProposal, bool, error) array() adt.Array - decode(*cbg.Deferred) (*DealProposal, error) + decode(*cbg.Deferred) (*market{{.latestVersion}}.DealProposal, error) } -type PublishStorageDealsParams = market0.PublishStorageDealsParams type PublishStorageDealsReturn interface { DealIDs() ([]abi.DealID, error) @@ -126,30 +129,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora return nil, xerrors.Errorf("unknown actor version %d", av) } -type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams -type WithdrawBalanceParams = market0.WithdrawBalanceParams +type DealProposal = market{{.latestVersion}}.DealProposal -type ClientDealProposal = market0.ClientDealProposal - -type DealState struct { - SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector - LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated - SlashEpoch abi.ChainEpoch // -1 if deal never slashed -} - -type DealProposal struct { - PieceCID cid.Cid - PieceSize abi.PaddedPieceSize - VerifiedDeal bool - Client address.Address - Provider address.Address - Label string - StartEpoch abi.ChainEpoch - EndEpoch abi.ChainEpoch - StoragePricePerEpoch abi.TokenAmount - ProviderCollateral abi.TokenAmount - ClientCollateral abi.TokenAmount -} +type DealState = market{{.latestVersion}}.DealState type DealStateChanges struct { Added []DealIDState @@ -176,7 +158,7 @@ type DealProposalChanges struct { type ProposalIDState struct { ID abi.DealID - Proposal DealProposal + Proposal market{{.latestVersion}}.DealProposal } func EmptyDealState() *DealState { @@ -188,7 +170,7 @@ func EmptyDealState() *DealState { } // returns the earned fees and pending fees for a given deal -func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { +func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch))) ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch))) @@ -202,3 +184,11 @@ func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, ab return ef, big.Sub(tf, ef) } + +func labelFromGoString(s string) (market{{.latestVersion}}.DealLabel, error) { + if utf8.ValidString(s) { + return market{{.latestVersion}}.NewLabelFromString(s) + } else { + return market{{.latestVersion}}.NewLabelFromBytes([]byte(s)) + } +} diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index d74309c3c..b7e4897fb 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -1,6 +1,8 @@ package market import ( + "unicode/utf8" + "github.com/filecoin-project/go-state-types/network" "golang.org/x/xerrors" @@ -8,10 +10,9 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -27,49 +28,32 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtin8 "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { - - builtin.RegisterActorState(builtin0.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - var ( - Address = builtin7.StorageMarketActorAddr - Methods = builtin7.MethodsMarket + Address = builtin8.StorageMarketActorAddr + Methods = builtin8.MethodsMarket ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.MarketKey { + return nil, xerrors.Errorf("actor code is not market: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.StorageMarketActorCodeID: @@ -94,6 +78,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -121,39 +106,13 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version7: return make7(store) + case actors.Version8: + return make8(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.StorageMarketActorCodeID, nil - - case actors.Version2: - return builtin2.StorageMarketActorCodeID, nil - - case actors.Version3: - return builtin3.StorageMarketActorCodeID, nil - - case actors.Version4: - return builtin4.StorageMarketActorCodeID, nil - - case actors.Version5: - return builtin5.StorageMarketActorCodeID, nil - - case actors.Version6: - return builtin6.StorageMarketActorCodeID, nil - - case actors.Version7: - return builtin7.StorageMarketActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler BalancesChanged(State) (bool, error) @@ -185,15 +144,13 @@ type DealStates interface { } type DealProposals interface { - ForEach(cb func(id abi.DealID, dp DealProposal) error) error - Get(id abi.DealID) (*DealProposal, bool, error) + ForEach(cb func(id abi.DealID, dp market8.DealProposal) error) error + Get(id abi.DealID) (*market8.DealProposal, bool, error) array() adt.Array - decode(*cbg.Deferred) (*DealProposal, error) + decode(*cbg.Deferred) (*market8.DealProposal, error) } -type PublishStorageDealsParams = market0.PublishStorageDealsParams - type PublishStorageDealsReturn interface { DealIDs() ([]abi.DealID, error) // Note that this index is based on the batch of deals that were published, NOT the DealID @@ -229,34 +186,16 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora case actors.Version7: return decodePublishStorageDealsReturn7(b) + case actors.Version8: + return decodePublishStorageDealsReturn8(b) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams -type WithdrawBalanceParams = market0.WithdrawBalanceParams +type DealProposal = market8.DealProposal -type ClientDealProposal = market0.ClientDealProposal - -type DealState struct { - SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector - LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated - SlashEpoch abi.ChainEpoch // -1 if deal never slashed -} - -type DealProposal struct { - PieceCID cid.Cid - PieceSize abi.PaddedPieceSize - VerifiedDeal bool - Client address.Address - Provider address.Address - Label string - StartEpoch abi.ChainEpoch - EndEpoch abi.ChainEpoch - StoragePricePerEpoch abi.TokenAmount - ProviderCollateral abi.TokenAmount - ClientCollateral abi.TokenAmount -} +type DealState = market8.DealState type DealStateChanges struct { Added []DealIDState @@ -283,7 +222,7 @@ type DealProposalChanges struct { type ProposalIDState struct { ID abi.DealID - Proposal DealProposal + Proposal market8.DealProposal } func EmptyDealState() *DealState { @@ -295,7 +234,7 @@ func EmptyDealState() *DealState { } // returns the earned fees and pending fees for a given deal -func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { +func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch))) ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch))) @@ -309,3 +248,11 @@ func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, ab return ef, big.Sub(tf, ef) } + +func labelFromGoString(s string) (market8.DealLabel, error) { + if utf8.ValidString(s) { + return market8.NewLabelFromString(s) + } else { + return market8.NewLabelFromBytes([]byte(s)) + } +} diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index 091dbc2f7..1ed2fc4fc 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -17,8 +17,13 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" +{{if (le .v 7)}} market{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/market" adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + market{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}market" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +{{end}} ) var _ State = (*state{{.v}})(nil) @@ -195,7 +200,7 @@ func (s *dealStates{{.v}}) array() adt.Array { } func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState { - return (DealState)(v{{.v}}) + return (DealState)(v{{.v}}) } type dealProposals{{.v}} struct { @@ -211,14 +216,24 @@ func (s *dealProposals{{.v}}) Get(dealID abi.DealID) (*DealProposal, bool, error if !found { return nil, false, nil } - proposal := fromV{{.v}}DealProposal(proposal{{.v}}) - return &proposal, true, nil + + proposal, err := fromV{{.v}}DealProposal(proposal{{.v}}) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil } func (s *dealProposals{{.v}}) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp{{.v}} market{{.v}}.DealProposal return s.Array.ForEach(&dp{{.v}}, func(idx int64) error { - return cb(abi.DealID(idx), fromV{{.v}}DealProposal(dp{{.v}})) + dp, err := fromV{{.v}}DealProposal(dp{{.v}}) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -227,18 +242,48 @@ func (s *dealProposals{{.v}}) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp{{.v}}.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV{{.v}}DealProposal(dp{{.v}}) - return &dp, nil + + dp, err := fromV{{.v}}DealProposal(dp{{.v}}) + if err != nil { + return nil, err + } + + return &dp, nil } func (s *dealProposals{{.v}}) array() adt.Array { return s.Array } -func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal { - return (DealProposal)(v{{.v}}) +func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, error) { + {{if (le .v 7)}} + label, err := labelFromGoString(v{{.v}}.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + {{else}} + label := v{{.v}}.Label + {{end}} + + return DealProposal{ + PieceCID: v{{.v}}.PieceCID, + PieceSize: v{{.v}}.PieceSize, + VerifiedDeal: v{{.v}}.VerifiedDeal, + Client: v{{.v}}.Client, + Provider: v{{.v}}.Provider, + + Label: label, + + StartEpoch: v{{.v}}.StartEpoch, + EndEpoch: v{{.v}}.EndEpoch, + StoragePricePerEpoch: v{{.v}}.StoragePricePerEpoch, + + ProviderCollateral: v{{.v}}.ProviderCollateral, + ClientCollateral: v{{.v}}.ClientCollateral, + }, nil } + func (s *state{{.v}}) GetState() interface{} { return &s.State } diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index aa2ec4716..b57d2c724 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -199,14 +199,24 @@ func (s *dealProposals0) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV0DealProposal(proposal0) + + proposal, err := fromV0DealProposal(proposal0) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals0) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp0 market0.DealProposal return s.Array.ForEach(&dp0, func(idx int64) error { - return cb(abi.DealID(idx), fromV0DealProposal(dp0)) + dp, err := fromV0DealProposal(dp0) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -215,7 +225,12 @@ func (s *dealProposals0) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp0.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV0DealProposal(dp0) + + dp, err := fromV0DealProposal(dp0) + if err != nil { + return nil, err + } + return &dp, nil } @@ -223,8 +238,29 @@ func (s *dealProposals0) array() adt.Array { return s.Array } -func fromV0DealProposal(v0 market0.DealProposal) DealProposal { - return (DealProposal)(v0) +func fromV0DealProposal(v0 market0.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v0.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v0.PieceCID, + PieceSize: v0.PieceSize, + VerifiedDeal: v0.VerifiedDeal, + Client: v0.Client, + Provider: v0.Provider, + + Label: label, + + StartEpoch: v0.StartEpoch, + EndEpoch: v0.EndEpoch, + StoragePricePerEpoch: v0.StoragePricePerEpoch, + + ProviderCollateral: v0.ProviderCollateral, + ClientCollateral: v0.ClientCollateral, + }, nil } func (s *state0) GetState() interface{} { diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 42742936c..57ded97b2 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -199,14 +199,24 @@ func (s *dealProposals2) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV2DealProposal(proposal2) + + proposal, err := fromV2DealProposal(proposal2) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals2) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp2 market2.DealProposal return s.Array.ForEach(&dp2, func(idx int64) error { - return cb(abi.DealID(idx), fromV2DealProposal(dp2)) + dp, err := fromV2DealProposal(dp2) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -215,7 +225,12 @@ func (s *dealProposals2) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp2.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV2DealProposal(dp2) + + dp, err := fromV2DealProposal(dp2) + if err != nil { + return nil, err + } + return &dp, nil } @@ -223,8 +238,29 @@ func (s *dealProposals2) array() adt.Array { return s.Array } -func fromV2DealProposal(v2 market2.DealProposal) DealProposal { - return (DealProposal)(v2) +func fromV2DealProposal(v2 market2.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v2.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v2.PieceCID, + PieceSize: v2.PieceSize, + VerifiedDeal: v2.VerifiedDeal, + Client: v2.Client, + Provider: v2.Provider, + + Label: label, + + StartEpoch: v2.StartEpoch, + EndEpoch: v2.EndEpoch, + StoragePricePerEpoch: v2.StoragePricePerEpoch, + + ProviderCollateral: v2.ProviderCollateral, + ClientCollateral: v2.ClientCollateral, + }, nil } func (s *state2) GetState() interface{} { diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index a37171a47..f85e55456 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -194,14 +194,24 @@ func (s *dealProposals3) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV3DealProposal(proposal3) + + proposal, err := fromV3DealProposal(proposal3) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals3) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp3 market3.DealProposal return s.Array.ForEach(&dp3, func(idx int64) error { - return cb(abi.DealID(idx), fromV3DealProposal(dp3)) + dp, err := fromV3DealProposal(dp3) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -210,7 +220,12 @@ func (s *dealProposals3) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp3.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV3DealProposal(dp3) + + dp, err := fromV3DealProposal(dp3) + if err != nil { + return nil, err + } + return &dp, nil } @@ -218,8 +233,29 @@ func (s *dealProposals3) array() adt.Array { return s.Array } -func fromV3DealProposal(v3 market3.DealProposal) DealProposal { - return (DealProposal)(v3) +func fromV3DealProposal(v3 market3.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v3.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v3.PieceCID, + PieceSize: v3.PieceSize, + VerifiedDeal: v3.VerifiedDeal, + Client: v3.Client, + Provider: v3.Provider, + + Label: label, + + StartEpoch: v3.StartEpoch, + EndEpoch: v3.EndEpoch, + StoragePricePerEpoch: v3.StoragePricePerEpoch, + + ProviderCollateral: v3.ProviderCollateral, + ClientCollateral: v3.ClientCollateral, + }, nil } func (s *state3) GetState() interface{} { diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index b291ebe24..5789318fb 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -194,14 +194,24 @@ func (s *dealProposals4) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV4DealProposal(proposal4) + + proposal, err := fromV4DealProposal(proposal4) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals4) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp4 market4.DealProposal return s.Array.ForEach(&dp4, func(idx int64) error { - return cb(abi.DealID(idx), fromV4DealProposal(dp4)) + dp, err := fromV4DealProposal(dp4) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -210,7 +220,12 @@ func (s *dealProposals4) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp4.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV4DealProposal(dp4) + + dp, err := fromV4DealProposal(dp4) + if err != nil { + return nil, err + } + return &dp, nil } @@ -218,8 +233,29 @@ func (s *dealProposals4) array() adt.Array { return s.Array } -func fromV4DealProposal(v4 market4.DealProposal) DealProposal { - return (DealProposal)(v4) +func fromV4DealProposal(v4 market4.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v4.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v4.PieceCID, + PieceSize: v4.PieceSize, + VerifiedDeal: v4.VerifiedDeal, + Client: v4.Client, + Provider: v4.Provider, + + Label: label, + + StartEpoch: v4.StartEpoch, + EndEpoch: v4.EndEpoch, + StoragePricePerEpoch: v4.StoragePricePerEpoch, + + ProviderCollateral: v4.ProviderCollateral, + ClientCollateral: v4.ClientCollateral, + }, nil } func (s *state4) GetState() interface{} { diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index e8e979ba8..6dbb724df 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -194,14 +194,24 @@ func (s *dealProposals5) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV5DealProposal(proposal5) + + proposal, err := fromV5DealProposal(proposal5) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals5) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp5 market5.DealProposal return s.Array.ForEach(&dp5, func(idx int64) error { - return cb(abi.DealID(idx), fromV5DealProposal(dp5)) + dp, err := fromV5DealProposal(dp5) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -210,7 +220,12 @@ func (s *dealProposals5) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp5.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV5DealProposal(dp5) + + dp, err := fromV5DealProposal(dp5) + if err != nil { + return nil, err + } + return &dp, nil } @@ -218,8 +233,29 @@ func (s *dealProposals5) array() adt.Array { return s.Array } -func fromV5DealProposal(v5 market5.DealProposal) DealProposal { - return (DealProposal)(v5) +func fromV5DealProposal(v5 market5.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v5.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v5.PieceCID, + PieceSize: v5.PieceSize, + VerifiedDeal: v5.VerifiedDeal, + Client: v5.Client, + Provider: v5.Provider, + + Label: label, + + StartEpoch: v5.StartEpoch, + EndEpoch: v5.EndEpoch, + StoragePricePerEpoch: v5.StoragePricePerEpoch, + + ProviderCollateral: v5.ProviderCollateral, + ClientCollateral: v5.ClientCollateral, + }, nil } func (s *state5) GetState() interface{} { diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 63aaba7d4..15c55998e 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -197,14 +197,24 @@ func (s *dealProposals6) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV6DealProposal(proposal6) + + proposal, err := fromV6DealProposal(proposal6) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals6) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp6 market6.DealProposal return s.Array.ForEach(&dp6, func(idx int64) error { - return cb(abi.DealID(idx), fromV6DealProposal(dp6)) + dp, err := fromV6DealProposal(dp6) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -213,7 +223,12 @@ func (s *dealProposals6) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp6.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV6DealProposal(dp6) + + dp, err := fromV6DealProposal(dp6) + if err != nil { + return nil, err + } + return &dp, nil } @@ -221,8 +236,29 @@ func (s *dealProposals6) array() adt.Array { return s.Array } -func fromV6DealProposal(v6 market6.DealProposal) DealProposal { - return (DealProposal)(v6) +func fromV6DealProposal(v6 market6.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v6.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v6.PieceCID, + PieceSize: v6.PieceSize, + VerifiedDeal: v6.VerifiedDeal, + Client: v6.Client, + Provider: v6.Provider, + + Label: label, + + StartEpoch: v6.StartEpoch, + EndEpoch: v6.EndEpoch, + StoragePricePerEpoch: v6.StoragePricePerEpoch, + + ProviderCollateral: v6.ProviderCollateral, + ClientCollateral: v6.ClientCollateral, + }, nil } func (s *state6) GetState() interface{} { diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index 0d546d7ac..a3c2c7214 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -197,14 +197,24 @@ func (s *dealProposals7) Get(dealID abi.DealID) (*DealProposal, bool, error) { if !found { return nil, false, nil } - proposal := fromV7DealProposal(proposal7) + + proposal, err := fromV7DealProposal(proposal7) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + return &proposal, true, nil } func (s *dealProposals7) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { var dp7 market7.DealProposal return s.Array.ForEach(&dp7, func(idx int64) error { - return cb(abi.DealID(idx), fromV7DealProposal(dp7)) + dp, err := fromV7DealProposal(dp7) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) }) } @@ -213,7 +223,12 @@ func (s *dealProposals7) decode(val *cbg.Deferred) (*DealProposal, error) { if err := dp7.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return nil, err } - dp := fromV7DealProposal(dp7) + + dp, err := fromV7DealProposal(dp7) + if err != nil { + return nil, err + } + return &dp, nil } @@ -221,8 +236,29 @@ func (s *dealProposals7) array() adt.Array { return s.Array } -func fromV7DealProposal(v7 market7.DealProposal) DealProposal { - return (DealProposal)(v7) +func fromV7DealProposal(v7 market7.DealProposal) (DealProposal, error) { + + label, err := labelFromGoString(v7.Label) + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v7.PieceCID, + PieceSize: v7.PieceSize, + VerifiedDeal: v7.VerifiedDeal, + Client: v7.Client, + Provider: v7.Provider, + + Label: label, + + StartEpoch: v7.StartEpoch, + EndEpoch: v7.EndEpoch, + StoragePricePerEpoch: v7.StoragePricePerEpoch, + + ProviderCollateral: v7.ProviderCollateral, + ClientCollateral: v7.ClientCollateral, + }, nil } func (s *state7) GetState() interface{} { diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go new file mode 100644 index 000000000..a306c44e9 --- /dev/null +++ b/chain/actors/builtin/market/v8.go @@ -0,0 +1,305 @@ +package market + +import ( + "bytes" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-bitfield" + rlepluslazy "github.com/filecoin-project/go-bitfield/rle" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/types" + + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store) (State, error) { + out := state8{store: store} + + s, err := market8.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state8 struct { + market8.State + store adt.Store +} + +func (s *state8) TotalLocked() (abi.TokenAmount, error) { + fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral) + fml = types.BigAdd(fml, s.TotalClientStorageFee) + return fml, nil +} + +func (s *state8) BalancesChanged(otherState State) (bool, error) { + otherState8, ok := otherState.(*state8) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.EscrowTable.Equals(otherState8.State.EscrowTable) || !s.State.LockedTable.Equals(otherState8.State.LockedTable), nil +} + +func (s *state8) StatesChanged(otherState State) (bool, error) { + otherState8, ok := otherState.(*state8) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.States.Equals(otherState8.State.States), nil +} + +func (s *state8) States() (DealStates, error) { + stateArray, err := adt8.AsArray(s.store, s.State.States, market8.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates8{stateArray}, nil +} + +func (s *state8) ProposalsChanged(otherState State) (bool, error) { + otherState8, ok := otherState.(*state8) + if !ok { + // there's no way to compare different versions of the state, so let's + // just say that means the state of balances has changed + return true, nil + } + return !s.State.Proposals.Equals(otherState8.State.Proposals), nil +} + +func (s *state8) Proposals() (DealProposals, error) { + proposalArray, err := adt8.AsArray(s.store, s.State.Proposals, market8.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals8{proposalArray}, nil +} + +func (s *state8) EscrowTable() (BalanceTable, error) { + bt, err := adt8.AsBalanceTable(s.store, s.State.EscrowTable) + if err != nil { + return nil, err + } + return &balanceTable8{bt}, nil +} + +func (s *state8) LockedTable() (BalanceTable, error) { + bt, err := adt8.AsBalanceTable(s.store, s.State.LockedTable) + if err != nil { + return nil, err + } + return &balanceTable8{bt}, nil +} + +func (s *state8) VerifyDealsForActivation( + minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, +) (weight, verifiedWeight abi.DealWeight, err error) { + w, vw, _, err := market8.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch) + return w, vw, err +} + +func (s *state8) NextID() (abi.DealID, error) { + return s.State.NextID, nil +} + +type balanceTable8 struct { + *adt8.BalanceTable +} + +func (bt *balanceTable8) ForEach(cb func(address.Address, abi.TokenAmount) error) error { + asMap := (*adt8.Map)(bt.BalanceTable) + var ta abi.TokenAmount + return asMap.ForEach(&ta, func(key string) error { + a, err := address.NewFromBytes([]byte(key)) + if err != nil { + return err + } + return cb(a, ta) + }) +} + +type dealStates8 struct { + adt.Array +} + +func (s *dealStates8) Get(dealID abi.DealID) (*DealState, bool, error) { + var deal8 market8.DealState + found, err := s.Array.Get(uint64(dealID), &deal8) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV8DealState(deal8) + return &deal, true, nil +} + +func (s *dealStates8) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds8 market8.DealState + return s.Array.ForEach(&ds8, func(idx int64) error { + return cb(abi.DealID(idx), fromV8DealState(ds8)) + }) +} + +func (s *dealStates8) decode(val *cbg.Deferred) (*DealState, error) { + var ds8 market8.DealState + if err := ds8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV8DealState(ds8) + return &ds, nil +} + +func (s *dealStates8) array() adt.Array { + return s.Array +} + +func fromV8DealState(v8 market8.DealState) DealState { + return (DealState)(v8) +} + +type dealProposals8 struct { + adt.Array +} + +func (s *dealProposals8) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal8 market8.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal8) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV8DealProposal(proposal8) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals8) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp8 market8.DealProposal + return s.Array.ForEach(&dp8, func(idx int64) error { + dp, err := fromV8DealProposal(dp8) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals8) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp8 market8.DealProposal + if err := dp8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV8DealProposal(dp8) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals8) array() adt.Array { + return s.Array +} + +func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) { + + label := v8.Label + + return DealProposal{ + PieceCID: v8.PieceCID, + PieceSize: v8.PieceSize, + VerifiedDeal: v8.VerifiedDeal, + Client: v8.Client, + Provider: v8.Provider, + + Label: label, + + StartEpoch: v8.StartEpoch, + EndEpoch: v8.EndEpoch, + StoragePricePerEpoch: v8.StoragePricePerEpoch, + + ProviderCollateral: v8.ProviderCollateral, + ClientCollateral: v8.ClientCollateral, + }, nil +} + +func (s *state8) GetState() interface{} { + return &s.State +} + +var _ PublishStorageDealsReturn = (*publishStorageDealsReturn8)(nil) + +func decodePublishStorageDealsReturn8(b []byte) (PublishStorageDealsReturn, error) { + var retval market8.PublishStorageDealsReturn + if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil { + return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err) + } + + return &publishStorageDealsReturn8{retval}, nil +} + +type publishStorageDealsReturn8 struct { + market8.PublishStorageDealsReturn +} + +func (r *publishStorageDealsReturn8) IsDealValid(index uint64) (bool, int, error) { + + set, err := r.ValidDeals.IsSet(index) + if err != nil || !set { + return false, -1, err + } + maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{ + Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}}) + if err != nil { + return false, -1, err + } + before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals) + if err != nil { + return false, -1, err + } + outIdx, err := before.Count() + if err != nil { + return false, -1, err + } + return set, int(outIdx), nil + +} + +func (r *publishStorageDealsReturn8) DealIDs() ([]abi.DealID, error) { + return r.IDs, nil +} diff --git a/chain/actors/builtin/miner/actor.go.template b/chain/actors/builtin/miner/actor.go.template index 74c16be36..731af6255 100644 --- a/chain/actors/builtin/miner/actor.go.template +++ b/chain/actors/builtin/miner/actor.go.template @@ -4,62 +4,51 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors" - "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" + miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}miner" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" - miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" - miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{end}} {{end}} ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}} -} - -var Methods = builtin{{.latestVersion}}.MethodsMiner - -// Unchanged between v0, v2, v3, v4, and v5 actors -var WPoStProvingPeriod = miner0.WPoStProvingPeriod -var WPoStPeriodDeadlines = miner0.WPoStPeriodDeadlines -var WPoStChallengeWindow = miner0.WPoStChallengeWindow -var WPoStChallengeLookback = miner0.WPoStChallengeLookback -var FaultDeclarationCutoff = miner0.FaultDeclarationCutoff - -const MinSectorExpiration = miner0.MinSectorExpiration - -// Not used / checked in v0 -// TODO: Abstract over network versions -var DeclarationsMax = miner2.DeclarationsMax -var AddressedSectorsMax = miner2.AddressedSectorsMax - func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.MinerKey { + return nil, xerrors.Errorf("actor code is not miner: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.StorageMinerActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.StorageMinerActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} -} + } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -73,17 +62,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.StorageMinerActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -98,8 +76,8 @@ type State interface { GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) FindSector(abi.SectorNumber) (*SectorLocation, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) - GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) - ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error + GetPrecommittedSector(abi.SectorNumber) (*miner{{.latestVersion}}.SectorPreCommitOnChainInfo, error) + ForEachPrecommittedSector(func(miner{{.latestVersion}}.SectorPreCommitOnChainInfo) error) error LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error) NumLiveSectors() (uint64, error) IsAllocated(abi.SectorNumber) (bool, error) @@ -128,7 +106,7 @@ type State interface { sectors() (adt.Array, error) decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) precommits() (adt.Map, error) - decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error) + decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner{{.latestVersion}}.SectorPreCommitOnChainInfo, error) GetState() interface{} } @@ -166,44 +144,7 @@ type Partition interface { UnprovenSectors() (bitfield.BitField, error) } -type SectorOnChainInfo struct { - SectorNumber abi.SectorNumber - SealProof abi.RegisteredSealProof - SealedCID cid.Cid - DealIDs []abi.DealID - Activation abi.ChainEpoch - Expiration abi.ChainEpoch - DealWeight abi.DealWeight - VerifiedDealWeight abi.DealWeight - InitialPledge abi.TokenAmount - ExpectedDayReward abi.TokenAmount - ExpectedStoragePledge abi.TokenAmount - SectorKeyCID *cid.Cid -} - -type SectorPreCommitInfo = miner0.SectorPreCommitInfo - -type SectorPreCommitOnChainInfo struct { - Info SectorPreCommitInfo - PreCommitDeposit abi.TokenAmount - PreCommitEpoch abi.ChainEpoch - DealWeight abi.DealWeight - VerifiedDealWeight abi.DealWeight -} - -type PoStPartition = miner0.PoStPartition -type RecoveryDeclaration = miner0.RecoveryDeclaration -type FaultDeclaration = miner0.FaultDeclaration -type ReplicaUpdate = miner7.ReplicaUpdate - -// Params -type DeclareFaultsParams = miner0.DeclareFaultsParams -type DeclareFaultsRecoveredParams = miner0.DeclareFaultsRecoveredParams -type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams -type ProveCommitSectorParams = miner0.ProveCommitSectorParams -type DisputeWindowedPoStParams = miner3.DisputeWindowedPoStParams -type ProveCommitAggregateParams = miner5.ProveCommitAggregateParams -type ProveReplicaUpdatesParams = miner7.ProveReplicaUpdatesParams +type SectorOnChainInfo = miner{{.latestVersion}}.SectorOnChainInfo func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { // We added support for the new proofs in network version 7, and removed support for the old @@ -258,33 +199,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi } } -type MinerInfo struct { - Owner address.Address // Must be an ID-address. - Worker address.Address // Must be an ID-address. - NewWorker address.Address // Must be an ID-address. - ControlAddresses []address.Address // Must be an ID-addresses. - WorkerChangeEpoch abi.ChainEpoch - PeerId *peer.ID - Multiaddrs []abi.Multiaddrs - WindowPoStProofType abi.RegisteredPoStProof - SectorSize abi.SectorSize - WindowPoStPartitionSectors uint64 - ConsensusFaultElapsed abi.ChainEpoch -} - -func (mi MinerInfo) IsController(addr address.Address) bool { - if addr == mi.Owner || addr == mi.Worker { - return true - } - - for _, ca := range mi.ControlAddresses { - if addr == ca { - return true - } - } - - return false -} +type MinerInfo = miner{{.latestVersion}}.MinerInfo +type WorkerKeyChange = miner{{.latestVersion}}.WorkerKeyChange +type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo type SectorExpiration struct { OnTime abi.ChainEpoch @@ -311,8 +228,8 @@ type SectorExtensions struct { } type PreCommitChanges struct { - Added []SectorPreCommitOnChainInfo - Removed []SectorPreCommitOnChainInfo + Added []miner{{.latestVersion}}.SectorPreCommitOnChainInfo + Removed []miner{{.latestVersion}}.SectorPreCommitOnChainInfo } type LockedFunds struct { diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 7889d7a4d..44fa080a6 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -4,27 +4,19 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors" - "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/dline" + "github.com/filecoin-project/go-state-types/proof" + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" - miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" - miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" @@ -40,55 +32,20 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" ) -func init() { - - builtin.RegisterActorState(builtin0.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) - -} - -var Methods = builtin7.MethodsMiner - -// Unchanged between v0, v2, v3, v4, and v5 actors -var WPoStProvingPeriod = miner0.WPoStProvingPeriod -var WPoStPeriodDeadlines = miner0.WPoStPeriodDeadlines -var WPoStChallengeWindow = miner0.WPoStChallengeWindow -var WPoStChallengeLookback = miner0.WPoStChallengeLookback -var FaultDeclarationCutoff = miner0.FaultDeclarationCutoff - -const MinSectorExpiration = miner0.MinSectorExpiration - -// Not used / checked in v0 -// TODO: Abstract over network versions -var DeclarationsMax = miner2.DeclarationsMax -var AddressedSectorsMax = miner2.AddressedSectorsMax - func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.MinerKey { + return nil, xerrors.Errorf("actor code is not miner: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.StorageMinerActorCodeID: @@ -113,6 +70,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -140,39 +98,13 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version7: return make7(store) + case actors.Version8: + return make8(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.StorageMinerActorCodeID, nil - - case actors.Version2: - return builtin2.StorageMinerActorCodeID, nil - - case actors.Version3: - return builtin3.StorageMinerActorCodeID, nil - - case actors.Version4: - return builtin4.StorageMinerActorCodeID, nil - - case actors.Version5: - return builtin5.StorageMinerActorCodeID, nil - - case actors.Version6: - return builtin6.StorageMinerActorCodeID, nil - - case actors.Version7: - return builtin7.StorageMinerActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -187,8 +119,8 @@ type State interface { GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) FindSector(abi.SectorNumber) (*SectorLocation, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) - GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) - ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error + GetPrecommittedSector(abi.SectorNumber) (*miner8.SectorPreCommitOnChainInfo, error) + ForEachPrecommittedSector(func(miner8.SectorPreCommitOnChainInfo) error) error LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error) NumLiveSectors() (uint64, error) IsAllocated(abi.SectorNumber) (bool, error) @@ -217,7 +149,7 @@ type State interface { sectors() (adt.Array, error) decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) precommits() (adt.Map, error) - decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error) + decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner8.SectorPreCommitOnChainInfo, error) GetState() interface{} } @@ -255,44 +187,7 @@ type Partition interface { UnprovenSectors() (bitfield.BitField, error) } -type SectorOnChainInfo struct { - SectorNumber abi.SectorNumber - SealProof abi.RegisteredSealProof - SealedCID cid.Cid - DealIDs []abi.DealID - Activation abi.ChainEpoch - Expiration abi.ChainEpoch - DealWeight abi.DealWeight - VerifiedDealWeight abi.DealWeight - InitialPledge abi.TokenAmount - ExpectedDayReward abi.TokenAmount - ExpectedStoragePledge abi.TokenAmount - SectorKeyCID *cid.Cid -} - -type SectorPreCommitInfo = miner0.SectorPreCommitInfo - -type SectorPreCommitOnChainInfo struct { - Info SectorPreCommitInfo - PreCommitDeposit abi.TokenAmount - PreCommitEpoch abi.ChainEpoch - DealWeight abi.DealWeight - VerifiedDealWeight abi.DealWeight -} - -type PoStPartition = miner0.PoStPartition -type RecoveryDeclaration = miner0.RecoveryDeclaration -type FaultDeclaration = miner0.FaultDeclaration -type ReplicaUpdate = miner7.ReplicaUpdate - -// Params -type DeclareFaultsParams = miner0.DeclareFaultsParams -type DeclareFaultsRecoveredParams = miner0.DeclareFaultsRecoveredParams -type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams -type ProveCommitSectorParams = miner0.ProveCommitSectorParams -type DisputeWindowedPoStParams = miner3.DisputeWindowedPoStParams -type ProveCommitAggregateParams = miner5.ProveCommitAggregateParams -type ProveReplicaUpdatesParams = miner7.ProveReplicaUpdatesParams +type SectorOnChainInfo = miner8.SectorOnChainInfo func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) { // We added support for the new proofs in network version 7, and removed support for the old @@ -347,33 +242,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi } } -type MinerInfo struct { - Owner address.Address // Must be an ID-address. - Worker address.Address // Must be an ID-address. - NewWorker address.Address // Must be an ID-address. - ControlAddresses []address.Address // Must be an ID-addresses. - WorkerChangeEpoch abi.ChainEpoch - PeerId *peer.ID - Multiaddrs []abi.Multiaddrs - WindowPoStProofType abi.RegisteredPoStProof - SectorSize abi.SectorSize - WindowPoStPartitionSectors uint64 - ConsensusFaultElapsed abi.ChainEpoch -} - -func (mi MinerInfo) IsController(addr address.Address) bool { - if addr == mi.Owner || addr == mi.Worker { - return true - } - - for _, ca := range mi.ControlAddresses { - if addr == ca { - return true - } - } - - return false -} +type MinerInfo = miner8.MinerInfo +type WorkerKeyChange = miner8.WorkerKeyChange +type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo type SectorExpiration struct { OnTime abi.ChainEpoch @@ -400,8 +271,8 @@ type SectorExtensions struct { } type PreCommitChanges struct { - Added []SectorPreCommitOnChainInfo - Removed []SectorPreCommitOnChainInfo + Added []miner8.SectorPreCommitOnChainInfo + Removed []miner8.SectorPreCommitOnChainInfo } type LockedFunds struct { diff --git a/chain/actors/builtin/miner/state.go.template b/chain/actors/builtin/miner/state.go.template index 775631961..53c4b446a 100644 --- a/chain/actors/builtin/miner/state.go.template +++ b/chain/actors/builtin/miner/state.go.template @@ -6,23 +6,28 @@ import ( {{if (le .v 1)}} "github.com/filecoin-project/go-state-types/big" {{end}} - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/actors/adt" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" -{{if (ge .v 3)}} - builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" +{{if (le .v 7)}} + {{if (ge .v 3)}} + builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + {{end}} + miner{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/miner" + adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + miner{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}miner" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" {{end}} - miner{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/miner" - adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" ) var _ State = (*state{{.v}})(nil) @@ -210,7 +215,7 @@ func (s *state{{.v}}) GetSectorExpiration(num abi.SectorNumber) (*SectorExpirati return &out, nil } -func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -221,7 +226,7 @@ func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCom return &ret, nil } -func (s *state{{.v}}) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state{{.v}}) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { {{if (ge .v 3) -}} precommitted, err := adt{{.v}}.AsMap(s.store, s.State.PreCommittedSectors, builtin{{.v}}.DefaultHamtBitwidth) {{- else -}} @@ -389,10 +394,6 @@ func (s *state{{.v}}) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } {{if (le .v 2)}} wpp, err := info.SealProofType.RegisteredWindowPoStProof() if err != nil { @@ -404,10 +405,9 @@ func (s *state{{.v}}) Info() (MinerInfo, error) { Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: {{if (ge .v 3)}}info.WindowPoStProofType{{else}}wpp{{end}}, SectorSize: info.SectorSize, @@ -415,11 +415,6 @@ func (s *state{{.v}}) Info() (MinerInfo, error) { ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}}, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -449,11 +444,11 @@ func (s *state{{.v}}) precommits() (adt.Map, error) { return adt{{.v}}.AsMap(s.store, s.PreCommittedSectors{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) } -func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner{{.v}}.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil @@ -584,18 +579,14 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO return info } -func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { -{{if (ge .v 2)}} - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v{{.v}}.Info), +func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v{{.v}}.Info), PreCommitDeposit: v{{.v}}.PreCommitDeposit, PreCommitEpoch: v{{.v}}.PreCommitEpoch, DealWeight: v{{.v}}.DealWeight, VerifiedDealWeight: v{{.v}}.VerifiedDealWeight, } -{{else}} - return (SectorPreCommitOnChainInfo)(v0) -{{end}} } func (s *state{{.v}}) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 8bde8bf73..a6f11179c 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -6,16 +6,15 @@ import ( "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" @@ -197,7 +196,7 @@ func (s *state0) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -208,7 +207,7 @@ func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state0) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state0) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt0.AsMap(s.store, s.State.PreCommittedSectors) if err != nil { return err @@ -372,11 +371,6 @@ func (s *state0) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - wpp, err := info.SealProofType.RegisteredWindowPoStProof() if err != nil { return MinerInfo{}, err @@ -387,10 +381,9 @@ func (s *state0) Info() (MinerInfo, error) { Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: wpp, SectorSize: info.SectorSize, @@ -398,11 +391,6 @@ func (s *state0) Info() (MinerInfo, error) { ConsensusFaultElapsed: -1, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -432,11 +420,11 @@ func (s *state0) precommits() (adt.Map, error) { return adt0.AsMap(s.store, s.PreCommittedSectors) } -func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner0.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV0SectorPreCommitOnChainInfo(sp), nil @@ -522,10 +510,14 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return (SectorPreCommitOnChainInfo)(v0) - +func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v0.Info), + PreCommitDeposit: v0.PreCommitDeposit, + PreCommitEpoch: v0.PreCommitEpoch, + DealWeight: v0.DealWeight, + VerifiedDealWeight: v0.VerifiedDealWeight, + } } func (s *state0) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index bbfdd403e..f54526bf7 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -4,16 +4,15 @@ import ( "bytes" "errors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" @@ -195,7 +194,7 @@ func (s *state2) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -206,7 +205,7 @@ func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state2) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state2) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt2.AsMap(s.store, s.State.PreCommittedSectors) if err != nil { return err @@ -370,11 +369,6 @@ func (s *state2) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - wpp, err := info.SealProofType.RegisteredWindowPoStProof() if err != nil { return MinerInfo{}, err @@ -385,10 +379,9 @@ func (s *state2) Info() (MinerInfo, error) { Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: wpp, SectorSize: info.SectorSize, @@ -396,11 +389,6 @@ func (s *state2) Info() (MinerInfo, error) { ConsensusFaultElapsed: info.ConsensusFaultElapsed, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -430,11 +418,11 @@ func (s *state2) precommits() (adt.Map, error) { return adt2.AsMap(s.store, s.PreCommittedSectors) } -func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner2.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV2SectorPreCommitOnChainInfo(sp), nil @@ -552,16 +540,14 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v2.Info), +func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v2.Info), PreCommitDeposit: v2.PreCommitDeposit, PreCommitEpoch: v2.PreCommitEpoch, DealWeight: v2.DealWeight, VerifiedDealWeight: v2.VerifiedDealWeight, } - } func (s *state2) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index 68505918a..0c71d0d77 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -4,16 +4,15 @@ import ( "bytes" "errors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" @@ -197,7 +196,7 @@ func (s *state3) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -208,7 +207,7 @@ func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state3) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state3) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt3.AsMap(s.store, s.State.PreCommittedSectors, builtin3.DefaultHamtBitwidth) if err != nil { return err @@ -372,20 +371,14 @@ func (s *state3) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: info.WindowPoStProofType, SectorSize: info.SectorSize, @@ -393,11 +386,6 @@ func (s *state3) Info() (MinerInfo, error) { ConsensusFaultElapsed: info.ConsensusFaultElapsed, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -427,11 +415,11 @@ func (s *state3) precommits() (adt.Map, error) { return adt3.AsMap(s.store, s.PreCommittedSectors, builtin3.DefaultHamtBitwidth) } -func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner3.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV3SectorPreCommitOnChainInfo(sp), nil @@ -553,16 +541,14 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v3.Info), +func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v3.Info), PreCommitDeposit: v3.PreCommitDeposit, PreCommitEpoch: v3.PreCommitEpoch, DealWeight: v3.DealWeight, VerifiedDealWeight: v3.VerifiedDealWeight, } - } func (s *state3) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index 5c40d4189..21f6d3feb 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -4,16 +4,15 @@ import ( "bytes" "errors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" @@ -197,7 +196,7 @@ func (s *state4) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -208,7 +207,7 @@ func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state4) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state4) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt4.AsMap(s.store, s.State.PreCommittedSectors, builtin4.DefaultHamtBitwidth) if err != nil { return err @@ -372,20 +371,14 @@ func (s *state4) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: info.WindowPoStProofType, SectorSize: info.SectorSize, @@ -393,11 +386,6 @@ func (s *state4) Info() (MinerInfo, error) { ConsensusFaultElapsed: info.ConsensusFaultElapsed, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -427,11 +415,11 @@ func (s *state4) precommits() (adt.Map, error) { return adt4.AsMap(s.store, s.PreCommittedSectors, builtin4.DefaultHamtBitwidth) } -func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner4.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV4SectorPreCommitOnChainInfo(sp), nil @@ -553,16 +541,14 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v4.Info), +func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v4.Info), PreCommitDeposit: v4.PreCommitDeposit, PreCommitEpoch: v4.PreCommitEpoch, DealWeight: v4.DealWeight, VerifiedDealWeight: v4.VerifiedDealWeight, } - } func (s *state4) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v5.go b/chain/actors/builtin/miner/v5.go index f717934f4..d5f81e175 100644 --- a/chain/actors/builtin/miner/v5.go +++ b/chain/actors/builtin/miner/v5.go @@ -4,16 +4,15 @@ import ( "bytes" "errors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" @@ -197,7 +196,7 @@ func (s *state5) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -208,7 +207,7 @@ func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state5) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state5) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt5.AsMap(s.store, s.State.PreCommittedSectors, builtin5.DefaultHamtBitwidth) if err != nil { return err @@ -372,20 +371,14 @@ func (s *state5) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: info.WindowPoStProofType, SectorSize: info.SectorSize, @@ -393,11 +386,6 @@ func (s *state5) Info() (MinerInfo, error) { ConsensusFaultElapsed: info.ConsensusFaultElapsed, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -427,11 +415,11 @@ func (s *state5) precommits() (adt.Map, error) { return adt5.AsMap(s.store, s.PreCommittedSectors, builtin5.DefaultHamtBitwidth) } -func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner5.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV5SectorPreCommitOnChainInfo(sp), nil @@ -553,16 +541,14 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v5.Info), +func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v5.Info), PreCommitDeposit: v5.PreCommitDeposit, PreCommitEpoch: v5.PreCommitEpoch, DealWeight: v5.DealWeight, VerifiedDealWeight: v5.VerifiedDealWeight, } - } func (s *state5) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v6.go b/chain/actors/builtin/miner/v6.go index 7a9dfb0df..36631aed4 100644 --- a/chain/actors/builtin/miner/v6.go +++ b/chain/actors/builtin/miner/v6.go @@ -4,16 +4,15 @@ import ( "bytes" "errors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" @@ -197,7 +196,7 @@ func (s *state6) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -208,7 +207,7 @@ func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state6) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state6) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt6.AsMap(s.store, s.State.PreCommittedSectors, builtin6.DefaultHamtBitwidth) if err != nil { return err @@ -372,20 +371,14 @@ func (s *state6) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: info.WindowPoStProofType, SectorSize: info.SectorSize, @@ -393,11 +386,6 @@ func (s *state6) Info() (MinerInfo, error) { ConsensusFaultElapsed: info.ConsensusFaultElapsed, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -427,11 +415,11 @@ func (s *state6) precommits() (adt.Map, error) { return adt6.AsMap(s.store, s.PreCommittedSectors, builtin6.DefaultHamtBitwidth) } -func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner6.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV6SectorPreCommitOnChainInfo(sp), nil @@ -553,16 +541,14 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v6.Info), +func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v6.Info), PreCommitDeposit: v6.PreCommitDeposit, PreCommitEpoch: v6.PreCommitEpoch, DealWeight: v6.DealWeight, VerifiedDealWeight: v6.VerifiedDealWeight, } - } func (s *state6) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v7.go b/chain/actors/builtin/miner/v7.go index e1b2520e4..502620069 100644 --- a/chain/actors/builtin/miner/v7.go +++ b/chain/actors/builtin/miner/v7.go @@ -4,16 +4,15 @@ import ( "bytes" "errors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/adt" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" @@ -196,7 +195,7 @@ func (s *state7) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e return &out, nil } -func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) { +func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { info, ok, err := s.State.GetPrecommittedSector(s.store, num) if !ok || err != nil { return nil, err @@ -207,7 +206,7 @@ func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn return &ret, nil } -func (s *state7) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error { +func (s *state7) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { precommitted, err := adt7.AsMap(s.store, s.State.PreCommittedSectors, builtin7.DefaultHamtBitwidth) if err != nil { return err @@ -371,20 +370,14 @@ func (s *state7) Info() (MinerInfo, error) { return MinerInfo{}, err } - var pid *peer.ID - if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { - pid = &peerID - } - mi := MinerInfo{ Owner: info.Owner, Worker: info.Worker, ControlAddresses: info.ControlAddresses, - NewWorker: address.Undef, - WorkerChangeEpoch: -1, + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), - PeerId: pid, + PeerId: info.PeerId, Multiaddrs: info.Multiaddrs, WindowPoStProofType: info.WindowPoStProofType, SectorSize: info.SectorSize, @@ -392,11 +385,6 @@ func (s *state7) Info() (MinerInfo, error) { ConsensusFaultElapsed: info.ConsensusFaultElapsed, } - if info.PendingWorkerKey != nil { - mi.NewWorker = info.PendingWorkerKey.NewWorker - mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt - } - return mi, nil } @@ -426,11 +414,11 @@ func (s *state7) precommits() (adt.Map, error) { return adt7.AsMap(s.store, s.PreCommittedSectors, builtin7.DefaultHamtBitwidth) } -func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) { +func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { var sp miner7.SectorPreCommitOnChainInfo err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) if err != nil { - return SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } return fromV7SectorPreCommitOnChainInfo(sp), nil @@ -554,16 +542,14 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo { return info } -func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo { - - return SectorPreCommitOnChainInfo{ - Info: (SectorPreCommitInfo)(v7.Info), +func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v7.Info), PreCommitDeposit: v7.PreCommitDeposit, PreCommitEpoch: v7.PreCommitEpoch, DealWeight: v7.DealWeight, VerifiedDealWeight: v7.VerifiedDealWeight, } - } func (s *state7) GetState() interface{} { diff --git a/chain/actors/builtin/miner/v8.go b/chain/actors/builtin/miner/v8.go new file mode 100644 index 000000000..370e149e7 --- /dev/null +++ b/chain/actors/builtin/miner/v8.go @@ -0,0 +1,556 @@ +package miner + +import ( + "bytes" + "errors" + + "github.com/filecoin-project/go-bitfield" + rle "github.com/filecoin-project/go-bitfield/rle" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/dline" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store) (State, error) { + out := state8{store: store} + out.State = miner8.State{} + return &out, nil +} + +type state8 struct { + miner8.State + store adt.Store +} + +type deadline8 struct { + miner8.Deadline + store adt.Store +} + +type partition8 struct { + miner8.Partition + store adt.Store +} + +func (s *state8) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) { + defer func() { + if r := recover(); r != nil { + err = xerrors.Errorf("failed to get available balance: %w", r) + available = abi.NewTokenAmount(0) + } + }() + // this panics if the miner doesnt have enough funds to cover their locked pledge + available, err = s.GetAvailableBalance(bal) + return available, err +} + +func (s *state8) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state8) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state8) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state8) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state8) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +func (s *state8) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV8SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state8) FindSector(num abi.SectorNumber) (*SectorLocation, error) { + dlIdx, partIdx, err := s.State.FindSector(s.store, num) + if err != nil { + return nil, err + } + return &SectorLocation{ + Deadline: dlIdx, + Partition: partIdx, + }, nil +} + +func (s *state8) NumLiveSectors() (uint64, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return 0, err + } + var total uint64 + if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner8.Deadline) error { + total += dl.LiveSectors + return nil + }); err != nil { + return 0, err + } + return total, nil +} + +// GetSectorExpiration returns the effective expiration of the given sector. +// +// If the sector does not expire early, the Early expiration field is 0. +func (s *state8) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + // NOTE: this can be optimized significantly. + // 1. If the sector is non-faulty, it will expire on-time (can be + // learned from the sector info). + // 2. If it's faulty, it will expire early within the first 42 entries + // of the expiration queue. + + stopErr := errors.New("stop") + out := SectorExpiration{} + err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner8.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner8.Partition + return partitions.ForEach(&part, func(partIdx int64) error { + if found, err := part.Sectors.IsSet(uint64(num)); err != nil { + return err + } else if !found { + return nil + } + if found, err := part.Terminated.IsSet(uint64(num)); err != nil { + return err + } else if found { + // already terminated + return stopErr + } + + q, err := miner8.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner8.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner8.ExpirationSet + return q.ForEach(&exp, func(epoch int64) error { + if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil { + return err + } else if early { + out.Early = abi.ChainEpoch(epoch) + return nil + } + if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil { + return err + } else if onTime { + out.OnTime = abi.ChainEpoch(epoch) + return stopErr + } + return nil + }) + }) + }) + if err == stopErr { + err = nil + } + if err != nil { + return nil, err + } + if out.Early == 0 && out.OnTime == 0 { + return nil, xerrors.Errorf("failed to find sector %d", num) + } + return &out, nil +} + +func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV8SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state8) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt8.AsMap(s.store, s.State.PreCommittedSectors, builtin8.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner8.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV8SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state8) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner8.LoadSectors(s.store, s.State.Sectors) + if err != nil { + return nil, err + } + + // If no sector numbers are specified, load all. + if snos == nil { + infos := make([]*SectorOnChainInfo, 0, sectors.Length()) + var info8 miner8.SectorOnChainInfo + if err := sectors.ForEach(&info8, func(_ int64) error { + info := fromV8SectorOnChainInfo(info8) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos8, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos8)) + for i, info8 := range infos8 { + info := fromV8SectorOnChainInfo(*info8) + infos[i] = &info + } + return infos, nil +} + +func (s *state8) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state8) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state8) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state8) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return nil, err + } + + allocatedRuns, err := allocatedSectors.RunIterator() + if err != nil { + return nil, err + } + + unallocatedRuns, err := rle.Subtract( + &rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}}, + allocatedRuns, + ) + if err != nil { + return nil, err + } + + iter, err := rle.BitsFromRuns(unallocatedRuns) + if err != nil { + return nil, err + } + + sectors := make([]abi.SectorNumber, 0, count) + for iter.HasNext() && len(sectors) < count { + nextNo, err := iter.Next() + if err != nil { + return nil, err + } + sectors = append(sectors, abi.SectorNumber(nextNo)) + } + + return sectors, nil +} + +func (s *state8) GetAllocatedSectors() (*bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil { + return nil, err + } + + return &allocatedSectors, nil +} + +func (s *state8) LoadDeadline(idx uint64) (Deadline, error) { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return nil, err + } + dl, err := dls.LoadDeadline(s.store, idx) + if err != nil { + return nil, err + } + return &deadline8{*dl, s.store}, nil +} + +func (s *state8) ForEachDeadline(cb func(uint64, Deadline) error) error { + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + return dls.ForEach(s.store, func(i uint64, dl *miner8.Deadline) error { + return cb(i, &deadline8{*dl, s.store}) + }) +} + +func (s *state8) NumDeadlines() (uint64, error) { + return miner8.WPoStPeriodDeadlines, nil +} + +func (s *state8) DeadlinesChanged(other State) (bool, error) { + other8, ok := other.(*state8) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other8.Deadlines), nil +} + +func (s *state8) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state8) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state8) Info() (MinerInfo, error) { + info, err := s.State.GetInfo(s.store) + if err != nil { + return MinerInfo{}, err + } + + mi := MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + + PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey), + + PeerId: info.PeerId, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + } + + return mi, nil +} + +func (s *state8) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state8) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state8) sectors() (adt.Array, error) { + return adt8.AsArray(s.store, s.Sectors, miner8.SectorsAmtBitwidth) +} + +func (s *state8) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner8.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV8SectorOnChainInfo(si), nil +} + +func (s *state8) precommits() (adt.Map, error) { + return adt8.AsMap(s.store, s.PreCommittedSectors, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { + var sp miner8.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return minertypes.SectorPreCommitOnChainInfo{}, err + } + + return fromV8SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state8) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner8.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner8.Partition + err = ps.ForEach(&part, func(pindx int64) error { + _ = part.ActivateUnproven() + err = ps.Set(uint64(pindx), &part) + return nil + }) + + if err != nil { + return err + } + + dl.Partitions, err = ps.Root() + if err != nil { + return err + } + + return dls.UpdateDeadline(s.store, dindx, dl) + }) + if err != nil { + return err + } + + return s.State.SaveDeadlines(s.store, dls) + +} + +func (d *deadline8) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition8{*p, d.store}, nil +} + +func (d *deadline8) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner8.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition8{part, d.store}) + }) +} + +func (d *deadline8) PartitionsChanged(other Deadline) (bool, error) { + other8, ok := other.(*deadline8) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other8.Deadline.Partitions), nil +} + +func (d *deadline8) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline8) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition8) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition8) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition8) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition8) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v8.SectorNumber, + SealProof: v8.SealProof, + SealedCID: v8.SealedCID, + DealIDs: v8.DealIDs, + Activation: v8.Activation, + Expiration: v8.Expiration, + DealWeight: v8.DealWeight, + VerifiedDealWeight: v8.VerifiedDealWeight, + InitialPledge: v8.InitialPledge, + ExpectedDayReward: v8.ExpectedDayReward, + ExpectedStoragePledge: v8.ExpectedStoragePledge, + + SectorKeyCID: v8.SectorKeyCID, + } + return info +} + +func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: (minertypes.SectorPreCommitInfo)(v8.Info), + PreCommitDeposit: v8.PreCommitDeposit, + PreCommitEpoch: v8.PreCommitEpoch, + DealWeight: v8.DealWeight, + VerifiedDealWeight: v8.VerifiedDealWeight, + } +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/multisig/actor.go.template b/chain/actors/builtin/multisig/actor.go.template index b899815a6..bd6d4d77a 100644 --- a/chain/actors/builtin/multisig/actor.go.template +++ b/chain/actors/builtin/multisig/actor.go.template @@ -10,34 +10,46 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" - msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" - msig{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/multisig" + msig{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}multisig" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.MultisigKey { + return nil, xerrors.Errorf("actor code is not multisig: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.MultisigActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.MultisigActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -51,17 +63,6 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.MultisigActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -80,7 +81,7 @@ type State interface { GetState() interface{} } -type Transaction = msig0.Transaction +type Transaction = msig{{.latestVersion}}.Transaction var Methods = builtin{{.latestVersion}}.MethodsMultisig diff --git a/chain/actors/builtin/multisig/message.go.template b/chain/actors/builtin/multisig/message.go.template index 6bff8983a..4db88826a 100644 --- a/chain/actors/builtin/multisig/message.go.template +++ b/chain/actors/builtin/multisig/message.go.template @@ -6,9 +6,17 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + {{if (le .v 7)}} + 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" + {{else}} + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" + multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init" + "github.com/filecoin-project/lotus/chain/actors/builtin" + {{end}} + "github.com/filecoin-project/lotus/chain/actors" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" @@ -54,11 +62,24 @@ func (m message{{.v}}) Create( return nil, actErr } - // new actors are created by invoking 'exec' on the init actor with the constructor params - execParams := &init{{.v}}.ExecParams{ - CodeCID: builtin{{.v}}.MultisigActorCodeID, - ConstructorParams: enc, - } + {{if (le .v 7)}} + // new actors are created by invoking 'exec' on the init actor with the constructor params + execParams := &init{{.v}}.ExecParams{ + CodeCID: builtin{{.v}}.MultisigActorCodeID, + ConstructorParams: enc, + } + {{else}} + code, err := builtin.GetMultisigActorCodeID(actors.Version{{.v}}) + if err != nil { + return nil, xerrors.Errorf("failed to get multisig code ID") + } + + // new actors are created by invoking 'exec' on the init actor with the constructor params + execParams := &init8.ExecParams{ + CodeCID: code, + ConstructorParams: enc, + } + {{end}} enc, actErr = actors.SerializeParams(execParams) if actErr != nil { diff --git a/chain/actors/builtin/multisig/message8.go b/chain/actors/builtin/multisig/message8.go new file mode 100644 index 000000000..bc560f50d --- /dev/null +++ b/chain/actors/builtin/multisig/message8.go @@ -0,0 +1,77 @@ +package multisig + +import ( + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" + multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + "github.com/filecoin-project/lotus/chain/actors/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" +) + +type message8 struct{ message0 } + +func (m message8) Create( + signers []address.Address, threshold uint64, + unlockStart, unlockDuration abi.ChainEpoch, + initialAmount abi.TokenAmount, +) (*types.Message, error) { + + lenAddrs := uint64(len(signers)) + + if lenAddrs < threshold { + return nil, xerrors.Errorf("cannot require signing of more addresses than provided for multisig") + } + + if threshold == 0 { + threshold = lenAddrs + } + + if m.from == address.Undef { + return nil, xerrors.Errorf("must provide source address") + } + + // Set up constructor parameters for multisig + msigParams := &multisig8.ConstructorParams{ + Signers: signers, + NumApprovalsThreshold: threshold, + UnlockDuration: unlockDuration, + StartEpoch: unlockStart, + } + + enc, actErr := actors.SerializeParams(msigParams) + if actErr != nil { + return nil, actErr + } + + code, err := builtin.GetMultisigActorCodeID(actors.Version8) + if err != nil { + return nil, xerrors.Errorf("failed to get multisig code ID") + } + + // new actors are created by invoking 'exec' on the init actor with the constructor params + execParams := &init8.ExecParams{ + CodeCID: code, + ConstructorParams: enc, + } + + enc, actErr = actors.SerializeParams(execParams) + if actErr != nil { + return nil, actErr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Method: builtin8.MethodsInit.Exec, + Params: enc, + Value: initialAmount, + }, nil +} diff --git a/chain/actors/builtin/multisig/multisig.go b/chain/actors/builtin/multisig/multisig.go index f1b50475a..3985d4466 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -10,10 +10,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" - msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" - msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig" + msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -29,44 +27,27 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtin8 "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { - - builtin.RegisterActorState(builtin0.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.MultisigKey { + return nil, xerrors.Errorf("actor code is not multisig: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.MultisigActorCodeID: @@ -91,6 +72,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -118,39 +100,13 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th case actors.Version7: return make7(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + case actors.Version8: + return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.MultisigActorCodeID, nil - - case actors.Version2: - return builtin2.MultisigActorCodeID, nil - - case actors.Version3: - return builtin3.MultisigActorCodeID, nil - - case actors.Version4: - return builtin4.MultisigActorCodeID, nil - - case actors.Version5: - return builtin5.MultisigActorCodeID, nil - - case actors.Version6: - return builtin6.MultisigActorCodeID, nil - - case actors.Version7: - return builtin7.MultisigActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler @@ -169,9 +125,9 @@ type State interface { GetState() interface{} } -type Transaction = msig0.Transaction +type Transaction = msig8.Transaction -var Methods = builtin7.MethodsMultisig +var Methods = builtin8.MethodsMultisig func Message(version actors.Version, from address.Address) MessageBuilder { switch version { @@ -196,6 +152,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder { case actors.Version7: return message7{message0{from}} + + case actors.Version8: + return message8{message0{from}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -219,13 +178,13 @@ type MessageBuilder interface { } // this type is the same between v0 and v2 -type ProposalHashData = msig7.ProposalHashData -type ProposeReturn = msig7.ProposeReturn -type ProposeParams = msig7.ProposeParams -type ApproveReturn = msig7.ApproveReturn +type ProposalHashData = msig8.ProposalHashData +type ProposeReturn = msig8.ProposeReturn +type ProposeParams = msig8.ProposeParams +type ApproveReturn = msig8.ApproveReturn func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { - params := msig7.TxnIDParams{ID: msig7.TxnID(id)} + params := msig8.TxnIDParams{ID: msig8.TxnID(id)} if data != nil { if data.Requester.Protocol() != address.ID { return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester) diff --git a/chain/actors/builtin/multisig/state.go.template b/chain/actors/builtin/multisig/state.go.template index 6c0130c09..e375becc3 100644 --- a/chain/actors/builtin/multisig/state.go.template +++ b/chain/actors/builtin/multisig/state.go.template @@ -4,7 +4,6 @@ import ( "bytes" "encoding/binary" - adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" @@ -14,10 +13,17 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" -{{if (ge .v 3)}} - builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" +{{if (le .v 7)}} + {{if (ge .v 3)}} + builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + {{end}} + msig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig" + adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + msig{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}multisig" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" {{end}} - msig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig" ) var _ State = (*state{{.v}})(nil) @@ -119,7 +125,7 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error) if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state{{.v}}) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v0.go b/chain/actors/builtin/multisig/v0.go index 973ac9209..ccd9a9e37 100644 --- a/chain/actors/builtin/multisig/v0.go +++ b/chain/actors/builtin/multisig/v0.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -15,6 +13,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) @@ -109,7 +108,7 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state0) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v2.go b/chain/actors/builtin/multisig/v2.go index 5b830e695..c3579b3e2 100644 --- a/chain/actors/builtin/multisig/v2.go +++ b/chain/actors/builtin/multisig/v2.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -15,6 +13,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" msig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) @@ -109,7 +108,7 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state2) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v3.go b/chain/actors/builtin/multisig/v3.go index c4a2791b7..80682808e 100644 --- a/chain/actors/builtin/multisig/v3.go +++ b/chain/actors/builtin/multisig/v3.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -17,6 +15,7 @@ import ( builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" msig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" + adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" ) var _ State = (*state3)(nil) @@ -111,7 +110,7 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state3) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v4.go b/chain/actors/builtin/multisig/v4.go index a35a890f8..f065f9f8c 100644 --- a/chain/actors/builtin/multisig/v4.go +++ b/chain/actors/builtin/multisig/v4.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -17,6 +15,7 @@ import ( builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" msig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig" + adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" ) var _ State = (*state4)(nil) @@ -111,7 +110,7 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state4) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v5.go b/chain/actors/builtin/multisig/v5.go index 4ad9aea94..783e3987f 100644 --- a/chain/actors/builtin/multisig/v5.go +++ b/chain/actors/builtin/multisig/v5.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -17,6 +15,7 @@ import ( builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" msig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig" + adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" ) var _ State = (*state5)(nil) @@ -111,7 +110,7 @@ func (s *state5) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state5) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v6.go b/chain/actors/builtin/multisig/v6.go index fa16494f8..71ea3c00c 100644 --- a/chain/actors/builtin/multisig/v6.go +++ b/chain/actors/builtin/multisig/v6.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -17,6 +15,7 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" msig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig" + adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" ) var _ State = (*state6)(nil) @@ -111,7 +110,7 @@ func (s *state6) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state6) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v7.go b/chain/actors/builtin/multisig/v7.go index bbe41f3db..8ed1caacd 100644 --- a/chain/actors/builtin/multisig/v7.go +++ b/chain/actors/builtin/multisig/v7.go @@ -4,8 +4,6 @@ import ( "bytes" "encoding/binary" - adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -17,6 +15,7 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig" + adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" ) var _ State = (*state7)(nil) @@ -111,7 +110,7 @@ func (s *state7) decodeTransaction(val *cbg.Deferred) (Transaction, error) { if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { return Transaction{}, err } - return tx, nil + return Transaction(tx), nil } func (s *state7) GetState() interface{} { diff --git a/chain/actors/builtin/multisig/v8.go b/chain/actors/builtin/multisig/v8.go new file mode 100644 index 000000000..5b76f662e --- /dev/null +++ b/chain/actors/builtin/multisig/v8.go @@ -0,0 +1,117 @@ +package multisig + +import ( + "bytes" + "encoding/binary" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { + out := state8{store: store} + out.State = msig8.State{} + out.State.Signers = signers + out.State.NumApprovalsThreshold = threshold + out.State.StartEpoch = startEpoch + out.State.UnlockDuration = unlockDuration + out.State.InitialBalance = initialBalance + + em, err := adt8.StoreEmptyMap(store, builtin8.DefaultHamtBitwidth) + if err != nil { + return nil, err + } + + out.State.PendingTxns = em + + return &out, nil +} + +type state8 struct { + msig8.State + store adt.Store +} + +func (s *state8) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state8) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state8) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state8) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state8) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state8) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state8) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt8.AsMap(s.store, s.State.PendingTxns, builtin8.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig8.Transaction + return arr.ForEach(&out, func(key string) error { + txid, n := binary.Varint([]byte(key)) + if n <= 0 { + return xerrors.Errorf("invalid pending transaction key: %v", key) + } + return cb(txid, (Transaction)(out)) //nolint:unconvert + }) +} + +func (s *state8) PendingTxnChanged(other State) (bool, error) { + other8, ok := other.(*state8) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other8.PendingTxns), nil +} + +func (s *state8) transactions() (adt.Map, error) { + return adt8.AsMap(s.store, s.PendingTxns, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig8.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/paych/actor.go.template b/chain/actors/builtin/paych/actor.go.template index 7699e76b6..8730e6177 100644 --- a/chain/actors/builtin/paych/actor.go.template +++ b/chain/actors/builtin/paych/actor.go.template @@ -10,59 +10,50 @@ import ( "github.com/filecoin-project/go-state-types/abi" big "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" ipldcbor "github.com/ipfs/go-ipld-cbor" paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{end}} {{end}} "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - // Load returns an abstract copy of payment channel state, irregardless of actor version func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.PaychKey { + return nil, xerrors.Errorf("actor code is not paych: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.PaymentChannelActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.PaymentChannelActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return make{{.}}(store) -{{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.PaymentChannelActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - // State is an abstract version of payment channel state that works across // versions type State interface { @@ -93,17 +84,14 @@ type LaneState interface { Nonce() (uint64, error) } -type SignedVoucher = paych0.SignedVoucher -type ModVerifyParams = paych0.ModVerifyParams - // DecodeSignedVoucher decodes base64 encoded signed voucher. -func DecodeSignedVoucher(s string) (*SignedVoucher, error) { +func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) { data, err := base64.RawURLEncoding.DecodeString(s) if err != nil { return nil, err } - var sv SignedVoucher + var sv paychtypes.SignedVoucher if err := ipldcbor.DecodeInto(data, &sv); err != nil { return nil, err } @@ -111,8 +99,6 @@ func DecodeSignedVoucher(s string) (*SignedVoucher, error) { return &sv, nil } -var Methods = builtin{{.latestVersion}}.MethodsPaych - func Message(version actors.Version, from address.Address) MessageBuilder { switch version { {{range .versions}} @@ -126,7 +112,23 @@ func Message(version actors.Version, from address.Address) MessageBuilder { type MessageBuilder interface { Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) - Update(paych address.Address, voucher *SignedVoucher, secret []byte) (*types.Message, error) + Update(paych address.Address, voucher *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) Settle(paych address.Address) (*types.Message, error) Collect(paych address.Address) (*types.Message, error) } + +func toV0SignedVoucher(sv paychtypes.SignedVoucher) paych0.SignedVoucher { + return paych0.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretPreimage: sv.SecretHash, + Extra: (*paych0.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: nil, + Signature: sv.Signature, + } +} \ No newline at end of file diff --git a/chain/actors/builtin/paych/message.go.template b/chain/actors/builtin/paych/message.go.template index 99f64cabb..9e92bf748 100644 --- a/chain/actors/builtin/paych/message.go.template +++ b/chain/actors/builtin/paych/message.go.template @@ -1,12 +1,24 @@ package paych import ( + {{if (ge .v 8)}} + "golang.org/x/xerrors" + {{end}} + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" - init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" - paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + {{if (le .v 7)}} + builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" + paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych" + {{else}} + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" + paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/paych" + init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init" + {{end}} + "github.com/filecoin-project/lotus/chain/actors" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" @@ -16,12 +28,21 @@ import ( type message{{.v}} struct{ from address.Address } func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + {{if (le .v 7)}} + actorCodeID := builtin{{.v}}.PaymentChannelActorCodeID + {{else}} + actorCodeID, ok := actors.GetActorCodeID(actors.Version{{.v}}, "paymentchannel") + if !ok { + return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", {{.v}}) + } + {{end}} + params, aerr := actors.SerializeParams(&paych{{.v}}.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init{{.v}}.ExecParams{ - CodeCID: builtin{{.v}}.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +58,10 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) }, nil } -func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{ - {{if (ge .v 7)}} - Sv: toV{{.v}}SignedVoucher(*sv), + {{if (le .v 6)}} + Sv: toV0SignedVoucher(*sv), {{else}} Sv: *sv, {{end}} diff --git a/chain/actors/builtin/paych/message0.go b/chain/actors/builtin/paych/message0.go index 7cba977e3..2daa0301b 100644 --- a/chain/actors/builtin/paych/message0.go +++ b/chain/actors/builtin/paych/message0.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message0 struct{ from address.Address } func (m message0) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin0.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych0.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init0.ExecParams{ - CodeCID: builtin0.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message0) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message0) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message0) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych0.UpdateChannelStateParams{ - Sv: *sv, + Sv: toV0SignedVoucher(*sv), Secret: secret, }) diff --git a/chain/actors/builtin/paych/message2.go b/chain/actors/builtin/paych/message2.go index 60c7fe16e..925ad0ed9 100644 --- a/chain/actors/builtin/paych/message2.go +++ b/chain/actors/builtin/paych/message2.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message2 struct{ from address.Address } func (m message2) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin2.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych2.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init2.ExecParams{ - CodeCID: builtin2.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message2) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message2) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message2) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych2.UpdateChannelStateParams{ - Sv: *sv, + Sv: toV0SignedVoucher(*sv), Secret: secret, }) diff --git a/chain/actors/builtin/paych/message3.go b/chain/actors/builtin/paych/message3.go index 04fb35b57..e8ae585fc 100644 --- a/chain/actors/builtin/paych/message3.go +++ b/chain/actors/builtin/paych/message3.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" paych3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message3 struct{ from address.Address } func (m message3) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin3.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych3.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init3.ExecParams{ - CodeCID: builtin3.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message3) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message3) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message3) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych3.UpdateChannelStateParams{ - Sv: *sv, + Sv: toV0SignedVoucher(*sv), Secret: secret, }) diff --git a/chain/actors/builtin/paych/message4.go b/chain/actors/builtin/paych/message4.go index 9f5e000d9..b32b0fa57 100644 --- a/chain/actors/builtin/paych/message4.go +++ b/chain/actors/builtin/paych/message4.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init" paych4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message4 struct{ from address.Address } func (m message4) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin4.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych4.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init4.ExecParams{ - CodeCID: builtin4.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message4) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message4) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message4) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych4.UpdateChannelStateParams{ - Sv: *sv, + Sv: toV0SignedVoucher(*sv), Secret: secret, }) diff --git a/chain/actors/builtin/paych/message5.go b/chain/actors/builtin/paych/message5.go index 71e6b6799..897bebe7a 100644 --- a/chain/actors/builtin/paych/message5.go +++ b/chain/actors/builtin/paych/message5.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init" paych5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message5 struct{ from address.Address } func (m message5) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin5.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych5.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init5.ExecParams{ - CodeCID: builtin5.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message5) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message5) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message5) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych5.UpdateChannelStateParams{ - Sv: *sv, + Sv: toV0SignedVoucher(*sv), Secret: secret, }) diff --git a/chain/actors/builtin/paych/message6.go b/chain/actors/builtin/paych/message6.go index 7f80bc4a6..11bd3a8a5 100644 --- a/chain/actors/builtin/paych/message6.go +++ b/chain/actors/builtin/paych/message6.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init" paych6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message6 struct{ from address.Address } func (m message6) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin6.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych6.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init6.ExecParams{ - CodeCID: builtin6.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message6) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message6) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message6) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych6.UpdateChannelStateParams{ - Sv: *sv, + Sv: toV0SignedVoucher(*sv), Secret: secret, }) diff --git a/chain/actors/builtin/paych/message7.go b/chain/actors/builtin/paych/message7.go index e3ee0d77b..446e54ead 100644 --- a/chain/actors/builtin/paych/message7.go +++ b/chain/actors/builtin/paych/message7.go @@ -4,6 +4,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init" paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych" @@ -16,12 +18,15 @@ import ( type message7 struct{ from address.Address } func (m message7) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID := builtin7.PaymentChannelActorCodeID + params, aerr := actors.SerializeParams(&paych7.ConstructorParams{From: m.from, To: to}) if aerr != nil { return nil, aerr } enc, aerr := actors.SerializeParams(&init7.ExecParams{ - CodeCID: builtin7.PaymentChannelActorCodeID, + CodeCID: actorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -37,10 +42,10 @@ func (m message7) Create(to address.Address, initialAmount abi.TokenAmount) (*ty }, nil } -func (m message7) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) { +func (m message7) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { params, aerr := actors.SerializeParams(&paych7.UpdateChannelStateParams{ - Sv: toV7SignedVoucher(*sv), + Sv: *sv, Secret: secret, }) diff --git a/chain/actors/builtin/paych/message8.go b/chain/actors/builtin/paych/message8.go new file mode 100644 index 000000000..189b20988 --- /dev/null +++ b/chain/actors/builtin/paych/message8.go @@ -0,0 +1,86 @@ +package paych + +import ( + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" + paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" + + "github.com/filecoin-project/lotus/chain/actors" + init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" + "github.com/filecoin-project/lotus/chain/types" +) + +type message8 struct{ from address.Address } + +func (m message8) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID, ok := actors.GetActorCodeID(actors.Version8, "paymentchannel") + if !ok { + return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 8) + } + + params, aerr := actors.SerializeParams(&paych8.ConstructorParams{From: m.from, To: to}) + if aerr != nil { + return nil, aerr + } + enc, aerr := actors.SerializeParams(&init8.ExecParams{ + CodeCID: actorCodeID, + ConstructorParams: params, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Value: initialAmount, + Method: builtin8.MethodsInit.Exec, + Params: enc, + }, nil +} + +func (m message8) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { + params, aerr := actors.SerializeParams(&paych8.UpdateChannelStateParams{ + + Sv: *sv, + + Secret: secret, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin8.MethodsPaych.UpdateChannelState, + Params: params, + }, nil +} + +func (m message8) Settle(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin8.MethodsPaych.Settle, + }, nil +} + +func (m message8) Collect(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin8.MethodsPaych.Collect, + }, nil +} diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index f807b33ed..9dd373e8b 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -10,9 +10,9 @@ import ( "github.com/filecoin-project/go-state-types/abi" big "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/cbor" - "github.com/ipfs/go-cid" ipldcbor "github.com/ipfs/go-ipld-cbor" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -31,43 +31,24 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { - - builtin.RegisterActorState(builtin0.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - // Load returns an abstract copy of payment channel state, irregardless of actor version func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.PaychKey { + return nil, xerrors.Errorf("actor code is not paych: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.PaymentChannelActorCodeID: @@ -92,66 +73,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { - - case actors.Version0: - return make0(store) - - case actors.Version2: - return make2(store) - - case actors.Version3: - return make3(store) - - case actors.Version4: - return make4(store) - - case actors.Version5: - return make5(store) - - case actors.Version6: - return make6(store) - - case actors.Version7: - return make7(store) - - } - return nil, xerrors.Errorf("unknown actor version %d", av) -} - -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.PaymentChannelActorCodeID, nil - - case actors.Version2: - return builtin2.PaymentChannelActorCodeID, nil - - case actors.Version3: - return builtin3.PaymentChannelActorCodeID, nil - - case actors.Version4: - return builtin4.PaymentChannelActorCodeID, nil - - case actors.Version5: - return builtin5.PaymentChannelActorCodeID, nil - - case actors.Version6: - return builtin6.PaymentChannelActorCodeID, nil - - case actors.Version7: - return builtin7.PaymentChannelActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - // State is an abstract version of payment channel state that works across // versions type State interface { @@ -182,17 +107,14 @@ type LaneState interface { Nonce() (uint64, error) } -type SignedVoucher = paych0.SignedVoucher -type ModVerifyParams = paych0.ModVerifyParams - // DecodeSignedVoucher decodes base64 encoded signed voucher. -func DecodeSignedVoucher(s string) (*SignedVoucher, error) { +func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) { data, err := base64.RawURLEncoding.DecodeString(s) if err != nil { return nil, err } - var sv SignedVoucher + var sv paychtypes.SignedVoucher if err := ipldcbor.DecodeInto(data, &sv); err != nil { return nil, err } @@ -200,8 +122,6 @@ func DecodeSignedVoucher(s string) (*SignedVoucher, error) { return &sv, nil } -var Methods = builtin7.MethodsPaych - func Message(version actors.Version, from address.Address) MessageBuilder { switch version { @@ -226,6 +146,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder { case actors.Version7: return message7{from} + case actors.Version8: + return message8{from} + default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -233,7 +156,23 @@ func Message(version actors.Version, from address.Address) MessageBuilder { type MessageBuilder interface { Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) - Update(paych address.Address, voucher *SignedVoucher, secret []byte) (*types.Message, error) + Update(paych address.Address, voucher *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) Settle(paych address.Address) (*types.Message, error) Collect(paych address.Address) (*types.Message, error) } + +func toV0SignedVoucher(sv paychtypes.SignedVoucher) paych0.SignedVoucher { + return paych0.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretPreimage: sv.SecretHash, + Extra: (*paych0.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: nil, + Signature: sv.Signature, + } +} diff --git a/chain/actors/builtin/paych/state.go.template b/chain/actors/builtin/paych/state.go.template index f11407202..c3954ce81 100644 --- a/chain/actors/builtin/paych/state.go.template +++ b/chain/actors/builtin/paych/state.go.template @@ -9,8 +9,13 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" +{{if (le .v 7)}} paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych" adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + paych{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}paych" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" +{{end}} ) var _ State = (*state{{.v}})(nil) @@ -112,21 +117,3 @@ func (ls *laneState{{.v}}) Redeemed() (big.Int, error) { func (ls *laneState{{.v}}) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } - -{{if (ge .v 7)}} -func toV{{.v}}SignedVoucher(sv SignedVoucher) paych{{.v}}.SignedVoucher { - return paych{{.v}}.SignedVoucher{ - ChannelAddr: sv.ChannelAddr, - TimeLockMin: sv.TimeLockMin, - TimeLockMax: sv.TimeLockMax, - SecretHash: sv.SecretPreimage, - Extra: sv.Extra, - Lane: sv.Lane, - Nonce: sv.Nonce, - Amount: sv.Amount, - MinSettleHeight: sv.MinSettleHeight, - Merges: sv.Merges, - Signature: sv.Signature, - } -} -{{end}} \ No newline at end of file diff --git a/chain/actors/builtin/paych/v7.go b/chain/actors/builtin/paych/v7.go index 19c801c82..ce09ea2e4 100644 --- a/chain/actors/builtin/paych/v7.go +++ b/chain/actors/builtin/paych/v7.go @@ -112,19 +112,3 @@ func (ls *laneState7) Redeemed() (big.Int, error) { func (ls *laneState7) Nonce() (uint64, error) { return ls.LaneState.Nonce, nil } - -func toV7SignedVoucher(sv SignedVoucher) paych7.SignedVoucher { - return paych7.SignedVoucher{ - ChannelAddr: sv.ChannelAddr, - TimeLockMin: sv.TimeLockMin, - TimeLockMax: sv.TimeLockMax, - SecretHash: sv.SecretPreimage, - Extra: sv.Extra, - Lane: sv.Lane, - Nonce: sv.Nonce, - Amount: sv.Amount, - MinSettleHeight: sv.MinSettleHeight, - Merges: sv.Merges, - Signature: sv.Signature, - } -} diff --git a/chain/actors/builtin/paych/v8.go b/chain/actors/builtin/paych/v8.go new file mode 100644 index 000000000..7936b76e1 --- /dev/null +++ b/chain/actors/builtin/paych/v8.go @@ -0,0 +1,114 @@ +package paych + +import ( + "github.com/ipfs/go-cid" + + "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/lotus/chain/actors/adt" + + paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store) (State, error) { + out := state8{store: store} + out.State = paych8.State{} + return &out, nil +} + +type state8 struct { + paych8.State + store adt.Store + lsAmt *adt8.Array +} + +// Channel owner, who has funded the actor +func (s *state8) From() (address.Address, error) { + return s.State.From, nil +} + +// Recipient of payouts from channel +func (s *state8) To() (address.Address, error) { + return s.State.To, nil +} + +// Height at which the channel can be `Collected` +func (s *state8) SettlingAt() (abi.ChainEpoch, error) { + return s.State.SettlingAt, nil +} + +// Amount successfully redeemed through the payment channel, paid out on `Collect()` +func (s *state8) ToSend() (abi.TokenAmount, error) { + return s.State.ToSend, nil +} + +func (s *state8) getOrLoadLsAmt() (*adt8.Array, error) { + if s.lsAmt != nil { + return s.lsAmt, nil + } + + // Get the lane state from the chain + lsamt, err := adt8.AsArray(s.store, s.State.LaneStates, paych8.LaneStatesAmtBitwidth) + if err != nil { + return nil, err + } + + s.lsAmt = lsamt + return lsamt, nil +} + +// Get total number of lanes +func (s *state8) LaneCount() (uint64, error) { + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return 0, err + } + return lsamt.Length(), nil +} + +func (s *state8) GetState() interface{} { + return &s.State +} + +// Iterate lane states +func (s *state8) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { + // Get the lane state from the chain + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return err + } + + // Note: we use a map instead of an array to store laneStates because the + // client sets the lane ID (the index) and potentially they could use a + // very large index. + var ls paych8.LaneState + return lsamt.ForEach(&ls, func(i int64) error { + return cb(uint64(i), &laneState8{ls}) + }) +} + +type laneState8 struct { + paych8.LaneState +} + +func (ls *laneState8) Redeemed() (big.Int, error) { + return ls.LaneState.Redeemed, nil +} + +func (ls *laneState8) Nonce() (uint64, error) { + return ls.LaneState.Nonce, nil +} diff --git a/chain/actors/builtin/power/actor.go.template b/chain/actors/builtin/power/actor.go.template index fe11fc160..af9190357 100644 --- a/chain/actors/builtin/power/actor.go.template +++ b/chain/actors/builtin/power/actor.go.template @@ -4,7 +4,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" - "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -14,30 +13,46 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" + {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - var ( Address = builtin{{.latestVersion}}.StoragePowerActorAddr Methods = builtin{{.latestVersion}}.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.PowerKey { + return nil, xerrors.Errorf("actor code is not power: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.StoragePowerActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.StoragePowerActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -51,17 +66,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.StoragePowerActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/power/power.go b/chain/actors/builtin/power/power.go index 9b73cdd60..1b79a623c 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -4,7 +4,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" - "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" @@ -28,45 +27,29 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" ) -func init() { - - builtin.RegisterActorState(builtin0.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - var ( - Address = builtin7.StoragePowerActorAddr - Methods = builtin7.MethodsPower + Address = builtin8.StoragePowerActorAddr + Methods = builtin8.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.PowerKey { + return nil, xerrors.Errorf("actor code is not power: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.StoragePowerActorCodeID: @@ -91,6 +74,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -118,39 +102,13 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version7: return make7(store) + case actors.Version8: + return make8(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.StoragePowerActorCodeID, nil - - case actors.Version2: - return builtin2.StoragePowerActorCodeID, nil - - case actors.Version3: - return builtin3.StoragePowerActorCodeID, nil - - case actors.Version4: - return builtin4.StoragePowerActorCodeID, nil - - case actors.Version5: - return builtin5.StoragePowerActorCodeID, nil - - case actors.Version6: - return builtin6.StoragePowerActorCodeID, nil - - case actors.Version7: - return builtin7.StoragePowerActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/power/state.go.template b/chain/actors/builtin/power/state.go.template index fcdc5c350..b53ba68c8 100644 --- a/chain/actors/builtin/power/state.go.template +++ b/chain/actors/builtin/power/state.go.template @@ -11,11 +11,17 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" -{{if (ge .v 3)}} - builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" -{{end}} +{{if (le .v 7)}} + {{if (ge .v 3)}} + builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + {{end}} power{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/power" adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" + power{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}power" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +{{end}} ) var _ State = (*state{{.v}})(nil) @@ -100,7 +106,7 @@ func (s *state{{.v}}) MinerNominalPowerMeetsConsensusMinimum(a address.Address) } func (s *state{{.v}}) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV{{.v}}FilterEstimate({{if (le .v 1)}}*{{end}}s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate({{if (le .v 1)}}*{{end}}s.State.ThisEpochQAPowerSmoothed), nil } func (s *state{{.v}}) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v0.go b/chain/actors/builtin/power/v0.go index 465d16c5c..e114ac219 100644 --- a/chain/actors/builtin/power/v0.go +++ b/chain/actors/builtin/power/v0.go @@ -89,7 +89,7 @@ func (s *state0) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state0) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV0FilterEstimate(*s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(*s.State.ThisEpochQAPowerSmoothed), nil } func (s *state0) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v2.go b/chain/actors/builtin/power/v2.go index 606534cef..405bad8ba 100644 --- a/chain/actors/builtin/power/v2.go +++ b/chain/actors/builtin/power/v2.go @@ -89,7 +89,7 @@ func (s *state2) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state2) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV2FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil } func (s *state2) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v3.go b/chain/actors/builtin/power/v3.go index 3dec3c63e..0ff06f617 100644 --- a/chain/actors/builtin/power/v3.go +++ b/chain/actors/builtin/power/v3.go @@ -86,7 +86,7 @@ func (s *state3) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state3) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV3FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil } func (s *state3) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v4.go b/chain/actors/builtin/power/v4.go index b73eedf5a..f121e3b2f 100644 --- a/chain/actors/builtin/power/v4.go +++ b/chain/actors/builtin/power/v4.go @@ -86,7 +86,7 @@ func (s *state4) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state4) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV4FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil } func (s *state4) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v5.go b/chain/actors/builtin/power/v5.go index 84b23a577..851522e50 100644 --- a/chain/actors/builtin/power/v5.go +++ b/chain/actors/builtin/power/v5.go @@ -86,7 +86,7 @@ func (s *state5) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state5) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV5FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil } func (s *state5) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v6.go b/chain/actors/builtin/power/v6.go index 4273c2c73..083b85f45 100644 --- a/chain/actors/builtin/power/v6.go +++ b/chain/actors/builtin/power/v6.go @@ -86,7 +86,7 @@ func (s *state6) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state6) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV6FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil } func (s *state6) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v7.go b/chain/actors/builtin/power/v7.go index af1761cb2..af626cf3a 100644 --- a/chain/actors/builtin/power/v7.go +++ b/chain/actors/builtin/power/v7.go @@ -86,7 +86,7 @@ func (s *state7) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool } func (s *state7) TotalPowerSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV7FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil } func (s *state7) MinerCounts() (uint64, uint64, error) { diff --git a/chain/actors/builtin/power/v8.go b/chain/actors/builtin/power/v8.go new file mode 100644 index 000000000..177d3bc3d --- /dev/null +++ b/chain/actors/builtin/power/v8.go @@ -0,0 +1,186 @@ +package power + +import ( + "bytes" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + power8 "github.com/filecoin-project/go-state-types/builtin/v8/power" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store) (State, error) { + out := state8{store: store} + + s, err := power8.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state8 struct { + power8.State + store adt.Store +} + +func (s *state8) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state8) TotalPower() (Claim, error) { + return Claim{ + RawBytePower: s.TotalRawBytePower, + QualityAdjPower: s.TotalQualityAdjPower, + }, nil +} + +// Committed power to the network. Includes miners below the minimum threshold. +func (s *state8) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state8) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.claims() + if err != nil { + return Claim{}, false, err + } + var claim power8.Claim + ok, err := claims.Get(abi.AddrKey(addr), &claim) + if err != nil { + return Claim{}, false, err + } + return Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }, ok, nil +} + +func (s *state8) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state8) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state8) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state8) ListAllMiners() ([]address.Address, error) { + claims, err := s.claims() + if err != nil { + return nil, err + } + + var miners []address.Address + err = claims.ForEach(nil, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + miners = append(miners, a) + return nil + }) + if err != nil { + return nil, err + } + + return miners, nil +} + +func (s *state8) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.claims() + if err != nil { + return err + } + + var claim power8.Claim + return claims.ForEach(&claim, func(k string) error { + a, err := address.NewFromBytes([]byte(k)) + if err != nil { + return err + } + return cb(a, Claim{ + RawBytePower: claim.RawBytePower, + QualityAdjPower: claim.QualityAdjPower, + }) + }) +} + +func (s *state8) ClaimsChanged(other State) (bool, error) { + other8, ok := other.(*state8) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other8.State.Claims), nil +} + +func (s *state8) SetTotalQualityAdjPower(p abi.StoragePower) error { + s.State.TotalQualityAdjPower = p + return nil +} + +func (s *state8) SetTotalRawBytePower(p abi.StoragePower) error { + s.State.TotalRawBytePower = p + return nil +} + +func (s *state8) SetThisEpochQualityAdjPower(p abi.StoragePower) error { + s.State.ThisEpochQualityAdjPower = p + return nil +} + +func (s *state8) SetThisEpochRawBytePower(p abi.StoragePower) error { + s.State.ThisEpochRawBytePower = p + return nil +} + +func (s *state8) GetState() interface{} { + return &s.State +} + +func (s *state8) claims() (adt.Map, error) { + return adt8.AsMap(s.store, s.Claims, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power8.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV8Claim(ci), nil +} + +func fromV8Claim(v8 power8.Claim) Claim { + return Claim{ + RawBytePower: v8.RawBytePower, + QualityAdjPower: v8.QualityAdjPower, + } +} diff --git a/chain/actors/builtin/reward/actor.go.template b/chain/actors/builtin/reward/actor.go.template index 89cdddaec..3e0e859a3 100644 --- a/chain/actors/builtin/reward/actor.go.template +++ b/chain/actors/builtin/reward/actor.go.template @@ -3,13 +3,16 @@ package reward import ( "github.com/filecoin-project/go-state-types/abi" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" - "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/cbor" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} "github.com/filecoin-project/lotus/chain/actors/adt" @@ -17,25 +20,36 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}}} - var ( Address = builtin{{.latestVersion}}.RewardActorAddr Methods = builtin{{.latestVersion}}.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.RewardKey { + return nil, xerrors.Errorf("actor code is not reward: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.RewardActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.RewardActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -49,17 +63,6 @@ func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.Storage return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.RewardActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index b6ee2f146..504c8a9ba 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -4,7 +4,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/chain/actors" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" - "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/cbor" @@ -23,48 +22,32 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtin8 "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" ) -func init() { - - builtin.RegisterActorState(builtin0.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} - var ( - Address = builtin7.RewardActorAddr - Methods = builtin7.MethodsReward + Address = builtin8.RewardActorAddr + Methods = builtin8.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.RewardKey { + return nil, xerrors.Errorf("actor code is not reward: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.RewardActorCodeID: @@ -89,6 +72,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -116,39 +100,13 @@ func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.Storage case actors.Version7: return make7(store, currRealizedPower) + case actors.Version8: + return make8(store, currRealizedPower) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.RewardActorCodeID, nil - - case actors.Version2: - return builtin2.RewardActorCodeID, nil - - case actors.Version3: - return builtin3.RewardActorCodeID, nil - - case actors.Version4: - return builtin4.RewardActorCodeID, nil - - case actors.Version5: - return builtin5.RewardActorCodeID, nil - - case actors.Version6: - return builtin6.RewardActorCodeID, nil - - case actors.Version7: - return builtin7.RewardActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/reward/state.go.template b/chain/actors/builtin/reward/state.go.template index 2bc271cbb..dac3d82a4 100644 --- a/chain/actors/builtin/reward/state.go.template +++ b/chain/actors/builtin/reward/state.go.template @@ -7,9 +7,15 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" +{{if (le .v 7)}} miner{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/miner" reward{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/reward" smoothing{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/smoothing" +{{else}} + smoothing{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/smoothing" + miner{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}miner" + reward{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}reward" +{{end}} ) var _ State = (*state{{.v}})(nil) @@ -45,7 +51,7 @@ func (s *state{{.v}}) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, }, nil {{else}} - return builtin.FromV0FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil + return builtin.FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil {{end}} } diff --git a/chain/actors/builtin/reward/v0.go b/chain/actors/builtin/reward/v0.go index cd098c151..646ab3a9a 100644 --- a/chain/actors/builtin/reward/v0.go +++ b/chain/actors/builtin/reward/v0.go @@ -40,7 +40,7 @@ func (s *state0) ThisEpochReward() (abi.TokenAmount, error) { func (s *state0) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { - return builtin.FromV0FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil + return builtin.FilterEstimate(*s.State.ThisEpochRewardSmoothed), nil } diff --git a/chain/actors/builtin/reward/v8.go b/chain/actors/builtin/reward/v8.go new file mode 100644 index 000000000..3d49063df --- /dev/null +++ b/chain/actors/builtin/reward/v8.go @@ -0,0 +1,98 @@ +package reward + +import ( + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + reward8 "github.com/filecoin-project/go-state-types/builtin/v8/reward" + smoothing8 "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { + out := state8{store: store} + out.State = *reward8.ConstructState(currRealizedPower) + return &out, nil +} + +type state8 struct { + reward8.State + store adt.Store +} + +func (s *state8) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state8) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state8) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state8) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state8) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state8) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state8) CumsumBaseline() (reward8.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state8) CumsumRealized() (reward8.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state8) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner8.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing8.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state8) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner8.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing8.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/system/actor.go.template b/chain/actors/builtin/system/actor.go.template index 925319970..616a20a76 100644 --- a/chain/actors/builtin/system/actor.go.template +++ b/chain/actors/builtin/system/actor.go.template @@ -3,11 +3,16 @@ package system import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/types" + "golang.org/x/xerrors" - "github.com/ipfs/go-cid" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} ) @@ -15,6 +20,34 @@ var ( Address = builtin{{.latestVersion}}.SystemActorAddr ) +func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.SystemKey { + return nil, xerrors.Errorf("actor code is not system: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + + switch act.Code { +{{range .versions}} + {{if (le . 7)}} + case builtin{{.}}.SystemActorCodeID: + return load{{.}}(store, act.Head) + {{end}} +{{end}} + } + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) +} + func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { {{range .versions}} @@ -25,17 +58,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.SystemActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { GetState() interface{} } diff --git a/chain/actors/builtin/system/state.go.template b/chain/actors/builtin/system/state.go.template index fa644f8c7..ddf458305 100644 --- a/chain/actors/builtin/system/state.go.template +++ b/chain/actors/builtin/system/state.go.template @@ -5,7 +5,11 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" +{{if (le .v 7)}} system{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/system" +{{else}} + system{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}system" +{{end}} ) var _ State = (*state{{.v}})(nil) diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go index fb7515f35..71d7f7024 100644 --- a/chain/actors/builtin/system/system.go +++ b/chain/actors/builtin/system/system.go @@ -3,7 +3,8 @@ package system import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/ipfs/go-cid" + "github.com/filecoin-project/lotus/chain/types" + "golang.org/x/xerrors" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -19,12 +20,56 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin7.SystemActorAddr + Address = builtin8.SystemActorAddr ) +func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.SystemKey { + return nil, xerrors.Errorf("actor code is not system: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + + switch act.Code { + + case builtin0.SystemActorCodeID: + return load0(store, act.Head) + + case builtin2.SystemActorCodeID: + return load2(store, act.Head) + + case builtin3.SystemActorCodeID: + return load3(store, act.Head) + + case builtin4.SystemActorCodeID: + return load4(store, act.Head) + + case builtin5.SystemActorCodeID: + return load5(store, act.Head) + + case builtin6.SystemActorCodeID: + return load6(store, act.Head) + + case builtin7.SystemActorCodeID: + return load7(store, act.Head) + + } + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) +} + func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { @@ -49,39 +94,13 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version7: return make7(store) + case actors.Version8: + return make8(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.SystemActorCodeID, nil - - case actors.Version2: - return builtin2.SystemActorCodeID, nil - - case actors.Version3: - return builtin3.SystemActorCodeID, nil - - case actors.Version4: - return builtin4.SystemActorCodeID, nil - - case actors.Version5: - return builtin5.SystemActorCodeID, nil - - case actors.Version6: - return builtin6.SystemActorCodeID, nil - - case actors.Version7: - return builtin7.SystemActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - type State interface { GetState() interface{} } diff --git a/chain/actors/builtin/system/v8.go b/chain/actors/builtin/system/v8.go new file mode 100644 index 000000000..2e0e2ba56 --- /dev/null +++ b/chain/actors/builtin/system/v8.go @@ -0,0 +1,35 @@ +package system + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + system8 "github.com/filecoin-project/go-state-types/builtin/v8/system" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store) (State, error) { + out := state8{store: store} + out.State = system8.State{} + return &out, nil +} + +type state8 struct { + system8.State + store adt.Store +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index adc156948..3df256004 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -1,7 +1,6 @@ package verifreg import ( - "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -9,36 +8,48 @@ import ( "github.com/filecoin-project/go-state-types/cbor" {{range .versions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{if (le . 7)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{else}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + {{end}} {{end}} "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" - verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" ) -func init() { -{{range .versions}} - builtin.RegisterActorState(builtin{{.}}.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load{{.}}(store, root) - }) -{{end}} -} - var ( Address = builtin{{.latestVersion}}.VerifiedRegistryActorAddr Methods = builtin{{.latestVersion}}.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.VerifregKey { + return nil, xerrors.Errorf("actor code is not verifreg: %s", name) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actors.Version{{.}}: + return load{{.}}(store, act.Head) + {{end}} + {{end}} + } + } + switch act.Code { {{range .versions}} - case builtin{{.}}.VerifiedRegistryActorCodeID: - return load{{.}}(store, act.Head) + {{if (le . 7)}} + case builtin{{.}}.VerifiedRegistryActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -52,23 +63,6 @@ func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Addres return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { -{{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.VerifiedRegistryActorCodeID, nil -{{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - -type RemoveDataCapProposal = verifreg{{.latestVersion}}.RemoveDataCapProposal -type RemoveDataCapRequest = verifreg{{.latestVersion}}.RemoveDataCapRequest -type RemoveDataCapParams = verifreg{{.latestVersion}}.RemoveDataCapParams -type RmDcProposalID = verifreg{{.latestVersion}}.RmDcProposalID -const SignatureDomainSeparation_RemoveDataCap = verifreg{{.latestVersion}}.SignatureDomainSeparation_RemoveDataCap - type State interface { cbor.Marshaler diff --git a/chain/actors/builtin/verifreg/state.go.template b/chain/actors/builtin/verifreg/state.go.template index 4dfc11469..aaca86905 100644 --- a/chain/actors/builtin/verifreg/state.go.template +++ b/chain/actors/builtin/verifreg/state.go.template @@ -8,9 +8,17 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" -{{if (ge .v 3)}} builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" -{{end}} verifreg{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/verifreg" +{{if (le .v 7)}} + {{if (ge .v 3)}} + builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + {{end}} + verifreg{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/verifreg" adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt" +{{else}} + verifreg{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}verifreg" + adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt" + builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" +{{end}} ) var _ State = (*state{{.v}})(nil) diff --git a/chain/actors/builtin/verifreg/v3.go b/chain/actors/builtin/verifreg/v3.go index c71c69f92..b7ab18080 100644 --- a/chain/actors/builtin/verifreg/v3.go +++ b/chain/actors/builtin/verifreg/v3.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + verifreg3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/verifreg" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" ) diff --git a/chain/actors/builtin/verifreg/v4.go b/chain/actors/builtin/verifreg/v4.go index d3adc5169..aee3fbdca 100644 --- a/chain/actors/builtin/verifreg/v4.go +++ b/chain/actors/builtin/verifreg/v4.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + verifreg4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/verifreg" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" ) diff --git a/chain/actors/builtin/verifreg/v5.go b/chain/actors/builtin/verifreg/v5.go index 2af501af3..4a74e1ea8 100644 --- a/chain/actors/builtin/verifreg/v5.go +++ b/chain/actors/builtin/verifreg/v5.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + verifreg5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/verifreg" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" ) diff --git a/chain/actors/builtin/verifreg/v6.go b/chain/actors/builtin/verifreg/v6.go index 454c9478f..a776f1149 100644 --- a/chain/actors/builtin/verifreg/v6.go +++ b/chain/actors/builtin/verifreg/v6.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + verifreg6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/verifreg" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" ) diff --git a/chain/actors/builtin/verifreg/v7.go b/chain/actors/builtin/verifreg/v7.go index 3bcfa10bd..39d72a15d 100644 --- a/chain/actors/builtin/verifreg/v7.go +++ b/chain/actors/builtin/verifreg/v7.go @@ -9,6 +9,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" ) diff --git a/chain/actors/builtin/verifreg/v8.go b/chain/actors/builtin/verifreg/v8.go new file mode 100644 index 000000000..95fdf2e6d --- /dev/null +++ b/chain/actors/builtin/verifreg/v8.go @@ -0,0 +1,83 @@ +package verifreg + +import ( + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + + builtin8 "github.com/filecoin-project/go-state-types/builtin" + adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" +) + +var _ State = (*state8)(nil) + +func load8(store adt.Store, root cid.Cid) (State, error) { + out := state8{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make8(store adt.Store, rootKeyAddress address.Address) (State, error) { + out := state8{store: store} + + s, err := verifreg8.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state8 struct { + verifreg8.State + store adt.Store +} + +func (s *state8) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state8) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version8, s.verifiedClients, addr) +} + +func (s *state8) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version8, s.verifiers, addr) +} + +func (s *state8) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version8, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state8) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version8, s.verifiers, cb) +} + +func (s *state8) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version8, s.verifiedClients, cb) +} + +func (s *state8) verifiedClients() (adt.Map, error) { + return adt8.AsMap(s.store, s.VerifiedClients, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) verifiers() (adt.Map, error) { + return adt8.AsMap(s.store, s.Verifiers, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) removeDataCapProposalIDs() (adt.Map, error) { + return adt8.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin8.DefaultHamtBitwidth) +} + +func (s *state8) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index cb26e324b..7c04bb733 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -1,7 +1,6 @@ package verifreg import ( - "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -23,51 +22,32 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtin8 "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/types" - verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" ) -func init() { - - builtin.RegisterActorState(builtin0.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load0(store, root) - }) - - builtin.RegisterActorState(builtin2.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load2(store, root) - }) - - builtin.RegisterActorState(builtin3.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load3(store, root) - }) - - builtin.RegisterActorState(builtin4.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) - - builtin.RegisterActorState(builtin5.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) - - builtin.RegisterActorState(builtin6.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) - - builtin.RegisterActorState(builtin7.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) - -} - var ( - Address = builtin7.VerifiedRegistryActorAddr - Methods = builtin7.MethodsVerifiedRegistry + Address = builtin8.VerifiedRegistryActorAddr + Methods = builtin8.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { + if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { + if name != actors.VerifregKey { + return nil, xerrors.Errorf("actor code is not verifreg: %s", name) + } + + switch av { + + case actors.Version8: + return load8(store, act.Head) + + } + } + switch act.Code { case builtin0.VerifiedRegistryActorCodeID: @@ -92,6 +72,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return load7(store, act.Head) } + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } @@ -119,46 +100,13 @@ func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Addres case actors.Version7: return make7(store, rootKeyAddress) + case actors.Version8: + return make8(store, rootKeyAddress) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { - switch av { - - case actors.Version0: - return builtin0.VerifiedRegistryActorCodeID, nil - - case actors.Version2: - return builtin2.VerifiedRegistryActorCodeID, nil - - case actors.Version3: - return builtin3.VerifiedRegistryActorCodeID, nil - - case actors.Version4: - return builtin4.VerifiedRegistryActorCodeID, nil - - case actors.Version5: - return builtin5.VerifiedRegistryActorCodeID, nil - - case actors.Version6: - return builtin6.VerifiedRegistryActorCodeID, nil - - case actors.Version7: - return builtin7.VerifiedRegistryActorCodeID, nil - - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) -} - -type RemoveDataCapProposal = verifreg7.RemoveDataCapProposal -type RemoveDataCapRequest = verifreg7.RemoveDataCapRequest -type RemoveDataCapParams = verifreg7.RemoveDataCapParams -type RmDcProposalID = verifreg7.RmDcProposalID - -const SignatureDomainSeparation_RemoveDataCap = verifreg7.SignatureDomainSeparation_RemoveDataCap - type State interface { cbor.Marshaler diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go new file mode 100644 index 000000000..b78c9a83c --- /dev/null +++ b/chain/actors/manifest.go @@ -0,0 +1,147 @@ +package actors + +import ( + "context" + "strings" + "sync" + + "github.com/filecoin-project/go-state-types/manifest" + + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/chain/actors/adt" + cid "github.com/ipfs/go-cid" + cbor "github.com/ipfs/go-ipld-cbor" +) + +var manifestCids map[Version]cid.Cid +var manifests map[Version]*manifest.Manifest +var actorMeta map[cid.Cid]actorEntry + +const ( + AccountKey = "account" + CronKey = "cron" + InitKey = "init" + MarketKey = "storagemarket" + MinerKey = "storageminer" + MultisigKey = "multisig" + PaychKey = "paymentchannel" + PowerKey = "storagepower" + RewardKey = "reward" + SystemKey = "system" + VerifregKey = "verifiedregistry" +) + +func GetBuiltinActorsKeys() []string { + return []string{ + AccountKey, + CronKey, + InitKey, + MarketKey, + MinerKey, + MultisigKey, + PaychKey, + PowerKey, + RewardKey, + SystemKey, + VerifregKey, + } +} + +var ( + manifestMx sync.RWMutex +) + +type actorEntry struct { + name string + version Version +} + +func AddManifest(av Version, manifestCid cid.Cid) { + manifestMx.Lock() + defer manifestMx.Unlock() + + if manifestCids == nil { + manifestCids = make(map[Version]cid.Cid) + } + + manifestCids[av] = manifestCid +} + +func GetManifest(av Version) (cid.Cid, bool) { + manifestMx.RLock() + defer manifestMx.RUnlock() + + c, ok := manifestCids[av] + return c, ok +} + +func LoadManifests(ctx context.Context, store cbor.IpldStore) error { + manifestMx.Lock() + defer manifestMx.Unlock() + + return loadManifests(ctx, store) +} + +func loadManifests(ctx context.Context, store cbor.IpldStore) error { + adtStore := adt.WrapStore(ctx, store) + + manifests = make(map[Version]*manifest.Manifest) + actorMeta = make(map[cid.Cid]actorEntry) + + for av, mfCid := range manifestCids { + mf := &manifest.Manifest{} + if err := adtStore.Get(ctx, mfCid, mf); err != nil { + return xerrors.Errorf("error reading manifest for network version %d (cid: %s): %w", av, mfCid, err) + } + + if err := mf.Load(ctx, adtStore); err != nil { + return xerrors.Errorf("error loading manifest for network version %d: %w", av, err) + } + + manifests[av] = mf + + var actorKeys = GetBuiltinActorsKeys() + for _, name := range actorKeys { + c, ok := mf.Get(name) + if ok { + actorMeta[c] = actorEntry{name: name, version: av} + } + } + } + + return nil +} + +func GetActorCodeID(av Version, name string) (cid.Cid, bool) { + manifestMx.RLock() + defer manifestMx.RUnlock() + + mf, ok := manifests[av] + if ok { + return mf.Get(name) + } + + return cid.Undef, false +} + +func GetActorMetaByCode(c cid.Cid) (string, Version, bool) { + manifestMx.RLock() + defer manifestMx.RUnlock() + + entry, ok := actorMeta[c] + if !ok { + return "", -1, false + } + + return entry.name, entry.version, true +} + +func CanonicalName(name string) string { + idx := strings.LastIndex(name, "/") + if idx >= 0 { + return name[idx+1:] + } + + return name +} diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index f51da7aa7..f4f04f4a9 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -12,47 +12,59 @@ import ( market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" + power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" verifreg3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/verifreg" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner" verifreg4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/verifreg" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" verifreg5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/verifreg" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market" miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" verifreg6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/verifreg" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg" - paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych" + builtin8 "github.com/filecoin-project/go-state-types/builtin" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" + + paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" ) const ( - ChainFinality = miner7.ChainFinality + ChainFinality = miner8.ChainFinality SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych7.SettleDelay - MaxPreCommitRandomnessLookback = builtin7.EpochsInDay + SealRandomnessLookback + PaychSettleDelay = paych8.SettleDelay + MaxPreCommitRandomnessLookback = builtin8.EpochsInDay + SealRandomnessLookback ) // SetSupportedProofTypes sets supported proof types, across all actor versions. @@ -79,6 +91,8 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { miner7.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + miner8.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) + AddSupportedProofTypes(types...) } @@ -135,6 +149,15 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { miner7.WindowPoStProofTypes[wpp] = struct{}{} + miner8.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} + wpp, err = t.RegisteredWindowPoStProof() + if err != nil { + // Fine to panic, this is a test-only method + panic(err) + } + + miner8.WindowPoStProofTypes[wpp] = struct{}{} + } } @@ -157,11 +180,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { miner7.PreCommitChallengeDelay = delay + miner8.PreCommitChallengeDelay = delay + } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. func GetPreCommitChallengeDelay() abi.ChainEpoch { - return miner7.PreCommitChallengeDelay + return miner8.PreCommitChallengeDelay } // SetConsensusMinerMinPower sets the minimum power of an individual miner must @@ -195,6 +220,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) { policy.ConsensusMinerMinPower = p } + for _, policy := range builtin8.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should @@ -215,6 +244,8 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { verifreg7.MinVerifiedDealSize = size + verifreg8.MinVerifiedDealSize = size + } func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { @@ -248,6 +279,10 @@ func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (a return miner7.MaxProveCommitDuration[t], nil + case actors.Version8: + + return miner8.MaxProveCommitDuration[t], nil + default: return 0, xerrors.Errorf("unsupported actors version") } @@ -288,6 +323,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) { Denominator: denom, } + market8.ProviderCollateralSupplyTarget = builtin8.BigFrac{ + Numerator: num, + Denominator: denom, + } + } func DealProviderCollateralBounds( @@ -336,13 +376,18 @@ func DealProviderCollateralBounds( min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil + case actors.Version8: + + min, max := market8.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) + return min, max, nil + default: return big.Zero(), big.Zero(), xerrors.Errorf("unsupported actors version") } } func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) { - return market7.DealDurationBounds(pieceSize) + return market8.DealDurationBounds(pieceSize) } // Sets the challenge window and scales the proving period to match (such that @@ -390,6 +435,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) { // scale it if we're scaling the challenge period. miner7.WPoStDisputeWindow = period * 30 + miner8.WPoStChallengeWindow = period + miner8.WPoStProvingPeriod = period * abi.ChainEpoch(miner8.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner8.WPoStDisputeWindow = period * 30 + } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -402,15 +454,15 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { } func GetMaxSectorExpirationExtension() abi.ChainEpoch { - return miner7.MaxSectorExpirationExtension + return miner8.MaxSectorExpirationExtension } func GetMinSectorExpiration() abi.ChainEpoch { - return miner7.MinSectorExpiration + return miner8.MinSectorExpiration } func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) { - sectorsPerPart, err := builtin7.PoStProofWindowPoStPartitionSectors(p) + sectorsPerPart, err := builtin8.PoStProofWindowPoStPartitionSectors(p) if err != nil { return 0, err } @@ -423,8 +475,8 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e func GetDefaultSectorSize() abi.SectorSize { // supported sector sizes are the same across versions. - szs := make([]abi.SectorSize, 0, len(miner7.PreCommitSealProofTypesV8)) - for spt := range miner7.PreCommitSealProofTypesV8 { + szs := make([]abi.SectorSize, 0, len(miner8.PreCommitSealProofTypesV8)) + for spt := range miner8.PreCommitSealProofTypesV8 { ss, err := spt.SectorSize() if err != nil { panic(err) @@ -449,7 +501,7 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime } - return builtin7.SealProofPoliciesV11[proof].SectorMaxLifetime + return builtin8.SealProofPoliciesV11[proof].SectorMaxLifetime } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { @@ -480,6 +532,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { case actors.Version7: return miner7.AddressedSectorsMax, nil + case actors.Version8: + return miner8.AddressedSectorsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } @@ -521,6 +576,10 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { return miner7.DeclarationsMax, nil + case actors.Version8: + + return miner8.DeclarationsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } @@ -561,6 +620,10 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + case actors.Version8: + + return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), xerrors.Errorf("unsupported network version") } @@ -601,6 +664,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + case actors.Version8: + + return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), xerrors.Errorf("unsupported network version") } diff --git a/chain/actors/policy/policy.go.template b/chain/actors/policy/policy.go.template index 64c1b7083..090e91165 100644 --- a/chain/actors/policy/policy.go.template +++ b/chain/actors/policy/policy.go.template @@ -11,14 +11,26 @@ import ( "github.com/filecoin-project/lotus/chain/actors" {{range .versions}} - {{if (ge . 2)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" {{end}} - market{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/market" - miner{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/miner" - verifreg{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/verifreg" - {{if (eq . 0)}} power{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/power" {{end}} + {{if (ge . 8)}} + builtin{{.}} "github.com/filecoin-project/go-state-types/builtin" + miner{{.}} "github.com/filecoin-project/go-state-types/builtin{{import .}}miner" + market{{.}} "github.com/filecoin-project/go-state-types/builtin{{import .}}market" + verifreg{{.}} "github.com/filecoin-project/go-state-types/builtin{{import .}}verifreg" + {{else}} + {{if (ge . 2)}} + builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{end}} + market{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/market" + miner{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/miner" + verifreg{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/verifreg" + {{if (eq . 0)}} + power{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/power" + {{end}} + {{end}} {{end}} - paych{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/paych" + paych{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}paych" + ) const ( diff --git a/chain/actors/version.go b/chain/actors/version.go index af51161c9..1a17a6972 100644 --- a/chain/actors/version.go +++ b/chain/actors/version.go @@ -20,9 +20,9 @@ const ({{range .actorVersions}} /* inline-gen start */ -var LatestVersion = 7 +var LatestVersion = 8 -var Versions = []int{0, 2, 3, 4, 5, 6, 7} +var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8} const ( Version0 Version = 0 @@ -32,6 +32,7 @@ const ( Version5 Version = 5 Version6 Version = 6 Version7 Version = 7 + Version8 Version = 8 ) /* inline-gen end */ @@ -53,6 +54,8 @@ func VersionForNetwork(version network.Version) (Version, error) { return Version6, nil case network.Version15: return Version7, nil + case network.Version16: + return Version8, nil default: return -1, fmt.Errorf("unsupported network version %d", version) } diff --git a/chain/beacon/beacon.go b/chain/beacon/beacon.go index 220057282..9c795fc91 100644 --- a/chain/beacon/beacon.go +++ b/chain/beacon/beacon.go @@ -3,6 +3,8 @@ package beacon import ( "context" + "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/go-state-types/abi" logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" @@ -42,10 +44,10 @@ type BeaconPoint struct { type RandomBeacon interface { Entry(context.Context, uint64) <-chan Response VerifyEntry(types.BeaconEntry, types.BeaconEntry) error - MaxBeaconRoundForEpoch(abi.ChainEpoch) uint64 + MaxBeaconRoundForEpoch(network.Version, abi.ChainEpoch) uint64 } -func ValidateBlockValues(bSchedule Schedule, h *types.BlockHeader, parentEpoch abi.ChainEpoch, +func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockHeader, parentEpoch abi.ChainEpoch, prevEntry types.BeaconEntry) error { { parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) @@ -65,7 +67,7 @@ func ValidateBlockValues(bSchedule Schedule, h *types.BlockHeader, parentEpoch a // TODO: fork logic b := bSchedule.BeaconForEpoch(h.Height) - maxRound := b.MaxBeaconRoundForEpoch(h.Height) + maxRound := b.MaxBeaconRoundForEpoch(nv, h.Height) if maxRound == prevEntry.Round { if len(h.BeaconEntries) != 0 { return xerrors.Errorf("expected not to have any beacon entries in this block, got %d", len(h.BeaconEntries)) @@ -92,13 +94,13 @@ func ValidateBlockValues(bSchedule Schedule, h *types.BlockHeader, parentEpoch a return nil } -func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, epoch abi.ChainEpoch, parentEpoch abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) { +func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, nv network.Version, epoch abi.ChainEpoch, parentEpoch abi.ChainEpoch, prev types.BeaconEntry) ([]types.BeaconEntry, error) { { parentBeacon := bSchedule.BeaconForEpoch(parentEpoch) currBeacon := bSchedule.BeaconForEpoch(epoch) if parentBeacon != currBeacon { // Fork logic - round := currBeacon.MaxBeaconRoundForEpoch(epoch) + round := currBeacon.MaxBeaconRoundForEpoch(nv, epoch) out := make([]types.BeaconEntry, 2) rch := currBeacon.Entry(ctx, round-1) res := <-rch @@ -120,7 +122,7 @@ func BeaconEntriesForBlock(ctx context.Context, bSchedule Schedule, epoch abi.Ch start := build.Clock.Now() - maxRound := beacon.MaxBeaconRoundForEpoch(epoch) + maxRound := beacon.MaxBeaconRoundForEpoch(nv, epoch) if maxRound == prev.Round { return nil, nil } diff --git a/chain/beacon/drand/drand.go b/chain/beacon/drand/drand.go index 118ab36e6..550fefab4 100644 --- a/chain/beacon/drand/drand.go +++ b/chain/beacon/drand/drand.go @@ -5,6 +5,8 @@ import ( "context" "time" + "github.com/filecoin-project/go-state-types/network" + dchain "github.com/drand/drand/chain" dclient "github.com/drand/drand/client" hclient "github.com/drand/drand/client/http" @@ -201,11 +203,32 @@ func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntr return err } -func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch) uint64 { +func (db *DrandBeacon) MaxBeaconRoundForEpoch(nv network.Version, filEpoch abi.ChainEpoch) uint64 { // TODO: sometimes the genesis time for filecoin is zero and this goes negative latestTs := ((uint64(filEpoch) * db.filRoundTime) + db.filGenTime) - db.filRoundTime + + if nv <= network.Version15 { + return db.maxBeaconRoundV1(latestTs) + } + + return db.maxBeaconRoundV2(latestTs) +} + +func (db *DrandBeacon) maxBeaconRoundV1(latestTs uint64) uint64 { dround := (latestTs - db.drandGenTime) / uint64(db.interval.Seconds()) return dround } +func (db *DrandBeacon) maxBeaconRoundV2(latestTs uint64) uint64 { + if latestTs < db.drandGenTime { + return 1 + } + + fromGenesis := latestTs - db.drandGenTime + // we take the time from genesis divided by the periods in seconds, that + // gives us the number of periods since genesis. We also add +1 because + // round 1 starts at genesis time. + return fromGenesis/uint64(db.interval.Seconds()) + 1 +} + var _ beacon.RandomBeacon = (*DrandBeacon)(nil) diff --git a/chain/beacon/drand/drand_test.go b/chain/beacon/drand/drand_test.go index 44effd506..4990dfb01 100644 --- a/chain/beacon/drand/drand_test.go +++ b/chain/beacon/drand/drand_test.go @@ -6,6 +6,8 @@ import ( "os" "testing" + "github.com/filecoin-project/go-state-types/network" + dchain "github.com/drand/drand/chain" hclient "github.com/drand/drand/client/http" "github.com/stretchr/testify/assert" @@ -25,3 +27,12 @@ func TestPrintGroupInfo(t *testing.T) { err = chain.ToJSON(os.Stdout) assert.NoError(t, err) } + +func TestMaxBeaconRoundForEpoch(t *testing.T) { + todayTs := uint64(1652222222) + db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[build.DrandDevnet]) + assert.NoError(t, err) + mbr15 := db.MaxBeaconRoundForEpoch(network.Version15, 100) + mbr16 := db.MaxBeaconRoundForEpoch(network.Version16, 100) + assert.Equal(t, mbr15+1, mbr16) +} diff --git a/chain/beacon/mock.go b/chain/beacon/mock.go index 2fc64b956..811698905 100644 --- a/chain/beacon/mock.go +++ b/chain/beacon/mock.go @@ -6,6 +6,8 @@ import ( "encoding/binary" "time" + "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/chain/types" "github.com/minio/blake2b-simd" @@ -53,7 +55,7 @@ func (mb *mockBeacon) VerifyEntry(from types.BeaconEntry, to types.BeaconEntry) return nil } -func (mb *mockBeacon) MaxBeaconRoundForEpoch(epoch abi.ChainEpoch) uint64 { +func (mb *mockBeacon) MaxBeaconRoundForEpoch(nv network.Version, epoch abi.ChainEpoch) uint64 { // offset for better testing return uint64(epoch + 100) } diff --git a/chain/consensus/filcns/compute_state.go b/chain/consensus/filcns/compute_state.go index 9b2183a59..657b2dd5a 100644 --- a/chain/consensus/filcns/compute_state.go +++ b/chain/consensus/filcns/compute_state.go @@ -2,21 +2,8 @@ package filcns import ( "context" - "os" "sync/atomic" - "github.com/filecoin-project/lotus/chain/rand" - - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "go.opencensus.io/stats" - "go.opencensus.io/trace" - "golang.org/x/xerrors" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/big" - blockadt "github.com/filecoin-project/specs-actors/actors/util/adt" - /* inline-gen template {{range .actorVersions}} exported{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin/exported"{{end}} @@ -30,9 +17,22 @@ import ( exported5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/exported" exported6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/exported" exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported" + exported8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/exported" /* inline-gen end */ + "github.com/filecoin-project/lotus/chain/rand" + + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "go.opencensus.io/stats" + "go.opencensus.io/trace" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + blockadt "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" @@ -49,20 +49,21 @@ import ( func NewActorRegistry() *vm.ActorRegistry { inv := vm.NewActorRegistry() - // TODO: define all these properties on the actors themselves, in specs-actors. /* inline-gen template {{range .actorVersions}} - inv.Register(vm.ActorsVersionPredicate(actors.Version{{.}}), exported{{.}}.BuiltinActors()...){{end}} + inv.Register(actors.Version{{.}}, vm.ActorsVersionPredicate(actors.Version{{.}}), exported{{.}}.BuiltinActors()...){{end}} + /* inline-gen start */ - inv.Register(vm.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...) - inv.Register(vm.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...) - inv.Register(vm.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...) - inv.Register(vm.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...) - inv.Register(vm.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...) - inv.Register(vm.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...) - inv.Register(vm.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...) + inv.Register(actors.Version0, vm.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...) + inv.Register(actors.Version2, vm.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...) + inv.Register(actors.Version3, vm.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...) + inv.Register(actors.Version4, vm.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...) + inv.Register(actors.Version5, vm.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...) + inv.Register(actors.Version6, vm.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...) + inv.Register(actors.Version7, vm.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...) + inv.Register(actors.Version8, vm.ActorsVersionPredicate(actors.Version8), exported8.BuiltinActors()...) /* inline-gen end */ @@ -109,19 +110,6 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts), } - if os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" { - // This is needed so that the FVM does not have to duplicate the genesis vesting schedule, one - // of the components of the circ supply calc. - // This field is NOT needed by the LegacyVM, and also NOT needed by the FVM from v15 onwards. - filVested, err := sm.GetFilVested(ctx, e) - if err != nil { - return nil, err - } - - vmopt.FilVested = filVested - return vm.NewFVM(ctx, vmopt) - } - return sm.VMConstructor()(ctx, vmopt) } diff --git a/chain/consensus/filcns/filecoin.go b/chain/consensus/filcns/filecoin.go index 3aa85c7c5..be608cecc 100644 --- a/chain/consensus/filcns/filecoin.go +++ b/chain/consensus/filcns/filecoin.go @@ -264,7 +264,8 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock) return nil } - if err := beacon.ValidateBlockValues(filec.beacon, h, baseTs.Height(), *prevBeacon); err != nil { + nv := filec.sm.GetNetworkVersion(ctx, h.Height) + if err := beacon.ValidateBlockValues(filec.beacon, nv, h, baseTs.Height(), *prevBeacon); err != nil { return xerrors.Errorf("failed to validate blocks random beacon values: %w", err) } return nil @@ -488,7 +489,7 @@ func (filec *FilecoinEC) checkBlockMessages(ctx context.Context, b *types.FullBl // Phase 2: (Partial) semantic validation: // the sender exists and is an account actor, and the nonces make sense var sender address.Address - if filec.sm.GetNetworkVersion(ctx, b.Header.Height) >= network.Version13 { + if nv >= network.Version13 { sender, err = st.LookupID(m.From) if err != nil { return xerrors.Errorf("failed to lookup sender %s: %w", m.From, err) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index 116684b9f..d2a182917 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -5,6 +5,8 @@ import ( "runtime" "time" + "github.com/filecoin-project/specs-actors/v8/actors/migration/nv16" + "github.com/docker/go-units" "github.com/filecoin-project/specs-actors/v6/actors/migration/nv14" @@ -34,6 +36,7 @@ import ( "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/multisig" "github.com/filecoin-project/lotus/chain/state" @@ -41,6 +44,7 @@ import ( "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" + "github.com/filecoin-project/lotus/node/bundle" ) func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { @@ -170,6 +174,17 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { StopWithin: 5, }}, Expensive: true, + }, { + Height: build.UpgradeSkyrHeight, + Network: network.Version16, + Migration: UpgradeActorsV8, + PreMigrations: []stmgr.PreMigration{{ + PreMigration: PreUpgradeActorsV8, + StartWithin: 180, + DontStartWithin: 60, + StopWithin: 5, + }}, + Expensive: true, }, } @@ -1304,6 +1319,118 @@ func upgradeActorsV7Common( return newRoot, nil } +func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { + // Use all the CPUs except 3. + workerCount := runtime.NumCPU() - 3 + if workerCount <= 0 { + workerCount = 1 + } + + config := nv16.Config{ + MaxWorkers: uint(workerCount), + JobQueueSize: 1000, + ResultQueueSize: 100, + ProgressLogPeriod: 10 * time.Second, + } + + newRoot, err := upgradeActorsV8Common(ctx, sm, cache, root, epoch, ts, config) + if err != nil { + return cid.Undef, xerrors.Errorf("migrating actors v7 state: %w", err) + } + + return newRoot, nil +} + +func PreUpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error { + // Use half the CPUs for pre-migration, but leave at least 3. + workerCount := runtime.NumCPU() + if workerCount <= 4 { + workerCount = 1 + } else { + workerCount /= 2 + } + + lbts, lbRoot, err := stmgr.GetLookbackTipSetForRound(ctx, sm, ts, epoch) + if err != nil { + return xerrors.Errorf("error getting lookback ts for premigration: %w", err) + } + + config := nv16.Config{MaxWorkers: uint(workerCount), + ProgressLogPeriod: time.Minute * 5} + + _, err = upgradeActorsV8Common(ctx, sm, cache, lbRoot, epoch, lbts, config) + return err +} + +func upgradeActorsV8Common( + ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, + root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet, + config nv16.Config, +) (cid.Cid, error) { + buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync()) + store := store.ActorStore(ctx, buf) + + // ensure that the manifest is loaded in the blockstore + if err := bundle.FetchAndLoadBundles(ctx, buf, map[actors.Version]build.Bundle{ + actors.Version8: build.BuiltinActorReleases[actors.Version8], + }); err != nil { + return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err) + } + + // Load the state root. + var stateRoot types.StateRoot + if err := store.Get(ctx, root, &stateRoot); err != nil { + return cid.Undef, xerrors.Errorf("failed to decode state root: %w", err) + } + + if stateRoot.Version != types.StateTreeVersion4 { + return cid.Undef, xerrors.Errorf( + "expected state root version 4 for actors v8 upgrade, got %d", + stateRoot.Version, + ) + } + + manifest, ok := actors.GetManifest(actors.Version8) + if !ok { + return cid.Undef, xerrors.Errorf("no manifest CID for v8 upgrade") + } + + if val, ok := build.ActorsCIDs[actors.Version8]; ok { + if val != manifest { + return cid.Undef, xerrors.Errorf("actors V8 manifest CID %s did not match CID given in params file: %s", manifest, val) + } + } + + // Perform the migration + newHamtRoot, err := nv16.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, migrationLogger{}, cache) + if err != nil { + return cid.Undef, xerrors.Errorf("upgrading to actors v8: %w", err) + } + + // Persist the result. + newRoot, err := store.Put(ctx, &types.StateRoot{ + Version: types.StateTreeVersion4, + Actors: newHamtRoot, + Info: stateRoot.Info, + }) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err) + } + + // Persist the new tree. + + { + from := buf + to := buf.Read() + + if err := vm.Copy(ctx, from, to, newRoot); err != nil { + return cid.Undef, xerrors.Errorf("copying migrated tree: %w", err) + } + } + + return newRoot, nil +} + type migrationLogger struct{} func (ml migrationLogger) Log(level rt.LogLevel, msg string, args ...interface{}) { diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 4153830dc..cde414fec 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -29,8 +29,6 @@ import ( "github.com/ipld/go-car" "golang.org/x/xerrors" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" @@ -55,7 +53,7 @@ const msgsPerBlock = 20 //nolint:deadcode,varcheck var log = logging.Logger("gen") -var ValidWpostForTesting = []proof5.PoStProof{{ +var ValidWpostForTesting = []proof7.PoStProof{{ ProofBytes: []byte("valid proof"), }} @@ -492,7 +490,7 @@ func (cg *ChainGen) NextTipSetFromMinersWithMessagesAndNulls(base *types.TipSet, func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticket *types.Ticket, eticket *types.ElectionProof, bvals []types.BeaconEntry, height abi.ChainEpoch, - wpost []proof5.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) { + wpost []proof7.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) { var ts uint64 if cg.Timestamper != nil { @@ -620,7 +618,7 @@ func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*cr type WinningPoStProver interface { GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error) - ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof5.PoStProof, error) + ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof7.PoStProof, error) } type wppProvider struct{} @@ -629,7 +627,7 @@ func (wpp *wppProvider) GenerateCandidates(ctx context.Context, _ abi.PoStRandom return []uint64{0}, nil } -func (wpp *wppProvider) ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof5.PoStProof, error) { +func (wpp *wppProvider) ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof7.PoStProof, error) { return ValidWpostForTesting, nil } @@ -680,11 +678,11 @@ type genFakeVerifier struct{} var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil) -func (m genFakeVerifier) VerifySeal(svi proof5.SealVerifyInfo) (bool, error) { +func (m genFakeVerifier) VerifySeal(svi proof7.SealVerifyInfo) (bool, error) { return true, nil } -func (m genFakeVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) { +func (m genFakeVerifier) VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) (bool, error) { panic("not supported") } diff --git a/chain/gen/genesis/f00_system.go b/chain/gen/genesis/f00_system.go index 4fde27107..faa585c95 100644 --- a/chain/gen/genesis/f00_system.go +++ b/chain/gen/genesis/f00_system.go @@ -3,6 +3,14 @@ package genesis import ( "context" + systemtypes "github.com/filecoin-project/go-state-types/builtin/v8/system" + + "github.com/filecoin-project/go-state-types/manifest" + + "github.com/filecoin-project/lotus/chain/actors/builtin" + + "golang.org/x/xerrors" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -22,12 +30,27 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi return nil, err } + if av >= actors.Version8 { + mfCid, ok := actors.GetManifest(av) + if !ok { + return nil, xerrors.Errorf("missing manifest for actors version %d", av) + } + + mf := manifest.Manifest{} + if err := cst.Get(ctx, mfCid, &mf); err != nil { + return nil, xerrors.Errorf("loading manifest for actors version %d: %w", av, err) + } + + st8 := st.GetState().(*systemtypes.State) + st8.BuiltinActors = mf.Data + } + statecid, err := cst.Put(ctx, st.GetState()) if err != nil { return nil, err } - actcid, err := system.GetActorCodeID(av) + actcid, err := builtin.GetSystemActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/gen/genesis/f01_init.go b/chain/gen/genesis/f01_init.go index 61ec91703..f1df7ae2a 100644 --- a/chain/gen/genesis/f01_init.go +++ b/chain/gen/genesis/f01_init.go @@ -5,6 +5,8 @@ import ( "encoding/json" "fmt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/actors" @@ -176,7 +178,7 @@ func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, i return 0, nil, nil, err } - actcid, err := init_.GetActorCodeID(av) + actcid, err := builtin.GetInitActorCodeID(av) if err != nil { return 0, nil, nil, err } diff --git a/chain/gen/genesis/f02_reward.go b/chain/gen/genesis/f02_reward.go index c8f479722..e4d6aa32a 100644 --- a/chain/gen/genesis/f02_reward.go +++ b/chain/gen/genesis/f02_reward.go @@ -3,6 +3,8 @@ package genesis import ( "context" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" @@ -28,7 +30,7 @@ func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int return nil, err } - actcid, err := reward.GetActorCodeID(av) + actcid, err := builtin.GetRewardActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/gen/genesis/f03_cron.go b/chain/gen/genesis/f03_cron.go index c9dd0d341..fad5e6fa6 100644 --- a/chain/gen/genesis/f03_cron.go +++ b/chain/gen/genesis/f03_cron.go @@ -3,6 +3,8 @@ package genesis import ( "context" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -26,7 +28,7 @@ func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version return nil, err } - actcid, err := cron.GetActorCodeID(av) + actcid, err := builtin.GetCronActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/gen/genesis/f04_power.go b/chain/gen/genesis/f04_power.go index b5e08cebe..35cd5f87b 100644 --- a/chain/gen/genesis/f04_power.go +++ b/chain/gen/genesis/f04_power.go @@ -3,6 +3,8 @@ package genesis import ( "context" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors/builtin/power" @@ -28,7 +30,7 @@ func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors return nil, err } - actcid, err := power.GetActorCodeID(av) + actcid, err := builtin.GetPowerActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/gen/genesis/f05_market.go b/chain/gen/genesis/f05_market.go index ac32294c9..045842cde 100644 --- a/chain/gen/genesis/f05_market.go +++ b/chain/gen/genesis/f05_market.go @@ -3,6 +3,8 @@ package genesis import ( "context" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -26,7 +28,7 @@ func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actor return nil, err } - actcid, err := market.GetActorCodeID(av) + actcid, err := builtin.GetMarketActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/gen/genesis/f06_vreg.go b/chain/gen/genesis/f06_vreg.go index e61c951f5..d93b01a4f 100644 --- a/chain/gen/genesis/f06_vreg.go +++ b/chain/gen/genesis/f06_vreg.go @@ -3,6 +3,8 @@ package genesis import ( "context" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" @@ -41,7 +43,7 @@ func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av ac return nil, err } - actcid, err := verifreg.GetActorCodeID(av) + actcid, err := builtin.GetVerifregActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index a1d1d01b8..fa4a0dedd 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -376,7 +376,7 @@ func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version return nil, err } - actcid, err := account.GetActorCodeID(av) + actcid, err := builtin.GetAccountActorCodeID(av) if err != nil { return nil, err } @@ -458,7 +458,7 @@ func CreateMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state return err } - actcid, err := multisig.GetActorCodeID(av) + actcid, err := builtin.GetMultisigActorCodeID(av) if err != nil { return err } @@ -491,11 +491,10 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca Actors: filcns.NewActorRegistry(), Syscalls: mkFakedSigSyscalls(sys), CircSupplyCalc: csc, - FilVested: big.Zero(), NetworkVersion: nv, BaseFee: big.Zero(), } - vm, err := vm.NewLegacyVM(ctx, &vmopt) + vm, err := vm.NewVM(ctx, &vmopt) if err != nil { return cid.Undef, xerrors.Errorf("failed to create NewLegacyVM: %w", err) } diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index fd83a7640..542111a62 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -6,6 +6,17 @@ import ( "fmt" "math/rand" + "github.com/filecoin-project/lotus/chain/wallet" + + cborutil "github.com/filecoin-project/go-cbor-util" + + "github.com/filecoin-project/lotus/lib/sigs" + + smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing" + + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" + runtime7 "github.com/filecoin-project/specs-actors/v7/actors/runtime" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" @@ -23,7 +34,6 @@ import ( builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" @@ -32,9 +42,11 @@ import ( power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power" reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward" + builtintypes "github.com/filecoin-project/go-state-types/builtin" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/power" @@ -86,22 +98,25 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal return big.Zero(), nil } - vmopt := &vm.VMOpts{ - StateBase: sroot, - Epoch: 0, - Rand: &fakeRand{}, - Bstore: cs.StateBlockstore(), - Actors: filcns.NewActorRegistry(), - Syscalls: mkFakedSigSyscalls(sys), - CircSupplyCalc: csc, - NetworkVersion: nv, - BaseFee: big.Zero(), - FilVested: big.Zero(), + newVM := func(base cid.Cid) (vm.Interface, error) { + vmopt := &vm.VMOpts{ + StateBase: base, + Epoch: 0, + Rand: &fakeRand{}, + Bstore: cs.StateBlockstore(), + Actors: filcns.NewActorRegistry(), + Syscalls: mkFakedSigSyscalls(sys), + CircSupplyCalc: csc, + NetworkVersion: nv, + BaseFee: big.Zero(), + } + + return vm.NewVM(ctx, vmopt) } - vm, err := vm.NewLegacyVM(ctx, vmopt) + genesisVm, err := newVM(sroot) if err != nil { - return cid.Undef, xerrors.Errorf("failed to create NewLegacyVM: %w", err) + return cid.Undef, fmt.Errorf("creating vm: %w", err) } if len(miners) == 0 { @@ -116,7 +131,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal dealIDs []abi.DealID }, len(miners)) - maxPeriods := policy.GetMaxSectorExpirationExtension() / miner.WPoStProvingPeriod + maxPeriods := policy.GetMaxSectorExpirationExtension() / minertypes.WPoStProvingPeriod for i, m := range miners { // Create miner through power actor i := i @@ -136,7 +151,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal } params := mustEnc(constructorParams) - rval, err := doExecValue(ctx, vm, power.Address, m.Owner, m.PowerBalance, power.Methods.CreateMiner, params) + rval, err := doExecValue(ctx, genesisVm, power.Address, m.Owner, m.PowerBalance, power.Methods.CreateMiner, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err) } @@ -152,12 +167,17 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal } minerInfos[i].maddr = ma.IDAddress - _, err = vm.Flush(ctx) + nh, err := genesisVm.Flush(ctx) if err != nil { return cid.Undef, xerrors.Errorf("flushing vm: %w", err) } - mact, err := vm.StateTree().GetActor(minerInfos[i].maddr) + nst, err := state.LoadStateTree(cst, nh) + if err != nil { + return cid.Undef, xerrors.Errorf("loading new state tree: %w", err) + } + + mact, err := nst.GetActor(minerInfos[i].maddr) if err != nil { return cid.Undef, xerrors.Errorf("getting newly created miner actor: %w", err) } @@ -179,7 +199,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal if m.MarketBalance.GreaterThan(big.Zero()) { params := mustEnc(&minerInfos[i].maddr) - _, err := doExecValue(ctx, vm, market.Address, m.Worker, m.MarketBalance, market.Methods.AddBalance, params) + _, err := doExecValue(ctx, genesisVm, market.Address, m.Worker, m.MarketBalance, market.Methods.AddBalance, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner (add balance): %w", err) } @@ -188,10 +208,10 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal // Publish preseal deals { - publish := func(params *market.PublishStorageDealsParams) error { + publish := func(params *markettypes.PublishStorageDealsParams) error { fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker) - ret, err := doExecValue(ctx, vm, market.Address, m.Worker, big.Zero(), builtin0.MethodsMarket.PublishStorageDeals, mustEnc(params)) + ret, err := doExecValue(ctx, genesisVm, market.Address, m.Worker, big.Zero(), builtin0.MethodsMarket.PublishStorageDeals, mustEnc(params)) if err != nil { return xerrors.Errorf("failed to create genesis miner (publish deals): %w", err) } @@ -213,21 +233,37 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal return nil } - params := &market.PublishStorageDealsParams{} + params := &markettypes.PublishStorageDealsParams{} for _, preseal := range m.Sectors { preseal.Deal.VerifiedDeal = true preseal.Deal.EndEpoch = minerInfos[i].presealExp - params.Deals = append(params.Deals, market.ClientDealProposal{ + p := markettypes.ClientDealProposal{ Proposal: preseal.Deal, - ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, // TODO: do we want to sign these? Or do we want to fake signatures for genesis setup? - }) + ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, + } + + if av >= actors.Version8 { + buf, err := cborutil.Dump(&preseal.Deal) + if err != nil { + return cid.Undef, fmt.Errorf("failed to marshal proposal: %w", err) + } + + sig, err := sigs.Sign(wallet.ActSigType(preseal.DealClientKey.Type), preseal.DealClientKey.PrivateKey, buf) + if err != nil { + return cid.Undef, fmt.Errorf("failed to sign proposal: %w", err) + } + + p.ClientSignature = *sig + } + + params.Deals = append(params.Deals, p) if len(params.Deals) == cbg.MaxLength { if err := publish(params); err != nil { return cid.Undef, err } - params = &market.PublishStorageDealsParams{} + params = &markettypes.PublishStorageDealsParams{} } } @@ -246,7 +282,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal for pi := range m.Sectors { rawPow = types.BigAdd(rawPow, types.NewInt(uint64(m.SectorSize))) - dweight, vdweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp, av) + dweight, vdweight, err := dealWeight(ctx, genesisVm, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp, av) if err != nil { return cid.Undef, xerrors.Errorf("getting deal weight: %w", err) } @@ -257,12 +293,21 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal } } - _, err = vm.Flush(ctx) + nh, err := genesisVm.Flush(ctx) if err != nil { return cid.Undef, xerrors.Errorf("flushing vm: %w", err) } - pact, err := vm.StateTree().GetActor(power.Address) + if err != nil { + return cid.Undef, xerrors.Errorf("flushing vm: %w", err) + } + + nst, err := state.LoadStateTree(cst, nh) + if err != nil { + return cid.Undef, xerrors.Errorf("loading new state tree: %w", err) + } + + pact, err := nst.GetActor(power.Address) if err != nil { return cid.Undef, xerrors.Errorf("getting power actor: %w", err) } @@ -295,7 +340,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal pact.Head = pcid - if err = vm.StateTree().SetActor(power.Address, pact); err != nil { + if err = nst.SetActor(power.Address, pact); err != nil { return cid.Undef, xerrors.Errorf("setting power state: %w", err) } @@ -304,16 +349,26 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal return cid.Undef, xerrors.Errorf("setup reward actor: %w", err) } - if err = vm.StateTree().SetActor(reward.Address, rewact); err != nil { + if err = nst.SetActor(reward.Address, rewact); err != nil { return cid.Undef, xerrors.Errorf("set reward actor: %w", err) } + + nh, err = nst.Flush(ctx) + if err != nil { + return cid.Undef, xerrors.Errorf("flushing state tree: %w", err) + } + + genesisVm, err = newVM(nh) + if err != nil { + return cid.Undef, fmt.Errorf("creating new vm: %w", err) + } } for i, m := range miners { // Commit sectors { for pi, preseal := range m.Sectors { - params := &miner.SectorPreCommitInfo{ + params := &minertypes.SectorPreCommitInfo{ SealProof: preseal.ProofType, SectorNumber: preseal.SectorID, SealedCID: preseal.CommR, @@ -322,7 +377,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally! } - dweight, vdweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp, av) + dweight, vdweight, err := dealWeight(ctx, genesisVm, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp, av) if err != nil { return cid.Undef, xerrors.Errorf("getting deal weight: %w", err) } @@ -331,12 +386,17 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal // we've added fake power for this sector above, remove it now - _, err = vm.Flush(ctx) + nh, err := genesisVm.Flush(ctx) if err != nil { return cid.Undef, xerrors.Errorf("flushing vm: %w", err) } - pact, err := vm.StateTree().GetActor(power.Address) + nst, err := state.LoadStateTree(cst, nh) + if err != nil { + return cid.Undef, xerrors.Errorf("loading new state tree: %w", err) + } + + pact, err := nst.GetActor(power.Address) if err != nil { return cid.Undef, xerrors.Errorf("getting power actor: %w", err) } @@ -366,35 +426,45 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal pact.Head = pcid - if err = vm.StateTree().SetActor(power.Address, pact); err != nil { + if err = nst.SetActor(power.Address, pact); err != nil { return cid.Undef, xerrors.Errorf("setting power state: %w", err) } - baselinePower, rewardSmoothed, err := currentEpochBlockReward(ctx, vm, minerInfos[i].maddr, av) + nh, err = nst.Flush(ctx) + if err != nil { + return cid.Undef, xerrors.Errorf("flushing state tree: %w", err) + } + + genesisVm, err = newVM(nh) + if err != nil { + return cid.Undef, fmt.Errorf("creating new vm: %w", err) + } + + baselinePower, rewardSmoothed, err := currentEpochBlockReward(ctx, genesisVm, minerInfos[i].maddr, av) if err != nil { return cid.Undef, xerrors.Errorf("getting current epoch reward: %w", err) } - tpow, err := currentTotalPower(ctx, vm, minerInfos[i].maddr) + tpow, err := currentTotalPower(ctx, genesisVm, minerInfos[i].maddr) if err != nil { return cid.Undef, xerrors.Errorf("getting current total power: %w", err) } - pcd := miner0.PreCommitDepositForPower(&rewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight) + pcd := miner0.PreCommitDepositForPower((*smoothing0.FilterEstimate)(&rewardSmoothed), tpow.QualityAdjPowerSmoothed, sectorWeight) pledge := miner0.InitialPledgeForPower( sectorWeight, baselinePower, tpow.PledgeCollateral, - &rewardSmoothed, + (*smoothing0.FilterEstimate)(&rewardSmoothed), tpow.QualityAdjPowerSmoothed, - circSupply(ctx, vm, minerInfos[i].maddr), + big.Zero(), ) pledge = big.Add(pcd, pledge) fmt.Println(types.FIL(pledge)) - _, err = doExecValue(ctx, vm, minerInfos[i].maddr, m.Worker, pledge, miner.Methods.PreCommitSector, mustEnc(params)) + _, err = doExecValue(ctx, genesisVm, minerInfos[i].maddr, m.Worker, pledge, builtintypes.MethodsMiner.PreCommitSector, mustEnc(params)) if err != nil { return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) } @@ -417,7 +487,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal paramBytes = mustEnc(confirmParams) } - _, err = doExecValue(ctx, vm, minerInfos[i].maddr, power.Address, big.Zero(), miner.Methods.ConfirmSectorProofsValid, paramBytes) + _, err = doExecValue(ctx, genesisVm, minerInfos[i].maddr, power.Address, big.Zero(), builtintypes.MethodsMiner.ConfirmSectorProofsValid, paramBytes) if err != nil { return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) } @@ -429,17 +499,22 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal QualityAdjustedDelta: sectorWeight, } - _, err = doExecValue(ctx, vm, power.Address, minerInfos[i].maddr, big.Zero(), power.Methods.UpdateClaimedPower, mustEnc(claimParams)) + _, err = doExecValue(ctx, genesisVm, power.Address, minerInfos[i].maddr, big.Zero(), power.Methods.UpdateClaimedPower, mustEnc(claimParams)) if err != nil { return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) } - _, err = vm.Flush(ctx) + nh, err := genesisVm.Flush(ctx) if err != nil { return cid.Undef, xerrors.Errorf("flushing vm: %w", err) } - mact, err := vm.StateTree().GetActor(minerInfos[i].maddr) + nst, err := state.LoadStateTree(cst, nh) + if err != nil { + return cid.Undef, xerrors.Errorf("loading new state tree: %w", err) + } + + mact, err := nst.GetActor(minerInfos[i].maddr) if err != nil { return cid.Undef, xerrors.Errorf("getting miner actor: %w", err) } @@ -460,21 +535,36 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal mact.Head = mcid - if err = vm.StateTree().SetActor(minerInfos[i].maddr, mact); err != nil { + if err = nst.SetActor(minerInfos[i].maddr, mact); err != nil { return cid.Undef, xerrors.Errorf("setting miner state: %w", err) } + + nh, err = nst.Flush(ctx) + if err != nil { + return cid.Undef, xerrors.Errorf("flushing state tree: %w", err) + } + + genesisVm, err = newVM(nh) + if err != nil { + return cid.Undef, fmt.Errorf("creating new vm: %w", err) + } } } } } // Sanity-check total network power - _, err = vm.Flush(ctx) + nh, err := genesisVm.Flush(ctx) if err != nil { - return cid.Undef, xerrors.Errorf("flushing vm: %w", err) + return cid.Undef, fmt.Errorf("flushing vm: %w", err) } - pact, err := vm.StateTree().GetActor(power.Address) + nst, err := state.LoadStateTree(cst, nh) + if err != nil { + return cid.Undef, xerrors.Errorf("loading new state tree: %w", err) + } + + pact, err := nst.GetActor(power.Address) if err != nil { return cid.Undef, xerrors.Errorf("getting power actor: %w", err) } @@ -499,10 +589,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal // TODO: Should we re-ConstructState for the reward actor using rawPow as currRealizedPower here? - c, err := vm.Flush(ctx) + c, err := genesisVm.Flush(ctx) if err != nil { return cid.Undef, xerrors.Errorf("flushing vm: %w", err) } + return c, nil } @@ -521,7 +612,7 @@ func (fr *fakeRand) GetBeaconRandomness(ctx context.Context, personalization cry return out, nil } -func currentTotalPower(ctx context.Context, vm *vm.LegacyVM, maddr address.Address) (*power0.CurrentTotalPowerReturn, error) { +func currentTotalPower(ctx context.Context, vm vm.Interface, maddr address.Address) (*power0.CurrentTotalPowerReturn, error) { pwret, err := doExecValue(ctx, vm, power.Address, maddr, big.Zero(), builtin0.MethodsPower.CurrentTotalPower, nil) if err != nil { return nil, err @@ -534,7 +625,7 @@ func currentTotalPower(ctx context.Context, vm *vm.LegacyVM, maddr address.Addre return &pwr, nil } -func dealWeight(ctx context.Context, vm *vm.LegacyVM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actors.Version) (abi.DealWeight, abi.DealWeight, error) { +func dealWeight(ctx context.Context, vm vm.Interface, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actors.Version) (abi.DealWeight, abi.DealWeight, error) { // TODO: This hack should move to market actor wrapper if av <= actors.Version2 { params := &market0.VerifyDealsForActivationParams{ @@ -594,7 +685,7 @@ func dealWeight(ctx context.Context, vm *vm.LegacyVM, maddr address.Address, dea return dealWeights.Sectors[0].DealWeight, dealWeights.Sectors[0].VerifiedDealWeight, nil } -func currentEpochBlockReward(ctx context.Context, vm *vm.LegacyVM, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) { +func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) { rwret, err := doExecValue(ctx, vm, reward.Address, maddr, big.Zero(), reward.Methods.ThisEpochReward, nil) if err != nil { return big.Zero(), builtin.FilterEstimate{}, err @@ -609,7 +700,7 @@ func currentEpochBlockReward(ctx context.Context, vm *vm.LegacyVM, maddr address return big.Zero(), builtin.FilterEstimate{}, err } - return epochReward.ThisEpochBaselinePower, *epochReward.ThisEpochRewardSmoothed, nil + return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(*epochReward.ThisEpochRewardSmoothed), nil case actors.Version2: var epochReward reward2.ThisEpochRewardReturn @@ -628,13 +719,3 @@ func currentEpochBlockReward(ctx context.Context, vm *vm.LegacyVM, maddr address return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(epochReward.ThisEpochRewardSmoothed), nil } - -func circSupply(ctx context.Context, vmi *vm.LegacyVM, maddr address.Address) abi.TokenAmount { - unsafeVM := &vm.UnsafeVM{VM: vmi} - rt := unsafeVM.MakeRuntime(ctx, &types.Message{ - GasLimit: 1_000_000_000, - From: maddr, - }) - - return rt.TotalFilCircSupply() -} diff --git a/chain/gen/genesis/util.go b/chain/gen/genesis/util.go index 452bc835b..1f576c8a4 100644 --- a/chain/gen/genesis/util.go +++ b/chain/gen/genesis/util.go @@ -21,12 +21,7 @@ func mustEnc(i cbg.CBORMarshaler) []byte { return enc } -func doExecValue(ctx context.Context, vm *vm.LegacyVM, to, from address.Address, value types.BigInt, method abi.MethodNum, params []byte) ([]byte, error) { - act, err := vm.StateTree().GetActor(from) - if err != nil { - return nil, xerrors.Errorf("doExec failed to get from actor (%s): %w", from, err) - } - +func doExecValue(ctx context.Context, vm vm.Interface, to, from address.Address, value types.BigInt, method abi.MethodNum, params []byte) ([]byte, error) { ret, err := vm.ApplyImplicitMessage(ctx, &types.Message{ To: to, From: from, @@ -34,7 +29,7 @@ func doExecValue(ctx context.Context, vm *vm.LegacyVM, to, from address.Address, Params: params, GasLimit: 1_000_000_000_000_000, Value: value, - Nonce: act.Nonce, + Nonce: 0, }) if err != nil { return nil, xerrors.Errorf("doExec apply message failed: %w", err) diff --git a/chain/market/fundmanager.go b/chain/market/fundmanager.go index e934201d7..53afa1343 100644 --- a/chain/market/fundmanager.go +++ b/chain/market/fundmanager.go @@ -7,10 +7,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/market" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/impl/full" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -677,10 +678,10 @@ func (env *fundManagerEnvironment) AddFunds( } smsg, aerr := env.api.MpoolPushMessage(ctx, &types.Message{ - To: market.Address, + To: builtin.StorageMarketActorAddr, From: wallet, Value: amt, - Method: market.Methods.AddBalance, + Method: builtin.MethodsMarket.AddBalance, Params: params, }, nil) @@ -706,10 +707,10 @@ func (env *fundManagerEnvironment) WithdrawFunds( } smsg, aerr := env.api.MpoolPushMessage(ctx, &types.Message{ - To: market.Address, + To: builtin.StorageMarketActorAddr, From: wallet, Value: types.NewInt(0), - Method: market.Methods.WithdrawBalance, + Method: builtin.MethodsMarket.WithdrawBalance, Params: params, }, nil) diff --git a/chain/market/fundmanager_test.go b/chain/market/fundmanager_test.go index 8f2d5a2f9..4dcf3b66c 100644 --- a/chain/market/fundmanager_test.go +++ b/chain/market/fundmanager_test.go @@ -8,6 +8,8 @@ import ( "testing" "time" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/api" @@ -662,7 +664,7 @@ func checkWithdrawMessageFields(t *testing.T, msg *types.Message, from address.A require.Equal(t, market.Address, msg.To) require.Equal(t, abi.NewTokenAmount(0), msg.Value) - var params market.WithdrawBalanceParams + var params markettypes.WithdrawBalanceParams err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)) require.NoError(t, err) require.Equal(t, addr, params.ProviderOrClientAddress) @@ -742,7 +744,7 @@ func (mapi *mockFundManagerAPI) completeMsg(msgCid cid.Cid) { mapi.escrow[escrowAcct] = escrow log.Debugf("%s: escrow %d -> %d", escrowAcct, before, escrow) } else { - var params market.WithdrawBalanceParams + var params markettypes.WithdrawBalanceParams err := params.UnmarshalCBOR(bytes.NewReader(pmsg.msg.Message.Params)) if err != nil { panic(err) diff --git a/chain/rand/rand.go b/chain/rand/rand.go index 427648f2a..529ba6732 100644 --- a/chain/rand/rand.go +++ b/chain/rand/rand.go @@ -198,7 +198,9 @@ func (sr *stateRand) extractBeaconEntryForEpoch(ctx context.Context, filecoinEpo return nil, err } - round := sr.beacon.BeaconForEpoch(filecoinEpoch).MaxBeaconRoundForEpoch(filecoinEpoch) + nv := sr.networkVersionGetter(ctx, filecoinEpoch) + + round := sr.beacon.BeaconForEpoch(filecoinEpoch).MaxBeaconRoundForEpoch(nv, filecoinEpoch) for i := 0; i < 20; i++ { cbe := randTs.Blocks()[0].BeaconEntries diff --git a/chain/state/statetree.go b/chain/state/statetree.go index 9a518a622..7d6876c3c 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -159,7 +159,7 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) { /* inline-gen start */ - case network.Version13, network.Version14, network.Version15: + case network.Version13, network.Version14, network.Version15, network.Version16: /* inline-gen end */ return types.StateTreeVersion4, nil diff --git a/chain/stmgr/actors.go b/chain/stmgr/actors.go index 52773e1e4..d8d121f02 100644 --- a/chain/stmgr/actors.go +++ b/chain/stmgr/actors.go @@ -17,6 +17,7 @@ import ( "golang.org/x/xerrors" + miner_types "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/market" @@ -89,7 +90,7 @@ func GetPowerRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr addres return mpow, tpow, minpow, nil } -func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.SectorPreCommitOnChainInfo, error) { +func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner_types.SectorPreCommitOnChainInfo, error) { act, err := sm.LoadActor(ctx, maddr, ts) if err != nil { return nil, xerrors.Errorf("(get sset) failed to load miner actor: %w", err) @@ -316,7 +317,7 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule prev = &types.BeaconEntry{} } - entries, err := beacon.BeaconEntriesForBlock(ctx, bcs, round, ts.Height(), *prev) + entries, err := beacon.BeaconEntriesForBlock(ctx, bcs, sm.GetNetworkVersion(ctx, round), round, ts.Height(), *prev) if err != nil { return nil, err } diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 888ca0254..7e011d99f 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -80,11 +80,6 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types. return nil, fmt.Errorf("failed to handle fork: %w", err) } - filVested, err := sm.GetFilVested(ctx, vmHeight) - if err != nil { - return nil, err - } - vmopt := &vm.VMOpts{ StateBase: bstate, Epoch: vmHeight, @@ -95,7 +90,6 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types. CircSupplyCalc: sm.GetVMCirculatingSupply, NetworkVersion: sm.GetNetworkVersion(ctx, pheight+1), BaseFee: types.NewInt(0), - FilVested: filVested, LookbackState: LookbackStateGetterForTipset(sm, ts), } @@ -218,11 +212,6 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri ) } - filVested, err := sm.GetFilVested(ctx, vmHeight) - if err != nil { - return nil, err - } - buffStore := blockstore.NewTieredBstore(sm.cs.StateBlockstore(), blockstore.NewMemorySync()) vmopt := &vm.VMOpts{ StateBase: stateCid, @@ -234,7 +223,6 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri CircSupplyCalc: sm.GetVMCirculatingSupply, NetworkVersion: sm.GetNetworkVersion(ctx, ts.Height()+1), BaseFee: ts.Blocks()[0].ParentBaseFee, - FilVested: filVested, LookbackState: LookbackStateGetterForTipset(sm, ts), } vmi, err := sm.newVM(ctx, vmopt) diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 9aa3f7e53..048ea7372 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -8,9 +8,7 @@ import ( "sync" "time" - "github.com/filecoin-project/lotus/build" - - "github.com/filecoin-project/specs-actors/v7/actors/migration/nv15" + "github.com/filecoin-project/specs-actors/v8/actors/migration/nv16" "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -19,6 +17,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" @@ -49,7 +48,8 @@ type MigrationCache interface { type MigrationFunc func( ctx context.Context, sm *StateManager, cache MigrationCache, - cb ExecMonitor, oldState cid.Cid, + cb ExecMonitor, + oldState cid.Cid, height abi.ChainEpoch, ts *types.TipSet, ) (newState cid.Cid, err error) @@ -214,7 +214,7 @@ func (sm *StateManager) hasExpensiveFork(height abi.ChainEpoch) bool { return ok } -func runPreMigration(ctx context.Context, sm *StateManager, fn PreMigrationFunc, cache *nv15.MemMigrationCache, ts *types.TipSet) { +func runPreMigration(ctx context.Context, sm *StateManager, fn PreMigrationFunc, cache *nv16.MemMigrationCache, ts *types.TipSet) { height := ts.Height() parent := ts.ParentState() diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index 9a22716ba..e36f57ceb 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -168,7 +168,7 @@ func TestForkHeightTriggers(t *testing.T) { } inv := filcns.NewActorRegistry() - inv.Register(nil, testActor{}) + inv.Register(actors.Version0, nil, testActor{}) sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) { nvm, err := vm.NewLegacyVM(ctx, vmopt) @@ -285,7 +285,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) { } inv := filcns.NewActorRegistry() - inv.Register(nil, testActor{}) + inv.Register(actors.Version0, nil, testActor{}) sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) { nvm, err := vm.NewLegacyVM(ctx, vmopt) @@ -506,7 +506,7 @@ func TestForkPreMigration(t *testing.T) { }() inv := filcns.NewActorRegistry() - inv.Register(nil, testActor{}) + inv.Register(actors.Version0, nil, testActor{}) sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) { nvm, err := vm.NewLegacyVM(ctx, vmopt) diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 7b10cd805..9aaccfff3 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -5,8 +5,7 @@ import ( "sync" "github.com/filecoin-project/lotus/chain/actors/adt" - - "github.com/filecoin-project/specs-actors/v7/actors/migration/nv15" + "github.com/filecoin-project/specs-actors/v8/actors/migration/nv16" "github.com/filecoin-project/lotus/chain/rand" @@ -57,7 +56,7 @@ type versionSpec struct { type migration struct { upgrade MigrationFunc preMigrations []PreMigration - cache *nv15.MemMigrationCache + cache *nv16.MemMigrationCache } type Executor interface { @@ -125,7 +124,7 @@ func NewStateManager(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder, migration := &migration{ upgrade: upgrade.Migration, preMigrations: upgrade.PreMigrations, - cache: nv15.NewMemMigrationCache(), + cache: nv16.NewMemMigrationCache(), } stateMigrations[upgrade.Height] = migration } diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 49dd4700a..2a84c777b 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -79,11 +79,6 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, // future. It's not guaranteed to be accurate... but that's fine. } - filVested, err := sm.GetFilVested(ctx, height) - if err != nil { - return cid.Undef, nil, err - } - r := rand.NewStateRand(sm.cs, ts.Cids(), sm.beacon, sm.GetNetworkVersion) vmopt := &vm.VMOpts{ StateBase: base, @@ -95,7 +90,6 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, CircSupplyCalc: sm.GetVMCirculatingSupply, NetworkVersion: sm.GetNetworkVersion(ctx, height), BaseFee: ts.Blocks()[0].ParentBaseFee, - FilVested: filVested, LookbackState: LookbackStateGetterForTipset(sm, ts), } vmi, err := sm.newVM(ctx, vmopt) diff --git a/chain/sync_test.go b/chain/sync_test.go index 96ed1440e..d8c68b132 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -8,6 +8,8 @@ import ( "testing" "time" + prooftypes "github.com/filecoin-project/go-state-types/proof" + "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/stmgr" @@ -22,9 +24,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/policy" @@ -143,6 +142,14 @@ func prepSyncTestWithV5Height(t testing.TB, h int, v5height abi.ChainEpoch) *syn Network: network.Version14, Height: v5height + 10, Migration: filcns.UpgradeActorsV6, + }, { + Network: network.Version15, + Height: v5height + 15, + Migration: filcns.UpgradeActorsV7, + }, { + Network: network.Version16, + Height: v5height + 20, + Migration: filcns.UpgradeActorsV8, }} g, err := gen.NewGeneratorWithUpgradeSchedule(sched) @@ -551,8 +558,8 @@ func (wpp badWpp) GenerateCandidates(context.Context, abi.PoStRandomness, uint64 return []uint64{1}, nil } -func (wpp badWpp) ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof2.PoStProof, error) { - return []proof2.PoStProof{ +func (wpp badWpp) ComputeProof(context.Context, []prooftypes.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]prooftypes.PoStProof, error) { + return []prooftypes.PoStProof{ { PoStProof: abi.RegisteredPoStProof_StackedDrgWinning2KiBV1, ProofBytes: []byte("evil"), diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index d36ee9314..c28a17abb 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -4,7 +4,7 @@ import ( "bytes" "math/big" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" + "github.com/filecoin-project/go-state-types/proof" "github.com/minio/blake2b-simd" @@ -49,21 +49,21 @@ func NewBeaconEntry(round uint64, data []byte) BeaconEntry { type BlockHeader struct { Miner address.Address // 0 unique per block/miner - Ticket *Ticket // 1 unique per block/miner: should be a valid VRF - ElectionProof *ElectionProof // 2 unique per block/miner: should be a valid VRF - BeaconEntries []BeaconEntry // 3 identical for all blocks in same tipset - WinPoStProof []proof2.PoStProof // 4 unique per block/miner - Parents []cid.Cid // 5 identical for all blocks in same tipset - ParentWeight BigInt // 6 identical for all blocks in same tipset - Height abi.ChainEpoch // 7 identical for all blocks in same tipset - ParentStateRoot cid.Cid // 8 identical for all blocks in same tipset - ParentMessageReceipts cid.Cid // 9 identical for all blocks in same tipset - Messages cid.Cid // 10 unique per block - BLSAggregate *crypto.Signature // 11 unique per block: aggrregate of BLS messages from above - Timestamp uint64 // 12 identical for all blocks in same tipset / hard-tied to the value of Height above - BlockSig *crypto.Signature // 13 unique per block/miner: miner signature - ForkSignaling uint64 // 14 currently unused/undefined - ParentBaseFee abi.TokenAmount // 15 identical for all blocks in same tipset: the base fee after executing parent tipset + Ticket *Ticket // 1 unique per block/miner: should be a valid VRF + ElectionProof *ElectionProof // 2 unique per block/miner: should be a valid VRF + BeaconEntries []BeaconEntry // 3 identical for all blocks in same tipset + WinPoStProof []proof.PoStProof // 4 unique per block/miner + Parents []cid.Cid // 5 identical for all blocks in same tipset + ParentWeight BigInt // 6 identical for all blocks in same tipset + Height abi.ChainEpoch // 7 identical for all blocks in same tipset + ParentStateRoot cid.Cid // 8 identical for all blocks in same tipset + ParentMessageReceipts cid.Cid // 9 identical for all blocks in same tipset + Messages cid.Cid // 10 unique per block + BLSAggregate *crypto.Signature // 11 unique per block: aggrregate of BLS messages from above + Timestamp uint64 // 12 identical for all blocks in same tipset / hard-tied to the value of Height above + BlockSig *crypto.Signature // 13 unique per block/miner: miner signature + ForkSignaling uint64 // 14 currently unused/undefined + ParentBaseFee abi.TokenAmount // 15 identical for all blocks in same tipset: the base fee after executing parent tipset validated bool // internal, true if the signature has been validated } diff --git a/chain/types/blockheader_test.go b/chain/types/blockheader_test.go index e386277df..773cf27b2 100644 --- a/chain/types/blockheader_test.go +++ b/chain/types/blockheader_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" + prooftypes "github.com/filecoin-project/go-state-types/proof" cid "github.com/ipfs/go-cid" "github.com/stretchr/testify/require" @@ -85,7 +85,7 @@ func TestInteropBH(t *testing.T) { t.Fatal(err) } - posts := []proof2.PoStProof{ + posts := []prooftypes.PoStProof{ {PoStProof: abi.RegisteredPoStProof_StackedDrgWinning2KiBV1, ProofBytes: []byte{0x07}}, } diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index 544728a3c..79ff5d19c 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -11,7 +11,7 @@ import ( abi "github.com/filecoin-project/go-state-types/abi" crypto "github.com/filecoin-project/go-state-types/crypto" exitcode "github.com/filecoin-project/go-state-types/exitcode" - proof "github.com/filecoin-project/specs-actors/actors/runtime/proof" + proof "github.com/filecoin-project/go-state-types/proof" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 2976b63d9..64730e784 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -3,7 +3,8 @@ package vm import ( "bytes" "context" - "sync/atomic" + "fmt" + "os" "time" "github.com/ipfs/go-cid" @@ -12,10 +13,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/actors/policy" - "github.com/filecoin-project/go-state-types/network" - - "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/state" cbor "github.com/ipfs/go-ipld-cbor" @@ -31,6 +28,7 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" ffi_cgo "github.com/filecoin-project/filecoin-ffi/cgo" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" @@ -256,25 +254,25 @@ type FVM struct { } func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { - log.Info("using the FVM, this is experimental!") - circToReport := opts.FilVested - // For v14 (and earlier), we perform the FilVested portion of the calculation, and let the FVM dynamically do the rest - // v15 and after, the circ supply is always constant per epoch, so we calculate the base and report it at creation - if opts.NetworkVersion >= network.Version15 { - state, err := state.LoadStateTree(cbor.NewCborStore(opts.Bstore), opts.StateBase) - if err != nil { - return nil, err - } - - circToReport, err = opts.CircSupplyCalc(ctx, opts.Epoch, state) - if err != nil { - return nil, err - } + state, err := state.LoadStateTree(cbor.NewCborStore(opts.Bstore), opts.StateBase) + if err != nil { + return nil, err } - fvmOpts := ffi.FVMOpts{ - FVMVersion: 0, - Externs: &FvmExtern{Rand: opts.Rand, Blockstore: opts.Bstore, lbState: opts.LookbackState, base: opts.StateBase, epoch: opts.Epoch}, + circToReport, err := opts.CircSupplyCalc(ctx, opts.Epoch, state) + if err != nil { + return nil, err + } + + fvmopts := &ffi.FVMOpts{ + FVMVersion: 0, + Externs: &FvmExtern{ + Rand: opts.Rand, + Blockstore: opts.Bstore, + lbState: opts.LookbackState, + base: opts.StateBase, + epoch: opts.Epoch, + }, Epoch: opts.Epoch, BaseFee: opts.BaseFee, BaseCircSupply: circToReport, @@ -283,7 +281,21 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { Tracing: EnableDetailedTracing, } - fvm, err := ffi.CreateFVM(&fvmOpts) + if os.Getenv("LOTUS_USE_FVM_CUSTOM_BUNDLE") == "1" { + av, err := actors.VersionForNetwork(opts.NetworkVersion) + if err != nil { + return nil, xerrors.Errorf("mapping network version to actors version: %w", err) + } + + c, ok := actors.GetManifest(av) + if !ok { + return nil, xerrors.Errorf("no manifest for custom bundle (actors version %d)", av) + } + + fvmopts.Manifest = c + } + + fvm, err := ffi.CreateFVM(fvmopts) if err != nil { return nil, err @@ -296,8 +308,8 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error) { start := build.Clock.Now() - defer atomic.AddUint64(&StatApplied, 1) - msgBytes, err := cmsg.VMMessage().Serialize() + vmMsg := cmsg.VMMessage() + msgBytes, err := vmMsg.Serialize() if err != nil { return nil, xerrors.Errorf("serializing msg: %w", err) } @@ -307,11 +319,11 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet return nil, xerrors.Errorf("applying msg: %w", err) } - var et FvmExecutionTrace - if len(ret.ExecTraceBytes) != 0 { - if err = et.UnmarshalCBOR(bytes.NewReader(ret.ExecTraceBytes)); err != nil { - return nil, xerrors.Errorf("failed to unmarshal exectrace: %w", err) - } + duration := time.Since(start) + receipt := types.MessageReceipt{ + Return: ret.Return, + ExitCode: exitcode.ExitCode(ret.ExitCode), + GasUsed: ret.GasUsed, } var aerr aerrors.ActorError @@ -323,32 +335,43 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet aerr = aerrors.New(exitcode.ExitCode(ret.ExitCode), amsg) } + var et types.ExecutionTrace + if len(ret.ExecTraceBytes) != 0 { + var fvmEt FvmExecutionTrace + if err = fvmEt.UnmarshalCBOR(bytes.NewReader(ret.ExecTraceBytes)); err != nil { + return nil, xerrors.Errorf("failed to unmarshal exectrace: %w", err) + } + et = fvmEt.ToExecutionTrace() + } else { + et.Msg = vmMsg + et.MsgRct = &receipt + et.Duration = duration + if aerr != nil { + et.Error = aerr.Error() + } + } + return &ApplyRet{ - MessageReceipt: types.MessageReceipt{ - Return: ret.Return, - ExitCode: exitcode.ExitCode(ret.ExitCode), - GasUsed: ret.GasUsed, - }, + MessageReceipt: receipt, GasCosts: &GasOutputs{ - // TODO: do the other optional fields eventually - BaseFeeBurn: big.Zero(), - OverEstimationBurn: big.Zero(), + BaseFeeBurn: ret.BaseFeeBurn, + OverEstimationBurn: ret.OverEstimationBurn, MinerPenalty: ret.MinerPenalty, MinerTip: ret.MinerTip, - Refund: big.Zero(), - GasRefund: 0, - GasBurned: 0, + Refund: ret.Refund, + GasRefund: ret.GasRefund, + GasBurned: ret.GasBurned, }, ActorErr: aerr, - ExecutionTrace: et.ToExecutionTrace(), - Duration: time.Since(start), + ExecutionTrace: et, + Duration: duration, }, nil } func (vm *FVM) ApplyImplicitMessage(ctx context.Context, cmsg *types.Message) (*ApplyRet, error) { start := build.Clock.Now() - defer atomic.AddUint64(&StatApplied, 1) - msgBytes, err := cmsg.VMMessage().Serialize() + vmMsg := cmsg.VMMessage() + msgBytes, err := vmMsg.Serialize() if err != nil { return nil, xerrors.Errorf("serializing msg: %w", err) } @@ -357,11 +380,11 @@ func (vm *FVM) ApplyImplicitMessage(ctx context.Context, cmsg *types.Message) (* return nil, xerrors.Errorf("applying msg: %w", err) } - var et FvmExecutionTrace - if len(ret.ExecTraceBytes) != 0 { - if err = et.UnmarshalCBOR(bytes.NewReader(ret.ExecTraceBytes)); err != nil { - return nil, xerrors.Errorf("failed to unmarshal exectrace: %w", err) - } + duration := time.Since(start) + receipt := types.MessageReceipt{ + Return: ret.Return, + ExitCode: exitcode.ExitCode(ret.ExitCode), + GasUsed: ret.GasUsed, } var aerr aerrors.ActorError @@ -373,16 +396,34 @@ func (vm *FVM) ApplyImplicitMessage(ctx context.Context, cmsg *types.Message) (* aerr = aerrors.New(exitcode.ExitCode(ret.ExitCode), amsg) } - return &ApplyRet{ - MessageReceipt: types.MessageReceipt{ - Return: ret.Return, - ExitCode: exitcode.ExitCode(ret.ExitCode), - GasUsed: ret.GasUsed, - }, + var et types.ExecutionTrace + if len(ret.ExecTraceBytes) != 0 { + var fvmEt FvmExecutionTrace + if err = fvmEt.UnmarshalCBOR(bytes.NewReader(ret.ExecTraceBytes)); err != nil { + return nil, xerrors.Errorf("failed to unmarshal exectrace: %w", err) + } + et = fvmEt.ToExecutionTrace() + } else { + et.Msg = vmMsg + et.MsgRct = &receipt + et.Duration = duration + if aerr != nil { + et.Error = aerr.Error() + } + } + + applyRet := &ApplyRet{ + MessageReceipt: receipt, ActorErr: aerr, - ExecutionTrace: et.ToExecutionTrace(), - Duration: time.Since(start), - }, nil + ExecutionTrace: et, + Duration: duration, + } + + if ret.ExitCode != 0 { + return applyRet, fmt.Errorf("implicit message failed with exit code: %d and error: %w", ret.ExitCode, applyRet.ActorErr) + } + + return applyRet, nil } func (vm *FVM) Flush(ctx context.Context) (cid.Cid, error) { diff --git a/chain/vm/invoker.go b/chain/vm/invoker.go index 8a7a4c8c9..ffc3ab138 100644 --- a/chain/vm/invoker.go +++ b/chain/vm/invoker.go @@ -89,22 +89,38 @@ func (ar *ActorRegistry) Invoke(codeCid cid.Cid, rt vmr.Runtime, method abi.Meth } -func (ar *ActorRegistry) Register(pred ActorPredicate, actors ...rtt.VMActor) { +func (ar *ActorRegistry) Register(av actors.Version, pred ActorPredicate, vmactors ...rtt.VMActor) { if pred == nil { pred = func(vmr.Runtime, rtt.VMActor) error { return nil } } - for _, a := range actors { + for _, a := range vmactors { // register in the `actors` map (for the invoker) code, err := ar.transform(a) if err != nil { panic(xerrors.Errorf("%s: %w", string(a.Code().Hash()), err)) } - ar.actors[a.Code()] = &actorInfo{ + + ai := &actorInfo{ methods: code, vmActor: a, predicate: pred, } + ac := a.Code() + ar.actors[ac] = ai + + // necessary to make stuff work + var realCode cid.Cid + if av >= actors.Version8 { + name := actors.CanonicalName(builtin.ActorNameByCode(ac)) + + var ok bool + realCode, ok = actors.GetActorCodeID(av, name) + if ok { + ar.actors[realCode] = ai + } + } + // register in the `Methods` map (used by statemanager utils) exports := a.Exports() methods := make(map[abi.MethodNum]MethodMeta, len(exports)) @@ -149,6 +165,9 @@ func (ar *ActorRegistry) Register(pred ActorPredicate, actors ...rtt.VMActor) { } } ar.Methods[a.Code()] = methods + if realCode.Defined() { + ar.Methods[realCode] = methods + } } } diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index 5716b5006..acdbf9ad4 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -14,12 +14,6 @@ import ( "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" - /* inline-gen template - {{range .actorVersions}} - builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"{{end}} - - /* inline-gen start */ - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" @@ -28,8 +22,6 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - /* inline-gen end */ - "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/actors/builtin" @@ -113,12 +105,6 @@ func newAccountActor(ver actors.Version) *types.Actor { // TODO: ActorsUpgrade use a global actor registry? var code cid.Cid switch ver { - /* inline-gen template - {{range .actorVersions}} - case actors.Version{{.}}: - code = builtin{{.}}.AccountActorCodeID{{end}} - /* inline-gen start */ - case actors.Version0: code = builtin0.AccountActorCodeID case actors.Version2: @@ -133,7 +119,6 @@ func newAccountActor(ver actors.Version) *types.Actor { code = builtin6.AccountActorCodeID case actors.Version7: code = builtin7.AccountActorCodeID - /* inline-gen end */ default: panic("unsupported actors version") } diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index 858c69885..497d4f6d9 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -29,7 +29,9 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" + "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" ) @@ -57,7 +59,7 @@ func (m *Message) ValueReceived() abi.TokenAmount { } // EnableDetailedTracing, if true, outputs gas tracing in execution traces. -var EnableDetailedTracing = os.Getenv("LOTUS_VM_ENABLE_GAS_TRACING_VERY_SLOW") == "1" +var EnableDetailedTracing = os.Getenv("LOTUS_VM_ENABLE_TRACING") == "1" type Runtime struct { rt7.Message @@ -365,6 +367,20 @@ func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid) { if t == callerCid { return } + + // this really only for genesis in tests; nv16 will be running on FVM anyway. + if nv := rt.NetworkVersion(); nv >= network.Version16 { + av, err := actors.VersionForNetwork(nv) + if err != nil { + panic(aerrors.Fatalf("failed to get actors version for network version %d", nv)) + } + + name := actors.CanonicalName(builtin.ActorNameByCode(t)) + ac, ok := actors.GetActorCodeID(av, name) + if ok && ac == callerCid { + return + } + } } rt.Abortf(exitcode.SysErrForbidden, "caller cid type %q was not one of %v", callerCid, ts) } diff --git a/chain/vm/syscalls.go b/chain/vm/syscalls.go index cd143279e..674a48070 100644 --- a/chain/vm/syscalls.go +++ b/chain/vm/syscalls.go @@ -7,8 +7,6 @@ import ( goruntime "runtime" "sync" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "github.com/minio/blake2b-simd" @@ -245,7 +243,7 @@ func (ss *syscallShim) workerKeyAtLookback(height abi.ChainEpoch) (address.Addre return ResolveToKeyAddr(ss.cstate, ss.cst, info.Worker) } -func (ss *syscallShim) VerifyPoSt(info proof5.WindowPoStVerifyInfo) error { +func (ss *syscallShim) VerifyPoSt(info proof7.WindowPoStVerifyInfo) error { ok, err := ss.verifier.VerifyWindowPoSt(context.TODO(), info) if err != nil { return err @@ -256,7 +254,7 @@ func (ss *syscallShim) VerifyPoSt(info proof5.WindowPoStVerifyInfo) error { return nil } -func (ss *syscallShim) VerifySeal(info proof5.SealVerifyInfo) error { +func (ss *syscallShim) VerifySeal(info proof7.SealVerifyInfo) error { //_, span := trace.StartSpan(ctx, "ValidatePoRep") //defer span.End() @@ -283,7 +281,7 @@ func (ss *syscallShim) VerifySeal(info proof5.SealVerifyInfo) error { return nil } -func (ss *syscallShim) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) error { +func (ss *syscallShim) VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) error { ok, err := ss.verifier.VerifyAggregateSeals(aggregate) if err != nil { return xerrors.Errorf("failed to verify aggregated PoRep: %w", err) @@ -322,7 +320,7 @@ func (ss *syscallShim) VerifySignature(sig crypto.Signature, addr address.Addres var BatchSealVerifyParallelism = goruntime.NumCPU() -func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]proof5.SealVerifyInfo) (map[address.Address][]bool, error) { +func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]proof7.SealVerifyInfo) (map[address.Address][]bool, error) { out := make(map[address.Address][]bool) sema := make(chan struct{}, BatchSealVerifyParallelism) @@ -334,7 +332,7 @@ func (ss *syscallShim) BatchVerifySeals(inp map[address.Address][]proof5.SealVer for i, s := range seals { wg.Add(1) - go func(ma address.Address, ix int, svi proof5.SealVerifyInfo, res []bool) { + go func(ma address.Address, ix int, svi proof7.SealVerifyInfo, res []bool) { defer wg.Done() sema <- struct{}{} diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 06c615ac7..26d3a82b3 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -27,12 +27,12 @@ import ( "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" + builtin_types "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/actors/builtin/account" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" @@ -227,8 +227,6 @@ type VMOpts struct { Actors *ActorRegistry Syscalls SyscallBuilder CircSupplyCalc CircSupplyCalculator - // Amount of FIL vested from genesis actors. - FilVested abi.TokenAmount NetworkVersion network.Version BaseFee abi.TokenAmount LookbackState LookbackStateGetter @@ -625,7 +623,7 @@ func (vm *LegacyVM) ShouldBurn(ctx context.Context, st *state.StateTree, msg *ty // Check to see if we should burn funds. We avoid burning on successful // window post. This won't catch _indirect_ window post calls, but this // is the best we can get for now. - if vm.blockHeight > build.UpgradeClausHeight && errcode == exitcode.Ok && msg.Method == miner.Methods.SubmitWindowedPoSt { + if vm.blockHeight > build.UpgradeClausHeight && errcode == exitcode.Ok && msg.Method == builtin_types.MethodsMiner.SubmitWindowedPoSt { // Ok, we've checked the _method_, but we still need to check // the target actor. It would be nice if we could just look at // the trace, but I'm not sure if that's safe? diff --git a/chain/vm/vmi.go b/chain/vm/vmi.go index 9ffd8d830..f7fc366ee 100644 --- a/chain/vm/vmi.go +++ b/chain/vm/vmi.go @@ -4,6 +4,7 @@ import ( "context" "os" + "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/types" "github.com/ipfs/go-cid" ) @@ -18,8 +19,15 @@ type Interface interface { Flush(ctx context.Context) (cid.Cid, error) } +var experimentalUseFvm = os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" + func NewVM(ctx context.Context, opts *VMOpts) (Interface, error) { - if os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" { + if opts.NetworkVersion >= network.Version16 { + return NewFVM(ctx, opts) + } + + // Remove after v16 upgrade, this is only to support testing and validation of the FVM + if experimentalUseFvm && opts.NetworkVersion >= network.Version15 { return NewFVM(ctx, opts) } diff --git a/cli/client.go b/cli/client.go index 5df7664cf..6ad08a7e6 100644 --- a/cli/client.go +++ b/cli/client.go @@ -1654,7 +1654,7 @@ var clientQueryAskCmd = &cli.Command{ return xerrors.Errorf("failed to get peerID for miner: %w", err) } - if mi.PeerId == nil || *mi.PeerId == peer.ID("SETME") { + if mi.PeerId == nil || *mi.PeerId == ("SETME") { return fmt.Errorf("the miner hasn't initialized yet") } diff --git a/cli/client_retr.go b/cli/client_retr.go index 9b195a5d8..f57681c74 100644 --- a/cli/client_retr.go +++ b/cli/client_retr.go @@ -145,7 +145,7 @@ func retrieve(ctx context.Context, cctx *cli.Context, fapi lapi.FullNode, sel *l } if offer.MinPrice.GreaterThan(big.Int(maxPrice)) { - return nil, xerrors.Errorf("failed to find offer satisfying maxPrice: %s", maxPrice) + return nil, xerrors.Errorf("failed to find offer satisfying maxPrice: %s. Try increasing maxPrice", maxPrice) } o := offer.Order(payer) diff --git a/cli/filplus.go b/cli/filplus.go index b3a98d487..24657c6b5 100644 --- a/cli/filplus.go +++ b/cli/filplus.go @@ -6,7 +6,7 @@ import ( "encoding/hex" "fmt" - verifreg4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/verifreg" + verifregtypes "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" "github.com/filecoin-project/go-state-types/big" @@ -96,7 +96,7 @@ var filplusVerifyClientCmd = &cli.Command{ } // TODO: This should be abstracted over actor versions - params, err := actors.SerializeParams(&verifreg4.AddVerifiedClientParams{Address: target, Allowance: allowance}) + params, err := actors.SerializeParams(&verifregtypes.AddVerifiedClientParams{Address: target, Allowance: allowance}) if err != nil { return err } @@ -361,14 +361,14 @@ var filplusSignRemoveDataCapProposal = &cli.Command{ } } - params := verifreg.RemoveDataCapProposal{ - RemovalProposalID: verifreg.RmDcProposalID{ProposalID: id}, + params := verifregtypes.RemoveDataCapProposal{ + RemovalProposalID: verifregtypes.RmDcProposalID{ProposalID: id}, DataCapAmount: allowanceToRemove, VerifiedClient: clientIdAddr, } paramBuf := new(bytes.Buffer) - paramBuf.WriteString(verifreg.SignatureDomainSeparation_RemoveDataCap) + paramBuf.WriteString(verifregtypes.SignatureDomainSeparation_RemoveDataCap) err = params.MarshalCBOR(paramBuf) if err != nil { return xerrors.Errorf("failed to marshall paramBuf: %w", err) diff --git a/cli/init.go b/cli/init.go new file mode 100644 index 000000000..25d6a1116 --- /dev/null +++ b/cli/init.go @@ -0,0 +1,21 @@ +package cli + +import ( + "context" + + "github.com/filecoin-project/lotus/blockstore" + "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/node/bundle" +) + +func init() { + // preload manifest so that we have the correct code CID inventory for cli since that doesn't + // go through CI + // TODO loading the bundle in every cli invocation adds some latency; we should figure out a way + // to load actor CIDs without incurring this hit. + bs := blockstore.NewMemory() + + if err := bundle.FetchAndLoadBundles(context.Background(), bs, build.BuiltinActorReleases); err != nil { + panic(err) + } +} diff --git a/cli/net.go b/cli/net.go index 5248a1410..1c3fb5be7 100644 --- a/cli/net.go +++ b/cli/net.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "math" "os" "sort" "strings" @@ -11,9 +12,11 @@ import ( "time" "github.com/dustin/go-humanize" + "github.com/fatih/color" "github.com/urfave/cli/v2" "golang.org/x/xerrors" + "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" protocol "github.com/libp2p/go-libp2p-core/protocol" "github.com/multiformats/go-multiaddr" @@ -150,7 +153,7 @@ var NetPing = &cli.Command{ ctx := ReqContext(cctx) - pis, err := addrInfoFromArg(ctx, cctx) + pis, err := AddrInfoFromArg(ctx, cctx) if err != nil { return err } @@ -271,7 +274,7 @@ var NetConnect = &cli.Command{ defer closer() ctx := ReqContext(cctx) - pis, err := addrInfoFromArg(ctx, cctx) + pis, err := AddrInfoFromArg(ctx, cctx) if err != nil { return err } @@ -290,7 +293,7 @@ var NetConnect = &cli.Command{ }, } -func addrInfoFromArg(ctx context.Context, cctx *cli.Context) ([]peer.AddrInfo, error) { +func AddrInfoFromArg(ctx context.Context, cctx *cli.Context) ([]peer.AddrInfo, error) { pis, err := addrutil.ParseAddresses(ctx, cctx.Args().Slice()) if err != nil { a, perr := address.NewFromString(cctx.Args().First()) @@ -701,9 +704,34 @@ var NetBlockListCmd = &cli.Command{ }, } +var BarCols = float64(64) + +func BarString(total, y, g float64) string { + yBars := int(math.Round(y / total * BarCols)) + gBars := int(math.Round(g / total * BarCols)) + if yBars < 0 { + yBars = 0 + } + if gBars < 0 { + gBars = 0 + } + eBars := int(BarCols) - yBars - gBars + var barString = color.YellowString(strings.Repeat("|", yBars)) + + color.GreenString(strings.Repeat("|", gBars)) + if eBars >= 0 { + barString += strings.Repeat(" ", eBars) + } + return barString +} + var NetStatCmd = &cli.Command{ - Name: "stat", - Usage: "Report resource usage for a scope", + Name: "stat", + Usage: "Report resource usage for a scope", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "json", + }, + }, ArgsUsage: "scope", Description: `Report resource usage for a scope. @@ -731,11 +759,72 @@ var NetStatCmd = &cli.Command{ result, err := api.NetStat(ctx, scope) if err != nil { - return err + return xerrors.Errorf("get stat: %w", err) } - enc := json.NewEncoder(os.Stdout) - return enc.Encode(result) + if cctx.Bool("json") { + enc := json.NewEncoder(os.Stdout) + return enc.Encode(result) + } + + printScope := func(stat *network.ScopeStat, scope string) { + if stat == nil { + return + } + + limit, err := api.NetLimit(ctx, scope) + if err != nil { + fmt.Printf("error: %s\n", color.RedString("%s", err)) + } + + fmt.Printf("%s\n", scope) + fmt.Printf("\tmemory: [%s] %s/%s\n", BarString(float64(limit.Memory), 0, float64(stat.Memory)), + types.SizeStr(types.NewInt(uint64(stat.Memory))), + types.SizeStr(types.NewInt(uint64(limit.Memory)))) + + fmt.Printf("\tstreams in: [%s] %d/%d\n", BarString(float64(limit.StreamsInbound), 0, float64(stat.NumStreamsInbound)), stat.NumStreamsInbound, limit.StreamsInbound) + fmt.Printf("\tstreams out: [%s] %d/%d\n", BarString(float64(limit.StreamsOutbound), 0, float64(stat.NumStreamsOutbound)), stat.NumStreamsOutbound, limit.StreamsOutbound) + fmt.Printf("\tconn in: [%s] %d/%d\n", BarString(float64(limit.ConnsInbound), 0, float64(stat.NumConnsInbound)), stat.NumConnsInbound, limit.ConnsInbound) + fmt.Printf("\tconn out: [%s] %d/%d\n", BarString(float64(limit.ConnsOutbound), 0, float64(stat.NumConnsOutbound)), stat.NumConnsOutbound, limit.ConnsOutbound) + fmt.Printf("\tfile desc: [%s] %d/%d\n", BarString(float64(limit.FD), 0, float64(stat.NumFD)), stat.NumFD, limit.FD) + fmt.Println() + } + + printScope(result.System, "system") + printScope(result.Transient, "transient") + + printScopes := func(name string, st map[string]network.ScopeStat) { + type namedStat struct { + name string + stat network.ScopeStat + } + + stats := make([]namedStat, 0, len(st)) + for n, stat := range st { + stats = append(stats, namedStat{ + name: n, + stat: stat, + }) + } + sort.Slice(stats, func(i, j int) bool { + if stats[i].stat.Memory == stats[j].stat.Memory { + return stats[i].name < stats[j].name + } + + return stats[i].stat.Memory > stats[j].stat.Memory + }) + + for _, stat := range stats { + printScope(&stat.stat, name+stat.name) + } + + } + + printScopes("svc:", result.Services) + printScopes("proto:", result.Protocols) + printScopes("peer:", result.Peers) + + return nil }, } diff --git a/cli/paych.go b/cli/paych.go index 92c1a13e3..33fcb2747 100644 --- a/cli/paych.go +++ b/cli/paych.go @@ -10,13 +10,14 @@ import ( lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/paychmgr" "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/build" "github.com/urfave/cli/v2" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + lpaych "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" ) @@ -92,6 +93,7 @@ var paychAddFundsCmd = &cli.Command{ } // Wait for the message to be confirmed + fmt.Println("waiting for confirmation..") chAddr, err := api.PaychGetWaitReady(ctx, info.WaitSentinel) if err != nil { return err @@ -416,7 +418,7 @@ var paychVoucherCheckCmd = &cli.Command{ return err } - sv, err := paych.DecodeSignedVoucher(cctx.Args().Get(1)) + sv, err := lpaych.DecodeSignedVoucher(cctx.Args().Get(1)) if err != nil { return err } @@ -452,7 +454,7 @@ var paychVoucherAddCmd = &cli.Command{ return err } - sv, err := paych.DecodeSignedVoucher(cctx.Args().Get(1)) + sv, err := lpaych.DecodeSignedVoucher(cctx.Args().Get(1)) if err != nil { return err } @@ -610,7 +612,7 @@ var paychVoucherSubmitCmd = &cli.Command{ return err } - sv, err := paych.DecodeSignedVoucher(cctx.Args().Get(1)) + sv, err := lpaych.DecodeSignedVoucher(cctx.Args().Get(1)) if err != nil { return err } diff --git a/cli/state.go b/cli/state.go index b1346d6cd..e9c187582 100644 --- a/cli/state.go +++ b/cli/state.go @@ -15,8 +15,13 @@ import ( "sort" "strconv" "strings" + "text/tabwriter" "time" + "github.com/filecoin-project/go-state-types/network" + + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/consensus/filcns" @@ -79,6 +84,7 @@ var StateCmd = &cli.Command{ StateExecTraceCmd, StateNtwkVersionCmd, StateMinerProvingDeadlineCmd, + StateSysActorCIDsCmd, }, } @@ -1875,3 +1881,71 @@ var StateNtwkVersionCmd = &cli.Command{ return nil }, } + +var StateSysActorCIDsCmd = &cli.Command{ + Name: "actor-cids", + Usage: "Returns the built-in actor bundle manifest ID & system actor cids", + Flags: []cli.Flag{ + &cli.UintFlag{ + Name: "network-version", + Usage: "specify network version", + Value: uint(build.NewestNetworkVersion), + }, + }, + Action: func(cctx *cli.Context) error { + if cctx.Args().Present() { + return ShowHelp(cctx, fmt.Errorf("doesn't expect any arguments")) + } + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + + ctx := ReqContext(cctx) + + ts, err := LoadTipSet(ctx, cctx, api) + if err != nil { + return err + } + + nv, err := api.StateNetworkVersion(ctx, ts.Key()) + if err != nil { + return err + } + + if cctx.IsSet("network-version") { + nv = network.Version(cctx.Uint64("network-version")) + } + + fmt.Printf("Network Version: %d\n", nv) + + actorVersion, err := actors.VersionForNetwork(nv) + if err != nil { + return err + } + fmt.Printf("Actor Version: %d\n", actorVersion) + + manifestCid, ok := actors.GetManifest(actorVersion) + if !ok { + return xerrors.Errorf("cannot get manifest CID") + } + fmt.Printf("Manifest CID: %v\n", manifestCid) + + tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0) + _, _ = fmt.Fprintln(tw, "\nActor\tCID\t") + + var actorKeys = actors.GetBuiltinActorsKeys() + for _, name := range actorKeys { + sysActorCID, ok := actors.GetActorCodeID(actorVersion, name) + if !ok { + return xerrors.Errorf("error getting actor %v code id for actor version %d", name, + actorVersion) + } + _, _ = fmt.Fprintf(tw, "%v\t%v\n", name, sysActorCID) + + } + return tw.Flush() + }, +} diff --git a/cmd/lotus-bench/caching_verifier.go b/cmd/lotus-bench/caching_verifier.go index 0fddf515d..8cb0f7211 100644 --- a/cmd/lotus-bench/caching_verifier.go +++ b/cmd/lotus-bench/caching_verifier.go @@ -5,11 +5,10 @@ import ( "context" "errors" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" - "github.com/filecoin-project/go-state-types/abi" + prooftypes "github.com/filecoin-project/go-state-types/proof" + "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" "github.com/ipfs/go-datastore" "github.com/minio/blake2b-simd" cbg "github.com/whyrusleeping/cbor-gen" @@ -80,17 +79,17 @@ func (cv cachingVerifier) withCache(execute func() (bool, error), param cbg.CBOR } } -func (cv *cachingVerifier) VerifySeal(svi proof2.SealVerifyInfo) (bool, error) { +func (cv *cachingVerifier) VerifySeal(svi prooftypes.SealVerifyInfo) (bool, error) { return cv.withCache(func() (bool, error) { return cv.backend.VerifySeal(svi) }, &svi) } -func (cv *cachingVerifier) VerifyWinningPoSt(ctx context.Context, info proof7.WinningPoStVerifyInfo) (bool, error) { +func (cv *cachingVerifier) VerifyWinningPoSt(ctx context.Context, info prooftypes.WinningPoStVerifyInfo) (bool, error) { return cv.backend.VerifyWinningPoSt(ctx, info) } -func (cv *cachingVerifier) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) { +func (cv *cachingVerifier) VerifyWindowPoSt(ctx context.Context, info prooftypes.WindowPoStVerifyInfo) (bool, error) { return cv.withCache(func() (bool, error) { return cv.backend.VerifyWindowPoSt(ctx, info) }, &info) @@ -99,11 +98,11 @@ func (cv *cachingVerifier) GenerateWinningPoStSectorChallenge(ctx context.Contex return cv.backend.GenerateWinningPoStSectorChallenge(ctx, proofType, a, rnd, u) } -func (cv cachingVerifier) VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) (bool, error) { +func (cv cachingVerifier) VerifyAggregateSeals(aggregate prooftypes.AggregateSealVerifyProofAndInfos) (bool, error) { return cv.backend.VerifyAggregateSeals(aggregate) } -func (cv cachingVerifier) VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) (bool, error) { +func (cv cachingVerifier) VerifyReplicaUpdate(update prooftypes.ReplicaUpdateInfo) (bool, error) { return cv.backend.VerifyReplicaUpdate(update) } diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 59d4e53cf..fc249cdec 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -11,9 +11,7 @@ import ( "path/filepath" "time" - saproof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" - "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" - saproof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + prooftypes "github.com/filecoin-project/go-state-types/proof" "github.com/docker/go-units" logging "github.com/ipfs/go-log/v2" @@ -263,8 +261,8 @@ var sealBenchCmd = &cli.Command{ sectorNumber := c.Int("num-sectors") var sealTimings []SealingResult - var extendedSealedSectors []saproof7.ExtendedSectorInfo - var sealedSectors []saproof7.SectorInfo + var extendedSealedSectors []prooftypes.ExtendedSectorInfo + var sealedSectors []prooftypes.SectorInfo if robench == "" { var err error @@ -278,7 +276,7 @@ var sealBenchCmd = &cli.Command{ return xerrors.Errorf("failed to run seals: %w", err) } for _, s := range extendedSealedSectors { - sealedSectors = append(sealedSectors, proof.SectorInfo{ + sealedSectors = append(sealedSectors, prooftypes.SectorInfo{ SealedCID: s.SealedCID, SectorNumber: s.SectorNumber, SealProof: s.SealProof, @@ -307,13 +305,13 @@ var sealBenchCmd = &cli.Command{ } for _, s := range genm.Sectors { - extendedSealedSectors = append(extendedSealedSectors, saproof7.ExtendedSectorInfo{ + extendedSealedSectors = append(extendedSealedSectors, prooftypes.ExtendedSectorInfo{ SealedCID: s.CommR, SectorNumber: s.SectorID, SealProof: s.ProofType, SectorKey: nil, }) - sealedSectors = append(sealedSectors, proof.SectorInfo{ + sealedSectors = append(sealedSectors, prooftypes.SectorInfo{ SealedCID: s.CommR, SectorNumber: s.SectorID, SealProof: s.ProofType, @@ -347,7 +345,7 @@ var sealBenchCmd = &cli.Command{ return err } - xcandidates := make([]saproof7.ExtendedSectorInfo, len(fcandidates)) + xcandidates := make([]prooftypes.ExtendedSectorInfo, len(fcandidates)) for i, fcandidate := range fcandidates { xcandidates[i] = extendedSealedSectors[fcandidate] } @@ -368,9 +366,9 @@ var sealBenchCmd = &cli.Command{ return err } - candidates := make([]saproof7.SectorInfo, len(xcandidates)) + candidates := make([]prooftypes.SectorInfo, len(xcandidates)) for i, xsi := range xcandidates { - candidates[i] = saproof7.SectorInfo{ + candidates[i] = prooftypes.SectorInfo{ SealedCID: xsi.SealedCID, SectorNumber: xsi.SectorNumber, SealProof: xsi.SealProof, @@ -379,7 +377,7 @@ var sealBenchCmd = &cli.Command{ winnningpost2 := time.Now() - pvi1 := saproof7.WinningPoStVerifyInfo{ + pvi1 := prooftypes.WinningPoStVerifyInfo{ Randomness: abi.PoStRandomness(challenge[:]), Proofs: proof1, ChallengedSectors: candidates, @@ -395,7 +393,7 @@ var sealBenchCmd = &cli.Command{ verifyWinningPost1 := time.Now() - pvi2 := saproof7.WinningPoStVerifyInfo{ + pvi2 := prooftypes.WinningPoStVerifyInfo{ Randomness: abi.PoStRandomness(challenge[:]), Proofs: proof2, ChallengedSectors: candidates, @@ -427,7 +425,7 @@ var sealBenchCmd = &cli.Command{ windowpost2 := time.Now() - wpvi1 := saproof2.WindowPoStVerifyInfo{ + wpvi1 := prooftypes.WindowPoStVerifyInfo{ Randomness: challenge[:], Proofs: wproof1, ChallengedSectors: sealedSectors, @@ -443,7 +441,7 @@ var sealBenchCmd = &cli.Command{ verifyWindowpost1 := time.Now() - wpvi2 := saproof2.WindowPoStVerifyInfo{ + wpvi2 := prooftypes.WindowPoStVerifyInfo{ Randomness: challenge[:], Proofs: wproof2, ChallengedSectors: sealedSectors, @@ -528,10 +526,10 @@ type ParCfg struct { Commit int } -func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par ParCfg, mid abi.ActorID, sectorSize abi.SectorSize, ticketPreimage []byte, saveC2inp string, skipc2, skipunseal bool) ([]SealingResult, []saproof7.ExtendedSectorInfo, error) { +func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par ParCfg, mid abi.ActorID, sectorSize abi.SectorSize, ticketPreimage []byte, saveC2inp string, skipc2, skipunseal bool) ([]SealingResult, []prooftypes.ExtendedSectorInfo, error) { var pieces []abi.PieceInfo sealTimings := make([]SealingResult, numSectors) - sealedSectors := make([]saproof7.ExtendedSectorInfo, numSectors) + sealedSectors := make([]prooftypes.ExtendedSectorInfo, numSectors) preCommit2Sema := make(chan struct{}, par.PreCommit2) commitSema := make(chan struct{}, par.Commit) @@ -605,7 +603,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par precommit2 := time.Now() <-preCommit2Sema - sealedSectors[i] = saproof7.ExtendedSectorInfo{ + sealedSectors[i] = prooftypes.ExtendedSectorInfo{ SealProof: sid.ProofType, SectorNumber: i, SealedCID: cids.Sealed, @@ -658,7 +656,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par <-commitSema if !skipc2 { - svi := saproof2.SealVerifyInfo{ + svi := prooftypes.SealVerifyInfo{ SectorID: abi.SectorID{Miner: mid, Number: i}, SealedCID: cids.Sealed, SealProof: sid.ProofType, diff --git a/cmd/lotus-bench/simple.go b/cmd/lotus-bench/simple.go index 21c90eb34..408381481 100644 --- a/cmd/lotus-bench/simple.go +++ b/cmd/lotus-bench/simple.go @@ -52,7 +52,7 @@ d:baga6ea4seaqpy7usqklokfx2vxuynmupslkeutzexe2uqurdg5vhtebhxqmpqmy r:bagboea4b5a > Run Commit1 -$ ./lotus-bench simple commit1 --sector-size 2k /tmp/sl /tmp/cac baga6ea4seaqpy7usqklokfx2vxuynmupslkeutzexe2uqurdg5vhtebhxqmpqmy bagboea4b5abcbrshxgmmpaucffwp2elaofbcrvb7hmcu3653o4lsw2arlor4hn3c /tmp/c1.json +$ ./lotus-bench simple commit1 --sector-size 2k /tmp/sealed /tmp/cache baga6ea4seaqpy7usqklokfx2vxuynmupslkeutzexe2uqurdg5vhtebhxqmpqmy bagboea4b5abcbrshxgmmpaucffwp2elaofbcrvb7hmcu3653o4lsw2arlor4hn3c /tmp/c1.json Commit1 20.691875ms (96.66 KiB/s) > Run Commit2 @@ -96,7 +96,7 @@ d:baga6ea4seaqkt24j5gbf2ye2wual5gn7a5yl2tqb52v2sk4nvur4bdy7lg76cdy r:bagboea4b5a > Run ProveReplicaUpdate1 -$ ./lotus-bench simple provereplicaupdate1 --sector-size 2K /tmp/sl /tmp/cac /tmp/update /tmp/update-cache bagboea4b5abcbrshxgmmpaucffwp2elaofbcrvb7hmcu3653o4lsw2arlor4hn3c bagboea4b5abcaydcwlbtdx5dph2a3efpqt42emxpn3be76iu4e4lx3ltrpmpi7af baga6ea4seaqkt24j5gbf2ye2wual5gn7a5yl2tqb52v2sk4nvur4bdy7lg76cdy /tmp/pr1.json +$ ./lotus-bench simple provereplicaupdate1 --sector-size 2K /tmp/sealed /tmp/cache /tmp/update /tmp/update-cache bagboea4b5abcbrshxgmmpaucffwp2elaofbcrvb7hmcu3653o4lsw2arlor4hn3c bagboea4b5abcaydcwlbtdx5dph2a3efpqt42emxpn3be76iu4e4lx3ltrpmpi7af baga6ea4seaqkt24j5gbf2ye2wual5gn7a5yl2tqb52v2sk4nvur4bdy7lg76cdy /tmp/pr1.json ProveReplicaUpdate1 18.373375ms (108.9 KiB/s) > Run ProveReplicaUpdate2 diff --git a/cmd/lotus-miner/actor.go b/cmd/lotus-miner/actor.go index 01440a09e..a6d047e37 100644 --- a/cmd/lotus-miner/actor.go +++ b/cmd/lotus-miner/actor.go @@ -6,6 +6,10 @@ import ( "os" "strings" + "github.com/filecoin-project/lotus/api" + + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/go-state-types/network" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" @@ -22,13 +26,12 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" - + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/lib/tablewriter" @@ -117,7 +120,7 @@ var actorSetAddrsCmd = &cli.Command{ return err } - params, err := actors.SerializeParams(&miner2.ChangeMultiaddrsParams{NewMultiaddrs: addrs}) + params, err := actors.SerializeParams(&miner.ChangeMultiaddrsParams{NewMultiaddrs: addrs}) if err != nil { return err } @@ -129,7 +132,7 @@ var actorSetAddrsCmd = &cli.Command{ From: minfo.Worker, Value: types.NewInt(0), GasLimit: gasLimit, - Method: miner.Methods.ChangeMultiaddrs, + Method: builtin.MethodsMiner.ChangeMultiaddrs, Params: params, }, nil) if err != nil { @@ -182,7 +185,7 @@ var actorSetPeeridCmd = &cli.Command{ return err } - params, err := actors.SerializeParams(&miner2.ChangePeerIDParams{NewID: abi.PeerID(pid)}) + params, err := actors.SerializeParams(&miner.ChangePeerIDParams{NewID: abi.PeerID(pid)}) if err != nil { return err } @@ -194,7 +197,7 @@ var actorSetPeeridCmd = &cli.Command{ From: minfo.Worker, Value: types.NewInt(0), GasLimit: gasLimit, - Method: miner.Methods.ChangePeerID, + Method: builtin.MethodsMiner.ChangePeerID, Params: params, }, nil) if err != nil { @@ -262,7 +265,7 @@ var actorWithdrawCmd = &cli.Command{ } } - params, err := actors.SerializeParams(&miner2.WithdrawBalanceParams{ + params, err := actors.SerializeParams(&miner.WithdrawBalanceParams{ AmountRequested: amount, // Default to attempting to withdraw all the extra funds in the miner actor }) if err != nil { @@ -273,7 +276,7 @@ var actorWithdrawCmd = &cli.Command{ To: maddr, From: mi.Owner, Value: types.NewInt(0), - Method: miner.Methods.WithdrawBalance, + Method: builtin.MethodsMiner.WithdrawBalance, Params: params, }, nil) if err != nil { @@ -368,7 +371,7 @@ var actorRepayDebtCmd = &cli.Command{ store := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(api))) - mst, err := miner.Load(store, mact) + mst, err := lminer.Load(store, mact) if err != nil { return err } @@ -395,7 +398,7 @@ var actorRepayDebtCmd = &cli.Command{ return err } - if !mi.IsController(fromId) { + if !isController(mi, fromId) { return xerrors.Errorf("sender isn't a controller of miner: %s", fromId) } @@ -403,7 +406,7 @@ var actorRepayDebtCmd = &cli.Command{ To: maddr, From: fromId, Value: amount, - Method: miner.Methods.RepayDebt, + Method: builtin.MethodsMiner.RepayDebt, Params: nil, }, nil) if err != nil { @@ -682,7 +685,7 @@ var actorControlSet = &cli.Command{ return nil } - cwp := &miner2.ChangeWorkerAddressParams{ + cwp := &miner.ChangeWorkerAddressParams{ NewWorker: mi.Worker, NewControlAddrs: toSet, } @@ -695,7 +698,7 @@ var actorControlSet = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.ChangeWorkerAddress, + Method: builtin.MethodsMiner.ChangeWorkerAddress, Value: big.Zero(), Params: sp, @@ -781,7 +784,7 @@ var actorSetOwnerCmd = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: fromAddrId, To: maddr, - Method: miner.Methods.ChangeOwnerAddress, + Method: builtin.MethodsMiner.ChangeOwnerAddress, Value: big.Zero(), Params: sp, }, nil) @@ -874,7 +877,7 @@ var actorProposeChangeWorker = &cli.Command{ return nil } - cwp := &miner2.ChangeWorkerAddressParams{ + cwp := &miner.ChangeWorkerAddressParams{ NewWorker: newAddr, NewControlAddrs: mi.ControlAddresses, } @@ -887,7 +890,7 @@ var actorProposeChangeWorker = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.ChangeWorkerAddress, + Method: builtin.MethodsMiner.ChangeWorkerAddress, Value: big.Zero(), Params: sp, }, nil) @@ -994,7 +997,7 @@ var actorConfirmChangeWorker = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.ConfirmUpdateWorkerKey, + Method: builtin.MethodsMiner.ConfirmUpdateWorkerKey, Value: big.Zero(), }, nil) if err != nil { @@ -1081,7 +1084,7 @@ var actorCompactAllocatedCmd = &cli.Command{ store := adt.WrapStore(ctx, cbor.NewCborStore(blockstore.NewAPIBlockstore(api))) - mst, err := miner.Load(store, mact) + mst, err := lminer.Load(store, mact) if err != nil { return err } @@ -1140,7 +1143,7 @@ var actorCompactAllocatedCmd = &cli.Command{ return err } - params := &miner2.CompactSectorNumbersParams{ + params := &miner.CompactSectorNumbersParams{ MaskSectorNumbers: maskBf, } @@ -1152,7 +1155,7 @@ var actorCompactAllocatedCmd = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: mi.Worker, To: maddr, - Method: miner.Methods.CompactSectorNumbers, + Method: builtin.MethodsMiner.CompactSectorNumbers, Value: big.Zero(), Params: sp, }, nil) @@ -1177,3 +1180,17 @@ var actorCompactAllocatedCmd = &cli.Command{ return nil }, } + +func isController(mi api.MinerInfo, addr address.Address) bool { + if addr == mi.Owner || addr == mi.Worker { + return true + } + + for _, ca := range mi.ControlAddresses { + if addr == ca { + return true + } + } + + return false +} diff --git a/cmd/lotus-miner/init.go b/cmd/lotus-miner/init.go index 7d81026f2..6dedb2656 100644 --- a/cmd/lotus-miner/init.go +++ b/cmd/lotus-miner/init.go @@ -13,6 +13,9 @@ import ( "path/filepath" "strconv" + "github.com/filecoin-project/go-state-types/builtin" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power" "github.com/docker/go-units" @@ -36,13 +39,13 @@ import ( "github.com/filecoin-project/lotus/extern/sector-storage/stores" "github.com/filecoin-project/lotus/extern/sector-storage/storiface" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/api/v1api" + "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -56,6 +59,7 @@ import ( "github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/journal/fsjournal" storageminer "github.com/filecoin-project/lotus/miner" + "github.com/filecoin-project/lotus/node/bundle" "github.com/filecoin-project/lotus/node/modules" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/repo" @@ -214,6 +218,13 @@ var initCmd = &cli.Command{ return err } + // load bundles + bs := blockstore.NewMemory() + + if err := bundle.FetchAndLoadBundles(ctx, bs, build.BuiltinActorReleases); err != nil { + return err + } + var localPaths []stores.LocalPath if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 { @@ -391,7 +402,7 @@ func migratePreSealMeta(ctx context.Context, api v1api.FullNode, metadata string return mds.Put(ctx, datastore.NewKey(modules.StorageCounterDSPrefix), buf[:size]) } -func findMarketDealID(ctx context.Context, api v1api.FullNode, deal market2.DealProposal) (abi.DealID, error) { +func findMarketDealID(ctx context.Context, api v1api.FullNode, deal market8.DealProposal) (abi.DealID, error) { // TODO: find a better way // (this is only used by genesis miners) @@ -599,7 +610,7 @@ func configureStorageMiner(ctx context.Context, api v1api.FullNode, addr address msg := &types.Message{ To: addr, From: mi.Worker, - Method: miner.Methods.ChangePeerID, + Method: builtin.MethodsMiner.ChangePeerID, Params: enc, Value: types.NewInt(0), GasPremium: gasPrice, diff --git a/cmd/lotus-miner/init_restore.go b/cmd/lotus-miner/init_restore.go index 1aaa7909a..e5f8174de 100644 --- a/cmd/lotus-miner/init_restore.go +++ b/cmd/lotus-miner/init_restore.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v0api" "github.com/docker/go-units" @@ -22,7 +23,6 @@ import ( lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/extern/sector-storage/stores" @@ -74,7 +74,7 @@ var restoreCmd = &cli.Command{ repoPath := cctx.String(FlagMinerRepo) - if err := restore(ctx, cctx, repoPath, storageCfg, nil, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi miner.MinerInfo) error { + if err := restore(ctx, cctx, repoPath, storageCfg, nil, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi api.MinerInfo) error { log.Info("Checking proof parameters") if err := paramfetch.GetParams(ctx, build.ParametersJSON(), build.SrsJSON(), uint64(mi.SectorSize)); err != nil { @@ -96,7 +96,7 @@ var restoreCmd = &cli.Command{ }, } -func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *stores.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi miner.MinerInfo) error) error { +func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *stores.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error { if cctx.Args().Len() != 1 { return xerrors.Errorf("expected 1 argument") } diff --git a/cmd/lotus-miner/init_service.go b/cmd/lotus-miner/init_service.go index 6e874023e..d0d0e3fa9 100644 --- a/cmd/lotus-miner/init_service.go +++ b/cmd/lotus-miner/init_service.go @@ -6,9 +6,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/lotus/api" lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/client" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" lcli "github.com/filecoin-project/lotus/cli" cliutil "github.com/filecoin-project/lotus/cli/util" "github.com/filecoin-project/lotus/extern/sector-storage/stores" @@ -99,7 +99,7 @@ var serviceCmd = &cli.Command{ } return nil - }, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi miner.MinerInfo) error { + }, func(api lapi.FullNode, maddr address.Address, peerid peer.ID, mi api.MinerInfo) error { if es.Contains(MarketsService) { log.Info("Configuring miner actor") diff --git a/cmd/lotus-miner/precommits-info.go b/cmd/lotus-miner/precommits-info.go index e700859e9..2075ed339 100644 --- a/cmd/lotus-miner/precommits-info.go +++ b/cmd/lotus-miner/precommits-info.go @@ -4,8 +4,10 @@ import ( "fmt" "sort" - "github.com/filecoin-project/lotus/blockstore" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + + "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/specs-actors/v7/actors/util/adt" @@ -36,8 +38,8 @@ var sectorPreCommitsCmd = &cli.Command{ if err != nil { return err } - preCommitSector := make([]miner.SectorPreCommitOnChainInfo, 0) - err = mst.ForEachPrecommittedSector(func(info miner.SectorPreCommitOnChainInfo) error { + preCommitSector := make([]minertypes.SectorPreCommitOnChainInfo, 0) + err = mst.ForEachPrecommittedSector(func(info minertypes.SectorPreCommitOnChainInfo) error { preCommitSector = append(preCommitSector, info) return err }) diff --git a/cmd/lotus-miner/sealing.go b/cmd/lotus-miner/sealing.go index 6ee10dacc..21e672e38 100644 --- a/cmd/lotus-miner/sealing.go +++ b/cmd/lotus-miner/sealing.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "math" "net/http" "os" "sort" @@ -42,20 +41,6 @@ var sealingCmd = &cli.Command{ }, } -var barCols = float64(64) - -func barString(total, y, g float64) string { - yBars := int(math.Round(y / total * barCols)) - gBars := int(math.Round(g / total * barCols)) - eBars := int(barCols) - yBars - gBars - var barString = color.YellowString(strings.Repeat("|", yBars)) + - color.GreenString(strings.Repeat("|", gBars)) - if eBars >= 0 { - barString += strings.Repeat(" ", eBars) - } - return barString -} - func workersCmd(sealing bool) *cli.Command { return &cli.Command{ Name: "workers", @@ -170,7 +155,7 @@ func workersCmd(sealing bool) *cli.Command { // CPU use fmt.Printf("\tCPU: [%s] %d/%d core(s) in use\n", - barString(float64(stat.Info.Resources.CPUs), 0, float64(stat.CpuUse)), stat.CpuUse, stat.Info.Resources.CPUs) + lcli.BarString(float64(stat.Info.Resources.CPUs), 0, float64(stat.CpuUse)), stat.CpuUse, stat.Info.Resources.CPUs) // RAM use @@ -181,7 +166,7 @@ func workersCmd(sealing bool) *cli.Command { if ramUsed > ramTasks { ramReserved = ramUsed - ramTasks } - ramBar := barString(float64(ramTotal), float64(ramReserved), float64(ramTasks)) + ramBar := lcli.BarString(float64(ramTotal), float64(ramReserved), float64(ramTasks)) fmt.Printf("\tRAM: [%s] %d%% %s/%s\n", ramBar, (ramTasks+ramReserved)*100/stat.Info.Resources.MemPhysical, @@ -197,7 +182,7 @@ func workersCmd(sealing bool) *cli.Command { if vmemUsed > vmemTasks { vmemReserved = vmemUsed - vmemTasks } - vmemBar := barString(float64(vmemTotal), float64(vmemReserved), float64(vmemTasks)) + vmemBar := lcli.BarString(float64(vmemTotal), float64(vmemReserved), float64(vmemTasks)) fmt.Printf("\tVMEM: [%s] %d%% %s/%s\n", vmemBar, (vmemTasks+vmemReserved)*100/vmemTotal, @@ -207,7 +192,7 @@ func workersCmd(sealing bool) *cli.Command { // GPU use if len(stat.Info.Resources.GPUs) > 0 { - gpuBar := barString(float64(len(stat.Info.Resources.GPUs)), 0, stat.GpuUsed) + gpuBar := lcli.BarString(float64(len(stat.Info.Resources.GPUs)), 0, stat.GpuUsed) fmt.Printf("\tGPU: [%s] %.f%% %.2f/%d gpu(s) in use\n", color.GreenString(gpuBar), stat.GpuUsed*100/float64(len(stat.Info.Resources.GPUs)), stat.GpuUsed, len(stat.Info.Resources.GPUs)) diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 0918f62f0..1ecc01295 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -20,14 +20,15 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/network" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/tablewriter" @@ -183,14 +184,14 @@ var sectorsStatusCmd = &cli.Command{ } tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(fullApi), blockstore.NewMemory()) - mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) + mas, err := lminer.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) if err != nil { return err } errFound := errors.New("found") - if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { - return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { + if err := mas.ForEachDeadline(func(dlIdx uint64, dl lminer.Deadline) error { + return dl.ForEachPartition(func(partIdx uint64, part lminer.Partition) error { pas, err := part.AllSectors() if err != nil { return err @@ -686,7 +687,7 @@ type PseudoExtendSectorExpirationParams struct { Extensions []PseudoExpirationExtension } -func NewPseudoExtendParams(p *miner5.ExtendSectorExpirationParams) (*PseudoExtendSectorExpirationParams, error) { +func NewPseudoExtendParams(p *miner.ExtendSectorExpirationParams) (*PseudoExtendSectorExpirationParams, error) { res := PseudoExtendSectorExpirationParams{} for _, ext := range p.Extensions { scount, err := ext.Sectors.Count() @@ -859,22 +860,22 @@ var sectorsRenewCmd = &cli.Command{ } tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(fullApi), blockstore.NewMemory()) - mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) + mas, err := lminer.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) if err != nil { return err } - activeSectorsLocation := make(map[abi.SectorNumber]*miner.SectorLocation, len(activeSet)) + activeSectorsLocation := make(map[abi.SectorNumber]*lminer.SectorLocation, len(activeSet)) - if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { - return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { + if err := mas.ForEachDeadline(func(dlIdx uint64, dl lminer.Deadline) error { + return dl.ForEachPartition(func(partIdx uint64, part lminer.Partition) error { pas, err := part.ActiveSectors() if err != nil { return err } return pas.ForEach(func(i uint64) error { - activeSectorsLocation[abi.SectorNumber(i)] = &miner.SectorLocation{ + activeSectorsLocation[abi.SectorNumber(i)] = &lminer.SectorLocation{ Deadline: dlIdx, Partition: partIdx, } @@ -939,7 +940,7 @@ var sectorsRenewCmd = &cli.Command{ } } - extensions := map[miner.SectorLocation]map[abi.ChainEpoch][]uint64{} + extensions := map[lminer.SectorLocation]map[abi.ChainEpoch][]uint64{} withinTolerance := func(a, b abi.ChainEpoch) bool { diff := a - b @@ -998,9 +999,9 @@ var sectorsRenewCmd = &cli.Command{ } } - var params []miner5.ExtendSectorExpirationParams + var params []miner.ExtendSectorExpirationParams - p := miner5.ExtendSectorExpirationParams{} + p := miner.ExtendSectorExpirationParams{} scount := 0 for l, exts := range extensions { @@ -1016,11 +1017,11 @@ var sectorsRenewCmd = &cli.Command{ } if scount > addrSectors || len(p.Extensions) == declMax { params = append(params, p) - p = miner5.ExtendSectorExpirationParams{} + p = miner.ExtendSectorExpirationParams{} scount = len(numbers) } - p.Extensions = append(p.Extensions, miner5.ExpirationExtension{ + p.Extensions = append(p.Extensions, miner.ExpirationExtension{ Deadline: l.Deadline, Partition: l.Partition, Sectors: bitfield.NewFromSet(numbers), @@ -1082,7 +1083,7 @@ var sectorsRenewCmd = &cli.Command{ smsg, err := fullApi.MpoolPushMessage(ctx, &types.Message{ From: mi.Worker, To: maddr, - Method: miner.Methods.ExtendSectorExpiration, + Method: builtin.MethodsMiner.ExtendSectorExpiration, Value: big.Zero(), Params: sp, }, spec) @@ -1148,7 +1149,7 @@ var sectorsExtendCmd = &cli.Command{ return err } - var params []miner5.ExtendSectorExpirationParams + var params []miner.ExtendSectorExpirationParams if cctx.Bool("v1-sectors") { @@ -1162,7 +1163,7 @@ var sectorsExtendCmd = &cli.Command{ return err } - extensions := map[miner.SectorLocation]map[abi.ChainEpoch][]uint64{} + extensions := map[lminer.SectorLocation]map[abi.ChainEpoch][]uint64{} // are given durations within tolerance epochs withinTolerance := func(a, b abi.ChainEpoch) bool { @@ -1201,7 +1202,7 @@ var sectorsExtendCmd = &cli.Command{ } // Set the new expiration to 48 hours less than the theoretical maximum lifetime - newExp := ml - (miner5.WPoStProvingPeriod * 2) + si.Activation + newExp := ml - (miner.WPoStProvingPeriod * 2) + si.Activation if withinTolerance(si.Expiration, newExp) || si.Expiration >= newExp { continue } @@ -1236,7 +1237,7 @@ var sectorsExtendCmd = &cli.Command{ } } - p := miner5.ExtendSectorExpirationParams{} + p := miner.ExtendSectorExpirationParams{} scount := 0 for l, exts := range extensions { @@ -1252,11 +1253,11 @@ var sectorsExtendCmd = &cli.Command{ } if scount > addressedMax || len(p.Extensions) == declMax { params = append(params, p) - p = miner5.ExtendSectorExpirationParams{} + p = miner.ExtendSectorExpirationParams{} scount = len(numbers) } - p.Extensions = append(p.Extensions, miner5.ExpirationExtension{ + p.Extensions = append(p.Extensions, miner.ExpirationExtension{ Deadline: l.Deadline, Partition: l.Partition, Sectors: bitfield.NewFromSet(numbers), @@ -1274,7 +1275,7 @@ var sectorsExtendCmd = &cli.Command{ if !cctx.Args().Present() || !cctx.IsSet("new-expiration") { return xerrors.Errorf("must pass at least one sector number and new expiration") } - sectors := map[miner.SectorLocation][]uint64{} + sectors := map[lminer.SectorLocation][]uint64{} for i, s := range cctx.Args().Slice() { id, err := strconv.ParseUint(s, 10, 64) @@ -1294,11 +1295,11 @@ var sectorsExtendCmd = &cli.Command{ sectors[*p] = append(sectors[*p], id) } - p := miner5.ExtendSectorExpirationParams{} + p := miner.ExtendSectorExpirationParams{} for l, numbers := range sectors { // TODO: Dedup with above loop - p.Extensions = append(p.Extensions, miner5.ExpirationExtension{ + p.Extensions = append(p.Extensions, miner.ExpirationExtension{ Deadline: l.Deadline, Partition: l.Partition, Sectors: bitfield.NewFromSet(numbers), @@ -1328,7 +1329,7 @@ var sectorsExtendCmd = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: mi.Worker, To: maddr, - Method: miner.Methods.ExtendSectorExpiration, + Method: builtin.MethodsMiner.ExtendSectorExpiration, Value: big.Zero(), Params: sp, @@ -1650,7 +1651,7 @@ var sectorsCapacityCollateralCmd = &cli.Command{ return err } - spt, err := miner.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType) + spt, err := lminer.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType) if err != nil { return err } @@ -1819,7 +1820,7 @@ var sectorsExpiredCmd = &cli.Command{ } tbs := blockstore.NewTieredBstore(blockstore.NewAPIBlockstore(fullApi), blockstore.NewMemory()) - mas, err := miner.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) + mas, err := lminer.Load(adt.WrapStore(ctx, cbor.NewCborStore(tbs)), mact) if err != nil { return err } @@ -1835,8 +1836,8 @@ var sectorsExpiredCmd = &cli.Command{ return xerrors.Errorf("intersecting bitfields: %w", err) } - if err := mas.ForEachDeadline(func(dlIdx uint64, dl miner.Deadline) error { - return dl.ForEachPartition(func(partIdx uint64, part miner.Partition) error { + if err := mas.ForEachDeadline(func(dlIdx uint64, dl lminer.Deadline) error { + return dl.ForEachPartition(func(partIdx uint64, part lminer.Partition) error { live, err := part.LiveSectors() if err != nil { return err @@ -2091,6 +2092,7 @@ func yesno(b bool) string { return color.RedString("NO") } +// TODO simulate this call if --really-do-it is not used var sectorsCompactPartitionsCmd = &cli.Command{ Name: "compact-partitions", Usage: "removes dead sectors from partitions and reduces the number of partitions used if possible", @@ -2110,6 +2112,10 @@ var sectorsCompactPartitionsCmd = &cli.Command{ Usage: "Actually send transaction performing the action", Value: false, }, + &cli.StringFlag{ + Name: "actor", + Usage: "Specify the address of the miner to run this command", + }, }, Action: func(cctx *cli.Context) error { if !cctx.Bool("really-do-it") { @@ -2136,21 +2142,22 @@ var sectorsCompactPartitionsCmd = &cli.Command{ } deadline := cctx.Uint64("deadline") - if err != nil { - return err + if deadline > miner.WPoStPeriodDeadlines { + return fmt.Errorf("deadline %d out of range", deadline) } parts := cctx.Int64Slice("partitions") if len(parts) <= 0 { return fmt.Errorf("must include at least one partition to compact") } + fmt.Printf("compacting %d paritions\n", len(parts)) - partitions := bitfield.BitField{} + partitions := bitfield.New() for _, partition := range parts { partitions.Set(uint64(partition)) } - params := miner5.CompactPartitionsParams{ + params := miner.CompactPartitionsParams{ Deadline: deadline, Partitions: partitions, } @@ -2163,7 +2170,7 @@ var sectorsCompactPartitionsCmd = &cli.Command{ smsg, err := api.MpoolPushMessage(ctx, &types.Message{ From: minfo.Worker, To: maddr, - Method: miner.Methods.CompactPartitions, + Method: builtin.MethodsMiner.CompactPartitions, Value: big.Zero(), Params: sp, }, nil) @@ -2171,7 +2178,18 @@ var sectorsCompactPartitionsCmd = &cli.Command{ return xerrors.Errorf("mpool push: %w", err) } - fmt.Println("Message CID:", smsg.Cid()) + fmt.Printf("Requested compact partitions in message %s\n", smsg.Cid()) + + wait, err := api.StateWaitMsg(ctx, smsg.Cid(), 0) + if err != nil { + return err + } + + // check it executed successfully + if wait.Receipt.ExitCode != 0 { + fmt.Println(cctx.App.Writer, "compact partitions failed!") + return err + } return nil }, diff --git a/cmd/lotus-pcr/main.go b/cmd/lotus-pcr/main.go index 469f5ad8e..46ba49834 100644 --- a/cmd/lotus-pcr/main.go +++ b/cmd/lotus-pcr/main.go @@ -16,7 +16,11 @@ import ( "strings" "time" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/go-state-types/builtin" + + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + + lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" lcli "github.com/filecoin-project/lotus/cli" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" @@ -635,9 +639,9 @@ type refunderNodeApi interface { ChainGetParentReceipts(ctx context.Context, blockCid cid.Cid) ([]*types.MessageReceipt, error) ChainGetTipSetByHeight(ctx context.Context, epoch abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) ChainReadObj(context.Context, cid.Cid) ([]byte, error) - StateMinerInitialPledgeCollateral(ctx context.Context, addr address.Address, precommitInfo miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) - StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) - StateSectorPreCommitInfo(ctx context.Context, addr address.Address, sector abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) + StateMinerInitialPledgeCollateral(ctx context.Context, addr address.Address, precommitInfo minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) + StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) + StateSectorPreCommitInfo(ctx context.Context, addr address.Address, sector abi.SectorNumber, tsk types.TipSetKey) (minertypes.SectorPreCommitOnChainInfo, error) StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) StateMinerSectors(ctx context.Context, addr address.Address, filter *bitfield.BitField, tsk types.TipSetKey) ([]*miner.SectorOnChainInfo, error) StateMinerFaults(ctx context.Context, addr address.Address, tsk types.TipSetKey) (bitfield.BitField, error) @@ -937,7 +941,7 @@ func (r *refunder) processTipsetStorageMinerActor(ctx context.Context, tipset *t } switch m.Method { - case miner.Methods.SubmitWindowedPoSt: + case builtin.MethodsMiner.SubmitWindowedPoSt: if !r.windowedPoStEnabled { return false, messageMethod, types.NewInt(0), nil } @@ -950,7 +954,7 @@ func (r *refunder) processTipsetStorageMinerActor(ctx context.Context, tipset *t } refundValue = types.BigMul(types.NewInt(uint64(recp.GasUsed)), tipset.Blocks()[0].ParentBaseFee) - case miner.Methods.ProveCommitSector: + case builtin.MethodsMiner.ProveCommitSector: if !r.proveCommitEnabled { return false, messageMethod, types.NewInt(0), nil } @@ -1011,7 +1015,7 @@ func (r *refunder) processTipsetStorageMinerActor(ctx context.Context, tipset *t if r.refundPercent > 0 { refundValue = types.BigMul(types.BigDiv(refundValue, types.NewInt(100)), types.NewInt(uint64(r.refundPercent))) } - case miner.Methods.PreCommitSector: + case builtin.MethodsMiner.PreCommitSector: if !r.preCommitEnabled { return false, messageMethod, types.NewInt(0), nil } @@ -1033,7 +1037,7 @@ func (r *refunder) processTipsetStorageMinerActor(ctx context.Context, tipset *t return false, messageMethod, types.NewInt(0), nil } - var precommitInfo miner.SectorPreCommitInfo + var precommitInfo minertypes.SectorPreCommitInfo if err := precommitInfo.UnmarshalCBOR(bytes.NewBuffer(m.Params)); err != nil { log.Warnw("failed to decode precommit params", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To) return false, messageMethod, types.NewInt(0), nil @@ -1098,7 +1102,7 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu processed, messageMethod, refundValue, err = r.processTipsetStorageMarketActor(ctx, tipset, msg, recps[i]) } - if builtin.IsStorageMinerActor(a.Code) { + if lbuiltin.IsStorageMinerActor(a.Code) { processed, messageMethod, refundValue, err = r.processTipsetStorageMinerActor(ctx, tipset, msg, recps[i]) } diff --git a/cmd/lotus-seed/genesis.go b/cmd/lotus-seed/genesis.go index 89feec33a..61a4d2813 100644 --- a/cmd/lotus-seed/genesis.go +++ b/cmd/lotus-seed/genesis.go @@ -15,6 +15,8 @@ import ( "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/journal" + "github.com/filecoin-project/lotus/node/bundle" + "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/testing" "github.com/google/uuid" "github.com/mitchellh/go-homedir" @@ -59,7 +61,7 @@ var genesisNewCmd = &cli.Command{ return xerrors.New("seed genesis new [genesis.json]") } out := genesis.Template{ - NetworkVersion: build.NewestNetworkVersion, + NetworkVersion: build.GenesisNetworkVersion, Accounts: []genesis.Actor{}, Miners: []genesis.Miner{}, VerifregRootKey: gen.DefaultVerifregRootkeyActor, @@ -577,7 +579,13 @@ var genesisCarCmd = &cli.Command{ jrnl := journal.NilJournal() bstor := blockstore.WrapIDStore(blockstore.NewMemorySync()) sbldr := vm.Syscalls(ffiwrapper.ProofVerifier) - _, err := testing.MakeGenesis(ofile, c.Args().First())(bstor, sbldr, jrnl)() + + // load appropriate bundles + if err := bundle.FetchAndLoadBundles(c.Context, bstor, build.BuiltinActorReleases); err != nil { + return err + } + + _, err := testing.MakeGenesis(ofile, c.Args().First())(bstor, sbldr, jrnl, dtypes.BuiltinActorsLoaded{})() return err }, } diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index 317f2965f..ce8b87df9 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -97,7 +97,7 @@ var preSealCmd = &cli.Command{ &cli.UintFlag{ Name: "network-version", Usage: "specify network version", - Value: uint(build.NewestNetworkVersion), + Value: uint(build.GenesisNetworkVersion), }, }, Action: func(c *cli.Context) error { @@ -134,7 +134,7 @@ var preSealCmd = &cli.Command{ } sectorSize := abi.SectorSize(sectorSizeInt) - nv := build.NewestNetworkVersion + nv := build.GenesisNetworkVersion if c.IsSet("network-version") { nv = network.Version(c.Uint64("network-version")) } diff --git a/cmd/lotus-seed/seed/seed.go b/cmd/lotus-seed/seed/seed.go index 3fbe66556..55411713e 100644 --- a/cmd/lotus-seed/seed/seed.go +++ b/cmd/lotus-seed/seed/seed.go @@ -24,7 +24,7 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-storage/storage" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/wallet" @@ -252,12 +252,17 @@ func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner, func createDeals(m *genesis.Miner, k *wallet.Key, maddr address.Address, ssize abi.SectorSize) error { for i, sector := range m.Sectors { - proposal := &market2.DealProposal{ + label, err := market8.NewLabelFromString(fmt.Sprintf("%d", i)) + if err != nil { + return xerrors.Errorf("error creating deal label: %w", err) + } + + proposal := &market8.DealProposal{ PieceCID: sector.CommD, PieceSize: abi.PaddedPieceSize(ssize), Client: k.Address, Provider: maddr, - Label: fmt.Sprintf("%d", i), + Label: label, StartEpoch: 0, EndEpoch: 9001, StoragePricePerEpoch: big.Zero(), @@ -265,6 +270,7 @@ func createDeals(m *genesis.Miner, k *wallet.Key, maddr address.Address, ssize a ClientCollateral: big.Zero(), } + sector.DealClientKey = k sector.Deal = *proposal } diff --git a/cmd/lotus-shed/actor.go b/cmd/lotus-shed/actor.go index 7ddc79b18..4a63a1ac5 100644 --- a/cmd/lotus-shed/actor.go +++ b/cmd/lotus-shed/actor.go @@ -5,6 +5,7 @@ import ( "fmt" "os" + "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/network" "github.com/fatih/color" @@ -20,7 +21,6 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/lib/tablewriter" @@ -119,7 +119,7 @@ var actorWithdrawCmd = &cli.Command{ To: maddr, From: mi.Owner, Value: types.NewInt(0), - Method: miner.Methods.WithdrawBalance, + Method: builtin.MethodsMiner.WithdrawBalance, Params: params, }, &api.MessageSendSpec{MaxFee: abi.TokenAmount(types.MustParseFIL("0.1"))}) if err != nil { @@ -253,7 +253,7 @@ var actorSetOwnerCmd = &cli.Command{ smsg, err := nodeAPI.MpoolPushMessage(ctx, &types.Message{ From: fromAddrId, To: maddr, - Method: miner.Methods.ChangeOwnerAddress, + Method: builtin.MethodsMiner.ChangeOwnerAddress, Value: big.Zero(), Params: sp, }, nil) @@ -513,7 +513,7 @@ var actorControlSet = &cli.Command{ smsg, err := nodeAPI.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.ChangeWorkerAddress, + Method: builtin.MethodsMiner.ChangeWorkerAddress, Value: big.Zero(), Params: sp, @@ -621,7 +621,7 @@ var actorProposeChangeWorker = &cli.Command{ smsg, err := nodeAPI.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.ChangeWorkerAddress, + Method: builtin.MethodsMiner.ChangeWorkerAddress, Value: big.Zero(), Params: sp, }, nil) @@ -743,7 +743,7 @@ var actorConfirmChangeWorker = &cli.Command{ smsg, err := nodeAPI.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.ConfirmUpdateWorkerKey, + Method: builtin.MethodsMiner.ConfirmUpdateWorkerKey, Value: big.Zero(), }, nil) if err != nil { diff --git a/cmd/lotus-shed/cid.go b/cmd/lotus-shed/cid.go index 09f3d6e6f..f98206a56 100644 --- a/cmd/lotus-shed/cid.go +++ b/cmd/lotus-shed/cid.go @@ -4,6 +4,10 @@ import ( "encoding/base64" "encoding/hex" "fmt" + "os" + + "github.com/filecoin-project/lotus/blockstore" + "github.com/ipld/go-car" "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" @@ -17,6 +21,7 @@ var cidCmd = &cli.Command{ Usage: "Cid command", Subcommands: cli.Commands{ cidIdCmd, + cidFromCarCmd, }, } @@ -83,3 +88,31 @@ var cidIdCmd = &cli.Command{ return nil }, } + +var cidFromCarCmd = &cli.Command{ + Name: "manifest-cid-from-car", + Usage: "Get the manifest CID from a car file", + ArgsUsage: "[path]", + Action: func(cctx *cli.Context) error { + ctx := cctx.Context + + cf := cctx.Args().Get(0) + f, err := os.OpenFile(cf, os.O_RDONLY, 0664) + if err != nil { + return xerrors.Errorf("opening the car file: %w", err) + } + + bs := blockstore.NewMemory() + + hdr, err := car.LoadCar(ctx, bs, f) + if err != nil { + return xerrors.Errorf("error loading car file: %w", err) + } + + manifestCid := hdr.Roots[0] + + fmt.Printf("Manifest CID: %s\n", manifestCid.String()) + + return nil + }, +} diff --git a/cmd/lotus-shed/deal-label.go b/cmd/lotus-shed/deal-label.go index 483415987..6c222a4b8 100644 --- a/cmd/lotus-shed/deal-label.go +++ b/cmd/lotus-shed/deal-label.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "unicode/utf8" "github.com/filecoin-project/lotus/chain/actors/builtin/market" @@ -99,7 +98,7 @@ var dealLabelCmd = &cli.Command{ var deals []abi.DealID if err = ps.ForEach(func(id abi.DealID, dp market.DealProposal) error { - if !utf8.Valid([]byte(dp.Label)) { + if dp.Label.IsBytes() { deals = append(deals, id) } diff --git a/cmd/lotus-shed/hello.go b/cmd/lotus-shed/hello.go new file mode 100644 index 000000000..e3a3756a9 --- /dev/null +++ b/cmd/lotus-shed/hello.go @@ -0,0 +1,63 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "time" + + cborutil "github.com/filecoin-project/go-cbor-util" + lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/node/hello" + "github.com/libp2p/go-libp2p" + inet "github.com/libp2p/go-libp2p-core/network" + "github.com/urfave/cli/v2" +) + +var resultCh chan bool + +var helloCmd = &cli.Command{ + Name: "hello", + Description: "Get remote peer hello message by multiaddr", + ArgsUsage: "[peerMultiaddr|minerActorAddress]", + Action: func(cctx *cli.Context) error { + ctx := lcli.ReqContext(cctx) + resultCh = make(chan bool, 1) + pis, err := lcli.AddrInfoFromArg(ctx, cctx) + if err != nil { + return err + } + h, err := libp2p.New() + if err != nil { + return err + } + h.SetStreamHandler(hello.ProtocolID, HandleStream) + err = h.Connect(ctx, pis[0]) + if err != nil { + return err + } + ctx, done := context.WithTimeout(ctx, 5*time.Second) + defer done() + select { + case <-resultCh: + case <-ctx.Done(): + fmt.Println("can't get hello message, please try again") + } + return nil + }, +} + +func HandleStream(s inet.Stream) { + var hmsg hello.HelloMessage + if err := cborutil.ReadCborRPC(s, &hmsg); err != nil { + log.Infow("failed to read hello message, disconnecting", "error", err) + _ = s.Conn().Close() + return + } + data, err := json.Marshal(hmsg) + if err != nil { + return + } + fmt.Println(string(data)) + resultCh <- true +} diff --git a/cmd/lotus-shed/main.go b/cmd/lotus-shed/main.go index cfbc73a14..f99454e0a 100644 --- a/cmd/lotus-shed/main.go +++ b/cmd/lotus-shed/main.go @@ -39,6 +39,7 @@ func main() { marketCmd, miscCmd, mpoolCmd, + helloCmd, genesisVerifyCmd, mathCmd, minerCmd, diff --git a/cmd/lotus-shed/market.go b/cmd/lotus-shed/market.go index aaef4690e..4cd018628 100644 --- a/cmd/lotus-shed/market.go +++ b/cmd/lotus-shed/market.go @@ -6,6 +6,8 @@ import ( "os" "path" + "github.com/filecoin-project/lotus/chain/actors/builtin/market" + levelds "github.com/ipfs/go-ds-leveldb" ldbopts "github.com/syndtr/goleveldb/leveldb/opt" @@ -82,7 +84,7 @@ var marketDealFeesCmd = &cli.Command{ for _, deal := range deals { if deal.Proposal.Provider == p { - e, p := deal.Proposal.GetDealFees(ht) + e, p := market.GetDealFees(deal.Proposal, ht) ef = big.Add(ef, e) pf = big.Add(pf, p) count++ @@ -103,7 +105,7 @@ var marketDealFeesCmd = &cli.Command{ return err } - ef, pf := deal.Proposal.GetDealFees(ht) + ef, pf := market.GetDealFees(deal.Proposal, ht) fmt.Println("Earned fees: ", ef) fmt.Println("Pending fees: ", pf) diff --git a/cmd/lotus-shed/mempool-stats.go b/cmd/lotus-shed/mempool-stats.go index 597ba0393..5a98f6965 100644 --- a/cmd/lotus-shed/mempool-stats.go +++ b/cmd/lotus-shed/mempool-stats.go @@ -6,6 +6,9 @@ import ( "sort" "time" + "github.com/filecoin-project/go-state-types/builtin" + lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" + "contrib.go.opencensus.io/exporter/prometheus" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" @@ -16,8 +19,6 @@ import ( "github.com/filecoin-project/go-address" lapi "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" ) @@ -122,7 +123,7 @@ var mpoolStatsCmd = &cli.Command{ return false, err } - ism := builtin.IsStorageMinerActor(act.Code) + ism := lbuiltin.IsStorageMinerActor(act.Code) mcache[addr] = ism return ism, nil } @@ -144,7 +145,7 @@ var mpoolStatsCmd = &cli.Command{ seen: time.Now(), } - if u.Message.Message.Method == miner.Methods.SubmitWindowedPoSt { + if u.Message.Message.Method == builtin.MethodsMiner.SubmitWindowedPoSt { miner, err := isMiner(u.Message.Message.To) if err != nil { diff --git a/cmd/lotus-shed/miner-multisig.go b/cmd/lotus-shed/miner-multisig.go index 712e45ee7..dd36a7a7d 100644 --- a/cmd/lotus-shed/miner-multisig.go +++ b/cmd/lotus-shed/miner-multisig.go @@ -5,6 +5,8 @@ import ( "fmt" "strconv" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/abi" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" @@ -16,7 +18,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/urfave/cli/v2" @@ -88,7 +89,7 @@ var mmProposeWithdrawBalance = &cli.Command{ return err } - pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(miner.Methods.WithdrawBalance), sp) + pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.WithdrawBalance), sp) if err != nil { return xerrors.Errorf("proposing message: %w", err) } @@ -167,7 +168,7 @@ var mmApproveWithdrawBalance = &cli.Command{ return err } - acid, err := api.MsigApproveTxnHash(ctx, multisigAddr, txid, proposer, minerAddr, big.Zero(), sender, uint64(miner.Methods.WithdrawBalance), sp) + acid, err := api.MsigApproveTxnHash(ctx, multisigAddr, txid, proposer, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.WithdrawBalance), sp) if err != nil { return xerrors.Errorf("approving message: %w", err) } @@ -248,7 +249,7 @@ var mmProposeChangeOwner = &cli.Command{ return xerrors.Errorf("serializing params: %w", err) } - pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(miner.Methods.ChangeOwnerAddress), sp) + pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.ChangeOwnerAddress), sp) if err != nil { return xerrors.Errorf("proposing message: %w", err) } @@ -338,7 +339,7 @@ var mmApproveChangeOwner = &cli.Command{ return xerrors.Errorf("serializing params: %w", err) } - acid, err := api.MsigApproveTxnHash(ctx, multisigAddr, txid, proposer, minerAddr, big.Zero(), sender, uint64(miner.Methods.ChangeOwnerAddress), sp) + acid, err := api.MsigApproveTxnHash(ctx, multisigAddr, txid, proposer, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.ChangeOwnerAddress), sp) if err != nil { return xerrors.Errorf("approving message: %w", err) } @@ -435,7 +436,7 @@ var mmProposeChangeWorker = &cli.Command{ return xerrors.Errorf("serializing params: %w", err) } - pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(miner.Methods.ChangeWorkerAddress), sp) + pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.ChangeWorkerAddress), sp) if err != nil { return xerrors.Errorf("proposing message: %w", err) } @@ -519,7 +520,7 @@ var mmConfirmChangeWorker = &cli.Command{ return xerrors.Errorf("worker key change cannot be confirmed until %d, current height is %d", mi.WorkerChangeEpoch, head.Height()) } - pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(miner.Methods.ConfirmUpdateWorkerKey), nil) + pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.ConfirmUpdateWorkerKey), nil) if err != nil { return xerrors.Errorf("proposing message: %w", err) } @@ -634,7 +635,7 @@ var mmProposeControlSet = &cli.Command{ return xerrors.Errorf("serializing params: %w", err) } - pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(miner.Methods.ChangeWorkerAddress), sp) + pcid, err := api.MsigPropose(ctx, multisigAddr, minerAddr, big.Zero(), sender, uint64(builtin.MethodsMiner.ChangeWorkerAddress), sp) if err != nil { return xerrors.Errorf("proposing message: %w", err) } diff --git a/cmd/lotus-shed/miner-peerid.go b/cmd/lotus-shed/miner-peerid.go index 3ccfb429b..5218bbe26 100644 --- a/cmd/lotus-shed/miner-peerid.go +++ b/cmd/lotus-shed/miner-peerid.go @@ -102,7 +102,7 @@ var minerPeeridCmd = &cli.Command{ return err } - if mi.PeerId != nil && *mi.PeerId == pid { + if mi.PeerId != nil && peer.ID(mi.PeerId) == pid { fmt.Println(addr) } } diff --git a/cmd/lotus-shed/miner.go b/cmd/lotus-shed/miner.go index c44b67d77..e961a4b30 100644 --- a/cmd/lotus-shed/miner.go +++ b/cmd/lotus-shed/miner.go @@ -9,15 +9,20 @@ import ( "path/filepath" "strings" - miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - - power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power" - - "github.com/docker/go-units" - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/big" + "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-bitfield" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin" + miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/crypto" + power7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power" + "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + + "github.com/docker/go-units" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -37,6 +42,8 @@ var minerCmd = &cli.Command{ minerUnpackInfoCmd, minerCreateCmd, minerFaultsCmd, + sendInvalidWindowPoStCmd, + generateAndSendConsensusFaultCmd, }, } @@ -75,7 +82,7 @@ var minerFaultsCmd = &cli.Command{ return err } - faults, err := faultBf.All(miner2.SectorsMax) + faults, err := faultBf.All(abi.MaxSectorNumber) if err != nil { return err } @@ -216,7 +223,7 @@ var minerCreateCmd = &cli.Command{ return xerrors.Errorf("getting post proof type: %w", err) } - params, err := actors.SerializeParams(&power6.CreateMinerParams{ + params, err := actors.SerializeParams(&power7.CreateMinerParams{ Owner: owner, Worker: worker, WindowPoStProofType: spt, @@ -252,7 +259,7 @@ var minerCreateCmd = &cli.Command{ return xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode) } - var retval power6.CreateMinerReturn + var retval power7.CreateMinerReturn if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil { return err } @@ -354,3 +361,226 @@ var minerUnpackInfoCmd = &cli.Command{ } }, } + +var sendInvalidWindowPoStCmd = &cli.Command{ + Name: "send-invalid-windowed-post", + Usage: "Sends an invalid windowed post for a specific deadline", + Description: `Note: This is meant for testing purposes and should NOT be used on mainnet or you will be slashed`, + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "really-do-it", + Usage: "Actually send transaction performing the action", + Value: false, + }, + &cli.Int64SliceFlag{ + Name: "partitions", + Usage: "list of partitions to submit invalid post for", + Required: true, + }, + &cli.StringFlag{ + Name: "actor", + Usage: "Specify the address of the miner to run this command", + }, + }, + Action: func(cctx *cli.Context) error { + if !cctx.Bool("really-do-it") { + return xerrors.Errorf("Pass --really-do-it to actually execute this action") + } + + api, acloser, err := lcli.GetFullNodeAPI(cctx) + if err != nil { + return xerrors.Errorf("getting api: %w", err) + } + defer acloser() + + ctx := lcli.ReqContext(cctx) + + maddr, err := address.NewFromString(cctx.String("actor")) + if err != nil { + return xerrors.Errorf("getting actor address: %w", err) + } + + minfo, err := api.StateMinerInfo(ctx, maddr, types.EmptyTSK) + if err != nil { + return xerrors.Errorf("getting mienr info: %w", err) + } + + deadline, err := api.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK) + if err != nil { + return xerrors.Errorf("getting deadline: %w", err) + } + + partitionIndices := cctx.Int64Slice("partitions") + if len(partitionIndices) <= 0 { + return fmt.Errorf("must include at least one partition to compact") + } + + chainHead, err := api.ChainHead(ctx) + if err != nil { + return xerrors.Errorf("getting chain head: %w", err) + } + + checkRand, err := api.StateGetRandomnessFromTickets(ctx, crypto.DomainSeparationTag_PoStChainCommit, deadline.Challenge, nil, chainHead.Key()) + if err != nil { + return xerrors.Errorf("getting randomness: %w", err) + } + + proofSize, err := minfo.WindowPoStProofType.ProofSize() + if err != nil { + return xerrors.Errorf("getting proof size: %w", err) + } + + var partitions []miner8.PoStPartition + + emptyProof := []proof.PoStProof{{ + PoStProof: minfo.WindowPoStProofType, + ProofBytes: make([]byte, proofSize)}} + + for _, partition := range partitionIndices { + newPartition := miner8.PoStPartition{ + Index: uint64(partition), + Skipped: bitfield.New(), + } + partitions = append(partitions, newPartition) + } + + params := miner8.SubmitWindowedPoStParams{ + Deadline: deadline.Index, + Partitions: partitions, + Proofs: emptyProof, + ChainCommitEpoch: deadline.Challenge, + ChainCommitRand: checkRand, + } + + sp, err := actors.SerializeParams(¶ms) + if err != nil { + return xerrors.Errorf("serializing params: %w", err) + } + + fmt.Printf("submitting bad PoST for %d paritions\n", len(partitionIndices)) + smsg, err := api.MpoolPushMessage(ctx, &types.Message{ + From: minfo.Worker, + To: maddr, + Method: builtin.MethodsMiner.SubmitWindowedPoSt, + Value: big.Zero(), + Params: sp, + }, nil) + if err != nil { + return xerrors.Errorf("mpool push: %w", err) + } + + fmt.Printf("Invalid PoST in message %s\n", smsg.Cid()) + + wait, err := api.StateWaitMsg(ctx, smsg.Cid(), 0) + if err != nil { + return err + } + + // check it executed successfully + if wait.Receipt.ExitCode != 0 { + fmt.Println(cctx.App.Writer, "Invalid PoST message failed!") + return err + } + + return nil + }, +} + +var generateAndSendConsensusFaultCmd = &cli.Command{ + Name: "generate-and-send-consensus-fault", + Usage: "Provided a block CID mined by the miner, will create another block at the same height, and send both block headers to generate a consensus fault.", + Description: `Note: This is meant for testing purposes and should NOT be used on mainnet or you will be slashed`, + Action: func(cctx *cli.Context) error { + if cctx.NArg() != 1 { + return xerrors.Errorf("expected 1 arg (blockCID)") + } + + blockCid, err := cid.Parse(cctx.Args().First()) + if err != nil { + return xerrors.Errorf("getting first arg: %w", err) + } + + api, acloser, err := lcli.GetFullNodeAPI(cctx) + if err != nil { + return xerrors.Errorf("getting chain head: %w", err) + } + defer acloser() + + ctx := lcli.ReqContext(cctx) + + blockHeader, err := api.ChainGetBlock(ctx, blockCid) + if err != nil { + return xerrors.Errorf("getting block header: %w", err) + } + + maddr := blockHeader.Miner + + minfo, err := api.StateMinerInfo(ctx, maddr, types.EmptyTSK) + if err != nil { + return xerrors.Errorf("getting miner info: %w", err) + } + + // We are changing one field in the block header, then resigning the new block. + // This gives two different blocks signed by the same miner at the same height which will result in a consensus fault. + blockHeaderCopy := *blockHeader + blockHeaderCopy.ForkSignaling = blockHeader.ForkSignaling + 1 + + signingBytes, err := blockHeaderCopy.SigningBytes() + if err != nil { + return xerrors.Errorf("getting bytes to sign second block: %w", err) + } + + sig, err := api.WalletSign(ctx, minfo.Worker, signingBytes) + if err != nil { + return xerrors.Errorf("signing second block: %w", err) + } + blockHeaderCopy.BlockSig = sig + + buf1 := new(bytes.Buffer) + err = blockHeader.MarshalCBOR(buf1) + if err != nil { + return xerrors.Errorf("marshalling block header 1: %w", err) + } + buf2 := new(bytes.Buffer) + err = blockHeaderCopy.MarshalCBOR(buf2) + if err != nil { + return xerrors.Errorf("marshalling block header 2: %w", err) + } + + params := miner8.ReportConsensusFaultParams{ + BlockHeader1: buf1.Bytes(), + BlockHeader2: buf2.Bytes(), + } + + sp, err := actors.SerializeParams(¶ms) + if err != nil { + return xerrors.Errorf("serializing params: %w", err) + } + + smsg, err := api.MpoolPushMessage(ctx, &types.Message{ + From: minfo.Worker, + To: maddr, + Method: builtin.MethodsMiner.ReportConsensusFault, + Value: big.Zero(), + Params: sp, + }, nil) + if err != nil { + return xerrors.Errorf("mpool push: %w", err) + } + + fmt.Printf("Consensus fault reported in message %s\n", smsg.Cid()) + + wait, err := api.StateWaitMsg(ctx, smsg.Cid(), 0) + if err != nil { + return err + } + + // check it executed successfully + if wait.Receipt.ExitCode != 0 { + fmt.Println(cctx.App.Writer, "Report consensus fault failed!") + return err + } + + return nil + }, +} diff --git a/cmd/lotus-shed/proofs.go b/cmd/lotus-shed/proofs.go index e75aeed14..13fdf008a 100644 --- a/cmd/lotus-shed/proofs.go +++ b/cmd/lotus-shed/proofs.go @@ -4,7 +4,7 @@ import ( "encoding/hex" "fmt" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" + prooftypes "github.com/filecoin-project/go-state-types/proof" "github.com/urfave/cli/v2" @@ -84,7 +84,7 @@ var verifySealProofCmd = &cli.Command{ snum := abi.SectorNumber(cctx.Uint64("sector-id")) - ok, err := ffi.VerifySeal(proof2.SealVerifyInfo{ + ok, err := ffi.VerifySeal(prooftypes.SealVerifyInfo{ SectorID: abi.SectorID{ Miner: abi.ActorID(mid), Number: snum, @@ -93,8 +93,8 @@ var verifySealProofCmd = &cli.Command{ SealProof: abi.RegisteredSealProof(cctx.Int64("proof-type")), Proof: proof, DealIDs: nil, - Randomness: abi.SealRandomness(ticket), - InteractiveRandomness: abi.InteractiveSealRandomness(proofRand), + Randomness: ticket, + InteractiveRandomness: proofRand, UnsealedCID: commd, }) if err != nil { diff --git a/cmd/lotus-shed/sectors.go b/cmd/lotus-shed/sectors.go index 4894a6eea..91fa67d32 100644 --- a/cmd/lotus-shed/sectors.go +++ b/cmd/lotus-shed/sectors.go @@ -21,6 +21,7 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin" "github.com/ipfs/go-cid" "github.com/urfave/cli/v2" @@ -28,7 +29,6 @@ import ( "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/lib/parmap" @@ -141,7 +141,7 @@ var terminateSectorCmd = &cli.Command{ smsg, err := nodeApi.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.TerminateSectors, + Method: builtin.MethodsMiner.TerminateSectors, Value: big.Zero(), Params: sp, @@ -262,7 +262,7 @@ var terminateSectorPenaltyEstimationCmd = &cli.Command{ msg := &types.Message{ From: mi.Owner, To: maddr, - Method: miner.Methods.TerminateSectors, + Method: builtin.MethodsMiner.TerminateSectors, Value: big.Zero(), Params: sp, diff --git a/cmd/lotus-shed/terminations.go b/cmd/lotus-shed/terminations.go index 0691f35da..357e7809e 100644 --- a/cmd/lotus-shed/terminations.go +++ b/cmd/lotus-shed/terminations.go @@ -7,7 +7,8 @@ import ( "io" "strconv" - "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/go-state-types/builtin" + lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/chain/types" @@ -111,7 +112,7 @@ var terminationsCmd = &cli.Command{ for _, v := range msgs { msg := v.VMMessage() - if msg.Method != miner.Methods.TerminateSectors { + if msg.Method != builtin.MethodsMiner.TerminateSectors { continue } @@ -125,7 +126,7 @@ var terminationsCmd = &cli.Command{ return err } - if !builtin.IsStorageMinerActor(minerAct.Code) { + if !lbuiltin.IsStorageMinerActor(minerAct.Code) { continue } @@ -167,8 +168,16 @@ var terminationsCmd = &cli.Command{ if err != nil { return err } + label, err := prop.Label.ToString() + if err != nil { + labelBs, err := prop.Label.ToBytes() + if err != nil { + return err + } + label = string(labelBs) + } if find { - fmt.Printf("%s, %d, %d, %s, %s, %s\n", msg.To, sector.SectorNumber, deal, prop.Client, prop.PieceCID, prop.Label) + fmt.Printf("%s, %d, %d, %s, %s, %s\n", msg.To, sector.SectorNumber, deal, prop.Client, prop.PieceCID, label) } } } diff --git a/cmd/lotus-shed/verifreg.go b/cmd/lotus-shed/verifreg.go index 7725b2f1b..ebd6df407 100644 --- a/cmd/lotus-shed/verifreg.go +++ b/cmd/lotus-shed/verifreg.go @@ -4,6 +4,8 @@ import ( "encoding/hex" "fmt" + verifregtypes "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" + "github.com/filecoin-project/lotus/chain/actors/builtin/multisig" "github.com/filecoin-project/go-state-types/crypto" @@ -479,14 +481,14 @@ var verifRegRemoveVerifiedClientDataCapCmd = &cli.Command{ return xerrors.Errorf("couldn't unmarshal sig: %w", err) } - params, err := actors.SerializeParams(&verifreg.RemoveDataCapParams{ + params, err := actors.SerializeParams(&verifregtypes.RemoveDataCapParams{ VerifiedClientToRemove: client, DataCapAmountToRemove: allowanceToRemove, - VerifierRequest1: verifreg.RemoveDataCapRequest{ + VerifierRequest1: verifregtypes.RemoveDataCapRequest{ Verifier: verifier1Addr, VerifierSignature: sig1, }, - VerifierRequest2: verifreg.RemoveDataCapRequest{ + VerifierRequest2: verifregtypes.RemoveDataCapRequest{ Verifier: verifier2Addr, VerifierSignature: sig2, }, diff --git a/cmd/lotus-sim/info_commit.go b/cmd/lotus-sim/info_commit.go index 7a0daa332..d58106f33 100644 --- a/cmd/lotus-sim/info_commit.go +++ b/cmd/lotus-sim/info_commit.go @@ -6,12 +6,14 @@ import ( "os" "syscall" + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/ipfs/go-cid" "github.com/koalacxr/quantile" "github.com/urfave/cli/v2" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/cmd/lotus-sim/simulation" @@ -85,8 +87,8 @@ var infoCommitGasSimCommand = &cli.Command{ if m.ExitCode != exitcode.Ok { continue } - if m.Method == miner.Methods.ProveCommitAggregate { - param := miner.ProveCommitAggregateParams{} + if m.Method == builtin.MethodsMiner.ProveCommitAggregate { + param := minertypes.ProveCommitAggregateParams{} err := param.UnmarshalCBOR(bytes.NewReader(m.Params)) if err != nil { log("failed to decode params: %+v", err) @@ -109,7 +111,7 @@ var infoCommitGasSimCommand = &cli.Command{ hist.Observe(float64(c)) } - if m.Method == miner.Methods.ProveCommitSector { + if m.Method == builtin.MethodsMiner.ProveCommitSector { gasSingle += uint64(m.GasUsed) proofsSingle++ qua.Add(1) diff --git a/cmd/lotus-sim/info_wdpost.go b/cmd/lotus-sim/info_wdpost.go index 719a133b1..37383c4fc 100644 --- a/cmd/lotus-sim/info_wdpost.go +++ b/cmd/lotus-sim/info_wdpost.go @@ -3,13 +3,13 @@ package main import ( "fmt" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/ipfs/go-cid" "github.com/urfave/cli/v2" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/cmd/lotus-sim/simulation" @@ -48,7 +48,7 @@ var infoWindowPostBandwidthSimCommand = &cli.Command{ if m.ExitCode != exitcode.Ok { continue } - if m.Method == miner.Methods.SubmitWindowedPoSt { + if m.Method == builtin.MethodsMiner.SubmitWindowedPoSt { postGas += m.GasUsed } } diff --git a/cmd/lotus-sim/simulation/mock/mock.go b/cmd/lotus-sim/simulation/mock/mock.go index b1d36ba48..5479cbec7 100644 --- a/cmd/lotus-sim/simulation/mock/mock.go +++ b/cmd/lotus-sim/simulation/mock/mock.go @@ -6,7 +6,7 @@ import ( "encoding/binary" "fmt" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + prooftypes "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" @@ -14,7 +14,6 @@ import ( logging "github.com/ipfs/go-log/v2" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" tutils "github.com/filecoin-project/specs-actors/v5/support/testing" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" @@ -36,7 +35,7 @@ type mockVerifier struct{} var Verifier ffiwrapper.Verifier = mockVerifier{} -func (mockVerifier) VerifySeal(proof proof5.SealVerifyInfo) (bool, error) { +func (mockVerifier) VerifySeal(proof prooftypes.SealVerifyInfo) (bool, error) { addr, err := address.NewIDAddress(uint64(proof.Miner)) if err != nil { return false, err @@ -52,7 +51,7 @@ func (mockVerifier) VerifySeal(proof proof5.SealVerifyInfo) (bool, error) { return false, nil } -func (mockVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) { +func (mockVerifier) VerifyAggregateSeals(aggregate prooftypes.AggregateSealVerifyProofAndInfos) (bool, error) { addr, err := address.NewIDAddress(uint64(aggregate.Miner)) if err != nil { return false, err @@ -74,14 +73,14 @@ func (mockVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyPro } // TODO: do the thing -func (mockVerifier) VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) (bool, error) { +func (mockVerifier) VerifyReplicaUpdate(update prooftypes.ReplicaUpdateInfo) (bool, error) { return false, nil } -func (mockVerifier) VerifyWinningPoSt(ctx context.Context, info proof7.WinningPoStVerifyInfo) (bool, error) { +func (mockVerifier) VerifyWinningPoSt(ctx context.Context, info prooftypes.WinningPoStVerifyInfo) (bool, error) { panic("should not be called") } -func (mockVerifier) VerifyWindowPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) (bool, error) { +func (mockVerifier) VerifyWindowPoSt(ctx context.Context, info prooftypes.WindowPoStVerifyInfo) (bool, error) { if len(info.Proofs) != 1 { return false, fmt.Errorf("expected exactly one proof") } diff --git a/cmd/lotus-sim/simulation/stages/commit_queue.go b/cmd/lotus-sim/simulation/stages/commit_queue.go index d625dedb6..1c689c32e 100644 --- a/cmd/lotus-sim/simulation/stages/commit_queue.go +++ b/cmd/lotus-sim/simulation/stages/commit_queue.go @@ -3,10 +3,11 @@ package stages import ( "sort" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -166,7 +167,7 @@ func (q *commitQueue) advanceEpoch(epoch abi.ChainEpoch) { } // enquueProveCommit enqueues prove-commit for the given pre-commit for the given miner. -func (q *commitQueue) enqueueProveCommit(addr address.Address, preCommitEpoch abi.ChainEpoch, info miner.SectorPreCommitInfo) error { +func (q *commitQueue) enqueueProveCommit(addr address.Address, preCommitEpoch abi.ChainEpoch, info minertypes.SectorPreCommitInfo) error { // Compute the epoch at which we can start trying to commit. preCommitDelay := policy.GetPreCommitChallengeDelay() minCommitEpoch := preCommitEpoch + preCommitDelay + 1 diff --git a/cmd/lotus-sim/simulation/stages/commit_queue_test.go b/cmd/lotus-sim/simulation/stages/commit_queue_test.go index 503228d38..589f8b201 100644 --- a/cmd/lotus-sim/simulation/stages/commit_queue_test.go +++ b/cmd/lotus-sim/simulation/stages/commit_queue_test.go @@ -4,12 +4,13 @@ package stages import ( "testing" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/stretchr/testify/require" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -19,31 +20,31 @@ func TestCommitQueue(t *testing.T) { addr1, err := address.NewIDAddress(1000) require.NoError(t, err) proofType := abi.RegisteredSealProof_StackedDrg64GiBV1_1 - require.NoError(t, q.enqueueProveCommit(addr1, 0, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 0, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 0, })) - require.NoError(t, q.enqueueProveCommit(addr1, 0, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 0, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 1, })) - require.NoError(t, q.enqueueProveCommit(addr1, 1, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 1, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 2, })) - require.NoError(t, q.enqueueProveCommit(addr1, 1, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 1, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 3, })) - require.NoError(t, q.enqueueProveCommit(addr1, 3, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 3, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 4, })) - require.NoError(t, q.enqueueProveCommit(addr1, 4, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 4, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 5, })) - require.NoError(t, q.enqueueProveCommit(addr1, 6, miner.SectorPreCommitInfo{ + require.NoError(t, q.enqueueProveCommit(addr1, 6, minertypes.SectorPreCommitInfo{ SealProof: proofType, SectorNumber: 6, })) diff --git a/cmd/lotus-sim/simulation/stages/interface.go b/cmd/lotus-sim/simulation/stages/interface.go index 0c40a9b23..2e3d54722 100644 --- a/cmd/lotus-sim/simulation/stages/interface.go +++ b/cmd/lotus-sim/simulation/stages/interface.go @@ -3,10 +3,11 @@ package stages import ( "context" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/cmd/lotus-sim/simulation/blockbuilder" ) @@ -23,5 +24,5 @@ type Funding interface { } type Committer interface { - EnqueueProveCommit(addr address.Address, preCommitEpoch abi.ChainEpoch, info miner.SectorPreCommitInfo) error + EnqueueProveCommit(addr address.Address, preCommitEpoch abi.ChainEpoch, info minertypes.SectorPreCommitInfo) error } diff --git a/cmd/lotus-sim/simulation/stages/precommit_stage.go b/cmd/lotus-sim/simulation/stages/precommit_stage.go index 5b9fed09e..dc5c16d0b 100644 --- a/cmd/lotus-sim/simulation/stages/precommit_stage.go +++ b/cmd/lotus-sim/simulation/stages/precommit_stage.go @@ -5,6 +5,9 @@ import ( "sort" "time" + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -176,9 +179,9 @@ func (stage *PreCommitStage) packMiner( } expiration := epoch + policy.GetMaxSectorExpirationExtension() - infos := make([]miner.SectorPreCommitInfo, len(sectorNos)) + infos := make([]minertypes.SectorPreCommitInfo, len(sectorNos)) for i, sno := range sectorNos { - infos[i] = miner.SectorPreCommitInfo{ + infos[i] = minertypes.SectorPreCommitInfo{ SealProof: sealType, SectorNumber: sno, SealedCID: mock.MockCommR(minerAddr, sno), @@ -196,7 +199,7 @@ func (stage *PreCommitStage) packMiner( if len(batch) > targetBatchSize { batch = batch[:targetBatchSize] } - params := miner5.PreCommitSectorBatchParams{ + params := minertypes.PreCommitSectorBatchParams{ Sectors: batch, } enc, err := actors.SerializeParams(¶ms) @@ -209,7 +212,7 @@ func (stage *PreCommitStage) packMiner( To: minerAddr, From: minerInfo.Worker, Value: abi.NewTokenAmount(0), - Method: miner.Methods.PreCommitSectorBatch, + Method: builtin.MethodsMiner.PreCommitSectorBatch, Params: enc, }); blockbuilder.IsOutOfGas(err) { // try again with a smaller batch. @@ -244,7 +247,7 @@ func (stage *PreCommitStage) packMiner( To: minerAddr, From: minerInfo.Worker, Value: abi.NewTokenAmount(0), - Method: miner.Methods.PreCommitSector, + Method: builtin.MethodsMiner.PreCommitSector, Params: enc, }); blockbuilder.IsOutOfGas(err) { return added, true, nil diff --git a/cmd/lotus-sim/simulation/stages/provecommit_stage.go b/cmd/lotus-sim/simulation/stages/provecommit_stage.go index 8b12fc68a..a6c14f3d0 100644 --- a/cmd/lotus-sim/simulation/stages/provecommit_stage.go +++ b/cmd/lotus-sim/simulation/stages/provecommit_stage.go @@ -4,6 +4,9 @@ import ( "context" "time" + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" @@ -48,7 +51,7 @@ func (*ProveCommitStage) Name() string { } func (stage *ProveCommitStage) EnqueueProveCommit( - minerAddr address.Address, preCommitEpoch abi.ChainEpoch, info miner.SectorPreCommitInfo, + minerAddr address.Address, preCommitEpoch abi.ChainEpoch, info minertypes.SectorPreCommitInfo, ) error { return stage.commitQueue.enqueueProveCommit(minerAddr, preCommitEpoch, info) } @@ -161,7 +164,7 @@ func (stage *ProveCommitStage) packProveCommitsMiner( From: info.Worker, To: minerAddr, Value: abi.NewTokenAmount(0), - Method: miner.Methods.ProveCommitAggregate, + Method: builtin.MethodsMiner.ProveCommitAggregate, Params: enc, }); err == nil { res.done += len(batch) @@ -237,7 +240,7 @@ func (stage *ProveCommitStage) packProveCommitsMiner( if err != nil { return res, err } - params := miner.ProveCommitSectorParams{ + params := minertypes.ProveCommitSectorParams{ SectorNumber: sno, Proof: proof, } @@ -249,7 +252,7 @@ func (stage *ProveCommitStage) packProveCommitsMiner( From: info.Worker, To: minerAddr, Value: abi.NewTokenAmount(0), - Method: miner.Methods.ProveCommitSector, + Method: builtin.MethodsMiner.ProveCommitSector, Params: enc, }); err == nil { res.unbatched++ @@ -293,7 +296,7 @@ func (stage *ProveCommitStage) loadMiner(ctx context.Context, bb *blockbuilder.B // Find all pending prove commits and group by proof type. Really, there should never // (except during upgrades be more than one type. var total, dropped int - err = minerState.ForEachPrecommittedSector(func(info miner.SectorPreCommitOnChainInfo) error { + err = minerState.ForEachPrecommittedSector(func(info minertypes.SectorPreCommitOnChainInfo) error { total++ msd, err := policy.GetMaxProveCommitDuration(av, info.Info.SealProof) if err != nil { diff --git a/cmd/lotus-sim/simulation/stages/windowpost_stage.go b/cmd/lotus-sim/simulation/stages/windowpost_stage.go index 68f8ea179..98490b9ca 100644 --- a/cmd/lotus-sim/simulation/stages/windowpost_stage.go +++ b/cmd/lotus-sim/simulation/stages/windowpost_stage.go @@ -5,13 +5,16 @@ import ( "math" "time" + prooftypes "github.com/filecoin-project/go-state-types/proof" + + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -129,8 +132,8 @@ func (stage *WindowPoStStage) queueMiner( } var ( - partitions []miner.PoStPartition - partitionGroups [][]miner.PoStPartition + partitions []minertypes.PoStPartition + partitionGroups [][]minertypes.PoStPartition ) // Only prove partitions with live sectors. err = dl.ForEachPartition(func(idx uint64, part miner.Partition) error { @@ -160,7 +163,7 @@ func (stage *WindowPoStStage) queueMiner( return err } if liveCount-faultyCount > 0 { - partitions = append(partitions, miner.PoStPartition{Index: idx}) + partitions = append(partitions, minertypes.PoStPartition{Index: idx}) } return nil }) @@ -177,10 +180,10 @@ func (stage *WindowPoStStage) queueMiner( return err } for _, group := range partitionGroups { - params := miner.SubmitWindowedPoStParams{ + params := minertypes.SubmitWindowedPoStParams{ Deadline: di.Index, Partitions: group, - Proofs: []proof5.PoStProof{{ + Proofs: []prooftypes.PoStProof{{ PoStProof: minerInfo.WindowPoStProofType, ProofBytes: proof, }}, @@ -194,7 +197,7 @@ func (stage *WindowPoStStage) queueMiner( msg := &types.Message{ To: addr, From: minerInfo.Worker, - Method: miner.Methods.SubmitWindowedPoSt, + Method: builtin.MethodsMiner.SubmitWindowedPoSt, Params: enc, Value: types.NewInt(0), } @@ -216,7 +219,7 @@ func (stage *WindowPoStStage) load(ctx context.Context, bb *blockbuilder.BlockBu }() // reset - stage.wpostPeriods = make([][]address.Address, miner.WPoStChallengeWindow) + stage.wpostPeriods = make([][]address.Address, minertypes.WPoStChallengeWindow) stage.pendingWposts = nil stage.nextWpostEpoch = bb.Height() + 1 @@ -259,7 +262,7 @@ func (stage *WindowPoStStage) load(ctx context.Context, bb *blockbuilder.BlockBu } dinfo = dinfo.NextNotElapsed() - ppOffset := int(dinfo.PeriodStart % miner.WPoStChallengeWindow) + ppOffset := int(dinfo.PeriodStart % minertypes.WPoStChallengeWindow) stage.wpostPeriods[ppOffset] = append(stage.wpostPeriods[ppOffset], minerAddr) return stage.queueMiner(ctx, bb, minerAddr, minerState, commitEpoch, commitRand) @@ -290,7 +293,7 @@ func (stage *WindowPoStStage) tick(ctx context.Context, bb *blockbuilder.BlockBu // Perform a bit of catch up. This lets us do things like skip blocks at upgrades then catch // up to make the simulation easier. for ; stage.nextWpostEpoch <= targetHeight; stage.nextWpostEpoch++ { - if stage.nextWpostEpoch+miner.WPoStChallengeWindow < targetHeight { + if stage.nextWpostEpoch+minertypes.WPoStChallengeWindow < targetHeight { bb.L().Warnw("skipping old window post", "deadline-open", stage.nextWpostEpoch) continue } @@ -300,7 +303,7 @@ func (stage *WindowPoStStage) tick(ctx context.Context, bb *blockbuilder.BlockBu return err } - for _, addr := range stage.wpostPeriods[int(stage.nextWpostEpoch%miner.WPoStChallengeWindow)] { + for _, addr := range stage.wpostPeriods[int(stage.nextWpostEpoch%minertypes.WPoStChallengeWindow)] { minerState, err := loadMiner(store, st, addr) if err != nil { return err diff --git a/cmd/tvx/extract.go b/cmd/tvx/extract.go index a3d538abd..281e469bb 100644 --- a/cmd/tvx/extract.go +++ b/cmd/tvx/extract.go @@ -13,8 +13,8 @@ import ( ) const ( - PrecursorSelectAll = "all" - PrecursorSelectSender = "sender" + PrecursorSelectAll = "all" + PrecursorSelectParticipants = "participants" ) type extractOpts struct { @@ -86,12 +86,12 @@ var extractCmd = &cli.Command{ }, &cli.StringFlag{ Name: "precursor-select", - Usage: "precursors to apply; values: 'all', 'sender'; 'all' selects all preceding " + - "messages in the canonicalised tipset, 'sender' selects only preceding messages from the same " + - "sender. Usually, 'sender' is a good tradeoff and gives you sufficient accuracy. If the receipt sanity " + + Usage: "precursors to apply; values: 'all', 'participants'; 'all' selects all preceding " + + "messages in the canonicalised tipset, 'participants' selects only preceding messages from the same " + + "participants. Usually, 'participants' is a good tradeoff and gives you sufficient accuracy. If the receipt sanity " + "check fails due to gas reasons, switch to 'all', as previous messages in the tipset may have " + "affected state in a disruptive way", - Value: "sender", + Value: "participants", Destination: &extractFlags.precursor, }, &cli.BoolFlag{ diff --git a/cmd/tvx/extract_many.go b/cmd/tvx/extract_many.go index ae196542e..3520cd2ad 100644 --- a/cmd/tvx/extract_many.go +++ b/cmd/tvx/extract_many.go @@ -13,11 +13,12 @@ import ( "github.com/fatih/color" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/exitcode" - "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/hashicorp/go-multierror" "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" "github.com/urfave/cli/v2" + + "github.com/filecoin-project/lotus/chain/consensus/filcns" ) var extractManyFlags struct { @@ -176,7 +177,7 @@ func runExtractMany(c *cli.Context) error { // Vector filename, using a base of outdir. file := filepath.Join(outdir, actorcodename, methodname, exitcodename, id) + ".json" - log.Println(color.YellowString("processing message cid with 'sender' precursor mode: %s", id)) + log.Println(color.YellowString("processing message cid with 'participants' precursor mode: %s", id)) opts := extractOpts{ id: id, @@ -185,7 +186,7 @@ func runExtractMany(c *cli.Context) error { cid: mcid, file: file, retain: "accessed-cids", - precursor: PrecursorSelectSender, + precursor: PrecursorSelectParticipants, } if err := doExtractMessage(opts); err != nil { @@ -199,7 +200,7 @@ func runExtractMany(c *cli.Context) error { generated = append(generated, file) } - log.Printf("extractions to try with canonical precursor selection mode: %d", len(retry)) + log.Printf("extractions to try with 'all' precursor selection mode: %d", len(retry)) for _, r := range retry { log.Printf("retrying %s: %s", r.cid, r.id) diff --git a/cmd/tvx/extract_message.go b/cmd/tvx/extract_message.go index 68376654a..33ae5ab8f 100644 --- a/cmd/tvx/extract_message.go +++ b/cmd/tvx/extract_message.go @@ -71,7 +71,7 @@ func doExtractMessage(opts extractOpts) error { return fmt.Errorf("failed to fetch messages in canonical order from inclusion tipset: %w", err) } - related, found, err := findMsgAndPrecursors(opts.precursor, mcid, msg.From, msgs) + related, found, err := findMsgAndPrecursors(ctx, opts.precursor, mcid, msg.From, msg.To, msgs) if err != nil { return fmt.Errorf("failed while finding message and precursors: %w", err) } @@ -114,7 +114,7 @@ func doExtractMessage(opts extractOpts) error { log.Printf("applying precursor %d, cid: %s", i, m.Cid()) _, root, err = driver.ExecuteMessage(pst.Blockstore, conformance.ExecuteMessageParams{ Preroot: root, - Epoch: execTs.Height(), + Epoch: incTs.Height(), Message: m, CircSupply: circSupplyDetail.FilCirculating, BaseFee: basefee, @@ -139,6 +139,7 @@ func doExtractMessage(opts extractOpts) error { ) log.Printf("using state retention strategy: %s", retention) + log.Printf("now applying requested message: %s", msg.Cid()) switch retention { case "accessed-cids": tbs, ok := pst.Blockstore.(TracingBlockstore) @@ -151,7 +152,7 @@ func doExtractMessage(opts extractOpts) error { preroot = root applyret, postroot, err = driver.ExecuteMessage(pst.Blockstore, conformance.ExecuteMessageParams{ Preroot: preroot, - Epoch: execTs.Height(), + Epoch: incTs.Height(), Message: msg, CircSupply: circSupplyDetail.FilCirculating, BaseFee: basefee, @@ -184,7 +185,7 @@ func doExtractMessage(opts extractOpts) error { } applyret, postroot, err = driver.ExecuteMessage(pst.Blockstore, conformance.ExecuteMessageParams{ Preroot: preroot, - Epoch: execTs.Height(), + Epoch: incTs.Height(), Message: msg, CircSupply: circSupplyDetail.FilCirculating, BaseFee: basefee, @@ -299,7 +300,7 @@ func doExtractMessage(opts extractOpts) error { CAR: out.Bytes(), Pre: &schema.Preconditions{ Variants: []schema.Variant{ - {ID: codename, Epoch: int64(execTs.Height()), NetworkVersion: uint(nv)}, + {ID: codename, Epoch: int64(incTs.Height()), NetworkVersion: uint(nv)}, }, CircSupply: circSupply.Int, BaseFee: basefee.Int, @@ -368,13 +369,13 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo // types.EmptyTSK hints to use the HEAD. execTs, err = api.ChainGetTipSetByHeight(ctx, blk.Height+1, types.EmptyTSK) if err != nil { - return nil, nil, nil, fmt.Errorf("failed to get message execution tipset: %w", err) + return nil, nil, nil, fmt.Errorf("failed to get message execution tipset (%d) : %w", blk.Height+1, err) } // walk back from the execTs instead of HEAD, to save time. incTs, err = api.ChainGetTipSetByHeight(ctx, blk.Height, execTs.Key()) if err != nil { - return nil, nil, nil, fmt.Errorf("failed to get message inclusion tipset: %w", err) + return nil, nil, nil, fmt.Errorf("failed to get message inclusion tipset (%d): %w", blk.Height, err) } return msg, execTs, incTs, nil @@ -403,19 +404,29 @@ func fetchThisAndPrevTipset(ctx context.Context, api v0api.FullNode, target type // findMsgAndPrecursors ranges through the canonical messages slice, locating // the target message and returning precursors in accordance to the supplied // mode. -func findMsgAndPrecursors(mode string, msgCid cid.Cid, sender address.Address, msgs []api.Message) (related []*types.Message, found bool, err error) { - // Range through canonicalised messages, selecting only the precursors based - // on selection mode. - for _, other := range msgs { +func findMsgAndPrecursors(ctx context.Context, mode string, msgCid cid.Cid, sender address.Address, recipient address.Address, msgs []api.Message) (related []*types.Message, found bool, err error) { + // Resolve addresses to IDs for canonicality. + senderID := mustResolveAddr(ctx, sender) + recipientID := mustResolveAddr(ctx, recipient) + + // Range through messages, selecting only the precursors based on selection mode. + for _, m := range msgs { + msgSenderID := mustResolveAddr(ctx, m.Message.From) + msgRecipientID := mustResolveAddr(ctx, m.Message.To) + switch { case mode == PrecursorSelectAll: fallthrough - case mode == PrecursorSelectSender && other.Message.From == sender: - related = append(related, other.Message) + case mode == PrecursorSelectParticipants && + msgSenderID == senderID || + msgRecipientID == recipientID || + msgSenderID == recipientID || + msgRecipientID == senderID: + related = append(related, m.Message) } // this message is the target; we're done. - if other.Cid == msgCid { + if m.Cid == msgCid { return related, true, nil } } @@ -425,3 +436,17 @@ func findMsgAndPrecursors(mode string, msgCid cid.Cid, sender address.Address, m // target). return related, false, nil } + +var addressCache = make(map[address.Address]address.Address) + +func mustResolveAddr(ctx context.Context, addr address.Address) address.Address { + if resolved, ok := addressCache[addr]; ok { + return resolved + } + id, err := FullAPI.StateLookupID(ctx, addr, types.EmptyTSK) + if err != nil { + panic(fmt.Errorf("failed to resolve addr: %w", err)) + } + addressCache[addr] = id + return id +} diff --git a/conformance/driver.go b/conformance/driver.go index f6ca9f9db..7993a15fc 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -6,8 +6,10 @@ import ( "os" "github.com/filecoin-project/go-state-types/network" + cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/lotus/blockstore" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" @@ -199,6 +201,9 @@ type ExecuteMessageParams struct { // Rand is an optional vm.Rand implementation to use. If nil, the driver // will use a vm.Rand that returns a fixed value for all calls. Rand vm.Rand + + // Lookback is the LookbackStateGetter; returns the state tree at a given epoch. + Lookback vm.LookbackStateGetter } // ExecuteMessage executes a conformance test vector message in a temporary VM. @@ -213,6 +218,17 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP params.Rand = NewFixedRand() } + // TODO: This lookback state returns the supplied precondition state tree, unconditionally. + // This is obviously not correct, but the lookback state tree is only used to validate the + // worker key when verifying a consensus fault. If the worker key hasn't changed in the + // current finality window, this workaround is enough. + // The correct solutions are documented in https://github.com/filecoin-project/ref-fvm/issues/381, + // but they're much harder to implement, and the tradeoffs aren't clear. + var lookback vm.LookbackStateGetter = func(ctx context.Context, epoch abi.ChainEpoch) (*state.StateTree, error) { + cst := cbor.NewCborStore(bs) + return state.LoadStateTree(cst, params.Preroot) + } + vmOpts := &vm.VMOpts{ StateBase: params.Preroot, Epoch: params.Epoch, @@ -224,6 +240,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP Rand: params.Rand, BaseFee: params.BaseFee, NetworkVersion: params.NetworkVersion, + LookbackState: lookback, } lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts) @@ -235,7 +252,8 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP // register the chaos actor if required by the vector. if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" { - invoker.Register(nil, chaos.Actor{}) + av, _ := actors.VersionForNetwork(params.NetworkVersion) + invoker.Register(av, nil, chaos.Actor{}) } lvm.SetInvoker(invoker) diff --git a/documentation/en/api-v0-methods-miner.md b/documentation/en/api-v0-methods-miner.md index 492bb0055..71067de3f 100644 --- a/documentation/en/api-v0-methods-miner.md +++ b/documentation/en/api-v0-methods-miner.md @@ -407,7 +407,7 @@ Inputs: ], "Bw==", 10101, - 15 + 16 ] ``` @@ -748,7 +748,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -1199,7 +1199,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -1341,7 +1341,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -1376,7 +1376,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -1497,7 +1497,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -2782,7 +2782,7 @@ Inputs: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -3150,7 +3150,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", diff --git a/documentation/en/api-v0-methods.md b/documentation/en/api-v0-methods.md index 6f3e5c8ee..87666bfd9 100644 --- a/documentation/en/api-v0-methods.md +++ b/documentation/en/api-v0-methods.md @@ -4274,7 +4274,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4351,7 +4351,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4392,7 +4392,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4433,7 +4433,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4480,7 +4480,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4524,7 +4524,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4561,7 +4561,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -5491,7 +5491,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -5569,7 +5569,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -5624,6 +5624,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ] @@ -6087,6 +6089,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ] @@ -6122,7 +6126,7 @@ Inputs: ] ``` -Response: `15` +Response: `16` ### StateReadState StateReadState returns the indicated actor's state. @@ -6508,6 +6512,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ``` diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index b08c87348..07f9b8684 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -8,8 +8,6 @@ * [Auth](#Auth) * [AuthNew](#AuthNew) * [AuthVerify](#AuthVerify) -* [Beacon](#Beacon) - * [BeaconGetEntry](#BeaconGetEntry) * [Chain](#Chain) * [ChainBlockstoreInfo](#ChainBlockstoreInfo) * [ChainCheckBlockstore](#ChainCheckBlockstore) @@ -175,6 +173,7 @@ * [StateDecodeParams](#StateDecodeParams) * [StateEncodeParams](#StateEncodeParams) * [StateGetActor](#StateGetActor) + * [StateGetBeaconEntry](#StateGetBeaconEntry) * [StateGetNetworkParams](#StateGetNetworkParams) * [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon) * [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets) @@ -342,33 +341,6 @@ Response: ] ``` -## Beacon -The Beacon method group contains methods for interacting with the random beacon (DRAND) - - -### BeaconGetEntry -BeaconGetEntry returns the beacon entry for the given filecoin epoch. If -the entry has not yet been produced, the call will block until the entry -becomes available - - -Perms: read - -Inputs: -```json -[ - 10101 -] -``` - -Response: -```json -{ - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" -} -``` - ## Chain The Chain method group contains methods for interacting with the blockchain, but that do not require any form of state computation. @@ -4712,7 +4684,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4789,7 +4761,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4830,7 +4802,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4871,7 +4843,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4918,7 +4890,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4962,7 +4934,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4999,7 +4971,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -5643,6 +5615,29 @@ Response: } ``` +### StateGetBeaconEntry +StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If +the entry has not yet been produced, the call will block until the entry +becomes available + + +Perms: read + +Inputs: +```json +[ + 10101 +] +``` + +Response: +```json +{ + "Round": 42, + "Data": "Ynl0ZSBhcnJheQ==" +} +``` + ### StateGetNetworkParams StateGetNetworkParams return current network params @@ -5931,7 +5926,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -6009,7 +6004,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -6064,6 +6059,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ] @@ -6527,6 +6524,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ] @@ -6562,7 +6561,7 @@ Inputs: ] ``` -Response: `15` +Response: `16` ### StateReadState StateReadState returns the indicated actor's state. @@ -6905,6 +6904,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ``` diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 4122026f8..c2addcac9 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -7,7 +7,7 @@ USAGE: lotus-miner [global options] command [command options] [arguments...] VERSION: - 1.15.4-dev + 1.17.0-dev COMMANDS: init Initialize a lotus miner repo @@ -1508,6 +1508,7 @@ DESCRIPTION: - all -- reports the resource usage for all currently active scopes. OPTIONS: + --json (default: false) --help, -h show help (default: false) ``` @@ -2048,6 +2049,7 @@ OPTIONS: --deadline value the deadline to compact the partitions in (default: 0) --partitions value list of partitions to compact sectors in --really-do-it Actually send transaction performing the action (default: false) + --actor value Specify the address of the miner to run this command --help, -h show help (default: false) ``` diff --git a/documentation/en/cli-lotus-worker.md b/documentation/en/cli-lotus-worker.md index c99417d42..5d2bab962 100644 --- a/documentation/en/cli-lotus-worker.md +++ b/documentation/en/cli-lotus-worker.md @@ -7,7 +7,7 @@ USAGE: lotus-worker [global options] command [command options] [arguments...] VERSION: - 1.15.4-dev + 1.17.0-dev COMMANDS: run Start lotus worker diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index d1f798f5f..7950d8060 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -7,7 +7,7 @@ USAGE: lotus [global options] command [command options] [arguments...] VERSION: - 1.15.4-dev + 1.17.0-dev COMMANDS: daemon Start a lotus daemon process @@ -1749,6 +1749,7 @@ COMMANDS: exec-trace Get the execution trace of a given message network-version Returns the network version miner-proving-deadline Retrieve information about a given miner's proving deadline + actor-cids Returns the built-in actor bundle manifest ID & system actor cids help, h Shows a list of commands or help for one command OPTIONS: @@ -2066,6 +2067,20 @@ OPTIONS: ``` +### lotus state actor-cids +``` +NAME: + lotus state actor-cids - Returns the built-in actor bundle manifest ID & system actor cids + +USAGE: + lotus state actor-cids [command options] [arguments...] + +OPTIONS: + --network-version value specify network version (default: 16) + --help, -h show help (default: false) + +``` + ## lotus chain ``` NAME: @@ -2849,6 +2864,7 @@ DESCRIPTION: - all -- reports the resource usage for all currently active scopes. OPTIONS: + --json (default: false) --help, -h show help (default: false) ``` diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index cd52de8db..3595f0c29 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit cd52de8dbcf117109c8d6f02c17e855ccdc0497c +Subproject commit 3595f0c2924f53ad802bd139d227609c907a85b1 diff --git a/extern/sector-storage/ffiwrapper/prover_cgo.go b/extern/sector-storage/ffiwrapper/prover_cgo.go index 1ca22083d..a41b11a27 100644 --- a/extern/sector-storage/ffiwrapper/prover_cgo.go +++ b/extern/sector-storage/ffiwrapper/prover_cgo.go @@ -5,7 +5,7 @@ package ffiwrapper import ( ffi "github.com/filecoin-project/filecoin-ffi" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" + "github.com/filecoin-project/go-state-types/proof" ) var ProofProver = proofProver{} @@ -14,6 +14,6 @@ var _ Prover = ProofProver type proofProver struct{} -func (v proofProver) AggregateSealProofs(aggregateInfo proof5.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) { +func (v proofProver) AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) { return ffi.AggregateSealProofs(aggregateInfo, proofs) } diff --git a/extern/sector-storage/ffiwrapper/sealer_cgo.go b/extern/sector-storage/ffiwrapper/sealer_cgo.go index d63e83c6e..cf5b40796 100644 --- a/extern/sector-storage/ffiwrapper/sealer_cgo.go +++ b/extern/sector-storage/ffiwrapper/sealer_cgo.go @@ -15,6 +15,8 @@ import ( "os" "runtime" + "github.com/filecoin-project/go-state-types/proof" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -25,7 +27,6 @@ import ( "github.com/filecoin-project/go-commp-utils/zerocomm" commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/go-state-types/abi" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/lotus/extern/sector-storage/fr32" @@ -1181,21 +1182,21 @@ func GenerateUnsealedCID(proofType abi.RegisteredSealProof, pieces []abi.PieceIn return ffi.GenerateUnsealedCID(proofType, allPieces) } -func (sb *Sealer) GenerateWinningPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, vanillas [][]byte) ([]proof5.PoStProof, error) { +func (sb *Sealer) GenerateWinningPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, vanillas [][]byte) ([]proof.PoStProof, error) { return ffi.GenerateWinningPoStWithVanilla(proofType, minerID, randomness, vanillas) } -func (sb *Sealer) GenerateWindowPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte, partitionIdx int) (proof5.PoStProof, error) { +func (sb *Sealer) GenerateWindowPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte, partitionIdx int) (proof.PoStProof, error) { pp, err := ffi.GenerateSinglePartitionWindowPoStWithVanilla(proofType, minerID, randomness, proofs, uint(partitionIdx)) if err != nil { - return proof5.PoStProof{}, err + return proof.PoStProof{}, err } if pp == nil { // should be impossible, but just in case do not panic - return proof5.PoStProof{}, xerrors.New("postproof was nil") + return proof.PoStProof{}, xerrors.New("postproof was nil") } - return proof5.PoStProof{ + return proof.PoStProof{ PoStProof: pp.PoStProof, ProofBytes: pp.ProofBytes, }, nil diff --git a/extern/sector-storage/ffiwrapper/sealer_test.go b/extern/sector-storage/ffiwrapper/sealer_test.go index 97102e50e..b182eff76 100644 --- a/extern/sector-storage/ffiwrapper/sealer_test.go +++ b/extern/sector-storage/ffiwrapper/sealer_test.go @@ -15,11 +15,9 @@ import ( "testing" "time" - commpffi "github.com/filecoin-project/go-commp-utils/ffiwrapper" + prooftypes "github.com/filecoin-project/go-state-types/proof" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + commpffi "github.com/filecoin-project/go-commp-utils/ffiwrapper" "github.com/ipfs/go-cid" @@ -32,7 +30,7 @@ import ( "github.com/filecoin-project/specs-storage/storage" ffi "github.com/filecoin-project/filecoin-ffi" - "github.com/filecoin-project/filecoin-ffi/generated" + "github.com/filecoin-project/filecoin-ffi/cgo" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs" @@ -106,7 +104,7 @@ func (s *seal) commit(t *testing.T, sb *Sealer, done func()) storage.Proof { return nil } - ok, err := ProofVerifier.VerifySeal(proof2.SealVerifyInfo{ + ok, err := ProofVerifier.VerifySeal(prooftypes.SealVerifyInfo{ SectorID: s.ref.ID, SealedCID: s.cids.Sealed, SealProof: s.ref.ProofType, @@ -188,9 +186,9 @@ func (s *seal) unseal(t *testing.T, sb *Sealer, sp *basicfs.Provider, si storage func post(t *testing.T, sealer *Sealer, skipped []abi.SectorID, seals ...seal) { randomness := abi.PoStRandomness{0, 9, 2, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 45, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 7} - xsis := make([]proof7.ExtendedSectorInfo, len(seals)) + xsis := make([]prooftypes.ExtendedSectorInfo, len(seals)) for i, s := range seals { - xsis[i] = proof7.ExtendedSectorInfo{ + xsis[i] = prooftypes.ExtendedSectorInfo{ SealProof: s.ref.ProofType, SectorNumber: s.ref.ID.Number, SealedCID: s.cids.Sealed, @@ -208,16 +206,16 @@ func post(t *testing.T, sealer *Sealer, skipped []abi.SectorID, seals ...seal) { t.Fatalf("%+v", err) } - sis := make([]proof7.SectorInfo, len(seals)) + sis := make([]prooftypes.SectorInfo, len(seals)) for i, xsi := range xsis { - sis[i] = proof7.SectorInfo{ + sis[i] = prooftypes.SectorInfo{ SealProof: xsi.SealProof, SectorNumber: xsi.SectorNumber, SealedCID: xsi.SealedCID, } } - ok, err := ProofVerifier.VerifyWindowPoSt(context.TODO(), proof7.WindowPoStVerifyInfo{ + ok, err := ProofVerifier.VerifyWindowPoSt(context.TODO(), prooftypes.WindowPoStVerifyInfo{ Randomness: randomness, Proofs: proofs, ChallengedSectors: sis, @@ -525,12 +523,12 @@ func TestSealAndVerifyAggregate(t *testing.T) { } }) - avi := proof5.AggregateSealVerifyProofAndInfos{ + avi := prooftypes.AggregateSealVerifyProofAndInfos{ Miner: miner, SealProof: sealProofType, AggregateProof: policy.GetDefaultAggregationProof(), Proof: nil, - Infos: make([]proof5.AggregateSealVerifyInfo, numAgg), + Infos: make([]prooftypes.AggregateSealVerifyInfo, numAgg), } toAggregate := make([][]byte, numAgg) @@ -544,7 +542,7 @@ func TestSealAndVerifyAggregate(t *testing.T) { s.precommit(t, sb, si, func() {}) toAggregate[i] = s.commit(t, sb, func() {}) - avi.Infos[i] = proof5.AggregateSealVerifyInfo{ + avi.Infos[i] = prooftypes.AggregateSealVerifyInfo{ Number: abi.SectorNumber(i + 1), Randomness: s.ticket, InteractiveRandomness: seed, @@ -883,14 +881,8 @@ func setupLogger(t *testing.T) *bytes.Buffer { runtime.KeepAlive(w) }() - resp := generated.FilInitLogFd(int32(w.Fd())) - resp.Deref() - - defer generated.FilDestroyInitLogFdResponse(resp) - - if resp.StatusCode != generated.FCPResponseStatusFCPNoError { - t.Fatal(generated.RawString(resp.ErrorMsg).Copy()) - } + err = cgo.InitLogFd(int32(w.Fd())) + require.NoError(t, err) return &bb } diff --git a/extern/sector-storage/ffiwrapper/types.go b/extern/sector-storage/ffiwrapper/types.go index b8d9e90f1..3c39a831e 100644 --- a/extern/sector-storage/ffiwrapper/types.go +++ b/extern/sector-storage/ffiwrapper/types.go @@ -4,7 +4,7 @@ import ( "context" "io" - "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + "github.com/filecoin-project/go-state-types/proof" "github.com/ipfs/go-cid" diff --git a/extern/sector-storage/ffiwrapper/verifier_cgo.go b/extern/sector-storage/ffiwrapper/verifier_cgo.go index 6adda05c9..3f689e62e 100644 --- a/extern/sector-storage/ffiwrapper/verifier_cgo.go +++ b/extern/sector-storage/ffiwrapper/verifier_cgo.go @@ -11,7 +11,6 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/go-state-types/abi" - ffiproof "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" @@ -114,7 +113,7 @@ func (sb *Sealer) pubExtendedSectorToPriv(ctx context.Context, mid abi.ActorID, return ffi.SortedPrivateSectorInfo{}, nil, nil, xerrors.Errorf("acquiring registered PoSt proof from sector info %+v: %w", s, err) } - ffiInfo := ffiproof.SectorInfo{ + ffiInfo := proof.SectorInfo{ SealProof: s.SealProof, SectorNumber: s.SectorNumber, SealedCID: s.SealedCID, diff --git a/extern/sector-storage/mock/mock.go b/extern/sector-storage/mock/mock.go index ecb06da0b..e50780d1c 100644 --- a/extern/sector-storage/mock/mock.go +++ b/extern/sector-storage/mock/mock.go @@ -10,7 +10,7 @@ import ( "math/rand" "sync" - "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + prooftypes "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/dagstore/mount" ffiwrapper2 "github.com/filecoin-project/go-commp-utils/ffiwrapper" @@ -37,7 +37,7 @@ type SectorMgr struct { } type mockVerifProver struct { - aggregates map[string]proof.AggregateSealVerifyProofAndInfos // used for logging bad verifies + aggregates map[string]prooftypes.AggregateSealVerifyProofAndInfos // used for logging bad verifies } func NewMockSectorMgr(genesisSectors []abi.SectorID) *SectorMgr { @@ -338,13 +338,13 @@ func AddOpFinish(ctx context.Context) (context.Context, func()) { } } -func (mgr *SectorMgr) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, xSectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, error) { +func (mgr *SectorMgr) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, xSectorInfo []prooftypes.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]prooftypes.PoStProof, error) { mgr.lk.Lock() defer mgr.lk.Unlock() - sectorInfo := make([]proof.SectorInfo, len(xSectorInfo)) + sectorInfo := make([]prooftypes.SectorInfo, len(xSectorInfo)) for i, xssi := range xSectorInfo { - sectorInfo[i] = proof.SectorInfo{ + sectorInfo[i] = prooftypes.SectorInfo{ SealProof: xssi.SealProof, SectorNumber: xssi.SectorNumber, SealedCID: xssi.SealedCID, @@ -354,7 +354,7 @@ func (mgr *SectorMgr) GenerateWinningPoSt(ctx context.Context, minerID abi.Actor return generateFakePoSt(sectorInfo, abi.RegisteredSealProof.RegisteredWinningPoStProof, randomness), nil } -func (mgr *SectorMgr) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, xSectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, []abi.SectorID, error) { +func (mgr *SectorMgr) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, xSectorInfo []prooftypes.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]prooftypes.PoStProof, []abi.SectorID, error) { mgr.lk.Lock() defer mgr.lk.Unlock() @@ -362,7 +362,7 @@ func (mgr *SectorMgr) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorI return nil, nil, xerrors.Errorf("failed to post (mock)") } - si := make([]proof.ExtendedSectorInfo, 0, len(xSectorInfo)) + si := make([]prooftypes.ExtendedSectorInfo, 0, len(xSectorInfo)) var skipped []abi.SectorID @@ -388,9 +388,9 @@ func (mgr *SectorMgr) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorI return nil, skipped, err } - sectorInfo := make([]proof.SectorInfo, len(si)) + sectorInfo := make([]prooftypes.SectorInfo, len(si)) for i, xssi := range si { - sectorInfo[i] = proof.SectorInfo{ + sectorInfo[i] = prooftypes.SectorInfo{ SealProof: xssi.SealProof, SectorNumber: xssi.SectorNumber, SealedCID: xssi.SealedCID, @@ -400,7 +400,7 @@ func (mgr *SectorMgr) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorI return generateFakePoSt(sectorInfo, abi.RegisteredSealProof.RegisteredWindowPoStProof, randomness), skipped, nil } -func generateFakePoStProof(sectorInfo []proof.SectorInfo, randomness abi.PoStRandomness) []byte { +func generateFakePoStProof(sectorInfo []prooftypes.SectorInfo, randomness abi.PoStRandomness) []byte { randomness[31] &= 0x3f hasher := sha256.New() @@ -415,13 +415,13 @@ func generateFakePoStProof(sectorInfo []proof.SectorInfo, randomness abi.PoStRan } -func generateFakePoSt(sectorInfo []proof.SectorInfo, rpt func(abi.RegisteredSealProof) (abi.RegisteredPoStProof, error), randomness abi.PoStRandomness) []proof.PoStProof { +func generateFakePoSt(sectorInfo []prooftypes.SectorInfo, rpt func(abi.RegisteredSealProof) (abi.RegisteredPoStProof, error), randomness abi.PoStRandomness) []prooftypes.PoStProof { wp, err := rpt(sectorInfo[0].SealProof) if err != nil { panic(err) } - return []proof.PoStProof{ + return []prooftypes.PoStProof{ { PoStProof: wp, ProofBytes: generateFakePoStProof(sectorInfo, randomness), @@ -429,11 +429,11 @@ func generateFakePoSt(sectorInfo []proof.SectorInfo, rpt func(abi.RegisteredSeal } } -func (mgr *SectorMgr) GenerateWinningPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte) ([]proof.PoStProof, error) { +func (mgr *SectorMgr) GenerateWinningPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte) ([]prooftypes.PoStProof, error) { panic("implement me") } -func (mgr *SectorMgr) GenerateWindowPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte, partitionIdx int) (proof.PoStProof, error) { +func (mgr *SectorMgr) GenerateWindowPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte, partitionIdx int) (prooftypes.PoStProof, error) { panic("implement me") } @@ -609,7 +609,7 @@ func (mgr *SectorMgr) ReturnFinalizeReplicaUpdate(ctx context.Context, callID st panic("not supported") } -func (m mockVerifProver) VerifySeal(svi proof.SealVerifyInfo) (bool, error) { +func (m mockVerifProver) VerifySeal(svi prooftypes.SealVerifyInfo) (bool, error) { plen, err := svi.SealProof.ProofSize() if err != nil { return false, err @@ -630,7 +630,7 @@ func (m mockVerifProver) VerifySeal(svi proof.SealVerifyInfo) (bool, error) { return true, nil } -func (m mockVerifProver) VerifyAggregateSeals(aggregate proof.AggregateSealVerifyProofAndInfos) (bool, error) { +func (m mockVerifProver) VerifyAggregateSeals(aggregate prooftypes.AggregateSealVerifyProofAndInfos) (bool, error) { out := make([]byte, m.aggLen(len(aggregate.Infos))) for pi, svi := range aggregate.Infos { for i := 0; i < 32; i++ { @@ -656,11 +656,11 @@ func (m mockVerifProver) VerifyAggregateSeals(aggregate proof.AggregateSealVerif return ok, nil } -func (m mockVerifProver) VerifyReplicaUpdate(update proof.ReplicaUpdateInfo) (bool, error) { +func (m mockVerifProver) VerifyReplicaUpdate(update prooftypes.ReplicaUpdateInfo) (bool, error) { return true, nil } -func (m mockVerifProver) AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) { +func (m mockVerifProver) AggregateSealProofs(aggregateInfo prooftypes.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) { out := make([]byte, m.aggLen(len(aggregateInfo.Infos))) // todo: figure out more real length for pi, proof := range proofs { for i := range proof[:32] { @@ -702,12 +702,12 @@ func (m mockVerifProver) aggLen(nproofs int) int { } } -func (m mockVerifProver) VerifyWinningPoSt(ctx context.Context, info proof.WinningPoStVerifyInfo) (bool, error) { +func (m mockVerifProver) VerifyWinningPoSt(ctx context.Context, info prooftypes.WinningPoStVerifyInfo) (bool, error) { info.Randomness[31] &= 0x3f return true, nil } -func (m mockVerifProver) VerifyWindowPoSt(ctx context.Context, info proof.WindowPoStVerifyInfo) (bool, error) { +func (m mockVerifProver) VerifyWindowPoSt(ctx context.Context, info prooftypes.WindowPoStVerifyInfo) (bool, error) { if len(info.Proofs) != 1 { return false, xerrors.Errorf("expected 1 proof entry") } @@ -730,7 +730,7 @@ func (m mockVerifProver) GenerateWinningPoStSectorChallenge(ctx context.Context, } var MockVerifier = mockVerifProver{ - aggregates: map[string]proof.AggregateSealVerifyProofAndInfos{}, + aggregates: map[string]prooftypes.AggregateSealVerifyProofAndInfos{}, } var MockProver = MockVerifier diff --git a/extern/sector-storage/sched_test.go b/extern/sector-storage/sched_test.go index 507fda1b8..c27330d44 100644 --- a/extern/sector-storage/sched_test.go +++ b/extern/sector-storage/sched_test.go @@ -11,13 +11,14 @@ import ( "testing" "time" + prooftypes "github.com/filecoin-project/go-state-types/proof" + "github.com/google/uuid" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "github.com/stretchr/testify/require" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/filecoin-project/lotus/extern/sector-storage/fsutil" "github.com/filecoin-project/lotus/extern/sector-storage/sealtasks" @@ -144,7 +145,7 @@ func (s *schedTestWorker) ReadPiece(ctx context.Context, writer io.Writer, id st panic("implement me") } -func (s *schedTestWorker) GenerateWinningPoSt(ctx context.Context, ppt abi.RegisteredPoStProof, mid abi.ActorID, sectors []storiface.PostSectorChallenge, randomness abi.PoStRandomness) ([]proof.PoStProof, error) { +func (s *schedTestWorker) GenerateWinningPoSt(ctx context.Context, ppt abi.RegisteredPoStProof, mid abi.ActorID, sectors []storiface.PostSectorChallenge, randomness abi.PoStRandomness) ([]prooftypes.PoStProof, error) { panic("implement me") } diff --git a/extern/sector-storage/stores/local.go b/extern/sector-storage/stores/local.go index 1f81d5bd0..722f8c0d4 100644 --- a/extern/sector-storage/stores/local.go +++ b/extern/sector-storage/stores/local.go @@ -11,11 +11,12 @@ import ( "sync" "time" + "github.com/filecoin-project/go-state-types/proof" + "golang.org/x/xerrors" ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/lotus/extern/sector-storage/fsutil" diff --git a/extern/sector-storage/storiface/worker.go b/extern/sector-storage/storiface/worker.go index 0f3e76bf6..e325908cc 100644 --- a/extern/sector-storage/storiface/worker.go +++ b/extern/sector-storage/storiface/worker.go @@ -6,11 +6,12 @@ import ( "fmt" "time" + "github.com/filecoin-project/go-state-types/proof" + "github.com/google/uuid" "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/lotus/extern/sector-storage/sealtasks" diff --git a/extern/sector-storage/teststorage_test.go b/extern/sector-storage/teststorage_test.go index 0c15fbf7b..b687e37a2 100644 --- a/extern/sector-storage/teststorage_test.go +++ b/extern/sector-storage/teststorage_test.go @@ -31,7 +31,7 @@ func (t *testExec) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, panic("implement me") } -func (t *testExec) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) (proof []proof.PoStProof, skipped []abi.SectorID, err error) { +func (t *testExec) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) (miner []proof.PoStProof, skipped []abi.SectorID, err error) { panic("implement me") } diff --git a/extern/sector-storage/worker_local.go b/extern/sector-storage/worker_local.go index 355915a34..055166cb1 100644 --- a/extern/sector-storage/worker_local.go +++ b/extern/sector-storage/worker_local.go @@ -11,6 +11,8 @@ import ( "sync/atomic" "time" + "github.com/filecoin-project/go-state-types/proof" + "github.com/elastic/go-sysinfo" "github.com/google/uuid" "github.com/hashicorp/go-multierror" @@ -20,7 +22,6 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-statestore" - "github.com/filecoin-project/specs-actors/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" diff --git a/extern/storage-sealing/cbor_gen.go b/extern/storage-sealing/cbor_gen.go index 8794fdf4d..8b66619e3 100644 --- a/extern/storage-sealing/cbor_gen.go +++ b/extern/storage-sealing/cbor_gen.go @@ -9,8 +9,8 @@ import ( "sort" abi "github.com/filecoin-project/go-state-types/abi" + miner "github.com/filecoin-project/go-state-types/builtin/v8/miner" api "github.com/filecoin-project/lotus/api" - miner "github.com/filecoin-project/specs-actors/actors/builtin/miner" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" diff --git a/extern/storage-sealing/checks.go b/extern/storage-sealing/checks.go index dc045ded2..4aa00c34e 100644 --- a/extern/storage-sealing/checks.go +++ b/extern/storage-sealing/checks.go @@ -4,9 +4,9 @@ import ( "bytes" "context" - "github.com/filecoin-project/lotus/chain/actors/policy" + prooftypes "github.com/filecoin-project/go-state-types/proof" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" + "github.com/filecoin-project/lotus/chain/actors/policy" "golang.org/x/xerrors" @@ -177,7 +177,7 @@ func (m *Sealing) checkCommit(ctx context.Context, si SectorInfo, proof []byte, log.Warn("on-chain sealed CID doesn't match!") } - ok, err := m.verif.VerifySeal(proof2.SealVerifyInfo{ + ok, err := m.verif.VerifySeal(prooftypes.SealVerifyInfo{ SectorID: m.minerSectorID(si.SectorNumber), SealedCID: pci.Info.SealedCID, SealProof: pci.Info.SealProof, diff --git a/extern/storage-sealing/commit_batch.go b/extern/storage-sealing/commit_batch.go index 1c55b6700..b364184fd 100644 --- a/extern/storage-sealing/commit_batch.go +++ b/extern/storage-sealing/commit_batch.go @@ -7,6 +7,8 @@ import ( "sync" "time" + "github.com/filecoin-project/go-state-types/proof" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -14,14 +16,12 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/network" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" @@ -38,7 +38,7 @@ var aggFeeDen = big.NewInt(100) 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, TipSetToken) (miner.MinerInfo, error) + StateMinerInfo(context.Context, address.Address, TipSetToken) (api.MinerInfo, error) ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error) ChainBaseFee(context.Context, TipSetToken) (abi.TokenAmount, error) @@ -50,7 +50,7 @@ type CommitBatcherApi interface { type AggregateInput struct { Spt abi.RegisteredSealProof - Info proof5.AggregateSealVerifyInfo + Info proof.AggregateSealVerifyInfo Proof []byte } @@ -206,7 +206,7 @@ func (b *CommitBatcher) maybeStartBatch(notif bool) ([]sealiface.CommitBatchRes, var res []sealiface.CommitBatchRes - individual := (total < cfg.MinCommitBatch) || (total < miner5.MinAggregatedSectors) + individual := (total < cfg.MinCommitBatch) || (total < miner.MinAggregatedSectors) if !individual && !cfg.AggregateAboveBaseFee.Equals(big.Zero()) { tok, _, err := b.api.ChainHead(b.mctx) @@ -269,12 +269,12 @@ func (b *CommitBatcher) processBatch(cfg sealiface.Config) ([]sealiface.CommitBa FailedSectors: map[abi.SectorNumber]string{}, } - params := miner5.ProveCommitAggregateParams{ + params := miner.ProveCommitAggregateParams{ SectorNumbers: bitfield.New(), } proofs := make([][]byte, 0, total) - infos := make([]proof5.AggregateSealVerifyInfo, 0, total) + infos := make([]proof.AggregateSealVerifyInfo, 0, total) collateral := big.Zero() for id, p := range b.todo { @@ -314,7 +314,7 @@ func (b *CommitBatcher) processBatch(cfg sealiface.Config) ([]sealiface.CommitBa return []sealiface.CommitBatchRes{res}, xerrors.Errorf("getting miner id: %w", err) } - params.AggregateProof, err = b.prover.AggregateSealProofs(proof5.AggregateSealVerifyProofAndInfos{ + params.AggregateProof, err = b.prover.AggregateSealProofs(proof.AggregateSealVerifyProofAndInfos{ Miner: abi.ActorID(mid), SealProof: b.todo[infos[0].Number].Spt, AggregateProof: arp, @@ -368,7 +368,7 @@ func (b *CommitBatcher) processBatch(cfg sealiface.Config) ([]sealiface.CommitBa return []sealiface.CommitBatchRes{res}, xerrors.Errorf("no good address found: %w", err) } - mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, miner.Methods.ProveCommitAggregate, needFunds, maxFee, enc.Bytes()) + mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, builtin.MethodsMiner.ProveCommitAggregate, needFunds, maxFee, enc.Bytes()) if err != nil { return []sealiface.CommitBatchRes{res}, xerrors.Errorf("sending message failed: %w", err) } @@ -427,7 +427,7 @@ func (b *CommitBatcher) processIndividually(cfg sealiface.Config) ([]sealiface.C return res, nil } -func (b *CommitBatcher) processSingle(cfg sealiface.Config, mi miner.MinerInfo, avail *abi.TokenAmount, sn abi.SectorNumber, info AggregateInput, tok TipSetToken) (cid.Cid, error) { +func (b *CommitBatcher) processSingle(cfg sealiface.Config, mi api.MinerInfo, avail *abi.TokenAmount, sn abi.SectorNumber, info AggregateInput, tok TipSetToken) (cid.Cid, error) { enc := new(bytes.Buffer) params := &miner.ProveCommitSectorParams{ SectorNumber: sn, @@ -463,7 +463,7 @@ func (b *CommitBatcher) processSingle(cfg sealiface.Config, mi miner.MinerInfo, return cid.Undef, xerrors.Errorf("no good address to send commit message from: %w", err) } - mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, miner.Methods.ProveCommitSector, collateral, big.Int(b.feeCfg.MaxCommitGasFee), enc.Bytes()) + mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, builtin.MethodsMiner.ProveCommitSector, collateral, big.Int(b.feeCfg.MaxCommitGasFee), enc.Bytes()) if err != nil { return cid.Undef, xerrors.Errorf("pushing message to mpool: %w", err) } diff --git a/extern/storage-sealing/commit_batch_test.go b/extern/storage-sealing/commit_batch_test.go index 3bda6d3fd..4b2f56aec 100644 --- a/extern/storage-sealing/commit_batch_test.go +++ b/extern/storage-sealing/commit_batch_test.go @@ -9,6 +9,10 @@ import ( "testing" "time" + prooftypes "github.com/filecoin-project/go-state-types/proof" + + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -16,16 +20,13 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" - "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" "github.com/filecoin-project/lotus/extern/storage-sealing/mocks" "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" + miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" ) func TestCommitBatcher(t *testing.T) { @@ -35,7 +36,7 @@ func TestCommitBatcher(t *testing.T) { ctx := context.Background() - as := func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { + as := func(ctx context.Context, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { return t0123, big.Zero(), nil } @@ -107,14 +108,14 @@ func TestCommitBatcher(t *testing.T) { s.EXPECT().ChainHead(gomock.Any()).Return(nil, abi.ChainEpoch(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(&miner.SectorPreCommitOnChainInfo{ + s.EXPECT().StateSectorPreCommitInfo(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&minertypes.SectorPreCommitOnChainInfo{ PreCommitDeposit: big.Zero(), }, nil) go func() { defer done.Unlock() pcres, pcerr = pcb.AddCommit(ctx, si, sealing.AggregateInput{ - Info: proof5.AggregateSealVerifyInfo{ + Info: prooftypes.AggregateSealVerifyInfo{ Number: sn, }, }) @@ -152,7 +153,7 @@ func TestCommitBatcher(t *testing.T) { //stm: @CHAIN_STATE_MINER_INFO_001, @CHAIN_STATE_NETWORK_VERSION_001, @CHAIN_STATE_MINER_GET_COLLATERAL_001 expectSend := func(expect []abi.SectorNumber, aboveBalancer, failOnePCI bool) action { return func(t *testing.T, s *mocks.MockCommitBatcherApi, pcb *sealing.CommitBatcher) promise { - s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(miner.MinerInfo{Owner: t0123, Worker: t0123}, nil) + s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(api.MinerInfo{Owner: t0123, Worker: t0123}, nil) ti := len(expect) batch := false @@ -186,7 +187,7 @@ func TestCommitBatcher(t *testing.T) { ti-- } } - s.EXPECT().StateSectorPreCommitInfo(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&miner.SectorPreCommitOnChainInfo{ + s.EXPECT().StateSectorPreCommitInfo(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&minertypes.SectorPreCommitOnChainInfo{ PreCommitDeposit: big.Zero(), }, nil).Times(pciC) s.EXPECT().StateMinerInitialPledgeCollateral(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(big.Zero(), nil).Times(pciC) @@ -380,7 +381,7 @@ func TestCommitBatcher(t *testing.T) { type fakeProver struct{} -func (f fakeProver) AggregateSealProofs(aggregateInfo proof5.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) { +func (f fakeProver) AggregateSealProofs(aggregateInfo prooftypes.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) { return []byte("Trust me, I'm a proof"), nil } diff --git a/extern/storage-sealing/currentdealinfo.go b/extern/storage-sealing/currentdealinfo.go index 06c24163b..542792696 100644 --- a/extern/storage-sealing/currentdealinfo.go +++ b/extern/storage-sealing/currentdealinfo.go @@ -5,15 +5,16 @@ import ( "context" "fmt" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/lotus/chain/actors/builtin/market" + "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/types" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" "github.com/ipfs/go-cid" "golang.org/x/xerrors" ) @@ -121,7 +122,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context return dealID, nil, xerrors.Errorf("getting publish deal message %s: %w", publishCid, err) } - var pubDealsParams market2.PublishStorageDealsParams + var pubDealsParams market8.PublishStorageDealsParams if err := pubDealsParams.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil { return dealID, nil, xerrors.Errorf("unmarshalling publish deal message params for message %s: %w", publishCid, err) } @@ -130,7 +131,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context // index of the target deal proposal dealIdx := -1 for i, paramDeal := range pubDealsParams.Deals { - eq, err := mgr.CheckDealEquality(ctx, tok, *proposal, market.DealProposal(paramDeal.Proposal)) + eq, err := mgr.CheckDealEquality(ctx, tok, *proposal, paramDeal.Proposal) if err != nil { return dealID, nil, xerrors.Errorf("comparing publish deal message %s proposal to deal proposal: %w", publishCid, err) } @@ -180,7 +181,7 @@ func (mgr *CurrentDealInfoManager) CheckDealEquality(ctx context.Context, tok Ti return p1.PieceCID.Equals(p2.PieceCID) && p1.PieceSize == p2.PieceSize && p1.VerifiedDeal == p2.VerifiedDeal && - p1.Label == p2.Label && + p1.Label.Equals(p2.Label) && p1.StartEpoch == p2.StartEpoch && p1.EndEpoch == p2.EndEpoch && p1.StoragePricePerEpoch.Equals(p2.StoragePricePerEpoch) && diff --git a/extern/storage-sealing/currentdealinfo_test.go b/extern/storage-sealing/currentdealinfo_test.go index 31d538190..5f889467a 100644 --- a/extern/storage-sealing/currentdealinfo_test.go +++ b/extern/storage-sealing/currentdealinfo_test.go @@ -9,10 +9,12 @@ import ( "time" "github.com/filecoin-project/go-bitfield" + + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/go-state-types/network" market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" - market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" "golang.org/x/net/context" "golang.org/x/xerrors" @@ -25,7 +27,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/market" evtmock "github.com/filecoin-project/lotus/chain/events/state/mock" "github.com/filecoin-project/lotus/chain/types" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" "github.com/ipfs/go-cid" "github.com/stretchr/testify/require" @@ -34,6 +35,15 @@ import ( var errNotFound = errors.New("could not find") func TestGetCurrentDealInfo(t *testing.T) { + success, err := markettypes.NewLabelFromString("success") + require.NoError(t, err) + + other, err := markettypes.NewLabelFromString("other") + require.NoError(t, err) + + another, err := markettypes.NewLabelFromString("another") + require.NoError(t, err) + ctx := context.Background() dummyCid, _ := cid.Parse("bafkqaaa") dummyCid2, _ := cid.Parse("bafkqaab") @@ -49,7 +59,7 @@ func TestGetCurrentDealInfo(t *testing.T) { StoragePricePerEpoch: abi.NewTokenAmount(1), ProviderCollateral: abi.NewTokenAmount(1), ClientCollateral: abi.NewTokenAmount(1), - Label: "success", + Label: success, } otherProposal := market.DealProposal{ PieceCID: dummyCid2, @@ -59,7 +69,7 @@ func TestGetCurrentDealInfo(t *testing.T) { StoragePricePerEpoch: abi.NewTokenAmount(1), ProviderCollateral: abi.NewTokenAmount(1), ClientCollateral: abi.NewTokenAmount(1), - Label: "other", + Label: other, } anotherProposal := market.DealProposal{ PieceCID: dummyCid2, @@ -69,7 +79,7 @@ func TestGetCurrentDealInfo(t *testing.T) { StoragePricePerEpoch: abi.NewTokenAmount(1), ProviderCollateral: abi.NewTokenAmount(1), ClientCollateral: abi.NewTokenAmount(1), - Label: "another", + Label: another, } successDeal := &api.MarketDeal{ Proposal: proposal, @@ -328,11 +338,11 @@ func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.C return keys[i].DealID < keys[j].DealID }) - var deals []market2.ClientDealProposal + var deals []markettypes.ClientDealProposal for _, k := range keys { dl := mapi.MarketDeals[k] - deals = append(deals, market2.ClientDealProposal{ - Proposal: market2.DealProposal(dl.Proposal), + deals = append(deals, markettypes.ClientDealProposal{ + Proposal: dl.Proposal, ClientSignature: crypto.Signature{ Data: []byte("foo bar cat dog"), Type: crypto.SigTypeBLS, @@ -341,7 +351,7 @@ func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.C } buf := new(bytes.Buffer) - params := market2.PublishStorageDealsParams{Deals: deals} + params := markettypes.PublishStorageDealsParams{Deals: deals} err := params.MarshalCBOR(buf) if err != nil { panic(err) @@ -393,7 +403,7 @@ func makePublishDealsReturnBytesOldVersion(t *testing.T, dealIDs []abi.DealID) [ func makePublishDealsReturn(t *testing.T, dealIDs []abi.DealID, validIdxs []uint64) []byte { buf := new(bytes.Buffer) - dealsReturn := market7.PublishStorageDealsReturn{ + dealsReturn := markettypes.PublishStorageDealsReturn{ IDs: dealIDs, ValidDeals: bitfield.NewFromSet(validIdxs), } diff --git a/extern/storage-sealing/fsm_events.go b/extern/storage-sealing/fsm_events.go index 66497473f..621b90aaf 100644 --- a/extern/storage-sealing/fsm_events.go +++ b/extern/storage-sealing/fsm_events.go @@ -10,7 +10,7 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-storage/storage" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" ) type mutator interface { diff --git a/extern/storage-sealing/mocks/api.go b/extern/storage-sealing/mocks/api.go index efe89ff0b..cd1b66d34 100644 --- a/extern/storage-sealing/mocks/api.go +++ b/extern/storage-sealing/mocks/api.go @@ -12,15 +12,14 @@ import ( bitfield "github.com/filecoin-project/go-bitfield" 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" - market "github.com/filecoin-project/lotus/chain/actors/builtin/market" - miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner" types "github.com/filecoin-project/lotus/chain/types" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" ) @@ -245,10 +244,10 @@ func (mr *MockSealingAPIMockRecorder) StateMinerAvailableBalance(arg0, arg1, arg } // StateMinerInfo mocks base method. -func (m *MockSealingAPI) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 sealing.TipSetToken) (miner.MinerInfo, error) { +func (m *MockSealingAPI) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 sealing.TipSetToken) (api.MinerInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(miner.MinerInfo) + ret0, _ := ret[0].(api.MinerInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -260,7 +259,7 @@ func (mr *MockSealingAPIMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{ } // StateMinerInitialPledgeCollateral mocks base method. -func (m *MockSealingAPI) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 sealing.TipSetToken) (big.Int, error) { +func (m *MockSealingAPI) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 sealing.TipSetToken) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInitialPledgeCollateral", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) @@ -290,7 +289,7 @@ func (mr *MockSealingAPIMockRecorder) StateMinerPartitions(arg0, arg1, arg2, arg } // StateMinerPreCommitDepositForPower mocks base method. -func (m *MockSealingAPI) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 sealing.TipSetToken) (big.Int, error) { +func (m *MockSealingAPI) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 sealing.TipSetToken) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerPreCommitDepositForPower", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) diff --git a/extern/storage-sealing/mocks/mock_commit_batcher.go b/extern/storage-sealing/mocks/mock_commit_batcher.go index 061121899..7285f7ea5 100644 --- a/extern/storage-sealing/mocks/mock_commit_batcher.go +++ b/extern/storage-sealing/mocks/mock_commit_batcher.go @@ -11,10 +11,10 @@ import ( 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" - miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + api "github.com/filecoin-project/lotus/api" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" ) @@ -104,10 +104,10 @@ func (mr *MockCommitBatcherApiMockRecorder) StateMinerAvailableBalance(arg0, arg } // StateMinerInfo mocks base method. -func (m *MockCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 sealing.TipSetToken) (miner.MinerInfo, error) { +func (m *MockCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 sealing.TipSetToken) (api.MinerInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(miner.MinerInfo) + ret0, _ := ret[0].(api.MinerInfo) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -119,7 +119,7 @@ func (mr *MockCommitBatcherApiMockRecorder) StateMinerInfo(arg0, arg1, arg2 inte } // StateMinerInitialPledgeCollateral mocks base method. -func (m *MockCommitBatcherApi) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 sealing.TipSetToken) (big.Int, error) { +func (m *MockCommitBatcherApi) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 sealing.TipSetToken) (big.Int, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInitialPledgeCollateral", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(big.Int) diff --git a/extern/storage-sealing/mocks/mock_precommit_batcher.go b/extern/storage-sealing/mocks/mock_precommit_batcher.go index fe7424d35..914fcd56d 100644 --- a/extern/storage-sealing/mocks/mock_precommit_batcher.go +++ b/extern/storage-sealing/mocks/mock_precommit_batcher.go @@ -12,7 +12,7 @@ import ( 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" - miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + api "github.com/filecoin-project/lotus/api" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" @@ -103,10 +103,10 @@ func (mr *MockPreCommitBatcherApiMockRecorder) StateMinerAvailableBalance(arg0, } // StateMinerInfo mocks base method. -func (m *MockPreCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 sealing.TipSetToken) (miner.MinerInfo, error) { +func (m *MockPreCommitBatcherApi) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 sealing.TipSetToken) (api.MinerInfo, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2) - ret0, _ := ret[0].(miner.MinerInfo) + ret0, _ := ret[0].(api.MinerInfo) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/extern/storage-sealing/precommit_batch.go b/extern/storage-sealing/precommit_batch.go index 2a8168a4a..02cce8c38 100644 --- a/extern/storage-sealing/precommit_batch.go +++ b/extern/storage-sealing/precommit_batch.go @@ -15,12 +15,12 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" @@ -31,7 +31,7 @@ import ( type PreCommitBatcherApi 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, TipSetToken) (miner.MinerInfo, error) + StateMinerInfo(context.Context, address.Address, TipSetToken) (api.MinerInfo, error) StateMinerAvailableBalance(context.Context, address.Address, TipSetToken) (big.Int, error) ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error) ChainBaseFee(context.Context, TipSetToken) (abi.TokenAmount, error) @@ -40,7 +40,7 @@ type PreCommitBatcherApi interface { type preCommitEntry struct { deposit abi.TokenAmount - pci *miner0.SectorPreCommitInfo + pci *miner.SectorPreCommitInfo } type PreCommitBatcher struct { @@ -281,7 +281,7 @@ func (b *PreCommitBatcher) processIndividually(cfg sealiface.Config) ([]sealifac return res, nil } -func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi miner.MinerInfo, avail *abi.TokenAmount, params *preCommitEntry) (cid.Cid, error) { +func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi api.MinerInfo, avail *abi.TokenAmount, params *preCommitEntry) (cid.Cid, error) { enc := new(bytes.Buffer) if err := params.pci.MarshalCBOR(enc); err != nil { @@ -309,7 +309,7 @@ func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi miner.MinerInf return cid.Undef, xerrors.Errorf("no good address to send precommit message from: %w", err) } - mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, miner.Methods.PreCommitSector, deposit, big.Int(b.feeCfg.MaxPreCommitGasFee), enc.Bytes()) + mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, builtin.MethodsMiner.PreCommitSector, deposit, big.Int(b.feeCfg.MaxPreCommitGasFee), enc.Bytes()) if err != nil { return cid.Undef, xerrors.Errorf("pushing message to mpool: %w", err) } @@ -318,7 +318,7 @@ func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi miner.MinerInf } func (b *PreCommitBatcher) processBatch(cfg sealiface.Config, tok TipSetToken, bf abi.TokenAmount, nv network.Version) ([]sealiface.PreCommitBatchRes, error) { - params := miner5.PreCommitSectorBatchParams{} + params := miner.PreCommitSectorBatchParams{} deposit := big.Zero() var res sealiface.PreCommitBatchRes @@ -366,7 +366,7 @@ func (b *PreCommitBatcher) processBatch(cfg sealiface.Config, tok TipSetToken, b return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("no good address found: %w", err) } - mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, miner.Methods.PreCommitSectorBatch, needFunds, maxFee, enc.Bytes()) + mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, needFunds, maxFee, enc.Bytes()) if err != nil { return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("sending message failed: %w", err) } @@ -379,7 +379,7 @@ func (b *PreCommitBatcher) processBatch(cfg sealiface.Config, tok TipSetToken, b } // register PreCommit, wait for batch message, return message CID -func (b *PreCommitBatcher) AddPreCommit(ctx context.Context, s SectorInfo, deposit abi.TokenAmount, in *miner0.SectorPreCommitInfo) (res sealiface.PreCommitBatchRes, err error) { +func (b *PreCommitBatcher) AddPreCommit(ctx context.Context, s SectorInfo, deposit abi.TokenAmount, in *miner.SectorPreCommitInfo) (res sealiface.PreCommitBatchRes, err error) { _, curEpoch, err := b.api.ChainHead(b.mctx) if err != nil { log.Errorf("getting chain head: %s", err) diff --git a/extern/storage-sealing/precommit_batch_test.go b/extern/storage-sealing/precommit_batch_test.go index a90645a05..e2cea330e 100644 --- a/extern/storage-sealing/precommit_batch_test.go +++ b/extern/storage-sealing/precommit_batch_test.go @@ -9,6 +9,8 @@ import ( "testing" "time" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" "github.com/filecoin-project/go-state-types/network" @@ -21,13 +23,11 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" "github.com/filecoin-project/lotus/extern/storage-sealing/mocks" "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" "github.com/filecoin-project/lotus/node/config" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" ) var fc = config.MinerFeeConfig{ @@ -45,7 +45,7 @@ func TestPrecommitBatcher(t *testing.T) { ctx := context.Background() - as := func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { + as := func(ctx context.Context, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { return t0123, big.Zero(), nil } @@ -116,7 +116,7 @@ func TestPrecommitBatcher(t *testing.T) { go func() { defer done.Unlock() - pcres, pcerr = pcb.AddPreCommit(ctx, si, big.Zero(), &miner0.SectorPreCommitInfo{ + pcres, pcerr = pcb.AddPreCommit(ctx, si, big.Zero(), &minertypes.SectorPreCommitInfo{ SectorNumber: si.SectorNumber, SealedCID: fakePieceCid(t), DealIDs: nil, @@ -160,7 +160,7 @@ func TestPrecommitBatcher(t *testing.T) { s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(big.NewInt(10001), nil) s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version14, nil) - s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(miner.MinerInfo{Owner: t0123, Worker: t0123}, nil) + s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(api.MinerInfo{Owner: t0123, Worker: t0123}, nil) s.EXPECT().SendMsg(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), funMatcher(func(i interface{}) bool { b := i.([]byte) var params miner6.PreCommitSectorBatchParams @@ -181,7 +181,7 @@ func TestPrecommitBatcher(t *testing.T) { s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(big.NewInt(9999), nil) s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version14, nil) - s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(miner.MinerInfo{Owner: t0123, Worker: t0123}, nil) + s.EXPECT().StateMinerInfo(gomock.Any(), gomock.Any(), gomock.Any()).Return(api.MinerInfo{Owner: t0123, Worker: t0123}, nil) for _, number := range expect { numClone := number s.EXPECT().SendMsg(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), funMatcher(func(i interface{}) bool { diff --git a/extern/storage-sealing/precommit_policy.go b/extern/storage-sealing/precommit_policy.go index 398956f01..b215e5844 100644 --- a/extern/storage-sealing/precommit_policy.go +++ b/extern/storage-sealing/precommit_policy.go @@ -6,9 +6,9 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" ) diff --git a/extern/storage-sealing/sealing.go b/extern/storage-sealing/sealing.go index cacd5b3c4..509e267c4 100644 --- a/extern/storage-sealing/sealing.go +++ b/extern/storage-sealing/sealing.go @@ -6,6 +6,8 @@ import ( "sync" "time" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/ipfs/go-cid" @@ -23,9 +25,9 @@ import ( "github.com/filecoin-project/go-statemachine" "github.com/filecoin-project/specs-storage/storage" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/market" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" @@ -62,7 +64,7 @@ type SealingAPI interface { StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tok TipSetToken) (address.Address, error) StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, TipSetToken) (big.Int, error) StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, TipSetToken) (big.Int, error) - StateMinerInfo(context.Context, address.Address, TipSetToken) (miner.MinerInfo, error) + StateMinerInfo(context.Context, address.Address, TipSetToken) (api.MinerInfo, error) StateMinerAvailableBalance(context.Context, address.Address, TipSetToken) (big.Int, error) StateMinerSectorAllocated(context.Context, address.Address, abi.SectorNumber, TipSetToken) (bool, error) StateMinerActiveSectors(context.Context, address.Address, TipSetToken) (bitfield.BitField, error) @@ -82,7 +84,7 @@ type SealingAPI interface { type SectorStateNotifee func(before, after SectorInfo) -type AddrSel func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) +type AddrSel func(ctx context.Context, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) type Sealing struct { Api SealingAPI @@ -269,7 +271,7 @@ func (m *Sealing) currentSealProof(ctx context.Context) (abi.RegisteredSealProof return 0, err } - return miner.PreferredSealProofTypeFromWindowPoStType(ver, mi.WindowPoStProofType) + return lminer.PreferredSealProofTypeFromWindowPoStType(ver, mi.WindowPoStProofType) } func (m *Sealing) minerSector(spt abi.RegisteredSealProof, num abi.SectorNumber) storage.SectorRef { diff --git a/extern/storage-sealing/states_failed.go b/extern/storage-sealing/states_failed.go index 2a6d50ccf..c94752552 100644 --- a/extern/storage-sealing/states_failed.go +++ b/extern/storage-sealing/states_failed.go @@ -8,8 +8,8 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/market" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/exitcode" @@ -455,7 +455,7 @@ func (m *Sealing) handleRecoverDealIDsOrFailWith(ctx statemachine.Context, secto var dp *market.DealProposal if p.DealInfo.DealProposal != nil { - mdp := market.DealProposal(*p.DealInfo.DealProposal) + mdp := *p.DealInfo.DealProposal dp = &mdp } res, err := m.DealInfo.GetCurrentDealInfo(ctx.Context(), tok, dp, *p.DealInfo.PublishCid) diff --git a/extern/storage-sealing/states_replica_update.go b/extern/storage-sealing/states_replica_update.go index ff6302599..186997553 100644 --- a/extern/storage-sealing/states_replica_update.go +++ b/extern/storage-sealing/states_replica_update.go @@ -7,10 +7,11 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/exitcode" statemachine "github.com/filecoin-project/go-statemachine" api "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "golang.org/x/xerrors" ) @@ -168,7 +169,7 @@ func (m *Sealing) handleSubmitReplicaUpdate(ctx statemachine.Context, sector Sec log.Errorf("no good address to send replica update message from: %+v", err) return ctx.Send(SectorSubmitReplicaUpdateFailed{}) } - mcid, err := m.Api.SendMsg(ctx.Context(), from, m.maddr, miner.Methods.ProveReplicaUpdates, collateral, big.Int(m.feeCfg.MaxCommitGasFee), enc.Bytes()) + mcid, err := m.Api.SendMsg(ctx.Context(), from, m.maddr, builtin.MethodsMiner.ProveReplicaUpdates, collateral, big.Int(m.feeCfg.MaxCommitGasFee), enc.Bytes()) if err != nil { log.Errorf("handleSubmitReplicaUpdate: error sending message: %+v", err) return ctx.Send(SectorSubmitReplicaUpdateFailed{}) diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index d20bbf696..384484c38 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -4,6 +4,8 @@ import ( "bytes" "context" + "github.com/filecoin-project/go-state-types/proof" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -14,12 +16,12 @@ import ( "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-statemachine" - "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/filecoin-project/specs-storage/storage" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" ) @@ -29,7 +31,7 @@ var MaxTicketAge = policy.MaxPreCommitRandomnessLookback func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) error { m.inputLk.Lock() - // make sure we not accepting deals into this sector + // make sure we are not accepting deals into this sector for _, c := range m.assignedPieces[m.minerSectorID(sector.SectorNumber)] { pp := m.pendingPieces[c] delete(m.pendingPieces, c) @@ -410,7 +412,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf } log.Infof("submitting precommit for sector %d (deposit: %s): ", sector.SectorNumber, deposit) - mcid, err := m.Api.SendMsg(ctx.Context(), from, m.maddr, miner.Methods.PreCommitSector, deposit, big.Int(m.feeCfg.MaxPreCommitGasFee), enc.Bytes()) + mcid, err := m.Api.SendMsg(ctx.Context(), from, m.maddr, builtin.MethodsMiner.PreCommitSector, deposit, big.Int(m.feeCfg.MaxPreCommitGasFee), enc.Bytes()) if err != nil { return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)}) } @@ -670,7 +672,7 @@ func (m *Sealing) handleSubmitCommit(ctx statemachine.Context, sector SectorInfo } // TODO: check seed / ticket / deals are up to date - mcid, err := m.Api.SendMsg(ctx.Context(), from, m.maddr, miner.Methods.ProveCommitSector, collateral, big.Int(m.feeCfg.MaxCommitGasFee), enc.Bytes()) + mcid, err := m.Api.SendMsg(ctx.Context(), from, m.maddr, builtin.MethodsMiner.ProveCommitSector, collateral, big.Int(m.feeCfg.MaxCommitGasFee), enc.Bytes()) if err != nil { return ctx.Send(SectorCommitFailed{xerrors.Errorf("pushing message to mpool: %w", err)}) } diff --git a/extern/storage-sealing/terminate_batch.go b/extern/storage-sealing/terminate_batch.go index 13fa281c3..ec772680b 100644 --- a/extern/storage-sealing/terminate_batch.go +++ b/extern/storage-sealing/terminate_batch.go @@ -14,18 +14,18 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/dline" - miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/node/config" ) type TerminateBatcherApi interface { StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok TipSetToken) (*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, TipSetToken) (miner.MinerInfo, error) + StateMinerInfo(context.Context, address.Address, TipSetToken) (api.MinerInfo, error) StateMinerProvingDeadline(context.Context, address.Address, TipSetToken) (*dline.Info, error) StateMinerPartitions(ctx context.Context, m address.Address, dlIdx uint64, tok TipSetToken) ([]api.Partition, error) } @@ -119,7 +119,7 @@ func (b *TerminateBatcher) processBatch(notif, after bool) (*cid.Cid, error) { b.lk.Lock() defer b.lk.Unlock() - params := miner2.TerminateSectorsParams{} + params := miner.TerminateSectorsParams{} var total uint64 for loc, sectors := range b.todo { @@ -178,7 +178,7 @@ func (b *TerminateBatcher) processBatch(notif, after bool) (*cid.Cid, error) { total += n - params.Terminations = append(params.Terminations, miner2.TerminationDeclaration{ + params.Terminations = append(params.Terminations, miner.TerminationDeclaration{ Deadline: loc.Deadline, Partition: loc.Partition, Sectors: toTerminate, @@ -220,7 +220,7 @@ func (b *TerminateBatcher) processBatch(notif, after bool) (*cid.Cid, error) { return nil, xerrors.Errorf("no good address found: %w", err) } - mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, miner.Methods.TerminateSectors, big.Zero(), big.Int(b.feeCfg.MaxTerminateGasFee), enc.Bytes()) + mcid, err := b.api.SendMsg(b.mctx, from, b.maddr, builtin.MethodsMiner.TerminateSectors, big.Zero(), big.Int(b.feeCfg.MaxTerminateGasFee), enc.Bytes()) if err != nil { return nil, xerrors.Errorf("sending message failed: %w", err) } diff --git a/extern/storage-sealing/types.go b/extern/storage-sealing/types.go index d30d98f03..f03843f5b 100644 --- a/extern/storage-sealing/types.go +++ b/extern/storage-sealing/types.go @@ -11,8 +11,8 @@ import ( "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/specs-storage/storage" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" ) diff --git a/extern/storage-sealing/types_test.go b/extern/storage-sealing/types_test.go index 68e2b1111..ae8569717 100644 --- a/extern/storage-sealing/types_test.go +++ b/extern/storage-sealing/types_test.go @@ -4,6 +4,8 @@ import ( "bytes" "testing" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/ipfs/go-cid" "gotest.tools/assert" @@ -11,7 +13,6 @@ import ( cborutil "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-state-types/abi" api "github.com/filecoin-project/lotus/api" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" ) @@ -29,7 +30,7 @@ func TestSectorInfoSerialization(t *testing.T) { StartEpoch: 0, EndEpoch: 100, }, - DealProposal: &market2.DealProposal{ + DealProposal: &markettypes.DealProposal{ PieceCID: dummyCid, PieceSize: 5, Client: tutils.NewActorAddr(t, "client"), diff --git a/gateway/node.go b/gateway/node.go index d070c46ef..bf54530f0 100644 --- a/gateway/node.go +++ b/gateway/node.go @@ -76,7 +76,7 @@ type TargetAPI interface { StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) - StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) + StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error) StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) @@ -542,12 +542,12 @@ func (gw *Node) StateMinerRecoveries(ctx context.Context, m address.Address, tsk return gw.target.StateMinerRecoveries(ctx, m, tsk) } -func (gw *Node) StateMinerInfo(ctx context.Context, m address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) { +func (gw *Node) StateMinerInfo(ctx context.Context, m address.Address, tsk types.TipSetKey) (api.MinerInfo, error) { if err := gw.limit(ctx, stateRateLimitTokens); err != nil { - return miner.MinerInfo{}, err + return api.MinerInfo{}, err } if err := gw.checkTipsetKey(ctx, tsk); err != nil { - return miner.MinerInfo{}, err + return api.MinerInfo{}, err } return gw.target.StateMinerInfo(ctx, m, tsk) } diff --git a/gateway/node_test.go b/gateway/node_test.go index 36bff9945..b077d514a 100644 --- a/gateway/node_test.go +++ b/gateway/node_test.go @@ -16,7 +16,6 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/mock" ) @@ -143,7 +142,7 @@ func (m *mockGatewayDepsAPI) StateMarketStorageDeal(ctx context.Context, dealId panic("implement me") } -func (m *mockGatewayDepsAPI) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) { +func (m *mockGatewayDepsAPI) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error) { panic("implement me") } diff --git a/gen/inlinegen-data.json b/gen/inlinegen-data.json index ef97db651..8b8081ac4 100644 --- a/gen/inlinegen-data.json +++ b/gen/inlinegen-data.json @@ -1,7 +1,7 @@ { - "actorVersions": [0, 2, 3, 4, 5, 6, 7], - "latestActorsVersion": 7, + "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8], + "latestActorsVersion": 8, - "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], - "latestNetworkVersion": 15 + "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], + "latestNetworkVersion": 16 } diff --git a/genesis/types.go b/genesis/types.go index d4c04113a..1a4bbec41 100644 --- a/genesis/types.go +++ b/genesis/types.go @@ -3,14 +3,14 @@ package genesis import ( "encoding/json" - "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/wallet" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/go-state-types/network" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/peer" - - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" ) type ActorType string @@ -21,11 +21,12 @@ const ( ) type PreSeal struct { - CommR cid.Cid - CommD cid.Cid - SectorID abi.SectorNumber - Deal market2.DealProposal - ProofType abi.RegisteredSealProof + CommR cid.Cid + CommD cid.Cid + SectorID abi.SectorNumber + Deal market8.DealProposal + DealClientKey *wallet.Key + ProofType abi.RegisteredSealProof } type Miner struct { diff --git a/go.mod b/go.mod index ba8b02603..28004eab0 100644 --- a/go.mod +++ b/go.mod @@ -36,25 +36,26 @@ require ( github.com/filecoin-project/go-data-transfer v1.15.1 github.com/filecoin-project/go-fil-commcid v0.1.0 github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 - github.com/filecoin-project/go-fil-markets v1.20.1 + github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 github.com/filecoin-project/go-jsonrpc v0.1.5 - github.com/filecoin-project/go-legs v0.3.7 + github.com/filecoin-project/go-legs v0.3.10 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.1.4 + github.com/filecoin-project/go-state-types v0.1.7 github.com/filecoin-project/go-statemachine v1.0.2 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 github.com/filecoin-project/index-provider v0.5.0 github.com/filecoin-project/pubsub v1.0.0 - github.com/filecoin-project/specs-actors v0.9.14 + github.com/filecoin-project/specs-actors v0.9.15 github.com/filecoin-project/specs-actors/v2 v2.3.6 - github.com/filecoin-project/specs-actors/v3 v3.1.1 - github.com/filecoin-project/specs-actors/v4 v4.0.1 - github.com/filecoin-project/specs-actors/v5 v5.0.4 - github.com/filecoin-project/specs-actors/v6 v6.0.1 - github.com/filecoin-project/specs-actors/v7 v7.0.0 - github.com/filecoin-project/specs-storage v0.2.3-0.20220426183226-1a0a63c5990f + github.com/filecoin-project/specs-actors/v3 v3.1.2 + github.com/filecoin-project/specs-actors/v4 v4.0.2 + github.com/filecoin-project/specs-actors/v5 v5.0.6 + github.com/filecoin-project/specs-actors/v6 v6.0.2 + github.com/filecoin-project/specs-actors/v7 v7.0.1 + github.com/filecoin-project/specs-actors/v8 v8.0.0 + github.com/filecoin-project/specs-storage v0.4.1 github.com/filecoin-project/test-vectors/schema v0.0.5 github.com/gbrlsnchs/jwt/v3 v3.0.1 github.com/gdamore/tcell/v2 v2.2.0 @@ -109,7 +110,7 @@ require ( github.com/koalacxr/quantile v0.0.1 github.com/libp2p/go-buffer-pool v0.0.2 github.com/libp2p/go-eventbus v0.2.1 - github.com/libp2p/go-libp2p v0.19.3 + github.com/libp2p/go-libp2p v0.19.4 github.com/libp2p/go-libp2p-connmgr v0.3.1 github.com/libp2p/go-libp2p-core v0.15.1 github.com/libp2p/go-libp2p-discovery v0.6.0 @@ -276,7 +277,7 @@ require ( github.com/libp2p/go-stream-muxer-multistream v0.4.0 // indirect github.com/libp2p/go-tcp-transport v0.5.1 // indirect github.com/libp2p/go-ws-transport v0.6.0 // indirect - github.com/libp2p/go-yamux/v3 v3.1.1 // indirect + github.com/libp2p/go-yamux/v3 v3.1.2 // indirect github.com/lucas-clemente/quic-go v0.27.1 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/magefile/mage v1.9.0 // indirect @@ -310,7 +311,6 @@ require ( github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/prometheus/statsd_exporter v0.21.0 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rivo/uniseg v0.1.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect @@ -319,7 +319,6 @@ require ( github.com/sirupsen/logrus v1.8.1 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/tj/go-spin v1.1.0 // indirect github.com/uber/jaeger-client-go v2.25.0+incompatible // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.0.1 // indirect @@ -327,8 +326,6 @@ require ( github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect - github.com/xlab/c-for-go v0.0.0-20201112171043-ea6dce5809cb // indirect - github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 // indirect github.com/zondax/hid v0.9.0 // indirect github.com/zondax/ledger-go v0.12.1 // indirect go.opentelemetry.io/otel/metric v0.25.0 // indirect @@ -350,11 +347,6 @@ require ( gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect lukechampine.com/blake3 v1.1.7 // indirect - modernc.org/cc v1.0.0 // indirect - modernc.org/golex v1.0.1 // indirect - modernc.org/mathutil v1.1.1 // indirect - modernc.org/strutil v1.1.0 // indirect - modernc.org/xc v1.0.0 // indirect ) replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi diff --git a/go.sum b/go.sum index 80daa30a7..c13f587f9 100644 --- a/go.sum +++ b/go.sum @@ -343,8 +343,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.20.1 h1:DwrFuNIWC0a2c2ESpHtdEMH3QCpR/hoZ5DwjNT+VJ+E= -github.com/filecoin-project/go-fil-markets v1.20.1/go.mod h1:QV767KIWHrikVK8R0u2wTc5wkee4gXOf5/AfxDoQckw= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 h1:/eZXwVg2Z7qPwTBUAinA7m6w6rLYBeSvE61XW8MTV5M= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-1/go.mod h1:QHJZVEbQ7TydJ6hjK87q4MxOmRfDNbQkuSkdjxtqBWo= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= @@ -355,8 +355,9 @@ github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBw github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY= github.com/filecoin-project/go-jsonrpc v0.1.5 h1:ckxqZ09ivBAVf5CSmxxrqqNHC7PJm3GYGtYKiNQ+vGk= github.com/filecoin-project/go-jsonrpc v0.1.5/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4= -github.com/filecoin-project/go-legs v0.3.7 h1:yfm7fx+iy1nPtgPEQ6kQjvhoJOVbXide50STYdy+yos= github.com/filecoin-project/go-legs v0.3.7/go.mod h1:pgekGm8/gKY5zCtQ/qGAoSjGP92wTLFqpO3GPHeu8YU= +github.com/filecoin-project/go-legs v0.3.10 h1:B14z78do63gkxf5Br7rPnxZsZk/m9PR3Mx5aOf2WTIs= +github.com/filecoin-project/go-legs v0.3.10/go.mod h1:5psVRe2nRQDa3PDtcd+2Ud4CirxOr2DI5VsDVMq7sIk= github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20/go.mod h1:mPn+LRRd5gEKNAtc+r3ScpW2JRU/pj4NBKdADYWHiak= github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6XHig+ynSGJg8ZOs= github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ= @@ -367,12 +368,13 @@ github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.1-0.20210810190654-139e0e79e69e/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= -github.com/filecoin-project/go-state-types v0.1.1/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.3/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= -github.com/filecoin-project/go-state-types v0.1.4 h1:NU0veVNxtDiLD/eRyKHV9lv3njSzfTh/sJGxxvcYcpg= github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg= +github.com/filecoin-project/go-state-types v0.1.5/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.7 h1:r/ZzyUA+CqY8IXyHsLtliqRgPFaON+aC2MmWKm1nl98= +github.com/filecoin-project/go-state-types v0.1.7/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= -github.com/filecoin-project/go-statemachine v1.0.1/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= @@ -386,27 +388,33 @@ github.com/filecoin-project/index-provider v0.5.0/go.mod h1:KHVrP2vU3YuScb+fawOb github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= -github.com/filecoin-project/specs-actors v0.9.14 h1:68PVstg2UB3ZsMLF+DKFTAs/YKsqhKWynkr0IqmVRQY= -github.com/filecoin-project/specs-actors v0.9.14/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= +github.com/filecoin-project/specs-actors v0.9.15-0.20220514164640-94e0d5e123bd/go.mod h1:pjGEe3QlWtK20ju/aFRsiArbMX6Cn8rqEhhsiCM9xYE= +github.com/filecoin-project/specs-actors v0.9.15 h1:3VpKP5/KaDUHQKAMOg4s35g/syDaEBueKLws0vbsjMc= +github.com/filecoin-project/specs-actors v0.9.15/go.mod h1:pjGEe3QlWtK20ju/aFRsiArbMX6Cn8rqEhhsiCM9xYE= github.com/filecoin-project/specs-actors/v2 v2.3.5-0.20210114162132-5b58b773f4fb/go.mod h1:LljnY2Mn2homxZsmokJZCpRuhOPxfXhvcek5gWkmqAc= github.com/filecoin-project/specs-actors/v2 v2.3.6 h1:UxnWTfQd7JsOae39/aHCK0m1IBjdcyymCJfqxuSkn+g= github.com/filecoin-project/specs-actors/v2 v2.3.6/go.mod h1:DJMpxVRXvev9t8P0XWA26RmTzN+MHiL9IlItVLT0zUc= github.com/filecoin-project/specs-actors/v3 v3.1.0/go.mod h1:mpynccOLlIRy0QnR008BwYBwT9fen+sPR13MA1VmMww= -github.com/filecoin-project/specs-actors/v3 v3.1.1 h1:BE8fsns1GnEOxt1DTE5LxBK2FThXtWmCChgcJoHTg0E= -github.com/filecoin-project/specs-actors/v3 v3.1.1/go.mod h1:mpynccOLlIRy0QnR008BwYBwT9fen+sPR13MA1VmMww= +github.com/filecoin-project/specs-actors/v3 v3.1.2 h1:Gq3gAbvdGLA/D0GKz1IJfewt9Fh7gA32TPt46Xv+1Cw= +github.com/filecoin-project/specs-actors/v3 v3.1.2/go.mod h1:uOJn+m6W8OW/1mdWMEvxeM1cjQPxmps7s1Z4bJ9V4kY= github.com/filecoin-project/specs-actors/v4 v4.0.0/go.mod h1:TkHXf/l7Wyw4ZejyXIPS2rK8bBO0rdwhTZyQQgaglng= -github.com/filecoin-project/specs-actors/v4 v4.0.1 h1:AiWrtvJZ63MHGe6rn7tPu4nSUY8bA1KDNszqJaD5+Fg= -github.com/filecoin-project/specs-actors/v4 v4.0.1/go.mod h1:TkHXf/l7Wyw4ZejyXIPS2rK8bBO0rdwhTZyQQgaglng= -github.com/filecoin-project/specs-actors/v5 v5.0.4 h1:OY7BdxJWlUfUFXWV/kpNBYGXNPasDIedf42T3sGx08s= +github.com/filecoin-project/specs-actors/v4 v4.0.2 h1:VTsv30kIf1Keo8Jlu6Omco+2Ud0pG4EN5UAzyYCibh8= +github.com/filecoin-project/specs-actors/v4 v4.0.2/go.mod h1:zT0GVFxwFS93prGK0b/rMd1sePjRQKfAuodQ9DFAd6Y= github.com/filecoin-project/specs-actors/v5 v5.0.4/go.mod h1:5BAKRAMsOOlD8+qCw4UvT/lTLInCJ3JwOWZbX8Ipwq4= +github.com/filecoin-project/specs-actors/v5 v5.0.5/go.mod h1:dnfda2U+0ZidVnZJ44fnLMa3Mbyzwx51iW/brSsS+nc= +github.com/filecoin-project/specs-actors/v5 v5.0.6 h1:TLtA9hT3pHQF5vB83GmB+m6anw9u6MjdT+VVn/lyC+c= +github.com/filecoin-project/specs-actors/v5 v5.0.6/go.mod h1:myb/UGwESp0V1f1BACXSUrFgTWLvGUoG0ZZH7eqriFM= github.com/filecoin-project/specs-actors/v6 v6.0.0/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk= -github.com/filecoin-project/specs-actors/v6 v6.0.1 h1:laxvHNsvrq83Y9n+W7znVCePi3oLyRf0Rkl4jFO8Wew= github.com/filecoin-project/specs-actors/v6 v6.0.1/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk= -github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1.0.20220118005651-2470cb39827e/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= -github.com/filecoin-project/specs-actors/v7 v7.0.0 h1:FQN7tjt3o68hfb3qLFSJBoLMuOFY0REkFVLO/zXj8RU= +github.com/filecoin-project/specs-actors/v6 v6.0.2 h1:K1xPRJoW5PBvb08QF9+4w1AjcnqwR6BjTmeltQFCvWo= +github.com/filecoin-project/specs-actors/v6 v6.0.2/go.mod h1:wnfVvPnYmzPZilNvSqCSSA/ZQX3rdV/U/Vf9EIoQhrI= github.com/filecoin-project/specs-actors/v7 v7.0.0/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= -github.com/filecoin-project/specs-storage v0.2.3-0.20220426183226-1a0a63c5990f h1:+suJFu4RJt7aZRXvE+Innrpacap+Z8N87y6a1Cgkuqc= -github.com/filecoin-project/specs-storage v0.2.3-0.20220426183226-1a0a63c5990f/go.mod h1:6cc/lncmAxMUocPi0z1EPCX63beIX7F7UnlmUZ3hLQo= +github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt2EPHN8oiwpA1Ay3/4= +github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= +github.com/filecoin-project/specs-actors/v8 v8.0.0 h1:c6NztoE4J5j7KvIfGmx9XW9o5aszPl6DU0M4xDqAJVU= +github.com/filecoin-project/specs-actors/v8 v8.0.0/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= +github.com/filecoin-project/specs-storage v0.4.1 h1:yvLEaLZj8f+uByhNC4mFOtCUyL2wQku+NGBp6hjTe9M= +github.com/filecoin-project/specs-storage v0.4.1/go.mod h1:Z2eK6uMwAOSLjek6+sy0jNV2DSsMEENziMUz0GHRFBw= github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q= github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI= github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg= @@ -1087,8 +1095,9 @@ github.com/libp2p/go-libp2p v0.16.0/go.mod h1:ump42BsirwAWxKzsCiFnTtN1Yc+DuPu76f github.com/libp2p/go-libp2p v0.17.0/go.mod h1:Fkin50rsGdv5mm5BshBUtPRZknt9esfmYXBOYcwOTgw= github.com/libp2p/go-libp2p v0.18.0-rc1/go.mod h1:RgYlH7IIWHXREimC92bw5Lg1V2R5XmSzuLHb5fTnr+8= github.com/libp2p/go-libp2p v0.18.0-rc3/go.mod h1:WYL+Xw1iuwi6rdfzw5VIEpD+HqzYucHZ6fcUuumbI3M= -github.com/libp2p/go-libp2p v0.19.3 h1:LqjvuBWdyYSqvkH4VVYxA78Fkphzg2Pq86VMnilqgkw= -github.com/libp2p/go-libp2p v0.19.3/go.mod h1:AGlPVLjh0+6jvEtf+a2gZEux7yHJrYXnG9IC7wcQ2NY= +github.com/libp2p/go-libp2p v0.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI= +github.com/libp2p/go-libp2p v0.19.4 h1:50YL0YwPhWKDd+qbZQDEdnsmVAAkaCQrWUjpdHv4hNA= +github.com/libp2p/go-libp2p v0.19.4/go.mod h1:MIt8y481VDhUe4ErWi1a4bvt/CjjFfOq6kZTothWIXY= github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo= github.com/libp2p/go-libp2p-asn-util v0.1.0 h1:rABPCO77SjdbJ/eJ/ynIo8vWICy1VEnL5JAxJbQLo1E= github.com/libp2p/go-libp2p-asn-util v0.1.0/go.mod h1:wu+AnM9Ii2KgO5jMmS1rz9dvzTdj8BXqsPR9HR0XB7I= @@ -1253,6 +1262,7 @@ github.com/libp2p/go-libp2p-quic-transport v0.13.0/go.mod h1:39/ZWJ1TW/jx1iFkKzz github.com/libp2p/go-libp2p-quic-transport v0.15.0/go.mod h1:wv4uGwjcqe8Mhjj7N/Ic0aKjA+/10UnMlSzLO0yRpYQ= github.com/libp2p/go-libp2p-quic-transport v0.15.2/go.mod h1:wv4uGwjcqe8Mhjj7N/Ic0aKjA+/10UnMlSzLO0yRpYQ= github.com/libp2p/go-libp2p-quic-transport v0.16.0/go.mod h1:1BXjVMzr+w7EkPfiHkKnwsWjPjtfaNT0q8RS3tGDvEQ= +github.com/libp2p/go-libp2p-quic-transport v0.16.1/go.mod h1:1BXjVMzr+w7EkPfiHkKnwsWjPjtfaNT0q8RS3tGDvEQ= github.com/libp2p/go-libp2p-quic-transport v0.17.0 h1:yFh4Gf5MlToAYLuw/dRvuzYd1EnE2pX3Lq1N6KDiWRQ= github.com/libp2p/go-libp2p-quic-transport v0.17.0/go.mod h1:x4pw61P3/GRCcSLypcQJE/Q2+E9f4X+5aRcZLXf20LM= github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= @@ -1346,6 +1356,7 @@ github.com/libp2p/go-libp2p-yamux v0.6.0/go.mod h1:MRhd6mAYnFRnSISp4M8i0ClV/j+mW github.com/libp2p/go-libp2p-yamux v0.7.0/go.mod h1:fMyA0CsPfHkIuBU0wjRGrCjTBFiXTXxG0k5M4ETv+08= github.com/libp2p/go-libp2p-yamux v0.8.0/go.mod h1:yTkPgN2ib8FHyU1ZcVD7aelzyAqXXwEPbyx+aSKm9h8= github.com/libp2p/go-libp2p-yamux v0.8.1/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE= +github.com/libp2p/go-libp2p-yamux v0.8.2/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE= github.com/libp2p/go-libp2p-yamux v0.9.1 h1:oplewiRix8s45SOrI30rCPZG5mM087YZp+VYhXAh4+c= github.com/libp2p/go-libp2p-yamux v0.9.1/go.mod h1:wRc6wvyxQINFcKe7daL4BeQ02Iyp+wxyC8WCNfngBrA= github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= @@ -1448,8 +1459,9 @@ github.com/libp2p/go-yamux/v2 v2.2.0/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZj github.com/libp2p/go-yamux/v2 v2.3.0/go.mod h1:iTU+lOIn/2h0AgKcL49clNTwfEw+WSfDYrXe05EyKIs= github.com/libp2p/go-yamux/v3 v3.0.1/go.mod h1:s2LsDhHbh+RfCsQoICSYt58U2f8ijtPANFD8BmE74Bo= github.com/libp2p/go-yamux/v3 v3.0.2/go.mod h1:s2LsDhHbh+RfCsQoICSYt58U2f8ijtPANFD8BmE74Bo= -github.com/libp2p/go-yamux/v3 v3.1.1 h1:X0qSVodCZciOu/f4KTp9V+O0LAqcqP2tdaUGB0+0lng= github.com/libp2p/go-yamux/v3 v3.1.1/go.mod h1:jeLEQgLXqE2YqX1ilAClIfCMDY+0uXQUKmmb/qp0gT4= +github.com/libp2p/go-yamux/v3 v3.1.2 h1:lNEy28MBk1HavUAlzKgShp+F6mn/ea1nDYWftZhFW9Q= +github.com/libp2p/go-yamux/v3 v3.1.2/go.mod h1:jeLEQgLXqE2YqX1ilAClIfCMDY+0uXQUKmmb/qp0gT4= github.com/libp2p/zeroconf/v2 v2.1.1/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= @@ -1809,8 +1821,6 @@ github.com/raulk/clock v1.1.0/go.mod h1:3MpVxdZ/ODBQDxbN+kzshf5OSZwPjtMDx6BBXBmO github.com/raulk/go-watchdog v1.2.0 h1:konN75pw2BMmZ+AfuAm5rtFsWcJpKF3m02rKituuXNo= github.com/raulk/go-watchdog v1.2.0/go.mod h1:lzSbAl5sh4rtI8tYHU01BWIDzgzqaQLj6RcA1i4mlqI= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -1924,8 +1934,6 @@ github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= -github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= @@ -1982,7 +1990,6 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20210713220151-be142a5ae1a8/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220224212727-7a699437a831/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799 h1:DOOT2B85S0tHoLGTzV+FakaSSihgRCVwZkjqKQP5L/w= @@ -2007,10 +2014,6 @@ github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee h1:lYbXeSv github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee/go.mod h1:m2aV4LZI4Aez7dP5PMyVKEHhUyEJ/RjmPEDOpDvudHg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xlab/c-for-go v0.0.0-20201112171043-ea6dce5809cb h1:/7/dQyiKnxAOj9L69FhST7uMe17U015XPzX7cy+5ykM= -github.com/xlab/c-for-go v0.0.0-20201112171043-ea6dce5809cb/go.mod h1:pbNsDSxn1ICiNn9Ct4ZGNrwzfkkwYbx/lw8VuyutFIg= -github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 h1:Sw125DKxZhPUI4JLlWugkzsrlB50jR9v2khiD9FxuSo= -github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245/go.mod h1:C+diUUz7pxhNY6KAoLgrTYARGWnt82zWTylZlxT92vk= github.com/xorcare/golden v0.6.0/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/U6FtvQ= github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542 h1:oWgZJmC1DorFZDpfMfWg7xk29yEOZiXmo/wZl+utTI8= github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/U6FtvQ= @@ -2172,7 +2175,6 @@ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrb golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2495,7 +2497,6 @@ golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200711155855-7342f9734a7d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -2680,20 +2681,6 @@ howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCU lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= -modernc.org/cc v1.0.0 h1:nPibNuDEx6tvYrUAtvDTTw98rx5juGsa5zuDnKwEEQQ= -modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= -modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8= -modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= -modernc.org/golex v1.0.1 h1:EYKY1a3wStt0RzHaH8mdSRNg78Ub0OHxYfCRWw35YtM= -modernc.org/golex v1.0.1/go.mod h1:QCA53QtsT1NdGkaZZkF5ezFwk4IXh4BGNafAARTC254= -modernc.org/lex v1.0.0/go.mod h1:G6rxMTy3cH2iA0iXL/HRRv4Znu8MK4higxph/lE7ypk= -modernc.org/lexer v1.0.0/go.mod h1:F/Dld0YKYdZCLQ7bD0USbWL4YKCyTDRDHiDTOs0q0vk= -modernc.org/mathutil v1.1.1 h1:FeylZSVX8S+58VsyJlkEj2bcpdytmp9MmDKZkKx8OIE= -modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc= -modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= -modernc.org/xc v1.0.0 h1:7ccXrupWZIS3twbUGrtKmHS2DXY6xegFua+6O3xgAFU= -modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/itests/deadlines_test.go b/itests/deadlines_test.go index f0abdb556..2b6d94143 100644 --- a/itests/deadlines_test.go +++ b/itests/deadlines_test.go @@ -7,6 +7,9 @@ import ( "testing" "time" + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" @@ -238,7 +241,7 @@ func TestDeadlineToggling(t *testing.T) { cr, err := cid.Parse("bagboea4b5abcatlxechwbp7kjpjguna6r6q7ejrhe6mdp3lf34pmswn27pkkiekz") require.NoError(t, err) - params := &miner.SectorPreCommitInfo{ + params := &minertypes.SectorPreCommitInfo{ Expiration: 2880 * 300, SectorNumber: 22, SealProof: kit.TestSpt, @@ -254,7 +257,7 @@ func TestDeadlineToggling(t *testing.T) { To: maddrE, From: defaultFrom, Value: types.FromFil(1), - Method: miner.Methods.PreCommitSector, + Method: builtin.MethodsMiner.PreCommitSector, Params: enc.Bytes(), }, nil) require.NoError(t, err) @@ -335,7 +338,7 @@ func TestDeadlineToggling(t *testing.T) { smsg, err := client.MpoolPushMessage(ctx, &types.Message{ From: defaultFrom, To: maddrD, - Method: miner.Methods.TerminateSectors, + Method: builtin.MethodsMiner.TerminateSectors, Value: big.Zero(), Params: sp, diff --git a/itests/deals_anycid_test.go b/itests/deals_anycid_test.go index 8e061af29..f504ead86 100644 --- a/itests/deals_anycid_test.go +++ b/itests/deals_anycid_test.go @@ -32,7 +32,7 @@ func TestDealRetrieveByAnyCid(t *testing.T) { ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) }) diff --git a/itests/deals_concurrent_test.go b/itests/deals_concurrent_test.go index 015cf03a1..53aa0c782 100644 --- a/itests/deals_concurrent_test.go +++ b/itests/deals_concurrent_test.go @@ -40,7 +40,7 @@ func TestDealWithMarketAndMinerNode(t *testing.T) { kit.QuietMiningLogs() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) }) @@ -92,7 +92,7 @@ func TestDealCyclesConcurrent(t *testing.T) { } oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) }) @@ -143,7 +143,7 @@ func TestSimultanenousTransferLimit(t *testing.T) { kit.QuietMiningLogs() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) }) diff --git a/itests/deals_invalid_utf8_label_test.go b/itests/deals_invalid_utf8_label_test.go new file mode 100644 index 000000000..7a4e79150 --- /dev/null +++ b/itests/deals_invalid_utf8_label_test.go @@ -0,0 +1,78 @@ +package itests + +import ( + "context" + "encoding/hex" + "testing" + "time" + + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/itests/kit" + "github.com/stretchr/testify/require" +) + +// The following function will generate and print out the hex encoding of PublishStorageDealsParams with a dealLabel with invalid utf8 encoding. +// This is not possible with our current code structure, so this was run with a modified NewLabelFromString() function in go-state-types +// The result is recorded in the function below for submission. +//func generateInvalidDealProposal(t *testing.T) { +// ctx := context.Background() +// +// kit.QuietMiningLogs() +// +// client16, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version16)) +// ens.InterconnectAll().BeginMining(10 * time.Millisecond) +// +// dealLabel, err := market.NewLabelFromString(string([]byte{0xde, 0xad, 0xbe, 0xef})) +// require.NoError(t, err) +// +// dummyCid, err := cid.Parse("bafkqaaa") +// require.NoError(t, err) +// +// proposal := market.DealProposal{ +// PieceCID: dummyCid, +// Client: client16.DefaultKey.Address, +// Provider: client16.DefaultKey.Address, +// Label: dealLabel, +// } +// +// proposalBytes := new(bytes.Buffer) +// err = proposal.MarshalCBOR(proposalBytes) +// require.NoError(t, err) +// +// signature, err := client16.WalletSign(ctx, client16.DefaultKey.Address, proposalBytes.Bytes()) +// require.NoError(t, err) +// +// params, err := actors.SerializeParams(&market.PublishStorageDealsParams{ +// Deals: []market.ClientDealProposal{{ +// Proposal: proposal, +// ClientSignature: *signature, +// }}, +// }) +// require.NoError(t, err) +// +// fmt.Println(hex.EncodeToString(params)) +//} + +func TestSubmitInvalidDealLabel(t *testing.T) { + ctx := context.Background() + + kit.QuietMiningLogs() + + client16, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version16)) + ens.InterconnectAll().BeginMining(10 * time.Millisecond) + + // This hex string is generated by using the commented function above. + serializedParams, err := hex.DecodeString("8181828bd82a45000155000000f458310394345a1393a5665772ae97456fdc00cf8f537960eeb3838c297da0d60546252d98469cc68b56eb45081e5c959c8cf4fa58310394345a1393a5665772ae97456fdc00cf8f537960eeb3838c297da0d60546252d98469cc68b56eb45081e5c959c8cf4fa64deadbeef00004040405861029927585cf250656cb3ddf337aed516e6393829389e52c45a4fbbe297b8ad3b7a008b3675a5b5c4df43657ff53bcb6c670b4bd83911867ba90b2b14da856a0ecb36782a7d87232272e3b9cd98dd959b2851602fea30c414a4dc1ea12057d31f81") + require.NoError(t, err) + + _, err = client16.MpoolPushMessage(ctx, &types.Message{ + To: builtin.StorageMarketActorAddr, + From: client16.DefaultKey.Address, + Value: types.NewInt(0), + Method: builtin.MethodsMarket.PublishStorageDeals, + Params: serializedParams, + }, nil) + require.Contains(t, err.Error(), "Serialization error for Cbor protocol: InvalidUtf8") +} diff --git a/itests/deals_padding_test.go b/itests/deals_padding_test.go index c79b6a7db..9ac736f8c 100644 --- a/itests/deals_padding_test.go +++ b/itests/deals_padding_test.go @@ -26,7 +26,7 @@ func TestDealPadding(t *testing.T) { var blockTime = 250 * time.Millisecond startEpoch := abi.ChainEpoch(2 << 12) - policy.SetPreCommitChallengeDelay(2) + policy.SetPreCommitChallengeDelay(10) client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.WithAllSubsystems()) // no mock proofs. ens.InterconnectAll().BeginMining(blockTime) diff --git a/itests/deals_partial_retrieval_dm-level_test.go b/itests/deals_partial_retrieval_dm-level_test.go index 4b1a5b0e3..7cb1d9b77 100644 --- a/itests/deals_partial_retrieval_dm-level_test.go +++ b/itests/deals_partial_retrieval_dm-level_test.go @@ -46,7 +46,7 @@ func TestDMLevelPartialRetrieval(t *testing.T) { //stm: @CLIENT_RETRIEVAL_RETRIEVE_001, @CLIENT_RETRIEVAL_FIND_001 ctx := context.Background() - policy.SetPreCommitChallengeDelay(2) + policy.SetPreCommitChallengeDelay(10) kit.QuietMiningLogs() client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.MockProofs()) dh := kit.NewDealHarness(t, client, miner, miner) diff --git a/itests/deals_partial_retrieval_test.go b/itests/deals_partial_retrieval_test.go index abc5cf411..5e7f073f0 100644 --- a/itests/deals_partial_retrieval_test.go +++ b/itests/deals_partial_retrieval_test.go @@ -48,7 +48,7 @@ func TestPartialRetrieval(t *testing.T) { //stm: @CLIENT_RETRIEVAL_RETRIEVE_001 ctx := context.Background() - policy.SetPreCommitChallengeDelay(2) + policy.SetPreCommitChallengeDelay(10) kit.EnableLargeSectors(t) kit.QuietMiningLogs() client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.MockProofs(), kit.SectorSize(512<<20)) diff --git a/itests/deals_retry_deal_no_funds_test.go b/itests/deals_retry_deal_no_funds_test.go index a14a0d085..3abd82053 100644 --- a/itests/deals_retry_deal_no_funds_test.go +++ b/itests/deals_retry_deal_no_funds_test.go @@ -36,7 +36,7 @@ func TestDealsRetryLackOfFunds(t *testing.T) { //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) @@ -120,7 +120,7 @@ func TestDealsRetryLackOfFunds_blockInPublishDeal(t *testing.T) { //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) @@ -201,7 +201,7 @@ func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) { //stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001 ctx := context.Background() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) @@ -261,7 +261,7 @@ func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) { dp.EpochPrice = abi.NewTokenAmount(62500000) // minimum asking price. deal := dh.StartDeal(ctx, dp) - err = dh.ExpectDealFailure(ctx, deal, "actor balance less than needed") + err = dh.ExpectDealFailure(ctx, deal, "Actor balance less than needed") if err != nil { t.Fatal(err) } diff --git a/itests/deals_test.go b/itests/deals_test.go index fb8e6e4f3..c7a2b2ad1 100644 --- a/itests/deals_test.go +++ b/itests/deals_test.go @@ -23,7 +23,7 @@ func TestDealsWithSealingAndRPC(t *testing.T) { kit.QuietMiningLogs() oldDelay := policy.GetPreCommitChallengeDelay() - policy.SetPreCommitChallengeDelay(5) + policy.SetPreCommitChallengeDelay(10) t.Cleanup(func() { policy.SetPreCommitChallengeDelay(oldDelay) }) diff --git a/itests/kit/blockminer.go b/itests/kit/blockminer.go index 03f5d6e34..aa1658dfe 100644 --- a/itests/kit/blockminer.go +++ b/itests/kit/blockminer.go @@ -9,11 +9,13 @@ import ( "testing" "time" + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/api" - aminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/miner" "github.com/stretchr/testify/require" @@ -72,10 +74,10 @@ func (p *partitionTracker) recordIfPost(t *testing.T, bm *BlockMiner, msg *types if !(msg.To == bm.miner.ActorAddr) { return } - if msg.Method != aminer.Methods.SubmitWindowedPoSt { + if msg.Method != builtin.MethodsMiner.SubmitWindowedPoSt { return } - params := aminer.SubmitWindowedPoStParams{} + params := minertypes.SubmitWindowedPoStParams{} require.NoError(t, params.UnmarshalCBOR(bytes.NewReader(msg.Params))) for _, part := range params.Partitions { p.posted.Set(part.Index) diff --git a/itests/kit/control.go b/itests/kit/control.go index 73ac39b7a..e1954c56c 100644 --- a/itests/kit/control.go +++ b/itests/kit/control.go @@ -3,6 +3,8 @@ package kit import ( "context" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/stretchr/testify/require" addr "github.com/filecoin-project/go-address" @@ -10,7 +12,6 @@ import ( miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) @@ -31,7 +32,7 @@ func (tm *TestMiner) SetControlAddresses(addrs ...addr.Address) { smsg, err := tm.FullNode.MpoolPushMessage(ctx, &types.Message{ From: mi.Owner, To: tm.ActorAddr, - Method: miner.Methods.ChangeWorkerAddress, + Method: builtin.MethodsMiner.ChangeWorkerAddress, Value: big.Zero(), Params: sp, diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index 0de06bd67..f9129a61e 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -12,6 +12,8 @@ import ( "testing" "time" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/namespace" libp2pcrypto "github.com/libp2p/go-libp2p-core/crypto" @@ -26,8 +28,6 @@ import ( "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-statestore" "github.com/filecoin-project/go-storedcounter" - miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" - power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" @@ -59,6 +59,8 @@ import ( testing2 "github.com/filecoin-project/lotus/node/modules/testing" "github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/storage/mockstorage" + miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" + power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power" ) func init() { @@ -406,19 +408,14 @@ func (n *Ensemble) Start() *Ensemble { // this is a miner created after genesis, so it won't have a preseal. // we need to create it on chain. - // we get the proof type for the requested sector size, for - // the current network version. - nv, err := m.FullNode.FullNode.StateNetworkVersion(ctx, types.EmptyTSK) + proofType, err := miner.WindowPoStProofTypeFromSectorSize(m.options.sectorSize) require.NoError(n.t, err) - proofType, err := miner.SealProofTypeFromSectorSize(m.options.sectorSize, nv) - require.NoError(n.t, err) - - params, aerr := actors.SerializeParams(&power2.CreateMinerParams{ - Owner: m.OwnerKey.Address, - Worker: m.OwnerKey.Address, - SealProofType: proofType, - Peer: abi.PeerID(m.Libp2p.PeerID), + params, aerr := actors.SerializeParams(&power3.CreateMinerParams{ + Owner: m.OwnerKey.Address, + Worker: m.OwnerKey.Address, + WindowPoStProofType: proofType, + Peer: abi.PeerID(m.Libp2p.PeerID), }) require.NoError(n.t, aerr) @@ -437,7 +434,7 @@ func (n *Ensemble) Start() *Ensemble { require.NoError(n.t, err) require.Equal(n.t, exitcode.Ok, mw.Receipt.ExitCode) - var retval power2.CreateMinerReturn + var retval power3.CreateMinerReturn err = retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)) require.NoError(n.t, err, "failed to create miner") @@ -449,7 +446,7 @@ func (n *Ensemble) Start() *Ensemble { msg := &types.Message{ To: m.options.mainMiner.ActorAddr, From: m.options.mainMiner.OwnerKey.Address, - Method: miner.Methods.ChangePeerID, + Method: builtin.MethodsMiner.ChangePeerID, Params: params, Value: types.NewInt(0), } @@ -560,7 +557,7 @@ func (n *Ensemble) Start() *Ensemble { msg := &types.Message{ From: m.OwnerKey.Address, To: m.ActorAddr, - Method: miner.Methods.ChangePeerID, + Method: builtin.MethodsMiner.ChangePeerID, Params: enc, Value: types.NewInt(0), } diff --git a/itests/kit/ensemble_opts_nv.go b/itests/kit/ensemble_opts_nv.go index 45ed51443..b51b82bd5 100644 --- a/itests/kit/ensemble_opts_nv.go +++ b/itests/kit/ensemble_opts_nv.go @@ -49,12 +49,12 @@ func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt { }) /* inline-gen start */ return UpgradeSchedule(stmgr.Upgrade{ - Network: network.Version14, + Network: network.Version15, Height: -1, }, stmgr.Upgrade{ - Network: network.Version15, + Network: network.Version16, Height: upgradeHeight, - Migration: filcns.UpgradeActorsV7, + Migration: filcns.UpgradeActorsV8, }) /* inline-gen end */ } diff --git a/itests/paych_api_test.go b/itests/paych_api_test.go index 19e181064..cf63f3de3 100644 --- a/itests/paych_api_test.go +++ b/itests/paych_api_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/itests/kit" @@ -171,7 +173,7 @@ func TestPaymentChannelsAPI(t *testing.T) { require.EqualValues(t, excessAmt, vouchRes.Shortfall, "Expected voucher shortfall of %d, got %d", excessAmt, vouchRes.Shortfall) // Add a voucher whose value would exceed the channel balance - vouch := &paych.SignedVoucher{ChannelAddr: channel, Amount: excessAmt, Lane: 4, Nonce: 1} + vouch := &paychtypes.SignedVoucher{ChannelAddr: channel, Amount: excessAmt, Lane: 4, Nonce: 1} vb, err := vouch.SigningBytes() require.NoError(t, err) diff --git a/itests/wdpost_dispute_test.go b/itests/wdpost_dispute_test.go index fe723a814..b1df48053 100644 --- a/itests/wdpost_dispute_test.go +++ b/itests/wdpost_dispute_test.go @@ -8,15 +8,18 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" + prooftypes "github.com/filecoin-project/go-state-types/proof" + + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - minerActor "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/itests/kit" - proof3 "github.com/filecoin-project/specs-actors/v3/actors/runtime/proof" "github.com/stretchr/testify/require" ) @@ -140,7 +143,7 @@ func TestWindowPostDispute(t *testing.T) { // OBJECTION! The good miner files a DISPUTE!!!! { - params := &minerActor.DisputeWindowedPoStParams{ + params := &minertypes.DisputeWindowedPoStParams{ Deadline: evilSectorLoc.Deadline, PoStIndex: 0, } @@ -150,7 +153,7 @@ func TestWindowPostDispute(t *testing.T) { msg := &types.Message{ To: evilMinerAddr, - Method: minerActor.Methods.DisputeWindowedPoSt, + Method: builtin.MethodsMiner.DisputeWindowedPoSt, Params: enc, Value: types.NewInt(0), From: defaultFrom, @@ -182,8 +185,8 @@ func TestWindowPostDispute(t *testing.T) { minerInfo, err := client.StateMinerInfo(ctx, evilMinerAddr, types.EmptyTSK) require.NoError(t, err) - params := &minerActor.DeclareFaultsRecoveredParams{ - Recoveries: []minerActor.RecoveryDeclaration{{ + params := &minertypes.DeclareFaultsRecoveredParams{ + Recoveries: []minertypes.RecoveryDeclaration{{ Deadline: evilSectorLoc.Deadline, Partition: evilSectorLoc.Partition, Sectors: bitfield.NewFromSet([]uint64{uint64(evilSectorNo)}), @@ -195,7 +198,7 @@ func TestWindowPostDispute(t *testing.T) { msg := &types.Message{ To: evilMinerAddr, - Method: minerActor.Methods.DeclareFaultsRecovered, + Method: builtin.MethodsMiner.DeclareFaultsRecovered, Params: enc, Value: types.FromFil(30), // repay debt. From: minerInfo.Owner, @@ -223,7 +226,8 @@ func TestWindowPostDispute(t *testing.T) { // Now try to be evil again err = submitBadProof(ctx, client, evilMiner.OwnerKey.Address, evilMinerAddr, di, evilSectorLoc.Deadline, evilSectorLoc.Partition) require.Error(t, err) - require.Contains(t, err.Error(), "message execution failed: exit 16, reason: window post failed: invalid PoSt") + require.Contains(t, err.Error(), "invalid post was submitted") + require.Contains(t, err.Error(), "(RetCode=16)") // It didn't work because we're recovering. } @@ -310,7 +314,7 @@ waitForProof: // Try to object to the proof. This should fail. { - params := &minerActor.DisputeWindowedPoStParams{ + params := &minertypes.DisputeWindowedPoStParams{ Deadline: targetDeadline, PoStIndex: 0, } @@ -320,14 +324,15 @@ waitForProof: msg := &types.Message{ To: maddr, - Method: minerActor.Methods.DisputeWindowedPoSt, + Method: builtin.MethodsMiner.DisputeWindowedPoSt, Params: enc, Value: types.NewInt(0), From: defaultFrom, } _, err := client.MpoolPushMessage(ctx, msg, nil) require.Error(t, err) - require.Contains(t, err.Error(), "failed to dispute valid post (RetCode=16)") + require.Contains(t, err.Error(), "failed to dispute valid post") + require.Contains(t, err.Error(), "(RetCode=16)") } } @@ -356,12 +361,12 @@ func submitBadProof( if err != nil { return err } - params := &minerActor.SubmitWindowedPoStParams{ + params := &minertypes.SubmitWindowedPoStParams{ ChainCommitEpoch: commEpoch, ChainCommitRand: commRand, Deadline: dlIdx, - Partitions: []minerActor.PoStPartition{{Index: partIdx}}, - Proofs: []proof3.PoStProof{{ + Partitions: []minertypes.PoStPartition{{Index: partIdx}}, + Proofs: []prooftypes.PoStProof{{ PoStProof: minerInfo.WindowPoStProofType, ProofBytes: []byte("I'm soooo very evil."), }}, @@ -374,7 +379,7 @@ func submitBadProof( msg := &types.Message{ To: maddr, - Method: minerActor.Methods.SubmitWindowedPoSt, + Method: builtin.MethodsMiner.SubmitWindowedPoSt, Params: enc, Value: types.NewInt(0), From: owner, diff --git a/lotuspond/front/src/chain/methods.json b/lotuspond/front/src/chain/methods.json index 15c04ca28..938105528 100644 --- a/lotuspond/front/src/chain/methods.json +++ b/lotuspond/front/src/chain/methods.json @@ -730,5 +730,113 @@ "UseBytes", "RestoreBytes", "RemoveVerifiedClientDataCap" + ], + "fil/8/account": [ + "Send", + "Constructor", + "PubkeyAddress" + ], + "fil/8/cron": [ + "Send", + "Constructor", + "EpochTick" + ], + "fil/8/init": [ + "Send", + "Constructor", + "Exec" + ], + "fil/8/multisig": [ + "Send", + "Constructor", + "Propose", + "Approve", + "Cancel", + "AddSigner", + "RemoveSigner", + "SwapSigner", + "ChangeNumApprovalsThreshold", + "LockBalance" + ], + "fil/8/paymentchannel": [ + "Send", + "Constructor", + "UpdateChannelState", + "Settle", + "Collect" + ], + "fil/8/reward": [ + "Send", + "Constructor", + "AwardBlockReward", + "ThisEpochReward", + "UpdateNetworkKPI" + ], + "fil/8/storagemarket": [ + "Send", + "Constructor", + "AddBalance", + "WithdrawBalance", + "PublishStorageDeals", + "VerifyDealsForActivation", + "ActivateDeals", + "OnMinerSectorsTerminate", + "ComputeDataCommitment", + "CronTick" + ], + "fil/8/storageminer": [ + "Send", + "Constructor", + "ControlAddresses", + "ChangeWorkerAddress", + "ChangePeerID", + "SubmitWindowedPoSt", + "PreCommitSector", + "ProveCommitSector", + "ExtendSectorExpiration", + "TerminateSectors", + "DeclareFaults", + "DeclareFaultsRecovered", + "OnDeferredCronEvent", + "CheckSectorProven", + "ApplyRewards", + "ReportConsensusFault", + "WithdrawBalance", + "ConfirmSectorProofsValid", + "ChangeMultiaddrs", + "CompactPartitions", + "CompactSectorNumbers", + "ConfirmUpdateWorkerKey", + "RepayDebt", + "ChangeOwnerAddress", + "DisputeWindowedPoSt", + "PreCommitSectorBatch", + "ProveCommitAggregate", + "ProveReplicaUpdates" + ], + "fil/8/storagepower": [ + "Send", + "Constructor", + "CreateMiner", + "UpdateClaimedPower", + "EnrollCronEvent", + "CronTick", + "UpdatePledgeTotal", + "SubmitPoRepForBulkVerify", + "CurrentTotalPower" + ], + "fil/8/system": [ + "Send", + "Constructor" + ], + "fil/8/verifiedregistry": [ + "Send", + "Constructor", + "AddVerifier", + "RemoveVerifier", + "AddVerifiedClient", + "UseBytes", + "RestoreBytes", + "RemoveVerifiedClientDataCap" ] } \ No newline at end of file diff --git a/markets/dagstore/miner_api_test.go b/markets/dagstore/miner_api_test.go index 637600bfc..f39bcb8de 100644 --- a/markets/dagstore/miner_api_test.go +++ b/markets/dagstore/miner_api_test.go @@ -10,6 +10,8 @@ import ( "testing" "time" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" ds_sync "github.com/ipfs/go-datastore/sync" @@ -18,13 +20,11 @@ import ( "github.com/filecoin-project/dagstore/mount" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/actors/builtin/paych" - "github.com/filecoin-project/go-fil-markets/piecestore" piecestoreimpl "github.com/filecoin-project/go-fil-markets/piecestore/impl" "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/shared" + "github.com/filecoin-project/go-state-types/abi" ) const unsealedSectorID = abi.SectorNumber(1) @@ -242,7 +242,7 @@ func (m *mockRPN) GetMinerWorkerAddress(ctx context.Context, miner address.Addre panic("implement me") } -func (m *mockRPN) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount, tok shared.TipSetToken) (abi.TokenAmount, error) { +func (m *mockRPN) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paychtypes.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount, tok shared.TipSetToken) (abi.TokenAmount, error) { panic("implement me") } diff --git a/markets/dagstore/wrapper_migration_test.go b/markets/dagstore/wrapper_migration_test.go index 6c04f6929..be723704e 100644 --- a/markets/dagstore/wrapper_migration_test.go +++ b/markets/dagstore/wrapper_migration_test.go @@ -6,6 +6,8 @@ import ( "io" "testing" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/require" @@ -20,8 +22,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/lotus/node/config" - - "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" ) func TestShardRegistration(t *testing.T) { @@ -63,8 +63,8 @@ func TestShardRegistration(t *testing.T) { //stm: @MARKET_DAGSTORE_MIGRATE_DEALS_001 State: storagemarket.StorageDealSealing, SectorNumber: unsealedSector1, - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: markettypes.ClientDealProposal{ + Proposal: markettypes.DealProposal{ PieceCID: pieceCidUnsealed, }, }, @@ -72,8 +72,8 @@ func TestShardRegistration(t *testing.T) { // Should be registered with lazy registration (because sector is sealed) State: storagemarket.StorageDealSealing, SectorNumber: sealedSector, - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: markettypes.ClientDealProposal{ + Proposal: markettypes.DealProposal{ PieceCID: pieceCidSealed, }, }, @@ -82,8 +82,8 @@ func TestShardRegistration(t *testing.T) { //stm: @MARKET_DAGSTORE_MIGRATE_DEALS_003 State: storagemarket.StorageDealError, SectorNumber: unsealedSector2, - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: markettypes.ClientDealProposal{ + Proposal: markettypes.DealProposal{ PieceCID: pieceCidUnsealed2, }, }, @@ -91,8 +91,8 @@ func TestShardRegistration(t *testing.T) { // Should be ignored because deal is not yet sealing State: storagemarket.StorageDealFundsReserved, SectorNumber: unsealedSector3, - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: markettypes.ClientDealProposal{ + Proposal: markettypes.DealProposal{ PieceCID: pieceCidUnsealed3, }, }, diff --git a/markets/retrievaladapter/client.go b/markets/retrievaladapter/client.go index 74f02570b..e08d78c38 100644 --- a/markets/retrievaladapter/client.go +++ b/markets/retrievaladapter/client.go @@ -10,8 +10,8 @@ import ( "github.com/ipfs/go-cid" "github.com/multiformats/go-multiaddr" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/impl/full" payapi "github.com/filecoin-project/lotus/node/impl/paych" @@ -63,7 +63,7 @@ func (rcn *retrievalClientNode) AllocateLane(ctx context.Context, paymentChannel // CreatePaymentVoucher creates a new payment voucher in the given lane for a // given payment channel so that all the payment vouchers in the lane add up // to the given amount (so the payment voucher will be for the difference) -func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paych.SignedVoucher, error) { +func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paychtypes.SignedVoucher, error) { // TODO: respect the provided TipSetToken (a serialized TipSetKey) when // querying the chain voucher, err := rcn.payAPI.PaychVoucherCreate(ctx, paymentChannel, amount, lane) diff --git a/markets/retrievaladapter/provider.go b/markets/retrievaladapter/provider.go index 470c1cfc7..31d0acc36 100644 --- a/markets/retrievaladapter/provider.go +++ b/markets/retrievaladapter/provider.go @@ -12,8 +12,8 @@ import ( "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/shared" "github.com/filecoin-project/go-state-types/abi" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/api/v1api" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" logging "github.com/ipfs/go-log/v2" ) @@ -42,7 +42,7 @@ func (rpn *retrievalProviderNode) GetMinerWorkerAddress(ctx context.Context, min return mi.Worker, err } -func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paych.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount, tok shared.TipSetToken) (abi.TokenAmount, error) { +func (rpn *retrievalProviderNode) SavePaymentVoucher(ctx context.Context, paymentChannel address.Address, voucher *paychtypes.SignedVoucher, proof []byte, expectedAmount abi.TokenAmount, tok shared.TipSetToken) (abi.TokenAmount, error) { // TODO: respect the provided TipSetToken (a serialized TipSetKey) when // querying the chain added, err := rpn.full.PaychVoucherAdd(ctx, paymentChannel, voucher, proof, expectedAmount) diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index 198e83a1a..bddd5b4f7 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -6,7 +6,7 @@ import ( "bytes" "context" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" "github.com/ipfs/go-cid" @@ -184,7 +184,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor return 0, xerrors.Errorf("deal publish message called incorrect method (method=%s)", pubmsg.Method) } - var params marketactor.PublishStorageDealsParams + var params market8.PublishStorageDealsParams if err := params.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil { return 0, err } @@ -269,13 +269,13 @@ func (c *ClientNodeAdapter) DealProviderCollateralBounds(ctx context.Context, si } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) -func (c *ClientNodeAdapter) OnDealSectorPreCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal market0.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorPreCommittedCallback) error { - return c.scMgr.OnDealSectorPreCommitted(ctx, provider, marketactor.DealProposal(proposal), *publishCid, cb) +func (c *ClientNodeAdapter) OnDealSectorPreCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal market8.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorPreCommittedCallback) error { + return c.scMgr.OnDealSectorPreCommitted(ctx, provider, proposal, *publishCid, cb) } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) -func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal market0.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error { - return c.scMgr.OnDealSectorCommitted(ctx, provider, sectorNumber, marketactor.DealProposal(proposal), *publishCid, cb) +func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal market8.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error { + return c.scMgr.OnDealSectorCommitted(ctx, provider, sectorNumber, proposal, *publishCid, cb) } // TODO: Replace dealID parameter with DealProposal @@ -368,7 +368,7 @@ func (c *ClientNodeAdapter) OnDealExpiredOrSlashed(ctx context.Context, dealID a return nil } -func (c *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Address, proposal market0.DealProposal) (*marketactor.ClientDealProposal, error) { +func (c *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Address, proposal market8.DealProposal) (*market8.ClientDealProposal, error) { // TODO: output spec signed proposal buf, err := cborutil.Dump(&proposal) if err != nil { @@ -387,7 +387,7 @@ func (c *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Add return nil, err } - return &marketactor.ClientDealProposal{ + return &market8.ClientDealProposal{ Proposal: proposal, ClientSignature: *sig, }, nil diff --git a/markets/storageadapter/dealpublisher.go b/markets/storageadapter/dealpublisher.go index 65a57d7ce..6e6d37bd4 100644 --- a/markets/storageadapter/dealpublisher.go +++ b/markets/storageadapter/dealpublisher.go @@ -15,14 +15,12 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/exitcode" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/market" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/storage" @@ -31,7 +29,7 @@ import ( type dealPublisherAPI interface { ChainHead(context.Context) (*types.TipSet, error) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) - StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) + StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) WalletBalance(context.Context, address.Address) (types.BigInt, error) WalletHas(context.Context, address.Address) (bool, error) @@ -69,7 +67,7 @@ type DealPublisher struct { // A deal that is queued to be published type pendingDeal struct { ctx context.Context - deal market2.ClientDealProposal + deal market.ClientDealProposal Result chan publishResult } @@ -79,7 +77,7 @@ type publishResult struct { err error } -func newPendingDeal(ctx context.Context, deal market2.ClientDealProposal) *pendingDeal { +func newPendingDeal(ctx context.Context, deal market.ClientDealProposal) *pendingDeal { return &pendingDeal{ ctx: ctx, deal: deal, @@ -151,7 +149,7 @@ func (p *DealPublisher) PendingDeals() api.PendingDealInfo { } } - pending := make([]market2.ClientDealProposal, len(deals)) + pending := make([]market.ClientDealProposal, len(deals)) for i, deal := range deals { pending[i] = deal.deal } @@ -173,7 +171,7 @@ func (p *DealPublisher) ForcePublishPendingDeals() { p.publishAllDeals() } -func (p *DealPublisher) Publish(ctx context.Context, deal market2.ClientDealProposal) (cid.Cid, error) { +func (p *DealPublisher) Publish(ctx context.Context, deal market.ClientDealProposal) (cid.Cid, error) { pdeal := newPendingDeal(ctx, deal) // Add the deal to the queue @@ -297,7 +295,7 @@ func (p *DealPublisher) publishReady(ready []*pendingDeal) { // Validate each deal to make sure it can be published validated := make([]*pendingDeal, 0, len(ready)) - deals := make([]market2.ClientDealProposal, 0, len(ready)) + deals := make([]market.ClientDealProposal, 0, len(ready)) for _, pd := range ready { // Validate the deal if err := p.validateDeal(pd.deal); err != nil { @@ -321,7 +319,7 @@ func (p *DealPublisher) publishReady(ready []*pendingDeal) { // validateDeal checks that the deal proposal start epoch hasn't already // elapsed -func (p *DealPublisher) validateDeal(deal market2.ClientDealProposal) error { +func (p *DealPublisher) validateDeal(deal market.ClientDealProposal) error { start := time.Now() pcid, err := deal.Proposal.Cid() @@ -344,8 +342,8 @@ func (p *DealPublisher) validateDeal(deal market2.ClientDealProposal) error { return xerrors.Errorf("getting provider info: %w", err) } - params, err := actors.SerializeParams(&market2.PublishStorageDealsParams{ - Deals: []market0.ClientDealProposal{deal}, + params, err := actors.SerializeParams(&market.PublishStorageDealsParams{ + Deals: []market.ClientDealProposal{deal}, }) if err != nil { return xerrors.Errorf("serializing PublishStorageDeals params failed: %w", err) @@ -357,10 +355,10 @@ func (p *DealPublisher) validateDeal(deal market2.ClientDealProposal) error { } res, err := p.api.StateCall(p.ctx, &types.Message{ - To: market.Address, + To: builtin.StorageMarketActorAddr, From: addr, Value: types.NewInt(0), - Method: market.Methods.PublishStorageDeals, + Method: builtin.MethodsMarket.PublishStorageDeals, Params: params, }, head.Key()) if err != nil { @@ -377,7 +375,7 @@ func (p *DealPublisher) validateDeal(deal market2.ClientDealProposal) error { } // Sends the publish message -func (p *DealPublisher) publishDealProposals(deals []market2.ClientDealProposal) (cid.Cid, error) { +func (p *DealPublisher) publishDealProposals(deals []market.ClientDealProposal) (cid.Cid, error) { if len(deals) == 0 { return cid.Undef, nil } @@ -400,7 +398,7 @@ func (p *DealPublisher) publishDealProposals(deals []market2.ClientDealProposal) return cid.Undef, err } - params, err := actors.SerializeParams(&market2.PublishStorageDealsParams{ + params, err := actors.SerializeParams(&market.PublishStorageDealsParams{ Deals: deals, }) @@ -414,10 +412,10 @@ func (p *DealPublisher) publishDealProposals(deals []market2.ClientDealProposal) } smsg, err := p.api.MpoolPushMessage(p.ctx, &types.Message{ - To: market.Address, + To: builtin.StorageMarketActorAddr, From: addr, Value: types.NewInt(0), - Method: market.Methods.PublishStorageDeals, + Method: builtin.MethodsMarket.PublishStorageDeals, Params: params, }, p.publishSpec) @@ -427,7 +425,7 @@ func (p *DealPublisher) publishDealProposals(deals []market2.ClientDealProposal) return smsg.Cid(), nil } -func pieceCids(deals []market2.ClientDealProposal) string { +func pieceCids(deals []market.ClientDealProposal) string { cids := make([]string, 0, len(deals)) for _, dl := range deals { cids = append(cids, dl.Proposal.PieceCID.String()) diff --git a/markets/storageadapter/dealpublisher_test.go b/markets/storageadapter/dealpublisher_test.go index a0ee0ae06..c0251b2c8 100644 --- a/markets/storageadapter/dealpublisher_test.go +++ b/markets/storageadapter/dealpublisher_test.go @@ -7,6 +7,8 @@ import ( "testing" "time" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/ipfs/go-cid" "github.com/raulk/clock" "golang.org/x/xerrors" @@ -17,15 +19,12 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/builtin/market" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" ) func TestDealPublisher(t *testing.T) { @@ -120,7 +119,7 @@ func TestDealPublisher(t *testing.T) { }, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(1)}) // Keep a record of the deals that were submitted to be published - var dealsToPublish []market.ClientDealProposal + var dealsToPublish []markettypes.ClientDealProposal // Publish deals within publish period for i := 0; i < tc.dealCountWithinPublishPeriod; i++ { @@ -203,7 +202,7 @@ func TestForcePublish(t *testing.T) { }, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(1)}) // Queue three deals for publishing, one with a cancelled context - var dealsToPublish []market.ClientDealProposal + var dealsToPublish []markettypes.ClientDealProposal // 1. Regular deal deal := publishDeal(t, dp, 0, false, false) dealsToPublish = append(dealsToPublish, deal) @@ -235,7 +234,7 @@ func TestForcePublish(t *testing.T) { checkPublishedDeals(t, dpapi, dealsToPublish, []int{2}) } -func publishDeal(t *testing.T, dp *DealPublisher, invalid int, ctxCancelled bool, expired bool) market.ClientDealProposal { +func publishDeal(t *testing.T, dp *DealPublisher, invalid int, ctxCancelled bool, expired bool) markettypes.ClientDealProposal { ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) @@ -249,8 +248,8 @@ func publishDeal(t *testing.T, dp *DealPublisher, invalid int, ctxCancelled bool if expired { startEpoch = abi.ChainEpoch(5) } - deal := market.ClientDealProposal{ - Proposal: market0.DealProposal{ + deal := markettypes.ClientDealProposal{ + Proposal: markettypes.DealProposal{ PieceCID: generateCids(1)[0], Client: getClientActor(t), Provider: getProviderActor(t), @@ -282,9 +281,9 @@ func publishDeal(t *testing.T, dp *DealPublisher, invalid int, ctxCancelled bool return deal } -func checkPublishedDeals(t *testing.T, dpapi *dpAPI, dealsToPublish []market.ClientDealProposal, expectedDealsPerMsg []int) { +func checkPublishedDeals(t *testing.T, dpapi *dpAPI, dealsToPublish []markettypes.ClientDealProposal, expectedDealsPerMsg []int) { // For each message that was expected to be sent - var publishedDeals []market.ClientDealProposal + var publishedDeals []markettypes.ClientDealProposal for _, expectedDealsInMsg := range expectedDealsPerMsg { // Should have called StateMinerInfo with the provider address stateMinerInfoAddr := <-dpapi.stateMinerInfoCalls @@ -297,7 +296,7 @@ func checkPublishedDeals(t *testing.T, dpapi *dpAPI, dealsToPublish []market.Cli require.Equal(t, market.Methods.PublishStorageDeals, msg.Method) // Check that the expected number of deals was included in the message - var params market2.PublishStorageDealsParams + var params markettypes.PublishStorageDealsParams err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)) require.NoError(t, err) require.Len(t, params.Deals, expectedDealsInMsg) @@ -313,7 +312,7 @@ func checkPublishedDeals(t *testing.T, dpapi *dpAPI, dealsToPublish []market.Cli require.True(t, matchPieceCids(publishedDeals, dealsToPublish)) } -func matchPieceCids(sent []market.ClientDealProposal, exp []market.ClientDealProposal) bool { +func matchPieceCids(sent []markettypes.ClientDealProposal, exp []markettypes.ClientDealProposal) bool { cidsA := dealPieceCids(sent) cidsB := dealPieceCids(exp) @@ -335,7 +334,7 @@ func matchPieceCids(sent []market.ClientDealProposal, exp []market.ClientDealPro return true } -func dealPieceCids(deals []market2.ClientDealProposal) []cid.Cid { +func dealPieceCids(deals []markettypes.ClientDealProposal) []cid.Cid { cids := make([]cid.Cid, 0, len(deals)) for _, dl := range deals { cids = append(cids, dl.Proposal.PieceCID) @@ -374,9 +373,9 @@ func (d *dpAPI) ChainHead(ctx context.Context) (*types.TipSet, error) { }}) } -func (d *dpAPI) StateMinerInfo(ctx context.Context, address address.Address, key types.TipSetKey) (miner.MinerInfo, error) { +func (d *dpAPI) StateMinerInfo(ctx context.Context, address address.Address, key types.TipSetKey) (api.MinerInfo, error) { d.stateMinerInfoCalls <- address - return miner.MinerInfo{Worker: d.worker}, nil + return api.MinerInfo{Worker: d.worker}, nil } func (d *dpAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) { @@ -401,7 +400,7 @@ func (d *dpAPI) StateLookupID(ctx context.Context, a address.Address, key types. } func (d *dpAPI) StateCall(ctx context.Context, message *types.Message, key types.TipSetKey) (*api.InvocResult, error) { - var p market2.PublishStorageDealsParams + var p markettypes.PublishStorageDealsParams if err := p.UnmarshalCBOR(bytes.NewReader(message.Params)); err != nil { return nil, xerrors.Errorf("unmarshal market params: %w", err) } diff --git a/markets/storageadapter/ondealsectorcommitted.go b/markets/storageadapter/ondealsectorcommitted.go index 94eaadef4..88457b70c 100644 --- a/markets/storageadapter/ondealsectorcommitted.go +++ b/markets/storageadapter/ondealsectorcommitted.go @@ -5,6 +5,8 @@ import ( "context" "sync" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/go-bitfield" sealing "github.com/filecoin-project/lotus/extern/storage-sealing" "github.com/ipfs/go-cid" @@ -13,11 +15,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors/builtin/market" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/types" ) @@ -31,7 +33,7 @@ type dealInfoAPI interface { } type diffPreCommitsAPI interface { - diffPreCommits(ctx context.Context, actor address.Address, pre, cur types.TipSetKey) (*miner.PreCommitChanges, error) + diffPreCommits(ctx context.Context, actor address.Address, pre, cur types.TipSetKey) (*lminer.PreCommitChanges, error) } type SectorCommittedManager struct { @@ -111,7 +113,7 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context, // Watch for a pre-commit message to the provider. matchEvent := func(msg *types.Message) (bool, error) { - matched := msg.To == provider && (msg.Method == miner.Methods.PreCommitSector || msg.Method == miner.Methods.PreCommitSectorBatch || msg.Method == miner.Methods.ProveReplicaUpdates) + matched := msg.To == provider && (msg.Method == builtin.MethodsMiner.PreCommitSector || msg.Method == builtin.MethodsMiner.PreCommitSectorBatch || msg.Method == builtin.MethodsMiner.ProveReplicaUpdates) return matched, nil } @@ -147,7 +149,7 @@ func (mgr *SectorCommittedManager) OnDealSectorPreCommitted(ctx context.Context, } // If this is a replica update method that succeeded the deal is active - if msg.Method == miner.Methods.ProveReplicaUpdates { + if msg.Method == builtin.MethodsMiner.ProveReplicaUpdates { sn, err := dealSectorInReplicaUpdateSuccess(msg, rec, res) if err != nil { return false, err @@ -318,7 +320,7 @@ func dealSectorInReplicaUpdateSuccess(msg *types.Message, rec *types.MessageRece // dealSectorInPreCommitMsg tries to find a sector containing the specified deal func dealSectorInPreCommitMsg(msg *types.Message, res sealing.CurrentDealInfo) (*abi.SectorNumber, error) { switch msg.Method { - case miner.Methods.PreCommitSector: + case builtin.MethodsMiner.PreCommitSector: var params miner.SectorPreCommitInfo if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return nil, xerrors.Errorf("unmarshal pre commit: %w", err) @@ -331,8 +333,8 @@ func dealSectorInPreCommitMsg(msg *types.Message, res sealing.CurrentDealInfo) ( return ¶ms.SectorNumber, nil } } - case miner.Methods.PreCommitSectorBatch: - var params miner5.PreCommitSectorBatchParams + case builtin.MethodsMiner.PreCommitSectorBatch: + var params miner.PreCommitSectorBatchParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return nil, xerrors.Errorf("unmarshal pre commit: %w", err) } @@ -356,7 +358,7 @@ func dealSectorInPreCommitMsg(msg *types.Message, res sealing.CurrentDealInfo) ( // sectorInCommitMsg checks if the provided message commits specified sector func sectorInCommitMsg(msg *types.Message, sectorNumber abi.SectorNumber) (bool, error) { switch msg.Method { - case miner.Methods.ProveCommitSector: + case builtin.MethodsMiner.ProveCommitSector: var params miner.ProveCommitSectorParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return false, xerrors.Errorf("failed to unmarshal prove commit sector params: %w", err) @@ -364,8 +366,8 @@ func sectorInCommitMsg(msg *types.Message, sectorNumber abi.SectorNumber) (bool, return params.SectorNumber == sectorNumber, nil - case miner.Methods.ProveCommitAggregate: - var params miner5.ProveCommitAggregateParams + case builtin.MethodsMiner.ProveCommitAggregate: + var params miner.ProveCommitAggregateParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return false, xerrors.Errorf("failed to unmarshal prove commit sector params: %w", err) } diff --git a/markets/storageadapter/ondealsectorcommitted_test.go b/markets/storageadapter/ondealsectorcommitted_test.go index b11bf03a5..8b420bdd3 100644 --- a/markets/storageadapter/ondealsectorcommitted_test.go +++ b/markets/storageadapter/ondealsectorcommitted_test.go @@ -10,6 +10,10 @@ import ( "testing" "time" + "github.com/filecoin-project/go-state-types/builtin" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + sealing "github.com/filecoin-project/lotus/extern/storage-sealing" "golang.org/x/xerrors" @@ -31,6 +35,9 @@ import ( ) func TestOnDealSectorPreCommitted(t *testing.T) { + label, err := markettypes.NewLabelFromString("success") + require.NoError(t, err) + provider := address.TestAddress ctx := context.Background() publishCid := generateCids(1)[0] @@ -46,7 +53,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) { StoragePricePerEpoch: abi.NewTokenAmount(1), ProviderCollateral: abi.NewTokenAmount(1), ClientCollateral: abi.NewTokenAmount(1), - Label: "success", + Label: label, } unfinishedDeal := &api.MarketDeal{ Proposal: proposal, @@ -91,7 +98,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) { }, matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.PreCommitSector, &miner.SectorPreCommitInfo{ + msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.SectorPreCommitInfo{ SectorNumber: sectorNumber, SealedCID: sealedCid, DealIDs: []abi.DealID{dealID}, @@ -109,7 +116,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) { }, matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.PreCommitSector, &miner.SectorPreCommitInfo{ + msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.SectorPreCommitInfo{ SectorNumber: sectorNumber, SealedCID: sealedCid, DealIDs: []abi.DealID{dealID}, @@ -126,8 +133,8 @@ func TestOnDealSectorPreCommitted(t *testing.T) { MarketDeal: unfinishedDeal, }, preCommitDiff: &miner.PreCommitChanges{ - Added: []miner.SectorPreCommitOnChainInfo{{ - Info: miner.SectorPreCommitInfo{ + Added: []minertypes.SectorPreCommitOnChainInfo{{ + Info: minertypes.SectorPreCommitInfo{ SectorNumber: sectorNumber, DealIDs: []abi.DealID{dealID}, }, @@ -167,7 +174,7 @@ func TestOnDealSectorPreCommitted(t *testing.T) { currentDealInfoErr2: errors.New("something went wrong"), matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.PreCommitSector, &miner.SectorPreCommitInfo{ + msg: makeMessage(t, provider, builtin.MethodsMiner.PreCommitSector, &minertypes.SectorPreCommitInfo{ SectorNumber: sectorNumber, SealedCID: sealedCid, DealIDs: []abi.DealID{dealID}, @@ -252,6 +259,9 @@ func TestOnDealSectorPreCommitted(t *testing.T) { } func TestOnDealSectorCommitted(t *testing.T) { + label, err := markettypes.NewLabelFromString("success") + require.NoError(t, err) + provider := address.TestAddress publishCid := generateCids(1)[0] pieceCid := generateCids(1)[0] @@ -265,7 +275,7 @@ func TestOnDealSectorCommitted(t *testing.T) { StoragePricePerEpoch: abi.NewTokenAmount(1), ProviderCollateral: abi.NewTokenAmount(1), ClientCollateral: abi.NewTokenAmount(1), - Label: "success", + Label: label, } unfinishedDeal := &api.MarketDeal{ Proposal: proposal, @@ -312,7 +322,7 @@ func TestOnDealSectorCommitted(t *testing.T) { }, matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.ProveCommitSector, &miner.ProveCommitSectorParams{ + msg: makeMessage(t, provider, builtin.MethodsMiner.ProveCommitSector, &minertypes.ProveCommitSectorParams{ SectorNumber: sectorNumber, }), }, @@ -330,7 +340,7 @@ func TestOnDealSectorCommitted(t *testing.T) { }, matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.ProveCommitSector, &miner.ProveCommitSectorParams{ + msg: makeMessage(t, provider, builtin.MethodsMiner.ProveCommitSector, &minertypes.ProveCommitSectorParams{ SectorNumber: sectorNumber, }), // Exit-code 1 means the prove-commit was unsuccessful @@ -367,7 +377,7 @@ func TestOnDealSectorCommitted(t *testing.T) { currentDealInfoErr2: errors.New("something went wrong"), matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.ProveCommitSector, &miner.ProveCommitSectorParams{ + msg: makeMessage(t, provider, builtin.MethodsMiner.ProveCommitSector, &minertypes.ProveCommitSectorParams{ SectorNumber: sectorNumber, }), }, @@ -395,7 +405,7 @@ func TestOnDealSectorCommitted(t *testing.T) { }, matchStates: []matchState{ { - msg: makeMessage(t, provider, miner.Methods.ProveCommitSector, &miner.ProveCommitSectorParams{ + msg: makeMessage(t, provider, builtin.MethodsMiner.ProveCommitSector, &minertypes.ProveCommitSectorParams{ SectorNumber: sectorNumber, }), }, diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 0828db271..ef8b8b76d 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -6,6 +6,8 @@ import ( "context" "time" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "go.uber.org/fx" @@ -17,7 +19,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" @@ -284,13 +285,13 @@ func (n *ProviderNodeAdapter) DealProviderCollateralBounds(ctx context.Context, } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) -func (n *ProviderNodeAdapter) OnDealSectorPreCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal market2.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorPreCommittedCallback) error { - return n.scMgr.OnDealSectorPreCommitted(ctx, provider, market.DealProposal(proposal), *publishCid, cb) +func (n *ProviderNodeAdapter) OnDealSectorPreCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal market8.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorPreCommittedCallback) error { + return n.scMgr.OnDealSectorPreCommitted(ctx, provider, proposal, *publishCid, cb) } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) -func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal market2.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error { - return n.scMgr.OnDealSectorCommitted(ctx, provider, sectorNumber, market.DealProposal(proposal), *publishCid, cb) +func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal market8.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error { + return n.scMgr.OnDealSectorCommitted(ctx, provider, sectorNumber, proposal, *publishCid, cb) } func (n *ProviderNodeAdapter) GetChainHead(ctx context.Context) (shared.TipSetToken, abi.ChainEpoch, error) { @@ -310,7 +311,7 @@ func (n *ProviderNodeAdapter) WaitForMessage(ctx context.Context, mcid cid.Cid, return cb(receipt.Receipt.ExitCode, receipt.Receipt.Return, receipt.Message, nil) } -func (n *ProviderNodeAdapter) WaitForPublishDeals(ctx context.Context, publishCid cid.Cid, proposal market2.DealProposal) (*storagemarket.PublishDealsWaitResult, error) { +func (n *ProviderNodeAdapter) WaitForPublishDeals(ctx context.Context, publishCid cid.Cid, proposal market8.DealProposal) (*storagemarket.PublishDealsWaitResult, error) { // Wait for deal to be published (plus additional time for confidence) receipt, err := n.StateWaitMsg(ctx, publishCid, 2*build.MessageConfidence, api.LookbackNoLimit, true) if err != nil { @@ -327,7 +328,7 @@ func (n *ProviderNodeAdapter) WaitForPublishDeals(ctx context.Context, publishCi return nil, xerrors.Errorf("WaitForPublishDeals failed to get chain head: %w", err) } - res, err := n.scMgr.dealInfo.GetCurrentDealInfo(ctx, head.Key().Bytes(), (*market.DealProposal)(&proposal), publishCid) + res, err := n.scMgr.dealInfo.GetCurrentDealInfo(ctx, head.Key().Bytes(), &proposal, publishCid) if err != nil { return nil, xerrors.Errorf("WaitForPublishDeals getting deal info errored: %w", err) } diff --git a/miner/miner.go b/miner/miner.go index 976e9ca6f..6fbf159bf 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -10,12 +10,12 @@ import ( "sync" "time" + "github.com/filecoin-project/go-state-types/proof" + lrand "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/api/v1api" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" - "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/gen/slashfilter" @@ -260,7 +260,7 @@ minerLoop: } // just wait for the beacon entry to become available before we select our final mining base - _, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1) + _, err = m.api.StateGetBeaconEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1) if err != nil { log.Errorf("failed getting beacon entry: %s", err) if !m.niceSleep(time.Second) { @@ -611,7 +611,7 @@ func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, bas } func (m *Miner) createBlock(base *MiningBase, addr address.Address, ticket *types.Ticket, - eproof *types.ElectionProof, bvals []types.BeaconEntry, wpostProof []proof2.PoStProof, msgs []*types.SignedMessage) (*types.BlockMsg, error) { + eproof *types.ElectionProof, bvals []types.BeaconEntry, wpostProof []proof.PoStProof, msgs []*types.SignedMessage) (*types.BlockMsg, error) { uts := base.TipSet.MinTimestamp() + build.BlockDelaySecs*(uint64(base.NullRounds)+1) nheight := base.TipSet.Height() + base.NullRounds + 1 diff --git a/node/builder.go b/node/builder.go index f0106ad97..6f9805760 100644 --- a/node/builder.go +++ b/node/builder.go @@ -384,6 +384,9 @@ func Test() Option { Unset(new(*peermgr.PeerMgr)), Override(new(beacon.Schedule), testing.RandomBeacon), Override(new(*storageadapter.DealPublisher), storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{})), + // use the testing bundles + Unset(new(dtypes.BuiltinActorsLoaded)), + Override(new(dtypes.BuiltinActorsLoaded), modules.LoadBuiltinActorsTesting), ) } diff --git a/node/builder_chain.go b/node/builder_chain.go index 226ecac68..650b79794 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -48,9 +48,16 @@ var ChainNode = Options( // Full node or lite node // TODO: Fix offline mode + // FVM: builtin actor bundle loading + // Note: this has to load before the upgrade schedule, so that we can patch in the + // right manifest cid. + // This restriction will be lifted once we have the final actors v8 bundle and we know + // the manifest cid. + Override(new(dtypes.BuiltinActorsLoaded), modules.LoadBuiltinActors), + // Consensus settings Override(new(dtypes.DrandSchedule), modules.BuiltinDrandConfig), - Override(new(stmgr.UpgradeSchedule), filcns.DefaultUpgradeSchedule()), + Override(new(stmgr.UpgradeSchedule), modules.UpgradeSchedule), Override(new(dtypes.NetworkName), modules.NetworkName), Override(new(modules.Genesis), modules.ErrorGenesis), Override(new(dtypes.AfterGenesisSet), modules.SetGenesis), diff --git a/node/builder_miner.go b/node/builder_miner.go index 2223d14ce..11cd34af5 100644 --- a/node/builder_miner.go +++ b/node/builder_miner.go @@ -51,6 +51,10 @@ var MinerNode = Options( // Mining / proving Override(new(*storage.AddressSelector), modules.AddressSelector(nil)), + + // builtin actors manifest + Override(new(dtypes.BuiltinActorsLoaded), modules.LoadBuiltinActors), + Override(new(dtypes.UniversalBlockstore), modules.MemoryBlockstore), ) func ConfigStorageMiner(c interface{}) Option { diff --git a/node/bundle/bundle.go b/node/bundle/bundle.go new file mode 100644 index 000000000..a3a14f468 --- /dev/null +++ b/node/bundle/bundle.go @@ -0,0 +1,216 @@ +package bundle + +import ( + "bytes" + "crypto/sha256" + "encoding/hex" + "fmt" + "io" + "net" + "net/http" + "os" + "path/filepath" + "strings" + "time" + + "golang.org/x/xerrors" + + logging "github.com/ipfs/go-log/v2" +) + +var log = logging.Logger("bundle-fetcher") + +type BundleFetcher struct { + path string +} + +func NewBundleFetcher(basepath string) (*BundleFetcher, error) { + path := filepath.Join(basepath, "builtin-actors") + if err := os.MkdirAll(path, 0755); err != nil { + return nil, xerrors.Errorf("error making bundle directory %s: %w", path, err) + } + + return &BundleFetcher{path: path}, nil +} + +func (b *BundleFetcher) FetchFromRelease(version int, release, netw string) (path string, err error) { + bundleName := fmt.Sprintf("builtin-actors-%s", netw) + bundleFile := fmt.Sprintf("%s.car", bundleName) + bundleHash := fmt.Sprintf("%s.sha256", bundleName) + bundleBasePath := filepath.Join(b.path, fmt.Sprintf("v%d", version), release) + + if err := os.MkdirAll(bundleBasePath, 0755); err != nil { + return "", xerrors.Errorf("error making bundle directory %s: %w", bundleBasePath, err) + } + + // check if it exists; if it does, check the hash + bundleFilePath := filepath.Join(bundleBasePath, bundleFile) + if _, err := os.Stat(bundleFilePath); err == nil { + err := b.checkRelease(bundleBasePath, bundleFile, bundleHash) + if err == nil { + return bundleFilePath, nil + } + + log.Warnf("invalid bundle %s: %s; refetching", bundleName, err) + } + + log.Infof("fetching bundle %s", bundleFile) + if err := b.fetchFromRelease(release, bundleBasePath, bundleFile, bundleHash); err != nil { + log.Errorf("error fetching bundle %s: %s", bundleName, err) + return "", xerrors.Errorf("error fetching bundle: %w", err) + } + + if err := b.checkRelease(bundleBasePath, bundleFile, bundleHash); err != nil { + log.Errorf("error checking bundle %s: %s", bundleName, err) + return "", xerrors.Errorf("error checking bundle: %s", err) + } + + return bundleFilePath, nil +} + +func (b *BundleFetcher) FetchFromURL(version int, release, netw, url, cksum string) (path string, err error) { + bundleName := fmt.Sprintf("builtin-actors-%s", netw) + bundleFile := fmt.Sprintf("%s.car", bundleName) + bundleBasePath := filepath.Join(b.path, fmt.Sprintf("v%d", version), release) + + if err := os.MkdirAll(bundleBasePath, 0755); err != nil { + return "", xerrors.Errorf("error making bundle directory %s: %w", bundleBasePath, err) + } + + // check if it exists; if it does, check the hash + bundleFilePath := filepath.Join(bundleBasePath, bundleFile) + if _, err := os.Stat(bundleFilePath); err == nil { + err := b.checkHash(bundleBasePath, bundleFile, cksum) + if err == nil { + return bundleFilePath, nil + } + + log.Warnf("invalid bundle %s: %s; refetching", bundleName, err) + } + + log.Infof("fetching bundle %s", bundleFile) + if err := b.fetchFromURL(bundleBasePath, bundleFile, url); err != nil { + log.Errorf("error fetching bundle %s: %s", bundleName, err) + return "", xerrors.Errorf("error fetching bundle: %w", err) + } + + if err := b.checkHash(bundleBasePath, bundleFile, cksum); err != nil { + log.Errorf("error checking bundle %s: %s", bundleName, err) + return "", xerrors.Errorf("error checking bundle: %s", err) + } + + return bundleFilePath, nil +} + +func (b *BundleFetcher) fetchURL(url, path string) error { + log.Infof("fetching URL: %s", url) + + for i := 0; i < 3; i++ { + resp, err := http.Get(url) //nolint + if err != nil { + if isTemporary(err) { + log.Warnf("temporary error fetching %s: %s; retrying in 1s", url, err) + time.Sleep(time.Second) + continue + } + return xerrors.Errorf("error fetching %s: %w", url, err) + } + defer resp.Body.Close() //nolint + + if resp.StatusCode != http.StatusOK { + log.Warnf("unexpected response fetching %s: %s (%d); retrying in 1s", url, resp.Status, resp.StatusCode) + time.Sleep(time.Second) + continue + } + + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) + if err != nil { + return xerrors.Errorf("error opening %s for writing: %w", path, err) + } + defer f.Close() //nolint + + if _, err := io.Copy(f, resp.Body); err != nil { + return xerrors.Errorf("error writing %s: %w", path, err) + } + + return nil + } + + return xerrors.Errorf("all attempts to fetch %s failed", url) +} + +func (b *BundleFetcher) fetchFromRelease(release, bundleBasePath, bundleFile, bundleHash string) error { + bundleHashUrl := fmt.Sprintf("https://github.com/filecoin-project/builtin-actors/releases/download/%s/%s", + release, bundleHash) + bundleHashPath := filepath.Join(bundleBasePath, bundleHash) + if err := b.fetchURL(bundleHashUrl, bundleHashPath); err != nil { + return err + } + + bundleFileUrl := fmt.Sprintf("https://github.com/filecoin-project/builtin-actors/releases/download/%s/%s", + release, bundleFile) + bundleFilePath := filepath.Join(bundleBasePath, bundleFile) + if err := b.fetchURL(bundleFileUrl, bundleFilePath); err != nil { + return err + } + + return nil +} + +func (b *BundleFetcher) fetchFromURL(bundleBasePath, bundleFile, url string) error { + bundleFilePath := filepath.Join(bundleBasePath, bundleFile) + return b.fetchURL(url, bundleFilePath) +} + +func (b *BundleFetcher) checkRelease(bundleBasePath, bundleFile, bundleHash string) error { + bundleHashPath := filepath.Join(bundleBasePath, bundleHash) + f, err := os.Open(bundleHashPath) + if err != nil { + return xerrors.Errorf("error opening %s: %w", bundleHashPath, err) + } + defer f.Close() //nolint + + bs, err := io.ReadAll(f) + if err != nil { + return xerrors.Errorf("error reading %s: %w", bundleHashPath, err) + } + + parts := strings.Split(string(bs), " ") + hashHex := parts[0] + + return b.checkHash(bundleBasePath, bundleFile, hashHex) +} + +func (b *BundleFetcher) checkHash(bundleBasePath, bundleFile, cksum string) error { + expectedDigest, err := hex.DecodeString(cksum) + if err != nil { + return xerrors.Errorf("error decoding digest from %s: %w", cksum, err) + } + + bundleFilePath := filepath.Join(bundleBasePath, bundleFile) + f, err := os.Open(bundleFilePath) + if err != nil { + return xerrors.Errorf("error opening %s: %w", bundleFilePath, err) + } + defer f.Close() //nolint + + h256 := sha256.New() + if _, err := io.Copy(h256, f); err != nil { + return xerrors.Errorf("error computing digest for %s: %w", bundleFilePath, err) + } + digest := h256.Sum(nil) + + if !bytes.Equal(digest, expectedDigest) { + return xerrors.Errorf("hash mismatch") + } + + return nil +} + +func isTemporary(err error) bool { + if ne, ok := err.(net.Error); ok { + return ne.Temporary() + } + + return false +} diff --git a/node/bundle/manifest.go b/node/bundle/manifest.go new file mode 100644 index 000000000..b292b94eb --- /dev/null +++ b/node/bundle/manifest.go @@ -0,0 +1,127 @@ +package bundle + +import ( + "context" + "fmt" + "os" + + "github.com/ipld/go-car" + + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/blockstore" + "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" + + cid "github.com/ipfs/go-cid" + cbor "github.com/ipfs/go-ipld-cbor" + + "github.com/mitchellh/go-homedir" +) + +func FetchAndLoadBundleFromRelease(ctx context.Context, basePath string, bs blockstore.Blockstore, av actors.Version, rel, netw string) (cid.Cid, error) { + fetcher, err := NewBundleFetcher(basePath) + if err != nil { + return cid.Undef, xerrors.Errorf("error creating fetcher for builtin-actors version %d: %w", av, err) + } + + path, err := fetcher.FetchFromRelease(int(av), rel, netw) + if err != nil { + return cid.Undef, xerrors.Errorf("error fetching bundle for builtin-actors version %d: %w", av, err) + } + + return LoadBundle(ctx, bs, path, av) +} + +func FetchAndLoadBundleFromURL(ctx context.Context, basePath string, bs blockstore.Blockstore, av actors.Version, rel, netw, url, cksum string) (cid.Cid, error) { + fetcher, err := NewBundleFetcher(basePath) + if err != nil { + return cid.Undef, xerrors.Errorf("error creating fetcher for builtin-actors version %d: %w", av, err) + } + + path, err := fetcher.FetchFromURL(int(av), rel, netw, url, cksum) + if err != nil { + return cid.Undef, xerrors.Errorf("error fetching bundle for builtin-actors version %d: %w", av, err) + } + + return LoadBundle(ctx, bs, path, av) +} + +func LoadBundle(ctx context.Context, bs blockstore.Blockstore, path string, av actors.Version) (cid.Cid, error) { + f, err := os.Open(path) + if err != nil { + return cid.Undef, xerrors.Errorf("error opening bundle for builtin-actors version %d: %w", av, err) + } + defer f.Close() //nolint + + hdr, err := car.LoadCar(ctx, bs, f) + if err != nil { + return cid.Undef, xerrors.Errorf("error loading builtin actors v%d bundle: %w", av, err) + } + + // TODO: check that this only has one root? + manifestCid := hdr.Roots[0] + + if val, ok := build.ActorsCIDs[av]; ok { + if val != manifestCid { + return cid.Undef, xerrors.Errorf("actors V%d manifest CID %s did not match CID given in params file: %s", av, manifestCid, val) + } + } + actors.AddManifest(av, manifestCid) + + mfCid, ok := actors.GetManifest(av) + if !ok { + return cid.Undef, xerrors.Errorf("missing manifest CID for builtin-actors vrsion %d", av) + } + + return mfCid, nil +} + +// utility for blanket loading outside DI +func FetchAndLoadBundles(ctx context.Context, bs blockstore.Blockstore, bar map[actors.Version]build.Bundle) error { + netw := build.NetworkBundle + + path := os.Getenv("LOTUS_PATH") + if path == "" { + var err error + path, err = homedir.Expand("~/.lotus") + if err != nil { + return err + } + } + + for av, bd := range bar { + envvar := fmt.Sprintf("LOTUS_BUILTIN_ACTORS_V%d_BUNDLE", av) + switch { + case os.Getenv(envvar) != "": + // this is a local bundle, specified by an env var to load from the filesystem + path := os.Getenv(envvar) + + if _, err := LoadBundle(ctx, bs, path, av); err != nil { + return err + } + + case bd.Path[netw] != "": + if _, err := LoadBundle(ctx, bs, bd.Path[netw], av); err != nil { + return err + } + + case bd.URL[netw].URL != "": + if _, err := FetchAndLoadBundleFromURL(ctx, path, bs, av, bd.Release, netw, bd.URL[netw].URL, bd.URL[netw].Checksum); err != nil { + return err + } + + case bd.Release != "": + if _, err := FetchAndLoadBundleFromRelease(ctx, path, bs, av, bd.Release, netw); err != nil { + return err + } + } + } + + cborStore := cbor.NewCborStore(bs) + if err := actors.LoadManifests(ctx, cborStore); err != nil { + return err + } + + return nil +} diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 5b4791cfa..83806ee80 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -12,6 +12,8 @@ import ( "strings" "time" + market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" + bstore "github.com/ipfs/go-ipfs-blockstore" format "github.com/ipfs/go-ipld-format" unixfile "github.com/ipfs/go-unixfs/file" @@ -60,7 +62,6 @@ import ( "github.com/filecoin-project/lotus/markets/storageadapter" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" "github.com/filecoin-project/lotus/node/config" "github.com/filecoin-project/lotus/node/repo/imports" @@ -233,12 +234,17 @@ func (a *API) dealStarter(ctx context.Context, params *api.StartDealParams, isSt // stateless flow from here to the end // - dealProposal := &market.DealProposal{ + label, err := market8.NewLabelFromString(params.Data.Root.Encode(multibase.MustNewEncoder('u'))) + if err != nil { + return nil, xerrors.Errorf("failed to encode label: %w", err) + } + + dealProposal := &market8.DealProposal{ PieceCID: *params.Data.PieceCid, PieceSize: params.Data.PieceSize.Padded(), Client: walletKey, Provider: params.Miner, - Label: params.Data.Root.Encode(multibase.MustNewEncoder('u')), + Label: label, StartEpoch: dealStart, EndEpoch: calcDealExpiration(params.MinBlocksDuration, md, dealStart), StoragePricePerEpoch: big.Zero(), @@ -265,7 +271,7 @@ func (a *API) dealStarter(ctx context.Context, params *api.StartDealParams, isSt return nil, xerrors.Errorf("failed to sign proposal : %w", err) } - dealProposalSigned := &market.ClientDealProposal{ + dealProposalSigned := &market8.ClientDealProposal{ Proposal: *dealProposal, ClientSignature: *dealProposalSig, } diff --git a/node/impl/full.go b/node/impl/full.go index a6f61c305..b66e647a1 100644 --- a/node/impl/full.go +++ b/node/impl/full.go @@ -35,7 +35,6 @@ type FullNodeAPI struct { full.MsigAPI full.WalletAPI full.SyncAPI - full.BeaconAPI DS dtypes.MetadataDS NetworkName dtypes.NetworkName diff --git a/node/impl/full/beacon.go b/node/impl/full/beacon.go deleted file mode 100644 index bc7232c27..000000000 --- a/node/impl/full/beacon.go +++ /dev/null @@ -1,36 +0,0 @@ -package full - -import ( - "context" - "fmt" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/beacon" - "github.com/filecoin-project/lotus/chain/types" - "go.uber.org/fx" -) - -type BeaconAPI struct { - fx.In - - Beacon beacon.Schedule -} - -func (a *BeaconAPI) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) { - b := a.Beacon.BeaconForEpoch(epoch) - rr := b.MaxBeaconRoundForEpoch(epoch) - e := b.Entry(ctx, rr) - - select { - case be, ok := <-e: - if !ok { - return nil, fmt.Errorf("beacon get returned no value") - } - if be.Err != nil { - return nil, be.Err - } - return &be.Entry, nil - case <-ctx.Done(): - return nil, ctx.Err() - } -} diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index dd1e8d5ea..624296254 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -6,8 +6,9 @@ import ( "math/rand" "sort" - "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" + + "github.com/filecoin-project/go-state-types/builtin" lru "github.com/hashicorp/golang-lru" "go.uber.org/fx" @@ -295,31 +296,62 @@ func gasEstimateGasLimit( return -1, xerrors.Errorf("message execution failed: exit %s, reason: %s", res.MsgRct.ExitCode, res.Error) } + ret := res.MsgRct.GasUsed + + transitionalMulti := 1.0 + // Overestimate gas around the upgrade + if ts.Height() <= build.UpgradeSkyrHeight && (build.UpgradeSkyrHeight-ts.Height() <= 20) { + transitionalMulti = 2.0 + + func() { + st, err := smgr.ParentState(ts) + if err != nil { + return + } + act, err := st.GetActor(msg.To) + if err != nil { + return + } + + if lbuiltin.IsStorageMinerActor(act.Code) { + switch msgIn.Method { + case 5: + transitionalMulti = 3.954 + case 6: + transitionalMulti = 4.095 + case 7: + // skip, stay at 2.0 + //transitionalMulti = 1.289 + case 11: + transitionalMulti = 17.8758 + case 16: + transitionalMulti = 2.1704 + case 25: + transitionalMulti = 3.1177 + case 26: + transitionalMulti = 2.3322 + default: + } + } + + // skip storage market, 80th percentie for everything ~1.9, leave it at 2.0 + }() + } + ret = (ret * int64(transitionalMulti*1024)) >> 10 + // Special case for PaymentChannel collect, which is deleting actor + // We ignore errors in this special case since they CAN occur, + // and we just want to detect existing payment channel actors st, err := smgr.ParentState(ts) - if err != nil { - _ = err - // somewhat ignore it as it can happen and we just want to detect - // an existing PaymentChannel actor - return res.MsgRct.GasUsed, nil - } - act, err := st.GetActor(msg.To) - if err != nil { - _ = err - // somewhat ignore it as it can happen and we just want to detect - // an existing PaymentChannel actor - return res.MsgRct.GasUsed, nil + if err == nil { + act, err := st.GetActor(msg.To) + if err == nil && lbuiltin.IsPaymentChannelActor(act.Code) && msgIn.Method == builtin.MethodsPaych.Collect { + // add the refunded gas for DestroyActor back into the gas used + ret += 76e3 + } } - if !builtin.IsPaymentChannelActor(act.Code) { - return res.MsgRct.GasUsed, nil - } - if msgIn.Method != paych.Methods.Collect { - return res.MsgRct.GasUsed, nil - } - - // return GasUsed without the refund for DestoryActor - return res.MsgRct.GasUsed + 76e3, nil + return ret, nil } func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, _ types.TipSetKey) (*types.Message, error) { diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 648b3e76e..69fe0fea2 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -4,8 +4,11 @@ import ( "bytes" "context" "encoding/json" + "fmt" "strconv" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/cbor" @@ -22,6 +25,7 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/market" @@ -53,7 +57,7 @@ type StateModuleAPI interface { StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error) - StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) + StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error) StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error) StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) StateNetworkVersion(ctx context.Context, key types.TipSetKey) (network.Version, error) @@ -132,27 +136,52 @@ func (a *StateAPI) StateMinerActiveSectors(ctx context.Context, maddr address.Ad return mas.LoadSectors(&activeSectors) } -func (m *StateModule) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) { +func (m *StateModule) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error) { ts, err := m.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { - return miner.MinerInfo{}, xerrors.Errorf("failed to load tipset: %w", err) + return api.MinerInfo{}, xerrors.Errorf("failed to load tipset: %w", err) } act, err := m.StateManager.LoadActor(ctx, actor, ts) if err != nil { - return miner.MinerInfo{}, xerrors.Errorf("failed to load miner actor: %w", err) + return api.MinerInfo{}, xerrors.Errorf("failed to load miner actor: %w", err) } mas, err := miner.Load(m.StateManager.ChainStore().ActorStore(ctx), act) if err != nil { - return miner.MinerInfo{}, xerrors.Errorf("failed to load miner actor state: %w", err) + return api.MinerInfo{}, xerrors.Errorf("failed to load miner actor state: %w", err) } info, err := mas.Info() if err != nil { - return miner.MinerInfo{}, err + return api.MinerInfo{}, err } - return info, nil + + var pid *peer.ID + if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { + pid = &peerID + } + + ret := api.MinerInfo{ + Owner: info.Owner, + Worker: info.Worker, + ControlAddresses: info.ControlAddresses, + NewWorker: address.Undef, + WorkerChangeEpoch: -1, + PeerId: pid, + Multiaddrs: info.Multiaddrs, + WindowPoStProofType: info.WindowPoStProofType, + SectorSize: info.SectorSize, + WindowPoStPartitionSectors: info.WindowPoStPartitionSectors, + ConsensusFaultElapsed: info.ConsensusFaultElapsed, + } + + if info.PendingWorkerKey != nil { + ret.NewWorker = info.PendingWorkerKey.NewWorker + ret.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt + } + + return ret, nil } func (a *StateAPI) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]api.Deadline, error) { @@ -680,8 +709,8 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSet return out, nil } -func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketDeal, error) { - out := map[string]api.MarketDeal{} +func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]*api.MarketDeal, error) { + out := map[string]*api.MarketDeal{} ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { @@ -710,7 +739,7 @@ func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (m } else if !found { s = market.EmptyDealState() } - out[strconv.FormatInt(int64(dealID), 10)] = api.MarketDeal{ + out[strconv.FormatInt(int64(dealID), 10)] = &api.MarketDeal{ Proposal: d, State: *s, } @@ -786,17 +815,17 @@ func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Addre return api.MinerSectors{Live: liveCount, Active: activeCount, Faulty: faultyCount}, nil } -func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) { +func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (minertypes.SectorPreCommitOnChainInfo, error) { ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { - return miner.SectorPreCommitOnChainInfo{}, xerrors.Errorf("loading tipset %s: %w", tsk, err) + return minertypes.SectorPreCommitOnChainInfo{}, xerrors.Errorf("loading tipset %s: %w", tsk, err) } pci, err := stmgr.PreCommitInfo(ctx, a.StateManager, maddr, n, ts) if err != nil { - return miner.SectorPreCommitOnChainInfo{}, err + return minertypes.SectorPreCommitOnChainInfo{}, err } else if pci == nil { - return miner.SectorPreCommitOnChainInfo{}, xerrors.Errorf("precommit info is not exists") + return minertypes.SectorPreCommitOnChainInfo{}, xerrors.Errorf("precommit info is not exists") } return *pci, err @@ -1062,7 +1091,7 @@ func (m *StateModule) MsigGetPending(ctx context.Context, addr address.Address, var initialPledgeNum = types.NewInt(110) var initialPledgeDen = types.NewInt(100) -func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { +func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err) @@ -1122,7 +1151,7 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr return types.BigDiv(types.BigMul(deposit, initialPledgeNum), initialPledgeDen), nil } -func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { +func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { // TODO: this repeats a lot of the previous function. Fix that. ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { @@ -1440,6 +1469,25 @@ func (a *StateAPI) StateGetRandomnessFromBeacon(ctx context.Context, personaliza } +func (a *StateAPI) StateGetBeaconEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) { + b := a.Beacon.BeaconForEpoch(epoch) + rr := b.MaxBeaconRoundForEpoch(a.StateManager.GetNetworkVersion(ctx, epoch), epoch) + e := b.Entry(ctx, rr) + + select { + case be, ok := <-e: + if !ok { + return nil, fmt.Errorf("beacon get returned no value") + } + if be.Err != nil { + return nil, be.Err + } + return &be.Entry, nil + case <-ctx.Done(): + return nil, ctx.Err() + } +} + func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParams, error) { networkName, err := a.StateNetworkName(ctx) if err != nil { diff --git a/node/impl/paych/paych.go b/node/impl/paych/paych.go index d338c6032..04ffbfe6a 100644 --- a/node/impl/paych/paych.go +++ b/node/impl/paych/paych.go @@ -10,8 +10,8 @@ import ( "github.com/filecoin-project/go-address" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/paychmgr" ) @@ -83,10 +83,10 @@ func (a *PaychAPI) PaychNewPayment(ctx context.Context, from, to address.Address return nil, err } - svs := make([]*paych.SignedVoucher, len(vouchers)) + svs := make([]*paychtypes.SignedVoucher, len(vouchers)) for i, v := range vouchers { - sv, err := a.PaychMgr.CreateVoucher(ctx, ch.Channel, paych.SignedVoucher{ + sv, err := a.PaychMgr.CreateVoucher(ctx, ch.Channel, paychtypes.SignedVoucher{ Amount: v.Amount, Lane: lane, @@ -135,15 +135,15 @@ func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid. return a.PaychMgr.Collect(ctx, addr) } -func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error { +func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher) error { return a.PaychMgr.CheckVoucherValid(ctx, ch, sv) } -func (a *PaychAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (a *PaychAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, secret []byte, proof []byte) (bool, error) { return a.PaychMgr.CheckVoucherSpendable(ctx, ch, sv, secret, proof) } -func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) { +func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) { return a.PaychMgr.AddVoucherInbound(ctx, ch, sv, proof, minDelta) } @@ -155,16 +155,16 @@ func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv * // If there are insufficient funds in the channel to create the voucher, // returns a nil voucher and the shortfall. func (a *PaychAPI) PaychVoucherCreate(ctx context.Context, pch address.Address, amt types.BigInt, lane uint64) (*api.VoucherCreateResult, error) { - return a.PaychMgr.CreateVoucher(ctx, pch, paych.SignedVoucher{Amount: amt, Lane: lane}) + return a.PaychMgr.CreateVoucher(ctx, pch, paychtypes.SignedVoucher{Amount: amt, Lane: lane}) } -func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) { +func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paychtypes.SignedVoucher, error) { vi, err := a.PaychMgr.ListVouchers(ctx, pch) if err != nil { return nil, err } - out := make([]*paych.SignedVoucher, len(vi)) + out := make([]*paychtypes.SignedVoucher, len(vi)) for k, v := range vi { out[k] = v.Voucher } @@ -172,6 +172,6 @@ func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([ return out, nil } -func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { +func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { return a.PaychMgr.SubmitVoucher(ctx, ch, sv, secret, proof) } diff --git a/node/impl/storminer.go b/node/impl/storminer.go index eb8952004..1dc3c8e70 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -11,12 +11,13 @@ import ( "strconv" "time" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/dagstore" "github.com/filecoin-project/dagstore/shard" "github.com/filecoin-project/go-jsonrpc/auth" "github.com/filecoin-project/lotus/chain/actors/builtin" - lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/gen" "github.com/google/uuid" @@ -413,7 +414,7 @@ func (sm *StorageMinerAPI) SectorMatchPendingPiecesToOpenSectors(ctx context.Con return sm.Miner.SectorMatchPendingPiecesToOpenSectors(ctx) } -func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]lminer.SubmitWindowedPoStParams, error) { +func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]minertypes.SubmitWindowedPoStParams, error) { var ts *types.TipSet var err error if tsk == types.EmptyTSK { @@ -461,7 +462,7 @@ func (sm *StorageMinerAPI) MarketImportDealData(ctx context.Context, propCid cid return sm.StorageProvider.ImportDataForDeal(ctx, propCid, fi) } -func (sm *StorageMinerAPI) listDeals(ctx context.Context) ([]api.MarketDeal, error) { +func (sm *StorageMinerAPI) listDeals(ctx context.Context) ([]*api.MarketDeal, error) { ts, err := sm.Full.ChainHead(ctx) if err != nil { return nil, err @@ -472,7 +473,7 @@ func (sm *StorageMinerAPI) listDeals(ctx context.Context) ([]api.MarketDeal, err return nil, err } - var out []api.MarketDeal + var out []*api.MarketDeal for _, deal := range allDeals { if deal.Proposal.Provider == sm.Miner.Address() { @@ -483,7 +484,7 @@ func (sm *StorageMinerAPI) listDeals(ctx context.Context) ([]api.MarketDeal, err return out, nil } -func (sm *StorageMinerAPI) MarketListDeals(ctx context.Context) ([]api.MarketDeal, error) { +func (sm *StorageMinerAPI) MarketListDeals(ctx context.Context) ([]*api.MarketDeal, error) { return sm.listDeals(ctx) } @@ -1108,7 +1109,7 @@ func (sm *StorageMinerAPI) DagstoreLookupPieces(ctx context.Context, cid cid.Cid return ret, nil } -func (sm *StorageMinerAPI) DealsList(ctx context.Context) ([]api.MarketDeal, error) { +func (sm *StorageMinerAPI) DealsList(ctx context.Context) ([]*api.MarketDeal, error) { return sm.listDeals(ctx) } diff --git a/node/modules/blockstore.go b/node/modules/blockstore.go index 2486b9744..7a01c4dcc 100644 --- a/node/modules/blockstore.go +++ b/node/modules/blockstore.go @@ -37,6 +37,10 @@ func UniversalBlockstore(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.Locked return bs, err } +func MemoryBlockstore() dtypes.UniversalBlockstore { + return blockstore.NewMemory() +} + func DiscardColdBlockstore(lc fx.Lifecycle, bs dtypes.UniversalBlockstore) (dtypes.ColdBlockstore, error) { return blockstore.NewDiscardStore(bs), nil } diff --git a/node/modules/builtin_actors.go b/node/modules/builtin_actors.go new file mode 100644 index 000000000..474619c05 --- /dev/null +++ b/node/modules/builtin_actors.go @@ -0,0 +1,177 @@ +package modules + +import ( + "fmt" + "os" + "sync" + + "go.uber.org/fx" + "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/build" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/node/bundle" + "github.com/filecoin-project/lotus/node/modules/dtypes" + "github.com/filecoin-project/lotus/node/modules/helpers" + "github.com/filecoin-project/lotus/node/repo" + + cid "github.com/ipfs/go-cid" + dstore "github.com/ipfs/go-datastore" + cbor "github.com/ipfs/go-ipld-cbor" +) + +func LoadBuiltinActors(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.LockedRepo, bs dtypes.UniversalBlockstore, ds dtypes.MetadataDS) (result dtypes.BuiltinActorsLoaded, err error) { + ctx := helpers.LifecycleCtx(mctx, lc) + + // We can't put it as a dep in inputs causes a stack overflow in DI from circular dependency + // So we pass it through ldflags instead + netw := build.NetworkBundle + + for av, bd := range build.BuiltinActorReleases { + // first check to see if we know this release + key := dstore.NewKey(fmt.Sprintf("/builtin-actors/v%d/%s/%s", av, bd.Release, netw)) + + data, err := ds.Get(ctx, key) + switch err { + case nil: + // ok, we do, this should be the manifest cid + mfCid, err := cid.Cast(data) + if err != nil { + return result, xerrors.Errorf("error parsing cid for %s: %w", key, err) + } + + // check the blockstore for existence of the manifest + has, err := bs.Has(ctx, mfCid) + if err != nil { + return result, xerrors.Errorf("error checking blockstore for manifest cid %s: %w", mfCid, err) + } + + if has { + // it's there, no need to reload the bundle to the blockstore; just add it to the manifest list. + if val, ok := build.ActorsCIDs[av]; ok { + if val != mfCid { + return result, xerrors.Errorf("actors V%d manifest CID %s did not match CID given in params file: %s", av, mfCid, val) + } + } + actors.AddManifest(av, mfCid) + continue + } + + // we have a release key but don't have the manifest in the blockstore; maybe the user + // nuked his blockstore to restart from a snapshot. So fallthrough to refetch (if necessary) + // and reload the bundle. + + case dstore.ErrNotFound: + // we don't have a release key, we need to load the bundle + + default: + return result, xerrors.Errorf("error loading %s from datastore: %w", key, err) + } + + // we haven't recorded it in the datastore, so we need to load it + envvar := fmt.Sprintf("LOTUS_BUILTIN_ACTORS_V%d_BUNDLE", av) + var mfCid cid.Cid + switch { + case os.Getenv(envvar) != "": + path := os.Getenv(envvar) + + mfCid, err = bundle.LoadBundle(ctx, bs, path, av) + if err != nil { + return result, err + } + + case bd.Path[netw] != "": + // this is a local bundle, load it directly from the filessystem + mfCid, err = bundle.LoadBundle(ctx, bs, bd.Path[netw], av) + if err != nil { + return result, err + } + + case bd.URL[netw].URL != "": + // fetch it from the specified URL + mfCid, err = bundle.FetchAndLoadBundleFromURL(ctx, r.Path(), bs, av, bd.Release, netw, bd.URL[netw].URL, bd.URL[netw].Checksum) + if err != nil { + return result, err + } + + case bd.Release != "": + // fetch it and add it to the blockstore + mfCid, err = bundle.FetchAndLoadBundleFromRelease(ctx, r.Path(), bs, av, bd.Release, netw) + if err != nil { + return result, err + } + + default: + return result, xerrors.Errorf("no release or path specified for version %d bundle", av) + } + + if bd.Development || bd.Release == "" { + // don't store the release key so that we always load development bundles + continue + } + + // add the release key with the manifest to avoid reloading it in next restart. + if err := ds.Put(ctx, key, mfCid.Bytes()); err != nil { + return result, xerrors.Errorf("error storing manifest CID for builtin-actors vrsion %d to the datastore: %w", av, err) + } + } + + // we've loaded all the bundles, now load the manifests to get actor code CIDs. + cborStore := cbor.NewCborStore(bs) + if err := actors.LoadManifests(ctx, cborStore); err != nil { + return result, xerrors.Errorf("error loading actor manifests: %w", err) + } + + return result, nil +} + +// for itests +var testingBundleMx sync.Mutex + +func LoadBuiltinActorsTesting(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.UniversalBlockstore) (result dtypes.BuiltinActorsLoaded, err error) { + ctx := helpers.LifecycleCtx(mctx, lc) + + var netw string + if build.InsecurePoStValidation { + netw = "testing-fake-proofs" + } else { + netw = "testing" + } + + testingBundleMx.Lock() + defer testingBundleMx.Unlock() + + // don't clobber the bundle during migration + build.NetworkBundle = netw + + const basePath = "/tmp/lotus-testing" + for av, bd := range build.BuiltinActorReleases { + switch { + case bd.Path[netw] != "": + if _, err := bundle.LoadBundle(ctx, bs, bd.Path[netw], av); err != nil { + return result, xerrors.Errorf("error loading testing bundle for builtin-actors version %d/%s: %w", av, netw, err) + } + + case bd.URL[netw].URL != "": + // fetch it from the specified URL + if _, err := bundle.FetchAndLoadBundleFromURL(ctx, basePath, bs, av, bd.Release, netw, bd.URL[netw].URL, bd.URL[netw].Checksum); err != nil { + return result, err + } + + case bd.Release != "": + if _, err := bundle.FetchAndLoadBundleFromRelease(ctx, basePath, bs, av, bd.Release, netw); err != nil { + return result, xerrors.Errorf("error loading testing bundle for builtin-actors version %d/%s: %w", av, netw, err) + } + + default: + return result, xerrors.Errorf("no path or release specified for version %d testing bundle", av) + } + } + + cborStore := cbor.NewCborStore(bs) + if err := actors.LoadManifests(ctx, cborStore); err != nil { + return result, xerrors.Errorf("error loading actor manifests: %w", err) + } + + return result, nil +} diff --git a/node/modules/chain.go b/node/modules/chain.go index ff957c9ad..ceb18f316 100644 --- a/node/modules/chain.go +++ b/node/modules/chain.go @@ -18,6 +18,7 @@ import ( "github.com/filecoin-project/lotus/chain" "github.com/filecoin-project/lotus/chain/beacon" "github.com/filecoin-project/lotus/chain/consensus" + "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/exchange" "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/messagepool" @@ -176,3 +177,7 @@ func NewSyncer(params SyncerParams) (*chain.Syncer, error) { func NewSlashFilter(ds dtypes.MetadataDS) *slashfilter.SlashFilter { return slashfilter.New(ds) } + +func UpgradeSchedule(_ dtypes.BuiltinActorsLoaded) stmgr.UpgradeSchedule { + return filcns.DefaultUpgradeSchedule() +} diff --git a/node/modules/dtypes/chain.go b/node/modules/dtypes/chain.go index 0c924c12a..da18b8664 100644 --- a/node/modules/dtypes/chain.go +++ b/node/modules/dtypes/chain.go @@ -2,3 +2,4 @@ package dtypes type NetworkName string type AfterGenesisSet struct{} +type BuiltinActorsLoaded struct{} diff --git a/node/modules/genesis.go b/node/modules/genesis.go index 03b4e2907..5aea2a5b4 100644 --- a/node/modules/genesis.go +++ b/node/modules/genesis.go @@ -22,8 +22,8 @@ func ErrorGenesis() Genesis { } } -func LoadGenesis(genBytes []byte) func(fx.Lifecycle, helpers.MetricsCtx, dtypes.ChainBlockstore) Genesis { - return func(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.ChainBlockstore) Genesis { +func LoadGenesis(genBytes []byte) func(fx.Lifecycle, helpers.MetricsCtx, dtypes.ChainBlockstore, dtypes.BuiltinActorsLoaded) Genesis { + return func(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.ChainBlockstore, _ dtypes.BuiltinActorsLoaded) Genesis { return func() (header *types.BlockHeader, e error) { ctx := helpers.LifecycleCtx(mctx, lc) c, err := car.LoadCar(ctx, bs, bytes.NewReader(genBytes)) @@ -49,7 +49,7 @@ func LoadGenesis(genBytes []byte) func(fx.Lifecycle, helpers.MetricsCtx, dtypes. func DoSetGenesis(_ dtypes.AfterGenesisSet) {} -func SetGenesis(lc fx.Lifecycle, mctx helpers.MetricsCtx, cs *store.ChainStore, g Genesis) (dtypes.AfterGenesisSet, error) { +func SetGenesis(lc fx.Lifecycle, mctx helpers.MetricsCtx, cs *store.ChainStore, g Genesis, _ dtypes.BuiltinActorsLoaded) (dtypes.AfterGenesisSet, error) { ctx := helpers.LifecycleCtx(mctx, lc) genFromRepo, err := cs.GetGenesis(ctx) if err == nil { diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 09b8b6f31..ae3628764 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -219,6 +219,8 @@ type StorageMinerParams struct { Journal journal.Journal AddrSel *storage.AddressSelector Maddr dtypes.MinerAddress + + ManifestLoaded dtypes.BuiltinActorsLoaded } func StorageMiner(fc config.MinerFeeConfig) func(params StorageMinerParams) (*storage.Miner, error) { diff --git a/node/modules/testing/genesis.go b/node/modules/testing/genesis.go index a3d25e36a..68d792d83 100644 --- a/node/modules/testing/genesis.go +++ b/node/modules/testing/genesis.go @@ -30,8 +30,8 @@ import ( var glog = logging.Logger("genesis") -func MakeGenesisMem(out io.Writer, template genesis.Template) func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal) modules.Genesis { - return func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal) modules.Genesis { +func MakeGenesisMem(out io.Writer, template genesis.Template) func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal, _ dtypes.BuiltinActorsLoaded) modules.Genesis { + return func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal, _ dtypes.BuiltinActorsLoaded) modules.Genesis { return func() (*types.BlockHeader, error) { glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network") b, err := genesis2.MakeGenesisBlock(context.TODO(), j, bs, syscalls, template) @@ -51,8 +51,8 @@ func MakeGenesisMem(out io.Writer, template genesis.Template) func(bs dtypes.Cha } } -func MakeGenesis(outFile, genesisTemplate string) func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal) modules.Genesis { - return func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal) modules.Genesis { +func MakeGenesis(outFile, genesisTemplate string) func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal, _ dtypes.BuiltinActorsLoaded) modules.Genesis { + return func(bs dtypes.ChainBlockstore, syscalls vm.SyscallBuilder, j journal.Journal, _ dtypes.BuiltinActorsLoaded) modules.Genesis { return func() (*types.BlockHeader, error) { glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network") genesisTemplate, err := homedir.Expand(genesisTemplate) diff --git a/paychmgr/cbor_gen.go b/paychmgr/cbor_gen.go index 9f12b60a2..450d526d8 100644 --- a/paychmgr/cbor_gen.go +++ b/paychmgr/cbor_gen.go @@ -9,7 +9,7 @@ import ( "sort" address "github.com/filecoin-project/go-address" - paych "github.com/filecoin-project/specs-actors/actors/builtin/paych" + paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" diff --git a/paychmgr/manager.go b/paychmgr/manager.go index ea77c67ef..f91cd793a 100644 --- a/paychmgr/manager.go +++ b/paychmgr/manager.go @@ -5,6 +5,8 @@ import ( "errors" "sync" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" logging "github.com/ipfs/go-log/v2" @@ -87,6 +89,7 @@ func newManager(pchstore *Store, pchapi managerAPI) (*Manager, error) { channels: make(map[string]*channelAccessor), pchapi: pchapi, } + pm.ctx, pm.shutdown = context.WithCancel(context.Background()) return pm, pm.Start() } @@ -206,7 +209,7 @@ func (pm *Manager) GetChannelInfo(ctx context.Context, addr address.Address) (*C return ca.getChannelInfo(ctx, addr) } -func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*api.VoucherCreateResult, error) { +func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paychtypes.SignedVoucher) (*api.VoucherCreateResult, error) { ca, err := pm.accessorByAddress(ctx, ch) if err != nil { return nil, err @@ -218,7 +221,7 @@ func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, vouche // CheckVoucherValid checks if the given voucher is valid (is or could become spendable at some point). // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). -func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error { +func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher) error { // Get an accessor for the channel, creating it from state if necessary ca, err := pm.inboundChannelAccessor(ctx, ch) if err != nil { @@ -230,7 +233,7 @@ func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv } // CheckVoucherSpendable checks if the given voucher is currently spendable -func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, secret []byte, proof []byte) (bool, error) { if len(proof) > 0 { return false, errProofNotSupported } @@ -244,7 +247,7 @@ func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address // AddVoucherOutbound adds a voucher for an outbound channel. // Returns an error if the channel is not already in the store. -func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) { +func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) { if len(proof) > 0 { return types.NewInt(0), errProofNotSupported } @@ -258,7 +261,7 @@ func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, s // AddVoucherInbound adds a voucher for an inbound channel. // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). -func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) { +func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) { if len(proof) > 0 { return types.NewInt(0), errProofNotSupported } @@ -331,7 +334,7 @@ func (pm *Manager) trackInboundChannel(ctx context.Context, ch address.Address) } // TODO: secret vs proof doesn't make sense, there is only one, not two -func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { +func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *paychtypes.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { if len(proof) > 0 { return cid.Undef, errProofNotSupported } diff --git a/paychmgr/mock_test.go b/paychmgr/mock_test.go index 2c891803b..d1325ad31 100644 --- a/paychmgr/mock_test.go +++ b/paychmgr/mock_test.go @@ -136,7 +136,7 @@ func newMockPaychAPI() *mockPaychAPI { func (pchapi *mockPaychAPI) StateWaitMsg(ctx context.Context, mcid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) { pchapi.lk.Lock() - response := make(chan types.MessageReceipt) + response := make(chan types.MessageReceipt, 1) if response, ok := pchapi.waitingResponses[mcid]; ok { defer pchapi.lk.Unlock() @@ -151,8 +151,12 @@ func (pchapi *mockPaychAPI) StateWaitMsg(ctx context.Context, mcid cid.Cid, conf pchapi.waitingCalls[mcid] = &waitingCall{response: response} pchapi.lk.Unlock() - receipt := <-response - return &api.MsgLookup{Receipt: receipt}, nil + select { + case receipt := <-response: + return &api.MsgLookup{Receipt: receipt}, nil + case <-ctx.Done(): + return nil, ctx.Err() + } } func (pchapi *mockPaychAPI) receiveMsgResponse(mcid cid.Cid, receipt types.MessageReceipt) { diff --git a/paychmgr/paych.go b/paychmgr/paych.go index 5fdb4d884..e0ea00d62 100644 --- a/paychmgr/paych.go +++ b/paychmgr/paych.go @@ -4,16 +4,18 @@ import ( "context" "fmt" + lpaych "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" cborutil "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/sigs" ) @@ -82,7 +84,7 @@ func newChannelAccessor(pm *Manager, from address.Address, to address.Address) * } } -func (ca *channelAccessor) messageBuilder(ctx context.Context, from address.Address) (paych.MessageBuilder, error) { +func (ca *channelAccessor) messageBuilder(ctx context.Context, from address.Address) (lpaych.MessageBuilder, error) { nwVersion, err := ca.api.StateNetworkVersion(ctx, types.EmptyTSK) if err != nil { return nil, err @@ -92,7 +94,7 @@ func (ca *channelAccessor) messageBuilder(ctx context.Context, from address.Addr if err != nil { return nil, err } - return paych.Message(av, from), nil + return lpaych.Message(av, from), nil } func (ca *channelAccessor) getChannelInfo(ctx context.Context, addr address.Address) (*ChannelInfo, error) { @@ -172,14 +174,14 @@ func (ca *channelAccessor) nextNonceForLane(ci *ChannelInfo, lane uint64) uint64 return maxnonce + 1 } -func (ca *channelAccessor) checkVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (map[uint64]paych.LaneState, error) { +func (ca *channelAccessor) checkVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (map[uint64]lpaych.LaneState, error) { ca.lk.Lock() defer ca.lk.Unlock() return ca.checkVoucherValidUnlocked(ctx, ch, sv) } -func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (map[uint64]paych.LaneState, error) { +func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (map[uint64]lpaych.LaneState, error) { if sv.ChannelAddr != ch { return nil, xerrors.Errorf("voucher ChannelAddr doesn't match channel address, got %s, expected %s", sv.ChannelAddr, ch) } @@ -194,7 +196,7 @@ func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch add if sv.TimeLockMin != 0 { return nil, xerrors.Errorf("voucher is Min Time Locked") } - if len(sv.SecretPreimage) != 0 { + if len(sv.SecretHash) != 0 { return nil, xerrors.Errorf("voucher is Hash Locked") } @@ -479,7 +481,7 @@ func (ca *channelAccessor) listVouchers(ctx context.Context, ch address.Address) // laneState gets the LaneStates from chain, then applies all vouchers in // the data store over the chain state -func (ca *channelAccessor) laneState(ctx context.Context, state paych.State, ch address.Address) (map[uint64]paych.LaneState, error) { +func (ca *channelAccessor) laneState(ctx context.Context, state lpaych.State, ch address.Address) (map[uint64]lpaych.LaneState, error) { // TODO: we probably want to call UpdateChannelState with all vouchers to be fully correct // (but technically dont't need to) @@ -491,8 +493,8 @@ func (ca *channelAccessor) laneState(ctx context.Context, state paych.State, ch // Note: we use a map instead of an array to store laneStates because the // client sets the lane ID (the index) and potentially they could use a // very large index. - laneStates := make(map[uint64]paych.LaneState, laneCount) - err = state.ForEachLaneState(func(idx uint64, ls paych.LaneState) error { + laneStates := make(map[uint64]lpaych.LaneState, laneCount) + err = state.ForEachLaneState(func(idx uint64, ls lpaych.LaneState) error { laneStates[idx] = ls return nil }) @@ -535,7 +537,7 @@ func (ca *channelAccessor) laneState(ctx context.Context, state paych.State, ch } // Get the total redeemed amount across all lanes, after applying the voucher -func (ca *channelAccessor) totalRedeemedWithVoucher(laneStates map[uint64]paych.LaneState, sv *paych.SignedVoucher) (big.Int, error) { +func (ca *channelAccessor) totalRedeemedWithVoucher(laneStates map[uint64]lpaych.LaneState, sv *paych.SignedVoucher) (big.Int, error) { // TODO: merges if len(sv.Merges) != 0 { return big.Int{}, xerrors.Errorf("dont currently support paych lane merges") diff --git a/paychmgr/paych_test.go b/paychmgr/paych_test.go index 7f767510b..cec74d10b 100644 --- a/paychmgr/paych_test.go +++ b/paychmgr/paych_test.go @@ -6,6 +6,8 @@ import ( "context" "testing" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" ds_sync "github.com/ipfs/go-datastore/sync" @@ -16,7 +18,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/specs-actors/v2/actors/builtin" - paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" "github.com/filecoin-project/lotus/api" @@ -242,7 +243,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 1 voucherLane1Amt := big.NewInt(5) - voucher := paych.SignedVoucher{ + voucher := paychtypes.SignedVoucher{ Lane: 1, Amount: voucherLane1Amt, } @@ -258,7 +259,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 1 again, with a higher amount voucherLane1Amt = big.NewInt(8) - voucher = paych.SignedVoucher{ + voucher = paychtypes.SignedVoucher{ Lane: 1, Amount: voucherLane1Amt, } @@ -273,7 +274,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 2 that covers all the remaining funds // in the channel voucherLane2Amt := big.Sub(s.amt, voucherLane1Amt) - voucher = paych.SignedVoucher{ + voucher = paychtypes.SignedVoucher{ Lane: 2, Amount: voucherLane2Amt, } @@ -287,7 +288,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 2 that exceeds the remaining funds in the // channel voucherLane2Amt = big.Add(voucherLane2Amt, big.NewInt(1)) - voucher = paych.SignedVoucher{ + voucher = paychtypes.SignedVoucher{ Lane: 2, Amount: voucherLane2Amt, } @@ -637,7 +638,7 @@ func TestCheckSpendable(t *testing.T) { // Check that the secret was passed through correctly lastCall := s.mock.getLastCall() - var p paych2.UpdateChannelStateParams + var p paychtypes.UpdateChannelStateParams err = p.UnmarshalCBOR(bytes.NewReader(lastCall.Params)) require.NoError(t, err) require.Equal(t, secret, p.Secret) @@ -691,7 +692,7 @@ func TestSubmitVoucher(t *testing.T) { // Check that the secret was passed through correctly msg := s.mock.pushedMessages(submitCid) - var p paych2.UpdateChannelStateParams + var p paychtypes.UpdateChannelStateParams err = p.UnmarshalCBOR(bytes.NewReader(msg.Message.Params)) require.NoError(t, err) @@ -703,7 +704,7 @@ func TestSubmitVoucher(t *testing.T) { require.NoError(t, err) msg = s.mock.pushedMessages(submitCid) - var p3 paych2.UpdateChannelStateParams + var p3 paychtypes.UpdateChannelStateParams err = p3.UnmarshalCBOR(bytes.NewReader(msg.Message.Params)) require.NoError(t, err) @@ -789,8 +790,8 @@ func testGenerateKeyPair(t *testing.T) ([]byte, []byte) { return priv, pub } -func createTestVoucher(t *testing.T, ch address.Address, voucherLane uint64, nonce uint64, voucherAmount big.Int, key []byte) *paych2.SignedVoucher { - sv := &paych2.SignedVoucher{ +func createTestVoucher(t *testing.T, ch address.Address, voucherLane uint64, nonce uint64, voucherAmount big.Int, key []byte) *paychtypes.SignedVoucher { + sv := &paychtypes.SignedVoucher{ ChannelAddr: ch, Lane: voucherLane, Nonce: nonce, @@ -805,13 +806,13 @@ func createTestVoucher(t *testing.T, ch address.Address, voucherLane uint64, non return sv } -func createTestVoucherWithExtra(t *testing.T, ch address.Address, voucherLane uint64, nonce uint64, voucherAmount big.Int, key []byte) *paych2.SignedVoucher { //nolint:deadcode - sv := &paych2.SignedVoucher{ +func createTestVoucherWithExtra(t *testing.T, ch address.Address, voucherLane uint64, nonce uint64, voucherAmount big.Int, key []byte) *paychtypes.SignedVoucher { //nolint:deadcode + sv := &paychtypes.SignedVoucher{ ChannelAddr: ch, Lane: voucherLane, Nonce: nonce, Amount: voucherAmount, - Extra: &paych2.ModVerifyParams{ + Extra: &paychtypes.ModVerifyParams{ Actor: tutils.NewActorAddr(t, "act"), }, } @@ -829,13 +830,13 @@ type mockBestSpendableAPI struct { mgr *Manager } -func (m *mockBestSpendableAPI) PaychVoucherList(ctx context.Context, ch address.Address) ([]*paych2.SignedVoucher, error) { +func (m *mockBestSpendableAPI) PaychVoucherList(ctx context.Context, ch address.Address) ([]*paychtypes.SignedVoucher, error) { vi, err := m.mgr.ListVouchers(ctx, ch) if err != nil { return nil, err } - out := make([]*paych2.SignedVoucher, len(vi)) + out := make([]*paychtypes.SignedVoucher, len(vi)) for k, v := range vi { out[k] = v.Voucher } @@ -843,7 +844,7 @@ func (m *mockBestSpendableAPI) PaychVoucherList(ctx context.Context, ch address. return out, nil } -func (m *mockBestSpendableAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, voucher *paych2.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (m *mockBestSpendableAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, voucher *paychtypes.SignedVoucher, secret []byte, proof []byte) (bool, error) { return m.mgr.CheckVoucherSpendable(ctx, ch, voucher, secret, proof) } diff --git a/paychmgr/paychget_test.go b/paychmgr/paychget_test.go index 9c5f3b47b..e18639794 100644 --- a/paychmgr/paychget_test.go +++ b/paychmgr/paychget_test.go @@ -631,7 +631,7 @@ func TestPaychGetRestartAfterAddFundsMsg(t *testing.T) { require.NoError(t, err) // Simulate shutting down system - mock.close() + require.NoError(t, mgr.Stop()) // Create a new manager with the same datastore mock2 := newMockManagerAPI() diff --git a/paychmgr/paychvoucherfunds_test.go b/paychmgr/paychvoucherfunds_test.go index dc894a04f..f44f75e4c 100644 --- a/paychmgr/paychvoucherfunds_test.go +++ b/paychmgr/paychvoucherfunds_test.go @@ -4,6 +4,8 @@ import ( "context" "testing" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/ipfs/go-cid" @@ -68,7 +70,7 @@ func TestPaychAddVoucherAfterAddFunds(t *testing.T) { require.NoError(t, err) // Create a voucher with a value equal to the channel balance - voucher := paych.SignedVoucher{Amount: createAmt, Lane: 1} + voucher := paychtypes.SignedVoucher{Amount: createAmt, Lane: 1} res, err := mgr.CreateVoucher(ctx, ch, voucher) require.NoError(t, err) require.NotNil(t, res.Voucher) @@ -76,7 +78,7 @@ func TestPaychAddVoucherAfterAddFunds(t *testing.T) { // Create a voucher in a different lane with an amount that exceeds the // channel balance excessAmt := types.NewInt(5) - voucher = paych.SignedVoucher{Amount: excessAmt, Lane: 2} + voucher = paychtypes.SignedVoucher{Amount: excessAmt, Lane: 2} res, err = mgr.CreateVoucher(ctx, ch, voucher) require.NoError(t, err) require.Nil(t, res.Voucher) diff --git a/paychmgr/settler/settler.go b/paychmgr/settler/settler.go index 38fcc3b92..0984b207f 100644 --- a/paychmgr/settler/settler.go +++ b/paychmgr/settler/settler.go @@ -13,10 +13,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin" + paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/impl/full" @@ -38,9 +39,9 @@ type API struct { type settlerAPI interface { PaychList(context.Context) ([]address.Address, error) PaychStatus(context.Context, address.Address) (*api.PaychStatus, error) - PaychVoucherCheckSpendable(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error) - PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error) - PaychVoucherSubmit(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (cid.Cid, error) + PaychVoucherCheckSpendable(context.Context, address.Address, *paychtypes.SignedVoucher, []byte, []byte) (bool, error) + PaychVoucherList(context.Context, address.Address) ([]*paychtypes.SignedVoucher, error) + PaychVoucherSubmit(context.Context, address.Address, *paychtypes.SignedVoucher, []byte, []byte) (cid.Cid, error) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error) } @@ -94,7 +95,7 @@ func (pcs *paymentChannelSettler) messageHandler(msg *types.Message, rec *types. if err != nil { return true, err } - go func(voucher *paych.SignedVoucher, submitMessageCID cid.Cid) { + go func(voucher *paychtypes.SignedVoucher, submitMessageCID cid.Cid) { defer wg.Done() msgLookup, err := pcs.api.StateWaitMsg(pcs.ctx, submitMessageCID, build.MessageConfidence, api.LookbackNoLimit, true) if err != nil { @@ -116,7 +117,7 @@ func (pcs *paymentChannelSettler) revertHandler(ctx context.Context, ts *types.T func (pcs *paymentChannelSettler) matcher(msg *types.Message) (matched bool, err error) { // Check if this is a settle payment channel message - if msg.Method != paych.Methods.Settle { + if msg.Method != builtin.MethodsPaych.Settle { return false, nil } // Check if this payment channel is of concern to this node (i.e. tracked in payment channel store), diff --git a/paychmgr/simple.go b/paychmgr/simple.go index 3d0992efe..8e8363ffc 100644 --- a/paychmgr/simple.go +++ b/paychmgr/simple.go @@ -3,6 +3,7 @@ package paychmgr import ( "bytes" "context" + "errors" "fmt" "sort" "sync" @@ -351,6 +352,11 @@ func (ca *channelAccessor) queueSize() int { // msgWaitComplete is called when the message for a previous task is confirmed // or there is an error. func (ca *channelAccessor) msgWaitComplete(ctx context.Context, mcid cid.Cid, err error) { + // if context is canceled, should Not mark message to 'bad', just return. + if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { + return + } + ca.lk.Lock() defer ca.lk.Unlock() diff --git a/paychmgr/store.go b/paychmgr/store.go index f3c67e565..671537afe 100644 --- a/paychmgr/store.go +++ b/paychmgr/store.go @@ -19,7 +19,7 @@ import ( "github.com/filecoin-project/go-address" cborrpc "github.com/filecoin-project/go-cbor-util" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" ) var ErrChannelNotTracked = errors.New("channel not tracked") diff --git a/paychmgr/util.go b/paychmgr/util.go index 8e5dd4fab..2e9965ff2 100644 --- a/paychmgr/util.go +++ b/paychmgr/util.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/actors/builtin/paych" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" ) type BestSpendableAPI interface { diff --git a/storage/adapter_storage_miner.go b/storage/adapter_storage_miner.go index d976d9aa2..4acf86f95 100644 --- a/storage/adapter_storage_miner.go +++ b/storage/adapter_storage_miner.go @@ -19,6 +19,7 @@ import ( market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" @@ -49,7 +50,7 @@ func (s SealingAPIAdapter) StateMinerSectorSize(ctx context.Context, maddr addre return mi.SectorSize, nil } -func (s SealingAPIAdapter) StateMinerPreCommitDepositForPower(ctx context.Context, a address.Address, pci miner.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) { +func (s SealingAPIAdapter) StateMinerPreCommitDepositForPower(ctx context.Context, a address.Address, pci minertypes.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) { tsk, err := types.TipSetKeyFromBytes(tok) if err != nil { return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) @@ -58,7 +59,7 @@ func (s SealingAPIAdapter) StateMinerPreCommitDepositForPower(ctx context.Contex return s.delegate.StateMinerPreCommitDepositForPower(ctx, a, pci, tsk) } -func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, pci miner.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) { +func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, pci minertypes.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) { tsk, err := types.TipSetKeyFromBytes(tok) if err != nil { return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) @@ -67,10 +68,10 @@ func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context return s.delegate.StateMinerInitialPledgeCollateral(ctx, a, pci, tsk) } -func (s SealingAPIAdapter) StateMinerInfo(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (miner.MinerInfo, error) { +func (s SealingAPIAdapter) StateMinerInfo(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (api.MinerInfo, error) { tsk, err := types.TipSetKeyFromBytes(tok) if err != nil { - return miner.MinerInfo{}, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) + return api.MinerInfo{}, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) } // TODO: update storage-fsm to just StateMinerInfo @@ -240,7 +241,7 @@ func (s SealingAPIAdapter) StateComputeDataCommitment(ctx context.Context, maddr return cid.Cid(cr.CommDs[0]), nil } -func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*miner.SectorPreCommitOnChainInfo, error) { +func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*minertypes.SectorPreCommitOnChainInfo, error) { tsk, err := types.TipSetKeyFromBytes(tok) if err != nil { return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) diff --git a/storage/addresses.go b/storage/addresses.go index f8f06ed98..2c9b381cd 100644 --- a/storage/addresses.go +++ b/storage/addresses.go @@ -8,7 +8,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) @@ -24,7 +23,7 @@ type AddressSelector struct { api.AddressConfig } -func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { +func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { if as == nil { // should only happen in some tests log.Warnw("smart address selection disabled, using worker address") @@ -82,7 +81,7 @@ func (as *AddressSelector) AddressFor(ctx context.Context, a addrSelectApi, mi m return pickAddress(ctx, a, mi, goodFunds, minFunds, addrs) } -func pickAddress(ctx context.Context, a addrSelectApi, mi miner.MinerInfo, goodFunds, minFunds abi.TokenAmount, addrs []address.Address) (address.Address, abi.TokenAmount, error) { +func pickAddress(ctx context.Context, a addrSelectApi, mi api.MinerInfo, goodFunds, minFunds abi.TokenAmount, addrs []address.Address) (address.Address, abi.TokenAmount, error) { leastBad := mi.Worker bestAvail := minFunds diff --git a/storage/miner.go b/storage/miner.go index c52b786ee..5a97c5f6a 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -22,11 +22,13 @@ import ( sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/chain/types" @@ -83,8 +85,8 @@ type fullNodeFilteredAPI interface { StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error) StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) - StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) - StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) + StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) + StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tok types.TipSetKey) (types.BigInt, error) StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*miner.SectorOnChainInfo, error) StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error) @@ -189,7 +191,7 @@ func (m *Miner) Run(ctx context.Context) error { pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, cfg, provingBuffer) // address selector. - as := func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { + as := func(ctx context.Context, mi api.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { return m.addrSel.AddressFor(ctx, m.api, mi, use, goodFunds, minFunds) } diff --git a/storage/mockstorage/preseal.go b/storage/mockstorage/preseal.go index 66a2a5054..4e5b2306c 100644 --- a/storage/mockstorage/preseal.go +++ b/storage/mockstorage/preseal.go @@ -3,14 +3,15 @@ package mockstorage import ( "fmt" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-commp-utils/zerocomm" commcid "github.com/filecoin-project/go-fil-commcid" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/extern/sector-storage/mock" - - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" + "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/wallet" @@ -39,6 +40,11 @@ func PreSeal(spt abi.RegisteredSealProof, maddr address.Address, sectors int) (* } for i := range genm.Sectors { + label, err := markettypes.NewLabelFromString(fmt.Sprintf("%d", i)) + if err != nil { + return nil, nil, xerrors.Errorf("failed to create label: %w", err) + } + preseal := &genesis.PreSeal{} preseal.ProofType = spt @@ -47,18 +53,19 @@ func PreSeal(spt abi.RegisteredSealProof, maddr address.Address, sectors int) (* r := mock.CommDR(d) preseal.CommR, _ = commcid.ReplicaCommitmentV1ToCID(r[:]) preseal.SectorID = abi.SectorNumber(i + 1) - preseal.Deal = market2.DealProposal{ + preseal.Deal = markettypes.DealProposal{ PieceCID: preseal.CommD, PieceSize: abi.PaddedPieceSize(ssize), Client: k.Address, Provider: maddr, - Label: fmt.Sprintf("%d", i), + Label: label, StartEpoch: 1, EndEpoch: 10000, StoragePricePerEpoch: big.Zero(), ProviderCollateral: big.Zero(), ClientCollateral: big.Zero(), } + preseal.DealClientKey = k genm.Sectors[i] = preseal } diff --git a/storage/wdpost_changehandler.go b/storage/wdpost_changehandler.go index 9540182b5..ce39eb37d 100644 --- a/storage/wdpost_changehandler.go +++ b/storage/wdpost_changehandler.go @@ -7,8 +7,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/chain/types" ) diff --git a/storage/wdpost_changehandler_test.go b/storage/wdpost_changehandler_test.go index 00b1e94cc..a1f08c200 100644 --- a/storage/wdpost_changehandler_test.go +++ b/storage/wdpost_changehandler_test.go @@ -8,6 +8,8 @@ import ( "testing" "time" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + tutils "github.com/filecoin-project/specs-actors/support/testing" "github.com/filecoin-project/go-state-types/crypto" @@ -18,7 +20,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/dline" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" ) @@ -29,7 +30,7 @@ func init() { } type proveRes struct { - posts []miner.SubmitWindowedPoStParams + posts []minertypes.SubmitWindowedPoStParams err error } @@ -85,10 +86,10 @@ func (m *mockAPI) setDeadline(di *dline.Info) { } func (m *mockAPI) getDeadline(currentEpoch abi.ChainEpoch) *dline.Info { - close := miner.WPoStChallengeWindow - 1 + close := minertypes.WPoStChallengeWindow - 1 dlIdx := uint64(0) for close < currentEpoch { - close += miner.WPoStChallengeWindow + close += minertypes.WPoStChallengeWindow dlIdx++ } return NewDeadlineInfo(0, dlIdx, currentEpoch) @@ -161,7 +162,7 @@ func (m *mockAPI) startSubmitPoST( ctx context.Context, ts *types.TipSet, deadline *dline.Info, - posts []miner.SubmitWindowedPoStParams, + posts []minertypes.SubmitWindowedPoStParams, completeSubmitPoST CompleteSubmitPoSTCb, ) context.CancelFunc { ctx, cancel := context.WithCancel(ctx) @@ -225,7 +226,7 @@ func TestChangeHandlerBasic(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -291,7 +292,7 @@ func TestChangeHandlerFromProvingToSubmittingNoHeadChange(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -346,7 +347,7 @@ func TestChangeHandlerFromProvingEmptyProofsToComplete(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs with an empty proofs array - posts := []miner.SubmitWindowedPoStParams{} + posts := []minertypes.SubmitWindowedPoStParams{} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -368,7 +369,7 @@ func TestChangeHandlerDontStartUntilProvingPeriod(t *testing.T) { s := makeScaffolding(t) mock := s.mock - periodStart := miner.WPoStProvingPeriod + periodStart := minertypes.WPoStProvingPeriod dlIdx := uint64(1) currentEpoch := abi.ChainEpoch(10) di := NewDeadlineInfo(periodStart, dlIdx, currentEpoch) @@ -390,7 +391,7 @@ func TestChangeHandlerDontStartUntilProvingPeriod(t *testing.T) { } // Advance the head to the next proving period's first epoch - currentEpoch = periodStart + miner.WPoStChallengeWindow + currentEpoch = periodStart + minertypes.WPoStChallengeWindow di = NewDeadlineInfo(periodStart, dlIdx, currentEpoch) mock.setDeadline(di) go triggerHeadAdvance(t, s, currentEpoch) @@ -431,7 +432,7 @@ func TestChangeHandlerStartProvingNextDeadline(t *testing.T) { require.Equal(t, postStatusProving, s.mock.getPostStatus(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -466,7 +467,7 @@ func TestChangeHandlerProvingRounds(t *testing.T) { s.ch.start() completeProofIndex := abi.ChainEpoch(10) - for currentEpoch := abi.ChainEpoch(1); currentEpoch < miner.WPoStChallengeWindow*5; currentEpoch++ { + for currentEpoch := abi.ChainEpoch(1); currentEpoch < minertypes.WPoStChallengeWindow*5; currentEpoch++ { // Trigger a head change di := mock.getDeadline(currentEpoch) go triggerHeadAdvance(t, s, currentEpoch+ChallengeConfidence) @@ -507,7 +508,7 @@ func TestChangeHandlerProvingRounds(t *testing.T) { if currentEpoch == completeProofEpoch { // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -562,7 +563,7 @@ func TestChangeHandlerProvingErrorRecovery(t *testing.T) { require.Equal(t, postStatusProving, s.mock.getPostStatus(di)) // Send a success response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -597,7 +598,7 @@ func TestChangeHandlerSubmitErrorRecovery(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -665,7 +666,7 @@ func TestChangeHandlerProveExpiry(t *testing.T) { require.Equal(t, postStatusProving, s.mock.getPostStatus(di)) // Move to a height that expires the current proof - currentEpoch = miner.WPoStChallengeWindow + currentEpoch = minertypes.WPoStChallengeWindow di = mock.getDeadline(currentEpoch) go triggerHeadAdvance(t, s, currentEpoch) @@ -676,7 +677,7 @@ func TestChangeHandlerProveExpiry(t *testing.T) { require.True(t, mock.wasAbortCalled()) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -709,7 +710,7 @@ func TestChangeHandlerSubmitExpiry(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -726,7 +727,7 @@ func TestChangeHandlerSubmitExpiry(t *testing.T) { require.Equal(t, SubmitStateSubmitting, s.submitState(di)) // Move to a height that expires the submit - currentEpoch = miner.WPoStChallengeWindow + currentEpoch = minertypes.WPoStChallengeWindow di = mock.getDeadline(currentEpoch) go triggerHeadAdvance(t, s, currentEpoch) @@ -763,7 +764,7 @@ func TestChangeHandlerProveRevert(t *testing.T) { s.ch.start() // Trigger a head change - currentEpoch := miner.WPoStChallengeWindow + currentEpoch := minertypes.WPoStChallengeWindow go triggerHeadAdvance(t, s, currentEpoch) // Should start proving @@ -780,7 +781,7 @@ func TestChangeHandlerProveRevert(t *testing.T) { require.Equal(t, postStatusProving, s.mock.getPostStatus(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -806,7 +807,7 @@ func TestChangeHandlerSubmittingRevert(t *testing.T) { s.ch.start() // Trigger a head change - currentEpoch := miner.WPoStChallengeWindow + currentEpoch := minertypes.WPoStChallengeWindow go triggerHeadAdvance(t, s, currentEpoch) // Submitter doesn't have anything to do yet @@ -815,7 +816,7 @@ func TestChangeHandlerSubmittingRevert(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -881,7 +882,7 @@ func TestChangeHandlerSubmitCompleteRevert(t *testing.T) { s.ch.start() // Trigger a head change - currentEpoch := miner.WPoStChallengeWindow + currentEpoch := minertypes.WPoStChallengeWindow go triggerHeadAdvance(t, s, currentEpoch) // Submitter doesn't have anything to do yet @@ -890,7 +891,7 @@ func TestChangeHandlerSubmitCompleteRevert(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(di)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: di.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: di.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -946,7 +947,7 @@ func TestChangeHandlerSubmitRevertTwoEpochs(t *testing.T) { s.ch.start() // Trigger a head change - currentEpoch := miner.WPoStChallengeWindow + currentEpoch := minertypes.WPoStChallengeWindow go triggerHeadAdvance(t, s, currentEpoch) // Submitter doesn't have anything to do yet @@ -955,7 +956,7 @@ func TestChangeHandlerSubmitRevertTwoEpochs(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(diE1)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: diE1.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: diE1.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -981,7 +982,7 @@ func TestChangeHandlerSubmitRevertTwoEpochs(t *testing.T) { // Should start proving epoch 2 // Send a response to the call to generate proofs - postsE2 := []miner.SubmitWindowedPoStParams{{Deadline: diE2.Index}} + postsE2 := []minertypes.SubmitWindowedPoStParams{{Deadline: diE2.Index}} mock.proveResult <- &proveRes{posts: postsE2} // Should move to proving complete for epoch 2 @@ -1051,7 +1052,7 @@ func TestChangeHandlerSubmitRevertAdvanceLess(t *testing.T) { s.ch.start() // Trigger a head change - currentEpoch := miner.WPoStChallengeWindow + currentEpoch := minertypes.WPoStChallengeWindow go triggerHeadAdvance(t, s, currentEpoch) // Submitter doesn't have anything to do yet @@ -1060,7 +1061,7 @@ func TestChangeHandlerSubmitRevertAdvanceLess(t *testing.T) { require.Equal(t, SubmitStateStart, s.submitState(diE1)) // Send a response to the call to generate proofs - posts := []miner.SubmitWindowedPoStParams{{Deadline: diE1.Index}} + posts := []minertypes.SubmitWindowedPoStParams{{Deadline: diE1.Index}} mock.proveResult <- &proveRes{posts: posts} // Should move to proving complete @@ -1086,7 +1087,7 @@ func TestChangeHandlerSubmitRevertAdvanceLess(t *testing.T) { // Should start proving epoch 2 // Send a response to the call to generate proofs - postsE2 := []miner.SubmitWindowedPoStParams{{Deadline: diE2.Index}} + postsE2 := []minertypes.SubmitWindowedPoStParams{{Deadline: diE2.Index}} mock.proveResult <- &proveRes{posts: postsE2} // Should move to proving complete for epoch 2 diff --git a/storage/wdpost_journal.go b/storage/wdpost_journal.go index 48eb2f2b1..53519588f 100644 --- a/storage/wdpost_journal.go +++ b/storage/wdpost_journal.go @@ -2,9 +2,8 @@ package storage import ( "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/dline" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" - "github.com/ipfs/go-cid" ) diff --git a/storage/wdpost_nextdl_test.go b/storage/wdpost_nextdl_test.go index 31e8b7d6d..5de546a17 100644 --- a/storage/wdpost_nextdl_test.go +++ b/storage/wdpost_nextdl_test.go @@ -7,7 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" ) func TestNextDeadline(t *testing.T) { @@ -22,14 +23,14 @@ func TestNextDeadline(t *testing.T) { require.EqualValues(t, 0, di.Open) require.EqualValues(t, 60, di.Close) - for i := 1; i < 1+int(miner.WPoStPeriodDeadlines)*2; i++ { + for i := 1; i < 1+int(minertypes.WPoStPeriodDeadlines)*2; i++ { //stm: @WDPOST_NEXT_DEADLINE_001 di = nextDeadline(di) - deadlineIdx = i % int(miner.WPoStPeriodDeadlines) - expPeriodStart := int(miner.WPoStProvingPeriod) * (i / int(miner.WPoStPeriodDeadlines)) - expOpen := expPeriodStart + deadlineIdx*int(miner.WPoStChallengeWindow) - expClose := expOpen + int(miner.WPoStChallengeWindow) - expChallenge := expOpen - int(miner.WPoStChallengeLookback) + deadlineIdx = i % int(minertypes.WPoStPeriodDeadlines) + expPeriodStart := int(minertypes.WPoStProvingPeriod) * (i / int(minertypes.WPoStPeriodDeadlines)) + expOpen := expPeriodStart + deadlineIdx*int(minertypes.WPoStChallengeWindow) + expClose := expOpen + int(minertypes.WPoStChallengeWindow) + expChallenge := expOpen - int(minertypes.WPoStChallengeLookback) //fmt.Printf("%d: %d@%d %d-%d (%d)\n", i, expPeriodStart, deadlineIdx, expOpen, expClose, expChallenge) require.EqualValues(t, deadlineIdx, di.Index) require.EqualValues(t, expPeriodStart, di.PeriodStart) diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index 7bda4e548..66dba486f 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -5,6 +5,8 @@ import ( "context" "time" + "github.com/filecoin-project/go-state-types/proof" + "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/specs-storage/storage" @@ -19,13 +21,13 @@ import ( "go.opencensus.io/trace" "golang.org/x/xerrors" - "github.com/filecoin-project/specs-actors/v3/actors/runtime/proof" proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/types" @@ -323,7 +325,7 @@ func (s *WindowPoStScheduler) declareRecoveries(ctx context.Context, dlIdx uint6 msg := &types.Message{ To: s.actor, - Method: miner.Methods.DeclareFaultsRecovered, + Method: builtin.MethodsMiner.DeclareFaultsRecovered, Params: enc, Value: types.NewInt(0), } @@ -421,7 +423,7 @@ func (s *WindowPoStScheduler) declareFaults(ctx context.Context, dlIdx uint64, p msg := &types.Message{ To: s.actor, - Method: miner.Methods.DeclareFaults, + Method: builtin.MethodsMiner.DeclareFaults, Params: enc, Value: types.NewInt(0), // TODO: Is there a fee? } @@ -859,7 +861,7 @@ func (s *WindowPoStScheduler) submitPoStMessage(ctx context.Context, proof *mine msg := &types.Message{ To: s.actor, - Method: miner.Methods.SubmitWindowedPoSt, + Method: builtin.MethodsMiner.SubmitWindowedPoSt, Params: enc, Value: types.NewInt(0), } diff --git a/storage/wdpost_run_test.go b/storage/wdpost_run_test.go index cd61f15b7..6efb3e547 100644 --- a/storage/wdpost_run_test.go +++ b/storage/wdpost_run_test.go @@ -6,6 +6,12 @@ import ( "context" "testing" + prooftypes "github.com/filecoin-project/go-state-types/proof" + + "github.com/filecoin-project/lotus/chain/actors" + lbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/stretchr/testify/require" "golang.org/x/xerrors" @@ -15,14 +21,9 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/specs-storage/storage" - builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" - proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" + "github.com/filecoin-project/go-state-types/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" - builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" - miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" - "github.com/filecoin-project/specs-actors/v6/actors/runtime/proof" - proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" @@ -32,7 +33,6 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/extern/sector-storage/storiface" @@ -51,8 +51,8 @@ func newMockStorageMinerAPI() *mockStorageMinerAPI { } } -func (m *mockStorageMinerAPI) StateMinerInfo(ctx context.Context, a address.Address, key types.TipSetKey) (miner.MinerInfo, error) { - return miner.MinerInfo{ +func (m *mockStorageMinerAPI) StateMinerInfo(ctx context.Context, a address.Address, key types.TipSetKey) (api.MinerInfo, error) { + return api.MinerInfo{ Worker: tutils.NewIDAddr(nil, 101), Owner: tutils.NewIDAddr(nil, 101), }, nil @@ -78,13 +78,13 @@ func (m *mockStorageMinerAPI) StateMinerPartitions(ctx context.Context, a addres return m.partitions, nil } -func (m *mockStorageMinerAPI) StateMinerSectors(ctx context.Context, address address.Address, snos *bitfield.BitField, key types.TipSetKey) ([]*miner.SectorOnChainInfo, error) { - var sis []*miner.SectorOnChainInfo +func (m *mockStorageMinerAPI) StateMinerSectors(ctx context.Context, address address.Address, snos *bitfield.BitField, key types.TipSetKey) ([]*minertypes.SectorOnChainInfo, error) { + var sis []*minertypes.SectorOnChainInfo if snos == nil { panic("unsupported") } _ = snos.ForEach(func(i uint64) error { - sis = append(sis, &miner.SectorOnChainInfo{ + sis = append(sis, &minertypes.SectorOnChainInfo{ SectorNumber: abi.SectorNumber(i), }) return nil @@ -118,20 +118,20 @@ func (m *mockStorageMinerAPI) GasEstimateFeeCap(context.Context, *types.Message, type mockProver struct { } -func (m *mockProver) GenerateWinningPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte) ([]proof.PoStProof, error) { +func (m *mockProver) GenerateWinningPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte) ([]prooftypes.PoStProof, error) { panic("implement me") } -func (m *mockProver) GenerateWindowPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte, partitionIdx int) (proof.PoStProof, error) { +func (m *mockProver) GenerateWindowPoStWithVanilla(ctx context.Context, proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, proofs [][]byte, partitionIdx int) (prooftypes.PoStProof, error) { panic("implement me") } -func (m *mockProver) GenerateWinningPoSt(context.Context, abi.ActorID, []proof7.ExtendedSectorInfo, abi.PoStRandomness) ([]proof2.PoStProof, error) { +func (m *mockProver) GenerateWinningPoSt(context.Context, abi.ActorID, []prooftypes.ExtendedSectorInfo, abi.PoStRandomness) ([]prooftypes.PoStProof, error) { panic("implement me") } -func (m *mockProver) GenerateWindowPoSt(ctx context.Context, aid abi.ActorID, sis []proof7.ExtendedSectorInfo, pr abi.PoStRandomness) ([]proof2.PoStProof, []abi.SectorID, error) { - return []proof2.PoStProof{ +func (m *mockProver) GenerateWindowPoSt(ctx context.Context, aid abi.ActorID, sis []prooftypes.ExtendedSectorInfo, pr abi.PoStRandomness) ([]prooftypes.PoStProof, []abi.SectorID, error) { + return []prooftypes.PoStProof{ { PoStProof: abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, ProofBytes: []byte("post-proof"), @@ -142,11 +142,11 @@ func (m *mockProver) GenerateWindowPoSt(ctx context.Context, aid abi.ActorID, si type mockVerif struct { } -func (m mockVerif) VerifyWinningPoSt(ctx context.Context, info proof7.WinningPoStVerifyInfo) (bool, error) { +func (m mockVerif) VerifyWinningPoSt(ctx context.Context, info prooftypes.WinningPoStVerifyInfo) (bool, error) { panic("implement me") } -func (m mockVerif) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) { +func (m mockVerif) VerifyWindowPoSt(ctx context.Context, info prooftypes.WindowPoStVerifyInfo) (bool, error) { if len(info.Proofs) != 1 { return false, xerrors.Errorf("expected 1 proof entry") } @@ -159,15 +159,15 @@ func (m mockVerif) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStV return true, nil } -func (m mockVerif) VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) (bool, error) { +func (m mockVerif) VerifyAggregateSeals(aggregate prooftypes.AggregateSealVerifyProofAndInfos) (bool, error) { panic("implement me") } -func (m mockVerif) VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) (bool, error) { +func (m mockVerif) VerifyReplicaUpdate(update prooftypes.ReplicaUpdateInfo) (bool, error) { panic("implement me") } -func (m mockVerif) VerifySeal(proof2.SealVerifyInfo) (bool, error) { +func (m mockVerif) VerifySeal(prooftypes.SealVerifyInfo) (bool, error) { panic("implement me") } @@ -199,7 +199,7 @@ func TestWDPostDoPost(t *testing.T) { mockStgMinerAPI := newMockStorageMinerAPI() // Get the number of sectors allowed in a partition for this proof type - sectorsPerPartition, err := builtin5.PoStProofWindowPoStPartitionSectors(proofType) + sectorsPerPartition, err := builtin.PoStProofWindowPoStPartitionSectors(proofType) require.NoError(t, err) // Work out the number of partitions that can be included in a message // without exceeding the message sector limit @@ -207,8 +207,8 @@ func TestWDPostDoPost(t *testing.T) { //stm: @BLOCKCHAIN_POLICY_GET_MAX_POST_PARTITIONS_001 partitionsPerMsg, err := policy.GetMaxPoStPartitions(network.Version13, proofType) require.NoError(t, err) - if partitionsPerMsg > miner5.AddressedPartitionsMax { - partitionsPerMsg = miner5.AddressedPartitionsMax + if partitionsPerMsg > minertypes.AddressedPartitionsMax { + partitionsPerMsg = minertypes.AddressedPartitionsMax } // Enough partitions to fill expectedMsgCount-1 messages @@ -245,23 +245,23 @@ func TestWDPostDoPost(t *testing.T) { } di := &dline.Info{ - WPoStPeriodDeadlines: miner5.WPoStPeriodDeadlines, - WPoStProvingPeriod: miner5.WPoStProvingPeriod, - WPoStChallengeWindow: miner5.WPoStChallengeWindow, - WPoStChallengeLookback: miner5.WPoStChallengeLookback, - FaultDeclarationCutoff: miner5.FaultDeclarationCutoff, + WPoStPeriodDeadlines: minertypes.WPoStPeriodDeadlines, + WPoStProvingPeriod: minertypes.WPoStProvingPeriod, + WPoStChallengeWindow: minertypes.WPoStChallengeWindow, + WPoStChallengeLookback: minertypes.WPoStChallengeLookback, + FaultDeclarationCutoff: minertypes.FaultDeclarationCutoff, } ts := mockTipSet(t) - scheduler.startGeneratePoST(ctx, ts, di, func(posts []miner.SubmitWindowedPoStParams, err error) { + scheduler.startGeneratePoST(ctx, ts, di, func(posts []minertypes.SubmitWindowedPoStParams, err error) { scheduler.startSubmitPoST(ctx, ts, di, posts, func(err error) {}) }) // Read the window PoST messages for i := 0; i < expectedMsgCount; i++ { msg := <-mockStgMinerAPI.pushedMessages - require.Equal(t, miner.Methods.SubmitWindowedPoSt, msg.Method) - var params miner.SubmitWindowedPoStParams + require.Equal(t, builtin.MethodsMiner.SubmitWindowedPoSt, msg.Method) + var params minertypes.SubmitWindowedPoStParams err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)) require.NoError(t, err) @@ -305,11 +305,11 @@ func (m *mockStorageMinerAPI) StateMinerDeadlines(ctx context.Context, maddr add panic("implement me") } -func (m *mockStorageMinerAPI) StateSectorPreCommitInfo(ctx context.Context, address address.Address, number abi.SectorNumber, key types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) { +func (m *mockStorageMinerAPI) StateSectorPreCommitInfo(ctx context.Context, address address.Address, number abi.SectorNumber, key types.TipSetKey) (minertypes.SectorPreCommitOnChainInfo, error) { panic("implement me") } -func (m *mockStorageMinerAPI) StateSectorGetInfo(ctx context.Context, address address.Address, number abi.SectorNumber, key types.TipSetKey) (*miner.SectorOnChainInfo, error) { +func (m *mockStorageMinerAPI) StateSectorGetInfo(ctx context.Context, address address.Address, number abi.SectorNumber, key types.TipSetKey) (*minertypes.SectorOnChainInfo, error) { panic("implement me") } @@ -326,19 +326,19 @@ func (m *mockStorageMinerAPI) StateMinerProvingDeadline(ctx context.Context, add Close: 0, Challenge: 0, FaultCutoff: 0, - WPoStPeriodDeadlines: miner2.WPoStPeriodDeadlines, - WPoStProvingPeriod: miner2.WPoStProvingPeriod, - WPoStChallengeWindow: miner2.WPoStChallengeWindow, - WPoStChallengeLookback: miner2.WPoStChallengeLookback, - FaultDeclarationCutoff: miner2.FaultDeclarationCutoff, + WPoStPeriodDeadlines: minertypes.WPoStPeriodDeadlines, + WPoStProvingPeriod: minertypes.WPoStProvingPeriod, + WPoStChallengeWindow: minertypes.WPoStChallengeWindow, + WPoStChallengeLookback: minertypes.WPoStChallengeLookback, + FaultDeclarationCutoff: minertypes.FaultDeclarationCutoff, }, nil } -func (m *mockStorageMinerAPI) StateMinerPreCommitDepositForPower(ctx context.Context, address address.Address, info miner.SectorPreCommitInfo, key types.TipSetKey) (types.BigInt, error) { +func (m *mockStorageMinerAPI) StateMinerPreCommitDepositForPower(ctx context.Context, address address.Address, info minertypes.SectorPreCommitInfo, key types.TipSetKey) (types.BigInt, error) { panic("implement me") } -func (m *mockStorageMinerAPI) StateMinerInitialPledgeCollateral(ctx context.Context, address address.Address, info miner.SectorPreCommitInfo, key types.TipSetKey) (types.BigInt, error) { +func (m *mockStorageMinerAPI) StateMinerInitialPledgeCollateral(ctx context.Context, address address.Address, info minertypes.SectorPreCommitInfo, key types.TipSetKey) (types.BigInt, error) { panic("implement me") } @@ -347,8 +347,12 @@ func (m *mockStorageMinerAPI) StateSearchMsg(ctx context.Context, from types.Tip } func (m *mockStorageMinerAPI) StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error) { + code, err := lbuiltin.GetMinerActorCodeID(actors.Version7) + if err != nil { + return nil, err + } return &types.Actor{ - Code: builtin2.StorageMinerActorCodeID, + Code: code, }, nil } diff --git a/testplans/lotus-soup/go.mod b/testplans/lotus-soup/go.mod index 65cd77f42..3d06b3ca2 100644 --- a/testplans/lotus-soup/go.mod +++ b/testplans/lotus-soup/go.mod @@ -9,12 +9,12 @@ require ( github.com/drand/drand v1.3.0 github.com/filecoin-project/go-address v0.0.6 github.com/filecoin-project/go-data-transfer v1.15.1 - github.com/filecoin-project/go-fil-markets v1.20.1 + github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 github.com/filecoin-project/go-jsonrpc v0.1.5 - github.com/filecoin-project/go-state-types v0.1.3 + github.com/filecoin-project/go-state-types v0.1.7 github.com/filecoin-project/go-storedcounter v0.1.0 github.com/filecoin-project/lotus v0.0.0-00010101000000-000000000000 - github.com/filecoin-project/specs-actors v0.9.14 + github.com/filecoin-project/specs-actors v0.9.15 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/hashicorp/go-multierror v1.1.1 @@ -27,7 +27,7 @@ require ( github.com/ipfs/go-unixfs v0.3.1 github.com/ipld/go-car v0.3.3 github.com/kpacha/opencensus-influxdb v0.0.0-20181102202715-663e2683a27c - github.com/libp2p/go-libp2p v0.19.0 + github.com/libp2p/go-libp2p v0.19.4 github.com/libp2p/go-libp2p-core v0.15.1 github.com/libp2p/go-libp2p-pubsub-tracer v0.0.0-20200626141350-e730b32bf1e6 github.com/multiformats/go-multiaddr v0.5.0 @@ -94,7 +94,7 @@ require ( github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 // indirect - github.com/filecoin-project/go-legs v0.3.7 // indirect + github.com/filecoin-project/go-legs v0.3.10 // indirect github.com/filecoin-project/go-padreader v0.0.1 // indirect github.com/filecoin-project/go-paramfetch v0.0.4 // indirect github.com/filecoin-project/go-statemachine v1.0.2 // indirect @@ -102,12 +102,13 @@ require ( github.com/filecoin-project/index-provider v0.5.0 // indirect github.com/filecoin-project/pubsub v1.0.0 // indirect github.com/filecoin-project/specs-actors/v2 v2.3.6 // indirect - github.com/filecoin-project/specs-actors/v3 v3.1.1 // indirect - github.com/filecoin-project/specs-actors/v4 v4.0.1 // indirect - github.com/filecoin-project/specs-actors/v5 v5.0.4 // indirect - github.com/filecoin-project/specs-actors/v6 v6.0.1 // indirect - github.com/filecoin-project/specs-actors/v7 v7.0.0 // indirect - github.com/filecoin-project/specs-storage v0.2.3-0.20220426183226-1a0a63c5990f // indirect + github.com/filecoin-project/specs-actors/v3 v3.1.2 // indirect + github.com/filecoin-project/specs-actors/v4 v4.0.2 // indirect + github.com/filecoin-project/specs-actors/v5 v5.0.6 // indirect + github.com/filecoin-project/specs-actors/v6 v6.0.2 // indirect + github.com/filecoin-project/specs-actors/v7 v7.0.1 // indirect + github.com/filecoin-project/specs-actors/v8 v8.0.0 // indirect + github.com/filecoin-project/specs-storage v0.4.1 // indirect github.com/filecoin-project/storetheindex v0.3.5 // indirect github.com/flynn/noise v1.0.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect @@ -214,7 +215,7 @@ require ( github.com/libp2p/go-libp2p-noise v0.4.0 // indirect github.com/libp2p/go-libp2p-peerstore v0.6.0 // indirect github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect - github.com/libp2p/go-libp2p-pubsub v0.6.1 // indirect + github.com/libp2p/go-libp2p-pubsub v0.7.0 // indirect github.com/libp2p/go-libp2p-quic-transport v0.17.0 // indirect github.com/libp2p/go-libp2p-record v0.1.3 // indirect github.com/libp2p/go-libp2p-resource-manager v0.2.1 // indirect @@ -235,8 +236,8 @@ require ( github.com/libp2p/go-stream-muxer-multistream v0.4.0 // indirect github.com/libp2p/go-tcp-transport v0.5.1 // indirect github.com/libp2p/go-ws-transport v0.6.0 // indirect - github.com/libp2p/go-yamux/v3 v3.1.1 // indirect - github.com/lucas-clemente/quic-go v0.27.0 // indirect + github.com/libp2p/go-yamux/v3 v3.1.2 // indirect + github.com/lucas-clemente/quic-go v0.27.1 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/magefile/mage v1.9.0 // indirect github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect @@ -284,7 +285,6 @@ require ( github.com/raulk/clock v1.1.0 // indirect github.com/raulk/go-watchdog v1.2.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rivo/uniseg v0.1.0 // indirect github.com/rs/cors v1.7.0 // indirect github.com/russross/blackfriday/v2 v2.0.1 // indirect @@ -296,7 +296,6 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/stretchr/testify v1.7.1 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect - github.com/tj/go-spin v1.1.0 // indirect github.com/uber/jaeger-client-go v2.28.0+incompatible // indirect github.com/uber/jaeger-lib v2.4.1+incompatible // indirect github.com/urfave/cli/v2 v2.3.0 // indirect @@ -306,14 +305,12 @@ require ( github.com/weaveworks/promrus v1.2.0 // indirect github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect - github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14 // indirect + github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799 // indirect github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/whyrusleeping/ledger-filecoin-go v0.9.1-0.20201010031517-c3dcc1bddce4 // indirect github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect - github.com/xlab/c-for-go v0.0.0-20201112171043-ea6dce5809cb // indirect - github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 // indirect github.com/zondax/hid v0.9.0 // indirect github.com/zondax/ledger-go v0.12.1 // indirect go.dedis.ch/fixbuf v1.0.3 // indirect @@ -345,11 +342,6 @@ require ( gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect lukechampine.com/blake3 v1.1.7 // indirect - modernc.org/cc v1.0.0 // indirect - modernc.org/golex v1.0.1 // indirect - modernc.org/mathutil v1.1.1 // indirect - modernc.org/strutil v1.1.0 // indirect - modernc.org/xc v1.0.0 // indirect ) // This will work in all build modes: docker:go, exec:go, and local go build. diff --git a/testplans/lotus-soup/go.sum b/testplans/lotus-soup/go.sum index 75ffd2a15..fb7c620e4 100644 --- a/testplans/lotus-soup/go.sum +++ b/testplans/lotus-soup/go.sum @@ -434,8 +434,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.20.1 h1:DwrFuNIWC0a2c2ESpHtdEMH3QCpR/hoZ5DwjNT+VJ+E= -github.com/filecoin-project/go-fil-markets v1.20.1/go.mod h1:QV767KIWHrikVK8R0u2wTc5wkee4gXOf5/AfxDoQckw= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-1 h1:/eZXwVg2Z7qPwTBUAinA7m6w6rLYBeSvE61XW8MTV5M= +github.com/filecoin-project/go-fil-markets v1.20.1-v16-1/go.mod h1:QHJZVEbQ7TydJ6hjK87q4MxOmRfDNbQkuSkdjxtqBWo= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= @@ -446,8 +446,9 @@ github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBw github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY= github.com/filecoin-project/go-jsonrpc v0.1.5 h1:ckxqZ09ivBAVf5CSmxxrqqNHC7PJm3GYGtYKiNQ+vGk= github.com/filecoin-project/go-jsonrpc v0.1.5/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4= -github.com/filecoin-project/go-legs v0.3.7 h1:yfm7fx+iy1nPtgPEQ6kQjvhoJOVbXide50STYdy+yos= github.com/filecoin-project/go-legs v0.3.7/go.mod h1:pgekGm8/gKY5zCtQ/qGAoSjGP92wTLFqpO3GPHeu8YU= +github.com/filecoin-project/go-legs v0.3.10 h1:B14z78do63gkxf5Br7rPnxZsZk/m9PR3Mx5aOf2WTIs= +github.com/filecoin-project/go-legs v0.3.10/go.mod h1:5psVRe2nRQDa3PDtcd+2Ud4CirxOr2DI5VsDVMq7sIk= github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20/go.mod h1:mPn+LRRd5gEKNAtc+r3ScpW2JRU/pj4NBKdADYWHiak= github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6XHig+ynSGJg8ZOs= github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ= @@ -458,11 +459,13 @@ github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-state-types v0.1.1-0.20210810190654-139e0e79e69e/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= -github.com/filecoin-project/go-state-types v0.1.1/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= -github.com/filecoin-project/go-state-types v0.1.3 h1:rzIJyQo5HO2ptc8Jcu8P0qTutnI7NWwTle54eAHoNO0= github.com/filecoin-project/go-state-types v0.1.3/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= +github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg= +github.com/filecoin-project/go-state-types v0.1.5/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.7 h1:r/ZzyUA+CqY8IXyHsLtliqRgPFaON+aC2MmWKm1nl98= +github.com/filecoin-project/go-state-types v0.1.7/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= -github.com/filecoin-project/go-statemachine v1.0.1/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc= github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= @@ -476,27 +479,33 @@ github.com/filecoin-project/index-provider v0.5.0/go.mod h1:KHVrP2vU3YuScb+fawOb github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM= github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg= github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= -github.com/filecoin-project/specs-actors v0.9.14 h1:68PVstg2UB3ZsMLF+DKFTAs/YKsqhKWynkr0IqmVRQY= -github.com/filecoin-project/specs-actors v0.9.14/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= +github.com/filecoin-project/specs-actors v0.9.15-0.20220514164640-94e0d5e123bd/go.mod h1:pjGEe3QlWtK20ju/aFRsiArbMX6Cn8rqEhhsiCM9xYE= +github.com/filecoin-project/specs-actors v0.9.15 h1:3VpKP5/KaDUHQKAMOg4s35g/syDaEBueKLws0vbsjMc= +github.com/filecoin-project/specs-actors v0.9.15/go.mod h1:pjGEe3QlWtK20ju/aFRsiArbMX6Cn8rqEhhsiCM9xYE= github.com/filecoin-project/specs-actors/v2 v2.3.5-0.20210114162132-5b58b773f4fb/go.mod h1:LljnY2Mn2homxZsmokJZCpRuhOPxfXhvcek5gWkmqAc= github.com/filecoin-project/specs-actors/v2 v2.3.6 h1:UxnWTfQd7JsOae39/aHCK0m1IBjdcyymCJfqxuSkn+g= github.com/filecoin-project/specs-actors/v2 v2.3.6/go.mod h1:DJMpxVRXvev9t8P0XWA26RmTzN+MHiL9IlItVLT0zUc= github.com/filecoin-project/specs-actors/v3 v3.1.0/go.mod h1:mpynccOLlIRy0QnR008BwYBwT9fen+sPR13MA1VmMww= -github.com/filecoin-project/specs-actors/v3 v3.1.1 h1:BE8fsns1GnEOxt1DTE5LxBK2FThXtWmCChgcJoHTg0E= -github.com/filecoin-project/specs-actors/v3 v3.1.1/go.mod h1:mpynccOLlIRy0QnR008BwYBwT9fen+sPR13MA1VmMww= +github.com/filecoin-project/specs-actors/v3 v3.1.2 h1:Gq3gAbvdGLA/D0GKz1IJfewt9Fh7gA32TPt46Xv+1Cw= +github.com/filecoin-project/specs-actors/v3 v3.1.2/go.mod h1:uOJn+m6W8OW/1mdWMEvxeM1cjQPxmps7s1Z4bJ9V4kY= github.com/filecoin-project/specs-actors/v4 v4.0.0/go.mod h1:TkHXf/l7Wyw4ZejyXIPS2rK8bBO0rdwhTZyQQgaglng= -github.com/filecoin-project/specs-actors/v4 v4.0.1 h1:AiWrtvJZ63MHGe6rn7tPu4nSUY8bA1KDNszqJaD5+Fg= -github.com/filecoin-project/specs-actors/v4 v4.0.1/go.mod h1:TkHXf/l7Wyw4ZejyXIPS2rK8bBO0rdwhTZyQQgaglng= -github.com/filecoin-project/specs-actors/v5 v5.0.4 h1:OY7BdxJWlUfUFXWV/kpNBYGXNPasDIedf42T3sGx08s= +github.com/filecoin-project/specs-actors/v4 v4.0.2 h1:VTsv30kIf1Keo8Jlu6Omco+2Ud0pG4EN5UAzyYCibh8= +github.com/filecoin-project/specs-actors/v4 v4.0.2/go.mod h1:zT0GVFxwFS93prGK0b/rMd1sePjRQKfAuodQ9DFAd6Y= github.com/filecoin-project/specs-actors/v5 v5.0.4/go.mod h1:5BAKRAMsOOlD8+qCw4UvT/lTLInCJ3JwOWZbX8Ipwq4= +github.com/filecoin-project/specs-actors/v5 v5.0.5/go.mod h1:dnfda2U+0ZidVnZJ44fnLMa3Mbyzwx51iW/brSsS+nc= +github.com/filecoin-project/specs-actors/v5 v5.0.6 h1:TLtA9hT3pHQF5vB83GmB+m6anw9u6MjdT+VVn/lyC+c= +github.com/filecoin-project/specs-actors/v5 v5.0.6/go.mod h1:myb/UGwESp0V1f1BACXSUrFgTWLvGUoG0ZZH7eqriFM= github.com/filecoin-project/specs-actors/v6 v6.0.0/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk= -github.com/filecoin-project/specs-actors/v6 v6.0.1 h1:laxvHNsvrq83Y9n+W7znVCePi3oLyRf0Rkl4jFO8Wew= github.com/filecoin-project/specs-actors/v6 v6.0.1/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk= -github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1.0.20220118005651-2470cb39827e/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= -github.com/filecoin-project/specs-actors/v7 v7.0.0 h1:FQN7tjt3o68hfb3qLFSJBoLMuOFY0REkFVLO/zXj8RU= +github.com/filecoin-project/specs-actors/v6 v6.0.2 h1:K1xPRJoW5PBvb08QF9+4w1AjcnqwR6BjTmeltQFCvWo= +github.com/filecoin-project/specs-actors/v6 v6.0.2/go.mod h1:wnfVvPnYmzPZilNvSqCSSA/ZQX3rdV/U/Vf9EIoQhrI= github.com/filecoin-project/specs-actors/v7 v7.0.0/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= -github.com/filecoin-project/specs-storage v0.2.3-0.20220426183226-1a0a63c5990f h1:+suJFu4RJt7aZRXvE+Innrpacap+Z8N87y6a1Cgkuqc= -github.com/filecoin-project/specs-storage v0.2.3-0.20220426183226-1a0a63c5990f/go.mod h1:6cc/lncmAxMUocPi0z1EPCX63beIX7F7UnlmUZ3hLQo= +github.com/filecoin-project/specs-actors/v7 v7.0.1 h1:w72xCxijK7xs1qzmJiw+WYJaVt2EPHN8oiwpA1Ay3/4= +github.com/filecoin-project/specs-actors/v7 v7.0.1/go.mod h1:tPLEYXoXhcpyLh69Ccq91SOuLXsPWjHiY27CzawjUEk= +github.com/filecoin-project/specs-actors/v8 v8.0.0 h1:c6NztoE4J5j7KvIfGmx9XW9o5aszPl6DU0M4xDqAJVU= +github.com/filecoin-project/specs-actors/v8 v8.0.0/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= +github.com/filecoin-project/specs-storage v0.4.1 h1:yvLEaLZj8f+uByhNC4mFOtCUyL2wQku+NGBp6hjTe9M= +github.com/filecoin-project/specs-storage v0.4.1/go.mod h1:Z2eK6uMwAOSLjek6+sy0jNV2DSsMEENziMUz0GHRFBw= github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q= github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI= github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E= @@ -1327,8 +1336,9 @@ github.com/libp2p/go-libp2p v0.16.0/go.mod h1:ump42BsirwAWxKzsCiFnTtN1Yc+DuPu76f github.com/libp2p/go-libp2p v0.17.0/go.mod h1:Fkin50rsGdv5mm5BshBUtPRZknt9esfmYXBOYcwOTgw= github.com/libp2p/go-libp2p v0.18.0-rc1/go.mod h1:RgYlH7IIWHXREimC92bw5Lg1V2R5XmSzuLHb5fTnr+8= github.com/libp2p/go-libp2p v0.18.0-rc3/go.mod h1:WYL+Xw1iuwi6rdfzw5VIEpD+HqzYucHZ6fcUuumbI3M= -github.com/libp2p/go-libp2p v0.19.0 h1:zosskMbaobL7UDCVLEe1m5CGs1TaFNFoN/M5XLiKg0U= -github.com/libp2p/go-libp2p v0.19.0/go.mod h1:Ki9jJXLO2YqrTIFxofV7Twyd3INWPT97+r8hGt7XPjI= +github.com/libp2p/go-libp2p v0.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI= +github.com/libp2p/go-libp2p v0.19.4 h1:50YL0YwPhWKDd+qbZQDEdnsmVAAkaCQrWUjpdHv4hNA= +github.com/libp2p/go-libp2p v0.19.4/go.mod h1:MIt8y481VDhUe4ErWi1a4bvt/CjjFfOq6kZTothWIXY= github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo= github.com/libp2p/go-libp2p-asn-util v0.1.0 h1:rABPCO77SjdbJ/eJ/ynIo8vWICy1VEnL5JAxJbQLo1E= github.com/libp2p/go-libp2p-asn-util v0.1.0/go.mod h1:wu+AnM9Ii2KgO5jMmS1rz9dvzTdj8BXqsPR9HR0XB7I= @@ -1490,8 +1500,9 @@ github.com/libp2p/go-libp2p-protocol v0.1.0/go.mod h1:KQPHpAabB57XQxGrXCNvbL6UEX github.com/libp2p/go-libp2p-pubsub v0.1.1/go.mod h1:ZwlKzRSe1eGvSIdU5bD7+8RZN/Uzw0t1Bp9R1znpR/Q= github.com/libp2p/go-libp2p-pubsub v0.3.2/go.mod h1:Uss7/Cfz872KggNb+doCVPHeCDmXB7z500m/R8DaAUk= github.com/libp2p/go-libp2p-pubsub v0.6.0/go.mod h1:nJv87QM2cU0w45KPR1rZicq+FmFIOD16zmT+ep1nOmg= -github.com/libp2p/go-libp2p-pubsub v0.6.1 h1:wycbV+f4rreCoVY61Do6g/BUk0RIrbNRcYVbn+QkjGk= github.com/libp2p/go-libp2p-pubsub v0.6.1/go.mod h1:nJv87QM2cU0w45KPR1rZicq+FmFIOD16zmT+ep1nOmg= +github.com/libp2p/go-libp2p-pubsub v0.7.0 h1:Fd9198JVc3pCsKuzd37TclzM0QcHA+uDyoiG2pvT7s4= +github.com/libp2p/go-libp2p-pubsub v0.7.0/go.mod h1:EuyBJFtF8qF67IEA98biwK8Xnw5MNJpJ/Z+8iWCMFwc= github.com/libp2p/go-libp2p-pubsub-router v0.5.0/go.mod h1:TRJKskSem3C0aSb3CmRgPwq6IleVFzds6hS09fmZbGM= github.com/libp2p/go-libp2p-pubsub-tracer v0.0.0-20200626141350-e730b32bf1e6 h1:2lH7rMlvDPSvXeOR+g7FE6aqiEwxtpxWKQL8uigk5fQ= github.com/libp2p/go-libp2p-pubsub-tracer v0.0.0-20200626141350-e730b32bf1e6/go.mod h1:8ZodgKS4qRLayfw9FDKDd9DX4C16/GMofDxSldG8QPI= @@ -1503,6 +1514,7 @@ github.com/libp2p/go-libp2p-quic-transport v0.13.0/go.mod h1:39/ZWJ1TW/jx1iFkKzz github.com/libp2p/go-libp2p-quic-transport v0.15.0/go.mod h1:wv4uGwjcqe8Mhjj7N/Ic0aKjA+/10UnMlSzLO0yRpYQ= github.com/libp2p/go-libp2p-quic-transport v0.15.2/go.mod h1:wv4uGwjcqe8Mhjj7N/Ic0aKjA+/10UnMlSzLO0yRpYQ= github.com/libp2p/go-libp2p-quic-transport v0.16.0/go.mod h1:1BXjVMzr+w7EkPfiHkKnwsWjPjtfaNT0q8RS3tGDvEQ= +github.com/libp2p/go-libp2p-quic-transport v0.16.1/go.mod h1:1BXjVMzr+w7EkPfiHkKnwsWjPjtfaNT0q8RS3tGDvEQ= github.com/libp2p/go-libp2p-quic-transport v0.17.0 h1:yFh4Gf5MlToAYLuw/dRvuzYd1EnE2pX3Lq1N6KDiWRQ= github.com/libp2p/go-libp2p-quic-transport v0.17.0/go.mod h1:x4pw61P3/GRCcSLypcQJE/Q2+E9f4X+5aRcZLXf20LM= github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= @@ -1598,6 +1610,7 @@ github.com/libp2p/go-libp2p-yamux v0.6.0/go.mod h1:MRhd6mAYnFRnSISp4M8i0ClV/j+mW github.com/libp2p/go-libp2p-yamux v0.7.0/go.mod h1:fMyA0CsPfHkIuBU0wjRGrCjTBFiXTXxG0k5M4ETv+08= github.com/libp2p/go-libp2p-yamux v0.8.0/go.mod h1:yTkPgN2ib8FHyU1ZcVD7aelzyAqXXwEPbyx+aSKm9h8= github.com/libp2p/go-libp2p-yamux v0.8.1/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE= +github.com/libp2p/go-libp2p-yamux v0.8.2/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE= github.com/libp2p/go-libp2p-yamux v0.9.1 h1:oplewiRix8s45SOrI30rCPZG5mM087YZp+VYhXAh4+c= github.com/libp2p/go-libp2p-yamux v0.9.1/go.mod h1:wRc6wvyxQINFcKe7daL4BeQ02Iyp+wxyC8WCNfngBrA= github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= @@ -1700,8 +1713,9 @@ github.com/libp2p/go-yamux/v2 v2.2.0/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZj github.com/libp2p/go-yamux/v2 v2.3.0/go.mod h1:iTU+lOIn/2h0AgKcL49clNTwfEw+WSfDYrXe05EyKIs= github.com/libp2p/go-yamux/v3 v3.0.1/go.mod h1:s2LsDhHbh+RfCsQoICSYt58U2f8ijtPANFD8BmE74Bo= github.com/libp2p/go-yamux/v3 v3.0.2/go.mod h1:s2LsDhHbh+RfCsQoICSYt58U2f8ijtPANFD8BmE74Bo= -github.com/libp2p/go-yamux/v3 v3.1.1 h1:X0qSVodCZciOu/f4KTp9V+O0LAqcqP2tdaUGB0+0lng= github.com/libp2p/go-yamux/v3 v3.1.1/go.mod h1:jeLEQgLXqE2YqX1ilAClIfCMDY+0uXQUKmmb/qp0gT4= +github.com/libp2p/go-yamux/v3 v3.1.2 h1:lNEy28MBk1HavUAlzKgShp+F6mn/ea1nDYWftZhFW9Q= +github.com/libp2p/go-yamux/v3 v3.1.2/go.mod h1:jeLEQgLXqE2YqX1ilAClIfCMDY+0uXQUKmmb/qp0gT4= github.com/libp2p/zeroconf/v2 v2.1.1/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= @@ -1712,8 +1726,9 @@ github.com/lucas-clemente/quic-go v0.21.2/go.mod h1:vF5M1XqhBAHgbjKcJOXY3JZz3GP0 github.com/lucas-clemente/quic-go v0.23.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= github.com/lucas-clemente/quic-go v0.24.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= github.com/lucas-clemente/quic-go v0.25.0/go.mod h1:YtzP8bxRVCBlO77yRanE264+fY/T2U9ZlW1AaHOsMOg= -github.com/lucas-clemente/quic-go v0.27.0 h1:v6WY87q9zD4dKASbG8hy/LpzAVNzEQzw8sEIeloJsc4= github.com/lucas-clemente/quic-go v0.27.0/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= +github.com/lucas-clemente/quic-go v0.27.1 h1:sOw+4kFSVrdWOYmUjufQ9GBVPqZ+tu+jMtXxXNmRJyk= +github.com/lucas-clemente/quic-go v0.27.1/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lufia/iostat v1.1.0/go.mod h1:rEPNA0xXgjHQjuI5Cy05sLlS2oRcSlWHRLrvh/AQ+Pg= @@ -2105,8 +2120,6 @@ github.com/raulk/go-watchdog v1.2.0/go.mod h1:lzSbAl5sh4rtI8tYHU01BWIDzgzqaQLj6R github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -2241,8 +2254,6 @@ github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0 github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= -github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= -github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= @@ -2306,10 +2317,10 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20210713220151-be142a5ae1a8/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20220224212727-7a699437a831/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14 h1:vo2wkP2ceHyGyZwFFtAabpot03EeSxxwAe57pOI9E/4= github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799 h1:DOOT2B85S0tHoLGTzV+FakaSSihgRCVwZkjqKQP5L/w= +github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-ctrlnet v0.0.0-20180313164037-f564fbbdaa95/go.mod h1:SJqKCCPXRfBFCwXjfNT/skfsceF7+MBFLI2OrvuRA7g= @@ -2334,10 +2345,6 @@ github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7V github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xlab/c-for-go v0.0.0-20201112171043-ea6dce5809cb h1:/7/dQyiKnxAOj9L69FhST7uMe17U015XPzX7cy+5ykM= -github.com/xlab/c-for-go v0.0.0-20201112171043-ea6dce5809cb/go.mod h1:pbNsDSxn1ICiNn9Ct4ZGNrwzfkkwYbx/lw8VuyutFIg= -github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 h1:Sw125DKxZhPUI4JLlWugkzsrlB50jR9v2khiD9FxuSo= -github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245/go.mod h1:C+diUUz7pxhNY6KAoLgrTYARGWnt82zWTylZlxT92vk= github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xorcare/golden v0.6.0/go.mod h1:7T39/ZMvaSEZlBPoYfVFmsBLmUl3uz9IuzWj/U6FtvQ= github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542 h1:oWgZJmC1DorFZDpfMfWg7xk29yEOZiXmo/wZl+utTI8= @@ -2512,7 +2519,6 @@ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrb golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2877,7 +2883,6 @@ golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200711155855-7342f9734a7d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200721032237-77f530d86f9a/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -3085,20 +3090,6 @@ k8s.io/utils v0.0.0-20200414100711-2df71ebbae66/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= -modernc.org/cc v1.0.0 h1:nPibNuDEx6tvYrUAtvDTTw98rx5juGsa5zuDnKwEEQQ= -modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= -modernc.org/fileutil v1.0.0/go.mod h1:JHsWpkrk/CnVV1H/eGlFf85BEpfkrp56ro8nojIq9Q8= -modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= -modernc.org/golex v1.0.1 h1:EYKY1a3wStt0RzHaH8mdSRNg78Ub0OHxYfCRWw35YtM= -modernc.org/golex v1.0.1/go.mod h1:QCA53QtsT1NdGkaZZkF5ezFwk4IXh4BGNafAARTC254= -modernc.org/lex v1.0.0/go.mod h1:G6rxMTy3cH2iA0iXL/HRRv4Znu8MK4higxph/lE7ypk= -modernc.org/lexer v1.0.0/go.mod h1:F/Dld0YKYdZCLQ7bD0USbWL4YKCyTDRDHiDTOs0q0vk= -modernc.org/mathutil v1.1.1 h1:FeylZSVX8S+58VsyJlkEj2bcpdytmp9MmDKZkKx8OIE= -modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc= -modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= -modernc.org/xc v1.0.0 h1:7ccXrupWZIS3twbUGrtKmHS2DXY6xegFua+6O3xgAFU= -modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/testplans/lotus-soup/paych/stress.go b/testplans/lotus-soup/paych/stress.go index 4f107bf5b..6b91d7277 100644 --- a/testplans/lotus-soup/paych/stress.go +++ b/testplans/lotus-soup/paych/stress.go @@ -6,11 +6,12 @@ import ( "os" "time" + "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/specs-actors/actors/builtin/paych" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big"