diff --git a/.circleci/config.yml b/.circleci/config.yml index ee4eabdd7..37a8c9745 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: @@ -204,6 +203,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 @@ -242,7 +242,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/.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 3a865e10a..5d7c05248 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,6 @@ build/paramfetch.sh /darwin /linux *.snap -build/builtin-actors *-fuzz.zip /chain/types/work_msg/ @@ -53,4 +52,7 @@ bin/tmp/* scratchpad gen.gen -**/*-wal/ \ No newline at end of file +**/*-wal/ + +build/builtin-actors/v* +build/builtin-actors/*.car diff --git a/Makefile b/Makefile index 301704fa7..dbc545249 100644 --- a/Makefile +++ b/Makefile @@ -64,22 +64,27 @@ CLEAN+=build/.update-modules deps: $(BUILD_DEPS) .PHONY: deps -build-devnets: build lotus-seed lotus-shed lotus-wallet lotus-gateway eudico +build-devnets: build lotus-seed lotus-shed lotus-wallet lotus-gateway lotus-fountain lotus-stats eudico .PHONY: build-devnets debug: GOFLAGS+=-tags=debug +debug: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=devnet debug: build-devnets 2k: GOFLAGS+=-tags=2k +2k: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=devnet 2k: build-devnets calibnet: GOFLAGS+=-tags=calibnet +calibnet: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=calibnet calibnet: build-devnets butterflynet: GOFLAGS+=-tags=butterflynet +butterflynet: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=butterflynet butterflynet: build-devnets interopnet: GOFLAGS+=-tags=interopnet +interopnet: GOFLAGS+=-ldflags=-X=github.com/filecoin-project/lotus/build.NetworkBundle=interopnet interopnet: build-devnets lotus: $(BUILD_DEPS) diff --git a/api/api_full.go b/api/api_full.go index d3875dba3..5cec3e704 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" @@ -444,7 +445,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 @@ -470,9 +471,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 @@ -518,15 +519,13 @@ 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 StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error) //perm:read // StateAccountKey returns the public key address of the given ID address for secp and bls accounts StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error) //perm:read - // StateLookupRobustAddress returns the public key address of the given ID address for non-account addresses (multisig, miners etc) - StateLookupRobustAddress(context.Context, address.Address, types.TipSetKey) (address.Address, error) //perm:read // StateChangedActors returns all the actors whose states change between the two given state CIDs // TODO: Should this take tipset keys instead? StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) //perm:read @@ -593,9 +592,6 @@ 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 - // StateGetNetworkParams return current network params - StateGetNetworkParams(ctx context.Context) (*NetworkParams, error) //perm:read - // MethodGroup: Msig // The Msig methods are used to interact with multisig wallets on the // filecoin network 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..16f6abbed 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" @@ -54,8 +54,6 @@ type StorageMiner interface { ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) //perm:admin - ComputeDataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (abi.PieceInfo, error) //perm:admin - // Temp api for testing PledgeSector(context.Context) (abi.SectorID, error) //perm:write @@ -126,7 +124,6 @@ type StorageMiner interface { WorkerJobs(context.Context) (map[uuid.UUID][]storiface.WorkerJob, error) //perm:admin //storiface.WorkerReturn - ReturnDataCid(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error //perm:admin retry:true ReturnAddPiece(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error //perm:admin retry:true ReturnSealPreCommit1(ctx context.Context, callID storiface.CallID, p1o storage.PreCommit1Out, err *storiface.CallError) error //perm:admin retry:true ReturnSealPreCommit2(ctx context.Context, callID storiface.CallID, sealed storage.SectorCids, err *storiface.CallError) error //perm:admin retry:true @@ -165,7 +162,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 @@ -227,9 +224,6 @@ type StorageMiner interface { // DagstoreGC runs garbage collection on the DAG store. DagstoreGC(ctx context.Context) ([]DagstoreShardResult, error) //perm:admin - // DagstoreRegisterShard registers a shard manually with dagstore with given pieceCID - DagstoreRegisterShard(ctx context.Context, key string) error //perm:admin - // IndexerAnnounceDeal informs indexer nodes that a new deal was received, // so they can download its index IndexerAnnounceDeal(ctx context.Context, proposalCid cid.Cid) error //perm:admin @@ -245,7 +239,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 524dc529e..fa588f123 100644 --- a/api/docgen/docgen.go +++ b/api/docgen/docgen.go @@ -152,6 +152,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 58859e20a..c7af19810 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -17,12 +17,14 @@ 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" hierarchical "github.com/filecoin-project/lotus/chain/consensus/hierarchical" sca "github.com/filecoin-project/lotus/chain/consensus/hierarchical/actors/sca" schema "github.com/filecoin-project/lotus/chain/consensus/hierarchical/checkpoints/schema" @@ -30,8 +32,6 @@ import ( 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" @@ -2663,21 +2663,6 @@ func (mr *MockFullNodeMockRecorder) StateGetActor(arg0, arg1, arg2 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetActor", reflect.TypeOf((*MockFullNode)(nil).StateGetActor), arg0, arg1, arg2) } -// StateGetNetworkParams mocks base method. -func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateGetNetworkParams", arg0) - ret0, _ := ret[0].(*api.NetworkParams) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateGetNetworkParams indicates an expected call of StateGetNetworkParams. -func (mr *MockFullNodeMockRecorder) StateGetNetworkParams(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetNetworkParams", reflect.TypeOf((*MockFullNode)(nil).StateGetNetworkParams), arg0) -} - // StateGetRandomnessFromBeacon mocks base method. func (m *MockFullNode) StateGetRandomnessFromBeacon(arg0 context.Context, arg1 crypto.DomainSeparationTag, arg2 abi.ChainEpoch, arg3 []byte, arg4 types.TipSetKey) (abi.Randomness, error) { m.ctrl.T.Helper() @@ -2799,10 +2784,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 } @@ -2904,10 +2889,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 } @@ -2919,7 +2904,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) @@ -2964,7 +2949,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) @@ -3129,10 +3114,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 } @@ -3159,10 +3144,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 04011c535..cb32372d3 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/consensus/hierarchical" "github.com/filecoin-project/lotus/chain/consensus/hierarchical/actors/sca" "github.com/filecoin-project/lotus/chain/consensus/hierarchical/checkpoints/schema" @@ -33,7 +35,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" @@ -357,7 +358,6 @@ type FullNodeStruct struct { StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, 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"` @@ -375,7 +375,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"` @@ -389,7 +389,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"` @@ -419,11 +419,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"` @@ -547,7 +547,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) `` @@ -709,8 +709,6 @@ type StorageMinerStruct struct { CheckProvable func(p0 context.Context, p1 abi.RegisteredPoStProof, p2 []storage.SectorRef, p3 bool) (map[abi.SectorNumber]string, error) `perm:"admin"` - ComputeDataCid func(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storage.Data) (abi.PieceInfo, error) `perm:"admin"` - ComputeProof func(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) `perm:"read"` ComputeWindowPoSt func(p0 context.Context, p1 uint64, p2 types.TipSetKey) ([]miner.SubmitWindowedPoStParams, error) `perm:"admin"` @@ -729,8 +727,6 @@ type StorageMinerStruct struct { DagstoreRecoverShard func(p0 context.Context, p1 string) error `perm:"write"` - DagstoreRegisterShard func(p0 context.Context, p1 string) error `perm:"admin"` - DealsConsiderOfflineRetrievalDeals func(p0 context.Context) (bool, error) `perm:"admin"` DealsConsiderOfflineStorageDeals func(p0 context.Context) (bool, error) `perm:"admin"` @@ -745,7 +741,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"` @@ -783,7 +779,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"` @@ -815,8 +811,6 @@ type StorageMinerStruct struct { ReturnAddPiece func(p0 context.Context, p1 storiface.CallID, p2 abi.PieceInfo, p3 *storiface.CallError) error `perm:"admin"` - ReturnDataCid func(p0 context.Context, p1 storiface.CallID, p2 abi.PieceInfo, p3 *storiface.CallError) error `perm:"admin"` - ReturnFetch func(p0 context.Context, p1 storiface.CallID, p2 *storiface.CallError) error `perm:"admin"` ReturnFinalizeReplicaUpdate func(p0 context.Context, p1 storiface.CallID, p2 *storiface.CallError) error `perm:"admin"` @@ -2540,17 +2534,6 @@ func (s *FullNodeStub) StateGetActor(p0 context.Context, p1 address.Address, p2 return nil, ErrNotSupported } -func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*NetworkParams, error) { - if s.Internal.StateGetNetworkParams == nil { - return nil, ErrNotSupported - } - return s.Internal.StateGetNetworkParams(p0) -} - -func (s *FullNodeStub) StateGetNetworkParams(p0 context.Context) (*NetworkParams, error) { - return nil, ErrNotSupported -} - func (s *FullNodeStruct) StateGetRandomnessFromBeacon(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) { if s.Internal.StateGetRandomnessFromBeacon == nil { return *new(abi.Randomness), ErrNotSupported @@ -2639,15 +2622,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) { @@ -2716,15 +2699,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) { @@ -2881,14 +2864,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 } @@ -2903,14 +2886,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 } @@ -3519,15 +3502,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) { @@ -4234,17 +4217,6 @@ func (s *StorageMinerStub) CheckProvable(p0 context.Context, p1 abi.RegisteredPo return *new(map[abi.SectorNumber]string), ErrNotSupported } -func (s *StorageMinerStruct) ComputeDataCid(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storage.Data) (abi.PieceInfo, error) { - if s.Internal.ComputeDataCid == nil { - return *new(abi.PieceInfo), ErrNotSupported - } - return s.Internal.ComputeDataCid(p0, p1, p2) -} - -func (s *StorageMinerStub) ComputeDataCid(p0 context.Context, p1 abi.UnpaddedPieceSize, p2 storage.Data) (abi.PieceInfo, error) { - return *new(abi.PieceInfo), ErrNotSupported -} - func (s *StorageMinerStruct) ComputeProof(p0 context.Context, p1 []builtin.ExtendedSectorInfo, p2 abi.PoStRandomness, p3 abi.ChainEpoch, p4 abinetwork.Version) ([]builtin.PoStProof, error) { if s.Internal.ComputeProof == nil { return *new([]builtin.PoStProof), ErrNotSupported @@ -4344,17 +4316,6 @@ func (s *StorageMinerStub) DagstoreRecoverShard(p0 context.Context, p1 string) e return ErrNotSupported } -func (s *StorageMinerStruct) DagstoreRegisterShard(p0 context.Context, p1 string) error { - if s.Internal.DagstoreRegisterShard == nil { - return ErrNotSupported - } - return s.Internal.DagstoreRegisterShard(p0, p1) -} - -func (s *StorageMinerStub) DagstoreRegisterShard(p0 context.Context, p1 string) error { - return ErrNotSupported -} - func (s *StorageMinerStruct) DealsConsiderOfflineRetrievalDeals(p0 context.Context) (bool, error) { if s.Internal.DealsConsiderOfflineRetrievalDeals == nil { return false, ErrNotSupported @@ -4432,15 +4393,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) { @@ -4641,15 +4602,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) { @@ -4817,17 +4778,6 @@ func (s *StorageMinerStub) ReturnAddPiece(p0 context.Context, p1 storiface.CallI return ErrNotSupported } -func (s *StorageMinerStruct) ReturnDataCid(p0 context.Context, p1 storiface.CallID, p2 abi.PieceInfo, p3 *storiface.CallError) error { - if s.Internal.ReturnDataCid == nil { - return ErrNotSupported - } - return s.Internal.ReturnDataCid(p0, p1, p2, p3) -} - -func (s *StorageMinerStub) ReturnDataCid(p0 context.Context, p1 storiface.CallID, p2 abi.PieceInfo, p3 *storiface.CallError) error { - return ErrNotSupported -} - func (s *StorageMinerStruct) ReturnFetch(p0 context.Context, p1 storiface.CallID, p2 *storiface.CallError) error { if s.Internal.ReturnFetch == nil { return ErrNotSupported diff --git a/api/types.go b/api/types.go index ce6b93f9e..19e0b5110 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" @@ -318,3 +320,17 @@ type ForkUpgradeParams struct { UpgradeChocolateHeight abi.ChainEpoch UpgradeOhSnapHeight abi.ChainEpoch } + +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 +} diff --git a/api/v0api/full.go b/api/v0api/full.go index 61850ed44..2ed24fb60 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" @@ -417,7 +418,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 @@ -443,9 +444,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 @@ -522,7 +523,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 @@ -605,9 +606,6 @@ 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 - // StateGetNetworkParams return current network params - StateGetNetworkParams(ctx context.Context) (*api.NetworkParams, error) //perm:read - // MethodGroup: Msig // The Msig methods are used to interact with multisig wallets on the // filecoin network 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 3af1da63b..42364f0eb 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" @@ -269,8 +270,6 @@ type FullNodeStruct struct { StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `perm:"read"` - StateGetNetworkParams func(p0 context.Context) (*api.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"` StateGetRandomnessFromTickets func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"` @@ -287,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"` @@ -301,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"` @@ -333,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"` @@ -451,7 +450,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) `` @@ -1752,17 +1751,6 @@ func (s *FullNodeStub) StateGetActor(p0 context.Context, p1 address.Address, p2 return nil, ErrNotSupported } -func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*api.NetworkParams, error) { - if s.Internal.StateGetNetworkParams == nil { - return nil, ErrNotSupported - } - return s.Internal.StateGetNetworkParams(p0) -} - -func (s *FullNodeStub) StateGetNetworkParams(p0 context.Context) (*api.NetworkParams, error) { - return nil, ErrNotSupported -} - func (s *FullNodeStruct) StateGetRandomnessFromBeacon(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) { if s.Internal.StateGetRandomnessFromBeacon == nil { return *new(abi.Randomness), ErrNotSupported @@ -1851,15 +1839,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) { @@ -1928,15 +1916,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) { @@ -2104,14 +2092,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 } @@ -2126,14 +2114,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 } @@ -2687,15 +2675,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 5c39feb7e..333b3cd6b 100644 --- a/api/v0api/v0mocks/mock_full.go +++ b/api/v0api/v0mocks/mock_full.go @@ -17,13 +17,15 @@ 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" hierarchical "github.com/filecoin-project/lotus/chain/consensus/hierarchical" sca "github.com/filecoin-project/lotus/chain/consensus/hierarchical/actors/sca" schema "github.com/filecoin-project/lotus/chain/consensus/hierarchical/checkpoints/schema" @@ -32,8 +34,6 @@ import ( 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" @@ -2532,21 +2532,6 @@ func (mr *MockFullNodeMockRecorder) StateGetActor(arg0, arg1, arg2 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetActor", reflect.TypeOf((*MockFullNode)(nil).StateGetActor), arg0, arg1, arg2) } -// StateGetNetworkParams mocks base method. -func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StateGetNetworkParams", arg0) - ret0, _ := ret[0].(*api.NetworkParams) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StateGetNetworkParams indicates an expected call of StateGetNetworkParams. -func (mr *MockFullNodeMockRecorder) StateGetNetworkParams(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetNetworkParams", reflect.TypeOf((*MockFullNode)(nil).StateGetNetworkParams), arg0) -} - // StateGetRandomnessFromBeacon mocks base method. func (m *MockFullNode) StateGetRandomnessFromBeacon(arg0 context.Context, arg1 crypto.DomainSeparationTag, arg2 abi.ChainEpoch, arg3 []byte, arg4 types.TipSetKey) (abi.Randomness, error) { m.ctrl.T.Helper() @@ -2668,10 +2653,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 } @@ -2773,10 +2758,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 } @@ -2788,7 +2773,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) @@ -2833,7 +2818,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) @@ -3013,10 +2998,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 } @@ -3043,10 +3028,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/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..3d91c21e1 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/12D3KooWJ7vSep82d6Y5XUH3PWyNFg1PQHAyDAvWVHzZgBZA22aF +/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWKH6sEmbAutazsBU3RHCYu8ULgd6FKencATJK1XuudZFG 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..9848ee615 --- /dev/null +++ b/build/bundle.go @@ -0,0 +1,53 @@ +package build + +import ( + _ "embed" + + "github.com/filecoin-project/lotus/chain/actors" +) + +var NetworkBundle string + +func GetNetworkBundle() string { + switch NetworkBundle { + case "devnet", "2k", "debug": + return "devnet" + case "calibnet", "calibrationnet": + return "calibrationnet" + case "butterflynet": + return "butterflynet" + case "interopnet", "caterpillarnet": + return "caterpillarnet" + default: + return "mainnet" + } +} + +//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 precdence 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..8b6a3adda --- /dev/null +++ b/build/bundles.toml @@ -0,0 +1,4 @@ +[[bundles]] +version = 8 +path = {mainnet = "./chain/consensus/hierarchical/actors/bundle.car"} +development = true diff --git a/build/genesis/interopnet.car b/build/genesis/interopnet.car index 2c7c2a498..db73e28b4 100644 Binary files a/build/genesis/interopnet.car and b/build/genesis/interopnet.car differ diff --git a/build/params_2k.go b/build/params_2k.go index df9744b62..f42d27b51 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -17,7 +17,7 @@ import ( const BootstrappersFile = "" const GenesisFile = "" -const GenesisNetworkVersion = network.Version15 +const GenesisNetworkVersion = network.Version16 var UpgradeBreezeHeight = abi.ChainEpoch(-1) @@ -48,6 +48,7 @@ var UpgradeHyperdriveHeight = abi.ChainEpoch(-16) var UpgradeChocolateHeight = abi.ChainEpoch(-17) var UpgradeOhSnapHeight = abi.ChainEpoch(-18) +var UpgradeFVM1Height = abi.ChainEpoch(-19) var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, @@ -99,6 +100,7 @@ func init() { UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight) UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight) UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight) + UpgradeFVM1Height = getUpgradeHeight("LOTUS_FVM1_HEIGHT", UpgradeFVM1Height) BuildType |= Build2k diff --git a/build/params_butterfly.go b/build/params_butterfly.go index d74e17305..a4c81c4b5 100644 --- a/build/params_butterfly.go +++ b/build/params_butterfly.go @@ -44,14 +44,7 @@ const UpgradeChocolateHeight = -17 const UpgradeOhSnapHeight = 240 -var SupportedProofTypes = []abi.RegisteredSealProof{ - abi.RegisteredSealProof_StackedDrg512MiBV1, - abi.RegisteredSealProof_StackedDrg32GiBV1, - abi.RegisteredSealProof_StackedDrg64GiBV1, -} -var ConsensusMinerMinPower = abi.NewStoragePower(2 << 30) -var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) -var PreCommitChallengeDelay = abi.ChainEpoch(150) +var UpgradeFVM1Height = abi.ChainEpoch(99999999999999) func init() { policy.SetSupportedProofTypes(SupportedProofTypes...) diff --git a/build/params_calibnet.go b/build/params_calibnet.go index 5ff8bd853..3bb11210c 100644 --- a/build/params_calibnet.go +++ b/build/params_calibnet.go @@ -57,13 +57,7 @@ const UpgradeChocolateHeight = 312746 // 2022-02-10T19:23:00Z const UpgradeOhSnapHeight = 682006 -var SupportedProofTypes = []abi.RegisteredSealProof{ - abi.RegisteredSealProof_StackedDrg32GiBV1, - abi.RegisteredSealProof_StackedDrg64GiBV1, -} -var ConsensusMinerMinPower = abi.NewStoragePower(32 << 30) -var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) -var PreCommitChallengeDelay = abi.ChainEpoch(150) +var UpgradeFVM1Height = abi.ChainEpoch(99999999999999) func init() { policy.SetSupportedProofTypes(SupportedProofTypes...) diff --git a/build/params_interop.go b/build/params_interop.go index ad051570c..5643fc28a 100644 --- a/build/params_interop.go +++ b/build/params_interop.go @@ -7,19 +7,18 @@ import ( "os" "strconv" - "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/network" "github.com/filecoin-project/lotus/chain/actors/policy" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + "github.com/ipfs/go-cid" ) const BootstrappersFile = "interopnet.pi" const GenesisFile = "interopnet.car" -const GenesisNetworkVersion = network.Version13 +const GenesisNetworkVersion = network.Version15 var UpgradeBreezeHeight = abi.ChainEpoch(-1) @@ -48,6 +47,7 @@ var UpgradeTurboHeight = abi.ChainEpoch(-15) var UpgradeHyperdriveHeight = abi.ChainEpoch(-16) var UpgradeChocolateHeight = abi.ChainEpoch(-17) var UpgradeOhSnapHeight = abi.ChainEpoch(-18) +var UpgradeFVM1Height = abi.ChainEpoch(100) var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, @@ -98,6 +98,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) + UpgradeFVM1Height = getUpgradeHeight("LOTUS_FVM1_HEIGHT", UpgradeFVM1Height) BuildType |= BuildInteropnet SetAddressNetwork(address.Testnet) diff --git a/build/params_mainnet.go b/build/params_mainnet.go index f5d13d805..a4b4c6a81 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -70,13 +70,7 @@ const UpgradeChocolateHeight = 1231620 // 2022-03-01T15:00:00Z var UpgradeOhSnapHeight = abi.ChainEpoch(1594680) -var SupportedProofTypes = []abi.RegisteredSealProof{ - abi.RegisteredSealProof_StackedDrg32GiBV1, - abi.RegisteredSealProof_StackedDrg64GiBV1, -} -var ConsensusMinerMinPower = abi.NewStoragePower(10 << 40) -var MinVerifiedDealSize = abi.NewStoragePower(1 << 20) -var PreCommitChallengeDelay = abi.ChainEpoch(150) +var UpgradeFVM1Height = abi.ChainEpoch(99999999999999) func init() { if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" { 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 b017bdc58..672006260 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -108,6 +108,7 @@ var ( UpgradeHyperdriveHeight abi.ChainEpoch = -15 UpgradeChocolateHeight abi.ChainEpoch = -16 UpgradeOhSnapHeight abi.ChainEpoch = -17 + UpgradeFVM1Height abi.ChainEpoch = -18 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, diff --git a/build/version.go b/build/version.go index 24da6355e..b6bcb4a5f 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.16.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" -) - -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) - }) + builtin8 "github.com/filecoin-project/go-state-types/builtin" +) - builtin.RegisterActorState(builtin4.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) +var Methods = builtin8.MethodsAccount - builtin.RegisterActorState(builtin5.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) +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) + } - builtin.RegisterActorState(builtin6.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + switch av { - builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} + case actors.Version8: + return load8(store, act.Head) -var Methods = builtin4.MethodsAccount + } + } -func Load(store adt.Store, act *types.Actor) (State, error) { 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,37 +95,11 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, case actors.Version7: return make7(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 + case actors.Version8: + return make8(store, addr) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { 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 1f9a5a748..6d707ba03 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -6,129 +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 RewardActorAddr = builtin7.RewardActorAddr +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) - + return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) } -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) +func ActorNameByCode(c cid.Cid) string { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name } - return loader(store, act.Head) -} -func ActorNameByCode(c cid.Cid) string { switch { case builtin0.IsBuiltinActor(c): @@ -152,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 @@ -190,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 @@ -223,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 @@ -256,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 @@ -289,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 @@ -322,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 56adeef54..bfa5d9ec2 100644 --- a/chain/actors/builtin/builtin.go.template +++ b/chain/actors/builtin/builtin.go.template @@ -5,137 +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 RewardActorAddr = builtin{{.latestVersion}}.RewardActorAddr +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) +func ActorNameByCode(c cid.Cid) string { + name, _, ok := actors.GetActorMetaByCode(c) + if ok { + return name } - return loader(store, act.Head) -} -func ActorNameByCode(c cid.Cid) string { 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,31 +4,53 @@ 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 MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { +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}} - case actors.Version{{.}}: - return make{{.}}(store) + {{if (le . 7)}} + case builtin{{.}}.CronActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) + } + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { +func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { {{range .versions}} case actors.Version{{.}}: - return builtin{{.}}.CronActorCodeID, nil + return make{{.}}(store) {{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + return nil, xerrors.Errorf("unknown actor version %d", av) } var ( 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,68 +19,86 @@ 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 MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { +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) + } - case actors.Version0: - return make0(store) + switch av { - case actors.Version2: - return make2(store) + case actors.Version8: + return load8(store, act.Head) - case actors.Version3: - return make3(store) + } + } - case actors.Version4: - return make4(store) + switch act.Code { - case actors.Version5: - return make5(store) + case builtin0.CronActorCodeID: + return load0(store, act.Head) - case actors.Version6: - return make6(store) + case builtin2.CronActorCodeID: + return load2(store, act.Head) - case actors.Version7: - return make7(store) + 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 version %d", av) + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { +func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { case actors.Version0: - return builtin0.CronActorCodeID, nil + return make0(store) case actors.Version2: - return builtin2.CronActorCodeID, nil + return make2(store) case actors.Version3: - return builtin3.CronActorCodeID, nil + return make3(store) case actors.Version4: - return builtin4.CronActorCodeID, nil + return make4(store) case actors.Version5: - return builtin5.CronActorCodeID, nil + return make5(store) case actors.Version6: - return builtin6.CronActorCodeID, nil + return make6(store) case actors.Version7: - return builtin7.CronActorCodeID, nil + return make7(store) - } + case actors.Version8: + return make8(store) - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + } + return nil, 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" -) - -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) - }) + builtin8 "github.com/filecoin-project/go-state-types/builtin" +) - builtin.RegisterActorState(builtin4.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) +var ( + Address = builtin8.InitActorAddr + Methods = builtin8.MethodsInit +) - builtin.RegisterActorState(builtin5.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) +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) + } - builtin.RegisterActorState(builtin6.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + switch av { - builtin.RegisterActorState(builtin7.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} + case actors.Version8: + return load8(store, act.Head) -var ( - Address = builtin7.InitActorAddr - Methods = builtin7.MethodsInit -) + } + } -func Load(store adt.Store, act *types.Actor) (State, error) { 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,37 +101,11 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e case actors.Version7: return make7(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 + case actors.Version8: + return make8(store, networkName) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { 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..c72623e4c 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,19 +100,18 @@ 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) // Note that this index is based on the batch of deals that were published, NOT the DealID - IsDealValid(index uint64) (bool, int, error) + IsDealValid(index uint64) (bool, error) } func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, 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 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 = market{{.latestVersion}}.DealProposal -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..974291077 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) - }) +var ( + Address = builtin8.StorageMarketActorAddr + Methods = builtin8.MethodsMarket +) - builtin.RegisterActorState(builtin5.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) +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) + } - builtin.RegisterActorState(builtin6.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + switch av { - builtin.RegisterActorState(builtin7.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} + case actors.Version8: + return load8(store, act.Head) -var ( - Address = builtin7.StorageMarketActorAddr - Methods = builtin7.MethodsMarket -) + } + } -func Load(store adt.Store, act *types.Actor) (State, error) { 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,37 +106,11 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { 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.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 + case actors.Version8: + return make8(store) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { @@ -185,19 +144,17 @@ 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 - IsDealValid(index uint64) (bool, int, error) + IsDealValid(index uint64) (bool, error) } func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) { @@ -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 ClientDealProposal = market0.ClientDealProposal +type DealProposal = market8.DealProposal -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..7e432d499 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -8,17 +8,17 @@ import ( "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - {{if (ge .v 6)}} - rlepluslazy "github.com/filecoin-project/go-bitfield/rle" - "github.com/filecoin-project/go-bitfield" - {{end}} - "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 +195,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 +211,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 +237,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 } @@ -258,29 +298,12 @@ type publishStorageDealsReturn{{.v}} struct { market{{.v}}.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn{{.v}}) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn{{.v}}) IsDealValid(index uint64) (bool, error) { {{if (ge .v 6)}} - 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 + return r.ValidDeals.IsSet(index) {{else}} // PublishStorageDeals only succeeded if all deals were valid in this version of actors - return true, int(index), nil + return true, nil {{end}} } diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index aa2ec4716..b00035976 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{} { @@ -246,10 +282,10 @@ type publishStorageDealsReturn0 struct { market0.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn0) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn0) IsDealValid(index uint64) (bool, error) { // PublishStorageDeals only succeeded if all deals were valid in this version of actors - return true, int(index), nil + return true, nil } diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 42742936c..b75fe8551 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{} { @@ -246,10 +282,10 @@ type publishStorageDealsReturn2 struct { market2.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn2) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn2) IsDealValid(index uint64) (bool, error) { // PublishStorageDeals only succeeded if all deals were valid in this version of actors - return true, int(index), nil + return true, nil } diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index a37171a47..0bca42eae 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{} { @@ -241,10 +277,10 @@ type publishStorageDealsReturn3 struct { market3.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn3) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn3) IsDealValid(index uint64) (bool, error) { // PublishStorageDeals only succeeded if all deals were valid in this version of actors - return true, int(index), nil + return true, nil } diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index b291ebe24..7ada6d57b 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{} { @@ -241,10 +277,10 @@ type publishStorageDealsReturn4 struct { market4.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn4) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn4) IsDealValid(index uint64) (bool, error) { // PublishStorageDeals only succeeded if all deals were valid in this version of actors - return true, int(index), nil + return true, nil } diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index e8e979ba8..c4301449b 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{} { @@ -241,10 +277,10 @@ type publishStorageDealsReturn5 struct { market5.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn5) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn5) IsDealValid(index uint64) (bool, error) { // PublishStorageDeals only succeeded if all deals were valid in this version of actors - return true, int(index), nil + return true, nil } diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 63aaba7d4..1fb16790b 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -9,9 +9,6 @@ import ( 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" @@ -197,14 +194,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 +220,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 +233,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{} { @@ -244,26 +277,9 @@ type publishStorageDealsReturn6 struct { market6.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn6) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn6) IsDealValid(index uint64) (bool, 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 + return r.ValidDeals.IsSet(index) } diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index 0d546d7ac..8b91a6c28 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -9,9 +9,6 @@ import ( 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" @@ -197,14 +194,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 +220,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 +233,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{} { @@ -244,26 +277,9 @@ type publishStorageDealsReturn7 struct { market7.PublishStorageDealsReturn } -func (r *publishStorageDealsReturn7) IsDealValid(index uint64) (bool, int, error) { +func (r *publishStorageDealsReturn7) IsDealValid(index uint64) (bool, 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 + return r.ValidDeals.IsSet(index) } diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go new file mode 100644 index 000000000..e9a5c7ef5 --- /dev/null +++ b/chain/actors/builtin/market/v8.go @@ -0,0 +1,285 @@ +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/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, error) { + + return r.ValidDeals.IsSet(index) + +} + +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 +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) + } -// 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 + switch av { -const MinSectorExpiration = miner0.MinSectorExpiration + case actors.Version8: + return load8(store, act.Head) -// 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) { 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,37 +98,11 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { 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.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 + case actors.Version8: + return make8(store) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { @@ -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" - -{{if (ge .v 3)}} - builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" + minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + +{{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) - }) +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) + } - builtin.RegisterActorState(builtin5.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) + switch av { - builtin.RegisterActorState(builtin6.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + case actors.Version8: + return load8(store, act.Head) - 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) { 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,37 +100,11 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th case actors.Version7: return make7(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 + case actors.Version8: + return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { @@ -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,57 +10,48 @@ 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) { - switch act.Code { -{{range .versions}} - case builtin{{.}}.PaymentChannelActorCodeID: - return load{{.}}(store, act.Head) -{{end}} + 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}} + } } - 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 { + switch act.Code { {{range .versions}} - case actors.Version{{.}}: - return builtin{{.}}.PaymentChannelActorCodeID, nil + {{if (le . 7)}} + case builtin{{.}}.PaymentChannelActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} } - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } // State is an abstract version of payment channel state that works across @@ -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) - }) +// 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) + } - builtin.RegisterActorState(builtin5.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) + switch av { - builtin.RegisterActorState(builtin6.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + case actors.Version8: + return load8(store, act.Head) - 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) { switch act.Code { case builtin0.PaymentChannelActorCodeID: @@ -92,64 +73,8 @@ 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) + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } // State is an abstract version of payment channel state that works across @@ -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" -) - -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) - }) + builtin8 "github.com/filecoin-project/go-state-types/builtin" +) - builtin.RegisterActorState(builtin4.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load4(store, root) - }) +var ( + Address = builtin8.StoragePowerActorAddr + Methods = builtin8.MethodsPower +) - builtin.RegisterActorState(builtin5.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) +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) + } - builtin.RegisterActorState(builtin6.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + switch av { - builtin.RegisterActorState(builtin7.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} + case actors.Version8: + return load8(store, act.Head) -var ( - Address = builtin7.StoragePowerActorAddr - Methods = builtin7.MethodsPower -) + } + } -func Load(store adt.Store, act *types.Actor) (State, error) { 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,37 +102,11 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { 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.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 + case actors.Version8: + return make8(store) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { 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) - }) +var ( + Address = builtin8.RewardActorAddr + Methods = builtin8.MethodsReward +) - builtin.RegisterActorState(builtin5.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load5(store, root) - }) +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) + } - builtin.RegisterActorState(builtin6.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) + switch av { - builtin.RegisterActorState(builtin7.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) -} + case actors.Version8: + return load8(store, act.Head) -var ( - Address = builtin7.RewardActorAddr - Methods = builtin7.MethodsReward -) + } + } -func Load(store adt.Store, act *types.Actor) (State, error) { 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,37 +100,11 @@ func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.Storage case actors.Version7: return make7(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 + case actors.Version8: + return make8(store, currRealizedPower) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, xerrors.Errorf("unknown actor version %d", av) } type State interface { 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,25 +20,42 @@ var ( Address = builtin{{.latestVersion}}.SystemActorAddr ) -func MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { +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}} - case actors.Version{{.}}: - return make{{.}}(store) + {{if (le . 7)}} + case builtin{{.}}.SystemActorCodeID: + return load{{.}}(store, act.Head) + {{end}} {{end}} -} - return nil, xerrors.Errorf("unknown actor version %d", av) + } + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { +func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { {{range .versions}} case actors.Version{{.}}: - return builtin{{.}}.SystemActorCodeID, nil + return make{{.}}(store) {{end}} - } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) +} + return nil, xerrors.Errorf("unknown actor version %d", av) } type State 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,67 +20,85 @@ 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 MakeState(store adt.Store, av actors.Version) (State, error) { - switch av { +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) + } - case actors.Version0: - return make0(store) + switch av { - case actors.Version2: - return make2(store) + case actors.Version8: + return load8(store, act.Head) - case actors.Version3: - return make3(store) + } + } - case actors.Version4: - return make4(store) + switch act.Code { - case actors.Version5: - return make5(store) + case builtin0.SystemActorCodeID: + return load0(store, act.Head) - case actors.Version6: - return make6(store) + case builtin2.SystemActorCodeID: + return load2(store, act.Head) - case actors.Version7: - return make7(store) + 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 version %d", av) + + return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func GetActorCodeID(av actors.Version) (cid.Cid, error) { +func MakeState(store adt.Store, av actors.Version) (State, error) { switch av { case actors.Version0: - return builtin0.SystemActorCodeID, nil + return make0(store) case actors.Version2: - return builtin2.SystemActorCodeID, nil + return make2(store) case actors.Version3: - return builtin3.SystemActorCodeID, nil + return make3(store) case actors.Version4: - return builtin4.SystemActorCodeID, nil + return make4(store) case actors.Version5: - return builtin5.SystemActorCodeID, nil + return make5(store) case actors.Version6: - return builtin6.SystemActorCodeID, nil + return make6(store) case actors.Version7: - return builtin7.SystemActorCodeID, nil + return make7(store) - } + case actors.Version8: + return make8(store) - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + } + return nil, xerrors.Errorf("unknown actor version %d", av) } type State 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) - }) +var ( + Address = builtin8.VerifiedRegistryActorAddr + Methods = builtin8.MethodsVerifiedRegistry +) - builtin.RegisterActorState(builtin6.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load6(store, root) - }) +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) + } - builtin.RegisterActorState(builtin7.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) { - return load7(store, root) - }) + switch av { -} + case actors.Version8: + return load8(store, act.Head) -var ( - Address = builtin7.VerifiedRegistryActorAddr - Methods = builtin7.MethodsVerifiedRegistry -) + } + } -func Load(store adt.Store, act *types.Actor) (State, error) { 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) - } - 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 + case actors.Version8: + return make8(store, rootKeyAddress) } - - return cid.Undef, xerrors.Errorf("unknown actor version %d", av) + return nil, 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..388c77b5e --- /dev/null +++ b/chain/actors/manifest.go @@ -0,0 +1,163 @@ +package actors + +import ( + "bytes" + "context" + "strings" + "sync" + + "github.com/filecoin-project/go-state-types/manifest" + + "golang.org/x/xerrors" + + cid "github.com/ipfs/go-cid" + cbor "github.com/ipfs/go-ipld-cbor" + car "github.com/ipld/go-car" + + "github.com/filecoin-project/lotus/blockstore" + "github.com/filecoin-project/lotus/chain/actors/adt" +) + +var manifestCids map[Version]cid.Cid = map[Version]cid.Cid{ + // TODO fill in manifest CIDs for v8 and upwards once these are fixed +} + +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" + SCAKey = "hierarchical_sca" +) + +var ( + manifestMx sync.RWMutex +) + +type actorEntry struct { + name string + version Version +} + +func AddManifest(av Version, manifestCid cid.Cid) { + manifestMx.Lock() + defer manifestMx.Unlock() + + 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 + + for _, name := range []string{ + AccountKey, + CronKey, + InitKey, + MarketKey, + MinerKey, + MultisigKey, + PaychKey, + PowerKey, + RewardKey, + SystemKey, + VerifregKey, + SCAKey, + } { + 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 +} + +func LoadBundle(ctx context.Context, bs blockstore.Blockstore, av Version, data []byte) error { + blobr := bytes.NewReader(data) + + hdr, err := car.LoadCar(ctx, bs, blobr) + if err != nil { + return xerrors.Errorf("error loading builtin actors v%d bundle: %w", av, err) + } + + // TODO: check that this only has one root? + + manifestCid := hdr.Roots[0] + AddManifest(av, manifestCid) + + return nil +} 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/go-state-types/builtin{{import .latestVersion}}paych" - paych{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/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/consensus/actors/registry/registry.go b/chain/consensus/actors/registry/registry.go index 9de9bb9e3..762ad4f75 100644 --- a/chain/consensus/actors/registry/registry.go +++ b/chain/consensus/actors/registry/registry.go @@ -1,7 +1,7 @@ package registry import ( - exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported" + exported8 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported" "github.com/filecoin-project/lotus/chain/actors" replace "github.com/filecoin-project/lotus/chain/consensus/actors/atomic-replace" @@ -17,17 +17,17 @@ func NewActorRegistry() *vm.ActorRegistry { inv := vm.NewActorRegistry() // TODO: drop unneeded - inv.Register(vm.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...) - inv.Register(nil, initactor.InitActor{}) // use our custom init actor + inv.Register(actors.Version8, vm.ActorsVersionPredicate(actors.Version8), exported8.BuiltinActors()...) + inv.Register(actors.Version8, nil, initactor.InitActor{}) // use our custom init actor // Hierarchical consensus - inv.Register(nil, reward.Actor{}) - inv.Register(nil, subnet.SubnetActor{}) - inv.Register(nil, sca.SubnetCoordActor{}) + inv.Register(actors.Version8, nil, reward.Actor{}) + inv.Register(actors.Version8, nil, subnet.SubnetActor{}) + inv.Register(actors.Version8, nil, sca.SubnetCoordActor{}) // Custom actors - inv.Register(nil, split.SplitActor{}) - inv.Register(nil, replace.ReplaceActor{}) + inv.Register(actors.Version8, nil, split.SplitActor{}) + inv.Register(actors.Version8, nil, replace.ReplaceActor{}) return inv } diff --git a/chain/consensus/common/executor.go b/chain/consensus/common/executor.go index 7919a1b4e..d7af2cf15 100644 --- a/chain/consensus/common/executor.go +++ b/chain/consensus/common/executor.go @@ -2,6 +2,7 @@ package common import ( "context" + "os" "sync/atomic" "github.com/filecoin-project/go-state-types/abi" @@ -32,7 +33,7 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { updates := []stmgr.Upgrade{{ Height: -1, - Network: network.Version15, + Network: network.Version16, Migration: nil, Expensive: true, }, @@ -90,6 +91,19 @@ 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) } @@ -278,7 +292,6 @@ func (t *tipSetExecutor) ExecuteTipSet(ctx context.Context, sm *stmgr.StateManag } baseFee := blks[0].ParentBaseFee - return t.ApplyBlocks(ctx, sm, cr, parentEpoch, pstate, blkmsgs, blks[0].Height, r, em, baseFee, ts) } diff --git a/chain/consensus/filcns/compute_state.go b/chain/consensus/filcns/compute_state.go index 6658d1a4b..568316665 100644 --- a/chain/consensus/filcns/compute_state.go +++ b/chain/consensus/filcns/compute_state.go @@ -18,12 +18,6 @@ import ( "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}} - - /* inline-gen start */ - exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported" exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported" exported3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/exported" @@ -31,8 +25,7 @@ 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" - - /* inline-gen end */ + exported8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/exported" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" @@ -50,22 +43,14 @@ 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}} - - /* 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()...) - - /* inline-gen end */ + 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()...) return inv } diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index 116684b9f..bed5ceecf 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" @@ -170,6 +173,17 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { StopWithin: 5, }}, Expensive: true, + }, { + Height: build.UpgradeFVM1Height, + Network: network.Version16, + Migration: UpgradeActorsV8, + PreMigrations: []stmgr.PreMigration{{ + PreMigration: PreUpgradeActorsV8, + StartWithin: 180, + DontStartWithin: 60, + StopWithin: 5, + }}, + Expensive: true, }, } @@ -1304,6 +1318,105 @@ 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) + + // 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") + } + + // 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/consensus/genesis/f00_system.go b/chain/consensus/genesis/f00_system.go index 4fde27107..faa585c95 100644 --- a/chain/consensus/genesis/f00_system.go +++ b/chain/consensus/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/consensus/genesis/f01_init.go b/chain/consensus/genesis/f01_init.go index 61ec91703..f1df7ae2a 100644 --- a/chain/consensus/genesis/f01_init.go +++ b/chain/consensus/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/consensus/genesis/f02_reward.go b/chain/consensus/genesis/f02_reward.go index c8f479722..e4d6aa32a 100644 --- a/chain/consensus/genesis/f02_reward.go +++ b/chain/consensus/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/consensus/genesis/f03_cron.go b/chain/consensus/genesis/f03_cron.go index c9dd0d341..fad5e6fa6 100644 --- a/chain/consensus/genesis/f03_cron.go +++ b/chain/consensus/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/consensus/genesis/f04_power.go b/chain/consensus/genesis/f04_power.go index b5e08cebe..35cd5f87b 100644 --- a/chain/consensus/genesis/f04_power.go +++ b/chain/consensus/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/consensus/genesis/f05_market.go b/chain/consensus/genesis/f05_market.go index ac32294c9..045842cde 100644 --- a/chain/consensus/genesis/f05_market.go +++ b/chain/consensus/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/consensus/genesis/f06_vreg.go b/chain/consensus/genesis/f06_vreg.go index e61c951f5..d93b01a4f 100644 --- a/chain/consensus/genesis/f06_vreg.go +++ b/chain/consensus/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/consensus/genesis/genesis.go b/chain/consensus/genesis/genesis.go index ae3d07471..e889e340d 100644 --- a/chain/consensus/genesis/genesis.go +++ b/chain/consensus/genesis/genesis.go @@ -6,9 +6,7 @@ import ( "encoding/json" "fmt" - actor "github.com/filecoin-project/lotus/chain/consensus/actors" - "github.com/filecoin-project/lotus/chain/consensus/hierarchical" - "github.com/filecoin-project/lotus/chain/consensus/hierarchical/actors/sca" + "github.com/filecoin-project/lotus/chain/consensus/filcns" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -17,9 +15,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/multisig" - "github.com/filecoin-project/lotus/chain/consensus/actors/registry" - rew "github.com/filecoin-project/lotus/chain/consensus/actors/reward" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin/account" @@ -182,7 +177,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge // Setup reward // RewardActor's state is overwritten by SetupStorageMiners, but needs to exist for miner creation messages - rewact, err := SetupHierarchicalRewardActor(ctx, bs, big.Zero(), av) + rewact, err := SetupRewardActor(ctx, bs, big.Zero(), av) if err != nil { return nil, nil, xerrors.Errorf("setup reward actor: %w", err) } @@ -201,22 +196,6 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return nil, nil, xerrors.Errorf("set cron actor: %w", err) } - // Setup sca actor - // FIXME: make it configurable? - checkPeriod := abi.ChainEpoch(100) - params := &sca.ConstructorParams{ - NetworkName: template.NetworkName, - CheckpointPeriod: uint64(checkPeriod), - } - scaact, err := SetupSCAActor(ctx, bs, params) - if err != nil { - return nil, nil, err - } - err = state.SetActor(hierarchical.SubnetCoordActorAddr, scaact) - if err != nil { - return nil, nil, xerrors.Errorf("set SCA actor: %w", err) - } - // Create empty power actor spact, err := SetupStoragePowerActor(ctx, bs, av) if err != nil { @@ -397,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 } @@ -479,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 } @@ -509,14 +488,14 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca Epoch: 0, Rand: &fakeRand{}, Bstore: cs.StateBlockstore(), - Actors: registry.NewActorRegistry(), + 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) } @@ -610,7 +589,6 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto mm := &types.MsgMeta{ BlsMessages: emptyroot, SecpkMessages: emptyroot, - CrossMessages: emptyroot, } mmb, err := mm.ToStorageBlock() if err != nil { @@ -685,46 +663,3 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto Genesis: b, }, nil } - -func SetupSCAActor(ctx context.Context, bs bstore.Blockstore, params *sca.ConstructorParams) (*types.Actor, error) { - cst := cbor.NewCborStore(bs) - st, err := sca.ConstructSCAState(adt.WrapStore(ctx, cst), params) - if err != nil { - return nil, err - } - - statecid, err := cst.Put(ctx, st) - if err != nil { - return nil, err - } - - act := &types.Actor{ - Code: actor.SubnetCoordActorCodeID, - Balance: big.Zero(), - Head: statecid, - } - - return act, nil -} - -func SetupHierarchicalRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actors.Version) (*types.Actor, error) { - cst := cbor.NewCborStore(bs) - rst := rew.ConstructState(qaPower) - - statecid, err := cst.Put(ctx, rst) - if err != nil { - return nil, err - } - - // NOTE: For now, everything in the reward actor is the same except the code, - // where we included an additional method to fund accounts. This may change - // in the future when we design specific reward system for subnets. - act := &types.Actor{ - Code: actor.RewardActorCodeID, - // NOTE: This sets up the initial balance of the reward actor. - Balance: types.BigInt{Int: build.InitialRewardBalance}, - Head: statecid, - } - - return act, nil -} diff --git a/chain/consensus/genesis/miners.go b/chain/consensus/genesis/miners.go index 9bc1a8679..5ff499351 100644 --- a/chain/consensus/genesis/miners.go +++ b/chain/consensus/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,15 +42,17 @@ 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" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/actors/policy" - "github.com/filecoin-project/lotus/chain/consensus/actors/registry" + "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" @@ -86,21 +98,26 @@ 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: registry.NewActorRegistry(), - Syscalls: mkFakedSigSyscalls(sys), - CircSupplyCalc: csc, - NetworkVersion: nv, - BaseFee: types.NewInt(0), + 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(), + FilVested: 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 { @@ -115,7 +132,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 @@ -135,7 +152,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) } @@ -151,12 +168,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) } @@ -178,7 +200,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) } @@ -187,10 +209,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) } @@ -212,21 +234,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{} } } @@ -245,7 +283,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) } @@ -256,12 +294,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) } @@ -294,25 +341,35 @@ 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) } - rewact, err := SetupHierarchicalRewardActor(ctx, cs.StateBlockstore(), big.Zero(), av) + rewact, err := SetupRewardActor(ctx, cs.StateBlockstore(), big.Zero(), av) if err != nil { 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, @@ -321,7 +378,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) } @@ -330,12 +387,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) } @@ -365,35 +427,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) } @@ -416,7 +488,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) } @@ -428,17 +500,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) } @@ -459,21 +536,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) } @@ -498,10 +590,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 } @@ -520,7 +613,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 @@ -533,7 +626,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{ @@ -593,7 +686,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 @@ -608,7 +701,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 @@ -627,13 +720,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/consensus/genesis/util.go b/chain/consensus/genesis/util.go index 452bc835b..1f576c8a4 100644 --- a/chain/consensus/genesis/util.go +++ b/chain/consensus/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/consensus/hierarchical/actors/bundle.car b/chain/consensus/hierarchical/actors/bundle.car new file mode 100644 index 000000000..a6367df77 Binary files /dev/null and b/chain/consensus/hierarchical/actors/bundle.car differ diff --git a/chain/consensus/hierarchical/actors/sca/sca_apply.go b/chain/consensus/hierarchical/actors/sca/sca_apply.go index 3a60568fc..e6af1e546 100644 --- a/chain/consensus/hierarchical/actors/sca/sca_apply.go +++ b/chain/consensus/hierarchical/actors/sca/sca_apply.go @@ -28,7 +28,7 @@ func fromToRawAddr(rt runtime.Runtime, from, to address.Address) (address.Addres func applyTopDown(rt runtime.Runtime, msg types.Message) { var st SCAState - _, rto := fromToRawAddr(rt, msg.From, msg.To) + // _, rto := fromToRawAddr(rt, msg.From, msg.To) sto, err := msg.To.Subnet() builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to get subnet from HAddress") @@ -65,17 +65,19 @@ func applyTopDown(rt runtime.Runtime, msg types.Message) { commitTopDownMsg(rt, &st, msg) }) } else { + // FIXME: THIS IS WRONG! BUT WE ARE NOT USING THE FORK OF SPECS-ACTORS ANYMORE. + // THIS CODE SHOULD BE DEPRECATED TO USE THE FVM ACTORS. // Send the cross-message // FIXME: Should we not discard the output for any reason? - code = rt.SendWithSerializedParams(rto, msg.Method, msg.Params, msg.Value, &builtin.Discard{}) - requireSuccessWithNoop(rt, msg, code, "error applying bottomUp message") + // code = rt.SendWithSerializedParams(rto, msg.Method, msg.Params, msg.Value, &builtin.Discard{}) + // requireSuccessWithNoop(rt, msg, code, "error applying bottomUp message") } } func applyBottomUp(rt runtime.Runtime, msg types.Message) { var st SCAState - _, rto := fromToRawAddr(rt, msg.From, msg.To) + // _, rto := fromToRawAddr(rt, msg.From, msg.To) sto, err := msg.To.Subnet() builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to get subnet from HAddress") @@ -93,10 +95,12 @@ func applyBottomUp(rt runtime.Runtime, msg types.Message) { }) if sto == st.NetworkName { + // FIXME: THIS IS WRONG! BUT WE ARE NOT USING THE FORK OF SPECS-ACTORS ANYMORE. + // THIS CODE SHOULD BE DEPRECATED TO USE THE FVM ACTORS. // Release funds to the destination address if it is directed to the current network. // FIXME: Should we not discard the output for any reason? - code := rt.SendWithSerializedParams(rto, msg.Method, msg.Params, msg.Value, &builtin.Discard{}) - requireSuccessWithNoop(rt, msg, code, "error applying bottomUp message") + // code := rt.SendWithSerializedParams(rto, msg.Method, msg.Params, msg.Value, &builtin.Discard{}) + // requireSuccessWithNoop(rt, msg, code, "error applying bottomUp message") } } diff --git a/chain/consensus/hierarchical/actors/subnet/genesis.go b/chain/consensus/hierarchical/actors/subnet/genesis.go index 94d679124..6233730cb 100644 --- a/chain/consensus/hierarchical/actors/subnet/genesis.go +++ b/chain/consensus/hierarchical/actors/subnet/genesis.go @@ -40,11 +40,12 @@ import ( "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/wallet" "github.com/filecoin-project/lotus/genesis" + "github.com/filecoin-project/lotus/node/bundle" adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) const ( - networkVersion = network.Version15 + networkVersion = network.Version16 ) func makeGenesisBlock( @@ -55,6 +56,12 @@ func makeGenesisBlock( e abi.ChainEpoch, ) (*genesis2.GenesisBootstrap, error) { var err error + + // load appropriate bundles + if err := bundle.FetchAndLoadBundles(ctx, bs, build.BuiltinActorReleases); err != nil { + return nil, err + } + st, _, err := MakeInitialStateTree(ctx, bs, t, e) if err != nil { return nil, xerrors.Errorf("make initial state tree failed: %w", err) @@ -66,6 +73,7 @@ func makeGenesisBlock( } store := adt.WrapStore(ctx, cbor.NewCborStore(bs)) + emptyRoot, err := adt0.MakeEmptyArray(store).Root() if err != nil { return nil, xerrors.Errorf("amt build failed: %w", err) @@ -468,11 +476,16 @@ func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int return nil, err } + actcid, err := builtin.GetRewardActorCodeID(av) + if err != nil { + return nil, err + } + // NOTE: For now, everything in the reward actor is the same except the code, // where we included an additional method to fund accounts. This may change // in the future when we design specific reward system for subnets. act := &types.Actor{ - Code: actor.RewardActorCodeID, + Code: actcid, // NOTE: This sets up the initial balance of the reward actor. Balance: types.BigInt{Int: build.InitialRewardBalance}, Head: statecid, @@ -493,7 +506,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 } @@ -520,7 +533,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/consensus/hierarchical/atomic/exec/exec_test.go b/chain/consensus/hierarchical/atomic/exec/exec_test.go index a2c5394bc..f42e9d499 100644 --- a/chain/consensus/hierarchical/atomic/exec/exec_test.go +++ b/chain/consensus/hierarchical/atomic/exec/exec_test.go @@ -693,7 +693,7 @@ func SetupStorageMarketActor(ctx context.Context, bs blockstore.Blockstore, av a return nil, err } - actcid, err := market.GetActorCodeID(av) + actcid, err := actbuiltin.GetMarketActorCodeID(av) if err != nil { return nil, err } @@ -720,7 +720,7 @@ func SetupStoragePowerActor(ctx context.Context, bs blockstore.Blockstore, av ac return nil, err } - actcid, err := power.GetActorCodeID(av) + actcid, err := actbuiltin.GetPowerActorCodeID(av) if err != nil { return nil, err } diff --git a/chain/consensus/mir/mir_agent.go b/chain/consensus/mir/mir_agent.go index 849be73ae..b43616f1c 100644 --- a/chain/consensus/mir/mir_agent.go +++ b/chain/consensus/mir/mir_agent.go @@ -5,12 +5,10 @@ import ( "fmt" "os" "path" - "time" logging "github.com/ipfs/go-log/v2" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/consensus/hierarchical" "github.com/filecoin-project/mir" mirCrypto "github.com/filecoin-project/mir/pkg/crypto" @@ -145,7 +143,7 @@ func (m *MirAgent) Start(ctx context.Context) chan error { }() go func() { - errChan <- m.Node.Run(ctx, time.NewTicker(time.Duration(build.MirTimer)*time.Millisecond).C) + errChan <- m.Node.Run(ctx) agentCancel() }() diff --git a/chain/gen/gen.go b/chain/gen/gen.go index bac6686d0..9ffd6395d 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -43,7 +43,6 @@ import ( "github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/node/repo" - proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof" ) @@ -52,7 +51,7 @@ const msgsPerBlock = 20 //nolint:deadcode,varcheck var log = logging.Logger("gen") -var ValidWpostForTesting = []proof5.PoStProof{{ +var ValidWpostForTesting = []proof7.PoStProof{{ ProofBytes: []byte("valid proof"), }} @@ -498,7 +497,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 { @@ -628,7 +627,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{} @@ -637,7 +636,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 } @@ -688,11 +687,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 5236de6f5..758dfb381 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 } @@ -495,7 +495,7 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca 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..5ff499351 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,26 @@ 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(), + FilVested: 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 +132,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 +152,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 +168,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 +200,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 +209,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 +234,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 +283,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 +294,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 +341,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 +350,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 +378,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 +387,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 +427,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 +488,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 +500,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 +536,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 +590,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 +613,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 +626,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 +686,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 +701,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 +720,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/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 0ff36512c..cc5cb90ba 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -66,7 +66,8 @@ var MaxUntrustedActorPendingMessages = 10 var MaxNonceGap = uint64(4) -const MaxMessageSize = 64 << 10 // 64KiB +//const MaxMessageSize = 64 << 10 // 64KiB +const MaxMessageSize = 1<<20 - 128 // 1MiB minus some change for pb stuff var ( ErrMessageTooBig = errors.New("message too big") 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..d824cc2f4 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) 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 2707d4942..d3377ea95 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 e4f6898e7..c582d4c5b 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -7,7 +7,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/consensus/hierarchical/subnet/resolver" - "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" @@ -58,7 +58,7 @@ type versionSpec struct { type migration struct { upgrade MigrationFunc preMigrations []PreMigration - cache *nv15.MemMigrationCache + cache *nv16.MemMigrationCache } type Executor interface { @@ -128,7 +128,7 @@ func NewStateManager(cs *store.ChainStore, exec Executor, cr *resolver.Resolver, migration := &migration{ upgrade: upgrade.Migration, preMigrations: upgrade.PreMigrations, - cache: nv15.NewMemMigrationCache(), + cache: nv16.NewMemMigrationCache(), } stateMigrations[upgrade.Height] = migration } 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 12ea2f782..1fbbbf4d4 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 6a8108e95..a65d46bd5 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 0262b1baa..381f8f285 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -3,7 +3,7 @@ package vm import ( "bytes" "context" - "sync/atomic" + "os" "time" "github.com/ipfs/go-cid" @@ -14,8 +14,6 @@ import ( "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 +29,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" @@ -257,7 +256,6 @@ 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 @@ -273,9 +271,15 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { } } - fvmOpts := ffi.FVMOpts{ - FVMVersion: 0, - Externs: &FvmExtern{Rand: opts.Rand, Blockstore: opts.Bstore, lbState: opts.LookbackState, base: opts.StateBase, epoch: opts.Epoch, nv: opts.NetworkVersion}, + 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, @@ -284,7 +288,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,7 +314,6 @@ 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() if err != nil { return nil, xerrors.Errorf("serializing msg: %w", err) @@ -330,14 +347,13 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet GasUsed: ret.GasUsed, }, 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(), @@ -347,7 +363,6 @@ func (vm *FVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet 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() if err != nil { return nil, xerrors.Errorf("serializing msg: %w", err) 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 b9dc96c18..02605d71c 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" @@ -118,12 +110,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: @@ -138,7 +124,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 7b2f14156..9579057ea 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -25,11 +25,14 @@ import ( rt7 "github.com/filecoin-project/specs-actors/v7/actors/runtime" "github.com/ipfs/go-cid" ipldcbor "github.com/ipfs/go-ipld-cbor" + mh "github.com/multiformats/go-multihash" "go.opencensus.io/trace" "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" ) @@ -220,6 +223,23 @@ func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool) panic(aerrors.Fatalf("failed to get actor: %s", err)) } + // required for genesis/testing + if nv := rt.NetworkVersion(); nv >= network.Version16 { + name, av, ok := actors.GetActorMetaByCode(act.Code) + + if ok { + // lies, lies, lies + builder := cid.V1Builder{Codec: cid.Raw, MhType: mh.IDENTITY} + synthetic := fmt.Sprintf("fil/%d/%s", av, name) + syntheticCid, err := builder.Sum([]byte(synthetic)) + if err != nil { + panic(aerrors.Fatalf("failed to generate synthetic CID: %s", err)) + } + + return syntheticCid, true + } + } + return act.Code, true } @@ -365,6 +385,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 4b3fd2105..683d145b3 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" @@ -625,7 +625,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..2e826080f 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" ) @@ -19,6 +20,11 @@ type Interface interface { } func NewVM(ctx context.Context, opts *VMOpts) (Interface, error) { + 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 os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" { return NewFVM(ctx, opts) } diff --git a/cli/chain.go b/cli/chain.go index 00b9a73c6..e50f5911e 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -20,6 +20,7 @@ import ( cborutil "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" + init8 "github.com/filecoin-project/go-state-types/builtin/v8/init" "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin/account" "github.com/filecoin-project/specs-actors/actors/builtin/market" @@ -61,6 +62,9 @@ var ChainCmd = &cli.Command{ ChainDecodeCmd, ChainEncodeCmd, ChainDisputeSetCmd, + ChainInstallCmd, + ChainExecCmd, + ChainInvokeCmd, }, } @@ -1461,3 +1465,298 @@ func createExportFile(app *cli.App, path string) (io.WriteCloser, error) { } return fi, nil } + +var ChainInstallCmd = &cli.Command{ + Name: "install-actor", + Usage: "Install a new actor and return the actor code CID", + ArgsUsage: "code", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "from", + Usage: "optionally specify the account to use for sending the installation message", + }, + }, + Action: func(cctx *cli.Context) error { + afmt := NewAppFmt(cctx.App) + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + ctx := ReqContext(cctx) + + if !cctx.Args().Present() { + return fmt.Errorf("must pass the filename containing actor code") + } + + filename := cctx.Args().First() + file, err := os.Open(filename) + if err != nil { + return err + } + defer file.Close() //nolint + + code, err := io.ReadAll(file) + if err != nil { + return err + } + + params, err := actors.SerializeParams(&init8.InstallParams{ + Code: code, + }) + if err != nil { + return xerrors.Errorf("failed to serialize params: %w", err) + } + + var fromAddr address.Address + if from := cctx.String("from"); from == "" { + defaddr, err := api.WalletDefaultAddress(ctx) + if err != nil { + return err + } + + fromAddr = defaddr + } else { + addr, err := address.NewFromString(from) + if err != nil { + return err + } + + fromAddr = addr + } + + msg := &types.Message{ + To: builtin.InitActorAddr, + From: fromAddr, + Value: big.Zero(), + Method: 3, + Params: params, + } + + afmt.Println("sending message...") + smsg, err := api.MpoolPushMessage(ctx, msg, nil) + if err != nil { + return xerrors.Errorf("failed to push message: %w", err) + } + + afmt.Printf("gas limit: %d\n", smsg.Message.GasLimit) + + afmt.Println("waiting for message to execute...") + wait, err := api.StateWaitMsg(ctx, smsg.Cid(), 0) + if err != nil { + return xerrors.Errorf("error waiting for message: %w", err) + } + + // check it executed successfully + if wait.Receipt.ExitCode != 0 { + return xerrors.Errorf("actor installation failed") + } + + var result init8.InstallReturn + r := bytes.NewReader(wait.Receipt.Return) + if err := result.UnmarshalCBOR(r); err != nil { + return xerrors.Errorf("error unmarshaling return value: %w", err) + } + + afmt.Printf("Actor Code CID: %s\n", result.CodeCid) + afmt.Printf("Installed: %t\n", result.Installed) + + return nil + }, +} + +var ChainExecCmd = &cli.Command{ + Name: "create-actor", + Usage: "Create an new actor via the init actor and return its address", + ArgsUsage: "code-cid [params]", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "from", + Usage: "optionally specify the account to use for sending the exec message", + }, + }, + Action: func(cctx *cli.Context) error { + afmt := NewAppFmt(cctx.App) + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + ctx := ReqContext(cctx) + + if argc := cctx.Args().Len(); argc < 1 || argc > 2 { + return xerrors.Errorf("must pass the code cid and (optionally) constructor params") + } + + codeCid, err := cid.Decode(cctx.Args().First()) + if err != nil { + return xerrors.Errorf("failed to decode code cid: %w", err) + } + + var cparams []byte + if cctx.Args().Len() == 2 { + cparams, err = base64.StdEncoding.DecodeString(cctx.Args().Get(1)) + if err != nil { + return xerrors.Errorf("decoding base64 value: %w", err) + } + } + + params, err := actors.SerializeParams(&init8.ExecParams{ + CodeCID: codeCid, + ConstructorParams: cparams, + }) + if err != nil { + return xerrors.Errorf("failed to serialize params: %w", err) + } + + var fromAddr address.Address + if from := cctx.String("from"); from == "" { + defaddr, err := api.WalletDefaultAddress(ctx) + if err != nil { + return err + } + + fromAddr = defaddr + } else { + addr, err := address.NewFromString(from) + if err != nil { + return err + } + + fromAddr = addr + } + + msg := &types.Message{ + To: builtin.InitActorAddr, + From: fromAddr, + Value: big.Zero(), + Method: 2, + Params: params, + } + + afmt.Println("sending message...") + smsg, err := api.MpoolPushMessage(ctx, msg, nil) + if err != nil { + return xerrors.Errorf("failed to push message: %w", err) + } + + afmt.Println("waiting for message to execute...") + wait, err := api.StateWaitMsg(ctx, smsg.Cid(), 0) + if err != nil { + return xerrors.Errorf("error waiting for message: %w", err) + } + + // check it executed successfully + if wait.Receipt.ExitCode != 0 { + return xerrors.Errorf("actor execution failed") + } + + var result init8.ExecReturn + r := bytes.NewReader(wait.Receipt.Return) + if err := result.UnmarshalCBOR(r); err != nil { + return xerrors.Errorf("error unmarshaling return value: %w", err) + } + + afmt.Printf("ID Address: %s\n", result.IDAddress) + afmt.Printf("Robust Address: %s\n", result.RobustAddress) + + return nil + }, +} + +var ChainInvokeCmd = &cli.Command{ + Name: "invoke", + Usage: "Invoke a method in an actor", + ArgsUsage: "address method [params]", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "from", + Usage: "optionally specify the account to use for sending the exec message", + }, + }, + Action: func(cctx *cli.Context) error { + afmt := NewAppFmt(cctx.App) + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + ctx := ReqContext(cctx) + + if argc := cctx.Args().Len(); argc < 2 || argc > 3 { + return xerrors.Errorf("must pass the address, method and (optionally) method params") + } + + addr, err := address.NewFromString(cctx.Args().Get(0)) + if err != nil { + return xerrors.Errorf("failed to decode address: %w", err) + } + + method, err := strconv.Atoi(cctx.Args().Get(1)) + if err != nil { + return xerrors.Errorf("failed to parse method: %w", err) + } + + var params []byte + if cctx.Args().Len() == 3 { + params, err = base64.StdEncoding.DecodeString(cctx.Args().Get(2)) + if err != nil { + return xerrors.Errorf("decoding base64 value: %w", err) + } + } + + var fromAddr address.Address + if from := cctx.String("from"); from == "" { + defaddr, err := api.WalletDefaultAddress(ctx) + if err != nil { + return err + } + + fromAddr = defaddr + } else { + addr, err := address.NewFromString(from) + if err != nil { + return err + } + + fromAddr = addr + } + + msg := &types.Message{ + To: addr, + From: fromAddr, + Value: big.Zero(), + Method: abi.MethodNum(method), + Params: params, + } + + afmt.Println("sending message...") + smsg, err := api.MpoolPushMessage(ctx, msg, nil) + if err != nil { + return xerrors.Errorf("failed to push message: %w", err) + } + + afmt.Println("waiting for message to execute...") + wait, err := api.StateWaitMsg(ctx, smsg.Cid(), 0) + if err != nil { + return xerrors.Errorf("error waiting for message: %w", err) + } + + // check it executed successfully + if wait.Receipt.ExitCode != 0 { + return xerrors.Errorf("actor execution failed") + } + + if len(wait.Receipt.Return) > 0 { + result := base64.StdEncoding.EncodeToString(wait.Receipt.Return) + afmt.Println(result) + } else { + afmt.Println("OK") + } + + return nil + }, +} 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/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/paych.go b/cli/paych.go index 92c1a13e3..7640eee01 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" ) @@ -416,7 +417,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 +453,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 +611,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/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-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/sectors.go b/cmd/lotus-miner/sectors.go index 0918f62f0..fea5cae58 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 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 3602c77f0..dc236970e 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" @@ -581,7 +583,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/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/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/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/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/conformance/driver.go b/conformance/driver.go index 3d350e1f8..063a2ff75 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-state-types/network" "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" @@ -235,7 +236,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..e675083c9 100644 --- a/documentation/en/api-v0-methods.md +++ b/documentation/en/api-v0-methods.md @@ -165,7 +165,6 @@ * [StateDealProviderCollateralBounds](#StateDealProviderCollateralBounds) * [StateDecodeParams](#StateDecodeParams) * [StateGetActor](#StateGetActor) - * [StateGetNetworkParams](#StateGetNetworkParams) * [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon) * [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets) * [StateGetReceipt](#StateGetReceipt) @@ -4274,7 +4273,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4351,7 +4350,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4392,7 +4391,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4433,7 +4432,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4480,7 +4479,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4524,7 +4523,7 @@ Response: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -4561,7 +4560,7 @@ Inputs: "ChannelAddr": "f01234", "TimeLockMin": 10101, "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", + "SecretHash": "Ynl0ZSBhcnJheQ==", "Extra": { "Actor": "f01234", "Method": 1, @@ -5186,49 +5185,6 @@ Response: } ``` -### StateGetNetworkParams -StateGetNetworkParams return current network params - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "NetworkName": "lotus", - "BlockDelaySecs": 42, - "ConsensusMinerMinPower": "0", - "SupportedProofTypes": [ - 8 - ], - "PreCommitChallengeDelay": 10101, - "ForkUpgradeParams": { - "UpgradeSmokeHeight": 10101, - "UpgradeBreezeHeight": 10101, - "UpgradeIgnitionHeight": 10101, - "UpgradeLiftoffHeight": 10101, - "UpgradeAssemblyHeight": 10101, - "UpgradeRefuelHeight": 10101, - "UpgradeTapeHeight": 10101, - "UpgradeKumquatHeight": 10101, - "UpgradePriceListOopsHeight": 10101, - "BreezeGasTampingDuration": 10101, - "UpgradeCalicoHeight": 10101, - "UpgradePersianHeight": 10101, - "UpgradeOrangeHeight": 10101, - "UpgradeClausHeight": 10101, - "UpgradeTrustHeight": 10101, - "UpgradeNorwegianHeight": 10101, - "UpgradeTurboHeight": 10101, - "UpgradeHyperdriveHeight": 10101, - "UpgradeChocolateHeight": 10101, - "UpgradeOhSnapHeight": 10101 - } -} -``` - ### StateGetRandomnessFromBeacon StateGetRandomnessFromBeacon is used to sample the beacon for randomness. @@ -5491,7 +5447,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -5569,7 +5525,7 @@ Response: "VerifiedDeal": true, "Client": "f01234", "Provider": "f01234", - "Label": "string value", + "Label": "", "StartEpoch": 10101, "EndEpoch": 10101, "StoragePricePerEpoch": "0", @@ -5624,6 +5580,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ] @@ -6087,6 +6045,8 @@ Response: "InitialPledge": "0", "ExpectedDayReward": "0", "ExpectedStoragePledge": "0", + "ReplacedSectorAge": 10101, + "ReplacedDayReward": "0", "SectorKeyCID": null } ] @@ -6122,7 +6082,7 @@ Inputs: ] ``` -Response: `15` +Response: `16` ### StateReadState StateReadState returns the indicated actor's state. @@ -6508,6 +6468,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..e69de29bb 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -1,7696 +0,0 @@ -# Groups -* [](#) - * [Closing](#Closing) - * [Discover](#Discover) - * [Session](#Session) - * [Shutdown](#Shutdown) - * [Version](#Version) -* [Auth](#Auth) - * [AuthNew](#AuthNew) - * [AuthVerify](#AuthVerify) -* [Beacon](#Beacon) - * [BeaconGetEntry](#BeaconGetEntry) -* [Chain](#Chain) - * [ChainBlockstoreInfo](#ChainBlockstoreInfo) - * [ChainCheckBlockstore](#ChainCheckBlockstore) - * [ChainDeleteObj](#ChainDeleteObj) - * [ChainExport](#ChainExport) - * [ChainGetBlock](#ChainGetBlock) - * [ChainGetBlockMessages](#ChainGetBlockMessages) - * [ChainGetGenesis](#ChainGetGenesis) - * [ChainGetMessage](#ChainGetMessage) - * [ChainGetMessagesInTipset](#ChainGetMessagesInTipset) - * [ChainGetNode](#ChainGetNode) - * [ChainGetParentMessages](#ChainGetParentMessages) - * [ChainGetParentReceipts](#ChainGetParentReceipts) - * [ChainGetPath](#ChainGetPath) - * [ChainGetTipSet](#ChainGetTipSet) - * [ChainGetTipSetAfterHeight](#ChainGetTipSetAfterHeight) - * [ChainGetTipSetByHeight](#ChainGetTipSetByHeight) - * [ChainHasObj](#ChainHasObj) - * [ChainHead](#ChainHead) - * [ChainNotify](#ChainNotify) - * [ChainReadObj](#ChainReadObj) - * [ChainSetHead](#ChainSetHead) - * [ChainStatObj](#ChainStatObj) - * [ChainTipSetWeight](#ChainTipSetWeight) -* [Client](#Client) - * [ClientCalcCommP](#ClientCalcCommP) - * [ClientCancelDataTransfer](#ClientCancelDataTransfer) - * [ClientCancelRetrievalDeal](#ClientCancelRetrievalDeal) - * [ClientDataTransferUpdates](#ClientDataTransferUpdates) - * [ClientDealPieceCID](#ClientDealPieceCID) - * [ClientDealSize](#ClientDealSize) - * [ClientExport](#ClientExport) - * [ClientFindData](#ClientFindData) - * [ClientGenCar](#ClientGenCar) - * [ClientGetDealInfo](#ClientGetDealInfo) - * [ClientGetDealStatus](#ClientGetDealStatus) - * [ClientGetDealUpdates](#ClientGetDealUpdates) - * [ClientGetRetrievalUpdates](#ClientGetRetrievalUpdates) - * [ClientHasLocal](#ClientHasLocal) - * [ClientImport](#ClientImport) - * [ClientListDataTransfers](#ClientListDataTransfers) - * [ClientListDeals](#ClientListDeals) - * [ClientListImports](#ClientListImports) - * [ClientListRetrievals](#ClientListRetrievals) - * [ClientMinerQueryOffer](#ClientMinerQueryOffer) - * [ClientQueryAsk](#ClientQueryAsk) - * [ClientRemoveImport](#ClientRemoveImport) - * [ClientRestartDataTransfer](#ClientRestartDataTransfer) - * [ClientRetrieve](#ClientRetrieve) - * [ClientRetrieveTryRestartInsufficientFunds](#ClientRetrieveTryRestartInsufficientFunds) - * [ClientRetrieveWait](#ClientRetrieveWait) - * [ClientStartDeal](#ClientStartDeal) - * [ClientStatelessDeal](#ClientStatelessDeal) -* [Create](#Create) - * [CreateBackup](#CreateBackup) -* [Gas](#Gas) - * [GasEstimateFeeCap](#GasEstimateFeeCap) - * [GasEstimateGasLimit](#GasEstimateGasLimit) - * [GasEstimateGasPremium](#GasEstimateGasPremium) - * [GasEstimateMessageGas](#GasEstimateMessageGas) -* [I](#I) - * [ID](#ID) -* [Log](#Log) - * [LogAlerts](#LogAlerts) - * [LogList](#LogList) - * [LogSetLevel](#LogSetLevel) -* [Market](#Market) - * [MarketAddBalance](#MarketAddBalance) - * [MarketGetReserved](#MarketGetReserved) - * [MarketReleaseFunds](#MarketReleaseFunds) - * [MarketReserveFunds](#MarketReserveFunds) - * [MarketWithdraw](#MarketWithdraw) -* [Miner](#Miner) - * [MinerCreateBlock](#MinerCreateBlock) - * [MinerGetBaseInfo](#MinerGetBaseInfo) -* [Mpool](#Mpool) - * [MpoolBatchPush](#MpoolBatchPush) - * [MpoolBatchPushMessage](#MpoolBatchPushMessage) - * [MpoolBatchPushUntrusted](#MpoolBatchPushUntrusted) - * [MpoolCheckMessages](#MpoolCheckMessages) - * [MpoolCheckPendingMessages](#MpoolCheckPendingMessages) - * [MpoolCheckReplaceMessages](#MpoolCheckReplaceMessages) - * [MpoolClear](#MpoolClear) - * [MpoolGetConfig](#MpoolGetConfig) - * [MpoolGetNonce](#MpoolGetNonce) - * [MpoolPending](#MpoolPending) - * [MpoolPush](#MpoolPush) - * [MpoolPushMessage](#MpoolPushMessage) - * [MpoolPushUntrusted](#MpoolPushUntrusted) - * [MpoolSelect](#MpoolSelect) - * [MpoolSetConfig](#MpoolSetConfig) - * [MpoolSub](#MpoolSub) -* [Msig](#Msig) - * [MsigAddApprove](#MsigAddApprove) - * [MsigAddCancel](#MsigAddCancel) - * [MsigAddPropose](#MsigAddPropose) - * [MsigApprove](#MsigApprove) - * [MsigApproveTxnHash](#MsigApproveTxnHash) - * [MsigCancel](#MsigCancel) - * [MsigCancelTxnHash](#MsigCancelTxnHash) - * [MsigCreate](#MsigCreate) - * [MsigGetAvailableBalance](#MsigGetAvailableBalance) - * [MsigGetPending](#MsigGetPending) - * [MsigGetVested](#MsigGetVested) - * [MsigGetVestingSchedule](#MsigGetVestingSchedule) - * [MsigPropose](#MsigPropose) - * [MsigRemoveSigner](#MsigRemoveSigner) - * [MsigSwapApprove](#MsigSwapApprove) - * [MsigSwapCancel](#MsigSwapCancel) - * [MsigSwapPropose](#MsigSwapPropose) -* [Net](#Net) - * [NetAddrsListen](#NetAddrsListen) - * [NetAgentVersion](#NetAgentVersion) - * [NetAutoNatStatus](#NetAutoNatStatus) - * [NetBandwidthStats](#NetBandwidthStats) - * [NetBandwidthStatsByPeer](#NetBandwidthStatsByPeer) - * [NetBandwidthStatsByProtocol](#NetBandwidthStatsByProtocol) - * [NetBlockAdd](#NetBlockAdd) - * [NetBlockList](#NetBlockList) - * [NetBlockRemove](#NetBlockRemove) - * [NetConnect](#NetConnect) - * [NetConnectedness](#NetConnectedness) - * [NetDisconnect](#NetDisconnect) - * [NetFindPeer](#NetFindPeer) - * [NetLimit](#NetLimit) - * [NetPeerInfo](#NetPeerInfo) - * [NetPeers](#NetPeers) - * [NetPing](#NetPing) - * [NetProtectAdd](#NetProtectAdd) - * [NetProtectList](#NetProtectList) - * [NetProtectRemove](#NetProtectRemove) - * [NetPubsubScores](#NetPubsubScores) - * [NetSetLimit](#NetSetLimit) - * [NetStat](#NetStat) -* [Node](#Node) - * [NodeStatus](#NodeStatus) -* [Paych](#Paych) - * [PaychAllocateLane](#PaychAllocateLane) - * [PaychAvailableFunds](#PaychAvailableFunds) - * [PaychAvailableFundsByFromTo](#PaychAvailableFundsByFromTo) - * [PaychCollect](#PaychCollect) - * [PaychFund](#PaychFund) - * [PaychGet](#PaychGet) - * [PaychGetWaitReady](#PaychGetWaitReady) - * [PaychList](#PaychList) - * [PaychNewPayment](#PaychNewPayment) - * [PaychSettle](#PaychSettle) - * [PaychStatus](#PaychStatus) - * [PaychVoucherAdd](#PaychVoucherAdd) - * [PaychVoucherCheckSpendable](#PaychVoucherCheckSpendable) - * [PaychVoucherCheckValid](#PaychVoucherCheckValid) - * [PaychVoucherCreate](#PaychVoucherCreate) - * [PaychVoucherList](#PaychVoucherList) - * [PaychVoucherSubmit](#PaychVoucherSubmit) -* [State](#State) - * [StateAccountKey](#StateAccountKey) - * [StateAllMinerFaults](#StateAllMinerFaults) - * [StateCall](#StateCall) - * [StateChangedActors](#StateChangedActors) - * [StateCirculatingSupply](#StateCirculatingSupply) - * [StateCompute](#StateCompute) - * [StateDealProviderCollateralBounds](#StateDealProviderCollateralBounds) - * [StateDecodeParams](#StateDecodeParams) - * [StateEncodeParams](#StateEncodeParams) - * [StateGetActor](#StateGetActor) - * [StateGetNetworkParams](#StateGetNetworkParams) - * [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon) - * [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets) - * [StateListActors](#StateListActors) - * [StateListMessages](#StateListMessages) - * [StateListMiners](#StateListMiners) - * [StateLookupID](#StateLookupID) - * [StateLookupRobustAddress](#StateLookupRobustAddress) - * [StateMarketBalance](#StateMarketBalance) - * [StateMarketDeals](#StateMarketDeals) - * [StateMarketParticipants](#StateMarketParticipants) - * [StateMarketStorageDeal](#StateMarketStorageDeal) - * [StateMinerActiveSectors](#StateMinerActiveSectors) - * [StateMinerAvailableBalance](#StateMinerAvailableBalance) - * [StateMinerDeadlines](#StateMinerDeadlines) - * [StateMinerFaults](#StateMinerFaults) - * [StateMinerInfo](#StateMinerInfo) - * [StateMinerInitialPledgeCollateral](#StateMinerInitialPledgeCollateral) - * [StateMinerPartitions](#StateMinerPartitions) - * [StateMinerPower](#StateMinerPower) - * [StateMinerPreCommitDepositForPower](#StateMinerPreCommitDepositForPower) - * [StateMinerProvingDeadline](#StateMinerProvingDeadline) - * [StateMinerRecoveries](#StateMinerRecoveries) - * [StateMinerSectorAllocated](#StateMinerSectorAllocated) - * [StateMinerSectorCount](#StateMinerSectorCount) - * [StateMinerSectors](#StateMinerSectors) - * [StateNetworkName](#StateNetworkName) - * [StateNetworkVersion](#StateNetworkVersion) - * [StateReadState](#StateReadState) - * [StateReplay](#StateReplay) - * [StateSearchMsg](#StateSearchMsg) - * [StateSectorExpiration](#StateSectorExpiration) - * [StateSectorGetInfo](#StateSectorGetInfo) - * [StateSectorPartition](#StateSectorPartition) - * [StateSectorPreCommitInfo](#StateSectorPreCommitInfo) - * [StateVMCirculatingSupplyInternal](#StateVMCirculatingSupplyInternal) - * [StateVerifiedClientStatus](#StateVerifiedClientStatus) - * [StateVerifiedRegistryRootKey](#StateVerifiedRegistryRootKey) - * [StateVerifierStatus](#StateVerifierStatus) - * [StateWaitMsg](#StateWaitMsg) -* [Sync](#Sync) - * [SyncCheckBad](#SyncCheckBad) - * [SyncCheckpoint](#SyncCheckpoint) - * [SyncIncomingBlocks](#SyncIncomingBlocks) - * [SyncMarkBad](#SyncMarkBad) - * [SyncState](#SyncState) - * [SyncSubmitBlock](#SyncSubmitBlock) - * [SyncUnmarkAllBad](#SyncUnmarkAllBad) - * [SyncUnmarkBad](#SyncUnmarkBad) - * [SyncValidateTipset](#SyncValidateTipset) -* [Wallet](#Wallet) - * [WalletBalance](#WalletBalance) - * [WalletDefaultAddress](#WalletDefaultAddress) - * [WalletDelete](#WalletDelete) - * [WalletExport](#WalletExport) - * [WalletHas](#WalletHas) - * [WalletImport](#WalletImport) - * [WalletList](#WalletList) - * [WalletNew](#WalletNew) - * [WalletSetDefault](#WalletSetDefault) - * [WalletSign](#WalletSign) - * [WalletSignMessage](#WalletSignMessage) - * [WalletValidateAddress](#WalletValidateAddress) - * [WalletVerify](#WalletVerify) -## - - -### Closing - - -Perms: read - -Inputs: `null` - -Response: `{}` - -### Discover - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "info": { - "title": "Lotus RPC API", - "version": "1.2.1/generated=2020-11-22T08:22:42-06:00" - }, - "methods": [], - "openrpc": "1.2.6" -} -``` - -### Session - - -Perms: read - -Inputs: `null` - -Response: `"07070707-0707-0707-0707-070707070707"` - -### Shutdown - - -Perms: admin - -Inputs: `null` - -Response: `{}` - -### Version - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Version": "string value", - "APIVersion": 131584, - "BlockDelay": 42 -} -``` - -## Auth - - -### AuthNew - - -Perms: admin - -Inputs: -```json -[ - [ - "write" - ] -] -``` - -Response: `"Ynl0ZSBhcnJheQ=="` - -### AuthVerify - - -Perms: read - -Inputs: -```json -[ - "string value" -] -``` - -Response: -```json -[ - "write" -] -``` - -## 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. - - -### ChainBlockstoreInfo -ChainBlockstoreInfo returns some basic information about the blockstore - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "abc": 123 -} -``` - -### ChainCheckBlockstore -ChainCheckBlockstore performs an (asynchronous) health check on the chain/state blockstore -if supported by the underlying implementation. - - -Perms: admin - -Inputs: `null` - -Response: `{}` - -### ChainDeleteObj -ChainDeleteObj deletes node referenced by the given CID - - -Perms: admin - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `{}` - -### ChainExport -ChainExport returns a stream of bytes with CAR dump of chain data. -The exported chain data includes the header chain from the given tipset -back to genesis, the entire genesis state, and the most recent 'nroots' -state trees. -If oldmsgskip is set, messages from before the requested roots are also not included. - - -Perms: read - -Inputs: -```json -[ - 10101, - true, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"Ynl0ZSBhcnJheQ=="` - -### ChainGetBlock -ChainGetBlock returns the block specified by the given CID. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "Miner": "f01234", - "Ticket": { - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "ElectionProof": { - "WinCount": 9, - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "BeaconEntries": [ - { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - } - ], - "WinPoStProof": [ - { - "PoStProof": 8, - "ProofBytes": "Ynl0ZSBhcnJheQ==" - } - ], - "Parents": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ], - "ParentWeight": "0", - "Height": 10101, - "ParentStateRoot": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ParentMessageReceipts": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Messages": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "BLSAggregate": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Timestamp": 42, - "BlockSig": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "ForkSignaling": 42, - "ParentBaseFee": "0" -} -``` - -### ChainGetBlockMessages -ChainGetBlockMessages returns messages stored in the specified block. - -Note: If there are multiple blocks in a tipset, it's likely that some -messages will be duplicated. It's also possible for blocks in a tipset to have -different messages from the same sender at the same nonce. When that happens, -only the first message (in a block with lowest ticket) will be considered -for execution - -NOTE: THIS METHOD SHOULD ONLY BE USED FOR GETTING MESSAGES IN A SPECIFIC BLOCK - -DO NOT USE THIS METHOD TO GET MESSAGES INCLUDED IN A TIPSET -Use ChainGetParentMessages, which will perform correct message deduplication - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "BlsMessages": [ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ], - "SecpkMessages": [ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ], - "Cids": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ] -} -``` - -### ChainGetGenesis -ChainGetGenesis returns the genesis tipset. - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Cids": null, - "Blocks": null, - "Height": 0 -} -``` - -### ChainGetMessage -ChainGetMessage reads a message referenced by the specified CID from the -chain blockstore. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } -} -``` - -### ChainGetMessagesInTipset -ChainGetMessagesInTipset returns message stores in current tipset - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "Cid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - } -] -``` - -### ChainGetNode - - -Perms: read - -Inputs: -```json -[ - "string value" -] -``` - -Response: -```json -{ - "Cid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Obj": {} -} -``` - -### ChainGetParentMessages -ChainGetParentMessages returns messages stored in parent tipset of the -specified block. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -[ - { - "Cid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - } -] -``` - -### ChainGetParentReceipts -ChainGetParentReceipts returns receipts for messages in parent tipset of -the specified block. The receipts in the list returned is one-to-one with the -messages returned by a call to ChainGetParentMessages with the same blockCid. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -[ - { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - } -] -``` - -### ChainGetPath -ChainGetPath returns a set of revert/apply operations needed to get from -one tipset to another, for example: -``` - to - ^ -from tAA - ^ ^ -tBA tAB - ^---*--^ - ^ - tRR -``` -Would return `[revert(tBA), apply(tAB), apply(tAA)]` - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "Type": "string value", - "Val": { - "Cids": null, - "Blocks": null, - "Height": 0 - } - } -] -``` - -### ChainGetTipSet -ChainGetTipSet returns the tipset specified by the given TipSetKey. - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Cids": null, - "Blocks": null, - "Height": 0 -} -``` - -### ChainGetTipSetAfterHeight -ChainGetTipSetAfterHeight looks back for a tipset at the specified epoch. -If there are no blocks at the specified epoch, the first non-nil tipset at a later epoch -will be returned. - - -Perms: read - -Inputs: -```json -[ - 10101, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Cids": null, - "Blocks": null, - "Height": 0 -} -``` - -### ChainGetTipSetByHeight -ChainGetTipSetByHeight looks back for a tipset at the specified epoch. -If there are no blocks at the specified epoch, a tipset at an earlier epoch -will be returned. - - -Perms: read - -Inputs: -```json -[ - 10101, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Cids": null, - "Blocks": null, - "Height": 0 -} -``` - -### ChainHasObj -ChainHasObj checks if a given CID exists in the chain blockstore. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `true` - -### ChainHead -ChainHead returns the current head of the chain. - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Cids": null, - "Blocks": null, - "Height": 0 -} -``` - -### ChainNotify -ChainNotify returns channel with chain head updates. -First message is guaranteed to be of len == 1, and type == 'current'. - - -Perms: read - -Inputs: `null` - -Response: -```json -[ - { - "Type": "string value", - "Val": { - "Cids": null, - "Blocks": null, - "Height": 0 - } - } -] -``` - -### ChainReadObj -ChainReadObj reads ipld nodes referenced by the specified CID from chain -blockstore and returns raw bytes. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `"Ynl0ZSBhcnJheQ=="` - -### ChainSetHead -ChainSetHead forcefully sets current chain head. Use with caution. - - -Perms: admin - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `{}` - -### ChainStatObj -ChainStatObj returns statistics about the graph referenced by 'obj'. -If 'base' is also specified, then the returned stat will be a diff -between the two objects. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "Size": 42, - "Links": 42 -} -``` - -### ChainTipSetWeight -ChainTipSetWeight computes weight for the specified tipset. - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -## Client -The Client methods all have to do with interacting with the storage and -retrieval markets as a client - - -### ClientCalcCommP -ClientCalcCommP calculates the CommP for a specified file - - -Perms: write - -Inputs: -```json -[ - "string value" -] -``` - -Response: -```json -{ - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Size": 1024 -} -``` - -### ClientCancelDataTransfer -ClientCancelDataTransfer cancels a data transfer with the given transfer ID and other peer - - -Perms: write - -Inputs: -```json -[ - 3, - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - true -] -``` - -Response: `{}` - -### ClientCancelRetrievalDeal -ClientCancelRetrievalDeal cancels an ongoing retrieval deal based on DealID - - -Perms: write - -Inputs: -```json -[ - 5 -] -``` - -Response: `{}` - -### ClientDataTransferUpdates - - -Perms: write - -Inputs: `null` - -Response: -```json -{ - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } -} -``` - -### ClientDealPieceCID -ClientCalcCommP calculates the CommP and data size of the specified CID - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "PayloadSize": 9, - "PieceSize": 1032, - "PieceCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -} -``` - -### ClientDealSize -ClientDealSize calculates real deal data size - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "PayloadSize": 9, - "PieceSize": 1032 -} -``` - -### ClientExport -ClientExport exports a file stored in the local filestore to a system file - - -Perms: admin - -Inputs: -```json -[ - { - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "DAGs": [ - { - "DataSelector": "Links/21/Hash/Links/42/Hash", - "ExportMerkleProof": true - } - ], - "FromLocalCAR": "string value", - "DealID": 5 - }, - { - "Path": "string value", - "IsCAR": true - } -] -``` - -Response: `{}` - -### ClientFindData -ClientFindData identifies peers that have a certain file, and returns QueryOffers (one per peer). - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - null -] -``` - -Response: -```json -[ - { - "Err": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Piece": null, - "Size": 42, - "MinPrice": "0", - "UnsealPrice": "0", - "PricePerByte": "0", - "PaymentInterval": 42, - "PaymentIntervalIncrease": 42, - "Miner": "f01234", - "MinerPeer": { - "Address": "f01234", - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "PieceCID": null - } - } -] -``` - -### ClientGenCar -ClientGenCar generates a CAR file for the specified file. - - -Perms: write - -Inputs: -```json -[ - { - "Path": "string value", - "IsCAR": true - }, - "string value" -] -``` - -Response: `{}` - -### ClientGetDealInfo -ClientGetDealInfo returns the latest information about a given deal. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "ProposalCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "State": 42, - "Message": "string value", - "DealStages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "ExpectedDuration": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - }, - "Provider": "f01234", - "DataRef": { - "TransferType": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceCid": null, - "PieceSize": 1024, - "RawBlockSize": 42 - }, - "PieceCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Size": 42, - "PricePerEpoch": "0", - "Duration": 42, - "DealID": 5432, - "CreationTime": "0001-01-01T00:00:00Z", - "Verified": true, - "TransferChannelID": { - "Initiator": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Responder": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "ID": 3 - }, - "DataTransfer": { - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } - } -} -``` - -### ClientGetDealStatus -ClientGetDealStatus returns status given a code - - -Perms: read - -Inputs: -```json -[ - 42 -] -``` - -Response: `"string value"` - -### ClientGetDealUpdates -ClientGetDealUpdates returns the status of updated deals - - -Perms: write - -Inputs: `null` - -Response: -```json -{ - "ProposalCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "State": 42, - "Message": "string value", - "DealStages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "ExpectedDuration": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - }, - "Provider": "f01234", - "DataRef": { - "TransferType": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceCid": null, - "PieceSize": 1024, - "RawBlockSize": 42 - }, - "PieceCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Size": 42, - "PricePerEpoch": "0", - "Duration": 42, - "DealID": 5432, - "CreationTime": "0001-01-01T00:00:00Z", - "Verified": true, - "TransferChannelID": { - "Initiator": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Responder": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "ID": 3 - }, - "DataTransfer": { - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } - } -} -``` - -### ClientGetRetrievalUpdates -ClientGetRetrievalUpdates returns status of updated retrieval deals - - -Perms: write - -Inputs: `null` - -Response: -```json -{ - "PayloadCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ID": 5, - "PieceCID": null, - "PricePerByte": "0", - "UnsealPrice": "0", - "Status": 0, - "Message": "string value", - "Provider": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "BytesReceived": 42, - "BytesPaidFor": 42, - "TotalPaid": "0", - "TransferChannelID": { - "Initiator": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Responder": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "ID": 3 - }, - "DataTransfer": { - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } - }, - "Event": 5 -} -``` - -### ClientHasLocal -ClientHasLocal indicates whether a certain CID is locally stored. - - -Perms: write - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `true` - -### ClientImport -ClientImport imports file under the specified path into filestore. - - -Perms: admin - -Inputs: -```json -[ - { - "Path": "string value", - "IsCAR": true - } -] -``` - -Response: -```json -{ - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ImportID": 50 -} -``` - -### ClientListDataTransfers -ClientListTransfers returns the status of all ongoing transfers of data - - -Perms: write - -Inputs: `null` - -Response: -```json -[ - { - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } - } -] -``` - -### ClientListDeals -ClientListDeals returns information about the deals made by the local client. - - -Perms: write - -Inputs: `null` - -Response: -```json -[ - { - "ProposalCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "State": 42, - "Message": "string value", - "DealStages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "ExpectedDuration": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - }, - "Provider": "f01234", - "DataRef": { - "TransferType": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceCid": null, - "PieceSize": 1024, - "RawBlockSize": 42 - }, - "PieceCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Size": 42, - "PricePerEpoch": "0", - "Duration": 42, - "DealID": 5432, - "CreationTime": "0001-01-01T00:00:00Z", - "Verified": true, - "TransferChannelID": { - "Initiator": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Responder": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "ID": 3 - }, - "DataTransfer": { - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } - } - } -] -``` - -### ClientListImports -ClientListImports lists imported files and their root CIDs - - -Perms: write - -Inputs: `null` - -Response: -```json -[ - { - "Key": 50, - "Err": "string value", - "Root": null, - "Source": "string value", - "FilePath": "string value", - "CARPath": "string value" - } -] -``` - -### ClientListRetrievals -ClientListRetrievals returns information about retrievals made by the local client - - -Perms: write - -Inputs: `null` - -Response: -```json -[ - { - "PayloadCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ID": 5, - "PieceCID": null, - "PricePerByte": "0", - "UnsealPrice": "0", - "Status": 0, - "Message": "string value", - "Provider": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "BytesReceived": 42, - "BytesPaidFor": 42, - "TotalPaid": "0", - "TransferChannelID": { - "Initiator": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Responder": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "ID": 3 - }, - "DataTransfer": { - "TransferID": 3, - "Status": 1, - "BaseCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "IsInitiator": true, - "IsSender": true, - "Voucher": "string value", - "Message": "string value", - "OtherPeer": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Transferred": 42, - "Stages": { - "Stages": [ - { - "Name": "string value", - "Description": "string value", - "CreatedTime": "0001-01-01T00:00:00Z", - "UpdatedTime": "0001-01-01T00:00:00Z", - "Logs": [ - { - "Log": "string value", - "UpdatedTime": "0001-01-01T00:00:00Z" - } - ] - } - ] - } - }, - "Event": 5 - } -] -``` - -### ClientMinerQueryOffer -ClientMinerQueryOffer returns a QueryOffer for the specific miner and file. - - -Perms: read - -Inputs: -```json -[ - "f01234", - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - null -] -``` - -Response: -```json -{ - "Err": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Piece": null, - "Size": 42, - "MinPrice": "0", - "UnsealPrice": "0", - "PricePerByte": "0", - "PaymentInterval": 42, - "PaymentIntervalIncrease": 42, - "Miner": "f01234", - "MinerPeer": { - "Address": "f01234", - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "PieceCID": null - } -} -``` - -### ClientQueryAsk -ClientQueryAsk returns a signed StorageAsk from the specified miner. - - -Perms: read - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "f01234" -] -``` - -Response: -```json -{ - "Response": { - "Price": "0", - "VerifiedPrice": "0", - "MinPieceSize": 1032, - "MaxPieceSize": 1032, - "Miner": "f01234", - "Timestamp": 10101, - "Expiry": 10101, - "SeqNo": 42 - }, - "DealProtocols": [ - "string value" - ] -} -``` - -### ClientRemoveImport -ClientRemoveImport removes file import - - -Perms: admin - -Inputs: -```json -[ - 50 -] -``` - -Response: `{}` - -### ClientRestartDataTransfer -ClientRestartDataTransfer attempts to restart a data transfer with the given transfer ID and other peer - - -Perms: write - -Inputs: -```json -[ - 3, - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - true -] -``` - -Response: `{}` - -### ClientRetrieve -ClientRetrieve initiates the retrieval of a file, as specified in the order. - - -Perms: admin - -Inputs: -```json -[ - { - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Piece": null, - "DataSelector": "Links/21/Hash/Links/42/Hash", - "Size": 42, - "Total": "0", - "UnsealPrice": "0", - "PaymentInterval": 42, - "PaymentIntervalIncrease": 42, - "Client": "f01234", - "Miner": "f01234", - "MinerPeer": { - "Address": "f01234", - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "PieceCID": null - } - } -] -``` - -Response: -```json -{ - "DealID": 5 -} -``` - -### ClientRetrieveTryRestartInsufficientFunds -ClientRetrieveTryRestartInsufficientFunds attempts to restart stalled retrievals on a given payment channel -which are stuck due to insufficient funds - - -Perms: write - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `{}` - -### ClientRetrieveWait -ClientRetrieveWait waits for retrieval to be complete - - -Perms: admin - -Inputs: -```json -[ - 5 -] -``` - -Response: `{}` - -### ClientStartDeal -ClientStartDeal proposes a deal with a miner. - - -Perms: admin - -Inputs: -```json -[ - { - "Data": { - "TransferType": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceCid": null, - "PieceSize": 1024, - "RawBlockSize": 42 - }, - "Wallet": "f01234", - "Miner": "f01234", - "EpochPrice": "0", - "MinBlocksDuration": 42, - "ProviderCollateral": "0", - "DealStartEpoch": 10101, - "FastRetrieval": true, - "VerifiedDeal": true - } -] -``` - -Response: `null` - -### ClientStatelessDeal -ClientStatelessDeal fire-and-forget-proposes an offline deal to a miner without subsequent tracking. - - -Perms: write - -Inputs: -```json -[ - { - "Data": { - "TransferType": "string value", - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceCid": null, - "PieceSize": 1024, - "RawBlockSize": 42 - }, - "Wallet": "f01234", - "Miner": "f01234", - "EpochPrice": "0", - "MinBlocksDuration": 42, - "ProviderCollateral": "0", - "DealStartEpoch": 10101, - "FastRetrieval": true, - "VerifiedDeal": true - } -] -``` - -Response: `null` - -## Create - - -### CreateBackup -CreateBackup creates node backup onder the specified file name. The -method requires that the lotus daemon is running with the -LOTUS_BACKUP_BASE_PATH environment variable set to some path, and that -the path specified when calling CreateBackup is within the base path - - -Perms: admin - -Inputs: -```json -[ - "string value" -] -``` - -Response: `{}` - -## Gas - - -### GasEstimateFeeCap -GasEstimateFeeCap estimates gas fee cap - - -Perms: read - -Inputs: -```json -[ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### GasEstimateGasLimit -GasEstimateGasLimit estimates gas used by the message and returns it. -It fails if message fails to execute. - - -Perms: read - -Inputs: -```json -[ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `9` - -### GasEstimateGasPremium -GasEstimateGasPremium estimates what gas price should be used for a -message to have high likelihood of inclusion in `nblocksincl` epochs. - - -Perms: read - -Inputs: -```json -[ - 42, - "f01234", - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### GasEstimateMessageGas -GasEstimateMessageGas estimates gas values for unset message gas fields - - -Perms: read - -Inputs: -```json -[ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - { - "MaxFee": "0" - }, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } -} -``` - -## I - - -### ID - - -Perms: read - -Inputs: `null` - -Response: `"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"` - -## Log - - -### LogAlerts - - -Perms: admin - -Inputs: `null` - -Response: -```json -[ - { - "Type": { - "System": "string value", - "Subsystem": "string value" - }, - "Active": true, - "LastActive": { - "Type": "string value", - "Message": "json raw message", - "Time": "0001-01-01T00:00:00Z" - }, - "LastResolved": { - "Type": "string value", - "Message": "json raw message", - "Time": "0001-01-01T00:00:00Z" - } - } -] -``` - -### LogList - - -Perms: write - -Inputs: `null` - -Response: -```json -[ - "string value" -] -``` - -### LogSetLevel - - -Perms: write - -Inputs: -```json -[ - "string value", - "string value" -] -``` - -Response: `{}` - -## Market - - -### MarketAddBalance -MarketAddBalance adds funds to the market actor - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "0" -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -### MarketGetReserved -MarketGetReserved gets the amount of funds that are currently reserved for the address - - -Perms: sign - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `"0"` - -### MarketReleaseFunds -MarketReleaseFunds releases funds reserved by MarketReserveFunds - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "0" -] -``` - -Response: `{}` - -### MarketReserveFunds -MarketReserveFunds reserves funds for a deal - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "0" -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -### MarketWithdraw -MarketWithdraw withdraws unlocked funds from the market actor - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "0" -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -## Miner - - -### MinerCreateBlock - - -Perms: write - -Inputs: -```json -[ - { - "Miner": "f01234", - "Parents": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - "Ticket": { - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "Eproof": { - "WinCount": 9, - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "BeaconValues": [ - { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - } - ], - "Messages": [ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ], - "Epoch": 10101, - "Timestamp": 42, - "WinningPoStProof": [ - { - "PoStProof": 8, - "ProofBytes": "Ynl0ZSBhcnJheQ==" - } - ] - } -] -``` - -Response: -```json -{ - "Header": { - "Miner": "f01234", - "Ticket": { - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "ElectionProof": { - "WinCount": 9, - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "BeaconEntries": [ - { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - } - ], - "WinPoStProof": [ - { - "PoStProof": 8, - "ProofBytes": "Ynl0ZSBhcnJheQ==" - } - ], - "Parents": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ], - "ParentWeight": "0", - "Height": 10101, - "ParentStateRoot": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ParentMessageReceipts": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Messages": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "BLSAggregate": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Timestamp": 42, - "BlockSig": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "ForkSignaling": 42, - "ParentBaseFee": "0" - }, - "BlsMessages": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ], - "SecpkMessages": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ] -} -``` - -### MinerGetBaseInfo -There are not yet any comments for this method. - -Perms: read - -Inputs: -```json -[ - "f01234", - 10101, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "MinerPower": "0", - "NetworkPower": "0", - "Sectors": [ - { - "SealProof": 8, - "SectorNumber": 9, - "SectorKey": null, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - } - ], - "WorkerKey": "f01234", - "SectorSize": 34359738368, - "PrevBeaconEntry": { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "BeaconEntries": [ - { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - } - ], - "EligibleForMining": true -} -``` - -## Mpool -The Mpool methods are for interacting with the message pool. The message pool -manages all incoming and outgoing 'messages' going over the network. - - -### MpoolBatchPush -MpoolBatchPush batch pushes a signed message to mempool. - - -Perms: write - -Inputs: -```json -[ - [ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ] -] -``` - -Response: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -### MpoolBatchPushMessage -MpoolBatchPushMessage batch pushes a unsigned message to mempool. - - -Perms: sign - -Inputs: -```json -[ - [ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ], - { - "MaxFee": "0" - } -] -``` - -Response: -```json -[ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -] -``` - -### MpoolBatchPushUntrusted -MpoolBatchPushUntrusted batch pushes a signed message to mempool from untrusted sources. - - -Perms: write - -Inputs: -```json -[ - [ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ] -] -``` - -Response: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -### MpoolCheckMessages -MpoolCheckMessages performs logical checks on a batch of messages - - -Perms: read - -Inputs: -```json -[ - [ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true - } - ] -] -``` - -Response: -```json -[ - [ - { - "Cid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Code": 0, - "OK": true, - "Err": "string value", - "Hint": { - "abc": 123 - } - } - ] -] -``` - -### MpoolCheckPendingMessages -MpoolCheckPendingMessages performs logical checks for all pending messages from a given address - - -Perms: read - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -[ - [ - { - "Cid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Code": 0, - "OK": true, - "Err": "string value", - "Hint": { - "abc": 123 - } - } - ] -] -``` - -### MpoolCheckReplaceMessages -MpoolCheckReplaceMessages performs logical checks on pending messages with replacement - - -Perms: read - -Inputs: -```json -[ - [ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ] -] -``` - -Response: -```json -[ - [ - { - "Cid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Code": 0, - "OK": true, - "Err": "string value", - "Hint": { - "abc": 123 - } - } - ] -] -``` - -### MpoolClear -MpoolClear clears pending messages from the mpool - - -Perms: write - -Inputs: -```json -[ - true -] -``` - -Response: `{}` - -### MpoolGetConfig -MpoolGetConfig returns (a copy of) the current mpool config - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "PriorityAddrs": [ - "f01234" - ], - "SizeLimitHigh": 123, - "SizeLimitLow": 123, - "ReplaceByFeeRatio": 12.3, - "PruneCooldown": 60000000000, - "GasLimitOverestimation": 12.3 -} -``` - -### MpoolGetNonce -MpoolGetNonce gets next nonce for the specified sender. -Note that this method may not be atomic. Use MpoolPushMessage instead. - - -Perms: read - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `42` - -### MpoolPending -MpoolPending returns pending mempool messages. - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -] -``` - -### MpoolPush -MpoolPush pushes a signed message to mempool. - - -Perms: write - -Inputs: -```json -[ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -### MpoolPushMessage -MpoolPushMessage atomically assigns a nonce, signs, and pushes a message -to mempool. -maxFee is only used when GasFeeCap/GasPremium fields aren't specified - -When maxFee is set to 0, MpoolPushMessage will guess appropriate fee -based on current chain conditions - - -Perms: sign - -Inputs: -```json -[ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - { - "MaxFee": "0" - } -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } -} -``` - -### MpoolPushUntrusted -MpoolPushUntrusted pushes a signed message to mempool from untrusted sources. - - -Perms: write - -Inputs: -```json -[ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -### MpoolSelect -MpoolSelect returns a list of pending messages for inclusion in the next block - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - 12.3 -] -``` - -Response: -```json -[ - { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -] -``` - -### MpoolSetConfig -MpoolSetConfig sets the mpool config to (a copy of) the supplied config - - -Perms: admin - -Inputs: -```json -[ - { - "PriorityAddrs": [ - "f01234" - ], - "SizeLimitHigh": 123, - "SizeLimitLow": 123, - "ReplaceByFeeRatio": 12.3, - "PruneCooldown": 60000000000, - "GasLimitOverestimation": 12.3 - } -] -``` - -Response: `{}` - -### MpoolSub - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Type": 0, - "Message": { - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -} -``` - -## Msig -The Msig methods are used to interact with multisig wallets on the -filecoin network - - -### MsigAddApprove -MsigAddApprove approves a previously proposed AddSigner message -It takes the following params: , , , -, , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - 42, - "f01234", - "f01234", - true -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigAddCancel -MsigAddCancel cancels a previously proposed AddSigner message -It takes the following params: , , , -, - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - 42, - "f01234", - true -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigAddPropose -MsigAddPropose proposes adding a signer in the multisig -It takes the following params: , , -, - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "f01234", - true -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigApprove -MsigApprove approves a previously-proposed multisig message by transaction ID -It takes the following params: , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - 42, - "f01234" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigApproveTxnHash -MsigApproveTxnHash approves a previously-proposed multisig message, specified -using both transaction ID and a hash of the parameters used in the -proposal. This method of approval can be used to ensure you only approve -exactly the transaction you think you are. -It takes the following params: , , , , , -, , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - 42, - "f01234", - "f01234", - "0", - "f01234", - 42, - "Ynl0ZSBhcnJheQ==" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigCancel -MsigCancel cancels a previously-proposed multisig message -It takes the following params: , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - 42, - "f01234" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigCancelTxnHash -MsigCancel cancels a previously-proposed multisig message -It takes the following params: , , , , -, , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - 42, - "f01234", - "0", - "f01234", - 42, - "Ynl0ZSBhcnJheQ==" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigCreate -MsigCreate creates a multisig wallet -It takes the following params: , , -, , - - -Perms: sign - -Inputs: -```json -[ - 42, - [ - "f01234" - ], - 10101, - "0", - "f01234", - "0" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigGetAvailableBalance -MsigGetAvailableBalance returns the portion of a multisig's balance that can be withdrawn or spent - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### MsigGetPending -MsigGetPending returns pending transactions for the given multisig -wallet. Once pending transactions are fully approved, they will no longer -appear here. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "ID": 9, - "To": "f01234", - "Value": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "Approved": [ - "f01234" - ] - } -] -``` - -### MsigGetVested -MsigGetVested returns the amount of FIL that vested in a multisig in a certain period. -It takes the following params: , , - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### MsigGetVestingSchedule -MsigGetVestingSchedule returns the vesting details of a given multisig. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "InitialBalance": "0", - "StartEpoch": 10101, - "UnlockDuration": 10101 -} -``` - -### MsigPropose -MsigPropose proposes a multisig message -It takes the following params: , , , -, , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "0", - "f01234", - 42, - "Ynl0ZSBhcnJheQ==" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigRemoveSigner -MsigRemoveSigner proposes the removal of a signer from the multisig. -It accepts the multisig to make the change on, the proposer address to -send the message from, the address to be removed, and a boolean -indicating whether or not the signing threshold should be lowered by one -along with the address removal. - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "f01234", - true -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigSwapApprove -MsigSwapApprove approves a previously proposed SwapSigner -It takes the following params: , , , -, , - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - 42, - "f01234", - "f01234", - "f01234" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigSwapCancel -MsigSwapCancel cancels a previously proposed SwapSigner message -It takes the following params: , , , -, - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - 42, - "f01234", - "f01234" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -### MsigSwapPropose -MsigSwapPropose proposes swapping 2 signers in the multisig -It takes the following params: , , -, - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "f01234", - "f01234" -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "ValidNonce": true -} -``` - -## Net - - -### NetAddrsListen - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Addrs": [ - "/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior" - ] -} -``` - -### NetAgentVersion - - -Perms: read - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -Response: `"string value"` - -### NetAutoNatStatus - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Reachability": 1, - "PublicAddr": "string value" -} -``` - -### NetBandwidthStats - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "TotalIn": 9, - "TotalOut": 9, - "RateIn": 12.3, - "RateOut": 12.3 -} -``` - -### NetBandwidthStatsByPeer - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "12D3KooWSXmXLJmBR1M7i9RW9GQPNUhZSzXKzxDHWtAgNuJAbyEJ": { - "TotalIn": 174000, - "TotalOut": 12500, - "RateIn": 100, - "RateOut": 50 - } -} -``` - -### NetBandwidthStatsByProtocol - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "/fil/hello/1.0.0": { - "TotalIn": 174000, - "TotalOut": 12500, - "RateIn": 100, - "RateOut": 50 - } -} -``` - -### NetBlockAdd - - -Perms: admin - -Inputs: -```json -[ - { - "Peers": [ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" - ], - "IPAddrs": [ - "string value" - ], - "IPSubnets": [ - "string value" - ] - } -] -``` - -Response: `{}` - -### NetBlockList - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Peers": [ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" - ], - "IPAddrs": [ - "string value" - ], - "IPSubnets": [ - "string value" - ] -} -``` - -### NetBlockRemove - - -Perms: admin - -Inputs: -```json -[ - { - "Peers": [ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" - ], - "IPAddrs": [ - "string value" - ], - "IPSubnets": [ - "string value" - ] - } -] -``` - -Response: `{}` - -### NetConnect - - -Perms: write - -Inputs: -```json -[ - { - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Addrs": [ - "/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior" - ] - } -] -``` - -Response: `{}` - -### NetConnectedness - - -Perms: read - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -Response: `1` - -### NetDisconnect - - -Perms: write - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -Response: `{}` - -### NetFindPeer - - -Perms: read - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -Response: -```json -{ - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Addrs": [ - "/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior" - ] -} -``` - -### NetLimit - - -Perms: read - -Inputs: -```json -[ - "string value" -] -``` - -Response: -```json -{ - "Memory": 123, - "Streams": 3, - "StreamsInbound": 1, - "StreamsOutbound": 2, - "Conns": 4, - "ConnsInbound": 3, - "ConnsOutbound": 4, - "FD": 5 -} -``` - -### NetPeerInfo - - -Perms: read - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -Response: -```json -{ - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Agent": "string value", - "Addrs": [ - "string value" - ], - "Protocols": [ - "string value" - ], - "ConnMgrMeta": { - "FirstSeen": "0001-01-01T00:00:00Z", - "Value": 123, - "Tags": { - "name": 42 - }, - "Conns": { - "name": "2021-03-08T22:52:18Z" - } - } -} -``` - -### NetPeers - - -Perms: read - -Inputs: `null` - -Response: -```json -[ - { - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Addrs": [ - "/ip4/52.36.61.156/tcp/1347/p2p/12D3KooWFETiESTf1v4PGUvtnxMAcEFMzLZbJGg4tjWfGEimYior" - ] - } -] -``` - -### NetPing - - -Perms: read - -Inputs: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -Response: `60000000000` - -### NetProtectAdd - - -Perms: admin - -Inputs: -```json -[ - [ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" - ] -] -``` - -Response: `{}` - -### NetProtectList - - -Perms: read - -Inputs: `null` - -Response: -```json -[ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" -] -``` - -### NetProtectRemove - - -Perms: admin - -Inputs: -```json -[ - [ - "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf" - ] -] -``` - -Response: `{}` - -### NetPubsubScores - - -Perms: read - -Inputs: `null` - -Response: -```json -[ - { - "ID": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Score": { - "Score": 12.3, - "Topics": { - "/blocks": { - "TimeInMesh": 60000000000, - "FirstMessageDeliveries": 122, - "MeshMessageDeliveries": 1234, - "InvalidMessageDeliveries": 3 - } - }, - "AppSpecificScore": 12.3, - "IPColocationFactor": 12.3, - "BehaviourPenalty": 12.3 - } - } -] -``` - -### NetSetLimit - - -Perms: admin - -Inputs: -```json -[ - "string value", - { - "Memory": 123, - "Streams": 3, - "StreamsInbound": 1, - "StreamsOutbound": 2, - "Conns": 4, - "ConnsInbound": 3, - "ConnsOutbound": 4, - "FD": 5 - } -] -``` - -Response: `{}` - -### NetStat - - -Perms: read - -Inputs: -```json -[ - "string value" -] -``` - -Response: -```json -{ - "System": { - "NumStreamsInbound": 123, - "NumStreamsOutbound": 123, - "NumConnsInbound": 123, - "NumConnsOutbound": 123, - "NumFD": 123, - "Memory": 9 - }, - "Transient": { - "NumStreamsInbound": 123, - "NumStreamsOutbound": 123, - "NumConnsInbound": 123, - "NumConnsOutbound": 123, - "NumFD": 123, - "Memory": 9 - }, - "Services": { - "abc": { - "NumStreamsInbound": 1, - "NumStreamsOutbound": 2, - "NumConnsInbound": 3, - "NumConnsOutbound": 4, - "NumFD": 5, - "Memory": 123 - } - }, - "Protocols": { - "abc": { - "NumStreamsInbound": 1, - "NumStreamsOutbound": 2, - "NumConnsInbound": 3, - "NumConnsOutbound": 4, - "NumFD": 5, - "Memory": 123 - } - }, - "Peers": { - "abc": { - "NumStreamsInbound": 1, - "NumStreamsOutbound": 2, - "NumConnsInbound": 3, - "NumConnsOutbound": 4, - "NumFD": 5, - "Memory": 123 - } - } -} -``` - -## Node -These methods are general node management and status commands - - -### NodeStatus -There are not yet any comments for this method. - -Perms: read - -Inputs: -```json -[ - true -] -``` - -Response: -```json -{ - "SyncStatus": { - "Epoch": 42, - "Behind": 42 - }, - "PeerStatus": { - "PeersToPublishMsgs": 123, - "PeersToPublishBlocks": 123 - }, - "ChainStatus": { - "BlocksPerTipsetLast100": 12.3, - "BlocksPerTipsetLastFinality": 12.3 - } -} -``` - -## Paych -The Paych methods are for interacting with and managing payment channels - - -### PaychAllocateLane - - -Perms: sign - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `42` - -### PaychAvailableFunds - - -Perms: sign - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -{ - "Channel": "\u003cempty\u003e", - "From": "f01234", - "To": "f01234", - "ConfirmedAmt": "0", - "PendingAmt": "0", - "NonReservedAmt": "0", - "PendingAvailableAmt": "0", - "PendingWaitSentinel": null, - "QueuedAmt": "0", - "VoucherReedeemedAmt": "0" -} -``` - -### PaychAvailableFundsByFromTo - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234" -] -``` - -Response: -```json -{ - "Channel": "\u003cempty\u003e", - "From": "f01234", - "To": "f01234", - "ConfirmedAmt": "0", - "PendingAmt": "0", - "NonReservedAmt": "0", - "PendingAvailableAmt": "0", - "PendingWaitSentinel": null, - "QueuedAmt": "0", - "VoucherReedeemedAmt": "0" -} -``` - -### PaychCollect - - -Perms: sign - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -### PaychFund -PaychFund gets or creates a payment channel between address pair. -The specified amount will be added to the channel through on-chain send for future use - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "0" -] -``` - -Response: -```json -{ - "Channel": "f01234", - "WaitSentinel": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -} -``` - -### PaychGet -PaychGet gets or creates a payment channel between address pair - The specified amount will be reserved for use. If there aren't enough non-reserved funds - available, funds will be added through an on-chain message. - - When opts.OffChain is true, this call will not cause any messages to be sent to the chain (no automatic - channel creation/funds adding). If the operation can't be performed without sending a message an error will be - returned. Note that even when this option is specified, this call can be blocked by previous operations on the - channel waiting for on-chain operations. - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - "0", - { - "OffChain": true - } -] -``` - -Response: -```json -{ - "Channel": "f01234", - "WaitSentinel": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -} -``` - -### PaychGetWaitReady - - -Perms: sign - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `"f01234"` - -### PaychList - - -Perms: read - -Inputs: `null` - -Response: -```json -[ - "f01234" -] -``` - -### PaychNewPayment - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "f01234", - [ - { - "Amount": "0", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "MinSettle": 10101, - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - } - } - ] -] -``` - -Response: -```json -{ - "Channel": "f01234", - "WaitSentinel": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Vouchers": [ - { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - } - ] -} -``` - -### PaychSettle - - -Perms: sign - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -### PaychStatus - - -Perms: read - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -{ - "ControlAddr": "f01234", - "Direction": 1 -} -``` - -### PaychVoucherAdd - - -Perms: write - -Inputs: -```json -[ - "f01234", - { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - }, - "Ynl0ZSBhcnJheQ==", - "0" -] -``` - -Response: `"0"` - -### PaychVoucherCheckSpendable - - -Perms: read - -Inputs: -```json -[ - "f01234", - { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - }, - "Ynl0ZSBhcnJheQ==", - "Ynl0ZSBhcnJheQ==" -] -``` - -Response: `true` - -### PaychVoucherCheckValid - - -Perms: read - -Inputs: -```json -[ - "f01234", - { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - } -] -``` - -Response: `{}` - -### PaychVoucherCreate - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "0", - 42 -] -``` - -Response: -```json -{ - "Voucher": { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - }, - "Shortfall": "0" -} -``` - -### PaychVoucherList - - -Perms: write - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -[ - { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - } -] -``` - -### PaychVoucherSubmit - - -Perms: sign - -Inputs: -```json -[ - "f01234", - { - "ChannelAddr": "f01234", - "TimeLockMin": 10101, - "TimeLockMax": 10101, - "SecretPreimage": "Ynl0ZSBhcnJheQ==", - "Extra": { - "Actor": "f01234", - "Method": 1, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Lane": 42, - "Nonce": 42, - "Amount": "0", - "MinSettleHeight": 10101, - "Merges": [ - { - "Lane": 42, - "Nonce": 42 - } - ], - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } - }, - "Ynl0ZSBhcnJheQ==", - "Ynl0ZSBhcnJheQ==" -] -``` - -Response: -```json -{ - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" -} -``` - -## State -The State methods are used to query, inspect, and interact with chain state. -Most methods take a TipSetKey as a parameter. The state looked up is the parent state of the tipset. -A nil TipSetKey can be provided as a param, this will cause the heaviest tipset in the chain to be used. - - -### StateAccountKey -StateAccountKey returns the public key address of the given ID address for secp and bls accounts - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"f01234"` - -### StateAllMinerFaults -StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset - - -Perms: read - -Inputs: -```json -[ - 10101, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "Miner": "f01234", - "Epoch": 10101 - } -] -``` - -### StateCall -StateCall runs the given message and returns its result without any persisted changes. - -StateCall applies the message to the tipset's parent state. The -message is not applied on-top-of the messages in the passed-in -tipset. - - -Perms: read - -Inputs: -```json -[ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "MsgCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "GasCost": { - "Message": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "GasUsed": "0", - "BaseFeeBurn": "0", - "OverEstimationBurn": "0", - "MinerPenalty": "0", - "MinerTip": "0", - "Refund": "0", - "TotalCost": "0" - }, - "ExecutionTrace": { - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "Error": "string value", - "Duration": 60000000000, - "GasCharges": [ - { - "Name": "string value", - "loc": [ - { - "File": "string value", - "Line": 123, - "Function": "string value" - } - ], - "tg": 9, - "cg": 9, - "sg": 9, - "vtg": 9, - "vcg": 9, - "vsg": 9, - "tt": 60000000000, - "ex": {} - } - ], - "Subcalls": [ - { - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "Error": "string value", - "Duration": 60000000000, - "GasCharges": [ - { - "Name": "string value", - "loc": [ - { - "File": "string value", - "Line": 123, - "Function": "string value" - } - ], - "tg": 9, - "cg": 9, - "sg": 9, - "vtg": 9, - "vcg": 9, - "vsg": 9, - "tt": 60000000000, - "ex": {} - } - ], - "Subcalls": null - } - ] - }, - "Error": "string value", - "Duration": 60000000000 -} -``` - -### StateChangedActors -StateChangedActors returns all the actors whose states change between the two given state CIDs -TODO: Should this take tipset keys instead? - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "t01236": { - "Code": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Head": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Nonce": 42, - "Balance": "0" - } -} -``` - -### StateCirculatingSupply -StateCirculatingSupply returns the exact circulating supply of Filecoin at the given tipset. -This is not used anywhere in the protocol itself, and is only for external consumption. - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### StateCompute -StateCompute is a flexible command that applies the given messages on the given tipset. -The messages are run as though the VM were at the provided height. - -When called, StateCompute will: -- Load the provided tipset, or use the current chain head if not provided -- Compute the tipset state of the provided tipset on top of the parent state - - (note that this step runs before vmheight is applied to the execution) - - Execute state upgrade if any were scheduled at the epoch, or in null - blocks preceding the tipset - - Call the cron actor on null blocks preceding the tipset - - For each block in the tipset - - Apply messages in blocks in the specified - - Award block reward by calling the reward actor - - Call the cron actor for the current epoch -- If the specified vmheight is higher than the current epoch, apply any - needed state upgrades to the state -- Apply the specified messages to the state - -The vmheight parameter sets VM execution epoch, and can be used to simulate -message execution in different network versions. If the specified vmheight -epoch is higher than the epoch of the specified tipset, any state upgrades -until the vmheight will be executed on the state before applying messages -specified by the user. - -Note that the initial tipset state computation is not affected by the -vmheight parameter - only the messages in the `apply` set are - -If the caller wants to simply compute the state, vmheight should be set to -the epoch of the specified tipset. - -Messages in the `apply` parameter must have the correct nonces, and gas -values set. - - -Perms: read - -Inputs: -```json -[ - 10101, - [ - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } - ], - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Root": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Trace": [ - { - "MsgCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "GasCost": { - "Message": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "GasUsed": "0", - "BaseFeeBurn": "0", - "OverEstimationBurn": "0", - "MinerPenalty": "0", - "MinerTip": "0", - "Refund": "0", - "TotalCost": "0" - }, - "ExecutionTrace": { - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "Error": "string value", - "Duration": 60000000000, - "GasCharges": [ - { - "Name": "string value", - "loc": [ - { - "File": "string value", - "Line": 123, - "Function": "string value" - } - ], - "tg": 9, - "cg": 9, - "sg": 9, - "vtg": 9, - "vcg": 9, - "vsg": 9, - "tt": 60000000000, - "ex": {} - } - ], - "Subcalls": [ - { - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "Error": "string value", - "Duration": 60000000000, - "GasCharges": [ - { - "Name": "string value", - "loc": [ - { - "File": "string value", - "Line": 123, - "Function": "string value" - } - ], - "tg": 9, - "cg": 9, - "sg": 9, - "vtg": 9, - "vcg": 9, - "vsg": 9, - "tt": 60000000000, - "ex": {} - } - ], - "Subcalls": null - } - ] - }, - "Error": "string value", - "Duration": 60000000000 - } - ] -} -``` - -### StateDealProviderCollateralBounds -StateDealProviderCollateralBounds returns the min and max collateral a storage provider -can issue. It takes the deal size and verified status as parameters. - - -Perms: read - -Inputs: -```json -[ - 1032, - true, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Min": "0", - "Max": "0" -} -``` - -### StateDecodeParams -StateDecodeParams attempts to decode the provided params, based on the recipient actor address and method number. - - -Perms: read - -Inputs: -```json -[ - "f01234", - 1, - "Ynl0ZSBhcnJheQ==", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `{}` - -### StateEncodeParams -StateEncodeParams attempts to encode the provided json params to the binary from - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - 1, - "json raw message" -] -``` - -Response: `"Ynl0ZSBhcnJheQ=="` - -### StateGetActor -StateGetActor returns the indicated actor's nonce and balance. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Code": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Head": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Nonce": 42, - "Balance": "0" -} -``` - -### StateGetNetworkParams -StateGetNetworkParams return current network params - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "NetworkName": "lotus", - "BlockDelaySecs": 42, - "ConsensusMinerMinPower": "0", - "SupportedProofTypes": [ - 8 - ], - "PreCommitChallengeDelay": 10101, - "ForkUpgradeParams": { - "UpgradeSmokeHeight": 10101, - "UpgradeBreezeHeight": 10101, - "UpgradeIgnitionHeight": 10101, - "UpgradeLiftoffHeight": 10101, - "UpgradeAssemblyHeight": 10101, - "UpgradeRefuelHeight": 10101, - "UpgradeTapeHeight": 10101, - "UpgradeKumquatHeight": 10101, - "UpgradePriceListOopsHeight": 10101, - "BreezeGasTampingDuration": 10101, - "UpgradeCalicoHeight": 10101, - "UpgradePersianHeight": 10101, - "UpgradeOrangeHeight": 10101, - "UpgradeClausHeight": 10101, - "UpgradeTrustHeight": 10101, - "UpgradeNorwegianHeight": 10101, - "UpgradeTurboHeight": 10101, - "UpgradeHyperdriveHeight": 10101, - "UpgradeChocolateHeight": 10101, - "UpgradeOhSnapHeight": 10101 - } -} -``` - -### StateGetRandomnessFromBeacon -StateGetRandomnessFromBeacon is used to sample the beacon for randomness. - - -Perms: read - -Inputs: -```json -[ - 2, - 10101, - "Ynl0ZSBhcnJheQ==", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"Bw=="` - -### StateGetRandomnessFromTickets -StateGetRandomnessFromTickets is used to sample the chain for randomness. - - -Perms: read - -Inputs: -```json -[ - 2, - 10101, - "Ynl0ZSBhcnJheQ==", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"Bw=="` - -### StateListActors -StateListActors returns the addresses of every actor in the state - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - "f01234" -] -``` - -### StateListMessages -StateListMessages looks back and returns all messages with a matching to or from address, stopping at the given height. - - -Perms: read - -Inputs: -```json -[ - { - "To": "f01234", - "From": "f01234" - }, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - 10101 -] -``` - -Response: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -### StateListMiners -StateListMiners returns the addresses of every miner that has claimed power in the Power Actor - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - "f01234" -] -``` - -### StateLookupID -StateLookupID retrieves the ID address of the given address - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"f01234"` - -### StateLookupRobustAddress -StateLookupRobustAddress returns the public key address of the given ID address for non-account addresses (multisig, miners etc) - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"f01234"` - -### StateMarketBalance -StateMarketBalance looks up the Escrow and Locked balances of the given address in the Storage Market - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Escrow": "0", - "Locked": "0" -} -``` - -### StateMarketDeals -StateMarketDeals returns information about every deal in the Storage Market - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "t026363": { - "Proposal": { - "PieceCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceSize": 1032, - "VerifiedDeal": true, - "Client": "f01234", - "Provider": "f01234", - "Label": "string value", - "StartEpoch": 10101, - "EndEpoch": 10101, - "StoragePricePerEpoch": "0", - "ProviderCollateral": "0", - "ClientCollateral": "0" - }, - "State": { - "SectorStartEpoch": 10101, - "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101 - } - } -} -``` - -### StateMarketParticipants -StateMarketParticipants returns the Escrow and Locked balances of every participant in the Storage Market - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "t026363": { - "Escrow": "0", - "Locked": "0" - } -} -``` - -### StateMarketStorageDeal -StateMarketStorageDeal returns information about the indicated deal - - -Perms: read - -Inputs: -```json -[ - 5432, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Proposal": { - "PieceCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "PieceSize": 1032, - "VerifiedDeal": true, - "Client": "f01234", - "Provider": "f01234", - "Label": "string value", - "StartEpoch": 10101, - "EndEpoch": 10101, - "StoragePricePerEpoch": "0", - "ProviderCollateral": "0", - "ClientCollateral": "0" - }, - "State": { - "SectorStartEpoch": 10101, - "LastUpdatedEpoch": 10101, - "SlashEpoch": 10101 - } -} -``` - -### StateMinerActiveSectors -StateMinerActiveSectors returns info about sectors that a given miner is actively proving. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "SectorNumber": 9, - "SealProof": 8, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "DealIDs": [ - 5432 - ], - "Activation": 10101, - "Expiration": 10101, - "DealWeight": "0", - "VerifiedDealWeight": "0", - "InitialPledge": "0", - "ExpectedDayReward": "0", - "ExpectedStoragePledge": "0", - "SectorKeyCID": null - } -] -``` - -### StateMinerAvailableBalance -StateMinerAvailableBalance returns the portion of a miner's balance that can be withdrawn or spent - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### StateMinerDeadlines -StateMinerDeadlines returns all the proving deadlines for the given miner - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "PostSubmissions": [ - 5, - 1 - ], - "DisputableProofCount": 42 - } -] -``` - -### StateMinerFaults -StateMinerFaults returns a bitfield indicating the faulty sectors of the given miner - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - 5, - 1 -] -``` - -### StateMinerInfo -StateMinerInfo returns info about the indicated miner - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Owner": "f01234", - "Worker": "f01234", - "NewWorker": "f01234", - "ControlAddresses": [ - "f01234" - ], - "WorkerChangeEpoch": 10101, - "PeerId": "12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf", - "Multiaddrs": [ - "Ynl0ZSBhcnJheQ==" - ], - "WindowPoStProofType": 8, - "SectorSize": 34359738368, - "WindowPoStPartitionSectors": 42, - "ConsensusFaultElapsed": 10101 -} -``` - -### StateMinerInitialPledgeCollateral -StateMinerInitialPledgeCollateral returns the initial pledge collateral for the specified miner's sector - - -Perms: read - -Inputs: -```json -[ - "f01234", - { - "SealProof": 8, - "SectorNumber": 9, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "SealRandEpoch": 10101, - "DealIDs": [ - 5432 - ], - "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 - }, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### StateMinerPartitions -StateMinerPartitions returns all partitions in the specified deadline - - -Perms: read - -Inputs: -```json -[ - "f01234", - 42, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "AllSectors": [ - 5, - 1 - ], - "FaultySectors": [ - 5, - 1 - ], - "RecoveringSectors": [ - 5, - 1 - ], - "LiveSectors": [ - 5, - 1 - ], - "ActiveSectors": [ - 5, - 1 - ] - } -] -``` - -### StateMinerPower -StateMinerPower returns the power of the indicated miner - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "MinerPower": { - "RawBytePower": "0", - "QualityAdjPower": "0" - }, - "TotalPower": { - "RawBytePower": "0", - "QualityAdjPower": "0" - }, - "HasMinPower": true -} -``` - -### StateMinerPreCommitDepositForPower -StateMinerInitialPledgeCollateral returns the precommit deposit for the specified miner's sector - - -Perms: read - -Inputs: -```json -[ - "f01234", - { - "SealProof": 8, - "SectorNumber": 9, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "SealRandEpoch": 10101, - "DealIDs": [ - 5432 - ], - "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 - }, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### StateMinerProvingDeadline -StateMinerProvingDeadline calculates the deadline at some epoch for a proving period -and returns the deadline-related calculations. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "CurrentEpoch": 10101, - "PeriodStart": 10101, - "Index": 42, - "Open": 10101, - "Close": 10101, - "Challenge": 10101, - "FaultCutoff": 10101, - "WPoStPeriodDeadlines": 42, - "WPoStProvingPeriod": 10101, - "WPoStChallengeWindow": 10101, - "WPoStChallengeLookback": 10101, - "FaultDeclarationCutoff": 10101 -} -``` - -### StateMinerRecoveries -StateMinerRecoveries returns a bitfield indicating the recovering sectors of the given miner - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - 5, - 1 -] -``` - -### StateMinerSectorAllocated -StateMinerSectorAllocated checks if a sector is allocated - - -Perms: read - -Inputs: -```json -[ - "f01234", - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `true` - -### StateMinerSectorCount -StateMinerSectorCount returns the number of sectors in a miner's sector set and proving set - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Live": 42, - "Active": 42, - "Faulty": 42 -} -``` - -### StateMinerSectors -StateMinerSectors returns info about the given miner's sectors. If the filter bitfield is nil, all sectors are included. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - 0 - ], - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -[ - { - "SectorNumber": 9, - "SealProof": 8, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "DealIDs": [ - 5432 - ], - "Activation": 10101, - "Expiration": 10101, - "DealWeight": "0", - "VerifiedDealWeight": "0", - "InitialPledge": "0", - "ExpectedDayReward": "0", - "ExpectedStoragePledge": "0", - "SectorKeyCID": null - } -] -``` - -### StateNetworkName -StateNetworkName returns the name of the network the node is synced to - - -Perms: read - -Inputs: `null` - -Response: `"lotus"` - -### StateNetworkVersion -StateNetworkVersion returns the network version at the given tipset - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `15` - -### StateReadState -StateReadState returns the indicated actor's state. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Balance": "0", - "Code": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "State": {} -} -``` - -### StateReplay -StateReplay replays a given message, assuming it was included in a block in the specified tipset. - -If a tipset key is provided, and a replacing message is found on chain, -the method will return an error saying that the message wasn't found - -If no tipset key is provided, the appropriate tipset is looked up, and if -the message was gas-repriced, the on-chain message will be replayed - in -that case the returned InvocResult.MsgCid will not match the Cid param - -If the caller wants to ensure that exactly the requested message was executed, -they MUST check that InvocResult.MsgCid is equal to the provided Cid. -Without this check both the requested and original message may appear as -successfully executed on-chain, which may look like a double-spend. - -A replacing message is a message with a different CID, any of Gas values, and -different signature, but with all other parameters matching (source/destination, -nonce, params, etc.) - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: -```json -{ - "MsgCid": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "GasCost": { - "Message": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "GasUsed": "0", - "BaseFeeBurn": "0", - "OverEstimationBurn": "0", - "MinerPenalty": "0", - "MinerTip": "0", - "Refund": "0", - "TotalCost": "0" - }, - "ExecutionTrace": { - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "Error": "string value", - "Duration": 60000000000, - "GasCharges": [ - { - "Name": "string value", - "loc": [ - { - "File": "string value", - "Line": 123, - "Function": "string value" - } - ], - "tg": 9, - "cg": 9, - "sg": 9, - "vtg": 9, - "vcg": 9, - "vsg": 9, - "tt": 60000000000, - "ex": {} - } - ], - "Subcalls": [ - { - "Msg": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "MsgRct": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "Error": "string value", - "Duration": 60000000000, - "GasCharges": [ - { - "Name": "string value", - "loc": [ - { - "File": "string value", - "Line": 123, - "Function": "string value" - } - ], - "tg": 9, - "cg": 9, - "sg": 9, - "vtg": 9, - "vcg": 9, - "vsg": 9, - "tt": 60000000000, - "ex": {} - } - ], - "Subcalls": null - } - ] - }, - "Error": "string value", - "Duration": 60000000000 -} -``` - -### StateSearchMsg -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 -a MsgLookup for the replacing message - the MsgLookup.Message will be a different -CID than the one provided in the 'cid' param, MsgLookup.Receipt will contain the -result of the execution of the replacing message. - -If the caller wants to ensure that exactly the requested message was executed, -they must check that MsgLookup.Message is equal to the provided 'cid', or set the -`allowReplaced` parameter to false. Without this check, and with `allowReplaced` -set to true, both the requested and original message may appear as -successfully executed on-chain, which may look like a double-spend. - -A replacing message is a message with a different CID, any of Gas values, and -different signature, but with all other parameters matching (source/destination, -nonce, params, etc.) - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - 10101, - true -] -``` - -Response: -```json -{ - "Message": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Receipt": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "ReturnDec": {}, - "TipSet": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - "Height": 10101 -} -``` - -### StateSectorExpiration -StateSectorExpiration returns epoch at which given sector will expire - - -Perms: read - -Inputs: -```json -[ - "f01234", - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "OnTime": 10101, - "Early": 10101 -} -``` - -### StateSectorGetInfo -StateSectorGetInfo returns the on-chain info for the specified miner's sector. Returns null in case the sector info isn't found -NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate -expiration epoch - - -Perms: read - -Inputs: -```json -[ - "f01234", - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "SectorNumber": 9, - "SealProof": 8, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "DealIDs": [ - 5432 - ], - "Activation": 10101, - "Expiration": 10101, - "DealWeight": "0", - "VerifiedDealWeight": "0", - "InitialPledge": "0", - "ExpectedDayReward": "0", - "ExpectedStoragePledge": "0", - "SectorKeyCID": null -} -``` - -### StateSectorPartition -StateSectorPartition finds deadline/partition with the specified sector - - -Perms: read - -Inputs: -```json -[ - "f01234", - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Deadline": 42, - "Partition": 42 -} -``` - -### StateSectorPreCommitInfo -StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector - - -Perms: read - -Inputs: -```json -[ - "f01234", - 9, - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "Info": { - "SealProof": 8, - "SectorNumber": 9, - "SealedCID": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "SealRandEpoch": 10101, - "DealIDs": [ - 5432 - ], - "Expiration": 10101, - "ReplaceCapacity": true, - "ReplaceSectorDeadline": 42, - "ReplaceSectorPartition": 42, - "ReplaceSectorNumber": 9 - }, - "PreCommitDeposit": "0", - "PreCommitEpoch": 10101, - "DealWeight": "0", - "VerifiedDealWeight": "0" -} -``` - -### StateVMCirculatingSupplyInternal -StateVMCirculatingSupplyInternal returns an approximation of the circulating supply of Filecoin at the given tipset. -This is the value reported by the runtime interface to actors code. - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: -```json -{ - "FilVested": "0", - "FilMined": "0", - "FilBurnt": "0", - "FilLocked": "0", - "FilCirculating": "0", - "FilReserveDisbursed": "0" -} -``` - -### StateVerifiedClientStatus -StateVerifiedClientStatus returns the data cap for the given address. -Returns nil if there is no entry in the data cap table for the -address. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### StateVerifiedRegistryRootKey -StateVerifiedClientStatus returns the address of the Verified Registry's root key - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"f01234"` - -### StateVerifierStatus -StateVerifierStatus returns the data cap for the given address. -Returns nil if there is no entry in the data cap table for the -address. - - -Perms: read - -Inputs: -```json -[ - "f01234", - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `"0"` - -### StateWaitMsg -StateWaitMsg looks back up to limit epochs in the chain for a message. -If not found, it blocks until the message arrives on chain, and gets to the -indicated confidence depth. - -NOTE: If a replacing message is found on chain, this method will return -a MsgLookup for the replacing message - the MsgLookup.Message will be a different -CID than the one provided in the 'cid' param, MsgLookup.Receipt will contain the -result of the execution of the replacing message. - -If the caller wants to ensure that exactly the requested message was executed, -they must check that MsgLookup.Message is equal to the provided 'cid', or set the -`allowReplaced` parameter to false. Without this check, and with `allowReplaced` -set to true, both the requested and original message may appear as -successfully executed on-chain, which may look like a double-spend. - -A replacing message is a message with a different CID, any of Gas values, and -different signature, but with all other parameters matching (source/destination, -nonce, params, etc.) - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - 42, - 10101, - true -] -``` - -Response: -```json -{ - "Message": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Receipt": { - "ExitCode": 0, - "Return": "Ynl0ZSBhcnJheQ==", - "GasUsed": 9 - }, - "ReturnDec": {}, - "TipSet": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ], - "Height": 10101 -} -``` - -## Sync -The Sync method group contains methods for interacting with and -observing the lotus sync service. - - -### SyncCheckBad -SyncCheckBad checks if a block was marked as bad, and if it was, returns -the reason. - - -Perms: read - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `"string value"` - -### SyncCheckpoint -SyncCheckpoint marks a blocks as checkpointed, meaning that it won't ever fork away from it. - - -Perms: admin - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `{}` - -### SyncIncomingBlocks -SyncIncomingBlocks returns a channel streaming incoming, potentially not -yet synced block headers. - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "Miner": "f01234", - "Ticket": { - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "ElectionProof": { - "WinCount": 9, - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "BeaconEntries": [ - { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - } - ], - "WinPoStProof": [ - { - "PoStProof": 8, - "ProofBytes": "Ynl0ZSBhcnJheQ==" - } - ], - "Parents": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ], - "ParentWeight": "0", - "Height": 10101, - "ParentStateRoot": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ParentMessageReceipts": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Messages": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "BLSAggregate": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Timestamp": 42, - "BlockSig": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "ForkSignaling": 42, - "ParentBaseFee": "0" -} -``` - -### SyncMarkBad -SyncMarkBad marks a blocks as bad, meaning that it won't ever by synced. -Use with extreme caution. - - -Perms: admin - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `{}` - -### SyncState -SyncState returns the current status of the lotus sync system. - - -Perms: read - -Inputs: `null` - -Response: -```json -{ - "ActiveSyncs": [ - { - "WorkerID": 42, - "Base": { - "Cids": null, - "Blocks": null, - "Height": 0 - }, - "Target": { - "Cids": null, - "Blocks": null, - "Height": 0 - }, - "Stage": 1, - "Height": 10101, - "Start": "0001-01-01T00:00:00Z", - "End": "0001-01-01T00:00:00Z", - "Message": "string value" - } - ], - "VMApplied": 42 -} -``` - -### SyncSubmitBlock -SyncSubmitBlock can be used to submit a newly created block to the. -network through this node - - -Perms: write - -Inputs: -```json -[ - { - "Header": { - "Miner": "f01234", - "Ticket": { - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "ElectionProof": { - "WinCount": 9, - "VRFProof": "Ynl0ZSBhcnJheQ==" - }, - "BeaconEntries": [ - { - "Round": 42, - "Data": "Ynl0ZSBhcnJheQ==" - } - ], - "WinPoStProof": [ - { - "PoStProof": 8, - "ProofBytes": "Ynl0ZSBhcnJheQ==" - } - ], - "Parents": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ], - "ParentWeight": "0", - "Height": 10101, - "ParentStateRoot": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "ParentMessageReceipts": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "Messages": { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - "BLSAggregate": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "Timestamp": 42, - "BlockSig": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "ForkSignaling": 42, - "ParentBaseFee": "0" - }, - "BlsMessages": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ], - "SecpkMessages": [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } - ] - } -] -``` - -Response: `{}` - -### SyncUnmarkAllBad -SyncUnmarkAllBad purges bad block cache, making it possible to sync to chains previously marked as bad - - -Perms: admin - -Inputs: `null` - -Response: `{}` - -### SyncUnmarkBad -SyncUnmarkBad unmarks a blocks as bad, making it possible to be validated and synced again. - - -Perms: admin - -Inputs: -```json -[ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - } -] -``` - -Response: `{}` - -### SyncValidateTipset -SyncValidateTipset indicates whether the provided tipset is valid or not - - -Perms: read - -Inputs: -```json -[ - [ - { - "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" - }, - { - "/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve" - } - ] -] -``` - -Response: `true` - -## Wallet - - -### WalletBalance -WalletBalance returns the balance of the given address at the current head of the chain. - - -Perms: read - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `"0"` - -### WalletDefaultAddress -WalletDefaultAddress returns the address marked as default in the wallet. - - -Perms: write - -Inputs: `null` - -Response: `"f01234"` - -### WalletDelete -WalletDelete deletes an address from the wallet. - - -Perms: admin - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `{}` - -### WalletExport -WalletExport returns the private key of an address in the wallet. - - -Perms: admin - -Inputs: -```json -[ - "f01234" -] -``` - -Response: -```json -{ - "Type": "bls", - "PrivateKey": "Ynl0ZSBhcnJheQ==" -} -``` - -### WalletHas -WalletHas indicates whether the given address is in the wallet. - - -Perms: write - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `true` - -### WalletImport -WalletImport receives a KeyInfo, which includes a private key, and imports it into the wallet. - - -Perms: admin - -Inputs: -```json -[ - { - "Type": "bls", - "PrivateKey": "Ynl0ZSBhcnJheQ==" - } -] -``` - -Response: `"f01234"` - -### WalletList -WalletList lists all the addresses in the wallet. - - -Perms: write - -Inputs: `null` - -Response: -```json -[ - "f01234" -] -``` - -### WalletNew -WalletNew creates a new address in the wallet with the given sigType. -Available key types: bls, secp256k1, secp256k1-ledger -Support for numerical types: 1 - secp256k1, 2 - BLS is deprecated - - -Perms: write - -Inputs: -```json -[ - "bls" -] -``` - -Response: `"f01234"` - -### WalletSetDefault -WalletSetDefault marks the given address as as the default one. - - -Perms: write - -Inputs: -```json -[ - "f01234" -] -``` - -Response: `{}` - -### WalletSign -WalletSign signs the given bytes using the given address. - - -Perms: sign - -Inputs: -```json -[ - "f01234", - "Ynl0ZSBhcnJheQ==" -] -``` - -Response: -```json -{ - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" -} -``` - -### WalletSignMessage -WalletSignMessage signs the given message using the given address. - - -Perms: sign - -Inputs: -```json -[ - "f01234", - { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - } -] -``` - -Response: -```json -{ - "Message": { - "Version": 42, - "To": "f01234", - "From": "f01234", - "Nonce": 42, - "Value": "0", - "GasLimit": 9, - "GasFeeCap": "0", - "GasPremium": "0", - "Method": 1, - "Params": "Ynl0ZSBhcnJheQ==", - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } - }, - "Signature": { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - }, - "CID": { - "/": "bafy2bzacebbpdegvr3i4cosewthysg5xkxpqfn2wfcz6mv2hmoktwbdxkax4s" - } -} -``` - -### WalletValidateAddress -WalletValidateAddress validates whether a given string can be decoded as a well-formed address - - -Perms: read - -Inputs: -```json -[ - "string value" -] -``` - -Response: `"f01234"` - -### WalletVerify -WalletVerify takes an address, a signature, and some bytes, and indicates whether the signature is valid. -The address does not have to be in the wallet. - - -Perms: read - -Inputs: -```json -[ - "f01234", - "Ynl0ZSBhcnJheQ==", - { - "Type": 2, - "Data": "Ynl0ZSBhcnJheQ==" - } -] -``` - -Response: `true` - diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 4122026f8..0b7f56e1e 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.16.0-dev COMMANDS: init Initialize a lotus miner repo @@ -47,7 +47,6 @@ GLOBAL OPTIONS: --miner-repo value, --storagerepo value Specify miner repo path. flag(storagerepo) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON (default: "~/.lotusminer") [$LOTUS_MINER_PATH, $LOTUS_STORAGE_PATH] --markets-repo value Markets repo path [$LOTUS_MARKETS_PATH] --call-on-markets (experimental; may be removed) call this command against a markets node; use only with common commands like net, auth, pprof, etc. whose target may be ambiguous (default: false) - --vv enables very verbose mode, useful for debugging the CLI (default: false) --help, -h show help (default: false) --version, -v print the version (default: false) ``` diff --git a/documentation/en/cli-lotus-worker.md b/documentation/en/cli-lotus-worker.md index c99417d42..33561850f 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.16.0-dev COMMANDS: run Start lotus worker diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index d1f798f5f..12d3e9dda 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.16.0-dev COMMANDS: daemon Start a lotus daemon process diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index cd52de8db..d826fbf36 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit cd52de8dbcf117109c8d6f02c17e855ccdc0497c +Subproject commit d826fbf3643979221dac05eeeb55b12740dc42c5 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..411e37385 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,14 +27,11 @@ 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" "github.com/filecoin-project/lotus/extern/sector-storage/partialfile" "github.com/filecoin-project/lotus/extern/sector-storage/storiface" - nr "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" - "github.com/filecoin-project/lotus/lib/nullreader" ) var _ Storage = &Sealer{} @@ -53,126 +52,6 @@ func (sb *Sealer) NewSector(ctx context.Context, sector storage.SectorRef) error return nil } -func (sb *Sealer) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (abi.PieceInfo, error) { - pieceData = io.LimitReader(io.MultiReader( - pieceData, - nullreader.Reader{}, - ), int64(pieceSize)) - - // TODO: allow tuning those: - chunk := abi.PaddedPieceSize(4 << 20) - parallel := runtime.NumCPU() - - maxSizeSpt := abi.RegisteredSealProof_StackedDrg64GiBV1_1 - - throttle := make(chan []byte, parallel) - piecePromises := make([]func() (abi.PieceInfo, error), 0) - - buf := make([]byte, chunk.Unpadded()) - for i := 0; i < parallel; i++ { - if abi.UnpaddedPieceSize(i)*chunk.Unpadded() >= pieceSize { - break // won't use this many buffers - } - throttle <- make([]byte, chunk.Unpadded()) - } - - for { - var read int - for rbuf := buf; len(rbuf) > 0; { - - n, err := pieceData.Read(rbuf) - if err != nil && err != io.EOF { - return abi.PieceInfo{}, xerrors.Errorf("pr read error: %w", err) - } - - rbuf = rbuf[n:] - read += n - - if err == io.EOF { - break - } - } - if read == 0 { - break - } - - done := make(chan struct { - cid.Cid - error - }, 1) - pbuf := <-throttle - copy(pbuf, buf[:read]) - - go func(read int) { - defer func() { - throttle <- pbuf - }() - - c, err := sb.pieceCid(maxSizeSpt, pbuf[:read]) - done <- struct { - cid.Cid - error - }{c, err} - }(read) - - piecePromises = append(piecePromises, func() (abi.PieceInfo, error) { - select { - case e := <-done: - if e.error != nil { - return abi.PieceInfo{}, e.error - } - - return abi.PieceInfo{ - Size: abi.UnpaddedPieceSize(read).Padded(), - PieceCID: e.Cid, - }, nil - case <-ctx.Done(): - return abi.PieceInfo{}, ctx.Err() - } - }) - } - - if len(piecePromises) == 1 { - return piecePromises[0]() - } - - var payloadRoundedBytes abi.PaddedPieceSize - pieceCids := make([]abi.PieceInfo, len(piecePromises)) - for i, promise := range piecePromises { - pinfo, err := promise() - if err != nil { - return abi.PieceInfo{}, err - } - - pieceCids[i] = pinfo - payloadRoundedBytes += pinfo.Size - } - - pieceCID, err := ffi.GenerateUnsealedCID(maxSizeSpt, pieceCids) - if err != nil { - return abi.PieceInfo{}, xerrors.Errorf("generate unsealed CID: %w", err) - } - - // validate that the pieceCID was properly formed - if _, err := commcid.CIDToPieceCommitmentV1(pieceCID); err != nil { - return abi.PieceInfo{}, err - } - - if payloadRoundedBytes < pieceSize.Padded() { - paddedCid, err := commpffi.ZeroPadPieceCommitment(pieceCID, payloadRoundedBytes.Unpadded(), pieceSize) - if err != nil { - return abi.PieceInfo{}, xerrors.Errorf("failed to pad data: %w", err) - } - - pieceCID = paddedCid - } - - return abi.PieceInfo{ - Size: pieceSize.Padded(), - PieceCID: pieceCID, - }, nil -} - func (sb *Sealer) AddPiece(ctx context.Context, sector storage.SectorRef, existingPieceSizes []abi.UnpaddedPieceSize, pieceSize abi.UnpaddedPieceSize, file storage.Data) (abi.PieceInfo, error) { // TODO: allow tuning those: chunk := abi.PaddedPieceSize(4 << 20) @@ -377,8 +256,8 @@ func (sb *Sealer) pieceCid(spt abi.RegisteredSealProof, in []byte) (cid.Cid, err return pieceCID, werr() } -func (sb *Sealer) tryDecodeUpdatedReplica(ctx context.Context, sector storage.SectorRef, commD cid.Cid, unsealedPath string, randomness abi.SealRandomness) (bool, error) { - replicaPath, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUpdate|storiface.FTUpdateCache, storiface.FTNone, storiface.PathStorage) +func (sb *Sealer) tryDecodeUpdatedReplica(ctx context.Context, sector storage.SectorRef, commD cid.Cid, unsealedPath string) (bool, error) { + paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUpdate|storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathStorage) if xerrors.Is(err, storiface.ErrSectorNotFound) { return false, nil } else if err != nil { @@ -386,47 +265,12 @@ func (sb *Sealer) tryDecodeUpdatedReplica(ctx context.Context, sector storage.Se } defer done() - sealedPaths, done2, err := sb.AcquireSectorKeyOrRegenerate(ctx, sector, randomness) - if err != nil { - return false, xerrors.Errorf("acquiring sealed sector: %w", err) - } - defer done2() - // Sector data stored in replica update updateProof, err := sector.ProofType.RegisteredUpdateProof() if err != nil { return false, err } - return true, ffi.SectorUpdate.DecodeFrom(updateProof, unsealedPath, replicaPath.Update, sealedPaths.Sealed, sealedPaths.Cache, commD) -} - -func (sb *Sealer) AcquireSectorKeyOrRegenerate(ctx context.Context, sector storage.SectorRef, randomness abi.SealRandomness) (storiface.SectorPaths, func(), error) { - paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathStorage) - if err == nil { - return paths, done, err - } else if !xerrors.Is(err, storiface.ErrSectorNotFound) { - return paths, done, xerrors.Errorf("reading sector key: %w", err) - } - - // Sector key can't be found, so let's regenerate it - sectorSize, err := sector.ProofType.SectorSize() - if err != nil { - return paths, done, xerrors.Errorf("retrieving sector size: %w", err) - } - paddedSize := abi.PaddedPieceSize(sectorSize) - - _, err = sb.AddPiece(ctx, sector, nil, paddedSize.Unpadded(), nr.NewNullReader(paddedSize.Unpadded())) - if err != nil { - return paths, done, xerrors.Errorf("recomputing empty data: %w", err) - } - - err = sb.RegenerateSectorKey(ctx, sector, randomness, []abi.PieceInfo{{PieceCID: zerocomm.ZeroPieceCommitment(paddedSize.Unpadded()), Size: paddedSize}}) - if err != nil { - return paths, done, xerrors.Errorf("during pc1: %w", err) - } - - // Sector key should exist now, let's grab the paths - return sb.sectors.AcquireSector(ctx, sector, storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathStorage) + return true, ffi.SectorUpdate.DecodeFrom(updateProof, unsealedPath, paths.Update, paths.Sealed, paths.Cache, commD) } func (sb *Sealer) UnsealPiece(ctx context.Context, sector storage.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize, randomness abi.SealRandomness, commd cid.Cid) error { @@ -480,7 +324,7 @@ func (sb *Sealer) UnsealPiece(ctx context.Context, sector storage.SectorRef, off } // If piece data stored in updated replica decode whole sector - decoded, err := sb.tryDecodeUpdatedReplica(ctx, sector, commd, unsealedPath.Unsealed, randomness) + decoded, err := sb.tryDecodeUpdatedReplica(ctx, sector, commd, unsealedPath.Unsealed) if err != nil { return xerrors.Errorf("decoding sector from replica: %w", err) } @@ -661,51 +505,6 @@ func (sb *Sealer) ReadPiece(ctx context.Context, writer io.Writer, sector storag return true, nil } -func (sb *Sealer) RegenerateSectorKey(ctx context.Context, sector storage.SectorRef, ticket abi.SealRandomness, pieces []abi.PieceInfo) error { - paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUnsealed|storiface.FTCache, storiface.FTSealed, storiface.PathSealing) - if err != nil { - return xerrors.Errorf("acquiring sector paths: %w", err) - } - defer done() - - e, err := os.OpenFile(paths.Sealed, os.O_RDWR|os.O_CREATE, 0644) // nolint:gosec - if err != nil { - return xerrors.Errorf("ensuring sealed file exists: %w", err) - } - if err := e.Close(); err != nil { - return err - } - - var sum abi.UnpaddedPieceSize - for _, piece := range pieces { - sum += piece.Size.Unpadded() - } - ssize, err := sector.ProofType.SectorSize() - if err != nil { - return err - } - ussize := abi.PaddedPieceSize(ssize).Unpadded() - if sum != ussize { - return xerrors.Errorf("aggregated piece sizes don't match sector size: %d != %d (%d)", sum, ussize, int64(ussize-sum)) - } - - // TODO: context cancellation respect - _, err = ffi.SealPreCommitPhase1( - sector.ProofType, - paths.Cache, - paths.Unsealed, - paths.Sealed, - sector.ID.Number, - sector.ID.Miner, - ticket, - pieces, - ) - if err != nil { - return xerrors.Errorf("presealing sector %d (%s): %w", sector.ID.Number, paths.Unsealed, err) - } - return nil -} - func (sb *Sealer) SealPreCommit1(ctx context.Context, sector storage.SectorRef, ticket abi.SealRandomness, pieces []abi.PieceInfo) (out storage.PreCommit1Out, err error) { paths, done, err := sb.sectors.AcquireSector(ctx, sector, storiface.FTUnsealed, storiface.FTSealed|storiface.FTCache, storiface.PathSealing) if err != nil { @@ -1181,21 +980,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/fsutil/filesize_unix.go b/extern/sector-storage/fsutil/filesize_unix.go index 9c7f04ace..7df8dae4c 100644 --- a/extern/sector-storage/fsutil/filesize_unix.go +++ b/extern/sector-storage/fsutil/filesize_unix.go @@ -4,7 +4,6 @@ import ( "os" "path/filepath" "syscall" - "time" "golang.org/x/xerrors" ) @@ -16,8 +15,6 @@ type SizeInfo struct { // FileSize returns bytes used by a file or directory on disk // NOTE: We care about the allocated bytes, not file or directory size func FileSize(path string) (SizeInfo, error) { - start := time.Now() - var size int64 err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error { if err != nil { @@ -35,11 +32,6 @@ func FileSize(path string) (SizeInfo, error) { } return err }) - - if time.Now().Sub(start) >= 3*time.Second { - log.Warnw("very slow file size check", "took", time.Now().Sub(start), "path", path) - } - if err != nil { if os.IsNotExist(err) { return SizeInfo{}, os.ErrNotExist diff --git a/extern/sector-storage/manager.go b/extern/sector-storage/manager.go index e48aecb4e..8bea96cca 100644 --- a/extern/sector-storage/manager.go +++ b/extern/sector-storage/manager.go @@ -62,7 +62,7 @@ type Manager struct { remoteHnd *stores.FetchHandler index stores.SectorIndex - sched *Scheduler + sched *scheduler windowPoStSched *poStScheduler winningPoStSched *poStScheduler @@ -71,8 +71,7 @@ type Manager struct { workLk sync.Mutex work *statestore.StateStore - parallelCheckLimit int - disallowRemoteFinalize bool + parallelCheckLimit int callToWork map[storiface.CallID]WorkID // used when we get an early return and there's no callToWork mapping @@ -123,10 +122,6 @@ type Config struct { // PoSt config ParallelCheckLimit int - - DisallowRemoteFinalize bool - - Assigner string } type StorageAuth http.Header @@ -140,11 +135,6 @@ func New(ctx context.Context, lstor *stores.Local, stor stores.Store, ls stores. return nil, xerrors.Errorf("creating prover instance: %w", err) } - sh, err := newScheduler(sc.Assigner) - if err != nil { - return nil, err - } - m := &Manager{ ls: ls, storage: stor, @@ -152,14 +142,13 @@ func New(ctx context.Context, lstor *stores.Local, stor stores.Store, ls stores. remoteHnd: &stores.FetchHandler{Local: lstor, PfHandler: &stores.DefaultPartialFileHandler{}}, index: si, - sched: sh, + sched: newScheduler(), windowPoStSched: newPoStScheduler(sealtasks.TTGenerateWindowPoSt), winningPoStSched: newPoStScheduler(sealtasks.TTGenerateWinningPoSt), localProver: prover, - parallelCheckLimit: sc.ParallelCheckLimit, - disallowRemoteFinalize: sc.DisallowRemoteFinalize, + parallelCheckLimit: sc.ParallelCheckLimit, work: mss, callToWork: map[storiface.CallID]WorkID{}, @@ -176,7 +165,7 @@ func New(ctx context.Context, lstor *stores.Local, stor stores.Store, ls stores. sealtasks.TTCommit1, sealtasks.TTProveReplicaUpdate1, sealtasks.TTFinalize, sealtasks.TTFetch, sealtasks.TTFinalizeReplicaUpdate, } if sc.AllowAddPiece { - localTasks = append(localTasks, sealtasks.TTAddPiece, sealtasks.TTDataCid) + localTasks = append(localTasks, sealtasks.TTAddPiece) } if sc.AllowPreCommit1 { localTasks = append(localTasks, sealtasks.TTPreCommit1) @@ -284,7 +273,7 @@ func (m *Manager) SectorsUnsealPiece(ctx context.Context, sector storage.SectorR defer cancel() log.Debugf("acquire unseal sector lock for sector %d", sector.ID) - if err := m.index.StorageLock(ctx, sector.ID, storiface.FTSealed|storiface.FTCache|storiface.FTUpdate|storiface.FTUpdateCache, storiface.FTUnsealed); err != nil { + if err := m.index.StorageLock(ctx, sector.ID, storiface.FTSealed|storiface.FTCache, storiface.FTUnsealed); err != nil { return xerrors.Errorf("acquiring unseal sector lock: %w", err) } @@ -292,11 +281,8 @@ func (m *Manager) SectorsUnsealPiece(ctx context.Context, sector storage.SectorR // put it in the sealing scratch space. sealFetch := func(ctx context.Context, worker Worker) error { log.Debugf("copy sealed/cache sector data for sector %d", sector.ID) - _, err := m.waitSimpleCall(ctx)(worker.Fetch(ctx, sector, storiface.FTSealed|storiface.FTCache, storiface.PathSealing, storiface.AcquireCopy)) - _, err2 := m.waitSimpleCall(ctx)(worker.Fetch(ctx, sector, storiface.FTUpdate|storiface.FTUpdateCache, storiface.PathSealing, storiface.AcquireCopy)) - - if err != nil && err2 != nil { - return xerrors.Errorf("cannot unseal piece. error fetching sealed data: %w. error fetching replica data: %w", err, err2) + if _, err := m.waitSimpleCall(ctx)(worker.Fetch(ctx, sector, storiface.FTSealed|storiface.FTCache, storiface.PathSealing, storiface.AcquireCopy)); err != nil { + return xerrors.Errorf("copy sealed/cache sector data: %w", err) } return nil @@ -341,27 +327,6 @@ func (m *Manager) NewSector(ctx context.Context, sector storage.SectorRef) error return nil } -func (m *Manager) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (abi.PieceInfo, error) { - ctx, cancel := context.WithCancel(ctx) - defer cancel() - - selector := newTaskSelector() - - var out abi.PieceInfo - err := m.sched.Schedule(ctx, storage.NoSectorRef, sealtasks.TTDataCid, selector, schedNop, func(ctx context.Context, w Worker) error { - p, err := m.waitSimpleCall(ctx)(w.DataCid(ctx, pieceSize, pieceData)) - if err != nil { - return err - } - if p != nil { - out = p.(abi.PieceInfo) - } - return nil - }) - - return out, err -} - func (m *Manager) AddPiece(ctx context.Context, sector storage.SectorRef, existingPieces []abi.UnpaddedPieceSize, sz abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -596,7 +561,6 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storage.SectorRef, return xerrors.Errorf("acquiring sector lock: %w", err) } - // first check if the unsealed file exists anywhere; If it doesn't ignore it unsealed := storiface.FTUnsealed { unsealedStores, err := m.index.StorageFindSector(ctx, sector.ID, storiface.FTUnsealed, 0, false) @@ -609,8 +573,6 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storage.SectorRef, } } - // Make sure that the sealed file is still in sealing storage; In case it already - // isn't, we want to do finalize in long-term storage pathType := storiface.PathStorage { sealedStores, err := m.index.StorageFindSector(ctx, sector.ID, storiface.FTSealed, 0, false) @@ -626,8 +588,6 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storage.SectorRef, } } - // do the cache trimming wherever the likely still very large cache lives. - // we really don't want to move it. selector := newExistingSelector(m.index, sector.ID, storiface.FTCache, false) err := m.sched.Schedule(ctx, sector, sealtasks.TTFinalize, selector, @@ -640,10 +600,7 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storage.SectorRef, return err } - // get a selector for moving stuff into long-term storage - fetchSel := newMoveSelector(m.index, sector.ID, storiface.FTCache|storiface.FTSealed, storiface.PathStorage, !m.disallowRemoteFinalize) - - // only move the unsealed file if it still exists and needs moving + fetchSel := newAllocSelector(m.index, storiface.FTCache|storiface.FTSealed, storiface.PathStorage) moveUnsealed := unsealed { if len(keepUnsealed) == 0 { @@ -651,7 +608,6 @@ func (m *Manager) FinalizeSector(ctx context.Context, sector storage.SectorRef, } } - // move stuff to long-term storage err = m.sched.Schedule(ctx, sector, sealtasks.TTFetch, fetchSel, m.schedFetch(sector, storiface.FTCache|storiface.FTSealed|moveUnsealed, storiface.PathStorage, storiface.AcquireMove), func(ctx context.Context, w Worker) error { @@ -673,7 +629,6 @@ func (m *Manager) FinalizeReplicaUpdate(ctx context.Context, sector storage.Sect return xerrors.Errorf("acquiring sector lock: %w", err) } - // first check if the unsealed file exists anywhere; If it doesn't ignore it moveUnsealed := storiface.FTUnsealed { unsealedStores, err := m.index.StorageFindSector(ctx, sector.ID, storiface.FTUnsealed, 0, false) @@ -686,8 +641,6 @@ func (m *Manager) FinalizeReplicaUpdate(ctx context.Context, sector storage.Sect } } - // Make sure that the update file is still in sealing storage; In case it already - // isn't, we want to do finalize in long-term storage pathType := storiface.PathStorage { sealedStores, err := m.index.StorageFindSector(ctx, sector.ID, storiface.FTUpdate, 0, false) @@ -703,9 +656,7 @@ func (m *Manager) FinalizeReplicaUpdate(ctx context.Context, sector storage.Sect } } - // do the cache trimming wherever the likely still large cache lives. - // we really don't want to move it. - selector := newExistingSelector(m.index, sector.ID, storiface.FTUpdateCache, false) + selector := newExistingSelector(m.index, sector.ID, storiface.FTCache|storiface.FTUpdateCache, false) err := m.sched.Schedule(ctx, sector, sealtasks.TTFinalizeReplicaUpdate, selector, m.schedFetch(sector, storiface.FTCache|storiface.FTUpdateCache|moveUnsealed, pathType, storiface.AcquireMove), @@ -718,8 +669,7 @@ func (m *Manager) FinalizeReplicaUpdate(ctx context.Context, sector storage.Sect } move := func(types storiface.SectorFileType) error { - // get a selector for moving stuff into long-term storage - fetchSel := newMoveSelector(m.index, sector.ID, types, storiface.PathStorage, !m.disallowRemoteFinalize) + fetchSel := newAllocSelector(m.index, types, storiface.PathStorage) { if len(keepUnsealed) == 0 { moveUnsealed = storiface.FTNone @@ -1025,10 +975,6 @@ func (m *Manager) ProveReplicaUpdate2(ctx context.Context, sector storage.Sector return out, waitErr } -func (m *Manager) ReturnDataCid(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error { - return m.returnResult(ctx, callID, pi, err) -} - func (m *Manager) ReturnAddPiece(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error { return m.returnResult(ctx, callID, pi, err) } diff --git a/extern/sector-storage/manager_test.go b/extern/sector-storage/manager_test.go index 5aee41328..9c844292e 100644 --- a/extern/sector-storage/manager_test.go +++ b/extern/sector-storage/manager_test.go @@ -109,9 +109,6 @@ func newTestMgr(ctx context.Context, t *testing.T, ds datastore.Datastore) (*Man stor := stores.NewRemote(lstor, si, nil, 6000, &stores.DefaultPartialFileHandler{}) - sh, err := newScheduler("") - require.NoError(t, err) - m := &Manager{ ls: st, storage: stor, @@ -119,7 +116,7 @@ func newTestMgr(ctx context.Context, t *testing.T, ds datastore.Datastore) (*Man remoteHnd: &stores.FetchHandler{Local: lstor}, index: si, - sched: sh, + sched: newScheduler(), windowPoStSched: newPoStScheduler(sealtasks.TTGenerateWindowPoSt), winningPoStSched: newPoStScheduler(sealtasks.TTGenerateWinningPoSt), @@ -318,12 +315,6 @@ func TestSnapDeals(t *testing.T) { require.NoError(t, m.GenerateSectorKeyFromData(ctx, sid, out.NewUnsealed)) fmt.Printf("GSK duration (%s): %s\n", ss.ShortString(), time.Since(startGSK)) - fmt.Printf("Remove data\n") - require.NoError(t, m.FinalizeSector(ctx, sid, nil)) - fmt.Printf("Release Sector Key\n") - require.NoError(t, m.ReleaseSectorKey(ctx, sid)) - fmt.Printf("Unseal Replica\n") - require.NoError(t, m.SectorsUnsealPiece(ctx, sid, 0, p1.Size.Unpadded(), ticket, &out.NewUnsealed)) } func TestRedoPC1(t *testing.T) { diff --git a/extern/sector-storage/mock/mock.go b/extern/sector-storage/mock/mock.go index ecb06da0b..038a7ac46 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 { @@ -80,10 +80,6 @@ func (mgr *SectorMgr) SectorsUnsealPiece(ctx context.Context, sector storage.Sec panic("SectorMgr: unsealing piece: implement me") } -func (mgr *SectorMgr) DataCid(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) { - panic("todo") -} - func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorID storage.SectorRef, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) { log.Warn("Add piece: ", sectorID, size, sectorID.ProofType) @@ -338,13 +334,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 +350,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 +358,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 +384,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 +396,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 +411,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 +425,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") } @@ -541,10 +537,6 @@ func (mgr *SectorMgr) CheckProvable(ctx context.Context, pp abi.RegisteredPoStPr var _ storiface.WorkerReturn = &SectorMgr{} -func (mgr *SectorMgr) ReturnDataCid(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error { - panic("not supported") -} - func (mgr *SectorMgr) ReturnAddPiece(ctx context.Context, callID storiface.CallID, pi abi.PieceInfo, err *storiface.CallError) error { panic("not supported") } @@ -609,7 +601,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 +622,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 +648,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 +694,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 +722,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/request_queue.go b/extern/sector-storage/request_queue.go index 87a057923..925c44fa8 100644 --- a/extern/sector-storage/request_queue.go +++ b/extern/sector-storage/request_queue.go @@ -2,34 +2,34 @@ package sectorstorage import "sort" -type RequestQueue []*WorkerRequest +type requestQueue []*workerRequest -func (q RequestQueue) Len() int { return len(q) } +func (q requestQueue) Len() int { return len(q) } -func (q RequestQueue) Less(i, j int) bool { - oneMuchLess, muchLess := q[i].TaskType.MuchLess(q[j].TaskType) +func (q requestQueue) Less(i, j int) bool { + oneMuchLess, muchLess := q[i].taskType.MuchLess(q[j].taskType) if oneMuchLess { return muchLess } - if q[i].Priority != q[j].Priority { - return q[i].Priority > q[j].Priority + if q[i].priority != q[j].priority { + return q[i].priority > q[j].priority } - if q[i].TaskType != q[j].TaskType { - return q[i].TaskType.Less(q[j].TaskType) + if q[i].taskType != q[j].taskType { + return q[i].taskType.Less(q[j].taskType) } - return q[i].Sector.ID.Number < q[j].Sector.ID.Number // optimize minerActor.NewSectors bitfield + return q[i].sector.ID.Number < q[j].sector.ID.Number // optimize minerActor.NewSectors bitfield } -func (q RequestQueue) Swap(i, j int) { +func (q requestQueue) Swap(i, j int) { q[i], q[j] = q[j], q[i] q[i].index = i q[j].index = j } -func (q *RequestQueue) Push(x *WorkerRequest) { +func (q *requestQueue) Push(x *workerRequest) { n := len(*q) item := x item.index = n @@ -37,7 +37,7 @@ func (q *RequestQueue) Push(x *WorkerRequest) { sort.Sort(q) } -func (q *RequestQueue) Remove(i int) *WorkerRequest { +func (q *requestQueue) Remove(i int) *workerRequest { old := *q n := len(old) item := old[i] diff --git a/extern/sector-storage/request_queue_test.go b/extern/sector-storage/request_queue_test.go index c95548c43..ed802f30a 100644 --- a/extern/sector-storage/request_queue_test.go +++ b/extern/sector-storage/request_queue_test.go @@ -8,13 +8,13 @@ import ( ) func TestRequestQueue(t *testing.T) { - rq := &RequestQueue{} + rq := &requestQueue{} - rq.Push(&WorkerRequest{TaskType: sealtasks.TTAddPiece}) - rq.Push(&WorkerRequest{TaskType: sealtasks.TTPreCommit1}) - rq.Push(&WorkerRequest{TaskType: sealtasks.TTPreCommit2}) - rq.Push(&WorkerRequest{TaskType: sealtasks.TTPreCommit1}) - rq.Push(&WorkerRequest{TaskType: sealtasks.TTAddPiece}) + rq.Push(&workerRequest{taskType: sealtasks.TTAddPiece}) + rq.Push(&workerRequest{taskType: sealtasks.TTPreCommit1}) + rq.Push(&workerRequest{taskType: sealtasks.TTPreCommit2}) + rq.Push(&workerRequest{taskType: sealtasks.TTPreCommit1}) + rq.Push(&workerRequest{taskType: sealtasks.TTAddPiece}) dump := func(s string) { fmt.Println("---") @@ -22,7 +22,7 @@ func TestRequestQueue(t *testing.T) { for sqi := 0; sqi < rq.Len(); sqi++ { task := (*rq)[sqi] - fmt.Println(sqi, task.TaskType) + fmt.Println(sqi, task.taskType) } } @@ -32,31 +32,31 @@ func TestRequestQueue(t *testing.T) { dump("pop 1") - if pt.TaskType != sealtasks.TTPreCommit2 { - t.Error("expected precommit2, got", pt.TaskType) + if pt.taskType != sealtasks.TTPreCommit2 { + t.Error("expected precommit2, got", pt.taskType) } pt = rq.Remove(0) dump("pop 2") - if pt.TaskType != sealtasks.TTPreCommit1 { - t.Error("expected precommit1, got", pt.TaskType) + if pt.taskType != sealtasks.TTPreCommit1 { + t.Error("expected precommit1, got", pt.taskType) } pt = rq.Remove(1) dump("pop 3") - if pt.TaskType != sealtasks.TTAddPiece { - t.Error("expected addpiece, got", pt.TaskType) + if pt.taskType != sealtasks.TTAddPiece { + t.Error("expected addpiece, got", pt.taskType) } pt = rq.Remove(0) dump("pop 4") - if pt.TaskType != sealtasks.TTPreCommit1 { - t.Error("expected precommit1, got", pt.TaskType) + if pt.taskType != sealtasks.TTPreCommit1 { + t.Error("expected precommit1, got", pt.taskType) } } diff --git a/extern/sector-storage/sched.go b/extern/sector-storage/sched.go index 32f91b4e7..eb2d17c59 100644 --- a/extern/sector-storage/sched.go +++ b/extern/sector-storage/sched.go @@ -2,6 +2,9 @@ package sectorstorage import ( "context" + "math" + "math/rand" + "sort" "sync" "time" @@ -44,28 +47,23 @@ const mib = 1 << 20 type WorkerAction func(ctx context.Context, w Worker) error type WorkerSelector interface { - // Ok is true if worker is acceptable for performing a task. - // If any worker is preferred for a task, other workers won't be considered for that task. - Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a *WorkerHandle) (ok, preferred bool, err error) + Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a *workerHandle) (bool, error) // true if worker is acceptable for performing a task - Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) // true if a is preferred over b + Cmp(ctx context.Context, task sealtasks.TaskType, a, b *workerHandle) (bool, error) // true if a is preferred over b } -type Scheduler struct { - assigner Assigner - +type scheduler struct { workersLk sync.RWMutex + workers map[storiface.WorkerID]*workerHandle - Workers map[storiface.WorkerID]*WorkerHandle - - schedule chan *WorkerRequest - windowRequests chan *SchedWindowRequest + schedule chan *workerRequest + windowRequests chan *schedWindowRequest workerChange chan struct{} // worker added / changed/freed resources workerDisable chan workerDisableReq // owned by the sh.runSched goroutine - SchedQueue *RequestQueue - OpenWindows []*SchedWindowRequest + schedQueue *requestQueue + openWindows []*schedWindowRequest workTracker *workTracker @@ -76,24 +74,24 @@ type Scheduler struct { testSync chan struct{} // used for testing } -type WorkerHandle struct { +type workerHandle struct { workerRpc Worker tasksCache map[sealtasks.TaskType]struct{} tasksUpdate time.Time tasksLk sync.Mutex - Info storiface.WorkerInfo + info storiface.WorkerInfo - preparing *ActiveResources // use with WorkerHandle.lk - active *ActiveResources // use with WorkerHandle.lk + preparing *activeResources // use with workerHandle.lk + active *activeResources // use with workerHandle.lk lk sync.Mutex // can be taken inside sched.workersLk.RLock wndLk sync.Mutex // can be taken inside sched.workersLk.RLock - activeWindows []*SchedWindow + activeWindows []*schedWindow - Enabled bool + enabled bool // for sync manager goroutine closing cleanupStarted bool @@ -101,28 +99,38 @@ type WorkerHandle struct { closingMgr chan struct{} } -type SchedWindowRequest struct { - Worker storiface.WorkerID +type schedWindowRequest struct { + worker storiface.WorkerID - Done chan *SchedWindow + done chan *schedWindow } -type SchedWindow struct { - Allocated ActiveResources - Todo []*WorkerRequest +type schedWindow struct { + allocated activeResources + todo []*workerRequest } type workerDisableReq struct { - activeWindows []*SchedWindow + activeWindows []*schedWindow wid storiface.WorkerID done func() } -type WorkerRequest struct { - Sector storage.SectorRef - TaskType sealtasks.TaskType - Priority int // larger values more important - Sel WorkerSelector +type activeResources struct { + memUsedMin uint64 + memUsedMax uint64 + gpuUsed float64 + cpuUse uint64 + + cond *sync.Cond + waiting int +} + +type workerRequest struct { + sector storage.SectorRef + taskType sealtasks.TaskType + priority int // larger values more important + sel WorkerSelector prepare WorkerAction work WorkerAction @@ -131,37 +139,25 @@ type WorkerRequest struct { index int // The index of the item in the heap. - IndexHeap int + indexHeap int ret chan<- workerResponse - Ctx context.Context + ctx context.Context } type workerResponse struct { err error } -func newScheduler(assigner string) (*Scheduler, error) { - var a Assigner - switch assigner { - case "", "utilization": - a = NewLowestUtilizationAssigner() - case "spread": - a = NewSpreadAssigner() - default: - return nil, xerrors.Errorf("unknown assigner '%s'", assigner) - } - - return &Scheduler{ - assigner: a, - - Workers: map[storiface.WorkerID]*WorkerHandle{}, +func newScheduler() *scheduler { + return &scheduler{ + workers: map[storiface.WorkerID]*workerHandle{}, - schedule: make(chan *WorkerRequest), - windowRequests: make(chan *SchedWindowRequest, 20), + schedule: make(chan *workerRequest), + windowRequests: make(chan *schedWindowRequest, 20), workerChange: make(chan struct{}, 20), workerDisable: make(chan workerDisableReq), - SchedQueue: &RequestQueue{}, + schedQueue: &requestQueue{}, workTracker: &workTracker{ done: map[storiface.CallID]struct{}{}, @@ -173,18 +169,18 @@ func newScheduler(assigner string) (*Scheduler, error) { closing: make(chan struct{}), closed: make(chan struct{}), - }, nil + } } -func (sh *Scheduler) Schedule(ctx context.Context, sector storage.SectorRef, taskType sealtasks.TaskType, sel WorkerSelector, prepare WorkerAction, work WorkerAction) error { +func (sh *scheduler) Schedule(ctx context.Context, sector storage.SectorRef, taskType sealtasks.TaskType, sel WorkerSelector, prepare WorkerAction, work WorkerAction) error { ret := make(chan workerResponse) select { - case sh.schedule <- &WorkerRequest{ - Sector: sector, - TaskType: taskType, - Priority: getPriority(ctx), - Sel: sel, + case sh.schedule <- &workerRequest{ + sector: sector, + taskType: taskType, + priority: getPriority(ctx), + sel: sel, prepare: prepare, work: work, @@ -192,7 +188,7 @@ func (sh *Scheduler) Schedule(ctx context.Context, sector storage.SectorRef, tas start: time.Now(), ret: ret, - Ctx: ctx, + ctx: ctx, }: case <-sh.closing: return xerrors.New("closing") @@ -210,21 +206,14 @@ func (sh *Scheduler) Schedule(ctx context.Context, sector storage.SectorRef, tas } } -func (r *WorkerRequest) respond(err error) { +func (r *workerRequest) respond(err error) { select { case r.ret <- workerResponse{err: err}: - case <-r.Ctx.Done(): + case <-r.ctx.Done(): log.Warnf("request got cancelled before we could respond") } } -func (r *WorkerRequest) SealTask() sealtasks.SealTaskType { - return sealtasks.SealTaskType{ - TaskType: r.TaskType, - RegisteredSealProof: r.Sector.ProofType, - } -} - type SchedDiagRequestInfo struct { Sector abi.SectorID TaskType sealtasks.TaskType @@ -236,7 +225,7 @@ type SchedDiagInfo struct { OpenWindows []string } -func (sh *Scheduler) runSched() { +func (sh *scheduler) runSched() { defer close(sh.closed) iw := time.After(InitWait) @@ -253,14 +242,14 @@ func (sh *Scheduler) runSched() { toDisable = append(toDisable, dreq) doSched = true case req := <-sh.schedule: - sh.SchedQueue.Push(req) + sh.schedQueue.Push(req) doSched = true if sh.testSync != nil { sh.testSync <- struct{}{} } case req := <-sh.windowRequests: - sh.OpenWindows = append(sh.OpenWindows, req) + sh.openWindows = append(sh.openWindows, req) doSched = true case ireq := <-sh.info: ireq(sh.diag()) @@ -284,12 +273,12 @@ func (sh *Scheduler) runSched() { case dreq := <-sh.workerDisable: toDisable = append(toDisable, dreq) case req := <-sh.schedule: - sh.SchedQueue.Push(req) + sh.schedQueue.Push(req) if sh.testSync != nil { sh.testSync <- struct{}{} } case req := <-sh.windowRequests: - sh.OpenWindows = append(sh.OpenWindows, req) + sh.openWindows = append(sh.openWindows, req) default: break loop } @@ -297,21 +286,21 @@ func (sh *Scheduler) runSched() { for _, req := range toDisable { for _, window := range req.activeWindows { - for _, request := range window.Todo { - sh.SchedQueue.Push(request) + for _, request := range window.todo { + sh.schedQueue.Push(request) } } - openWindows := make([]*SchedWindowRequest, 0, len(sh.OpenWindows)) - for _, window := range sh.OpenWindows { - if window.Worker != req.wid { + openWindows := make([]*schedWindowRequest, 0, len(sh.openWindows)) + for _, window := range sh.openWindows { + if window.worker != req.wid { openWindows = append(openWindows, window) } } - sh.OpenWindows = openWindows + sh.openWindows = openWindows sh.workersLk.Lock() - sh.Workers[req.wid].Enabled = false + sh.workers[req.wid].enabled = false sh.workersLk.Unlock() req.done() @@ -323,51 +312,281 @@ func (sh *Scheduler) runSched() { } } -func (sh *Scheduler) diag() SchedDiagInfo { +func (sh *scheduler) diag() SchedDiagInfo { var out SchedDiagInfo - for sqi := 0; sqi < sh.SchedQueue.Len(); sqi++ { - task := (*sh.SchedQueue)[sqi] + for sqi := 0; sqi < sh.schedQueue.Len(); sqi++ { + task := (*sh.schedQueue)[sqi] out.Requests = append(out.Requests, SchedDiagRequestInfo{ - Sector: task.Sector.ID, - TaskType: task.TaskType, - Priority: task.Priority, + Sector: task.sector.ID, + TaskType: task.taskType, + Priority: task.priority, }) } sh.workersLk.RLock() defer sh.workersLk.RUnlock() - for _, window := range sh.OpenWindows { - out.OpenWindows = append(out.OpenWindows, uuid.UUID(window.Worker).String()) + for _, window := range sh.openWindows { + out.OpenWindows = append(out.OpenWindows, uuid.UUID(window.worker).String()) } return out } -type Assigner interface { - TrySched(sh *Scheduler) -} +func (sh *scheduler) trySched() { + /* + This assigns tasks to workers based on: + - Task priority (achieved by handling sh.schedQueue in order, since it's already sorted by priority) + - Worker resource availability + - Task-specified worker preference (acceptableWindows array below sorted by this preference) + - Window request age + + 1. For each task in the schedQueue find windows which can handle them + 1.1. Create list of windows capable of handling a task + 1.2. Sort windows according to task selector preferences + 2. Going through schedQueue again, assign task to first acceptable window + with resources available + 3. Submit windows with scheduled tasks to workers + + */ -func (sh *Scheduler) trySched() { sh.workersLk.RLock() defer sh.workersLk.RUnlock() - sh.assigner.TrySched(sh) + windowsLen := len(sh.openWindows) + queueLen := sh.schedQueue.Len() + + log.Debugf("SCHED %d queued; %d open windows", queueLen, windowsLen) + + if windowsLen == 0 || queueLen == 0 { + // nothing to schedule on + return + } + + windows := make([]schedWindow, windowsLen) + acceptableWindows := make([][]int, queueLen) // QueueIndex -> []OpenWindowIndex + + // Step 1 + throttle := make(chan struct{}, windowsLen) + + var wg sync.WaitGroup + wg.Add(queueLen) + for i := 0; i < queueLen; i++ { + throttle <- struct{}{} + + go func(sqi int) { + defer wg.Done() + defer func() { + <-throttle + }() + + task := (*sh.schedQueue)[sqi] + + task.indexHeap = sqi + for wnd, windowRequest := range sh.openWindows { + worker, ok := sh.workers[windowRequest.worker] + if !ok { + log.Errorf("worker referenced by windowRequest not found (worker: %s)", windowRequest.worker) + // TODO: How to move forward here? + continue + } + + if !worker.enabled { + log.Debugw("skipping disabled worker", "worker", windowRequest.worker) + continue + } + + needRes := worker.info.Resources.ResourceSpec(task.sector.ProofType, task.taskType) + + // TODO: allow bigger windows + if !windows[wnd].allocated.canHandleRequest(needRes, windowRequest.worker, "schedAcceptable", worker.info) { + continue + } + + rpcCtx, cancel := context.WithTimeout(task.ctx, SelectorTimeout) + ok, err := task.sel.Ok(rpcCtx, task.taskType, task.sector.ProofType, worker) + cancel() + if err != nil { + log.Errorf("trySched(1) req.sel.Ok error: %+v", err) + continue + } + + if !ok { + continue + } + + acceptableWindows[sqi] = append(acceptableWindows[sqi], wnd) + } + + if len(acceptableWindows[sqi]) == 0 { + return + } + + // Pick best worker (shuffle in case some workers are equally as good) + rand.Shuffle(len(acceptableWindows[sqi]), func(i, j int) { + acceptableWindows[sqi][i], acceptableWindows[sqi][j] = acceptableWindows[sqi][j], acceptableWindows[sqi][i] // nolint:scopelint + }) + sort.SliceStable(acceptableWindows[sqi], func(i, j int) bool { + wii := sh.openWindows[acceptableWindows[sqi][i]].worker // nolint:scopelint + wji := sh.openWindows[acceptableWindows[sqi][j]].worker // nolint:scopelint + + if wii == wji { + // for the same worker prefer older windows + return acceptableWindows[sqi][i] < acceptableWindows[sqi][j] // nolint:scopelint + } + + wi := sh.workers[wii] + wj := sh.workers[wji] + + rpcCtx, cancel := context.WithTimeout(task.ctx, SelectorTimeout) + defer cancel() + + r, err := task.sel.Cmp(rpcCtx, task.taskType, wi, wj) + if err != nil { + log.Errorf("selecting best worker: %s", err) + } + return r + }) + }(i) + } + + wg.Wait() + + log.Debugf("SCHED windows: %+v", windows) + log.Debugf("SCHED Acceptable win: %+v", acceptableWindows) + + // Step 2 + scheduled := 0 + rmQueue := make([]int, 0, queueLen) + workerUtil := map[storiface.WorkerID]float64{} + + for sqi := 0; sqi < queueLen; sqi++ { + task := (*sh.schedQueue)[sqi] + + selectedWindow := -1 + var needRes storiface.Resources + var info storiface.WorkerInfo + var bestWid storiface.WorkerID + bestUtilization := math.MaxFloat64 // smaller = better + + for i, wnd := range acceptableWindows[task.indexHeap] { + wid := sh.openWindows[wnd].worker + w := sh.workers[wid] + + res := info.Resources.ResourceSpec(task.sector.ProofType, task.taskType) + + log.Debugf("SCHED try assign sqi:%d sector %d to window %d (awi:%d)", sqi, task.sector.ID.Number, wnd, i) + + // TODO: allow bigger windows + if !windows[wnd].allocated.canHandleRequest(needRes, wid, "schedAssign", info) { + continue + } + + wu, found := workerUtil[wid] + if !found { + wu = w.utilization() + workerUtil[wid] = wu + } + if wu >= bestUtilization { + // acceptable worker list is initially sorted by utilization, and the initially-best workers + // will be assigned tasks first. This means that if we find a worker which isn't better, it + // probably means that the other workers aren't better either. + // + // utilization + // ^ + // | / + // | \ / + // | \ / + // | * + // #--------> acceptableWindow index + // + // * -> we're here + break + } + + info = w.info + needRes = res + bestWid = wid + selectedWindow = wnd + bestUtilization = wu + } + + if selectedWindow < 0 { + // all windows full + continue + } + + log.Debugw("SCHED ASSIGNED", + "sqi", sqi, + "sector", task.sector.ID.Number, + "task", task.taskType, + "window", selectedWindow, + "worker", bestWid, + "utilization", bestUtilization) + + workerUtil[bestWid] += windows[selectedWindow].allocated.add(info.Resources, needRes) + windows[selectedWindow].todo = append(windows[selectedWindow].todo, task) + + rmQueue = append(rmQueue, sqi) + scheduled++ + } + + if len(rmQueue) > 0 { + for i := len(rmQueue) - 1; i >= 0; i-- { + sh.schedQueue.Remove(rmQueue[i]) + } + } + + // Step 3 + + if scheduled == 0 { + return + } + + scheduledWindows := map[int]struct{}{} + for wnd, window := range windows { + if len(window.todo) == 0 { + // Nothing scheduled here, keep the window open + continue + } + + scheduledWindows[wnd] = struct{}{} + + window := window // copy + select { + case sh.openWindows[wnd].done <- &window: + default: + log.Error("expected sh.openWindows[wnd].done to be buffered") + } + } + + // Rewrite sh.openWindows array, removing scheduled windows + newOpenWindows := make([]*schedWindowRequest, 0, windowsLen-len(scheduledWindows)) + for wnd, window := range sh.openWindows { + if _, scheduled := scheduledWindows[wnd]; scheduled { + // keep unscheduled windows open + continue + } + + newOpenWindows = append(newOpenWindows, window) + } + + sh.openWindows = newOpenWindows } -func (sh *Scheduler) schedClose() { +func (sh *scheduler) schedClose() { sh.workersLk.Lock() defer sh.workersLk.Unlock() log.Debugf("closing scheduler") - for i, w := range sh.Workers { + for i, w := range sh.workers { sh.workerCleanup(i, w) } } -func (sh *Scheduler) Info(ctx context.Context) (interface{}, error) { +func (sh *scheduler) Info(ctx context.Context) (interface{}, error) { ch := make(chan interface{}, 1) sh.info <- func(res interface{}) { @@ -382,7 +601,7 @@ func (sh *Scheduler) Info(ctx context.Context) (interface{}, error) { } } -func (sh *Scheduler) Close(ctx context.Context) error { +func (sh *scheduler) Close(ctx context.Context) error { close(sh.closing) select { case <-sh.closed: diff --git a/extern/sector-storage/sched_assigner_common.go b/extern/sector-storage/sched_assigner_common.go deleted file mode 100644 index 41cf866b2..000000000 --- a/extern/sector-storage/sched_assigner_common.go +++ /dev/null @@ -1,192 +0,0 @@ -package sectorstorage - -import ( - "context" - "math/rand" - "sort" - "sync" -) - -type WindowSelector func(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []SchedWindow) int - -// AssignerCommon is a task assigner with customizable parts -type AssignerCommon struct { - WindowSel WindowSelector -} - -var _ Assigner = &AssignerCommon{} - -func (a *AssignerCommon) TrySched(sh *Scheduler) { - /* - This assigns tasks to workers based on: - - Task priority (achieved by handling sh.SchedQueue in order, since it's already sorted by priority) - - Worker resource availability - - Task-specified worker preference (acceptableWindows array below sorted by this preference) - - Window request age - - 1. For each task in the SchedQueue find windows which can handle them - 1.1. Create list of windows capable of handling a task - 1.2. Sort windows according to task selector preferences - 2. Going through SchedQueue again, assign task to first acceptable window - with resources available - 3. Submit windows with scheduled tasks to workers - - */ - - windowsLen := len(sh.OpenWindows) - queueLen := sh.SchedQueue.Len() - - log.Debugf("SCHED %d queued; %d open windows", queueLen, windowsLen) - - if windowsLen == 0 || queueLen == 0 { - // nothing to schedule on - return - } - - windows := make([]SchedWindow, windowsLen) - for i := range windows { - windows[i].Allocated = *NewActiveResources() - } - acceptableWindows := make([][]int, queueLen) // QueueIndex -> []OpenWindowIndex - - // Step 1 - throttle := make(chan struct{}, windowsLen) - - var wg sync.WaitGroup - wg.Add(queueLen) - for i := 0; i < queueLen; i++ { - throttle <- struct{}{} - - go func(sqi int) { - defer wg.Done() - defer func() { - <-throttle - }() - - task := (*sh.SchedQueue)[sqi] - task.IndexHeap = sqi - - var havePreferred bool - - for wnd, windowRequest := range sh.OpenWindows { - worker, ok := sh.Workers[windowRequest.Worker] - if !ok { - log.Errorf("worker referenced by windowRequest not found (worker: %s)", windowRequest.Worker) - // TODO: How to move forward here? - continue - } - - if !worker.Enabled { - log.Debugw("skipping disabled worker", "worker", windowRequest.Worker) - continue - } - - needRes := worker.Info.Resources.ResourceSpec(task.Sector.ProofType, task.TaskType) - - // TODO: allow bigger windows - if !windows[wnd].Allocated.CanHandleRequest(task.SealTask(), needRes, windowRequest.Worker, "schedAcceptable", worker.Info) { - continue - } - - rpcCtx, cancel := context.WithTimeout(task.Ctx, SelectorTimeout) - ok, preferred, err := task.Sel.Ok(rpcCtx, task.TaskType, task.Sector.ProofType, worker) - cancel() - if err != nil { - log.Errorf("trySched(1) req.Sel.Ok error: %+v", err) - continue - } - - if !ok { - continue - } - - if havePreferred && !preferred { - // we have a way better worker for this task - continue - } - - if preferred && !havePreferred { - // all workers we considered previously are much worse choice - acceptableWindows[sqi] = acceptableWindows[sqi][:0] - havePreferred = true - } - - acceptableWindows[sqi] = append(acceptableWindows[sqi], wnd) - } - - if len(acceptableWindows[sqi]) == 0 { - return - } - - // Pick best worker (shuffle in case some workers are equally as good) - rand.Shuffle(len(acceptableWindows[sqi]), func(i, j int) { - acceptableWindows[sqi][i], acceptableWindows[sqi][j] = acceptableWindows[sqi][j], acceptableWindows[sqi][i] // nolint:scopelint - }) - sort.SliceStable(acceptableWindows[sqi], func(i, j int) bool { - wii := sh.OpenWindows[acceptableWindows[sqi][i]].Worker // nolint:scopelint - wji := sh.OpenWindows[acceptableWindows[sqi][j]].Worker // nolint:scopelint - - if wii == wji { - // for the same worker prefer older windows - return acceptableWindows[sqi][i] < acceptableWindows[sqi][j] // nolint:scopelint - } - - wi := sh.Workers[wii] - wj := sh.Workers[wji] - - rpcCtx, cancel := context.WithTimeout(task.Ctx, SelectorTimeout) - defer cancel() - - r, err := task.Sel.Cmp(rpcCtx, task.TaskType, wi, wj) - if err != nil { - log.Errorf("selecting best worker: %s", err) - } - return r - }) - }(i) - } - - wg.Wait() - - log.Debugf("SCHED windows: %+v", windows) - log.Debugf("SCHED Acceptable win: %+v", acceptableWindows) - - // Step 2 - scheduled := a.WindowSel(sh, queueLen, acceptableWindows, windows) - - // Step 3 - - if scheduled == 0 { - return - } - - scheduledWindows := map[int]struct{}{} - for wnd, window := range windows { - if len(window.Todo) == 0 { - // Nothing scheduled here, keep the window open - continue - } - - scheduledWindows[wnd] = struct{}{} - - window := window // copy - select { - case sh.OpenWindows[wnd].Done <- &window: - default: - log.Error("expected sh.OpenWindows[wnd].Done to be buffered") - } - } - - // Rewrite sh.OpenWindows array, removing scheduled windows - newOpenWindows := make([]*SchedWindowRequest, 0, windowsLen-len(scheduledWindows)) - for wnd, window := range sh.OpenWindows { - if _, scheduled := scheduledWindows[wnd]; scheduled { - // keep unscheduled windows open - continue - } - - newOpenWindows = append(newOpenWindows, window) - } - - sh.OpenWindows = newOpenWindows -} diff --git a/extern/sector-storage/sched_assigner_spread.go b/extern/sector-storage/sched_assigner_spread.go deleted file mode 100644 index c62cd42b2..000000000 --- a/extern/sector-storage/sched_assigner_spread.go +++ /dev/null @@ -1,81 +0,0 @@ -package sectorstorage - -import ( - "math" - - "github.com/filecoin-project/lotus/extern/sector-storage/storiface" -) - -func NewSpreadAssigner() Assigner { - return &AssignerCommon{ - WindowSel: SpreadWS, - } -} - -func SpreadWS(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []SchedWindow) int { - scheduled := 0 - rmQueue := make([]int, 0, queueLen) - workerAssigned := map[storiface.WorkerID]int{} - - for sqi := 0; sqi < queueLen; sqi++ { - task := (*sh.SchedQueue)[sqi] - - selectedWindow := -1 - var needRes storiface.Resources - var info storiface.WorkerInfo - var bestWid storiface.WorkerID - bestAssigned := math.MaxInt // smaller = better - - for i, wnd := range acceptableWindows[task.IndexHeap] { - wid := sh.OpenWindows[wnd].Worker - w := sh.Workers[wid] - - res := w.Info.Resources.ResourceSpec(task.Sector.ProofType, task.TaskType) - - log.Debugf("SCHED try assign sqi:%d sector %d to window %d (awi:%d)", sqi, task.Sector.ID.Number, wnd, i) - - if !windows[wnd].Allocated.CanHandleRequest(task.SealTask(), res, wid, "schedAssign", w.Info) { - continue - } - - wu, _ := workerAssigned[wid] - if wu >= bestAssigned { - continue - } - - info = w.Info - needRes = res - bestWid = wid - selectedWindow = wnd - bestAssigned = wu - } - - if selectedWindow < 0 { - // all windows full - continue - } - - log.Debugw("SCHED ASSIGNED", - "sqi", sqi, - "sector", task.Sector.ID.Number, - "task", task.TaskType, - "window", selectedWindow, - "worker", bestWid, - "assigned", bestAssigned) - - workerAssigned[bestWid]++ - windows[selectedWindow].Allocated.Add(task.SealTask(), info.Resources, needRes) - windows[selectedWindow].Todo = append(windows[selectedWindow].Todo, task) - - rmQueue = append(rmQueue, sqi) - scheduled++ - } - - if len(rmQueue) > 0 { - for i := len(rmQueue) - 1; i >= 0; i-- { - sh.SchedQueue.Remove(rmQueue[i]) - } - } - - return scheduled -} diff --git a/extern/sector-storage/sched_assigner_utilization.go b/extern/sector-storage/sched_assigner_utilization.go deleted file mode 100644 index 6cea72a1c..000000000 --- a/extern/sector-storage/sched_assigner_utilization.go +++ /dev/null @@ -1,98 +0,0 @@ -package sectorstorage - -import ( - "math" - - "github.com/filecoin-project/lotus/extern/sector-storage/storiface" -) - -func NewLowestUtilizationAssigner() Assigner { - return &AssignerCommon{ - WindowSel: LowestUtilizationWS, - } -} - -func LowestUtilizationWS(sh *Scheduler, queueLen int, acceptableWindows [][]int, windows []SchedWindow) int { - scheduled := 0 - rmQueue := make([]int, 0, queueLen) - workerUtil := map[storiface.WorkerID]float64{} - - for sqi := 0; sqi < queueLen; sqi++ { - task := (*sh.SchedQueue)[sqi] - - selectedWindow := -1 - var needRes storiface.Resources - var info storiface.WorkerInfo - var bestWid storiface.WorkerID - bestUtilization := math.MaxFloat64 // smaller = better - - for i, wnd := range acceptableWindows[task.IndexHeap] { - wid := sh.OpenWindows[wnd].Worker - w := sh.Workers[wid] - - res := w.Info.Resources.ResourceSpec(task.Sector.ProofType, task.TaskType) - - log.Debugf("SCHED try assign sqi:%d sector %d to window %d (awi:%d)", sqi, task.Sector.ID.Number, wnd, i) - - // TODO: allow bigger windows - if !windows[wnd].Allocated.CanHandleRequest(task.SealTask(), res, wid, "schedAssign", w.Info) { - continue - } - - wu, found := workerUtil[wid] - if !found { - wu = w.Utilization() - workerUtil[wid] = wu - } - if wu >= bestUtilization { - // acceptable worker list is initially sorted by utilization, and the initially-best workers - // will be assigned tasks first. This means that if we find a worker which isn't better, it - // probably means that the other workers aren't better either. - // - // utilization - // ^ - // | / - // | \ / - // | \ / - // | * - // #--------> acceptableWindow index - // - // * -> we're here - break - } - - info = w.Info - needRes = res - bestWid = wid - selectedWindow = wnd - bestUtilization = wu - } - - if selectedWindow < 0 { - // all windows full - continue - } - - log.Debugw("SCHED ASSIGNED", - "sqi", sqi, - "sector", task.Sector.ID.Number, - "task", task.TaskType, - "window", selectedWindow, - "worker", bestWid, - "utilization", bestUtilization) - - workerUtil[bestWid] += windows[selectedWindow].Allocated.Add(task.SealTask(), info.Resources, needRes) - windows[selectedWindow].Todo = append(windows[selectedWindow].Todo, task) - - rmQueue = append(rmQueue, sqi) - scheduled++ - } - - if len(rmQueue) > 0 { - for i := len(rmQueue) - 1; i >= 0; i-- { - sh.SchedQueue.Remove(rmQueue[i]) - } - } - - return scheduled -} diff --git a/extern/sector-storage/sched_post.go b/extern/sector-storage/sched_post.go index 9c3838e08..58d79fc86 100644 --- a/extern/sector-storage/sched_post.go +++ b/extern/sector-storage/sched_post.go @@ -17,7 +17,7 @@ import ( type poStScheduler struct { lk sync.RWMutex - workers map[storiface.WorkerID]*WorkerHandle + workers map[storiface.WorkerID]*workerHandle cond *sync.Cond postType sealtasks.TaskType @@ -25,14 +25,14 @@ type poStScheduler struct { func newPoStScheduler(t sealtasks.TaskType) *poStScheduler { ps := &poStScheduler{ - workers: map[storiface.WorkerID]*WorkerHandle{}, + workers: map[storiface.WorkerID]*workerHandle{}, postType: t, } ps.cond = sync.NewCond(&ps.lk) return ps } -func (ps *poStScheduler) MaybeAddWorker(wid storiface.WorkerID, tasks map[sealtasks.TaskType]struct{}, w *WorkerHandle) bool { +func (ps *poStScheduler) MaybeAddWorker(wid storiface.WorkerID, tasks map[sealtasks.TaskType]struct{}, w *workerHandle) bool { if _, ok := tasks[ps.postType]; !ok { return false } @@ -49,10 +49,10 @@ func (ps *poStScheduler) MaybeAddWorker(wid storiface.WorkerID, tasks map[sealta return true } -func (ps *poStScheduler) delWorker(wid storiface.WorkerID) *WorkerHandle { +func (ps *poStScheduler) delWorker(wid storiface.WorkerID) *workerHandle { ps.lk.Lock() defer ps.lk.Unlock() - var w *WorkerHandle = nil + var w *workerHandle = nil if wh, ok := ps.workers[wid]; ok { w = wh delete(ps.workers, wid) @@ -68,7 +68,7 @@ func (ps *poStScheduler) CanSched(ctx context.Context) bool { } for _, w := range ps.workers { - if w.Enabled { + if w.enabled { return true } } @@ -105,7 +105,7 @@ func (ps *poStScheduler) Schedule(ctx context.Context, primary bool, spt abi.Reg selected := candidates[0] worker := ps.workers[selected.id] - return worker.active.withResources(selected.id, worker.Info, ps.postType.SealTask(spt), selected.res, &ps.lk, func() error { + return worker.active.withResources(selected.id, worker.info, selected.res, &ps.lk, func() error { ps.lk.Unlock() defer ps.lk.Lock() @@ -122,9 +122,9 @@ func (ps *poStScheduler) readyWorkers(spt abi.RegisteredSealProof) (bool, []cand var accepts []candidateWorker //if the gpus of the worker are insufficient or it's disabled, it cannot be scheduled for wid, wr := range ps.workers { - needRes := wr.Info.Resources.ResourceSpec(spt, ps.postType) + needRes := wr.info.Resources.ResourceSpec(spt, ps.postType) - if !wr.active.CanHandleRequest(ps.postType.SealTask(spt), needRes, wid, "post-readyWorkers", wr.Info) { + if !wr.active.canHandleRequest(needRes, wid, "post-readyWorkers", wr.info) { continue } @@ -145,16 +145,16 @@ func (ps *poStScheduler) readyWorkers(spt abi.RegisteredSealProof) (bool, []cand func (ps *poStScheduler) disable(wid storiface.WorkerID) { ps.lk.Lock() defer ps.lk.Unlock() - ps.workers[wid].Enabled = false + ps.workers[wid].enabled = false } func (ps *poStScheduler) enable(wid storiface.WorkerID) { ps.lk.Lock() defer ps.lk.Unlock() - ps.workers[wid].Enabled = true + ps.workers[wid].enabled = true } -func (ps *poStScheduler) watch(wid storiface.WorkerID, worker *WorkerHandle) { +func (ps *poStScheduler) watch(wid storiface.WorkerID, worker *workerHandle) { heartbeatTimer := time.NewTicker(stores.HeartbeatInterval) defer heartbeatTimer.Stop() @@ -197,7 +197,7 @@ func (ps *poStScheduler) watch(wid storiface.WorkerID, worker *WorkerHandle) { } } -func (ps *poStScheduler) workerCleanup(wid storiface.WorkerID, w *WorkerHandle) { +func (ps *poStScheduler) workerCleanup(wid storiface.WorkerID, w *workerHandle) { select { case <-w.closingMgr: default: @@ -223,7 +223,7 @@ func (ps *poStScheduler) schedClose() { } } -func (ps *poStScheduler) WorkerStats(ctx context.Context, cb func(ctx context.Context, wid storiface.WorkerID, worker *WorkerHandle)) { +func (ps *poStScheduler) WorkerStats(ctx context.Context, cb func(ctx context.Context, wid storiface.WorkerID, worker *workerHandle)) { ps.lk.RLock() defer ps.lk.RUnlock() for id, w := range ps.workers { diff --git a/extern/sector-storage/sched_resources.go b/extern/sector-storage/sched_resources.go index 0f1f259b7..458ca981d 100644 --- a/extern/sector-storage/sched_resources.go +++ b/extern/sector-storage/sched_resources.go @@ -9,26 +9,8 @@ import ( "github.com/filecoin-project/lotus/extern/sector-storage/storiface" ) -type ActiveResources struct { - memUsedMin uint64 - memUsedMax uint64 - gpuUsed float64 - cpuUse uint64 - - taskCounters map[sealtasks.SealTaskType]int - - cond *sync.Cond - waiting int -} - -func NewActiveResources() *ActiveResources { - return &ActiveResources{ - taskCounters: map[sealtasks.SealTaskType]int{}, - } -} - -func (a *ActiveResources) withResources(id storiface.WorkerID, wr storiface.WorkerInfo, tt sealtasks.SealTaskType, r storiface.Resources, locker sync.Locker, cb func() error) error { - for !a.CanHandleRequest(tt, r, id, "withResources", wr) { +func (a *activeResources) withResources(id storiface.WorkerID, wr storiface.WorkerInfo, r storiface.Resources, locker sync.Locker, cb func() error) error { + for !a.canHandleRequest(r, id, "withResources", wr) { if a.cond == nil { a.cond = sync.NewCond(locker) } @@ -37,22 +19,22 @@ func (a *ActiveResources) withResources(id storiface.WorkerID, wr storiface.Work a.waiting-- } - a.Add(tt, wr.Resources, r) + a.add(wr.Resources, r) err := cb() - a.Free(tt, wr.Resources, r) + a.free(wr.Resources, r) return err } // must be called with the same lock as the one passed to withResources -func (a *ActiveResources) hasWorkWaiting() bool { +func (a *activeResources) hasWorkWaiting() bool { return a.waiting > 0 } -// add task resources to ActiveResources and return utilization difference -func (a *ActiveResources) Add(tt sealtasks.SealTaskType, wr storiface.WorkerResources, r storiface.Resources) float64 { +// add task resources to activeResources and return utilization difference +func (a *activeResources) add(wr storiface.WorkerResources, r storiface.Resources) float64 { startUtil := a.utilization(wr) if r.GPUUtilization > 0 { @@ -61,35 +43,26 @@ func (a *ActiveResources) Add(tt sealtasks.SealTaskType, wr storiface.WorkerReso a.cpuUse += r.Threads(wr.CPUs, len(wr.GPUs)) a.memUsedMin += r.MinMemory a.memUsedMax += r.MaxMemory - a.taskCounters[tt]++ return a.utilization(wr) - startUtil } -func (a *ActiveResources) Free(tt sealtasks.SealTaskType, wr storiface.WorkerResources, r storiface.Resources) { +func (a *activeResources) free(wr storiface.WorkerResources, r storiface.Resources) { if r.GPUUtilization > 0 { a.gpuUsed -= r.GPUUtilization } a.cpuUse -= r.Threads(wr.CPUs, len(wr.GPUs)) a.memUsedMin -= r.MinMemory a.memUsedMax -= r.MaxMemory - a.taskCounters[tt]-- if a.cond != nil { a.cond.Broadcast() } } -// CanHandleRequest evaluates if the worker has enough available resources to +// canHandleRequest evaluates if the worker has enough available resources to // handle the request. -func (a *ActiveResources) CanHandleRequest(tt sealtasks.SealTaskType, needRes storiface.Resources, wid storiface.WorkerID, caller string, info storiface.WorkerInfo) bool { - if needRes.MaxConcurrent > 0 { - if a.taskCounters[tt] >= needRes.MaxConcurrent { - log.Debugf("sched: not scheduling on worker %s for %s; at task limit tt=%s, curcount=%d", wid, caller, tt, a.taskCounters[tt]) - return false - } - } - +func (a *activeResources) canHandleRequest(needRes storiface.Resources, wid storiface.WorkerID, caller string, info storiface.WorkerInfo) bool { if info.IgnoreResources { // shortcircuit; if this worker is ignoring resources, it can always handle the request. return true @@ -137,7 +110,7 @@ func (a *ActiveResources) CanHandleRequest(tt sealtasks.SealTaskType, needRes st } // utilization returns a number in 0..1 range indicating fraction of used resources -func (a *ActiveResources) utilization(wr storiface.WorkerResources) float64 { // todo task type +func (a *activeResources) utilization(wr storiface.WorkerResources) float64 { var max float64 cpu := float64(a.cpuUse) / float64(wr.CPUs) @@ -172,14 +145,14 @@ func (a *ActiveResources) utilization(wr storiface.WorkerResources) float64 { // return max } -func (wh *WorkerHandle) Utilization() float64 { +func (wh *workerHandle) utilization() float64 { wh.lk.Lock() - u := wh.active.utilization(wh.Info.Resources) - u += wh.preparing.utilization(wh.Info.Resources) + u := wh.active.utilization(wh.info.Resources) + u += wh.preparing.utilization(wh.info.Resources) wh.lk.Unlock() wh.wndLk.Lock() for _, window := range wh.activeWindows { - u += window.Allocated.utilization(wh.Info.Resources) + u += window.allocated.utilization(wh.info.Resources) } wh.wndLk.Unlock() @@ -188,7 +161,7 @@ func (wh *WorkerHandle) Utilization() float64 { var tasksCacheTimeout = 30 * time.Second -func (wh *WorkerHandle) TaskTypes(ctx context.Context) (t map[sealtasks.TaskType]struct{}, err error) { +func (wh *workerHandle) TaskTypes(ctx context.Context) (t map[sealtasks.TaskType]struct{}, err error) { wh.tasksLk.Lock() defer wh.tasksLk.Unlock() diff --git a/extern/sector-storage/sched_test.go b/extern/sector-storage/sched_test.go index 507fda1b8..d913fdb9e 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" @@ -68,10 +69,6 @@ type schedTestWorker struct { ignoreResources bool } -func (s *schedTestWorker) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (storiface.CallID, error) { - panic("implement me") -} - func (s *schedTestWorker) SealPreCommit1(ctx context.Context, sector storage.SectorRef, ticket abi.SealRandomness, pieces []abi.PieceInfo) (storiface.CallID, error) { panic("implement me") } @@ -144,7 +141,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") } @@ -183,7 +180,7 @@ func (s *schedTestWorker) Close() error { var _ Worker = &schedTestWorker{} -func addTestWorker(t *testing.T, sched *Scheduler, index *stores.Index, name string, taskTypes map[sealtasks.TaskType]struct{}, resources storiface.WorkerResources, ignoreResources bool) { +func addTestWorker(t *testing.T, sched *scheduler, index *stores.Index, name string, taskTypes map[sealtasks.TaskType]struct{}, resources storiface.WorkerResources, ignoreResources bool) { w := &schedTestWorker{ name: name, taskTypes: taskTypes, @@ -223,8 +220,7 @@ func addTestWorker(t *testing.T, sched *Scheduler, index *stores.Index, name str } func TestSchedStartStop(t *testing.T) { - sched, err := newScheduler("") - require.NoError(t, err) + sched := newScheduler() go sched.runSched() addTestWorker(t, sched, stores.NewIndex(), "fred", nil, decentWorkerResources, false) @@ -260,13 +256,13 @@ func TestSched(t *testing.T) { wg sync.WaitGroup } - type task func(*testing.T, *Scheduler, *stores.Index, *runMeta) + type task func(*testing.T, *scheduler, *stores.Index, *runMeta) sched := func(taskName, expectWorker string, sid abi.SectorNumber, taskType sealtasks.TaskType) task { _, _, l, _ := runtime.Caller(1) _, _, l2, _ := runtime.Caller(2) - return func(t *testing.T, sched *Scheduler, index *stores.Index, rm *runMeta) { + return func(t *testing.T, sched *scheduler, index *stores.Index, rm *runMeta) { done := make(chan struct{}) rm.done[taskName] = done @@ -315,7 +311,7 @@ func TestSched(t *testing.T) { taskStarted := func(name string) task { _, _, l, _ := runtime.Caller(1) _, _, l2, _ := runtime.Caller(2) - return func(t *testing.T, sched *Scheduler, index *stores.Index, rm *runMeta) { + return func(t *testing.T, sched *scheduler, index *stores.Index, rm *runMeta) { select { case rm.done[name] <- struct{}{}: case <-ctx.Done(): @@ -327,7 +323,7 @@ func TestSched(t *testing.T) { taskDone := func(name string) task { _, _, l, _ := runtime.Caller(1) _, _, l2, _ := runtime.Caller(2) - return func(t *testing.T, sched *Scheduler, index *stores.Index, rm *runMeta) { + return func(t *testing.T, sched *scheduler, index *stores.Index, rm *runMeta) { select { case rm.done[name] <- struct{}{}: case <-ctx.Done(): @@ -340,7 +336,7 @@ func TestSched(t *testing.T) { taskNotScheduled := func(name string) task { _, _, l, _ := runtime.Caller(1) _, _, l2, _ := runtime.Caller(2) - return func(t *testing.T, sched *Scheduler, index *stores.Index, rm *runMeta) { + return func(t *testing.T, sched *scheduler, index *stores.Index, rm *runMeta) { select { case rm.done[name] <- struct{}{}: t.Fatal("not expected", l, l2) @@ -353,8 +349,7 @@ func TestSched(t *testing.T) { return func(t *testing.T) { index := stores.NewIndex() - sched, err := newScheduler("") - require.NoError(t, err) + sched := newScheduler() sched.testSync = make(chan struct{}) go sched.runSched() @@ -380,7 +375,7 @@ func TestSched(t *testing.T) { } multTask := func(tasks ...task) task { - return func(t *testing.T, s *Scheduler, index *stores.Index, meta *runMeta) { + return func(t *testing.T, s *scheduler, index *stores.Index, meta *runMeta) { for _, tsk := range tasks { tsk(t, s, index, meta) } @@ -494,7 +489,7 @@ func TestSched(t *testing.T) { } diag := func() task { - return func(t *testing.T, s *Scheduler, index *stores.Index, meta *runMeta) { + return func(t *testing.T, s *scheduler, index *stores.Index, meta *runMeta) { time.Sleep(20 * time.Millisecond) for _, request := range s.diag().Requests { log.Infof("!!! sDIAG: sid(%d) task(%s)", request.Sector.Number, request.TaskType) @@ -584,12 +579,12 @@ func TestSched(t *testing.T) { type slowishSelector bool -func (s slowishSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a *WorkerHandle) (bool, bool, error) { +func (s slowishSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, a *workerHandle) (bool, error) { time.Sleep(200 * time.Microsecond) - return bool(s), false, nil + return bool(s), nil } -func (s slowishSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) { +func (s slowishSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *workerHandle) (bool, error) { time.Sleep(100 * time.Microsecond) return true, nil } @@ -606,30 +601,29 @@ func BenchmarkTrySched(b *testing.B) { for i := 0; i < b.N; i++ { b.StopTimer() - sched, err := newScheduler("") - require.NoError(b, err) - sched.Workers[storiface.WorkerID{}] = &WorkerHandle{ + sched := newScheduler() + sched.workers[storiface.WorkerID{}] = &workerHandle{ workerRpc: nil, - Info: storiface.WorkerInfo{ + info: storiface.WorkerInfo{ Hostname: "t", Resources: decentWorkerResources, }, - preparing: NewActiveResources(), - active: NewActiveResources(), + preparing: &activeResources{}, + active: &activeResources{}, } for i := 0; i < windows; i++ { - sched.OpenWindows = append(sched.OpenWindows, &SchedWindowRequest{ - Worker: storiface.WorkerID{}, - Done: make(chan *SchedWindow, 1000), + sched.openWindows = append(sched.openWindows, &schedWindowRequest{ + worker: storiface.WorkerID{}, + done: make(chan *schedWindow, 1000), }) } for i := 0; i < queue; i++ { - sched.SchedQueue.Push(&WorkerRequest{ - TaskType: sealtasks.TTCommit2, - Sel: slowishSelector(true), - Ctx: ctx, + sched.schedQueue.Push(&workerRequest{ + taskType: sealtasks.TTCommit2, + sel: slowishSelector(true), + ctx: ctx, }) } @@ -647,28 +641,26 @@ func BenchmarkTrySched(b *testing.B) { } func TestWindowCompact(t *testing.T) { - sh := Scheduler{} + sh := scheduler{} spt := abi.RegisteredSealProof_StackedDrg32GiBV1 test := func(start [][]sealtasks.TaskType, expect [][]sealtasks.TaskType) func(t *testing.T) { return func(t *testing.T) { - wh := &WorkerHandle{ - Info: storiface.WorkerInfo{ + wh := &workerHandle{ + info: storiface.WorkerInfo{ Resources: decentWorkerResources, }, } for _, windowTasks := range start { - window := &SchedWindow{ - Allocated: *NewActiveResources(), - } + window := &schedWindow{} for _, task := range windowTasks { - window.Todo = append(window.Todo, &WorkerRequest{ - TaskType: task, - Sector: storage.SectorRef{ProofType: spt}, + window.todo = append(window.todo, &workerRequest{ + taskType: task, + sector: storage.SectorRef{ProofType: spt}, }) - window.Allocated.Add(task.SealTask(spt), wh.Info.Resources, storiface.ResourceTable[task][spt]) + window.allocated.add(wh.info.Resources, storiface.ResourceTable[task][spt]) } wh.activeWindows = append(wh.activeWindows, window) @@ -683,17 +675,17 @@ func TestWindowCompact(t *testing.T) { require.Equal(t, len(start)-len(expect), -sw.windowsRequested) for wi, tasks := range expect { - expectRes := NewActiveResources() + var expectRes activeResources for ti, task := range tasks { - require.Equal(t, task, wh.activeWindows[wi].Todo[ti].TaskType, "%d, %d", wi, ti) - expectRes.Add(task.SealTask(spt), wh.Info.Resources, storiface.ResourceTable[task][spt]) + require.Equal(t, task, wh.activeWindows[wi].todo[ti].taskType, "%d, %d", wi, ti) + expectRes.add(wh.info.Resources, storiface.ResourceTable[task][spt]) } - require.Equal(t, expectRes.cpuUse, wh.activeWindows[wi].Allocated.cpuUse, "%d", wi) - require.Equal(t, expectRes.gpuUsed, wh.activeWindows[wi].Allocated.gpuUsed, "%d", wi) - require.Equal(t, expectRes.memUsedMin, wh.activeWindows[wi].Allocated.memUsedMin, "%d", wi) - require.Equal(t, expectRes.memUsedMax, wh.activeWindows[wi].Allocated.memUsedMax, "%d", wi) + require.Equal(t, expectRes.cpuUse, wh.activeWindows[wi].allocated.cpuUse, "%d", wi) + require.Equal(t, expectRes.gpuUsed, wh.activeWindows[wi].allocated.gpuUsed, "%d", wi) + require.Equal(t, expectRes.memUsedMin, wh.activeWindows[wi].allocated.memUsedMin, "%d", wi) + require.Equal(t, expectRes.memUsedMax, wh.activeWindows[wi].allocated.memUsedMax, "%d", wi) } } diff --git a/extern/sector-storage/sched_worker.go b/extern/sector-storage/sched_worker.go index c9b019ad0..f0a85ea3f 100644 --- a/extern/sector-storage/sched_worker.go +++ b/extern/sector-storage/sched_worker.go @@ -12,31 +12,31 @@ import ( ) type schedWorker struct { - sched *Scheduler - worker *WorkerHandle + sched *scheduler + worker *workerHandle wid storiface.WorkerID heartbeatTimer *time.Ticker - scheduledWindows chan *SchedWindow + scheduledWindows chan *schedWindow taskDone chan struct{} windowsRequested int } -func newWorkerHandle(ctx context.Context, w Worker) (*WorkerHandle, error) { +func newWorkerHandle(ctx context.Context, w Worker) (*workerHandle, error) { info, err := w.Info(ctx) if err != nil { return nil, xerrors.Errorf("getting worker info: %w", err) } - worker := &WorkerHandle{ + worker := &workerHandle{ workerRpc: w, - Info: info, + info: info, - preparing: NewActiveResources(), - active: NewActiveResources(), - Enabled: true, + preparing: &activeResources{}, + active: &activeResources{}, + enabled: true, closingMgr: make(chan struct{}), closedMgr: make(chan struct{}), @@ -46,9 +46,9 @@ func newWorkerHandle(ctx context.Context, w Worker) (*WorkerHandle, error) { } // context only used for startup -func (sh *Scheduler) runWorker(ctx context.Context, wid storiface.WorkerID, worker *WorkerHandle) error { +func (sh *scheduler) runWorker(ctx context.Context, wid storiface.WorkerID, worker *workerHandle) error { sh.workersLk.Lock() - _, exist := sh.Workers[wid] + _, exist := sh.workers[wid] if exist { log.Warnw("duplicated worker added", "id", wid) @@ -57,7 +57,7 @@ func (sh *Scheduler) runWorker(ctx context.Context, wid storiface.WorkerID, work return nil } - sh.Workers[wid] = worker + sh.workers[wid] = worker sh.workersLk.Unlock() sw := &schedWorker{ @@ -67,7 +67,7 @@ func (sh *Scheduler) runWorker(ctx context.Context, wid storiface.WorkerID, work wid: wid, heartbeatTimer: time.NewTicker(stores.HeartbeatInterval), - scheduledWindows: make(chan *SchedWindow, SchedWindows), + scheduledWindows: make(chan *schedWindow, SchedWindows), taskDone: make(chan struct{}, 1), windowsRequested: 0, @@ -94,7 +94,7 @@ func (sw *schedWorker) handleWorker() { } sched.workersLk.Lock() - delete(sched.Workers, sw.wid) + delete(sched.workers, sw.wid) sched.workersLk.Unlock() }() @@ -103,7 +103,7 @@ func (sw *schedWorker) handleWorker() { for { { sched.workersLk.Lock() - enabled := worker.Enabled + enabled := worker.enabled sched.workersLk.Unlock() // ask for more windows if we need them (non-blocking) @@ -124,8 +124,8 @@ func (sw *schedWorker) handleWorker() { // session looks good { sched.workersLk.Lock() - enabled := worker.Enabled - worker.Enabled = true + enabled := worker.enabled + worker.enabled = true sched.workersLk.Unlock() if !enabled { @@ -248,9 +248,9 @@ func (sw *schedWorker) checkSession(ctx context.Context) bool { func (sw *schedWorker) requestWindows() bool { for ; sw.windowsRequested < SchedWindows; sw.windowsRequested++ { select { - case sw.sched.windowRequests <- &SchedWindowRequest{ - Worker: sw.wid, - Done: sw.scheduledWindows, + case sw.sched.windowRequests <- &schedWindowRequest{ + worker: sw.wid, + done: sw.scheduledWindows, }: case <-sw.sched.closing: return false @@ -290,21 +290,21 @@ func (sw *schedWorker) workerCompactWindows() { lower := worker.activeWindows[wi] var moved []int - for ti, todo := range window.Todo { - needRes := worker.Info.Resources.ResourceSpec(todo.Sector.ProofType, todo.TaskType) - if !lower.Allocated.CanHandleRequest(todo.SealTask(), needRes, sw.wid, "compactWindows", worker.Info) { + for ti, todo := range window.todo { + needRes := worker.info.Resources.ResourceSpec(todo.sector.ProofType, todo.taskType) + if !lower.allocated.canHandleRequest(needRes, sw.wid, "compactWindows", worker.info) { continue } moved = append(moved, ti) - lower.Todo = append(lower.Todo, todo) - lower.Allocated.Add(todo.SealTask(), worker.Info.Resources, needRes) - window.Allocated.Free(todo.SealTask(), worker.Info.Resources, needRes) + lower.todo = append(lower.todo, todo) + lower.allocated.add(worker.info.Resources, needRes) + window.allocated.free(worker.info.Resources, needRes) } if len(moved) > 0 { - newTodo := make([]*WorkerRequest, 0, len(window.Todo)-len(moved)) - for i, t := range window.Todo { + newTodo := make([]*workerRequest, 0, len(window.todo)-len(moved)) + for i, t := range window.todo { if len(moved) > 0 && moved[0] == i { moved = moved[1:] continue @@ -312,16 +312,16 @@ func (sw *schedWorker) workerCompactWindows() { newTodo = append(newTodo, t) } - window.Todo = newTodo + window.todo = newTodo } } } var compacted int - var newWindows []*SchedWindow + var newWindows []*schedWindow for _, window := range worker.activeWindows { - if len(window.Todo) == 0 { + if len(window.todo) == 0 { compacted++ continue } @@ -347,13 +347,13 @@ assignLoop: firstWindow := worker.activeWindows[0] // process tasks within a window, preferring tasks at lower indexes - for len(firstWindow.Todo) > 0 { + for len(firstWindow.todo) > 0 { tidx := -1 worker.lk.Lock() - for t, todo := range firstWindow.Todo { - needRes := worker.Info.Resources.ResourceSpec(todo.Sector.ProofType, todo.TaskType) - if worker.preparing.CanHandleRequest(todo.SealTask(), needRes, sw.wid, "startPreparing", worker.Info) { + for t, todo := range firstWindow.todo { + needRes := worker.info.Resources.ResourceSpec(todo.sector.ProofType, todo.taskType) + if worker.preparing.canHandleRequest(needRes, sw.wid, "startPreparing", worker.info) { tidx = t break } @@ -364,9 +364,9 @@ assignLoop: break assignLoop } - todo := firstWindow.Todo[tidx] + todo := firstWindow.todo[tidx] - log.Debugf("assign worker sector %d", todo.Sector.ID.Number) + log.Debugf("assign worker sector %d", todo.sector.ID.Number) err := sw.startProcessingTask(todo) if err != nil { @@ -375,9 +375,9 @@ assignLoop: } // Note: we're not freeing window.allocated resources here very much on purpose - copy(firstWindow.Todo[tidx:], firstWindow.Todo[tidx+1:]) - firstWindow.Todo[len(firstWindow.Todo)-1] = nil - firstWindow.Todo = firstWindow.Todo[:len(firstWindow.Todo)-1] + copy(firstWindow.todo[tidx:], firstWindow.todo[tidx+1:]) + firstWindow.todo[len(firstWindow.todo)-1] = nil + firstWindow.todo = firstWindow.todo[:len(firstWindow.todo)-1] } copy(worker.activeWindows, worker.activeWindows[1:]) @@ -405,16 +405,16 @@ assignLoop: firstWindow := worker.activeWindows[0] // process tasks within a window, preferring tasks at lower indexes - for len(firstWindow.Todo) > 0 { + for len(firstWindow.todo) > 0 { tidx := -1 - for t, todo := range firstWindow.Todo { - if todo.TaskType != sealtasks.TTCommit1 && todo.TaskType != sealtasks.TTCommit2 { // todo put in task + for t, todo := range firstWindow.todo { + if todo.taskType != sealtasks.TTCommit1 && todo.taskType != sealtasks.TTCommit2 { // todo put in task continue } - needRes := worker.Info.Resources.ResourceSpec(todo.Sector.ProofType, todo.TaskType) - if worker.active.CanHandleRequest(todo.SealTask(), needRes, sw.wid, "startPreparing", worker.Info) { + needRes := storiface.ResourceTable[todo.taskType][todo.sector.ProofType] + if worker.active.canHandleRequest(needRes, sw.wid, "startPreparing", worker.info) { tidx = t break } @@ -424,9 +424,9 @@ assignLoop: break assignLoop } - todo := firstWindow.Todo[tidx] + todo := firstWindow.todo[tidx] - log.Debugf("assign worker sector %d (ready)", todo.Sector.ID.Number) + log.Debugf("assign worker sector %d (ready)", todo.sector.ID.Number) err := sw.startProcessingReadyTask(todo) if err != nil { @@ -435,9 +435,9 @@ assignLoop: } // Note: we're not freeing window.allocated resources here very much on purpose - copy(firstWindow.Todo[tidx:], firstWindow.Todo[tidx+1:]) - firstWindow.Todo[len(firstWindow.Todo)-1] = nil - firstWindow.Todo = firstWindow.Todo[:len(firstWindow.Todo)-1] + copy(firstWindow.todo[tidx:], firstWindow.todo[tidx+1:]) + firstWindow.todo[len(firstWindow.todo)-1] = nil + firstWindow.todo = firstWindow.todo[:len(firstWindow.todo)-1] } copy(worker.activeWindows, worker.activeWindows[1:]) @@ -448,24 +448,24 @@ assignLoop: } } -func (sw *schedWorker) startProcessingTask(req *WorkerRequest) error { +func (sw *schedWorker) startProcessingTask(req *workerRequest) error { w, sh := sw.worker, sw.sched - needRes := w.Info.Resources.ResourceSpec(req.Sector.ProofType, req.TaskType) + needRes := w.info.Resources.ResourceSpec(req.sector.ProofType, req.taskType) w.lk.Lock() - w.preparing.Add(req.SealTask(), w.Info.Resources, needRes) + w.preparing.add(w.info.Resources, needRes) w.lk.Unlock() go func() { // first run the prepare step (e.g. fetching sector data from other worker) - tw := sh.workTracker.worker(sw.wid, w.Info, w.workerRpc) + tw := sh.workTracker.worker(sw.wid, w.info, w.workerRpc) tw.start() - err := req.prepare(req.Ctx, tw) + err := req.prepare(req.ctx, tw) w.lk.Lock() if err != nil { - w.preparing.Free(req.SealTask(), w.Info.Resources, needRes) + w.preparing.free(w.info.Resources, needRes) w.lk.Unlock() select { @@ -477,7 +477,7 @@ func (sw *schedWorker) startProcessingTask(req *WorkerRequest) error { select { case req.ret <- workerResponse{err: err}: - case <-req.Ctx.Done(): + case <-req.ctx.Done(): log.Warnf("request got cancelled before we could respond (prepare error: %+v)", err) case <-sh.closing: log.Warnf("scheduler closed while sending response (prepare error: %+v)", err) @@ -485,17 +485,17 @@ func (sw *schedWorker) startProcessingTask(req *WorkerRequest) error { return } - tw = sh.workTracker.worker(sw.wid, w.Info, w.workerRpc) + tw = sh.workTracker.worker(sw.wid, w.info, w.workerRpc) // start tracking work first early in case we need to wait for resources werr := make(chan error, 1) go func() { - werr <- req.work(req.Ctx, tw) + werr <- req.work(req.ctx, tw) }() // wait (if needed) for resources in the 'active' window - err = w.active.withResources(sw.wid, w.Info, req.SealTask(), needRes, &w.lk, func() error { - w.preparing.Free(req.SealTask(), w.Info.Resources, needRes) + err = w.active.withResources(sw.wid, w.info, needRes, &w.lk, func() error { + w.preparing.free(w.info.Resources, needRes) w.lk.Unlock() defer w.lk.Lock() // we MUST return locked from this function @@ -511,7 +511,7 @@ func (sw *schedWorker) startProcessingTask(req *WorkerRequest) error { select { case req.ret <- workerResponse{err: err}: - case <-req.Ctx.Done(): + case <-req.ctx.Done(): log.Warnf("request got cancelled before we could respond") case <-sh.closing: log.Warnf("scheduler closed while sending response") @@ -531,22 +531,22 @@ func (sw *schedWorker) startProcessingTask(req *WorkerRequest) error { return nil } -func (sw *schedWorker) startProcessingReadyTask(req *WorkerRequest) error { +func (sw *schedWorker) startProcessingReadyTask(req *workerRequest) error { w, sh := sw.worker, sw.sched - needRes := w.Info.Resources.ResourceSpec(req.Sector.ProofType, req.TaskType) + needRes := w.info.Resources.ResourceSpec(req.sector.ProofType, req.taskType) - w.active.Add(req.SealTask(), w.Info.Resources, needRes) + w.active.add(w.info.Resources, needRes) go func() { // Do the work! - tw := sh.workTracker.worker(sw.wid, w.Info, w.workerRpc) + tw := sh.workTracker.worker(sw.wid, w.info, w.workerRpc) tw.start() - err := req.work(req.Ctx, tw) + err := req.work(req.ctx, tw) select { case req.ret <- workerResponse{err: err}: - case <-req.Ctx.Done(): + case <-req.ctx.Done(): log.Warnf("request got cancelled before we could respond") case <-sh.closing: log.Warnf("scheduler closed while sending response") @@ -554,7 +554,7 @@ func (sw *schedWorker) startProcessingReadyTask(req *WorkerRequest) error { w.lk.Lock() - w.active.Free(req.SealTask(), w.Info.Resources, needRes) + w.active.free(w.info.Resources, needRes) select { case sw.taskDone <- struct{}{}: @@ -574,7 +574,7 @@ func (sw *schedWorker) startProcessingReadyTask(req *WorkerRequest) error { return nil } -func (sh *Scheduler) workerCleanup(wid storiface.WorkerID, w *WorkerHandle) { +func (sh *scheduler) workerCleanup(wid storiface.WorkerID, w *workerHandle) { select { case <-w.closingMgr: default: @@ -592,13 +592,13 @@ func (sh *Scheduler) workerCleanup(wid storiface.WorkerID, w *WorkerHandle) { if !w.cleanupStarted { w.cleanupStarted = true - newWindows := make([]*SchedWindowRequest, 0, len(sh.OpenWindows)) - for _, window := range sh.OpenWindows { - if window.Worker != wid { + newWindows := make([]*schedWindowRequest, 0, len(sh.openWindows)) + for _, window := range sh.openWindows { + if window.worker != wid { newWindows = append(newWindows, window) } } - sh.OpenWindows = newWindows + sh.openWindows = newWindows log.Debugf("worker %s dropped", wid) } diff --git a/extern/sector-storage/sealtasks/task.go b/extern/sector-storage/sealtasks/task.go index 061e84c7f..1d3d3c1b5 100644 --- a/extern/sector-storage/sealtasks/task.go +++ b/extern/sector-storage/sealtasks/task.go @@ -1,19 +1,8 @@ package sealtasks -import ( - "fmt" - "strconv" - "strings" - - "golang.org/x/xerrors" - - "github.com/filecoin-project/go-state-types/abi" -) - type TaskType string const ( - TTDataCid TaskType = "seal/v0/datacid" TTAddPiece TaskType = "seal/v0/addpiece" TTPreCommit1 TaskType = "seal/v0/precommit/1" TTPreCommit2 TaskType = "seal/v0/precommit/2" @@ -36,8 +25,7 @@ const ( ) var order = map[TaskType]int{ - TTRegenSectorKey: 11, // least priority - TTDataCid: 10, + TTRegenSectorKey: 10, // least priority TTAddPiece: 9, TTReplicaUpdate: 8, TTProveReplicaUpdate2: 7, @@ -56,7 +44,6 @@ var order = map[TaskType]int{ } var shortNames = map[TaskType]string{ - TTDataCid: "DC", TTAddPiece: "AP", TTPreCommit1: "PC1", @@ -114,37 +101,3 @@ func (a TaskType) Short() string { return n } - -type SealTaskType struct { - TaskType - abi.RegisteredSealProof -} - -func (a TaskType) SealTask(spt abi.RegisteredSealProof) SealTaskType { - return SealTaskType{ - TaskType: a, - RegisteredSealProof: spt, - } -} - -func SttFromString(s string) (SealTaskType, error) { - var res SealTaskType - - sub := strings.SplitN(s, ":", 2) - if len(sub) != 2 { - return res, xerrors.Errorf("seal task type string invalid") - } - - res.TaskType = TaskType(sub[1]) - spt, err := strconv.ParseInt(sub[0], 10, 64) - if err != nil { - return SealTaskType{}, err - } - res.RegisteredSealProof = abi.RegisteredSealProof(spt) - - return res, nil -} - -func (a SealTaskType) String() string { - return fmt.Sprintf("%d:%s", a.RegisteredSealProof, a.TaskType) -} diff --git a/extern/sector-storage/selector_alloc.go b/extern/sector-storage/selector_alloc.go index ffdf35b5e..fe6a11e1e 100644 --- a/extern/sector-storage/selector_alloc.go +++ b/extern/sector-storage/selector_alloc.go @@ -26,18 +26,18 @@ func newAllocSelector(index stores.SectorIndex, alloc storiface.SectorFileType, } } -func (s *allocSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *WorkerHandle) (bool, bool, error) { +func (s *allocSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *workerHandle) (bool, error) { tasks, err := whnd.TaskTypes(ctx) if err != nil { - return false, false, xerrors.Errorf("getting supported worker task types: %w", err) + return false, xerrors.Errorf("getting supported worker task types: %w", err) } if _, supported := tasks[task]; !supported { - return false, false, nil + return false, nil } paths, err := whnd.workerRpc.Paths(ctx) if err != nil { - return false, false, xerrors.Errorf("getting worker paths: %w", err) + return false, xerrors.Errorf("getting worker paths: %w", err) } have := map[storiface.ID]struct{}{} @@ -47,25 +47,25 @@ func (s *allocSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi ssize, err := spt.SectorSize() if err != nil { - return false, false, xerrors.Errorf("getting sector size: %w", err) + return false, xerrors.Errorf("getting sector size: %w", err) } best, err := s.index.StorageBestAlloc(ctx, s.alloc, ssize, s.ptype) if err != nil { - return false, false, xerrors.Errorf("finding best alloc storage: %w", err) + return false, xerrors.Errorf("finding best alloc storage: %w", err) } for _, info := range best { if _, ok := have[info.ID]; ok { - return true, false, nil + return true, nil } } - return false, false, nil + return false, nil } -func (s *allocSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) { - return a.Utilization() < b.Utilization(), nil +func (s *allocSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *workerHandle) (bool, error) { + return a.utilization() < b.utilization(), nil } var _ WorkerSelector = &allocSelector{} diff --git a/extern/sector-storage/selector_existing.go b/extern/sector-storage/selector_existing.go index 78a3b1988..b84991b5c 100644 --- a/extern/sector-storage/selector_existing.go +++ b/extern/sector-storage/selector_existing.go @@ -28,18 +28,18 @@ func newExistingSelector(index stores.SectorIndex, sector abi.SectorID, alloc st } } -func (s *existingSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *WorkerHandle) (bool, bool, error) { +func (s *existingSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *workerHandle) (bool, error) { tasks, err := whnd.TaskTypes(ctx) if err != nil { - return false, false, xerrors.Errorf("getting supported worker task types: %w", err) + return false, xerrors.Errorf("getting supported worker task types: %w", err) } if _, supported := tasks[task]; !supported { - return false, false, nil + return false, nil } paths, err := whnd.workerRpc.Paths(ctx) if err != nil { - return false, false, xerrors.Errorf("getting worker paths: %w", err) + return false, xerrors.Errorf("getting worker paths: %w", err) } have := map[storiface.ID]struct{}{} @@ -49,25 +49,25 @@ func (s *existingSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt ssize, err := spt.SectorSize() if err != nil { - return false, false, xerrors.Errorf("getting sector size: %w", err) + return false, xerrors.Errorf("getting sector size: %w", err) } best, err := s.index.StorageFindSector(ctx, s.sector, s.alloc, ssize, s.allowFetch) if err != nil { - return false, false, xerrors.Errorf("finding best storage: %w", err) + return false, xerrors.Errorf("finding best storage: %w", err) } for _, info := range best { if _, ok := have[info.ID]; ok { - return true, false, nil + return true, nil } } - return false, false, nil + return false, nil } -func (s *existingSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) { - return a.Utilization() < b.Utilization(), nil +func (s *existingSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *workerHandle) (bool, error) { + return a.utilization() < b.utilization(), nil } var _ WorkerSelector = &existingSelector{} diff --git a/extern/sector-storage/selector_move.go b/extern/sector-storage/selector_move.go deleted file mode 100644 index 7c63691b1..000000000 --- a/extern/sector-storage/selector_move.go +++ /dev/null @@ -1,98 +0,0 @@ -package sectorstorage - -import ( - "context" - - "golang.org/x/xerrors" - - "github.com/filecoin-project/go-state-types/abi" - - "github.com/filecoin-project/lotus/extern/sector-storage/sealtasks" - "github.com/filecoin-project/lotus/extern/sector-storage/stores" - "github.com/filecoin-project/lotus/extern/sector-storage/storiface" -) - -type moveSelector struct { - index stores.SectorIndex - sector abi.SectorID - alloc storiface.SectorFileType - destPtype storiface.PathType - allowRemote bool -} - -func newMoveSelector(index stores.SectorIndex, sector abi.SectorID, alloc storiface.SectorFileType, destPtype storiface.PathType, allowRemote bool) *moveSelector { - return &moveSelector{ - index: index, - sector: sector, - alloc: alloc, - destPtype: destPtype, - allowRemote: allowRemote, - } -} - -func (s *moveSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *WorkerHandle) (bool, bool, error) { - tasks, err := whnd.TaskTypes(ctx) - if err != nil { - return false, false, xerrors.Errorf("getting supported worker task types: %w", err) - } - if _, supported := tasks[task]; !supported { - return false, false, nil - } - - paths, err := whnd.workerRpc.Paths(ctx) - if err != nil { - return false, false, xerrors.Errorf("getting worker paths: %w", err) - } - - workerPaths := map[storiface.ID]int{} - for _, path := range paths { - workerPaths[path.ID] = 0 - } - - ssize, err := spt.SectorSize() - if err != nil { - return false, false, xerrors.Errorf("getting sector size: %w", err) - } - - // note: allowFetch is always false here, because we want to find workers with - // the sector available locally - preferred, err := s.index.StorageFindSector(ctx, s.sector, s.alloc, ssize, false) - if err != nil { - return false, false, xerrors.Errorf("finding preferred storage: %w", err) - } - - for _, info := range preferred { - if _, ok := workerPaths[info.ID]; ok { - workerPaths[info.ID]++ - } - } - - best, err := s.index.StorageBestAlloc(ctx, s.alloc, ssize, s.destPtype) - if err != nil { - return false, false, xerrors.Errorf("finding best dest storage: %w", err) - } - - var ok bool - - for _, info := range best { - if n, has := workerPaths[info.ID]; has { - ok = true - - // if the worker has a local path with the sector already in it - // prefer that worker; This usually meant that the move operation is - // either a no-op because the sector is already in the correct path, - // or the move a local move. - if n > 0 { - return true, true, nil - } - } - } - - return ok && s.allowRemote, false, nil -} - -func (s *moveSelector) Cmp(ctx context.Context, task sealtasks.TaskType, a, b *WorkerHandle) (bool, error) { - return a.Utilization() < b.Utilization(), nil -} - -var _ WorkerSelector = &moveSelector{} diff --git a/extern/sector-storage/selector_task.go b/extern/sector-storage/selector_task.go index d5ea9618b..94bcb4419 100644 --- a/extern/sector-storage/selector_task.go +++ b/extern/sector-storage/selector_task.go @@ -19,17 +19,17 @@ func newTaskSelector() *taskSelector { return &taskSelector{} } -func (s *taskSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *WorkerHandle) (bool, bool, error) { +func (s *taskSelector) Ok(ctx context.Context, task sealtasks.TaskType, spt abi.RegisteredSealProof, whnd *workerHandle) (bool, error) { tasks, err := whnd.TaskTypes(ctx) if err != nil { - return false, false, xerrors.Errorf("getting supported worker task types: %w", err) + return false, xerrors.Errorf("getting supported worker task types: %w", err) } _, supported := tasks[task] - return supported, false, nil + return supported, nil } -func (s *taskSelector) Cmp(ctx context.Context, _ sealtasks.TaskType, a, b *WorkerHandle) (bool, error) { +func (s *taskSelector) Cmp(ctx context.Context, _ sealtasks.TaskType, a, b *workerHandle) (bool, error) { atasks, err := a.TaskTypes(ctx) if err != nil { return false, xerrors.Errorf("getting supported worker task types: %w", err) @@ -43,7 +43,7 @@ func (s *taskSelector) Cmp(ctx context.Context, _ sealtasks.TaskType, a, b *Work return len(atasks) < len(btasks), nil // prefer workers which can do less } - return a.Utilization() < b.Utilization(), nil + return a.utilization() < b.utilization(), nil } var _ WorkerSelector = &taskSelector{} diff --git a/extern/sector-storage/stats.go b/extern/sector-storage/stats.go index 56866793b..9b374f328 100644 --- a/extern/sector-storage/stats.go +++ b/extern/sector-storage/stats.go @@ -15,7 +15,7 @@ func (m *Manager) WorkerStats(ctx context.Context) map[uuid.UUID]storiface.Worke out := map[uuid.UUID]storiface.WorkerStats{} - cb := func(ctx context.Context, id storiface.WorkerID, handle *WorkerHandle) { + cb := func(ctx context.Context, id storiface.WorkerID, handle *workerHandle) { handle.lk.Lock() ctx, cancel := context.WithTimeout(ctx, 3*time.Second) @@ -32,25 +32,18 @@ func (m *Manager) WorkerStats(ctx context.Context) map[uuid.UUID]storiface.Worke } out[uuid.UUID(id)] = storiface.WorkerStats{ - Info: handle.Info, + Info: handle.info, Tasks: taskList, - Enabled: handle.Enabled, + Enabled: handle.enabled, MemUsedMin: handle.active.memUsedMin, MemUsedMax: handle.active.memUsedMax, GpuUsed: handle.active.gpuUsed, CpuUse: handle.active.cpuUse, - - TaskCounts: map[string]int{}, - } - - for tt, count := range handle.active.taskCounters { - out[uuid.UUID(id)].TaskCounts[tt.String()] = count } - handle.lk.Unlock() } - for id, handle := range m.sched.Workers { + for id, handle := range m.sched.workers { cb(ctx, id, handle) } @@ -79,14 +72,14 @@ func (m *Manager) WorkerJobs() map[uuid.UUID][]storiface.WorkerJob { m.sched.workersLk.RLock() - for id, handle := range m.sched.Workers { + for id, handle := range m.sched.workers { handle.wndLk.Lock() for wi, window := range handle.activeWindows { - for _, request := range window.Todo { + for _, request := range window.todo { out[uuid.UUID(id)] = append(out[uuid.UUID(id)], storiface.WorkerJob{ ID: storiface.UndefCall, - Sector: request.Sector.ID, - Task: request.TaskType, + Sector: request.sector.ID, + Task: request.taskType, RunWait: wi + 2, Start: request.start, }) diff --git a/extern/sector-storage/stores/local.go b/extern/sector-storage/stores/local.go index 1f81d5bd0..1bdd1f08b 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" @@ -88,8 +89,6 @@ type path struct { } func (p *path) stat(ls LocalStorage) (fsutil.FsStat, error) { - start := time.Now() - stat, err := ls.Stat(p.local) if err != nil { return fsutil.FsStat{}, xerrors.Errorf("stat %s: %w", p.local, err) @@ -157,10 +156,6 @@ func (p *path) stat(ls LocalStorage) (fsutil.FsStat, error) { } } - if time.Now().Sub(start) > 5*time.Second { - log.Warnw("slow storage stat", "took", time.Now().Sub(start), "reservations", len(p.reservations)) - } - return stat, err } @@ -172,7 +167,7 @@ type URLs []string func NewLocal(ctx context.Context, ls LocalStorage, index SectorIndex, urls []string) (*Local, error) { l := &Local{ - localStorage: newCachedLocalStorage(ls), + localStorage: ls, index: index, urls: urls, diff --git a/extern/sector-storage/stores/localstorage_cached.go b/extern/sector-storage/stores/localstorage_cached.go deleted file mode 100644 index 9ada06cbf..000000000 --- a/extern/sector-storage/stores/localstorage_cached.go +++ /dev/null @@ -1,131 +0,0 @@ -package stores - -import ( - "sync" - "time" - - lru "github.com/hashicorp/golang-lru" - - "github.com/filecoin-project/lotus/extern/sector-storage/fsutil" -) - -var StatTimeout = 5 * time.Second -var MaxDiskUsageDuration = time.Second - -type cachedLocalStorage struct { - base LocalStorage - - statLk sync.Mutex - stats *lru.Cache // path -> statEntry - pathDUs *lru.Cache // path -> *diskUsageEntry -} - -func newCachedLocalStorage(ls LocalStorage) *cachedLocalStorage { - statCache, _ := lru.New(1024) - duCache, _ := lru.New(1024) - - return &cachedLocalStorage{ - base: ls, - stats: statCache, - pathDUs: duCache, - } -} - -type statEntry struct { - stat fsutil.FsStat - time time.Time -} - -type diskUsageEntry struct { - last diskUsageResult - - usagePromise <-chan diskUsageResult -} - -type diskUsageResult struct { - usage int64 - time time.Time -} - -func (c *cachedLocalStorage) GetStorage() (StorageConfig, error) { - return c.base.GetStorage() -} - -func (c *cachedLocalStorage) SetStorage(f func(*StorageConfig)) error { - return c.base.SetStorage(f) -} - -func (c *cachedLocalStorage) Stat(path string) (fsutil.FsStat, error) { - c.statLk.Lock() - defer c.statLk.Unlock() - - if v, ok := c.stats.Get(path); ok && time.Now().Sub(v.(statEntry).time) < StatTimeout { - return v.(statEntry).stat, nil - } - - // if we don't, get the stat - st, err := c.base.Stat(path) - if err == nil { - c.stats.Add(path, statEntry{ - stat: st, - time: time.Now(), - }) - } - - return st, err -} - -func (c *cachedLocalStorage) DiskUsage(path string) (int64, error) { - c.statLk.Lock() - defer c.statLk.Unlock() - - var entry *diskUsageEntry - - if v, ok := c.pathDUs.Get(path); ok { - entry = v.(*diskUsageEntry) - - // if we have recent cached entry, use that - if time.Now().Sub(entry.last.time) < StatTimeout { - return entry.last.usage, nil - } - } else { - entry = new(diskUsageEntry) - c.pathDUs.Add(path, entry) - } - - // start a new disk usage request; this can take a while so start a - // goroutine, and if it doesn't return quickly, return either the - // previous value, or zero - that's better than potentially blocking - // here for a long time. - if entry.usagePromise == nil { - resCh := make(chan diskUsageResult, 1) - go func() { - du, err := c.base.DiskUsage(path) - if err != nil { - log.Errorw("error getting disk usage", "path", path, "error", err) - } - resCh <- diskUsageResult{ - usage: du, - time: time.Now(), - } - }() - entry.usagePromise = resCh - } - - // wait for the disk usage result; if it doesn't come, fallback on - // previous usage - select { - case du := <-entry.usagePromise: - entry.usagePromise = nil - entry.last = du - case <-time.After(MaxDiskUsageDuration): - log.Warnw("getting usage is slow, falling back to previous usage", - "path", path, - "fallback", entry.last.usage, - "age", time.Now().Sub(entry.last.time)) - } - - return entry.last.usage, nil -} - -var _ LocalStorage = &cachedLocalStorage{} diff --git a/extern/sector-storage/stores/remote.go b/extern/sector-storage/stores/remote.go index e8e008139..62c780d09 100644 --- a/extern/sector-storage/stores/remote.go +++ b/extern/sector-storage/stores/remote.go @@ -95,8 +95,6 @@ func (r *Remote) AcquireSector(ctx context.Context, s storage.SectorRef, existin return storiface.SectorPaths{}, storiface.SectorPaths{}, xerrors.New("can't both find and allocate a sector") } - // First make sure that no other goroutines are trying to fetch this sector; - // wait if there are any. for { r.fetchLk.Lock() @@ -124,7 +122,6 @@ func (r *Remote) AcquireSector(ctx context.Context, s storage.SectorRef, existin r.fetchLk.Unlock() }() - // Try to get the sector from local storage paths, stores, err := r.local.AcquireSector(ctx, s, existing, allocate, pathType, op) if err != nil { return storiface.SectorPaths{}, storiface.SectorPaths{}, xerrors.Errorf("local acquire error: %w", err) @@ -151,9 +148,6 @@ func (r *Remote) AcquireSector(ctx context.Context, s storage.SectorRef, existin odt = storiface.FsOverheadFinalized } - // If any path types weren't found in local storage, try fetching them - - // First reserve storage releaseStorage, err := r.local.Reserve(ctx, s, toFetch, ids, odt) if err != nil { return storiface.SectorPaths{}, storiface.SectorPaths{}, xerrors.Errorf("reserving storage space: %w", err) @@ -833,7 +827,7 @@ func (r *Remote) GenerateSingleVanillaProof(ctx context.Context, minerID abi.Act log.Error("response close: ", err) } - return nil, xerrors.Errorf("non-200 code from %s: '%s'", url, strings.TrimSpace(string(body))) + return nil, xerrors.Errorf("non-200 code from %s: '%s'", url, string(body)) } body, err := ioutil.ReadAll(resp.Body) diff --git a/extern/sector-storage/storiface/filetype.go b/extern/sector-storage/storiface/filetype.go index ce6f2e8e1..83fcadc90 100644 --- a/extern/sector-storage/storiface/filetype.go +++ b/extern/sector-storage/storiface/filetype.go @@ -30,7 +30,7 @@ var FSOverheadSeal = map[SectorFileType]int{ // 10x overheads FTUnsealed: FSOverheadDen, FTSealed: FSOverheadDen, FTUpdate: FSOverheadDen, - FTUpdateCache: FSOverheadDen*2 + 1, + FTUpdateCache: FSOverheadDen * 2, FTCache: 141, // 11 layers + D(2x ssize) + C + R' } @@ -39,9 +39,9 @@ var FSOverheadSeal = map[SectorFileType]int{ // 10x overheads var FsOverheadFinalized = map[SectorFileType]int{ FTUnsealed: FSOverheadDen, FTSealed: FSOverheadDen, - FTUpdate: FSOverheadDen, - FTUpdateCache: 1, - FTCache: 1, + FTUpdate: FSOverheadDen * 2, // XXX: we should clear the update cache on Finalize??? + FTUpdateCache: FSOverheadDen, + FTCache: 2, } type SectorFileType int diff --git a/extern/sector-storage/storiface/resources.go b/extern/sector-storage/storiface/resources.go index 0e3294756..ce533e2c0 100644 --- a/extern/sector-storage/storiface/resources.go +++ b/extern/sector-storage/storiface/resources.go @@ -26,8 +26,6 @@ type Resources struct { MaxParallelismGPU int `envname:"MAX_PARALLELISM_GPU"` // when 0, inherits MaxParallelism BaseMinMemory uint64 `envname:"BASE_MIN_MEMORY"` // What Must be in RAM for decent perf (shared between threads) - - MaxConcurrent int `envname:"MAX_CONCURRENT"` // Maximum number of tasks of this type that can be scheduled on a worker (0=default, no limit) } /* @@ -571,7 +569,6 @@ var ResourceTable = map[sealtasks.TaskType]map[abi.RegisteredSealProof]Resources func init() { ResourceTable[sealtasks.TTUnseal] = ResourceTable[sealtasks.TTPreCommit1] // TODO: measure accurately ResourceTable[sealtasks.TTRegenSectorKey] = ResourceTable[sealtasks.TTReplicaUpdate] - ResourceTable[sealtasks.TTDataCid] = ResourceTable[sealtasks.TTAddPiece] // V1_1 is the same as V1 for _, m := range ResourceTable { diff --git a/extern/sector-storage/storiface/worker.go b/extern/sector-storage/storiface/worker.go index 0f3e76bf6..876c3df59 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" @@ -75,8 +76,6 @@ type WorkerStats struct { MemUsedMax uint64 GpuUsed float64 // nolint CpuUse uint64 // nolint - - TaskCounts map[string]int } const ( @@ -119,7 +118,6 @@ var UndefCall CallID type WorkerCalls interface { // async - DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (CallID, error) AddPiece(ctx context.Context, sector storage.SectorRef, pieceSizes []abi.UnpaddedPieceSize, newPieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (CallID, error) SealPreCommit1(ctx context.Context, sector storage.SectorRef, ticket abi.SealRandomness, pieces []abi.PieceInfo) (CallID, error) SealPreCommit2(ctx context.Context, sector storage.SectorRef, pc1o storage.PreCommit1Out) (CallID, error) @@ -200,7 +198,6 @@ func Err(code ErrorCode, sub error) *CallError { } type WorkerReturn interface { - ReturnDataCid(ctx context.Context, callID CallID, pi abi.PieceInfo, err *CallError) error ReturnAddPiece(ctx context.Context, callID CallID, pi abi.PieceInfo, err *CallError) error ReturnSealPreCommit1(ctx context.Context, callID CallID, p1o storage.PreCommit1Out, err *CallError) error ReturnSealPreCommit2(ctx context.Context, callID CallID, sealed storage.SectorCids, err *CallError) error diff --git a/extern/sector-storage/teststorage_test.go b/extern/sector-storage/teststorage_test.go index 0c15fbf7b..6d9ce5e4d 100644 --- a/extern/sector-storage/teststorage_test.go +++ b/extern/sector-storage/teststorage_test.go @@ -23,15 +23,11 @@ type testExec struct { apch chan chan apres } -func (t *testExec) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (abi.PieceInfo, error) { - panic("implement me") -} - func (t *testExec) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, error) { 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..14ec3a037 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" @@ -180,7 +181,6 @@ func (l *LocalWorker) ffiExec() (ffiwrapper.Storage, error) { type ReturnType string const ( - DataCid ReturnType = "DataCid" AddPiece ReturnType = "AddPiece" SealPreCommit1 ReturnType = "SealPreCommit1" SealPreCommit2 ReturnType = "SealPreCommit2" @@ -233,7 +233,6 @@ func rfunc(in interface{}) func(context.Context, storiface.CallID, storiface.Wor } var returnFunc = map[ReturnType]func(context.Context, storiface.CallID, storiface.WorkerReturn, interface{}, *storiface.CallError) error{ - DataCid: rfunc(storiface.WorkerReturn.ReturnDataCid), AddPiece: rfunc(storiface.WorkerReturn.ReturnAddPiece), SealPreCommit1: rfunc(storiface.WorkerReturn.ReturnSealPreCommit1), SealPreCommit2: rfunc(storiface.WorkerReturn.ReturnSealPreCommit2), @@ -289,7 +288,7 @@ func (l *LocalWorker) asyncCall(ctx context.Context, sector storage.SectorRef, r log.Errorf("get hostname err: %+v", err) } - err = xerrors.Errorf("%w [Hostname: %s]", err, hostname) + err = xerrors.Errorf("%w [Hostname: %s]", err.Error(), hostname) } if doReturn(ctx, rt, ci, l.ret, res, toCallError(err)) { @@ -343,17 +342,6 @@ func (l *LocalWorker) NewSector(ctx context.Context, sector storage.SectorRef) e return sb.NewSector(ctx, sector) } -func (l *LocalWorker) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (storiface.CallID, error) { - sb, err := l.executor() - if err != nil { - return storiface.UndefCall, err - } - - return l.asyncCall(ctx, storage.NoSectorRef, DataCid, func(ctx context.Context, ci storiface.CallID) (interface{}, error) { - return sb.DataCid(ctx, pieceSize, pieceData) - }) -} - func (l *LocalWorker) AddPiece(ctx context.Context, sector storage.SectorRef, epcs []abi.UnpaddedPieceSize, sz abi.UnpaddedPieceSize, r io.Reader) (storiface.CallID, error) { sb, err := l.executor() if err != nil { diff --git a/extern/sector-storage/worker_tracked.go b/extern/sector-storage/worker_tracked.go index e3ce0a46a..1d92579a5 100644 --- a/extern/sector-storage/worker_tracked.go +++ b/extern/sector-storage/worker_tracked.go @@ -186,12 +186,6 @@ func (t *trackedWorker) FinalizeSector(ctx context.Context, sector storage.Secto return t.tracker.track(ctx, t.execute, t.wid, t.workerInfo, sector, sealtasks.TTFinalize, func() (storiface.CallID, error) { return t.Worker.FinalizeSector(ctx, sector, keepUnsealed) }) } -func (t *trackedWorker) DataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (storiface.CallID, error) { - return t.tracker.track(ctx, t.execute, t.wid, t.workerInfo, storage.NoSectorRef, sealtasks.TTDataCid, func() (storiface.CallID, error) { - return t.Worker.DataCid(ctx, pieceSize, pieceData) - }) -} - func (t *trackedWorker) AddPiece(ctx context.Context, sector storage.SectorRef, pieceSizes []abi.UnpaddedPieceSize, newPieceSize abi.UnpaddedPieceSize, pieceData storage.Data) (storiface.CallID, error) { return t.tracker.track(ctx, t.execute, t.wid, t.workerInfo, sector, sealtasks.TTAddPiece, func() (storiface.CallID, error) { return t.Worker.AddPiece(ctx, sector, pieceSizes, newPieceSize, pieceData) 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..692b32e20 100644 --- a/extern/storage-sealing/currentdealinfo.go +++ b/extern/storage-sealing/currentdealinfo.go @@ -3,7 +3,9 @@ package sealing import ( "bytes" "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" @@ -11,9 +13,7 @@ import ( "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 +121,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 +130,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) } @@ -139,19 +139,18 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context break } } - fmt.Printf("found dealIdx %d\n", dealIdx) if dealIdx == -1 { return dealID, nil, xerrors.Errorf("could not find deal in publish deals message %s", publishCid) } - if dealIdx >= len(pubDealsParams.Deals) { + if dealIdx >= len(dealIDs) { return dealID, nil, xerrors.Errorf( - "deal index %d out of bounds of deal proposals (len %d) in publish deals message %s", + "deal index %d out of bounds of deals (len %d) in publish deals message %s", dealIdx, len(dealIDs), publishCid) } - valid, outIdx, err := retval.IsDealValid(uint64(dealIdx)) + valid, err := retval.IsDealValid(uint64(dealIdx)) if err != nil { return dealID, nil, xerrors.Errorf("determining deal validity: %w", err) } @@ -160,12 +159,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context return dealID, nil, xerrors.New("deal was invalid at publication") } - // final check against for invalid return value output - // should not be reachable from onchain output, only pathological test cases - if outIdx >= len(dealIDs) { - return dealID, nil, xerrors.Errorf("invalid publish storage deals ret marking %d as valid while only returning %d valid deals in publish deal message %s", outIdx, len(dealIDs), publishCid) - } - return dealIDs[outIdx], lookup.TipSetTok, nil + return dealIDs[dealIdx], lookup.TipSetTok, nil } func (mgr *CurrentDealInfoManager) CheckDealEquality(ctx context.Context, tok TipSetToken, p1, p2 market.DealProposal) (bool, error) { @@ -180,7 +174,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..8dbc5c496 100644 --- a/extern/storage-sealing/currentdealinfo_test.go +++ b/extern/storage-sealing/currentdealinfo_test.go @@ -8,11 +8,10 @@ import ( "testing" "time" - "github.com/filecoin-project/go-bitfield" - "github.com/filecoin-project/go-state-types/network" - + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" - market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" + + "github.com/filecoin-project/go-state-types/network" "golang.org/x/net/context" "golang.org/x/xerrors" @@ -25,7 +24,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,11 +32,16 @@ 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) + ctx := context.Background() dummyCid, _ := cid.Parse("bafkqaaa") dummyCid2, _ := cid.Parse("bafkqaab") zeroDealID := abi.DealID(0) - anotherDealID := abi.DealID(8) earlierDealID := abi.DealID(9) successDealID := abi.DealID(10) proposal := market.DealProposal{ @@ -49,7 +52,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,17 +62,7 @@ func TestGetCurrentDealInfo(t *testing.T) { StoragePricePerEpoch: abi.NewTokenAmount(1), ProviderCollateral: abi.NewTokenAmount(1), ClientCollateral: abi.NewTokenAmount(1), - Label: "other", - } - anotherProposal := market.DealProposal{ - PieceCID: dummyCid2, - PieceSize: abi.PaddedPieceSize(100), - Client: tutils.NewActorAddr(t, "client"), - Provider: tutils.NewActorAddr(t, "provider"), - StoragePricePerEpoch: abi.NewTokenAmount(1), - ProviderCollateral: abi.NewTokenAmount(1), - ClientCollateral: abi.NewTokenAmount(1), - Label: "another", + Label: other, } successDeal := &api.MarketDeal{ Proposal: proposal, @@ -85,13 +78,6 @@ func TestGetCurrentDealInfo(t *testing.T) { LastUpdatedEpoch: 2, }, } - anotherDeal := &api.MarketDeal{ - Proposal: anotherProposal, - State: market.DealState{ - SectorStartEpoch: 1, - LastUpdatedEpoch: 2, - }, - } type testCaseData struct { searchMessageLookup *MsgLookup @@ -102,7 +88,6 @@ func TestGetCurrentDealInfo(t *testing.T) { expectedDealID abi.DealID expectedMarketDeal *api.MarketDeal expectedError error - networkVersion network.Version } testCases := map[string]testCaseData{ "deal lookup succeeds": { @@ -110,7 +95,7 @@ func TestGetCurrentDealInfo(t *testing.T) { searchMessageLookup: &MsgLookup{ Receipt: MessageReceipt{ ExitCode: exitcode.Ok, - Return: makePublishDealsReturnBytesOldVersion(t, []abi.DealID{successDealID}), + Return: makePublishDealsReturnBytes(t, []abi.DealID{successDealID}), }, }, marketDeals: map[abi.DealID]*api.MarketDeal{ @@ -125,7 +110,7 @@ func TestGetCurrentDealInfo(t *testing.T) { searchMessageLookup: &MsgLookup{ Receipt: MessageReceipt{ ExitCode: exitcode.Ok, - Return: makePublishDealsReturnBytesOldVersion(t, []abi.DealID{earlierDealID, successDealID}), + Return: makePublishDealsReturnBytes(t, []abi.DealID{earlierDealID, successDealID}), }, }, marketDeals: map[abi.DealID]*api.MarketDeal{ @@ -141,7 +126,7 @@ func TestGetCurrentDealInfo(t *testing.T) { searchMessageLookup: &MsgLookup{ Receipt: MessageReceipt{ ExitCode: exitcode.Ok, - Return: makePublishDealsReturnBytesOldVersion(t, []abi.DealID{earlierDealID}), + Return: makePublishDealsReturnBytes(t, []abi.DealID{earlierDealID}), }, }, marketDeals: map[abi.DealID]*api.MarketDeal{ @@ -151,29 +136,12 @@ func TestGetCurrentDealInfo(t *testing.T) { expectedDealID: zeroDealID, expectedError: xerrors.Errorf("could not find deal in publish deals message %s", dummyCid), }, - "deal lookup handles invalid actor output with mismatched count of deals and return values": { - publishCid: dummyCid, - searchMessageLookup: &MsgLookup{ - Receipt: MessageReceipt{ - ExitCode: exitcode.Ok, - Return: makePublishDealsReturnBytesOldVersion(t, []abi.DealID{earlierDealID}), - }, - }, - marketDeals: map[abi.DealID]*api.MarketDeal{ - earlierDealID: earlierDeal, - successDealID: successDeal, - }, - targetProposal: &proposal, - expectedDealID: zeroDealID, - expectedError: xerrors.Errorf("invalid publish storage deals ret marking 1 as valid while only returning 1 valid deals in publish deal message %s", dummyCid), - }, - - "deal lookup fails when deal was not valid and index exceeds output array": { + "deal lookup fails mismatch count of deals and return values": { publishCid: dummyCid, searchMessageLookup: &MsgLookup{ Receipt: MessageReceipt{ ExitCode: exitcode.Ok, - Return: makePublishDealsReturn(t, []abi.DealID{earlierDealID}, []uint64{0}), + Return: makePublishDealsReturnBytes(t, []abi.DealID{earlierDealID}), }, }, marketDeals: map[abi.DealID]*api.MarketDeal{ @@ -182,35 +150,14 @@ func TestGetCurrentDealInfo(t *testing.T) { }, targetProposal: &proposal, expectedDealID: zeroDealID, - expectedError: xerrors.Errorf("deal was invalid at publication"), - networkVersion: network.Version14, - }, - - "deal lookup succeeds when theres a separate deal failure": { - publishCid: dummyCid, - searchMessageLookup: &MsgLookup{ - Receipt: MessageReceipt{ - ExitCode: exitcode.Ok, - Return: makePublishDealsReturn(t, []abi.DealID{anotherDealID, successDealID}, []uint64{0, 2}), - }, - }, - marketDeals: map[abi.DealID]*api.MarketDeal{ - anotherDealID: anotherDeal, - earlierDealID: earlierDeal, - successDealID: successDeal, - }, - targetProposal: &proposal, - expectedDealID: successDealID, - expectedMarketDeal: successDeal, - networkVersion: network.Version14, + expectedError: xerrors.Errorf("deal index 1 out of bounds of deals (len 1) in publish deals message %s", dummyCid), }, - "deal lookup succeeds, target proposal nil, single deal in message": { publishCid: dummyCid, searchMessageLookup: &MsgLookup{ Receipt: MessageReceipt{ ExitCode: exitcode.Ok, - Return: makePublishDealsReturnBytesOldVersion(t, []abi.DealID{successDealID}), + Return: makePublishDealsReturnBytes(t, []abi.DealID{successDealID}), }, }, marketDeals: map[abi.DealID]*api.MarketDeal{ @@ -225,7 +172,7 @@ func TestGetCurrentDealInfo(t *testing.T) { searchMessageLookup: &MsgLookup{ Receipt: MessageReceipt{ ExitCode: exitcode.Ok, - Return: makePublishDealsReturnBytesOldVersion(t, []abi.DealID{earlierDealID, successDealID}), + Return: makePublishDealsReturnBytes(t, []abi.DealID{earlierDealID, successDealID}), }, }, marketDeals: map[abi.DealID]*api.MarketDeal{ @@ -287,7 +234,6 @@ func TestGetCurrentDealInfo(t *testing.T) { SearchMessageLookup: data.searchMessageLookup, SearchMessageErr: data.searchMessageErr, MarketDeals: marketDeals, - Version: data.networkVersion, } dealInfoMgr := CurrentDealInfoManager{mockApi} @@ -316,37 +262,30 @@ type CurrentDealInfoMockAPI struct { SearchMessageErr error MarketDeals map[marketDealKey]*api.MarketDeal - Version network.Version } func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.Cid) (*types.Message, error) { - var keys []marketDealKey - for k := range mapi.MarketDeals { - keys = append(keys, k) - } - sort.SliceStable(keys, func(i, j int) bool { - return keys[i].DealID < keys[j].DealID - }) - - var deals []market2.ClientDealProposal - for _, k := range keys { - dl := mapi.MarketDeals[k] - deals = append(deals, market2.ClientDealProposal{ - Proposal: market2.DealProposal(dl.Proposal), + var dealIDs []abi.DealID + var deals []markettypes.ClientDealProposal + for k, dl := range mapi.MarketDeals { + dealIDs = append(dealIDs, k.DealID) + deals = append(deals, markettypes.ClientDealProposal{ + Proposal: dl.Proposal, ClientSignature: crypto.Signature{ Data: []byte("foo bar cat dog"), Type: crypto.SigTypeBLS, }, }) } - + sort.SliceStable(deals, func(i, j int) bool { + return dealIDs[i] < dealIDs[j] + }) buf := new(bytes.Buffer) - params := market2.PublishStorageDealsParams{Deals: deals} + params := markettypes.PublishStorageDealsParams{Deals: deals} err := params.MarshalCBOR(buf) if err != nil { panic(err) } - return &types.Message{ Params: buf.Bytes(), }, nil @@ -377,28 +316,15 @@ func (mapi *CurrentDealInfoMockAPI) StateSearchMsg(ctx context.Context, c cid.Ci } func (mapi *CurrentDealInfoMockAPI) StateNetworkVersion(ctx context.Context, tok TipSetToken) (network.Version, error) { - return mapi.Version, nil + return network.Version0, nil } -func makePublishDealsReturnBytesOldVersion(t *testing.T, dealIDs []abi.DealID) []byte { +func makePublishDealsReturnBytes(t *testing.T, dealIDs []abi.DealID) []byte { buf := new(bytes.Buffer) dealsReturn := market0.PublishStorageDealsReturn{ IDs: dealIDs, } err := dealsReturn.MarshalCBOR(buf) require.NoError(t, err) - - return buf.Bytes() -} - -func makePublishDealsReturn(t *testing.T, dealIDs []abi.DealID, validIdxs []uint64) []byte { - buf := new(bytes.Buffer) - dealsReturn := market7.PublishStorageDealsReturn{ - IDs: dealIDs, - ValidDeals: bitfield.NewFromSet(validIdxs), - } - err := dealsReturn.MarshalCBOR(buf) - require.NoError(t, err) - return buf.Bytes() } 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/input.go b/extern/storage-sealing/input.go index ca7ae7dd3..9654296ca 100644 --- a/extern/storage-sealing/input.go +++ b/extern/storage-sealing/input.go @@ -22,7 +22,6 @@ import ( "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" - "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" "github.com/filecoin-project/lotus/extern/storage-sealing/sealiface" ) @@ -221,7 +220,7 @@ func (m *Sealing) handleAddPiece(ctx statemachine.Context, sector SectorInfo) er m.minerSector(sector.SectorType, sector.SectorNumber), pieceSizes, p.Unpadded(), - nullreader.NewNullReader(p.Unpadded())) + NewNullReader(p.Unpadded())) if err != nil { err = xerrors.Errorf("writing padding piece: %w", err) deal.accepted(sector.SectorNumber, offset, err) @@ -447,7 +446,7 @@ func (m *Sealing) updateInput(ctx context.Context, sp abi.RegisteredSealProof) e } if !ok { exp, _, _ := expF(sector.number) - log.Debugf("CC update sector %d cannot fit deal, expiration %d before deal end epoch %d", id, exp, piece.deal.DealProposal.EndEpoch) + log.Infof("CC update sector %d cannot fit deal, expiration %d before deal end epoch %d", id, exp, piece.deal.DealProposal.EndEpoch) continue } diff --git a/extern/storage-sealing/lib/nullreader/nullreader.go b/extern/storage-sealing/lib/nullreader/nullreader.go index 9e4bc523c..dc3537ad7 100644 --- a/extern/storage-sealing/lib/nullreader/nullreader.go +++ b/extern/storage-sealing/lib/nullreader/nullreader.go @@ -1,23 +1,5 @@ package nullreader -import ( - "io" - - "github.com/filecoin-project/go-state-types/abi" -) - -type NullReader struct { - *io.LimitedReader -} - -func NewNullReader(size abi.UnpaddedPieceSize) io.Reader { - return &NullReader{(io.LimitReader(&Reader{}, int64(size))).(*io.LimitedReader)} -} - -func (m NullReader) NullBytes() int64 { - return m.N -} - // TODO: extract this to someplace where it can be shared with lotus type Reader struct{} 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/nullreader.go b/extern/storage-sealing/nullreader.go new file mode 100644 index 000000000..5987a4145 --- /dev/null +++ b/extern/storage-sealing/nullreader.go @@ -0,0 +1,20 @@ +package sealing + +import ( + "io" + + "github.com/filecoin-project/go-state-types/abi" + nr "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" +) + +type NullReader struct { + *io.LimitedReader +} + +func NewNullReader(size abi.UnpaddedPieceSize) io.Reader { + return &NullReader{(io.LimitReader(&nr.Reader{}, int64(size))).(*io.LimitedReader)} +} + +func (m NullReader) NullBytes() int64 { + return m.N +} diff --git a/extern/storage-sealing/precommit_batch.go b/extern/storage-sealing/precommit_batch.go index 2a8168a4a..e4db0aef5 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,22 +379,17 @@ 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) return sealiface.PreCommitBatchRes{}, err } - cutoff, err := getPreCommitCutoff(curEpoch, s) - if err != nil { - return sealiface.PreCommitBatchRes{}, xerrors.Errorf("failed to calculate cutoff: %w", err) - } - sn := s.SectorNumber b.lk.Lock() - b.cutoffs[sn] = cutoff + b.cutoffs[sn] = getPreCommitCutoff(curEpoch, s) b.todo[sn] = &preCommitEntry{ deposit: deposit, pci: in, @@ -472,7 +467,7 @@ func (b *PreCommitBatcher) Stop(ctx context.Context) error { } // TODO: If this returned epochs, it would make testing much easier -func getPreCommitCutoff(curEpoch abi.ChainEpoch, si SectorInfo) (time.Time, error) { +func getPreCommitCutoff(curEpoch abi.ChainEpoch, si SectorInfo) time.Time { cutoffEpoch := si.TicketEpoch + policy.MaxPreCommitRandomnessLookback for _, p := range si.Pieces { if p.DealInfo == nil { @@ -486,8 +481,8 @@ func getPreCommitCutoff(curEpoch abi.ChainEpoch, si SectorInfo) (time.Time, erro } if cutoffEpoch <= curEpoch { - return time.Now(), xerrors.Errorf("cutoff has already passed (cutoff %d <= curEpoch %d)", cutoffEpoch, curEpoch) + return time.Now() } - return time.Now().Add(time.Duration(cutoffEpoch-curEpoch) * time.Duration(build.BlockDelaySecs) * time.Second), nil + return time.Now().Add(time.Duration(cutoffEpoch-curEpoch) * time.Duration(build.BlockDelaySecs) * time.Second) } 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..052ff846d 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,14 +16,13 @@ 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" ) var DealSectorPriority = 1024 @@ -29,7 +30,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) @@ -92,7 +93,7 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi for i, size := range sizes { expectCid := zerocomm.ZeroPieceCommitment(size) - ppi, err := m.sealer.AddPiece(ctx, sectorID, existingPieceSizes, size, nullreader.NewNullReader(size)) + ppi, err := m.sealer.AddPiece(ctx, sectorID, existingPieceSizes, size, NewNullReader(size)) if err != nil { return nil, xerrors.Errorf("add piece: %w", err) } @@ -410,7 +411,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 +671,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 f16d0acab..58a2f35c9 100644 --- a/gateway/node.go +++ b/gateway/node.go @@ -68,7 +68,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) @@ -419,9 +419,9 @@ 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.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 4705f9bd5..aebd8ba14 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 7fc24ff40..375fa783e 100644 --- a/go.mod +++ b/go.mod @@ -37,26 +37,27 @@ 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.8-0.20220523171308-92f973e10902 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/mir v0.0.0-20220510082156-0a9866313648 + github.com/filecoin-project/mir v0.0.0-20220530131146-5a6547186fdb 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-0.20220514164640-94e0d5e123bd 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-0.20220514165557-0b29a778685b + github.com/filecoin-project/specs-actors/v6 v6.0.2-0.20220511204807-569c6d12432b + github.com/filecoin-project/specs-actors/v7 v7.0.1-0.20220511223846-637436c27154 + github.com/filecoin-project/specs-actors/v8 v8.0.0-20220422153930-0afe155bfffa + github.com/filecoin-project/specs-storage v0.4.0 github.com/filecoin-project/test-vectors/schema v0.0.5 github.com/gammazero/keymutex v0.0.2 github.com/gbrlsnchs/jwt/v3 v3.0.1 @@ -160,9 +161,9 @@ require ( go.uber.org/fx v1.15.0 go.uber.org/multierr v1.8.0 go.uber.org/zap v1.21.0 - golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220412211240-33da011f77ad + golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac golang.org/x/tools v0.1.10 golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f @@ -179,7 +180,7 @@ require ( github.com/StackExchange/wmi v1.2.1 // indirect github.com/Stebalien/go-bitfield v0.0.1 // indirect github.com/akavel/rsrc v0.8.0 // indirect - github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect + github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bep/debounce v1.2.0 // indirect @@ -327,11 +328,11 @@ 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/tidwall/gjson v1.9.3 // indirect + github.com/tidwall/gjson v1.14.1 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect - github.com/tidwall/tinylru v1.0.2 // indirect - github.com/tidwall/wal v0.1.3 // indirect + github.com/tidwall/tinylru v1.1.0 // indirect + github.com/tidwall/wal v1.1.7 // 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 @@ -351,16 +352,16 @@ require ( go.uber.org/dig v1.12.0 // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect - golang.org/x/exp v0.0.0-20210715201039-d37aa40e8013 // indirect + golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect - google.golang.org/grpc v1.45.0 // indirect + google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3 // indirect + google.golang.org/grpc v1.46.0 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect modernc.org/cc v1.0.0 // indirect modernc.org/golex v1.0.1 // indirect @@ -373,7 +374,7 @@ require ( // in the eudico repo. // In this fork we also include a SendWithSerializedParams required to forward messages with already serialized // params from an actor. -replace github.com/filecoin-project/specs-actors/v7 => github.com/adlrocha/specs-actors/v7 v7.0.0-rc1.0.20220215102846-08bb2fde502a +// replace github.com/filecoin-project/specs-actors/v7 => github.com/adlrocha/specs-actors/v7 v7.0.0-rc1.0.20220215102846-08bb2fde502a // FIXME: Replacing with a fork that includes support to hierarchical consensus addresses. replace github.com/filecoin-project/go-address => github.com/adlrocha/go-address v0.0.7-0.20220201161333-9140b209222d diff --git a/go.sum b/go.sum index 9bc5a4d3a..0bd1e8938 100644 --- a/go.sum +++ b/go.sum @@ -120,8 +120,6 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat6 github.com/adlio/schema v1.1.14/go.mod h1:hQveFEMiDlG/M9yz9RAajnH5DzT6nAfqOG9YkEQU2pg= github.com/adlrocha/go-address v0.0.7-0.20220201161333-9140b209222d h1:49cRLnRjRE3YO4NsdFhkVhz2Y/Zv5a/V7a9iFZW76/E= github.com/adlrocha/go-address v0.0.7-0.20220201161333-9140b209222d/go.mod h1:7B0/5DA13n6nHkB8bbGx1gWzG/dbTsZ0fgOJVGsM3TE= -github.com/adlrocha/specs-actors/v7 v7.0.0-rc1.0.20220215102846-08bb2fde502a h1:P3KHHAOD20pEI2MC8SYTRqrfSrBq6BSink8ROQDhjGE= -github.com/adlrocha/specs-actors/v7 v7.0.0-rc1.0.20220215102846-08bb2fde502a/go.mod h1:QQisUhgXrjKFA1u8d3k4MDL0A04sDUQrUTJUsLRJDBk= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -135,8 +133,9 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a h1:E/8AP5dFtMhl5KPJz66Kt9G0n+7Sn41Fy1wv9/jHOrc= github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= +github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alexbrainman/goissue34681 v0.0.0-20191006012335-3fc7a47baff5/go.mod h1:Y2QMoi1vgtOIfc+6DhrMOGkLoGzqSV2rKp4Sm+opsyA= github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= @@ -256,6 +255,7 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= @@ -372,6 +372,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/esimonov/ifshort v1.0.3/go.mod h1:yZqNJUrNn20K8Q9n2CrjTKYyVEmX209Hgu+M1LBpeZE= @@ -426,8 +427,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= @@ -438,8 +439,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= @@ -450,12 +452,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-0.20220511200558-7a486892661a/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg= 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.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.8-0.20220523171308-92f973e10902 h1:9+2alB9brdUrhyrnDTbpzRJFUCk3fyUNUFwxst8uy6Q= +github.com/filecoin-project/go-state-types v0.1.8-0.20220523171308-92f973e10902/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= @@ -466,28 +469,39 @@ github.com/filecoin-project/go-storedcounter v0.1.0 h1:Mui6wSUBC+cQGHbDUBcO7rfh5 github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8= github.com/filecoin-project/index-provider v0.5.0 h1:k2C1RFvOvxmA2i8bhmkb3b4qun7RDRDzzs/y25/TwQg= github.com/filecoin-project/index-provider v0.5.0/go.mod h1:KHVrP2vU3YuScb+fawObwTFoR882up9U07kk0ZrfP0c= -github.com/filecoin-project/mir v0.0.0-20220510082156-0a9866313648 h1:wBZgLhIseEDuV6fTw4le2FoZ5rp/kR2B2VYoYM9/C4o= -github.com/filecoin-project/mir v0.0.0-20220510082156-0a9866313648/go.mod h1:l1X9usvhl01cfYi3sR1+VVwYDfUTz6+XcHnYvYA6KP8= +github.com/filecoin-project/mir v0.0.0-20220530131146-5a6547186fdb h1:cu46Dsv4bNYf+CCa9Dh9GdKZC7mgJFu73TT617rSfO8= +github.com/filecoin-project/mir v0.0.0-20220530131146-5a6547186fdb/go.mod h1:yRDxrh/nbL9MdlZdqegX3pBJtoWu7DtcYPu19iIRIss= 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 h1:PoQ9+o9zjqD7gBMAvG0nwvpmmONo2lFajmjIfzlqeFc= +github.com/filecoin-project/specs-actors v0.9.15-0.20220514164640-94e0d5e123bd/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-0.20220511204328-97fa6fffc45a/go.mod h1:tg58UmhrivJsYrnsvWNEr+RQugRZCpJA+aTBE71t48E= github.com/filecoin-project/specs-actors/v5 v5.0.4/go.mod h1:5BAKRAMsOOlD8+qCw4UvT/lTLInCJ3JwOWZbX8Ipwq4= -github.com/filecoin-project/specs-actors/v6 v6.0.1 h1:laxvHNsvrq83Y9n+W7znVCePi3oLyRf0Rkl4jFO8Wew= +github.com/filecoin-project/specs-actors/v5 v5.0.6-0.20220514165557-0b29a778685b h1:0DevEGyWsWWItaOuqzMa2b2swyCAwRp6crY3uS35qGk= +github.com/filecoin-project/specs-actors/v5 v5.0.6-0.20220514165557-0b29a778685b/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/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk= -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/v6 v6.0.2-0.20220511204807-569c6d12432b h1:UaMSIWqvyBAkM5/hA/iVcTrnwI7IOgQI0Xi4wEkmYM4= +github.com/filecoin-project/specs-actors/v6 v6.0.2-0.20220511204807-569c6d12432b/go.mod h1:UkunB8pzBOV5Rzx0BmvVB2mxMV6CXEnHAC5VlMokOVE= +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/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= +github.com/filecoin-project/specs-actors/v7 v7.0.1-0.20220511223846-637436c27154 h1:NKA2mpz3GAksmrP7P13zLufvoYG9DlasgKxdhrk9gGM= +github.com/filecoin-project/specs-actors/v7 v7.0.1-0.20220511223846-637436c27154/go.mod h1:2pWr2Soyl4yfOkoMThzj41l2lPIRC+CUgU5cW3wI+K4= +github.com/filecoin-project/specs-actors/v8 v8.0.0-20220422153930-0afe155bfffa h1:P9l2WQMvWUJ450esBttbAaqH8Lhe1hu1W2J6cQsiZcA= +github.com/filecoin-project/specs-actors/v8 v8.0.0-20220422153930-0afe155bfffa/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= +github.com/filecoin-project/specs-storage v0.4.0 h1:Gima+B0dNwtsLJrvpg40W3HgHOgWTYyl8lPEYeOxuPk= +github.com/filecoin-project/specs-storage v0.4.0/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= @@ -713,6 +727,7 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= @@ -1285,6 +1300,7 @@ 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.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI= 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-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo= @@ -1450,6 +1466,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= @@ -1543,6 +1560,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= @@ -1933,6 +1951,9 @@ github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvw github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= +github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -1940,8 +1961,10 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= -github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/open-rpc/meta-schema v0.0.0-20201029221707-1b72ef2ea333 h1:CznVS40zms0Dj5he4ERo+fRPtO0qxUk8lA8Xu3ddet0= github.com/open-rpc/meta-schema v0.0.0-20201029221707-1b72ef2ea333/go.mod h1:Ag6rSXkHIckQmjFBCweJEEt1mrTPBv8b9W4aU/NQWfI= @@ -2251,20 +2274,19 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1: github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g= github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= -github.com/tidwall/gjson v1.6.1/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKsxEHI0= -github.com/tidwall/gjson v1.9.3 h1:hqzS9wAHMO+KVBBkLxYdkEeeFHuqr95GfClRLKlgK0E= -github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= +github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/tinylru v1.0.2 h1:W4mp7iUz4cnVMqAvWy2zbzC35ASv5sqdyyEjoQKKBFg= -github.com/tidwall/tinylru v1.0.2/go.mod h1:HDVL7TsWeezQ4g44Um84TOVBMFcq7Xa9giqNc805KJ8= -github.com/tidwall/wal v0.1.3 h1:4641ZiOjDT6hAsdIySfPTctQa5fZBs2/TwPF+EZChas= -github.com/tidwall/wal v0.1.3/go.mod h1:ww7Pd44/KnyETODJPUPKrzLlYjI72GZWlucNKt7pOt0= +github.com/tidwall/tinylru v1.1.0 h1:XY6IUfzVTU9rpwdhKUF6nQdChgCdGjkMfLzbWyiau6I= +github.com/tidwall/tinylru v1.1.0/go.mod h1:3+bX+TJ2baOLMWTnlyNWHh4QMnFyARg2TLTQ6OFbzw8= +github.com/tidwall/wal v1.1.7 h1:emc1TRjIVsdKKSnpwGBAcsAGg0767SvUk8+ygx7Bb+4= +github.com/tidwall/wal v1.1.7/go.mod h1:r6lR1j27W9EPalgHiB7zLJDYu3mzW5BQP5KrzBpYY/E= github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= @@ -2567,8 +2589,9 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20210615023648-acb5c1269671/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc= golang.org/x/exp v0.0.0-20210714144626-1041f73d31d8/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc= -golang.org/x/exp v0.0.0-20210715201039-d37aa40e8013 h1:Jp57DBw4K7mimZNA3F9f7CndVcUt4kJjmyJf2rzJHoI= golang.org/x/exp v0.0.0-20210715201039-d37aa40e8013/go.mod h1:DVyR6MI7P4kEQgvZJSj1fQGrWIi2RzIrfYWycwheUAc= +golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4= +golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -2600,6 +2623,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -2679,8 +2704,9 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 h1:6mzvA99KwZxbOrxww4EvWVQUnN1+xEu9tafK5ZxkYeA= golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -2844,8 +2870,10 @@ golang.org/x/sys v0.0.0-20211025112917-711f33c9992c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211209171907-798191bca915/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2984,6 +3012,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -3103,8 +3132,9 @@ google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKr google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 h1:ysnBoUyeL/H6RCvNRhWHjKoDEmguI+mPU+qHgK8qv/w= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3 h1:q1kiSVscqoDeqTF27eQ2NnLLDmqF0I373qQNXYMy0fo= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= @@ -3143,8 +3173,9 @@ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= -google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -3200,9 +3231,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= 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_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 58fba109c..c9f5029e1 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() { @@ -408,19 +410,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) - require.NoError(n.t, err) - - proofType, err := miner.SealProofTypeFromSectorSize(m.options.sectorSize, nv) + proofType, err := miner.WindowPoStProofTypeFromSectorSize(m.options.sectorSize) 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) @@ -439,7 +436,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") @@ -451,7 +448,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), } @@ -562,7 +559,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/lookup_robust_address_test.go b/itests/lookup_robust_address_test.go deleted file mode 100644 index d2d49af8b..000000000 --- a/itests/lookup_robust_address_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package itests - -import ( - "context" - "testing" - "time" - - "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" -) - -func TestStateLookupRobustAddress(t *testing.T) { - ctx := context.Background() - kit.QuietMiningLogs() - - client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version15)) - ens.InterconnectAll().BeginMining(10 * time.Millisecond) - - addr, err := miner.ActorAddress(ctx) - require.NoError(t, err) - - // Look up the robust address - robAddr, err := client.StateLookupRobustAddress(ctx, addr, types.EmptyTSK) - require.NoError(t, err) - - // Check the id address for the given robust address and make sure it matches - idAddr, err := client.StateLookupID(ctx, robAddr, types.EmptyTSK) - require.NoError(t, err) - require.Equal(t, addr, idAddr) -} 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..bc307eb84 100644 --- a/itests/wdpost_dispute_test.go +++ b/itests/wdpost_dispute_test.go @@ -6,6 +6,11 @@ import ( "testing" "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" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/crypto" @@ -13,10 +18,8 @@ import ( "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,7 @@ 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.Equal(t, 16, err) // It didn't work because we're recovering. } @@ -310,7 +313,7 @@ waitForProof: // Try to object to the proof. This should fail. { - params := &minerActor.DisputeWindowedPoStParams{ + params := &minertypes.DisputeWindowedPoStParams{ Deadline: targetDeadline, PoStIndex: 0, } @@ -320,14 +323,14 @@ 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.Equal(t, err, 16) } } @@ -356,12 +359,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 +377,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/lib/rpcenc/reader.go b/lib/rpcenc/reader.go index a4f16982e..6693dc83d 100644 --- a/lib/rpcenc/reader.go +++ b/lib/rpcenc/reader.go @@ -21,9 +21,7 @@ import ( "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-state-types/abi" - - "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" - "github.com/filecoin-project/lotus/lib/httpreader" + sealing "github.com/filecoin-project/lotus/extern/storage-sealing" ) var log = logging.Logger("rpcenc") @@ -35,7 +33,6 @@ type StreamType string const ( Null StreamType = "null" PushStream StreamType = "push" - HTTP StreamType = "http" // TODO: Data transfer handoff to workers? ) @@ -104,12 +101,9 @@ func ReaderParamEncoder(addr string) jsonrpc.Option { return jsonrpc.WithParamEncoder(new(io.Reader), func(value reflect.Value) (reflect.Value, error) { r := value.Interface().(io.Reader) - if r, ok := r.(*nullreader.NullReader); ok { + if r, ok := r.(*sealing.NullReader); ok { return reflect.ValueOf(ReaderStream{Type: Null, Info: fmt.Sprint(r.N)}), nil } - if r, ok := r.(*httpreader.HttpReader); ok && r.URL != "" { - return reflect.ValueOf(ReaderStream{Type: HTTP, Info: r.URL}), nil - } reqID := uuid.New() u, err := url.Parse(addr) @@ -217,7 +211,6 @@ type RpcReader struct { postBody io.ReadCloser // nil on initial head request next chan *RpcReader // on head will get us the postBody after sending resStart mustRedirect bool - eof bool res chan readRes beginOnce *sync.Once @@ -273,10 +266,6 @@ func (w *RpcReader) Read(p []byte) (int, error) { w.beginPost() }) - if w.eof { - return 0, io.EOF - } - if w.mustRedirect { return 0, ErrMustRedirect } @@ -287,9 +276,6 @@ func (w *RpcReader) Read(p []byte) (int, error) { n, err := w.postBody.Read(p) if err != nil { - if err == io.EOF { - w.eof = true - } w.closeOnce.Do(func() { close(w.res) }) @@ -418,16 +404,13 @@ func ReaderParamDecoder() (http.HandlerFunc, jsonrpc.ServerOption) { return reflect.Value{}, xerrors.Errorf("unmarshaling reader id: %w", err) } - switch rs.Type { - case Null: + if rs.Type == Null { n, err := strconv.ParseInt(rs.Info, 10, 64) if err != nil { return reflect.Value{}, xerrors.Errorf("parsing null byte count: %w", err) } - return reflect.ValueOf(nullreader.NewNullReader(abi.UnpaddedPieceSize(n))), nil - case HTTP: - return reflect.ValueOf(&httpreader.HttpReader{URL: rs.Info}), nil + return reflect.ValueOf(sealing.NewNullReader(abi.UnpaddedPieceSize(n))), nil } u, err := uuid.Parse(rs.Info) diff --git a/libp2p-host-12D3KooWKMjdksKDcfoeZ9FAVAYzWbWQrZdo8TMF9smuL4mPMWWZ.keyinfo b/libp2p-host-12D3KooWKMjdksKDcfoeZ9FAVAYzWbWQrZdo8TMF9smuL4mPMWWZ.keyinfo new file mode 100644 index 000000000..9a828cf6e --- /dev/null +++ b/libp2p-host-12D3KooWKMjdksKDcfoeZ9FAVAYzWbWQrZdo8TMF9smuL4mPMWWZ.keyinfo @@ -0,0 +1 @@ +7b2254797065223a226c69627032702d686f7374222c22507269766174654b6579223a2243414553514f67435736735452715a32692f796b5a41696b30345430397a5971345378435843626761415078535179646a634a31644375467969727443627071494c4c4b473672657876486750584943536842376a3034796c41593d227d \ No newline at end of file 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..e60f19997 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 } @@ -237,7 +237,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor dealIdx, len(params.Deals), pubmsg.Cid()) } - valid, outIdx, err := res.IsDealValid(uint64(dealIdx)) + valid, err := res.IsDealValid(uint64(dealIdx)) if err != nil { return 0, xerrors.Errorf("determining deal validity: %w", err) } @@ -246,7 +246,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor return 0, xerrors.New("deal was invalid at publication") } - return dealIDs[outIdx], nil + return dealIDs[dealIdx], nil } var clientOverestimation = struct { @@ -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 cccf0a85f..d7935f35e 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" @@ -623,7 +623,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, + eproof *types.ElectionProof, bvals []types.BeaconEntry, wpostProof []proof.PoStProof, msgs []*types.SignedMessage, crossmsgs []*types.Message) (*types.BlockMsg, error) { uts := base.TipSet.MinTimestamp() + build.BlockDelaySecs*(uint64(base.NullRounds)+1) diff --git a/node/builder.go b/node/builder.go index c97b728b2..d81efe2fb 100644 --- a/node/builder.go +++ b/node/builder.go @@ -396,6 +396,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 f43967a7e..242ed590c 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -53,9 +53,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 8aa36156c..9c39b679e 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..d726b0260 --- /dev/null +++ b/node/bundle/manifest.go @@ -0,0 +1,120 @@ +package bundle + +import ( + "context" + "fmt" + "io" + "os" + + "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 vresion %d: %w", av, err) + } + defer f.Close() //nolint + + data, err := io.ReadAll(f) + if err != nil { + return cid.Undef, xerrors.Errorf("error reading bundle for builtin-actors vresion %d: %w", av, err) + } + + if err := actors.LoadBundle(ctx, bs, av, data); err != nil { + return cid.Undef, xerrors.Errorf("error loading bundle for builtin-actors vresion %d: %w", av, err) + } + + 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.GetNetworkBundle() + + 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/config/def.go b/node/config/def.go index 6be3b61d8..e993b4a1b 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -198,7 +198,7 @@ func DefaultStorageMiner() *StorageMiner { }, IndexProvider: IndexProviderConfig{ - Enable: true, + Enable: false, EntriesCacheCapacity: 1024, EntriesChunkSize: 16384, // The default empty TopicName means it is inferred from network name, in the following diff --git a/node/config/storage.go b/node/config/storage.go index de65dc60a..bf997add2 100644 --- a/node/config/storage.go +++ b/node/config/storage.go @@ -63,9 +63,6 @@ func (c *StorageMiner) StorageManager() sectorstorage.Config { AllowProveReplicaUpdate2: c.Storage.AllowProveReplicaUpdate2, AllowRegenSectorKey: c.Storage.AllowRegenSectorKey, ResourceFiltering: c.Storage.ResourceFiltering, - DisallowRemoteFinalize: c.Storage.DisallowRemoteFinalize, - - Assigner: c.Storage.Assigner, ParallelCheckLimit: c.Proving.ParallelCheckLimit, } 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/gas.go b/node/impl/full/gas.go index dd1e8d5ea..05643eab2 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) } - // Special case for PaymentChannel collect, which is deleting actor - 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 + ret := res.MsgRct.GasUsed + + transitionalMulti := 1.0 + // Overestimate gas around the upgrade + if ts.Height() <= build.UpgradeFVM1Height && (build.UpgradeFVM1Height-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 - if !builtin.IsPaymentChannelActor(act.Code) { - return res.MsgRct.GasUsed, nil - } - if msgIn.Method != paych.Methods.Collect { - return res.MsgRct.GasUsed, nil + // 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 { + 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 + } } - // 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) { @@ -347,7 +379,8 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag msg.GasFeeCap = feeCap } - messagepool.CapGasFee(m.GetMaxFee, msg, spec) + // XXX disable this to make things work. + //messagepool.CapGasFee(m.GetMaxFee, msg, spec) return msg, nil } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index a850d88f4..dca0c5e6e 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -6,7 +6,12 @@ import ( "encoding/json" "strconv" - "github.com/ipfs/go-cid" + "github.com/libp2p/go-libp2p-core/peer" + + "github.com/filecoin-project/go-state-types/crypto" + + "github.com/filecoin-project/go-state-types/cbor" + cid "github.com/ipfs/go-cid" "go.uber.org/fx" "golang.org/x/xerrors" @@ -14,12 +19,11 @@ 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/cbor" - "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" - "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" @@ -37,7 +41,6 @@ import ( "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/chain/wallet" - "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -52,7 +55,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) @@ -79,8 +82,8 @@ var _ StateModuleAPI = (*StateModule)(nil) type StateAPI struct { fx.In - // TODO: the wallet here is only needed because we have the MinerCreateBlock API attached to the state API. - // It probably should live somewhere better. + // TODO: the wallet here is only needed because we have the MinerCreateBlock + // API attached to the state API. It probably should live somewhere better Wallet api.Wallet DefWallet wallet.Default @@ -131,27 +134,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 + } + + var pid *peer.ID + if peerID, err := peer.IDFromBytes(info.PeerId); err == nil { + pid = &peerID } - return info, nil + + 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) { @@ -288,7 +316,7 @@ func (a *StateAPI) StateMinerFaults(ctx context.Context, addr address.Address, t } func (a *StateAPI) StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, endTsk types.TipSetKey) ([]*api.Fault, error) { - return nil, xerrors.New("unimplemented") + return nil, xerrors.Errorf("fixme") /*endTs, err := a.Chain.GetTipSetFromKey(endTsk) if err != nil { @@ -449,15 +477,6 @@ func (m *StateModule) StateLookupID(ctx context.Context, addr address.Address, t return m.StateManager.LookupID(ctx, addr, ts) } -func (a *StateAPI) StateLookupRobustAddress(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) { - ts, err := a.Chain.GetTipSetFromKey(ctx, tsk) - if err != nil { - return address.Undef, xerrors.Errorf("loading tipset %s: %w", tsk, err) - } - - return a.StateManager.LookupRobustAddress(ctx, addr, ts) -} - func (m *StateModule) StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) { ts, err := m.Chain.GetTipSetFromKey(ctx, tsk) if err != nil { @@ -530,9 +549,7 @@ func (a *StateAPI) StateEncodeParams(ctx context.Context, toActCode cid.Cid, met return cbb.Bytes(), nil } -// MinerGetBaseInfo returns base information about a miner. -// -// This is on StateAPI because miner.Miner requires this, and MinerAPI requires miner.Miner. +// This is on StateAPI because miner.Miner requires this, and MinerAPI requires miner.Miner func (a *StateAPI) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) { // XXX: Gets the state by computing the tipset state, instead of looking at the parent. return stmgr.MinerGetBaseInfo(ctx, a.StateManager, a.Beacon, tsk, epoch, maddr, a.ProofVerifier) @@ -555,9 +572,6 @@ func (a *StateAPI) MinerCreateBlock(ctx context.Context, bt *api.BlockTemplate) for _, msg := range fblk.SecpkMessages { out.SecpkMessages = append(out.SecpkMessages, msg.Cid()) } - for _, msg := range fblk.CrossMessages { - out.CrossMessages = append(out.CrossMessages, msg.Cid()) - } return &out, nil } @@ -578,15 +592,16 @@ func (m *StateModule) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence vmsg := cmsg.VMMessage() t, err := stmgr.GetReturnType(ctx, m.StateManager, vmsg.To, vmsg.Method, ts) - if err != nil { - return nil, xerrors.Errorf("failed to get return type: %w", err) - } + if err == nil { + // user actors by definition are unknown, so don't cry over spilled milk + if err := t.UnmarshalCBOR(bytes.NewReader(recpt.Return)); err != nil { + return nil, err + } - if err := t.UnmarshalCBOR(bytes.NewReader(recpt.Return)); err != nil { - return nil, err + returndec = t + } else { + log.Warnf("unknown method %d for actor %s", vmsg.Method, vmsg.To) } - - returndec = t } return &api.MsgLookup{ @@ -652,15 +667,15 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSet return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) } - mstate, err := a.StateManager.GetMarketState(ctx, ts) + state, err := a.StateManager.GetMarketState(ctx, ts) if err != nil { return nil, err } - escrow, err := mstate.EscrowTable() + escrow, err := state.EscrowTable() if err != nil { return nil, err } - locked, err := mstate.LockedTable() + locked, err := state.LockedTable() if err != nil { return nil, err } @@ -684,25 +699,25 @@ 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 { return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) } - mstate, err := a.StateManager.GetMarketState(ctx, ts) + state, err := a.StateManager.GetMarketState(ctx, ts) if err != nil { return nil, err } - da, err := mstate.Proposals() + da, err := state.Proposals() if err != nil { return nil, err } - sa, err := mstate.States() + sa, err := state.States() if err != nil { return nil, err } @@ -714,7 +729,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, } @@ -734,14 +749,14 @@ func (m *StateModule) StateMarketStorageDeal(ctx context.Context, dealId abi.Dea } func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.Cid) (map[string]types.Actor, error) { - st := a.Chain.ActorStore(ctx) + store := a.Chain.ActorStore(ctx) - oldTree, err := state.LoadStateTree(st, old) + oldTree, err := state.LoadStateTree(store, old) if err != nil { return nil, xerrors.Errorf("failed to load old state tree: %w", err) } - newTree, err := state.LoadStateTree(st, new) + newTree, err := state.LoadStateTree(store, new) if err != nil { return nil, xerrors.Errorf("failed to load new state tree: %w", err) } @@ -790,17 +805,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 @@ -1044,7 +1059,7 @@ func (m *StateModule) MsigGetPending(ctx context.Context, addr address.Address, return nil, xerrors.Errorf("failed to load multisig actor state: %w", err) } - var out []*api.MsigTransaction + var out = []*api.MsigTransaction{} if err := msas.ForEachPendingTxn(func(id int64, txn multisig.Transaction) error { out = append(out, &api.MsigTransaction{ ID: id, @@ -1066,13 +1081,13 @@ 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) } - parentState, err := a.StateManager.ParentState(ts) + state, err := a.StateManager.ParentState(ts) if err != nil { return types.EmptyInt, xerrors.Errorf("loading state %s: %w", tsk, err) } @@ -1082,12 +1097,12 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr return types.EmptyInt, xerrors.Errorf("failed to get resolve size: %w", err) } - st := a.Chain.ActorStore(ctx) + store := a.Chain.ActorStore(ctx) var sectorWeight abi.StoragePower - if act, err := parentState.GetActor(market.Address); err != nil { + if act, err := state.GetActor(market.Address); err != nil { return types.EmptyInt, xerrors.Errorf("loading market actor %s: %w", maddr, err) - } else if s, err := market.Load(st, act); err != nil { + } else if s, err := market.Load(store, act); err != nil { return types.EmptyInt, xerrors.Errorf("loading market actor state %s: %w", maddr, err) } else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil { return types.EmptyInt, xerrors.Errorf("verifying deals for activation: %w", err) @@ -1098,9 +1113,9 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr } var powerSmoothed builtin.FilterEstimate - if act, err := parentState.GetActor(power.Address); err != nil { + if act, err := state.GetActor(power.Address); err != nil { return types.EmptyInt, xerrors.Errorf("loading power actor: %w", err) - } else if s, err := power.Load(st, act); err != nil { + } else if s, err := power.Load(store, act); err != nil { return types.EmptyInt, xerrors.Errorf("loading power actor state: %w", err) } else if p, err := s.TotalPowerSmoothed(); err != nil { return types.EmptyInt, xerrors.Errorf("failed to determine total power: %w", err) @@ -1108,12 +1123,12 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr powerSmoothed = p } - rewardActor, err := parentState.GetActor(reward.Address) + rewardActor, err := state.GetActor(reward.Address) if err != nil { return types.EmptyInt, xerrors.Errorf("loading miner actor: %w", err) } - rewardState, err := reward.Load(st, rewardActor) + rewardState, err := reward.Load(store, rewardActor) if err != nil { return types.EmptyInt, xerrors.Errorf("loading reward actor state: %w", err) } @@ -1126,14 +1141,14 @@ 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 { return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err) } - parentState, err := a.StateManager.ParentState(ts) + state, err := a.StateManager.ParentState(ts) if err != nil { return types.EmptyInt, xerrors.Errorf("loading state %s: %w", tsk, err) } @@ -1143,12 +1158,12 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr return types.EmptyInt, xerrors.Errorf("failed to get resolve size: %w", err) } - st := a.Chain.ActorStore(ctx) + store := a.Chain.ActorStore(ctx) var sectorWeight abi.StoragePower - if act, err := parentState.GetActor(market.Address); err != nil { + if act, err := state.GetActor(market.Address); err != nil { return types.EmptyInt, xerrors.Errorf("loading market actor: %w", err) - } else if s, err := market.Load(st, act); err != nil { + } else if s, err := market.Load(store, act); err != nil { return types.EmptyInt, xerrors.Errorf("loading market actor state: %w", err) } else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil { return types.EmptyInt, xerrors.Errorf("verifying deals for activation: %w", err) @@ -1162,9 +1177,9 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr powerSmoothed builtin.FilterEstimate pledgeCollateral abi.TokenAmount ) - if act, err := parentState.GetActor(power.Address); err != nil { + if act, err := state.GetActor(power.Address); err != nil { return types.EmptyInt, xerrors.Errorf("loading power actor: %w", err) - } else if s, err := power.Load(st, act); err != nil { + } else if s, err := power.Load(store, act); err != nil { return types.EmptyInt, xerrors.Errorf("loading power actor state: %w", err) } else if p, err := s.TotalPowerSmoothed(); err != nil { return types.EmptyInt, xerrors.Errorf("failed to determine total power: %w", err) @@ -1175,12 +1190,12 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr pledgeCollateral = c } - rewardActor, err := parentState.GetActor(reward.Address) + rewardActor, err := state.GetActor(reward.Address) if err != nil { return types.EmptyInt, xerrors.Errorf("loading reward actor: %w", err) } - rewardState, err := reward.Load(st, rewardActor) + rewardState, err := reward.Load(store, rewardActor) if err != nil { return types.EmptyInt, xerrors.Errorf("loading reward actor state: %w", err) } @@ -1251,8 +1266,9 @@ func (a *StateAPI) StateMinerSectorAllocated(ctx context.Context, maddr address. return mas.IsAllocated(s) } -// StateVerifierStatus returns the data cap for the given address. -// Returns zero if there is no entry in the data cap table for the address. +// StateVerifiedClientStatus returns the data cap for the given address. +// Returns zero if there is no entry in the data cap table for the +// address. func (a *StateAPI) StateVerifierStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) { act, err := a.StateGetActor(ctx, verifreg.Address, tsk) if err != nil { @@ -1442,39 +1458,3 @@ func (a *StateAPI) StateGetRandomnessFromBeacon(ctx context.Context, personaliza return a.StateManager.GetRandomnessFromBeacon(ctx, personalization, randEpoch, entropy, tsk) } - -func (a *StateAPI) StateGetNetworkParams(ctx context.Context) (*api.NetworkParams, error) { - networkName, err := a.StateNetworkName(ctx) - if err != nil { - return nil, err - } - - return &api.NetworkParams{ - NetworkName: networkName, - BlockDelaySecs: build.BlockDelaySecs, - ConsensusMinerMinPower: build.ConsensusMinerMinPower, - SupportedProofTypes: build.SupportedProofTypes, - PreCommitChallengeDelay: build.PreCommitChallengeDelay, - ForkUpgradeParams: api.ForkUpgradeParams{ - UpgradeSmokeHeight: build.UpgradeSmokeHeight, - UpgradeBreezeHeight: build.UpgradeBreezeHeight, - UpgradeIgnitionHeight: build.UpgradeIgnitionHeight, - UpgradeLiftoffHeight: build.UpgradeLiftoffHeight, - UpgradeAssemblyHeight: build.UpgradeAssemblyHeight, - UpgradeRefuelHeight: build.UpgradeRefuelHeight, - UpgradeTapeHeight: build.UpgradeTapeHeight, - UpgradeKumquatHeight: build.UpgradeKumquatHeight, - BreezeGasTampingDuration: build.BreezeGasTampingDuration, - UpgradeCalicoHeight: build.UpgradeCalicoHeight, - UpgradePersianHeight: build.UpgradePersianHeight, - UpgradeOrangeHeight: build.UpgradeOrangeHeight, - UpgradeClausHeight: build.UpgradeClausHeight, - UpgradeTrustHeight: build.UpgradeTrustHeight, - UpgradeNorwegianHeight: build.UpgradeNorwegianHeight, - UpgradeTurboHeight: build.UpgradeTurboHeight, - UpgradeHyperdriveHeight: build.UpgradeHyperdriveHeight, - UpgradeChocolateHeight: build.UpgradeChocolateHeight, - UpgradeOhSnapHeight: build.UpgradeOhSnapHeight, - }, - }, 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..3996fec83 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" @@ -37,10 +38,8 @@ import ( "github.com/filecoin-project/go-fil-markets/piecestore" "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/storagemarket" - filmktsstore "github.com/filecoin-project/go-fil-markets/stores" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" - mktsdagstore "github.com/filecoin-project/lotus/markets/dagstore" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" "github.com/filecoin-project/lotus/extern/sector-storage/fsutil" @@ -85,7 +84,6 @@ type StorageMinerAPI struct { SectorBlocks *sectorblocks.SectorBlocks `optional:"true"` Host host.Host `optional:"true"` DAGStore *dagstore.DAGStore `optional:"true"` - DAGStoreWrapper *mktsdagstore.Wrapper `optional:"true"` // Miner / storage Miner *storage.Miner `optional:"true"` @@ -413,7 +411,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 { @@ -428,10 +426,6 @@ func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, return sm.WdPoSt.ComputePoSt(ctx, dlIdx, ts) } -func (sm *StorageMinerAPI) ComputeDataCid(ctx context.Context, pieceSize abi.UnpaddedPieceSize, pieceData sto.Data) (abi.PieceInfo, error) { - return sm.StorageMgr.DataCid(ctx, pieceSize, pieceData) -} - func (sm *StorageMinerAPI) WorkerConnect(ctx context.Context, url string) error { w, err := connectRemoteWorker(ctx, sm, url) if err != nil { @@ -461,7 +455,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 +466,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 +477,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) } @@ -795,35 +789,6 @@ func (sm *StorageMinerAPI) DagstoreListShards(ctx context.Context) ([]api.Dagsto return ret, nil } -func (sm *StorageMinerAPI) DagstoreRegisterShard(ctx context.Context, key string) error { - if sm.DAGStore == nil { - return fmt.Errorf("dagstore not available on this node") - } - - // First check if the shard has already been registered - k := shard.KeyFromString(key) - _, err := sm.DAGStore.GetShardInfo(k) - if err == nil { - // Shard already registered, nothing further to do - return nil - } - // If the shard is not registered we would expect ErrShardUnknown - if !errors.Is(err, dagstore.ErrShardUnknown) { - return fmt.Errorf("getting shard info from DAG store: %w", err) - } - - pieceCid, err := cid.Parse(key) - if err != nil { - return fmt.Errorf("parsing shard key as piece cid: %w", err) - } - - if err = filmktsstore.RegisterShardSync(ctx, sm.DAGStoreWrapper, pieceCid, "", true); err != nil { - return fmt.Errorf("failed to register shard: %w", err) - } - - return nil -} - func (sm *StorageMinerAPI) DagstoreInitializeShard(ctx context.Context, key string) error { if sm.DAGStore == nil { return fmt.Errorf("dagstore not available on this node") @@ -1108,7 +1073,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..4384bb3f3 --- /dev/null +++ b/node/modules/builtin_actors.go @@ -0,0 +1,169 @@ +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.GetNetworkBundle() + + 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. + 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() + + 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 39fc6d706..792a9eac9 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" @@ -178,3 +179,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 7ba8865d7..9cb977a22 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..0fb3a399c 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" @@ -206,7 +208,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 +220,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 +232,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 +246,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 +260,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 +333,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/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/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/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..0da2cb5ea 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-0.20220514164640-94e0d5e123bd github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 github.com/hashicorp/go-multierror v1.1.1 @@ -94,20 +94,20 @@ 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 github.com/filecoin-project/go-statestore v0.2.0 // indirect 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-0.20220514165557-0b29a778685b // indirect + github.com/filecoin-project/specs-actors/v6 v6.0.2-0.20220511204807-569c6d12432b // indirect + github.com/filecoin-project/specs-actors/v7 v7.0.1-0.20220511223846-637436c27154 // indirect + github.com/filecoin-project/specs-actors/v8 v8.0.0-20220422153930-0afe155bfffa // indirect + github.com/filecoin-project/specs-storage v0.4.0 // 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 @@ -284,7 +284,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 @@ -294,9 +293,8 @@ 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/stretchr/testify v1.7.1 // indirect + github.com/stretchr/testify v1.7.0 // 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 +304,13 @@ 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/pubsub v0.0.0-20190708150250-92bcb0691325 // 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..4cbce36c2 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-0.20220511200558-7a486892661a/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg= +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.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,32 @@ 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 h1:PoQ9+o9zjqD7gBMAvG0nwvpmmONo2lFajmjIfzlqeFc= +github.com/filecoin-project/specs-actors v0.9.15-0.20220514164640-94e0d5e123bd/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-0.20220511204328-97fa6fffc45a/go.mod h1:tg58UmhrivJsYrnsvWNEr+RQugRZCpJA+aTBE71t48E= 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.6-0.20220514165557-0b29a778685b h1:0DevEGyWsWWItaOuqzMa2b2swyCAwRp6crY3uS35qGk= +github.com/filecoin-project/specs-actors/v5 v5.0.6-0.20220514165557-0b29a778685b/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-0.20220511204807-569c6d12432b h1:UaMSIWqvyBAkM5/hA/iVcTrnwI7IOgQI0Xi4wEkmYM4= +github.com/filecoin-project/specs-actors/v6 v6.0.2-0.20220511204807-569c6d12432b/go.mod h1:UkunB8pzBOV5Rzx0BmvVB2mxMV6CXEnHAC5VlMokOVE= 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-0.20220511223846-637436c27154 h1:NKA2mpz3GAksmrP7P13zLufvoYG9DlasgKxdhrk9gGM= +github.com/filecoin-project/specs-actors/v7 v7.0.1-0.20220511223846-637436c27154/go.mod h1:2pWr2Soyl4yfOkoMThzj41l2lPIRC+CUgU5cW3wI+K4= +github.com/filecoin-project/specs-actors/v8 v8.0.0-20220422153930-0afe155bfffa h1:P9l2WQMvWUJ450esBttbAaqH8Lhe1hu1W2J6cQsiZcA= +github.com/filecoin-project/specs-actors/v8 v8.0.0-20220422153930-0afe155bfffa/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA= +github.com/filecoin-project/specs-storage v0.4.0 h1:Gima+B0dNwtsLJrvpg40W3HgHOgWTYyl8lPEYeOxuPk= +github.com/filecoin-project/specs-storage v0.4.0/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,6 +1335,7 @@ 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.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI= 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-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo= @@ -1503,6 +1512,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 +1608,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= @@ -2105,8 +2116,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 +2250,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 +2313,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 +2341,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 +2515,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 +2879,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 +3086,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"