From 0b565eb946f9da5c382d3a811efc2ab325a3348e Mon Sep 17 00:00:00 2001 From: Aayush Date: Tue, 6 Sep 2022 11:49:29 -0400 Subject: [PATCH] introduce v9 actors and nv17 --- api/api_full.go | 2 +- api/api_gateway.go | 2 +- api/api_storage.go | 2 +- api/cbor_gen.go | 7 +- api/mocks/mock_full.go | 20 +- api/proxy_gen.go | 20 +- api/v0api/full.go | 2 +- api/v0api/gateway.go | 2 +- api/v0api/proxy_gen.go | 12 +- api/v0api/v0mocks/mock_full.go | 20 +- api/v0api/v1_wrapper.go | 2 +- build/builtin_actors.go | 14 +- build/builtin_actors_test.go | 8 +- build/params_2k.go | 7 +- build/params_butterfly.go | 11 +- build/params_calibnet.go | 6 +- build/params_interop.go | 17 +- build/params_mainnet.go | 13 +- build/params_shared_vals.go | 2 +- build/params_testground.go | 9 +- chain/actors/actor_cids.go | 161 ++--- chain/actors/agen/main.go | 45 +- chain/actors/builtin/account/account.go | 45 +- .../actors/builtin/account/actor.go.template | 11 +- chain/actors/builtin/account/v0.go | 6 +- chain/actors/builtin/account/v2.go | 6 +- chain/actors/builtin/account/v3.go | 6 +- chain/actors/builtin/account/v4.go | 6 +- chain/actors/builtin/account/v5.go | 6 +- chain/actors/builtin/account/v6.go | 6 +- chain/actors/builtin/account/v7.go | 6 +- chain/actors/builtin/account/v8.go | 6 +- chain/actors/builtin/account/v9.go | 40 ++ chain/actors/builtin/builtin.go | 26 +- chain/actors/builtin/builtin.go.template | 4 + chain/actors/builtin/cron/actor.go.template | 10 +- chain/actors/builtin/cron/cron.go | 45 +- chain/actors/builtin/cron/v0.go | 4 +- chain/actors/builtin/cron/v2.go | 4 +- chain/actors/builtin/cron/v3.go | 4 +- chain/actors/builtin/cron/v4.go | 4 +- chain/actors/builtin/cron/v5.go | 4 +- chain/actors/builtin/cron/v6.go | 4 +- chain/actors/builtin/cron/v7.go | 4 +- chain/actors/builtin/cron/v8.go | 4 +- chain/actors/builtin/cron/v9.go | 35 ++ chain/actors/builtin/init/actor.go.template | 10 +- chain/actors/builtin/init/init.go | 51 +- chain/actors/builtin/init/v0.go | 10 +- chain/actors/builtin/init/v2.go | 10 +- chain/actors/builtin/init/v3.go | 11 +- chain/actors/builtin/init/v4.go | 11 +- chain/actors/builtin/init/v5.go | 11 +- chain/actors/builtin/init/v6.go | 11 +- chain/actors/builtin/init/v7.go | 11 +- chain/actors/builtin/init/v8.go | 10 +- chain/actors/builtin/init/v9.go | 113 ++++ chain/actors/builtin/market/actor.go.template | 46 +- chain/actors/builtin/market/market.go | 92 +-- chain/actors/builtin/market/state.go.template | 28 +- chain/actors/builtin/market/v0.go | 11 +- chain/actors/builtin/market/v2.go | 11 +- chain/actors/builtin/market/v3.go | 11 +- chain/actors/builtin/market/v4.go | 11 +- chain/actors/builtin/market/v5.go | 11 +- chain/actors/builtin/market/v6.go | 10 +- chain/actors/builtin/market/v7.go | 10 +- chain/actors/builtin/market/v8.go | 32 +- chain/actors/builtin/market/v9.go | 326 ++++++++++ chain/actors/builtin/miner/actor.go.template | 4 +- chain/actors/builtin/miner/miner.go | 47 +- chain/actors/builtin/miner/state.go.template | 14 +- chain/actors/builtin/miner/v0.go | 31 +- chain/actors/builtin/miner/v2.go | 30 +- chain/actors/builtin/miner/v3.go | 31 +- chain/actors/builtin/miner/v4.go | 31 +- chain/actors/builtin/miner/v5.go | 31 +- chain/actors/builtin/miner/v6.go | 31 +- chain/actors/builtin/miner/v7.go | 31 +- chain/actors/builtin/miner/v8.go | 30 +- chain/actors/builtin/miner/v9.go | 562 ++++++++++++++++++ .../actors/builtin/multisig/actor.go.template | 17 +- .../builtin/multisig/message.go.template | 12 +- chain/actors/builtin/multisig/message0.go | 4 +- chain/actors/builtin/multisig/message2.go | 4 +- chain/actors/builtin/multisig/message3.go | 4 +- chain/actors/builtin/multisig/message4.go | 4 +- chain/actors/builtin/multisig/message5.go | 4 +- chain/actors/builtin/multisig/message6.go | 4 +- chain/actors/builtin/multisig/message7.go | 4 +- chain/actors/builtin/multisig/message8.go | 12 +- chain/actors/builtin/multisig/message9.go | 77 +++ chain/actors/builtin/multisig/multisig.go | 75 ++- chain/actors/builtin/multisig/v0.go | 8 +- chain/actors/builtin/multisig/v2.go | 8 +- chain/actors/builtin/multisig/v3.go | 9 +- chain/actors/builtin/multisig/v4.go | 9 +- chain/actors/builtin/multisig/v5.go | 9 +- chain/actors/builtin/multisig/v6.go | 9 +- chain/actors/builtin/multisig/v7.go | 9 +- chain/actors/builtin/multisig/v8.go | 8 +- chain/actors/builtin/multisig/v9.go | 117 ++++ chain/actors/builtin/paych/actor.go.template | 7 +- .../actors/builtin/paych/message.go.template | 37 +- chain/actors/builtin/paych/message0.go | 2 + chain/actors/builtin/paych/message2.go | 2 + chain/actors/builtin/paych/message3.go | 2 + chain/actors/builtin/paych/message4.go | 2 + chain/actors/builtin/paych/message5.go | 2 + chain/actors/builtin/paych/message6.go | 2 + chain/actors/builtin/paych/message7.go | 2 + chain/actors/builtin/paych/message8.go | 7 +- chain/actors/builtin/paych/message9.go | 111 ++++ chain/actors/builtin/paych/paych.go | 41 +- chain/actors/builtin/paych/v0.go | 5 +- chain/actors/builtin/paych/v2.go | 5 +- chain/actors/builtin/paych/v3.go | 5 +- chain/actors/builtin/paych/v4.go | 5 +- chain/actors/builtin/paych/v5.go | 5 +- chain/actors/builtin/paych/v6.go | 5 +- chain/actors/builtin/paych/v7.go | 5 +- chain/actors/builtin/paych/v8.go | 5 +- chain/actors/builtin/paych/v9.go | 114 ++++ chain/actors/builtin/power/actor.go.template | 10 +- chain/actors/builtin/power/power.go | 53 +- chain/actors/builtin/power/v0.go | 10 +- chain/actors/builtin/power/v2.go | 10 +- chain/actors/builtin/power/v3.go | 11 +- chain/actors/builtin/power/v4.go | 11 +- chain/actors/builtin/power/v5.go | 11 +- chain/actors/builtin/power/v6.go | 11 +- chain/actors/builtin/power/v7.go | 11 +- chain/actors/builtin/power/v8.go | 10 +- chain/actors/builtin/power/v9.go | 186 ++++++ chain/actors/builtin/registry.go | 78 +++ chain/actors/builtin/registry.go.template | 69 +++ chain/actors/builtin/reward/actor.go.template | 10 +- chain/actors/builtin/reward/reward.go | 47 +- chain/actors/builtin/reward/v0.go | 8 +- chain/actors/builtin/reward/v2.go | 8 +- chain/actors/builtin/reward/v3.go | 8 +- chain/actors/builtin/reward/v4.go | 8 +- chain/actors/builtin/reward/v5.go | 8 +- chain/actors/builtin/reward/v6.go | 8 +- chain/actors/builtin/reward/v7.go | 8 +- chain/actors/builtin/reward/v8.go | 8 +- chain/actors/builtin/reward/v9.go | 98 +++ chain/actors/builtin/system/actor.go.template | 10 +- chain/actors/builtin/system/system.go | 44 +- chain/actors/builtin/system/v0.go | 4 +- chain/actors/builtin/system/v2.go | 4 +- chain/actors/builtin/system/v3.go | 4 +- chain/actors/builtin/system/v4.go | 4 +- chain/actors/builtin/system/v5.go | 4 +- chain/actors/builtin/system/v6.go | 4 +- chain/actors/builtin/system/v7.go | 4 +- chain/actors/builtin/system/v8.go | 4 +- chain/actors/builtin/system/v9.go | 43 ++ .../actors/builtin/verifreg/actor.go.template | 10 +- chain/actors/builtin/verifreg/v0.go | 8 +- chain/actors/builtin/verifreg/v2.go | 8 +- chain/actors/builtin/verifreg/v3.go | 11 +- chain/actors/builtin/verifreg/v4.go | 11 +- chain/actors/builtin/verifreg/v5.go | 11 +- chain/actors/builtin/verifreg/v6.go | 11 +- chain/actors/builtin/verifreg/v7.go | 11 +- chain/actors/builtin/verifreg/v8.go | 10 +- chain/actors/builtin/verifreg/v9.go | 83 +++ chain/actors/builtin/verifreg/verifreg.go | 42 +- chain/actors/manifest.go | 19 +- chain/actors/policy/policy.go | 237 ++++---- chain/actors/policy/policy.go.template | 50 +- chain/actors/version.go | 35 +- chain/consensus/filcns/compute_state.go | 48 +- chain/consensus/filcns/upgrades.go | 128 +++- chain/exchange/cbor_gen.go | 3 +- chain/gen/genesis/f00_system.go | 5 +- chain/gen/genesis/f01_init.go | 3 +- chain/gen/genesis/f02_reward.go | 3 +- chain/gen/genesis/f03_cron.go | 3 +- chain/gen/genesis/f04_power.go | 3 +- chain/gen/genesis/f05_market.go | 3 +- chain/gen/genesis/f06_vreg.go | 3 +- chain/gen/genesis/genesis.go | 9 +- chain/gen/genesis/miners.go | 22 +- chain/state/statetree.go | 2 +- chain/stmgr/actors.go | 3 +- chain/stmgr/forks_test.go | 7 +- chain/sync_test.go | 4 + chain/types/cbor_gen.go | 7 +- chain/vm/cbor_gen.go | 3 +- chain/vm/fvm.go | 9 +- chain/vm/invoker.go | 34 +- chain/vm/mkactor.go | 21 +- chain/vm/runtime.go | 3 +- cli/chain.go | 4 +- cli/multisig.go | 2 +- cli/servicesmock_test.go | 4 +- cli/state.go | 9 +- cmd/lotus-miner/init.go | 3 +- cmd/lotus-miner/precommits-info.go | 2 +- cmd/lotus-miner/sectors.go | 2 +- cmd/lotus-pcr/main.go | 2 +- cmd/lotus-shed/msg.go | 2 +- cmd/lotus-sim/info.go | 2 +- .../simulation/blockbuilder/blockbuilder.go | 6 +- cmd/lotus-sim/simulation/node.go | 2 +- .../simulation/stages/commit_queue.go | 2 +- .../simulation/stages/commit_queue_test.go | 2 +- cmd/lotus-sim/simulation/stages/interface.go | 2 +- .../simulation/stages/precommit_stage.go | 2 +- .../simulation/stages/provecommit_stage.go | 2 +- cmd/lotus-wallet/interactive.go | 4 +- cmd/tvx/extract_many.go | 2 +- conformance/chaos/cbor_gen.go | 7 +- conformance/driver.go | 4 +- documentation/en/cli-lotus-miner.md | 2 +- documentation/en/cli-lotus.md | 2 +- gen/api/proxygen.go | 26 +- gen/inlinegen-data.json | 8 +- go.mod | 3 +- go.sum | 7 +- itests/kit/ensemble_opts_nv.go | 6 +- itests/lite_migration_test.go | 4 +- journal/mockjournal/journal.go | 3 +- lib/retry/retry.go | 3 +- lotuspond/front/src/chain/methodgen.go | 2 +- markets/dagstore/mocks/mock_lotus_accessor.go | 3 +- .../ondealsectorcommitted_test.go | 2 +- node/bundle/bundle.go | 6 +- node/config/cfgdocgen/gen.go | 4 +- node/hello/cbor_gen.go | 3 +- node/impl/full/multisig.go | 3 +- node/impl/full/state.go | 7 +- node/impl/storminer.go | 2 +- paychmgr/cbor_gen.go | 5 +- paychmgr/paych.go | 4 +- storage/paths/mocks/index.go | 4 +- storage/paths/mocks/pf.go | 4 +- storage/paths/mocks/store.go | 4 +- storage/pipeline/cbor_gen.go | 8 +- storage/pipeline/commit_batch.go | 6 +- storage/pipeline/commit_batch_test.go | 2 +- storage/pipeline/fsm_events.go | 2 +- storage/pipeline/mocks/api.go | 8 +- storage/pipeline/mocks/mock_commit_batcher.go | 6 +- .../pipeline/mocks/mock_precommit_batcher.go | 4 +- storage/pipeline/precommit_batch.go | 11 +- storage/pipeline/precommit_batch_test.go | 2 +- storage/pipeline/sealing.go | 2 +- storage/pipeline/states_failed.go | 2 +- storage/pipeline/states_replica_update.go | 2 +- storage/pipeline/states_sealing.go | 10 +- storage/pipeline/types.go | 2 +- storage/sealer/cbor_gen.go | 3 +- storage/wdpost/wdpost_changehandler.go | 2 +- storage/wdpost/wdpost_changehandler_test.go | 2 +- storage/wdpost/wdpost_journal.go | 2 +- storage/wdpost/wdpost_run.go | 2 +- storage/wdpost/wdpost_run_faults.go | 2 +- storage/wdpost/wdpost_run_test.go | 5 +- storage/wdpost/wdpost_sched.go | 2 +- 262 files changed, 3866 insertions(+), 1306 deletions(-) create mode 100644 chain/actors/builtin/account/v9.go create mode 100644 chain/actors/builtin/cron/v9.go create mode 100644 chain/actors/builtin/init/v9.go create mode 100644 chain/actors/builtin/market/v9.go create mode 100644 chain/actors/builtin/miner/v9.go create mode 100644 chain/actors/builtin/multisig/message9.go create mode 100644 chain/actors/builtin/multisig/v9.go create mode 100644 chain/actors/builtin/paych/message9.go create mode 100644 chain/actors/builtin/paych/v9.go create mode 100644 chain/actors/builtin/power/v9.go create mode 100644 chain/actors/builtin/registry.go create mode 100644 chain/actors/builtin/registry.go.template create mode 100644 chain/actors/builtin/reward/v9.go create mode 100644 chain/actors/builtin/system/v9.go create mode 100644 chain/actors/builtin/verifreg/v9.go diff --git a/api/api_full.go b/api/api_full.go index 2c98eaa5363..155601fc800 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -18,8 +18,8 @@ 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/v8/market" - "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/builtin/v9/miner" "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" diff --git a/api/api_gateway.go b/api/api_gateway.go index 7d84e807c1c..b95299493ef 100644 --- a/api/api_gateway.go +++ b/api/api_gateway.go @@ -8,7 +8,7 @@ import ( "github.com/filecoin-project/go-address" "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/v9/miner" "github.com/filecoin-project/go-state-types/dline" apitypes "github.com/filecoin-project/lotus/api/types" diff --git a/api/api_storage.go b/api/api_storage.go index 93bb1f86964..1b6498cab15 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -18,7 +18,7 @@ import ( "github.com/filecoin-project/go-jsonrpc/auth" "github.com/filecoin-project/go-state-types/abi" "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/v9/miner" abinetwork "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors/builtin" diff --git a/api/cbor_gen.go b/api/cbor_gen.go index 66655fd7587..40982779e96 100644 --- a/api/cbor_gen.go +++ b/api/cbor_gen.go @@ -8,13 +8,12 @@ import ( "math" "sort" - cid "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - xerrors "golang.org/x/xerrors" - abi "github.com/filecoin-project/go-state-types/abi" 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" ) var _ = xerrors.Errorf diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index 2640d6032f6..fd2d5520ca9 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -10,15 +10,6 @@ import ( reflect "reflect" time "time" - gomock "github.com/golang/mock/gomock" - uuid "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - cid "github.com/ipfs/go-cid" - metrics "github.com/libp2p/go-libp2p/core/metrics" - network0 "github.com/libp2p/go-libp2p/core/network" - peer "github.com/libp2p/go-libp2p/core/peer" - protocol "github.com/libp2p/go-libp2p/core/protocol" - address "github.com/filecoin-project/go-address" bitfield "github.com/filecoin-project/go-bitfield" datatransfer "github.com/filecoin-project/go-data-transfer" @@ -26,12 +17,11 @@ 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" + miner "github.com/filecoin-project/go-state-types/builtin/v9/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" apitypes "github.com/filecoin-project/lotus/api/types" miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -39,6 +29,14 @@ 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" + gomock "github.com/golang/mock/gomock" + uuid "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + cid "github.com/ipfs/go-cid" + metrics "github.com/libp2p/go-libp2p/core/metrics" + network0 "github.com/libp2p/go-libp2p/core/network" + peer "github.com/libp2p/go-libp2p/core/peer" + protocol "github.com/libp2p/go-libp2p/core/protocol" ) // MockFullNode is a mock of FullNode interface. diff --git a/api/proxy_gen.go b/api/proxy_gen.go index 274b9ee1240..79dd4d334f9 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -7,15 +7,6 @@ import ( "encoding/json" "time" - "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p/core/metrics" - "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" datatransfer "github.com/filecoin-project/go-data-transfer" @@ -24,13 +15,12 @@ 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/builtin/v9/miner" "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" lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -42,6 +32,14 @@ import ( "github.com/filecoin-project/lotus/storage/sealer/fsutil" "github.com/filecoin-project/lotus/storage/sealer/sealtasks" "github.com/filecoin-project/lotus/storage/sealer/storiface" + "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-cid" + "github.com/libp2p/go-libp2p/core/metrics" + "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/protocol" + "golang.org/x/xerrors" ) var ErrNotSupported = xerrors.New("method not supported") diff --git a/api/v0api/full.go b/api/v0api/full.go index cca358ada28..3600663b4fe 100644 --- a/api/v0api/full.go +++ b/api/v0api/full.go @@ -14,8 +14,8 @@ 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/builtin/v9/miner" "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" diff --git a/api/v0api/gateway.go b/api/v0api/gateway.go index ab374b59caa..bd55917c712 100644 --- a/api/v0api/gateway.go +++ b/api/v0api/gateway.go @@ -8,7 +8,7 @@ import ( "github.com/filecoin-project/go-address" "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/v9/miner" "github.com/filecoin-project/go-state-types/dline" abinetwork "github.com/filecoin-project/go-state-types/network" diff --git a/api/v0api/proxy_gen.go b/api/v0api/proxy_gen.go index b568fe15626..3d4744fcef9 100644 --- a/api/v0api/proxy_gen.go +++ b/api/v0api/proxy_gen.go @@ -5,23 +5,17 @@ package v0api import ( "context" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-cid" - "github.com/libp2p/go-libp2p/core/peer" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" datatransfer "github.com/filecoin-project/go-data-transfer" "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/builtin/v9/miner" "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" lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -29,6 +23,10 @@ import ( marketevents "github.com/filecoin-project/lotus/markets/loggers" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/repo/imports" + blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-cid" + "github.com/libp2p/go-libp2p/core/peer" + "golang.org/x/xerrors" ) var ErrNotSupported = xerrors.New("method not supported") diff --git a/api/v0api/v0mocks/mock_full.go b/api/v0api/v0mocks/mock_full.go index 7dc9c0d63ff..4f65c06722f 100644 --- a/api/v0api/v0mocks/mock_full.go +++ b/api/v0api/v0mocks/mock_full.go @@ -9,15 +9,6 @@ import ( reflect "reflect" time "time" - gomock "github.com/golang/mock/gomock" - uuid "github.com/google/uuid" - blocks "github.com/ipfs/go-block-format" - cid "github.com/ipfs/go-cid" - metrics "github.com/libp2p/go-libp2p/core/metrics" - network0 "github.com/libp2p/go-libp2p/core/network" - peer "github.com/libp2p/go-libp2p/core/peer" - protocol "github.com/libp2p/go-libp2p/core/protocol" - address "github.com/filecoin-project/go-address" bitfield "github.com/filecoin-project/go-bitfield" datatransfer "github.com/filecoin-project/go-data-transfer" @@ -26,12 +17,11 @@ 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" + miner "github.com/filecoin-project/go-state-types/builtin/v9/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" apitypes "github.com/filecoin-project/lotus/api/types" v0api "github.com/filecoin-project/lotus/api/v0api" @@ -41,6 +31,14 @@ 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" + gomock "github.com/golang/mock/gomock" + uuid "github.com/google/uuid" + blocks "github.com/ipfs/go-block-format" + cid "github.com/ipfs/go-cid" + metrics "github.com/libp2p/go-libp2p/core/metrics" + network0 "github.com/libp2p/go-libp2p/core/network" + peer "github.com/libp2p/go-libp2p/core/peer" + protocol "github.com/libp2p/go-libp2p/core/protocol" ) // MockFullNode is a mock of FullNode interface. diff --git a/api/v0api/v1_wrapper.go b/api/v0api/v1_wrapper.go index d2b58ccb85a..f58b0420f32 100644 --- a/api/v0api/v1_wrapper.go +++ b/api/v0api/v1_wrapper.go @@ -12,7 +12,7 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/lotus/api" diff --git a/build/builtin_actors.go b/build/builtin_actors.go index ba61fc70e33..4d283919e2a 100644 --- a/build/builtin_actors.go +++ b/build/builtin_actors.go @@ -18,6 +18,8 @@ import ( "github.com/ipld/go-car" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -28,14 +30,14 @@ var embeddedBuiltinActorReleases embed.FS func init() { if BundleOverrides == nil { - BundleOverrides = make(map[actors.Version]string) + BundleOverrides = make(map[actorstypes.Version]string) } for _, av := range actors.Versions { path := os.Getenv(fmt.Sprintf("LOTUS_BUILTIN_ACTORS_V%d_BUNDLE", av)) if path == "" { continue } - BundleOverrides[actors.Version(av)] = path + BundleOverrides[actorstypes.Version(av)] = path } if err := loadManifests(NetworkBundle); err != nil { panic(err) @@ -55,7 +57,7 @@ func UseNetworkBundle(netw string) error { } func loadManifests(netw string) error { - overridden := make(map[actors.Version]struct{}) + overridden := make(map[actorstypes.Version]struct{}) var newMetadata []*BuiltinActorsMetadata // First, prefer overrides. for av, path := range BundleOverrides { @@ -94,7 +96,7 @@ func loadManifests(netw string) error { type BuiltinActorsMetadata struct { Network string - Version actors.Version + Version actorstypes.Version ManifestCid cid.Cid Actors map[string]cid.Cid } @@ -182,7 +184,7 @@ func readEmbeddedBuiltinActorsMetadata(bundle string) ([]*BuiltinActorsMetadata, } bundles = append(bundles, &BuiltinActorsMetadata{ Network: name, - Version: actors.Version(version), + Version: actorstypes.Version(version), ManifestCid: root, Actors: actorCids, }) @@ -229,7 +231,7 @@ func readBundleManifest(r io.Reader) (cid.Cid, map[string]cid.Cid, error) { } // GetEmbeddedBuiltinActorsBundle returns the builtin-actors bundle for the given actors version. -func GetEmbeddedBuiltinActorsBundle(version actors.Version) ([]byte, bool) { +func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version) ([]byte, bool) { fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("actors/v%d.tar.zst", version)) if err != nil { return nil, false diff --git a/build/builtin_actors_test.go b/build/builtin_actors_test.go index 7a5c0936d15..489f0ad7de3 100644 --- a/build/builtin_actors_test.go +++ b/build/builtin_actors_test.go @@ -5,6 +5,8 @@ import ( "github.com/stretchr/testify/require" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" ) @@ -19,16 +21,16 @@ func TestEmbeddedMetadata(t *testing.T) { // Test that we're registering the manifest correctly. func TestRegistration(t *testing.T) { - manifestCid, found := actors.GetManifest(actors.Version8) + manifestCid, found := actors.GetManifest(actorstypes.Version8) require.True(t, found) require.True(t, manifestCid.Defined()) for _, key := range actors.GetBuiltinActorsKeys() { - actorCid, found := actors.GetActorCodeID(actors.Version8, key) + actorCid, found := actors.GetActorCodeID(actorstypes.Version8, key) require.True(t, found) name, version, found := actors.GetActorMetaByCode(actorCid) require.True(t, found) - require.Equal(t, actors.Version8, version) + require.Equal(t, actorstypes.Version8, version) require.Equal(t, key, name) } } diff --git a/build/params_2k.go b/build/params_2k.go index 476d4fba182..aaab3f835c4 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -10,9 +10,9 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -20,7 +20,7 @@ const BootstrappersFile = "" const GenesisFile = "" var NetworkBundle = "devnet" -var BundleOverrides map[actors.Version]string +var BundleOverrides map[actorstypes.Version]string const GenesisNetworkVersion = network.Version16 @@ -56,6 +56,8 @@ var UpgradeOhSnapHeight = abi.ChainEpoch(-18) var UpgradeSkyrHeight = abi.ChainEpoch(-19) +var UpgradeV17Height = abi.ChainEpoch(99999999999999) + var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, } @@ -107,6 +109,7 @@ func init() { UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight) UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight) UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight) + UpgradeV17Height = getUpgradeHeight("LOTUS_V17_HEIGHT", UpgradeV17Height) BuildType |= Build2k diff --git a/build/params_butterfly.go b/build/params_butterfly.go index f43c3077891..59318a1c339 100644 --- a/build/params_butterfly.go +++ b/build/params_butterfly.go @@ -8,10 +8,10 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -19,10 +19,10 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, } -const GenesisNetworkVersion = network.Version15 +const GenesisNetworkVersion = network.Version16 var NetworkBundle = "butterflynet" -var BundleOverrides map[actors.Version]string +var BundleOverrides map[actorstypes.Version]string const BootstrappersFile = "butterflynet.pi" const GenesisFile = "butterflynet.car" @@ -47,10 +47,9 @@ const UpgradeNorwegianHeight = -14 const UpgradeTurboHeight = -15 const UpgradeHyperdriveHeight = -16 const UpgradeChocolateHeight = -17 - const UpgradeOhSnapHeight = -18 - -const UpgradeSkyrHeight = abi.ChainEpoch(50) +const UpgradeSkyrHeight = -19 +const UpgradeV17Height = abi.ChainEpoch(99999999999999) var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg512MiBV1, diff --git a/build/params_calibnet.go b/build/params_calibnet.go index 9ecfc048dc7..eeb707fca99 100644 --- a/build/params_calibnet.go +++ b/build/params_calibnet.go @@ -8,10 +8,10 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -22,7 +22,7 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ const GenesisNetworkVersion = network.Version0 var NetworkBundle = "calibrationnet" -var BundleOverrides map[actors.Version]string +var BundleOverrides map[actorstypes.Version]string const BootstrappersFile = "calibnet.pi" const GenesisFile = "calibnet.car" @@ -66,6 +66,8 @@ const UpgradeOhSnapHeight = 682006 // 2022-06-16T17:30:00Z const UpgradeSkyrHeight = 1044660 +var UpgradeV17Height = abi.ChainEpoch(99999999999999) + var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, abi.RegisteredSealProof_StackedDrg64GiBV1, diff --git a/build/params_interop.go b/build/params_interop.go index f3af7aed42b..2e089dcd66a 100644 --- a/build/params_interop.go +++ b/build/params_interop.go @@ -11,20 +11,20 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) var NetworkBundle = "caterpillarnet" -var BundleOverrides map[actors.Version]string +var BundleOverrides map[actorstypes.Version]string const BootstrappersFile = "interopnet.pi" const GenesisFile = "interopnet.car" -const GenesisNetworkVersion = network.Version15 +const GenesisNetworkVersion = network.Version16 var UpgradeBreezeHeight = abi.ChainEpoch(-1) @@ -34,26 +34,22 @@ var UpgradeSmokeHeight = abi.ChainEpoch(-1) var UpgradeIgnitionHeight = abi.ChainEpoch(-2) var UpgradeRefuelHeight = abi.ChainEpoch(-3) var UpgradeTapeHeight = abi.ChainEpoch(-4) - var UpgradeAssemblyHeight = abi.ChainEpoch(-5) var UpgradeLiftoffHeight = abi.ChainEpoch(-6) - var UpgradeKumquatHeight = abi.ChainEpoch(-7) var UpgradeCalicoHeight = abi.ChainEpoch(-9) var UpgradePersianHeight = abi.ChainEpoch(-10) var UpgradeOrangeHeight = abi.ChainEpoch(-11) var UpgradeClausHeight = abi.ChainEpoch(-12) - var UpgradeTrustHeight = abi.ChainEpoch(-13) - var UpgradeNorwegianHeight = abi.ChainEpoch(-14) - var UpgradeTurboHeight = abi.ChainEpoch(-15) - var UpgradeHyperdriveHeight = abi.ChainEpoch(-16) var UpgradeChocolateHeight = abi.ChainEpoch(-17) var UpgradeOhSnapHeight = abi.ChainEpoch(-18) -var UpgradeSkyrHeight = abi.ChainEpoch(100) +var UpgradeSkyrHeight = abi.ChainEpoch(-19) + +const UpgradeV17Height = abi.ChainEpoch(99999999999999) var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, @@ -107,6 +103,7 @@ func init() { UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight) UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight) UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight) + UpgradeV17Height = getUpgradeHeight("LOTUS_V17_HEIGHT", UpgradeV17Height) BuildType |= BuildInteropnet SetAddressNetwork(address.Testnet) diff --git a/build/params_mainnet.go b/build/params_mainnet.go index 7a532c17451..a681d4c5937 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -9,10 +9,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - - "github.com/filecoin-project/lotus/chain/actors" ) var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ @@ -23,7 +22,7 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ var NetworkBundle = "mainnet" // NOTE: DO NOT change this unless you REALLY know what you're doing. This is consensus critical. -var BundleOverrides map[actors.Version]string +var BundleOverrides map[actorstypes.Version]string const GenesisNetworkVersion = network.Version0 @@ -77,7 +76,9 @@ const UpgradeChocolateHeight = 1231620 const UpgradeOhSnapHeight = 1594680 // 2022-07-06T14:00:00Z -var UpgradeSkyrHeight = abi.ChainEpoch(1960320) +const UpgradeSkyrHeight = 1960320 + +var UpgradeV17Height = abi.ChainEpoch(99999999999999) var SupportedProofTypes = []abi.RegisteredSealProof{ abi.RegisteredSealProof_StackedDrg32GiBV1, @@ -92,8 +93,8 @@ func init() { SetAddressNetwork(address.Mainnet) } - if os.Getenv("LOTUS_DISABLE_SKYR") == "1" { - UpgradeSkyrHeight = math.MaxInt64 + if os.Getenv("LOTUS_DISABLE_V17") == "1" { + UpgradeV17Height = math.MaxInt64 } Devnet = false diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index 6f59189a612..a77feb9d821 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -33,7 +33,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}} /* inline-gen start */ -const NewestNetworkVersion = network.Version16 +const NewestNetworkVersion = network.Version17 /* inline-gen end */ diff --git a/build/params_testground.go b/build/params_testground.go index 9d708781d45..bcbc32b9481 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -13,10 +13,10 @@ import ( "github.com/ipfs/go-cid" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" ) @@ -107,6 +107,7 @@ var ( UpgradeChocolateHeight abi.ChainEpoch = -16 UpgradeOhSnapHeight abi.ChainEpoch = -17 UpgradeSkyrHeight abi.ChainEpoch = -18 + UpgradeV17Height abi.ChainEpoch = -19 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, @@ -114,10 +115,10 @@ var ( GenesisNetworkVersion = network.Version0 NetworkBundle = "devnet" - BundleOverrides map[actors.Version]string + BundleOverrides map[actorstypes.Version]string - NewestNetworkVersion = network.Version15 - ActorUpgradeNetworkVersion = network.Version15 + NewestNetworkVersion = network.Version16 + ActorUpgradeNetworkVersion = network.Version16 Devnet = true ZeroAddress = MustParseAddress("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a") diff --git a/chain/actors/actor_cids.go b/chain/actors/actor_cids.go index 9612983dcb9..598d3d8f70d 100644 --- a/chain/actors/actor_cids.go +++ b/chain/actors/actor_cids.go @@ -4,6 +4,7 @@ import ( "github.com/ipfs/go-cid" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" 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" @@ -14,10 +15,10 @@ import ( ) // GetActorCodeID looks up a builtin actor's code CID by actor version and canonical actor name. -func GetActorCodeID(av Version, name string) (cid.Cid, bool) { +func GetActorCodeID(av actorstypes.Version, name string) (cid.Cid, bool) { // Actors V8 and above - if av >= Version8 { + if av >= actorstypes.Version8 { if cids, ok := GetActorCodeIDsFromManifest(av); ok { c, ok := cids[name] return c, ok @@ -30,275 +31,275 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) { case AccountKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.AccountActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.AccountActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.AccountActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.AccountActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.AccountActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.AccountActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.AccountActorCodeID, true } case CronKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.CronActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.CronActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.CronActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.CronActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.CronActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.CronActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.CronActorCodeID, true } case InitKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.InitActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.InitActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.InitActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.InitActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.InitActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.InitActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.InitActorCodeID, true } case MarketKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.StorageMarketActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.StorageMarketActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.StorageMarketActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.StorageMarketActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.StorageMarketActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.StorageMarketActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.StorageMarketActorCodeID, true } case MinerKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.StorageMinerActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.StorageMinerActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.StorageMinerActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.StorageMinerActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.StorageMinerActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.StorageMinerActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.StorageMinerActorCodeID, true } case MultisigKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.MultisigActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.MultisigActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.MultisigActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.MultisigActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.MultisigActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.MultisigActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.MultisigActorCodeID, true } case PaychKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.PaymentChannelActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.PaymentChannelActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.PaymentChannelActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.PaymentChannelActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.PaymentChannelActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.PaymentChannelActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.PaymentChannelActorCodeID, true } case PowerKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.StoragePowerActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.StoragePowerActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.StoragePowerActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.StoragePowerActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.StoragePowerActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.StoragePowerActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.StoragePowerActorCodeID, true } case RewardKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.RewardActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.RewardActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.RewardActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.RewardActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.RewardActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.RewardActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.RewardActorCodeID, true } case SystemKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.SystemActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.SystemActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.SystemActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.SystemActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.SystemActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.SystemActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.SystemActorCodeID, true } case VerifregKey: switch av { - case Version0: + case actorstypes.Version0: return builtin0.VerifiedRegistryActorCodeID, true - case Version2: + case actorstypes.Version2: return builtin2.VerifiedRegistryActorCodeID, true - case Version3: + case actorstypes.Version3: return builtin3.VerifiedRegistryActorCodeID, true - case Version4: + case actorstypes.Version4: return builtin4.VerifiedRegistryActorCodeID, true - case Version5: + case actorstypes.Version5: return builtin5.VerifiedRegistryActorCodeID, true - case Version6: + case actorstypes.Version6: return builtin6.VerifiedRegistryActorCodeID, true - case Version7: + case actorstypes.Version7: return builtin7.VerifiedRegistryActorCodeID, true } } @@ -307,7 +308,7 @@ func GetActorCodeID(av Version, name string) (cid.Cid, bool) { } // GetActorCodeIDs looks up all builtin actor's code CIDs by actor version. -func GetActorCodeIDs(av Version) (map[string]cid.Cid, error) { +func GetActorCodeIDs(av actorstypes.Version) (map[string]cid.Cid, error) { cids, ok := GetActorCodeIDsFromManifest(av) if ok { return cids, nil diff --git a/chain/actors/agen/main.go b/chain/actors/agen/main.go index ba88c54d115..bb2ca8bd36a 100644 --- a/chain/actors/agen/main.go +++ b/chain/actors/agen/main.go @@ -44,6 +44,11 @@ func main() { fmt.Println(err) return } + + if err := generateRegistry("chain/actors/builtin/registry.go"); err != nil { + fmt.Println(err) + return + } } func generateAdapters() error { @@ -108,8 +113,9 @@ func generateState(actDir string) error { var b bytes.Buffer err := tpl.Execute(&b, map[string]interface{}{ - "v": version, - "import": getVersionImports()[version], + "v": version, + "import": getVersionImports()[version], + "latestVersion": lotusactors.LatestVersion, }) if err != nil { return err @@ -139,8 +145,9 @@ func generateMessages(actDir string) error { var b bytes.Buffer err := tpl.Execute(&b, map[string]interface{}{ - "v": version, - "import": getVersionImports()[version], + "v": version, + "import": getVersionImports()[version], + "latestVersion": lotusactors.LatestVersion, }) if err != nil { return err @@ -216,6 +223,36 @@ func generateBuiltin(builtinPath string) error { return nil } +func generateRegistry(registryPath string) error { + + bf, err := ioutil.ReadFile(registryPath + ".template") + if err != nil { + if os.IsNotExist(err) { + return nil // skip + } + + return xerrors.Errorf("loading builtin template file: %w", err) + } + + tpl := template.Must(template.New("").Funcs(template.FuncMap{ + "import": func(v int) string { return getVersionImports()[v] }, + }).Parse(string(bf))) + var b bytes.Buffer + + err = tpl.Execute(&b, map[string]interface{}{ + "versions": lotusactors.Versions, + }) + if err != nil { + return err + } + + if err := ioutil.WriteFile(registryPath, b.Bytes(), 0666); err != nil { + return err + } + + return nil +} + func getVersionImports() map[int]string { versionImports := make(map[int]string, lotusactors.LatestVersion) for _, v := range lotusactors.Versions { diff --git a/chain/actors/builtin/account/account.go b/chain/actors/builtin/account/account.go index f233f173c66..64aef158855 100644 --- a/chain/actors/builtin/account/account.go +++ b/chain/actors/builtin/account/account.go @@ -1,25 +1,34 @@ package account import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" - builtin8 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/types" + 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) -var Methods = builtin8.MethodsAccount +var Methods = builtin9.MethodsAccount func Load(store adt.Store, act *types.Actor) (State, error) { if name, av, ok := actors.GetActorMetaByCode(act.Code); ok { @@ -29,9 +38,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -63,33 +75,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, addr) - case actors.Version2: + case actorstypes.Version2: return make2(store, addr) - case actors.Version3: + case actorstypes.Version3: return make3(store, addr) - case actors.Version4: + case actorstypes.Version4: return make4(store, addr) - case actors.Version5: + case actorstypes.Version5: return make5(store, addr) - case actors.Version6: + case actorstypes.Version6: return make6(store, addr) - case actors.Version7: + case actorstypes.Version7: return make7(store, addr) - case actors.Version8: + case actorstypes.Version8: return make8(store, addr) + case actorstypes.Version9: + return make9(store, addr) + } return nil, xerrors.Errorf("unknown actor version %d", av) } diff --git a/chain/actors/builtin/account/actor.go.template b/chain/actors/builtin/account/actor.go.template index 7aff20d42b5..07b4cc94bbd 100644 --- a/chain/actors/builtin/account/actor.go.template +++ b/chain/actors/builtin/account/actor.go.template @@ -1,6 +1,7 @@ package account import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" @@ -9,13 +10,13 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var Methods = builtin{{.latestVersion}}.MethodsAccount @@ -29,7 +30,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -48,10 +49,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, addr) {{end}} } diff --git a/chain/actors/builtin/account/v0.go b/chain/actors/builtin/account/v0.go index 314bd4b298f..bdfca2fd705 100644 --- a/chain/actors/builtin/account/v0.go +++ b/chain/actors/builtin/account/v0.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account0 "github.com/filecoin-project/specs-actors/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account0 "github.com/filecoin-project/specs-actors/actors/builtin/account" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/account/v2.go b/chain/actors/builtin/account/v2.go index 60506542466..66618e06a4e 100644 --- a/chain/actors/builtin/account/v2.go +++ b/chain/actors/builtin/account/v2.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/account" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/account/v3.go b/chain/actors/builtin/account/v3.go index d070476ea1e..dbe100a4f83 100644 --- a/chain/actors/builtin/account/v3.go +++ b/chain/actors/builtin/account/v3.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/account" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/account/v4.go b/chain/actors/builtin/account/v4.go index f4d9f7a06ea..53f71dcc5e9 100644 --- a/chain/actors/builtin/account/v4.go +++ b/chain/actors/builtin/account/v4.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/account" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/account/v5.go b/chain/actors/builtin/account/v5.go index 5e01ce15210..538f5698750 100644 --- a/chain/actors/builtin/account/v5.go +++ b/chain/actors/builtin/account/v5.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/account" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/account/v6.go b/chain/actors/builtin/account/v6.go index 85135dcda2f..a0d157ae54d 100644 --- a/chain/actors/builtin/account/v6.go +++ b/chain/actors/builtin/account/v6.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/account" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/account/v7.go b/chain/actors/builtin/account/v7.go index 4ae979b8279..883776cf8f0 100644 --- a/chain/actors/builtin/account/v7.go +++ b/chain/actors/builtin/account/v7.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/account" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors/adt" + + account7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/account" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/account/v8.go b/chain/actors/builtin/account/v8.go index 211deea3338..d8ef52c0069 100644 --- a/chain/actors/builtin/account/v8.go +++ b/chain/actors/builtin/account/v8.go @@ -1,12 +1,12 @@ package account import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" - account8 "github.com/filecoin-project/go-state-types/builtin/v8/account" + "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) diff --git a/chain/actors/builtin/account/v9.go b/chain/actors/builtin/account/v9.go new file mode 100644 index 00000000000..f44e192b63d --- /dev/null +++ b/chain/actors/builtin/account/v9.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" + + account9 "github.com/filecoin-project/go-state-types/builtin/v9/account" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, addr address.Address) (State, error) { + out := state9{store: store} + out.State = account9.State{Address: addr} + return &out, nil +} + +type state9 struct { + account9.State + store adt.Store +} + +func (s *state9) PubkeyAddress() (address.Address, error) { + return s.Address, nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/builtin.go b/chain/actors/builtin/builtin.go index fb95a28d6c7..c80215c61d9 100644 --- a/chain/actors/builtin/builtin.go +++ b/chain/actors/builtin/builtin.go @@ -3,24 +3,31 @@ package builtin import ( "fmt" + "github.com/filecoin-project/go-address" "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/builtin" - miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" - smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing" - "github.com/filecoin-project/go-state-types/proof" 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + 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/specs-actors/v8/actors/builtin" + + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/go-state-types/proof" "github.com/filecoin-project/lotus/chain/actors" + + miner9 "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.SystemActorAddr @@ -53,7 +60,7 @@ type PoStProof = proof.PoStProof type FilterEstimate = smoothingtypes.FilterEstimate func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower { - return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) + return miner9.QAPowerForWeight(size, duration, dealWeight, verifiedWeight) } func ActorNameByCode(c cid.Cid) string { @@ -84,9 +91,6 @@ func ActorNameByCode(c cid.Cid) string { case builtin7.IsBuiltinActor(c): return builtin7.ActorNameByCode(c) - case builtin8.IsBuiltinActor(c): - return builtin8.ActorNameByCode(c) - default: return "" } diff --git a/chain/actors/builtin/builtin.go.template b/chain/actors/builtin/builtin.go.template index d536eff36d8..5dcdbbafa6f 100644 --- a/chain/actors/builtin/builtin.go.template +++ b/chain/actors/builtin/builtin.go.template @@ -7,7 +7,9 @@ import ( "github.com/ipfs/go-cid" {{range .versions}} + {{if (le . 7)}} builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin" + {{end}} {{end}} "github.com/filecoin-project/go-state-types/abi" @@ -60,8 +62,10 @@ func ActorNameByCode(c cid.Cid) string { switch { {{range .versions}} + {{if (le . 7)}} case builtin{{.}}.IsBuiltinActor(c): return builtin{{.}}.ActorNameByCode(c) + {{end}} {{end}} default: return "" diff --git a/chain/actors/builtin/cron/actor.go.template b/chain/actors/builtin/cron/actor.go.template index fb70f314abb..67c781fb2e1 100644 --- a/chain/actors/builtin/cron/actor.go.template +++ b/chain/actors/builtin/cron/actor.go.template @@ -1,6 +1,7 @@ package cron import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "golang.org/x/xerrors" @@ -9,10 +10,9 @@ import ( {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -24,7 +24,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -43,10 +43,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store) {{end}} } diff --git a/chain/actors/builtin/cron/cron.go b/chain/actors/builtin/cron/cron.go index 00264e3b442..165059aa4ca 100644 --- a/chain/actors/builtin/cron/cron.go +++ b/chain/actors/builtin/cron/cron.go @@ -1,20 +1,27 @@ package cron import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/types" "golang.org/x/xerrors" - builtin8 "github.com/filecoin-project/go-state-types/builtin" 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -25,9 +32,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -59,40 +69,43 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store) + case actorstypes.Version9: + return make9(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } var ( - Address = builtin8.CronActorAddr - Methods = builtin8.MethodsCron + Address = builtin9.CronActorAddr + Methods = builtin9.MethodsCron ) type State interface { diff --git a/chain/actors/builtin/cron/v0.go b/chain/actors/builtin/cron/v0.go index baa81aac3c1..6147b858c10 100644 --- a/chain/actors/builtin/cron/v0.go +++ b/chain/actors/builtin/cron/v0.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron0 "github.com/filecoin-project/specs-actors/actors/builtin/cron" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/cron/v2.go b/chain/actors/builtin/cron/v2.go index d6ee35935e9..51ca179d9ce 100644 --- a/chain/actors/builtin/cron/v2.go +++ b/chain/actors/builtin/cron/v2.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/cron" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/cron/v3.go b/chain/actors/builtin/cron/v3.go index 356d385cd30..ff74d511de5 100644 --- a/chain/actors/builtin/cron/v3.go +++ b/chain/actors/builtin/cron/v3.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/cron" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/cron/v4.go b/chain/actors/builtin/cron/v4.go index 3db3c95aaeb..1cff8cc2813 100644 --- a/chain/actors/builtin/cron/v4.go +++ b/chain/actors/builtin/cron/v4.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/cron" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/cron/v5.go b/chain/actors/builtin/cron/v5.go index 5d99af1fd4b..2bb00dc21da 100644 --- a/chain/actors/builtin/cron/v5.go +++ b/chain/actors/builtin/cron/v5.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/cron" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/cron/v6.go b/chain/actors/builtin/cron/v6.go index c86cd6c42f0..8bbadd79f52 100644 --- a/chain/actors/builtin/cron/v6.go +++ b/chain/actors/builtin/cron/v6.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/cron" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/cron/v7.go b/chain/actors/builtin/cron/v7.go index db9f8f9e2f7..e5538c89ff6 100644 --- a/chain/actors/builtin/cron/v7.go +++ b/chain/actors/builtin/cron/v7.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/cron" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/cron/v8.go b/chain/actors/builtin/cron/v8.go index 00567acf956..00b22fcbfee 100644 --- a/chain/actors/builtin/cron/v8.go +++ b/chain/actors/builtin/cron/v8.go @@ -3,9 +3,9 @@ package cron import ( "github.com/ipfs/go-cid" - cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron" - "github.com/filecoin-project/lotus/chain/actors/adt" + + cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron" ) var _ State = (*state8)(nil) diff --git a/chain/actors/builtin/cron/v9.go b/chain/actors/builtin/cron/v9.go new file mode 100644 index 00000000000..94530e1810c --- /dev/null +++ b/chain/actors/builtin/cron/v9.go @@ -0,0 +1,35 @@ +package cron + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + cron9 "github.com/filecoin-project/go-state-types/builtin/v9/cron" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + out.State = *cron9.ConstructState(cron9.BuiltInEntries()) + return &out, nil +} + +type state9 struct { + cron9.State + store adt.Store +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/init/actor.go.template b/chain/actors/builtin/init/actor.go.template index e27c66fbb63..43bb70c4c4b 100644 --- a/chain/actors/builtin/init/actor.go.template +++ b/chain/actors/builtin/init/actor.go.template @@ -1,6 +1,7 @@ package init import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors" "golang.org/x/xerrors" @@ -15,10 +16,9 @@ import ( {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var ( @@ -35,7 +35,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -54,10 +54,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, networkName string) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, networkName) {{end}} } diff --git a/chain/actors/builtin/init/init.go b/chain/actors/builtin/init/init.go index c7e0f7b8204..10cac5e355e 100644 --- a/chain/actors/builtin/init/init.go +++ b/chain/actors/builtin/init/init.go @@ -1,30 +1,39 @@ package init import ( - "github.com/ipfs/go-cid" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/chain/actors" "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" "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/types" + "github.com/filecoin-project/lotus/node/modules/dtypes" + 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/node/modules/dtypes" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin8.InitActorAddr - Methods = builtin8.MethodsInit + Address = builtin9.InitActorAddr + Methods = builtin9.MethodsInit ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -35,9 +44,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -69,33 +81,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, networkName string) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, networkName) - case actors.Version2: + case actorstypes.Version2: return make2(store, networkName) - case actors.Version3: + case actorstypes.Version3: return make3(store, networkName) - case actors.Version4: + case actorstypes.Version4: return make4(store, networkName) - case actors.Version5: + case actorstypes.Version5: return make5(store, networkName) - case actors.Version6: + case actorstypes.Version6: return make6(store, networkName) - case actors.Version7: + case actorstypes.Version7: return make7(store, networkName) - case actors.Version8: + case actorstypes.Version8: return make8(store, networkName) + case actorstypes.Version9: + return make9(store, networkName) + } return nil, xerrors.Errorf("unknown actor version %d", av) } diff --git a/chain/actors/builtin/init/v0.go b/chain/actors/builtin/init/v0.go index 2f6b213c007..ddd2dab94f2 100644 --- a/chain/actors/builtin/init/v0.go +++ b/chain/actors/builtin/init/v0.go @@ -1,17 +1,17 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" - init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" + + init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/init/v2.go b/chain/actors/builtin/init/v2.go index d780a1fe92c..72e2d56a522 100644 --- a/chain/actors/builtin/init/v2.go +++ b/chain/actors/builtin/init/v2.go @@ -1,17 +1,17 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" - init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/node/modules/dtypes" + + init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/init/v3.go b/chain/actors/builtin/init/v3.go index b2f713b1fe4..4609c94a372 100644 --- a/chain/actors/builtin/init/v3.go +++ b/chain/actors/builtin/init/v3.go @@ -1,18 +1,19 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/node/modules/dtypes" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/init/v4.go b/chain/actors/builtin/init/v4.go index 9de02816ff0..dc56d1f196c 100644 --- a/chain/actors/builtin/init/v4.go +++ b/chain/actors/builtin/init/v4.go @@ -1,18 +1,19 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/node/modules/dtypes" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/init/v5.go b/chain/actors/builtin/init/v5.go index f9c59f83aa6..107366de536 100644 --- a/chain/actors/builtin/init/v5.go +++ b/chain/actors/builtin/init/v5.go @@ -1,18 +1,19 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/node/modules/dtypes" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/init/v6.go b/chain/actors/builtin/init/v6.go index 494b6aaa094..a5bd9edfb77 100644 --- a/chain/actors/builtin/init/v6.go +++ b/chain/actors/builtin/init/v6.go @@ -1,18 +1,19 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/node/modules/dtypes" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/init/v7.go b/chain/actors/builtin/init/v7.go index bc378a14131..341aa52cdb0 100644 --- a/chain/actors/builtin/init/v7.go +++ b/chain/actors/builtin/init/v7.go @@ -1,18 +1,19 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/node/modules/dtypes" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/node/modules/dtypes" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/init/v8.go b/chain/actors/builtin/init/v8.go index 63b058e5734..91981954920 100644 --- a/chain/actors/builtin/init/v8.go +++ b/chain/actors/builtin/init/v8.go @@ -1,18 +1,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "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" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/node/modules/dtypes" ) var _ State = (*state8)(nil) diff --git a/chain/actors/builtin/init/v9.go b/chain/actors/builtin/init/v9.go new file mode 100644 index 00000000000..e6406b2ddea --- /dev/null +++ b/chain/actors/builtin/init/v9.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" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, networkName string) (State, error) { + out := state9{store: store} + + s, err := init9.ConstructState(store, networkName) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + init9.State + store adt.Store +} + +func (s *state9) ResolveAddress(address address.Address) (address.Address, bool, error) { + return s.State.ResolveAddress(s.store, address) +} + +func (s *state9) MapAddressToNewID(address address.Address) (address.Address, error) { + return s.State.MapAddressToNewID(s.store, address) +} + +func (s *state9) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error { + addrs, err := adt9.AsMap(s.store, s.State.AddressMap, builtin9.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 *state9) NetworkName() (dtypes.NetworkName, error) { + return dtypes.NetworkName(s.State.NetworkName), nil +} + +func (s *state9) SetNetworkName(name string) error { + s.State.NetworkName = name + return nil +} + +func (s *state9) SetNextID(id abi.ActorID) error { + s.State.NextID = id + return nil +} + +func (s *state9) Remove(addrs ...address.Address) (err error) { + m, err := adt9.AsMap(s.store, s.State.AddressMap, builtin9.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 *state9) SetAddressMap(mcid cid.Cid) error { + s.State.AddressMap = mcid + return nil +} + +func (s *state9) AddressMap() (adt.Map, error) { + return adt9.AsMap(s.store, s.State.AddressMap, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index 66298a18a47..0b34fbf758b 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -1,7 +1,8 @@ package market import ( - "unicode/utf8" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "unicode/utf8" "github.com/filecoin-project/go-state-types/network" "golang.org/x/xerrors" @@ -12,23 +13,23 @@ import ( "github.com/filecoin-project/go-state-types/cbor" cbg "github.com/whyrusleeping/cbor-gen" - market{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}market" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" {{range .versions}} {{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}} + builtintypes "github.com/filecoin-project/go-state-types/builtin" + "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) var ( - Address = builtin{{.latestVersion}}.StorageMarketActorAddr - Methods = builtin{{.latestVersion}}.MethodsMarket + Address = builtintypes.StorageMarketActorAddr + Methods = builtintypes.MethodsMarket ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -40,7 +41,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -59,10 +60,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store) {{end}} } @@ -100,11 +101,11 @@ type DealStates interface { } type DealProposals interface { - ForEach(cb func(id abi.DealID, dp market{{.latestVersion}}.DealProposal) error) error - Get(id abi.DealID) (*market{{.latestVersion}}.DealProposal, bool, error) + ForEach(cb func(id abi.DealID, dp markettypes.DealProposal) error) error + Get(id abi.DealID) (*markettypes.DealProposal, bool, error) array() adt.Array - decode(*cbg.Deferred) (*market{{.latestVersion}}.DealProposal, error) + decode(*cbg.Deferred) (*markettypes.DealProposal, error) } @@ -115,23 +116,24 @@ type PublishStorageDealsReturn interface { } func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) { - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, err } switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return decodePublishStorageDealsReturn{{.}}(b) {{end}} } return nil, xerrors.Errorf("unknown actor version %d", av) } -type DealProposal = market{{.latestVersion}}.DealProposal +type DealProposal = markettypes.DealProposal +type DealLabel = markettypes.DealLabel -type DealState = market{{.latestVersion}}.DealState +type DealState = markettypes.DealState type DealStateChanges struct { Added []DealIDState @@ -158,7 +160,7 @@ type DealProposalChanges struct { type ProposalIDState struct { ID abi.DealID - Proposal market{{.latestVersion}}.DealProposal + Proposal markettypes.DealProposal } func EmptyDealState() *DealState { @@ -170,7 +172,7 @@ func EmptyDealState() *DealState { } // returns the earned fees and pending fees for a given deal -func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { +func GetDealFees(deal markettypes.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))) @@ -185,14 +187,14 @@ func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpo return ef, big.Sub(tf, ef) } -func IsDealActive(state market{{.latestVersion}}.DealState) bool { +func IsDealActive(state markettypes.DealState) bool { return state.SectorStartEpoch > -1 && state.SlashEpoch == -1 } -func labelFromGoString(s string) (market{{.latestVersion}}.DealLabel, error) { +func labelFromGoString(s string) (markettypes.DealLabel, error) { if utf8.ValidString(s) { - return market{{.latestVersion}}.NewLabelFromString(s) + return markettypes.NewLabelFromString(s) } else { - return market{{.latestVersion}}.NewLabelFromBytes([]byte(s)) + return markettypes.NewLabelFromBytes([]byte(s)) } } diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 8c0e4e91ae6..4c5d67aad20 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -1,34 +1,44 @@ package market import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "unicode/utf8" - cbg "github.com/whyrusleeping/cbor-gen" + "github.com/filecoin-project/go-state-types/network" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - builtin8 "github.com/filecoin-project/go-state-types/builtin" - market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" "github.com/filecoin-project/go-state-types/cbor" - "github.com/filecoin-project/go-state-types/network" + cbg "github.com/whyrusleeping/cbor-gen" + + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtintypes "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/types" ) var ( - Address = builtin8.StorageMarketActorAddr - Methods = builtin8.MethodsMarket + Address = builtintypes.StorageMarketActorAddr + Methods = builtintypes.MethodsMarket ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -39,9 +49,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -73,33 +86,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store) + case actorstypes.Version9: + return make9(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -135,11 +151,11 @@ type DealStates interface { } type DealProposals interface { - ForEach(cb func(id abi.DealID, dp market8.DealProposal) error) error - Get(id abi.DealID) (*market8.DealProposal, bool, error) + ForEach(cb func(id abi.DealID, dp markettypes.DealProposal) error) error + Get(id abi.DealID) (*markettypes.DealProposal, bool, error) array() adt.Array - decode(*cbg.Deferred) (*market8.DealProposal, error) + decode(*cbg.Deferred) (*markettypes.DealProposal, error) } type PublishStorageDealsReturn interface { @@ -149,44 +165,48 @@ type PublishStorageDealsReturn interface { } func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStorageDealsReturn, error) { - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, err } switch av { - case actors.Version0: + case actorstypes.Version0: return decodePublishStorageDealsReturn0(b) - case actors.Version2: + case actorstypes.Version2: return decodePublishStorageDealsReturn2(b) - case actors.Version3: + case actorstypes.Version3: return decodePublishStorageDealsReturn3(b) - case actors.Version4: + case actorstypes.Version4: return decodePublishStorageDealsReturn4(b) - case actors.Version5: + case actorstypes.Version5: return decodePublishStorageDealsReturn5(b) - case actors.Version6: + case actorstypes.Version6: return decodePublishStorageDealsReturn6(b) - case actors.Version7: + case actorstypes.Version7: return decodePublishStorageDealsReturn7(b) - case actors.Version8: + case actorstypes.Version8: return decodePublishStorageDealsReturn8(b) + case actorstypes.Version9: + return decodePublishStorageDealsReturn9(b) + } return nil, xerrors.Errorf("unknown actor version %d", av) } -type DealProposal = market8.DealProposal +type DealProposal = markettypes.DealProposal +type DealLabel = markettypes.DealLabel -type DealState = market8.DealState +type DealState = markettypes.DealState type DealStateChanges struct { Added []DealIDState @@ -213,7 +233,7 @@ type DealProposalChanges struct { type ProposalIDState struct { ID abi.DealID - Proposal market8.DealProposal + Proposal markettypes.DealProposal } func EmptyDealState() *DealState { @@ -225,7 +245,7 @@ func EmptyDealState() *DealState { } // returns the earned fees and pending fees for a given deal -func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) { +func GetDealFees(deal markettypes.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))) @@ -240,14 +260,14 @@ func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmo return ef, big.Sub(tf, ef) } -func IsDealActive(state market8.DealState) bool { +func IsDealActive(state markettypes.DealState) bool { return state.SectorStartEpoch > -1 && state.SlashEpoch == -1 } -func labelFromGoString(s string) (market8.DealLabel, error) { +func labelFromGoString(s string) (markettypes.DealLabel, error) { if utf8.ValidString(s) { - return market8.NewLabelFromString(s) + return markettypes.NewLabelFromString(s) } else { - return market8.NewLabelFromBytes([]byte(s)) + return markettypes.NewLabelFromBytes([]byte(s)) } } diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index 1ed2fc4fcb5..475381e8201 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -22,6 +22,7 @@ import ( 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" + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" {{end}} ) @@ -258,12 +259,12 @@ func (s *dealProposals{{.v}}) array() adt.Array { 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 + label, err := fromV{{.v}}Label(v{{.v}}.Label) {{end}} + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } return DealProposal{ PieceCID: v{{.v}}.PieceCID, @@ -283,6 +284,25 @@ func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, e }, nil } +{{if (ge .v 8)}} + func fromV{{.v}}Label(v{{.v}} market{{.v}}.DealLabel) (DealLabel, error) { + if v{{.v}}.IsString() { + str, err := v{{.v}}.ToString() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v{{.v}}.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) + } +{{end}} + + func (s *state{{.v}}) GetState() interface{} { return &s.State diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index 38e92f12df3..9ede96cd90e 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -3,17 +3,17 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market0 "github.com/filecoin-project/specs-actors/actors/builtin/market" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) @@ -241,6 +241,7 @@ func (s *dealProposals0) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 5a399e68c8e..6de3a3a6d2c 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -3,17 +3,17 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) @@ -241,6 +241,7 @@ func (s *dealProposals2) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index a953429fc53..bd2ca7b0c25 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -3,17 +3,17 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" - adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/market" + adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" ) var _ State = (*state3)(nil) @@ -236,6 +236,7 @@ func (s *dealProposals3) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index 8e6b3cd34c4..11f62a5f416 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -3,17 +3,17 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" - adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market" + adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" ) var _ State = (*state4)(nil) @@ -236,6 +236,7 @@ func (s *dealProposals4) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index 5cf904e049e..378bc23bbf4 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -3,17 +3,17 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/go-state-types/abi" - market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" - adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market" + adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" ) var _ State = (*state5)(nil) @@ -236,6 +236,7 @@ func (s *dealProposals5) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 03862ac0960..6c1b6c497c4 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -3,19 +3,20 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" - "github.com/filecoin-project/go-state-types/abi" - market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market" - adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/market" + adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" ) var _ State = (*state6)(nil) @@ -238,6 +239,7 @@ func (s *dealProposals6) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index 2c2664110aa..faf178307d8 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -3,19 +3,20 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" - "github.com/filecoin-project/go-state-types/abi" - market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" - adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + + market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market" + adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" ) var _ State = (*state7)(nil) @@ -238,6 +239,7 @@ func (s *dealProposals7) array() adt.Array { 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) } diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go index 8afbf39dee6..ea65ec70546 100644 --- a/chain/actors/builtin/market/v8.go +++ b/chain/actors/builtin/market/v8.go @@ -3,19 +3,21 @@ package market import ( "bytes" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" rlepluslazy "github.com/filecoin-project/go-bitfield/rle" - "github.com/filecoin-project/go-state-types/abi" - market8 "github.com/filecoin-project/go-state-types/builtin/v8/market" - adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" "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" + markettypes "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) @@ -237,7 +239,11 @@ func (s *dealProposals8) array() adt.Array { func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) { - label := v8.Label + label, err := fromV8Label(v8.Label) + + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } return DealProposal{ PieceCID: v8.PieceCID, @@ -257,6 +263,22 @@ func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) { }, nil } +func fromV8Label(v8 market8.DealLabel) (DealLabel, error) { + if v8.IsString() { + str, err := v8.ToString() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v8.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} + func (s *state8) GetState() interface{} { return &s.State } diff --git a/chain/actors/builtin/market/v9.go b/chain/actors/builtin/market/v9.go new file mode 100644 index 00000000000..8984a1b75ac --- /dev/null +++ b/chain/actors/builtin/market/v9.go @@ -0,0 +1,326 @@ +package market + +import ( + "bytes" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + + "github.com/filecoin-project/go-bitfield" + rlepluslazy "github.com/filecoin-project/go-bitfield/rle" + + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/types" + + markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" + adt9 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + + s, err := market9.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + market9.State + store adt.Store +} + +func (s *state9) TotalLocked() (abi.TokenAmount, error) { + fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral) + fml = types.BigAdd(fml, s.TotalClientStorageFee) + return fml, nil +} + +func (s *state9) BalancesChanged(otherState State) (bool, error) { + otherState9, ok := otherState.(*state9) + 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(otherState9.State.EscrowTable) || !s.State.LockedTable.Equals(otherState9.State.LockedTable), nil +} + +func (s *state9) StatesChanged(otherState State) (bool, error) { + otherState9, ok := otherState.(*state9) + 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(otherState9.State.States), nil +} + +func (s *state9) States() (DealStates, error) { + stateArray, err := adt9.AsArray(s.store, s.State.States, market9.StatesAmtBitwidth) + if err != nil { + return nil, err + } + return &dealStates9{stateArray}, nil +} + +func (s *state9) ProposalsChanged(otherState State) (bool, error) { + otherState9, ok := otherState.(*state9) + 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(otherState9.State.Proposals), nil +} + +func (s *state9) Proposals() (DealProposals, error) { + proposalArray, err := adt9.AsArray(s.store, s.State.Proposals, market9.ProposalsAmtBitwidth) + if err != nil { + return nil, err + } + return &dealProposals9{proposalArray}, nil +} + +func (s *state9) EscrowTable() (BalanceTable, error) { + bt, err := adt9.AsBalanceTable(s.store, s.State.EscrowTable) + if err != nil { + return nil, err + } + return &balanceTable9{bt}, nil +} + +func (s *state9) LockedTable() (BalanceTable, error) { + bt, err := adt9.AsBalanceTable(s.store, s.State.LockedTable) + if err != nil { + return nil, err + } + return &balanceTable9{bt}, nil +} + +func (s *state9) VerifyDealsForActivation( + minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, +) (weight, verifiedWeight abi.DealWeight, err error) { + w, vw, _, err := market9.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch) + return w, vw, err +} + +func (s *state9) NextID() (abi.DealID, error) { + return s.State.NextID, nil +} + +type balanceTable9 struct { + *adt9.BalanceTable +} + +func (bt *balanceTable9) ForEach(cb func(address.Address, abi.TokenAmount) error) error { + asMap := (*adt9.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 dealStates9 struct { + adt.Array +} + +func (s *dealStates9) Get(dealID abi.DealID) (*DealState, bool, error) { + var deal9 market9.DealState + found, err := s.Array.Get(uint64(dealID), &deal9) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + deal := fromV9DealState(deal9) + return &deal, true, nil +} + +func (s *dealStates9) ForEach(cb func(dealID abi.DealID, ds DealState) error) error { + var ds9 market9.DealState + return s.Array.ForEach(&ds9, func(idx int64) error { + return cb(abi.DealID(idx), fromV9DealState(ds9)) + }) +} + +func (s *dealStates9) decode(val *cbg.Deferred) (*DealState, error) { + var ds9 market9.DealState + if err := ds9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + ds := fromV9DealState(ds9) + return &ds, nil +} + +func (s *dealStates9) array() adt.Array { + return s.Array +} + +func fromV9DealState(v9 market9.DealState) DealState { + return (DealState)(v9) +} + +type dealProposals9 struct { + adt.Array +} + +func (s *dealProposals9) Get(dealID abi.DealID) (*DealProposal, bool, error) { + var proposal9 market9.DealProposal + found, err := s.Array.Get(uint64(dealID), &proposal9) + if err != nil { + return nil, false, err + } + if !found { + return nil, false, nil + } + + proposal, err := fromV9DealProposal(proposal9) + if err != nil { + return nil, true, xerrors.Errorf("decoding proposal: %w", err) + } + + return &proposal, true, nil +} + +func (s *dealProposals9) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error { + var dp9 market9.DealProposal + return s.Array.ForEach(&dp9, func(idx int64) error { + dp, err := fromV9DealProposal(dp9) + if err != nil { + return xerrors.Errorf("decoding proposal: %w", err) + } + + return cb(abi.DealID(idx), dp) + }) +} + +func (s *dealProposals9) decode(val *cbg.Deferred) (*DealProposal, error) { + var dp9 market9.DealProposal + if err := dp9.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return nil, err + } + + dp, err := fromV9DealProposal(dp9) + if err != nil { + return nil, err + } + + return &dp, nil +} + +func (s *dealProposals9) array() adt.Array { + return s.Array +} + +func fromV9DealProposal(v9 market9.DealProposal) (DealProposal, error) { + + label, err := fromV9Label(v9.Label) + + if err != nil { + return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err) + } + + return DealProposal{ + PieceCID: v9.PieceCID, + PieceSize: v9.PieceSize, + VerifiedDeal: v9.VerifiedDeal, + Client: v9.Client, + Provider: v9.Provider, + + Label: label, + + StartEpoch: v9.StartEpoch, + EndEpoch: v9.EndEpoch, + StoragePricePerEpoch: v9.StoragePricePerEpoch, + + ProviderCollateral: v9.ProviderCollateral, + ClientCollateral: v9.ClientCollateral, + }, nil +} + +func fromV9Label(v9 market9.DealLabel) (DealLabel, error) { + if v9.IsString() { + str, err := v9.ToString() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err) + } + return markettypes.NewLabelFromString(str) + } + + bs, err := v9.ToBytes() + if err != nil { + return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err) + } + return markettypes.NewLabelFromBytes(bs) +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +var _ PublishStorageDealsReturn = (*publishStorageDealsReturn9)(nil) + +func decodePublishStorageDealsReturn9(b []byte) (PublishStorageDealsReturn, error) { + var retval market9.PublishStorageDealsReturn + if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil { + return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err) + } + + return &publishStorageDealsReturn9{retval}, nil +} + +type publishStorageDealsReturn9 struct { + market9.PublishStorageDealsReturn +} + +func (r *publishStorageDealsReturn9) IsDealValid(index uint64) (bool, int, error) { + + set, err := r.ValidDeals.IsSet(index) + if err != nil || !set { + return false, -1, err + } + maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{ + Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}}) + if err != nil { + return false, -1, err + } + before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals) + if err != nil { + return false, -1, err + } + outIdx, err := before.Count() + if err != nil { + return false, -1, err + } + return set, int(outIdx), nil + +} + +func (r *publishStorageDealsReturn9) 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 731af6255ec..751ab698f88 100644 --- a/chain/actors/builtin/miner/actor.go.template +++ b/chain/actors/builtin/miner/actor.go.template @@ -1,6 +1,7 @@ package miner import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/chain/actors" @@ -33,7 +34,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -201,6 +202,7 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi type MinerInfo = miner{{.latestVersion}}.MinerInfo type WorkerKeyChange = miner{{.latestVersion}}.WorkerKeyChange +type SectorPreCommitOnChainInfo = miner{{.latestVersion}}.SectorPreCommitOnChainInfo type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo type SectorExpiration struct { diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index 820be35a4e5..2184194ea9e 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -1,28 +1,36 @@ package miner import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/actors" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/big" - miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/dline" - "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/proof" + + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/types" + 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" - builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -33,9 +41,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -94,6 +105,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { case actors.Version8: return make8(store) + case actors.Version9: + return make9(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -112,8 +126,8 @@ type State interface { GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) FindSector(abi.SectorNumber) (*SectorLocation, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) - GetPrecommittedSector(abi.SectorNumber) (*miner8.SectorPreCommitOnChainInfo, error) - ForEachPrecommittedSector(func(miner8.SectorPreCommitOnChainInfo) error) error + GetPrecommittedSector(abi.SectorNumber) (*miner9.SectorPreCommitOnChainInfo, error) + ForEachPrecommittedSector(func(miner9.SectorPreCommitOnChainInfo) error) error LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error) NumLiveSectors() (uint64, error) IsAllocated(abi.SectorNumber) (bool, error) @@ -142,7 +156,7 @@ type State interface { sectors() (adt.Array, error) decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) precommits() (adt.Map, error) - decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner8.SectorPreCommitOnChainInfo, error) + decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner9.SectorPreCommitOnChainInfo, error) GetState() interface{} } @@ -180,7 +194,7 @@ type Partition interface { UnprovenSectors() (bitfield.BitField, error) } -type SectorOnChainInfo = miner8.SectorOnChainInfo +type SectorOnChainInfo = miner9.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 @@ -235,8 +249,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi } } -type MinerInfo = miner8.MinerInfo -type WorkerKeyChange = miner8.WorkerKeyChange +type MinerInfo = miner9.MinerInfo +type WorkerKeyChange = miner9.WorkerKeyChange +type SectorPreCommitOnChainInfo = miner9.SectorPreCommitOnChainInfo type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo type SectorExpiration struct { @@ -264,8 +279,8 @@ type SectorExtensions struct { } type PreCommitChanges struct { - Added []miner8.SectorPreCommitOnChainInfo - Removed []miner8.SectorPreCommitOnChainInfo + Added []miner9.SectorPreCommitOnChainInfo + Removed []miner9.SectorPreCommitOnChainInfo } type LockedFunds struct { diff --git a/chain/actors/builtin/miner/state.go.template b/chain/actors/builtin/miner/state.go.template index 53c4b446a6a..e24188fa0a3 100644 --- a/chain/actors/builtin/miner/state.go.template +++ b/chain/actors/builtin/miner/state.go.template @@ -15,7 +15,7 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/actors/adt" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/miner" {{if (le .v 7)}} {{if (ge .v 3)}} @@ -581,11 +581,17 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { return minertypes.SectorPreCommitOnChainInfo{ - Info: (minertypes.SectorPreCommitInfo)(v{{.v}}.Info), + Info: minertypes.SectorPreCommitInfo{ + SealProof: v{{.v}}.Info.SealProof, + SectorNumber: v{{.v}}.Info.SectorNumber, + SealedCID: v{{.v}}.Info.SealedCID, + SealRandEpoch: v{{.v}}.Info.SealRandEpoch, + DealIDs: v{{.v}}.Info.DealIDs, + Expiration: v{{.v}}.Info.Expiration, + UnsealedCid: nil, + }, PreCommitDeposit: v{{.v}}.PreCommitDeposit, PreCommitEpoch: v{{.v}}.PreCommitEpoch, - DealWeight: v{{.v}}.DealWeight, - VerifiedDealWeight: v{{.v}}.VerifiedDealWeight, } } diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index daa0a6bfd04..d8f45038116 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -4,20 +4,21 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" + "github.com/filecoin-project/go-state-types/big" "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/big" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/dline" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/actors/adt" + + miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) @@ -511,11 +512,17 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v0.Info.SealProof, + SectorNumber: v0.Info.SectorNumber, + SealedCID: v0.Info.SealedCID, + SealRandEpoch: v0.Info.SealRandEpoch, + DealIDs: v0.Info.DealIDs, + Expiration: v0.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v0.PreCommitDeposit, + PreCommitEpoch: v0.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v2.go b/chain/actors/builtin/miner/v2.go index 7741b542693..e5bc784fe3a 100644 --- a/chain/actors/builtin/miner/v2.go +++ b/chain/actors/builtin/miner/v2.go @@ -4,19 +4,19 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" - minertypes "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" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/actors/adt" + + miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) @@ -542,11 +542,17 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v2.Info.SealProof, + SectorNumber: v2.Info.SectorNumber, + SealedCID: v2.Info.SealedCID, + SealRandEpoch: v2.Info.SealRandEpoch, + DealIDs: v2.Info.DealIDs, + Expiration: v2.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v2.PreCommitDeposit, + PreCommitEpoch: v2.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v3.go b/chain/actors/builtin/miner/v3.go index 8cb1c40049f..670df7f1b6b 100644 --- a/chain/actors/builtin/miner/v3.go +++ b/chain/actors/builtin/miner/v3.go @@ -4,20 +4,21 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "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/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state3)(nil) @@ -542,11 +543,17 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v3.Info.SealProof, + SectorNumber: v3.Info.SectorNumber, + SealedCID: v3.Info.SealedCID, + SealRandEpoch: v3.Info.SealRandEpoch, + DealIDs: v3.Info.DealIDs, + Expiration: v3.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v3.PreCommitDeposit, + PreCommitEpoch: v3.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v4.go b/chain/actors/builtin/miner/v4.go index dc8b7a1d169..740e748ba75 100644 --- a/chain/actors/builtin/miner/v4.go +++ b/chain/actors/builtin/miner/v4.go @@ -4,20 +4,21 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "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/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state4)(nil) @@ -542,11 +543,17 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v4.Info.SealProof, + SectorNumber: v4.Info.SectorNumber, + SealedCID: v4.Info.SealedCID, + SealRandEpoch: v4.Info.SealRandEpoch, + DealIDs: v4.Info.DealIDs, + Expiration: v4.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v4.PreCommitDeposit, + PreCommitEpoch: v4.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v5.go b/chain/actors/builtin/miner/v5.go index f5ec6087b53..f120e78b6f4 100644 --- a/chain/actors/builtin/miner/v5.go +++ b/chain/actors/builtin/miner/v5.go @@ -4,20 +4,21 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "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/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state5)(nil) @@ -542,11 +543,17 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v5.Info.SealProof, + SectorNumber: v5.Info.SectorNumber, + SealedCID: v5.Info.SealedCID, + SealRandEpoch: v5.Info.SealRandEpoch, + DealIDs: v5.Info.DealIDs, + Expiration: v5.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v5.PreCommitDeposit, + PreCommitEpoch: v5.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v6.go b/chain/actors/builtin/miner/v6.go index 78445b2ba53..d0ea06e8020 100644 --- a/chain/actors/builtin/miner/v6.go +++ b/chain/actors/builtin/miner/v6.go @@ -4,20 +4,21 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "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/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state6)(nil) @@ -542,11 +543,17 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v6.Info.SealProof, + SectorNumber: v6.Info.SectorNumber, + SealedCID: v6.Info.SealedCID, + SealRandEpoch: v6.Info.SealRandEpoch, + DealIDs: v6.Info.DealIDs, + Expiration: v6.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v6.PreCommitDeposit, + PreCommitEpoch: v6.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v7.go b/chain/actors/builtin/miner/v7.go index c91fceb7b67..19a4eb7af70 100644 --- a/chain/actors/builtin/miner/v7.go +++ b/chain/actors/builtin/miner/v7.go @@ -4,20 +4,21 @@ import ( "bytes" "errors" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "golang.org/x/xerrors" - "github.com/filecoin-project/go-bitfield" rle "github.com/filecoin-project/go-bitfield/rle" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" "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/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state7)(nil) @@ -543,11 +544,17 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v7.Info.SealProof, + SectorNumber: v7.Info.SectorNumber, + SealedCID: v7.Info.SealedCID, + SealRandEpoch: v7.Info.SealRandEpoch, + DealIDs: v7.Info.DealIDs, + Expiration: v7.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v7.PreCommitDeposit, + PreCommitEpoch: v7.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v8.go b/chain/actors/builtin/miner/v8.go index 817a073a2ea..52b6b61962f 100644 --- a/chain/actors/builtin/miner/v8.go +++ b/chain/actors/builtin/miner/v8.go @@ -4,20 +4,20 @@ 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" - "github.com/filecoin-project/go-bitfield" - rle "github.com/filecoin-project/go-bitfield/rle" - "github.com/filecoin-project/go-state-types/abi" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/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" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" - "github.com/filecoin-project/go-state-types/dline" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state8)(nil) @@ -543,11 +543,17 @@ func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo { 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, + Info: minertypes.SectorPreCommitInfo{ + SealProof: v8.Info.SealProof, + SectorNumber: v8.Info.SectorNumber, + SealedCID: v8.Info.SealedCID, + SealRandEpoch: v8.Info.SealRandEpoch, + DealIDs: v8.Info.DealIDs, + Expiration: v8.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v8.PreCommitDeposit, + PreCommitEpoch: v8.PreCommitEpoch, } } diff --git a/chain/actors/builtin/miner/v9.go b/chain/actors/builtin/miner/v9.go new file mode 100644 index 00000000000..79872fd8d71 --- /dev/null +++ b/chain/actors/builtin/miner/v9.go @@ -0,0 +1,562 @@ +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/v9/miner" + "github.com/filecoin-project/lotus/chain/actors/adt" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + out.State = miner9.State{} + return &out, nil +} + +type state9 struct { + miner9.State + store adt.Store +} + +type deadline9 struct { + miner9.Deadline + store adt.Store +} + +type partition9 struct { + miner9.Partition + store adt.Store +} + +func (s *state9) 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 *state9) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.CheckVestedFunds(s.store, epoch) +} + +func (s *state9) LockedFunds() (LockedFunds, error) { + return LockedFunds{ + VestingFunds: s.State.LockedFunds, + InitialPledgeRequirement: s.State.InitialPledge, + PreCommitDeposits: s.State.PreCommitDeposits, + }, nil +} + +func (s *state9) FeeDebt() (abi.TokenAmount, error) { + return s.State.FeeDebt, nil +} + +func (s *state9) InitialPledge() (abi.TokenAmount, error) { + return s.State.InitialPledge, nil +} + +func (s *state9) PreCommitDeposits() (abi.TokenAmount, error) { + return s.State.PreCommitDeposits, nil +} + +func (s *state9) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) { + info, ok, err := s.State.GetSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV9SectorOnChainInfo(*info) + return &ret, nil +} + +func (s *state9) 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 *state9) 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 *miner9.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 *state9) 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 *miner9.Deadline) error { + partitions, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + quant := s.State.QuantSpecForDeadline(dlIdx) + var part miner9.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 := miner9.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner9.PartitionExpirationAmtBitwidth) + if err != nil { + return err + } + var exp miner9.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 *state9) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) { + info, ok, err := s.State.GetPrecommittedSector(s.store, num) + if !ok || err != nil { + return nil, err + } + + ret := fromV9SectorPreCommitOnChainInfo(*info) + + return &ret, nil +} + +func (s *state9) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error { + precommitted, err := adt9.AsMap(s.store, s.State.PreCommittedSectors, builtin9.DefaultHamtBitwidth) + if err != nil { + return err + } + + var info miner9.SectorPreCommitOnChainInfo + if err := precommitted.ForEach(&info, func(_ string) error { + return cb(fromV9SectorPreCommitOnChainInfo(info)) + }); err != nil { + return err + } + + return nil +} + +func (s *state9) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) { + sectors, err := miner9.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 info9 miner9.SectorOnChainInfo + if err := sectors.ForEach(&info9, func(_ int64) error { + info := fromV9SectorOnChainInfo(info9) + infos = append(infos, &info) + return nil + }); err != nil { + return nil, err + } + return infos, nil + } + + // Otherwise, load selected. + infos9, err := sectors.Load(*snos) + if err != nil { + return nil, err + } + infos := make([]*SectorOnChainInfo, len(infos9)) + for i, info9 := range infos9 { + info := fromV9SectorOnChainInfo(*info9) + infos[i] = &info + } + return infos, nil +} + +func (s *state9) loadAllocatedSectorNumbers() (bitfield.BitField, error) { + var allocatedSectors bitfield.BitField + err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors) + return allocatedSectors, err +} + +func (s *state9) IsAllocated(num abi.SectorNumber) (bool, error) { + allocatedSectors, err := s.loadAllocatedSectorNumbers() + if err != nil { + return false, err + } + + return allocatedSectors.IsSet(uint64(num)) +} + +func (s *state9) GetProvingPeriodStart() (abi.ChainEpoch, error) { + return s.State.ProvingPeriodStart, nil +} + +func (s *state9) 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 *state9) 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 *state9) 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 &deadline9{*dl, s.store}, nil +} + +func (s *state9) 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 *miner9.Deadline) error { + return cb(i, &deadline9{*dl, s.store}) + }) +} + +func (s *state9) NumDeadlines() (uint64, error) { + return miner9.WPoStPeriodDeadlines, nil +} + +func (s *state9) DeadlinesChanged(other State) (bool, error) { + other9, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !s.State.Deadlines.Equals(other9.Deadlines), nil +} + +func (s *state9) MinerInfoChanged(other State) (bool, error) { + other0, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Info.Equals(other0.State.Info), nil +} + +func (s *state9) 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 *state9) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) { + return s.State.RecordedDeadlineInfo(epoch), nil +} + +func (s *state9) DeadlineCronActive() (bool, error) { + return s.State.DeadlineCronActive, nil +} + +func (s *state9) sectors() (adt.Array, error) { + return adt9.AsArray(s.store, s.Sectors, miner9.SectorsAmtBitwidth) +} + +func (s *state9) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) { + var si miner9.SectorOnChainInfo + err := si.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return SectorOnChainInfo{}, err + } + + return fromV9SectorOnChainInfo(si), nil +} + +func (s *state9) precommits() (adt.Map, error) { + return adt9.AsMap(s.store, s.PreCommittedSectors, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) { + var sp miner9.SectorPreCommitOnChainInfo + err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw)) + if err != nil { + return minertypes.SectorPreCommitOnChainInfo{}, err + } + + return fromV9SectorPreCommitOnChainInfo(sp), nil +} + +func (s *state9) EraseAllUnproven() error { + + dls, err := s.State.LoadDeadlines(s.store) + if err != nil { + return err + } + + err = dls.ForEach(s.store, func(dindx uint64, dl *miner9.Deadline) error { + ps, err := dl.PartitionsArray(s.store) + if err != nil { + return err + } + + var part miner9.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 *deadline9) LoadPartition(idx uint64) (Partition, error) { + p, err := d.Deadline.LoadPartition(d.store, idx) + if err != nil { + return nil, err + } + return &partition9{*p, d.store}, nil +} + +func (d *deadline9) ForEachPartition(cb func(uint64, Partition) error) error { + ps, err := d.Deadline.PartitionsArray(d.store) + if err != nil { + return err + } + var part miner9.Partition + return ps.ForEach(&part, func(i int64) error { + return cb(uint64(i), &partition9{part, d.store}) + }) +} + +func (d *deadline9) PartitionsChanged(other Deadline) (bool, error) { + other9, ok := other.(*deadline9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + + return !d.Deadline.Partitions.Equals(other9.Deadline.Partitions), nil +} + +func (d *deadline9) PartitionsPoSted() (bitfield.BitField, error) { + return d.Deadline.PartitionsPoSted, nil +} + +func (d *deadline9) DisputableProofCount() (uint64, error) { + + ops, err := d.OptimisticProofsSnapshotArray(d.store) + if err != nil { + return 0, err + } + + return ops.Length(), nil + +} + +func (p *partition9) AllSectors() (bitfield.BitField, error) { + return p.Partition.Sectors, nil +} + +func (p *partition9) FaultySectors() (bitfield.BitField, error) { + return p.Partition.Faults, nil +} + +func (p *partition9) RecoveringSectors() (bitfield.BitField, error) { + return p.Partition.Recoveries, nil +} + +func (p *partition9) UnprovenSectors() (bitfield.BitField, error) { + return p.Partition.Unproven, nil +} + +func fromV9SectorOnChainInfo(v9 miner9.SectorOnChainInfo) SectorOnChainInfo { + info := SectorOnChainInfo{ + SectorNumber: v9.SectorNumber, + SealProof: v9.SealProof, + SealedCID: v9.SealedCID, + DealIDs: v9.DealIDs, + Activation: v9.Activation, + Expiration: v9.Expiration, + DealWeight: v9.DealWeight, + VerifiedDealWeight: v9.VerifiedDealWeight, + InitialPledge: v9.InitialPledge, + ExpectedDayReward: v9.ExpectedDayReward, + ExpectedStoragePledge: v9.ExpectedStoragePledge, + + SectorKeyCID: v9.SectorKeyCID, + } + return info +} + +func fromV9SectorPreCommitOnChainInfo(v9 miner9.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo { + return minertypes.SectorPreCommitOnChainInfo{ + Info: minertypes.SectorPreCommitInfo{ + SealProof: v9.Info.SealProof, + SectorNumber: v9.Info.SectorNumber, + SealedCID: v9.Info.SealedCID, + SealRandEpoch: v9.Info.SealRandEpoch, + DealIDs: v9.Info.DealIDs, + Expiration: v9.Info.Expiration, + UnsealedCid: nil, + }, + PreCommitDeposit: v9.PreCommitDeposit, + PreCommitEpoch: v9.PreCommitEpoch, + } +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/multisig/actor.go.template b/chain/actors/builtin/multisig/actor.go.template index bd6d4d77a9e..a02a986aaea 100644 --- a/chain/actors/builtin/multisig/actor.go.template +++ b/chain/actors/builtin/multisig/actor.go.template @@ -1,6 +1,7 @@ package multisig import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "fmt" "github.com/minio/blake2b-simd" @@ -15,11 +16,11 @@ import ( {{range .versions}} {{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}} + builtintypes "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/types" @@ -34,7 +35,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -53,10 +54,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, signers, threshold, startEpoch, unlockDuration, initialBalance) {{end}} } @@ -83,12 +84,12 @@ type State interface { type Transaction = msig{{.latestVersion}}.Transaction -var Methods = builtin{{.latestVersion}}.MethodsMultisig +var Methods = builtintypes.MethodsMultisig -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return message{{.}}{{"{"}}{{if (ge . 2)}}message0{from}{{else}}from{{end}}} {{end}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) diff --git a/chain/actors/builtin/multisig/message.go.template b/chain/actors/builtin/multisig/message.go.template index 5542f4eecd9..499ed7467c1 100644 --- a/chain/actors/builtin/multisig/message.go.template +++ b/chain/actors/builtin/multisig/message.go.template @@ -10,10 +10,12 @@ import ( builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin" init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init" multisig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig" + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" {{else}} - builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin" + actorstypes "github.com/filecoin-project/go-state-types/actors" multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/multisig" - init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init" + init{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/init" + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" {{end}} @@ -68,13 +70,13 @@ func (m message{{.v}}) Create( ConstructorParams: enc, } {{else}} - code, ok := actors.GetActorCodeID(actors.Version{{.v}}, actors.MultisigKey) + code, ok := actors.GetActorCodeID(actorstypes.Version{{.v}}, actors.MultisigKey) if !ok { 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{ + execParams := &init{{.latestVersion}}.ExecParams{ CodeCID: code, ConstructorParams: enc, } @@ -88,7 +90,7 @@ func (m message{{.v}}) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin{{.v}}.MethodsInit.Exec, + Method: builtin{{.latestVersion}}.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message0.go b/chain/actors/builtin/multisig/message0.go index ac538d5b0fc..8d7070c8bb3 100644 --- a/chain/actors/builtin/multisig/message0.go +++ b/chain/actors/builtin/multisig/message0.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" init0 "github.com/filecoin-project/specs-actors/actors/builtin/init" multisig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig" @@ -66,7 +68,7 @@ func (m message0) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin0.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message2.go b/chain/actors/builtin/multisig/message2.go index 6667479b182..af454f298d5 100644 --- a/chain/actors/builtin/multisig/message2.go +++ b/chain/actors/builtin/multisig/message2.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" @@ -63,7 +65,7 @@ func (m message2) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin2.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message3.go b/chain/actors/builtin/multisig/message3.go index b2e5880ba24..2317c5133e0 100644 --- a/chain/actors/builtin/multisig/message3.go +++ b/chain/actors/builtin/multisig/message3.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init" multisig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig" @@ -63,7 +65,7 @@ func (m message3) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin3.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message4.go b/chain/actors/builtin/multisig/message4.go index c62ae3da531..53f447dcd1d 100644 --- a/chain/actors/builtin/multisig/message4.go +++ b/chain/actors/builtin/multisig/message4.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init" multisig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig" @@ -63,7 +65,7 @@ func (m message4) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin4.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message5.go b/chain/actors/builtin/multisig/message5.go index d1ae532ea03..abca500fd8f 100644 --- a/chain/actors/builtin/multisig/message5.go +++ b/chain/actors/builtin/multisig/message5.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init" multisig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig" @@ -63,7 +65,7 @@ func (m message5) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin5.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message6.go b/chain/actors/builtin/multisig/message6.go index 896ea72128a..84ee5774169 100644 --- a/chain/actors/builtin/multisig/message6.go +++ b/chain/actors/builtin/multisig/message6.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init" multisig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig" @@ -63,7 +65,7 @@ func (m message6) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin6.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message7.go b/chain/actors/builtin/multisig/message7.go index b0595227908..aaaabfe5788 100644 --- a/chain/actors/builtin/multisig/message7.go +++ b/chain/actors/builtin/multisig/message7.go @@ -5,6 +5,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" init7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/init" multisig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig" @@ -63,7 +65,7 @@ func (m message7) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin7.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message8.go b/chain/actors/builtin/multisig/message8.go index 23bee19d0f9..55d153b76af 100644 --- a/chain/actors/builtin/multisig/message8.go +++ b/chain/actors/builtin/multisig/message8.go @@ -5,9 +5,11 @@ import ( "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" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin9 "github.com/filecoin-project/go-state-types/builtin" multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" "github.com/filecoin-project/lotus/chain/actors" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" @@ -49,13 +51,13 @@ func (m message8) Create( return nil, actErr } - code, ok := actors.GetActorCodeID(actors.Version8, actors.MultisigKey) + code, ok := actors.GetActorCodeID(actorstypes.Version8, actors.MultisigKey) if !ok { 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{ + execParams := &init9.ExecParams{ CodeCID: code, ConstructorParams: enc, } @@ -68,7 +70,7 @@ func (m message8) Create( return &types.Message{ To: init_.Address, From: m.from, - Method: builtin8.MethodsInit.Exec, + Method: builtin9.MethodsInit.Exec, Params: enc, Value: initialAmount, }, nil diff --git a/chain/actors/builtin/multisig/message9.go b/chain/actors/builtin/multisig/message9.go new file mode 100644 index 00000000000..83a46cb8d8d --- /dev/null +++ b/chain/actors/builtin/multisig/message9.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" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin9 "github.com/filecoin-project/go-state-types/builtin" + multisig9 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + + "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 message9 struct{ message0 } + +func (m message9) 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 := &multisig9.ConstructorParams{ + Signers: signers, + NumApprovalsThreshold: threshold, + UnlockDuration: unlockDuration, + StartEpoch: unlockStart, + } + + enc, actErr := actors.SerializeParams(msigParams) + if actErr != nil { + return nil, actErr + } + + code, ok := actors.GetActorCodeID(actorstypes.Version9, actors.MultisigKey) + if !ok { + 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 := &init9.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: builtin9.MethodsInit.Exec, + Params: enc, + Value: initialAmount, + }, nil +} diff --git a/chain/actors/builtin/multisig/multisig.go b/chain/actors/builtin/multisig/multisig.go index 1b2fa794856..b29153b708a 100644 --- a/chain/actors/builtin/multisig/multisig.go +++ b/chain/actors/builtin/multisig/multisig.go @@ -2,6 +2,7 @@ package multisig import ( "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/minio/blake2b-simd" cbg "github.com/whyrusleeping/cbor-gen" @@ -9,17 +10,26 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - builtin8 "github.com/filecoin-project/go-state-types/builtin" - msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig" "github.com/filecoin-project/go-state-types/cbor" + + msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" + 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtintypes "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/types" @@ -33,9 +43,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -67,33 +80,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version2: + case actorstypes.Version2: return make2(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version3: + case actorstypes.Version3: return make3(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version4: + case actorstypes.Version4: return make4(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version5: + case actorstypes.Version5: return make5(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version6: + case actorstypes.Version6: return make6(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version7: + case actorstypes.Version7: return make7(store, signers, threshold, startEpoch, unlockDuration, initialBalance) - case actors.Version8: + case actorstypes.Version8: return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + case actorstypes.Version9: + return make9(store, signers, threshold, startEpoch, unlockDuration, initialBalance) + } return nil, xerrors.Errorf("unknown actor version %d", av) } @@ -116,36 +132,39 @@ type State interface { GetState() interface{} } -type Transaction = msig8.Transaction +type Transaction = msig9.Transaction -var Methods = builtin8.MethodsMultisig +var Methods = builtintypes.MethodsMultisig -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { - case actors.Version0: + case actorstypes.Version0: return message0{from} - case actors.Version2: + case actorstypes.Version2: return message2{message0{from}} - case actors.Version3: + case actorstypes.Version3: return message3{message0{from}} - case actors.Version4: + case actorstypes.Version4: return message4{message0{from}} - case actors.Version5: + case actorstypes.Version5: return message5{message0{from}} - case actors.Version6: + case actorstypes.Version6: return message6{message0{from}} - case actors.Version7: + case actorstypes.Version7: return message7{message0{from}} - case actors.Version8: + case actorstypes.Version8: return message8{message0{from}} + + case actorstypes.Version9: + return message9{message0{from}} default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } @@ -169,13 +188,13 @@ type MessageBuilder interface { } // this type is the same between v0 and v2 -type ProposalHashData = msig8.ProposalHashData -type ProposeReturn = msig8.ProposeReturn -type ProposeParams = msig8.ProposeParams -type ApproveReturn = msig8.ApproveReturn +type ProposalHashData = msig9.ProposalHashData +type ProposeReturn = msig9.ProposeReturn +type ProposeParams = msig9.ProposeParams +type ApproveReturn = msig9.ApproveReturn func txnParams(id uint64, data *ProposalHashData) ([]byte, error) { - params := msig8.TxnIDParams{ID: msig8.TxnID(id)} + params := msig9.TxnIDParams{ID: msig9.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/v0.go b/chain/actors/builtin/multisig/v0.go index 9f4d09dc13c..ccd9a9e37ed 100644 --- a/chain/actors/builtin/multisig/v0.go +++ b/chain/actors/builtin/multisig/v0.go @@ -4,16 +4,16 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/multisig/v2.go b/chain/actors/builtin/multisig/v2.go index 14e89568093..c3579b3e27f 100644 --- a/chain/actors/builtin/multisig/v2.go +++ b/chain/actors/builtin/multisig/v2.go @@ -4,16 +4,16 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/multisig/v3.go b/chain/actors/builtin/multisig/v3.go index 5cde148c1a9..80682808ee3 100644 --- a/chain/actors/builtin/multisig/v3.go +++ b/chain/actors/builtin/multisig/v3.go @@ -4,17 +4,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + 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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/multisig/v4.go b/chain/actors/builtin/multisig/v4.go index 87936661d78..f065f9f8ca1 100644 --- a/chain/actors/builtin/multisig/v4.go +++ b/chain/actors/builtin/multisig/v4.go @@ -4,17 +4,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + 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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/multisig/v5.go b/chain/actors/builtin/multisig/v5.go index d50638ca5fa..783e3987f49 100644 --- a/chain/actors/builtin/multisig/v5.go +++ b/chain/actors/builtin/multisig/v5.go @@ -4,17 +4,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + 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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/multisig/v6.go b/chain/actors/builtin/multisig/v6.go index 9246eeaa961..71ea3c00c68 100644 --- a/chain/actors/builtin/multisig/v6.go +++ b/chain/actors/builtin/multisig/v6.go @@ -4,17 +4,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + 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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/multisig/v7.go b/chain/actors/builtin/multisig/v7.go index a6b630179f3..8ed1caacd78 100644 --- a/chain/actors/builtin/multisig/v7.go +++ b/chain/actors/builtin/multisig/v7.go @@ -4,17 +4,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + 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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/multisig/v8.go b/chain/actors/builtin/multisig/v8.go index 6311583b387..5b76f662e6a 100644 --- a/chain/actors/builtin/multisig/v8.go +++ b/chain/actors/builtin/multisig/v8.go @@ -4,17 +4,17 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "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" - - "github.com/filecoin-project/lotus/chain/actors/adt" ) var _ State = (*state8)(nil) diff --git a/chain/actors/builtin/multisig/v9.go b/chain/actors/builtin/multisig/v9.go new file mode 100644 index 00000000000..cf6df9316ae --- /dev/null +++ b/chain/actors/builtin/multisig/v9.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" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) { + out := state9{store: store} + out.State = msig9.State{} + out.State.Signers = signers + out.State.NumApprovalsThreshold = threshold + out.State.StartEpoch = startEpoch + out.State.UnlockDuration = unlockDuration + out.State.InitialBalance = initialBalance + + em, err := adt9.StoreEmptyMap(store, builtin9.DefaultHamtBitwidth) + if err != nil { + return nil, err + } + + out.State.PendingTxns = em + + return &out, nil +} + +type state9 struct { + msig9.State + store adt.Store +} + +func (s *state9) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) { + return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil +} + +func (s *state9) StartEpoch() (abi.ChainEpoch, error) { + return s.State.StartEpoch, nil +} + +func (s *state9) UnlockDuration() (abi.ChainEpoch, error) { + return s.State.UnlockDuration, nil +} + +func (s *state9) InitialBalance() (abi.TokenAmount, error) { + return s.State.InitialBalance, nil +} + +func (s *state9) Threshold() (uint64, error) { + return s.State.NumApprovalsThreshold, nil +} + +func (s *state9) Signers() ([]address.Address, error) { + return s.State.Signers, nil +} + +func (s *state9) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error { + arr, err := adt9.AsMap(s.store, s.State.PendingTxns, builtin9.DefaultHamtBitwidth) + if err != nil { + return err + } + var out msig9.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 *state9) PendingTxnChanged(other State) (bool, error) { + other9, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.PendingTxns.Equals(other9.PendingTxns), nil +} + +func (s *state9) transactions() (adt.Map, error) { + return adt9.AsMap(s.store, s.PendingTxns, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) decodeTransaction(val *cbg.Deferred) (Transaction, error) { + var tx msig9.Transaction + if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Transaction{}, err + } + return Transaction(tx), nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/paych/actor.go.template b/chain/actors/builtin/paych/actor.go.template index a815c880e2f..1308d4ea446 100644 --- a/chain/actors/builtin/paych/actor.go.template +++ b/chain/actors/builtin/paych/actor.go.template @@ -1,6 +1,7 @@ package paych import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "encoding/base64" "fmt" @@ -35,7 +36,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -99,10 +100,10 @@ func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) { return &sv, nil } -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return message{{.}}{from} {{end}} default: diff --git a/chain/actors/builtin/paych/message.go.template b/chain/actors/builtin/paych/message.go.template index 9e92bf7480c..79aed1692c1 100644 --- a/chain/actors/builtin/paych/message.go.template +++ b/chain/actors/builtin/paych/message.go.template @@ -14,9 +14,10 @@ import ( 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}} + actorstypes "github.com/filecoin-project/go-state-types/actors" 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" + paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v{{.v}}/paych" + init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v{{.v}}/init" {{end}} @@ -31,7 +32,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) {{if (le .v 7)}} actorCodeID := builtin{{.v}}.PaymentChannelActorCodeID {{else}} - actorCodeID, ok := actors.GetActorCodeID(actors.Version{{.v}}, "paymentchannel") + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version{{.v}}, "paymentchannel") if !ok { return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", {{.v}}) } @@ -62,8 +63,10 @@ func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVouche params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{ {{if (le .v 6)}} Sv: toV0SignedVoucher(*sv), - {{else}} + {{else if (le .v 8)}} Sv: *sv, + {{else}} + Sv: toV{{.v}}SignedVoucher(*sv), {{end}} Secret: secret, }) @@ -80,6 +83,32 @@ func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVouche }, nil } +{{if (ge .v 9)}} + func toV{{.v}}SignedVoucher(sv paychtypes.SignedVoucher) paych{{.v}}.SignedVoucher { + merges := make([]paych{{.v}}.Merge, len(sv.Merges)) + for i := range sv.Merges { + merges[i] = paych{{.v}}.Merge{ + Lane: sv.Merges[i].Lane, + Nonce: sv.Merges[i].Nonce, + } + } + + return paych{{.v}}.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretHash: sv.SecretHash, + Extra: (*paych{{.v}}.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: merges, + Signature: sv.Signature, + } + } +{{end}} + func (m message{{.v}}) Settle(paych address.Address) (*types.Message, error) { return &types.Message{ To: paych, diff --git a/chain/actors/builtin/paych/message0.go b/chain/actors/builtin/paych/message0.go index d5a112d43b2..2daa0301bf7 100644 --- a/chain/actors/builtin/paych/message0.go +++ b/chain/actors/builtin/paych/message0.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message2.go b/chain/actors/builtin/paych/message2.go index 89a6e74ce9b..925ad0ed9d1 100644 --- a/chain/actors/builtin/paych/message2.go +++ b/chain/actors/builtin/paych/message2.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message3.go b/chain/actors/builtin/paych/message3.go index 47f8e7e9e25..e8ae585fce6 100644 --- a/chain/actors/builtin/paych/message3.go +++ b/chain/actors/builtin/paych/message3.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message4.go b/chain/actors/builtin/paych/message4.go index 65e63149d9d..b32b0fa5791 100644 --- a/chain/actors/builtin/paych/message4.go +++ b/chain/actors/builtin/paych/message4.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message5.go b/chain/actors/builtin/paych/message5.go index ede1c8ceb7f..897bebe7a7c 100644 --- a/chain/actors/builtin/paych/message5.go +++ b/chain/actors/builtin/paych/message5.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message6.go b/chain/actors/builtin/paych/message6.go index 009e8641fe7..11bd3a8a5d1 100644 --- a/chain/actors/builtin/paych/message6.go +++ b/chain/actors/builtin/paych/message6.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message7.go b/chain/actors/builtin/paych/message7.go index 430fb93415b..446e54eade9 100644 --- a/chain/actors/builtin/paych/message7.go +++ b/chain/actors/builtin/paych/message7.go @@ -3,7 +3,9 @@ package paych 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" diff --git a/chain/actors/builtin/paych/message8.go b/chain/actors/builtin/paych/message8.go index 3fb743bc945..6d9df4f4cd1 100644 --- a/chain/actors/builtin/paych/message8.go +++ b/chain/actors/builtin/paych/message8.go @@ -5,10 +5,13 @@ 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" + + actorstypes "github.com/filecoin-project/go-state-types/actors" 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" - paychtypes "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" @@ -19,7 +22,7 @@ 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") + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version8, "paymentchannel") if !ok { return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 8) } diff --git a/chain/actors/builtin/paych/message9.go b/chain/actors/builtin/paych/message9.go new file mode 100644 index 00000000000..c0e68a4c3fb --- /dev/null +++ b/chain/actors/builtin/paych/message9.go @@ -0,0 +1,111 @@ +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" + + actorstypes "github.com/filecoin-project/go-state-types/actors" + builtin9 "github.com/filecoin-project/go-state-types/builtin" + init9 "github.com/filecoin-project/go-state-types/builtin/v9/init" + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/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 message9 struct{ from address.Address } + +func (m message9) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) { + + actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version9, "paymentchannel") + if !ok { + return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 9) + } + + params, aerr := actors.SerializeParams(&paych9.ConstructorParams{From: m.from, To: to}) + if aerr != nil { + return nil, aerr + } + enc, aerr := actors.SerializeParams(&init9.ExecParams{ + CodeCID: actorCodeID, + ConstructorParams: params, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: init_.Address, + From: m.from, + Value: initialAmount, + Method: builtin9.MethodsInit.Exec, + Params: enc, + }, nil +} + +func (m message9) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) { + params, aerr := actors.SerializeParams(&paych9.UpdateChannelStateParams{ + + Sv: toV9SignedVoucher(*sv), + + Secret: secret, + }) + if aerr != nil { + return nil, aerr + } + + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin9.MethodsPaych.UpdateChannelState, + Params: params, + }, nil +} + +func toV9SignedVoucher(sv paychtypes.SignedVoucher) paych9.SignedVoucher { + merges := make([]paych9.Merge, len(sv.Merges)) + for i := range sv.Merges { + merges[i] = paych9.Merge{ + Lane: sv.Merges[i].Lane, + Nonce: sv.Merges[i].Nonce, + } + } + + return paych9.SignedVoucher{ + ChannelAddr: sv.ChannelAddr, + TimeLockMin: sv.TimeLockMin, + TimeLockMax: sv.TimeLockMax, + SecretHash: sv.SecretHash, + Extra: (*paych9.ModVerifyParams)(sv.Extra), + Lane: sv.Lane, + Nonce: sv.Nonce, + Amount: sv.Amount, + MinSettleHeight: sv.MinSettleHeight, + Merges: merges, + Signature: sv.Signature, + } +} + +func (m message9) Settle(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin9.MethodsPaych.Settle, + }, nil +} + +func (m message9) Collect(paych address.Address) (*types.Message, error) { + return &types.Message{ + To: paych, + From: m.from, + Value: abi.NewTokenAmount(0), + Method: builtin9.MethodsPaych.Collect, + }, nil +} diff --git a/chain/actors/builtin/paych/paych.go b/chain/actors/builtin/paych/paych.go index 20d9d255215..2fc2eca816f 100644 --- a/chain/actors/builtin/paych/paych.go +++ b/chain/actors/builtin/paych/paych.go @@ -3,22 +3,31 @@ package paych import ( "encoding/base64" "fmt" + actorstypes "github.com/filecoin-project/go-state-types/actors" - ipldcbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/go-state-types/cbor" - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" + 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" + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" "github.com/filecoin-project/lotus/chain/actors" @@ -35,9 +44,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -114,33 +126,36 @@ func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) { return &sv, nil } -func Message(version actors.Version, from address.Address) MessageBuilder { +func Message(version actorstypes.Version, from address.Address) MessageBuilder { switch version { - case actors.Version0: + case actorstypes.Version0: return message0{from} - case actors.Version2: + case actorstypes.Version2: return message2{from} - case actors.Version3: + case actorstypes.Version3: return message3{from} - case actors.Version4: + case actorstypes.Version4: return message4{from} - case actors.Version5: + case actorstypes.Version5: return message5{from} - case actors.Version6: + case actorstypes.Version6: return message6{from} - case actors.Version7: + case actorstypes.Version7: return message7{from} - case actors.Version8: + case actorstypes.Version8: return message8{from} + case actorstypes.Version9: + return message9{from} + default: panic(fmt.Sprintf("unsupported actors version: %d", version)) } diff --git a/chain/actors/builtin/paych/v0.go b/chain/actors/builtin/paych/v0.go index 727525c50da..e9bc30e3d18 100644 --- a/chain/actors/builtin/paych/v0.go +++ b/chain/actors/builtin/paych/v0.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/paych/v2.go b/chain/actors/builtin/paych/v2.go index 5852c9a645b..400305e2fb0 100644 --- a/chain/actors/builtin/paych/v2.go +++ b/chain/actors/builtin/paych/v2.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/paych/v3.go b/chain/actors/builtin/paych/v3.go index 5297e9d10a6..1d7c2f94b06 100644 --- a/chain/actors/builtin/paych/v3.go +++ b/chain/actors/builtin/paych/v3.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/paych" - adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/paych" + adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/paych/v4.go b/chain/actors/builtin/paych/v4.go index be10061bfcc..b7d1e52a5b8 100644 --- a/chain/actors/builtin/paych/v4.go +++ b/chain/actors/builtin/paych/v4.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/paych" - adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/paych" + adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/paych/v5.go b/chain/actors/builtin/paych/v5.go index 37a91727314..b331a1500bf 100644 --- a/chain/actors/builtin/paych/v5.go +++ b/chain/actors/builtin/paych/v5.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/paych" - adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/paych" + adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/paych/v6.go b/chain/actors/builtin/paych/v6.go index 36676d9de09..0d60b1f03f4 100644 --- a/chain/actors/builtin/paych/v6.go +++ b/chain/actors/builtin/paych/v6.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/paych" - adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/paych" + adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/paych/v7.go b/chain/actors/builtin/paych/v7.go index 88b6f2b8449..ce09ea2e4be 100644 --- a/chain/actors/builtin/paych/v7.go +++ b/chain/actors/builtin/paych/v7.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych" - adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" "github.com/filecoin-project/lotus/chain/actors/adt" + + paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych" + adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/paych/v8.go b/chain/actors/builtin/paych/v8.go index 1961e69ec07..7936b76e132 100644 --- a/chain/actors/builtin/paych/v8.go +++ b/chain/actors/builtin/paych/v8.go @@ -6,10 +6,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" - adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" "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) diff --git a/chain/actors/builtin/paych/v9.go b/chain/actors/builtin/paych/v9.go new file mode 100644 index 00000000000..02493ac99aa --- /dev/null +++ b/chain/actors/builtin/paych/v9.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" + + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + out.State = paych9.State{} + return &out, nil +} + +type state9 struct { + paych9.State + store adt.Store + lsAmt *adt9.Array +} + +// Channel owner, who has funded the actor +func (s *state9) From() (address.Address, error) { + return s.State.From, nil +} + +// Recipient of payouts from channel +func (s *state9) To() (address.Address, error) { + return s.State.To, nil +} + +// Height at which the channel can be `Collected` +func (s *state9) SettlingAt() (abi.ChainEpoch, error) { + return s.State.SettlingAt, nil +} + +// Amount successfully redeemed through the payment channel, paid out on `Collect()` +func (s *state9) ToSend() (abi.TokenAmount, error) { + return s.State.ToSend, nil +} + +func (s *state9) getOrLoadLsAmt() (*adt9.Array, error) { + if s.lsAmt != nil { + return s.lsAmt, nil + } + + // Get the lane state from the chain + lsamt, err := adt9.AsArray(s.store, s.State.LaneStates, paych9.LaneStatesAmtBitwidth) + if err != nil { + return nil, err + } + + s.lsAmt = lsamt + return lsamt, nil +} + +// Get total number of lanes +func (s *state9) LaneCount() (uint64, error) { + lsamt, err := s.getOrLoadLsAmt() + if err != nil { + return 0, err + } + return lsamt.Length(), nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +// Iterate lane states +func (s *state9) 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 paych9.LaneState + return lsamt.ForEach(&ls, func(i int64) error { + return cb(uint64(i), &laneState9{ls}) + }) +} + +type laneState9 struct { + paych9.LaneState +} + +func (ls *laneState9) Redeemed() (big.Int, error) { + return ls.LaneState.Redeemed, nil +} + +func (ls *laneState9) 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 af9190357cd..93fe70370eb 100644 --- a/chain/actors/builtin/power/actor.go.template +++ b/chain/actors/builtin/power/actor.go.template @@ -1,6 +1,7 @@ package power import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/chain/actors" @@ -17,10 +18,9 @@ import ( {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var ( @@ -37,7 +37,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -56,10 +56,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store) {{end}} } diff --git a/chain/actors/builtin/power/power.go b/chain/actors/builtin/power/power.go index 2f1cfa22fc4..1d8563d5a0a 100644 --- a/chain/actors/builtin/power/power.go +++ b/chain/actors/builtin/power/power.go @@ -1,31 +1,40 @@ package power import ( + "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/lotus/chain/actors" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/big" - builtin8 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" + + "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" + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/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" - "github.com/filecoin-project/lotus/chain/types" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin8.StoragePowerActorAddr - Methods = builtin8.MethodsPower + Address = builtin9.StoragePowerActorAddr + Methods = builtin9.MethodsPower ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -36,9 +45,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -70,33 +82,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store) + case actorstypes.Version9: + return make9(store) + } return nil, xerrors.Errorf("unknown actor version %d", av) } diff --git a/chain/actors/builtin/power/v0.go b/chain/actors/builtin/power/v0.go index 5ae42b4df4f..e114ac219f8 100644 --- a/chain/actors/builtin/power/v0.go +++ b/chain/actors/builtin/power/v0.go @@ -3,16 +3,16 @@ package power import ( "bytes" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "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" + + power0 "github.com/filecoin-project/specs-actors/actors/builtin/power" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/power/v2.go b/chain/actors/builtin/power/v2.go index 485819e3e8c..405bad8baed 100644 --- a/chain/actors/builtin/power/v2.go +++ b/chain/actors/builtin/power/v2.go @@ -3,16 +3,16 @@ package power import ( "bytes" - "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "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" + + power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/power/v3.go b/chain/actors/builtin/power/v3.go index e33ee2bb560..0ff06f617e8 100644 --- a/chain/actors/builtin/power/v3.go +++ b/chain/actors/builtin/power/v3.go @@ -3,17 +3,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power" adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/power/v4.go b/chain/actors/builtin/power/v4.go index e5c446f07c3..f121e3b2f5a 100644 --- a/chain/actors/builtin/power/v4.go +++ b/chain/actors/builtin/power/v4.go @@ -3,17 +3,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power" adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/power/v5.go b/chain/actors/builtin/power/v5.go index aaf24805860..851522e507c 100644 --- a/chain/actors/builtin/power/v5.go +++ b/chain/actors/builtin/power/v5.go @@ -3,17 +3,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + power5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/power" adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/power/v6.go b/chain/actors/builtin/power/v6.go index 072def6e20e..083b85f450b 100644 --- a/chain/actors/builtin/power/v6.go +++ b/chain/actors/builtin/power/v6.go @@ -3,17 +3,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power" adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/power/v7.go b/chain/actors/builtin/power/v7.go index 0c60b03a000..af626cf3a20 100644 --- a/chain/actors/builtin/power/v7.go +++ b/chain/actors/builtin/power/v7.go @@ -3,17 +3,18 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + power7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/power" adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/power/v8.go b/chain/actors/builtin/power/v8.go index c23da69046c..177d3bc3dc0 100644 --- a/chain/actors/builtin/power/v8.go +++ b/chain/actors/builtin/power/v8.go @@ -3,17 +3,17 @@ 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/go-address" - "github.com/filecoin-project/go-state-types/abi" + "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" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state8)(nil) diff --git a/chain/actors/builtin/power/v9.go b/chain/actors/builtin/power/v9.go new file mode 100644 index 00000000000..30dbefe7adf --- /dev/null +++ b/chain/actors/builtin/power/v9.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" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + adt9 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt" + power9 "github.com/filecoin-project/go-state-types/builtin/v9/power" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store) (State, error) { + out := state9{store: store} + + s, err := power9.ConstructState(store) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + power9.State + store adt.Store +} + +func (s *state9) TotalLocked() (abi.TokenAmount, error) { + return s.TotalPledgeCollateral, nil +} + +func (s *state9) 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 *state9) TotalCommitted() (Claim, error) { + return Claim{ + RawBytePower: s.TotalBytesCommitted, + QualityAdjPower: s.TotalQABytesCommitted, + }, nil +} + +func (s *state9) MinerPower(addr address.Address) (Claim, bool, error) { + claims, err := s.claims() + if err != nil { + return Claim{}, false, err + } + var claim power9.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 *state9) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) { + return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a) +} + +func (s *state9) TotalPowerSmoothed() (builtin.FilterEstimate, error) { + return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil +} + +func (s *state9) MinerCounts() (uint64, uint64, error) { + return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil +} + +func (s *state9) 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 *state9) ForEachClaim(cb func(miner address.Address, claim Claim) error) error { + claims, err := s.claims() + if err != nil { + return err + } + + var claim power9.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 *state9) ClaimsChanged(other State) (bool, error) { + other9, ok := other.(*state9) + if !ok { + // treat an upgrade as a change, always + return true, nil + } + return !s.State.Claims.Equals(other9.State.Claims), nil +} + +func (s *state9) SetTotalQualityAdjPower(p abi.StoragePower) error { + s.State.TotalQualityAdjPower = p + return nil +} + +func (s *state9) SetTotalRawBytePower(p abi.StoragePower) error { + s.State.TotalRawBytePower = p + return nil +} + +func (s *state9) SetThisEpochQualityAdjPower(p abi.StoragePower) error { + s.State.ThisEpochQualityAdjPower = p + return nil +} + +func (s *state9) SetThisEpochRawBytePower(p abi.StoragePower) error { + s.State.ThisEpochRawBytePower = p + return nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +func (s *state9) claims() (adt.Map, error) { + return adt9.AsMap(s.store, s.Claims, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) decodeClaim(val *cbg.Deferred) (Claim, error) { + var ci power9.Claim + if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil { + return Claim{}, err + } + return fromV9Claim(ci), nil +} + +func fromV9Claim(v9 power9.Claim) Claim { + return Claim{ + RawBytePower: v9.RawBytePower, + QualityAdjPower: v9.QualityAdjPower, + } +} diff --git a/chain/actors/builtin/registry.go b/chain/actors/builtin/registry.go new file mode 100644 index 00000000000..20df77678a0 --- /dev/null +++ b/chain/actors/builtin/registry.go @@ -0,0 +1,78 @@ +package builtin + +import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" + + account8 "github.com/filecoin-project/go-state-types/builtin/v8/account" + + account9 "github.com/filecoin-project/go-state-types/builtin/v9/account" + + "github.com/filecoin-project/go-state-types/cbor" + rtt "github.com/filecoin-project/go-state-types/rt" + "github.com/filecoin-project/lotus/chain/actors" +) + +var _ rtt.VMActor = (*RegistryEntry)(nil) + +type RegistryEntry struct { + state cbor.Er + code cid.Cid + methods []interface{} +} + +func (r RegistryEntry) State() cbor.Er { + return r.state +} + +func (r RegistryEntry) Exports() []interface{} { + return r.methods +} + +func (r RegistryEntry) Code() cid.Cid { + return r.code +} + +func MakeRegistry(av actorstypes.Version) []rtt.VMActor { + if av < actorstypes.Version8 { + panic("expected version v8 and up only, use specs-actors for v0-7") + } + registry := make([]rtt.VMActor, 0) + + codeIDs, err := actors.GetActorCodeIDs(av) + if err != nil { + panic(err) + } + + switch av { + + case actorstypes.Version8: + for key, codeID := range codeIDs { + switch key { + case actors.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account8.Methods, + state: new(account8.State), + }) + } + } + + case actorstypes.Version9: + for key, codeID := range codeIDs { + switch key { + case actors.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account9.Methods, + state: new(account9.State), + }) + } + } + + default: + panic("expected version v8 and up only, use specs-actors for v0-7") + } + + return registry +} diff --git a/chain/actors/builtin/registry.go.template b/chain/actors/builtin/registry.go.template new file mode 100644 index 00000000000..56a177330b4 --- /dev/null +++ b/chain/actors/builtin/registry.go.template @@ -0,0 +1,69 @@ +package builtin + +import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/ipfs/go-cid" + {{range .versions}} + {{if (ge . 8)}} + account{{.}} "github.com/filecoin-project/go-state-types/builtin/v{{.}}/account" + {{end}} + {{end}} + "github.com/filecoin-project/go-state-types/cbor" + rtt "github.com/filecoin-project/go-state-types/rt" + "github.com/filecoin-project/lotus/chain/actors" +) + +var _ rtt.VMActor = (*RegistryEntry)(nil) + +type RegistryEntry struct { + state cbor.Er + code cid.Cid + methods []interface{} +} + +func (r RegistryEntry) State() cbor.Er { + return r.state +} + +func (r RegistryEntry) Exports() []interface{} { + return r.methods +} + +func (r RegistryEntry) Code() cid.Cid { + return r.code +} + +func MakeRegistry(av actorstypes.Version) []rtt.VMActor { + if av < actorstypes.Version8 { + panic("expected version v8 and up only, use specs-actors for v0-7") + } + registry := make([]rtt.VMActor, 0) + + codeIDs, err := actors.GetActorCodeIDs(av) + if err != nil { + panic(err) + } + + switch av { + {{range .versions}} + {{if (ge . 8)}} + case actorstypes.Version{{.}}: + for key, codeID := range codeIDs { + switch key { + case actors.AccountKey: + registry = append(registry, RegistryEntry{ + code: codeID, + methods: account{{.}}.Methods, + state: new(account{{.}}.State), + }) + } + } + {{end}} + {{end}} + + default: + panic("expected version v8 and up only, use specs-actors for v0-7") + } + + return registry +} diff --git a/chain/actors/builtin/reward/actor.go.template b/chain/actors/builtin/reward/actor.go.template index 3e0e859a35c..165f9efdf99 100644 --- a/chain/actors/builtin/reward/actor.go.template +++ b/chain/actors/builtin/reward/actor.go.template @@ -1,6 +1,7 @@ package reward import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/abi" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/actors" @@ -10,10 +11,9 @@ import ( {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin" @@ -34,7 +34,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -53,10 +53,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.StoragePower) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, currRealizedPower) {{end}} } diff --git a/chain/actors/builtin/reward/reward.go b/chain/actors/builtin/reward/reward.go index 943386f6a86..2c4856bc8df 100644 --- a/chain/actors/builtin/reward/reward.go +++ b/chain/actors/builtin/reward/reward.go @@ -1,29 +1,38 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/chain/actors" + reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" "golang.org/x/xerrors" - "github.com/filecoin-project/go-state-types/abi" - builtin8 "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/go-state-types/cbor" + builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" - reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" + builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin" + builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" + builtin9 "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" ) var ( - Address = builtin8.RewardActorAddr - Methods = builtin8.MethodsReward + Address = builtin9.RewardActorAddr + Methods = builtin9.MethodsReward ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -34,9 +43,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -68,33 +80,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.StoragePower) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, currRealizedPower) - case actors.Version2: + case actorstypes.Version2: return make2(store, currRealizedPower) - case actors.Version3: + case actorstypes.Version3: return make3(store, currRealizedPower) - case actors.Version4: + case actorstypes.Version4: return make4(store, currRealizedPower) - case actors.Version5: + case actorstypes.Version5: return make5(store, currRealizedPower) - case actors.Version6: + case actorstypes.Version6: return make6(store, currRealizedPower) - case actors.Version7: + case actorstypes.Version7: return make7(store, currRealizedPower) - case actors.Version8: + case actorstypes.Version8: return make8(store, currRealizedPower) + case actorstypes.Version9: + return make9(store, currRealizedPower) + } return nil, xerrors.Errorf("unknown actor version %d", av) } diff --git a/chain/actors/builtin/reward/v0.go b/chain/actors/builtin/reward/v0.go index 12bdee054f1..646ab3a9a63 100644 --- a/chain/actors/builtin/reward/v0.go +++ b/chain/actors/builtin/reward/v0.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/reward/v2.go b/chain/actors/builtin/reward/v2.go index ed24816357b..08e9a7bc39a 100644 --- a/chain/actors/builtin/reward/v2.go +++ b/chain/actors/builtin/reward/v2.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" reward2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward" smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/reward/v3.go b/chain/actors/builtin/reward/v3.go index d9f4bf36971..fd9fa56e27e 100644 --- a/chain/actors/builtin/reward/v3.go +++ b/chain/actors/builtin/reward/v3.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner" reward3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/reward" smoothing3 "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/reward/v4.go b/chain/actors/builtin/reward/v4.go index 160c72ce794..310ca04e8df 100644 --- a/chain/actors/builtin/reward/v4.go +++ b/chain/actors/builtin/reward/v4.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner" reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward" smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/reward/v5.go b/chain/actors/builtin/reward/v5.go index 838ec8f21a6..7200f7d11af 100644 --- a/chain/actors/builtin/reward/v5.go +++ b/chain/actors/builtin/reward/v5.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" reward5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/reward" smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/reward/v6.go b/chain/actors/builtin/reward/v6.go index e056b22f66b..010a3a87062 100644 --- a/chain/actors/builtin/reward/v6.go +++ b/chain/actors/builtin/reward/v6.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" reward6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/reward" smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/reward/v7.go b/chain/actors/builtin/reward/v7.go index 5fedaa43c7d..368bb3abd12 100644 --- a/chain/actors/builtin/reward/v7.go +++ b/chain/actors/builtin/reward/v7.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/actors/builtin" + miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner" reward7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/reward" smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/reward/v8.go b/chain/actors/builtin/reward/v8.go index ecc5a94ba46..3d49063df11 100644 --- a/chain/actors/builtin/reward/v8.go +++ b/chain/actors/builtin/reward/v8.go @@ -1,15 +1,15 @@ package reward import ( + "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-state-types/abi" + "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" - - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/actors/builtin" ) var _ State = (*state8)(nil) diff --git a/chain/actors/builtin/reward/v9.go b/chain/actors/builtin/reward/v9.go new file mode 100644 index 00000000000..6dbfdd2e6f2 --- /dev/null +++ b/chain/actors/builtin/reward/v9.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" + + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + reward9 "github.com/filecoin-project/go-state-types/builtin/v9/reward" + smoothing9 "github.com/filecoin-project/go-state-types/builtin/v9/util/smoothing" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, currRealizedPower abi.StoragePower) (State, error) { + out := state9{store: store} + out.State = *reward9.ConstructState(currRealizedPower) + return &out, nil +} + +type state9 struct { + reward9.State + store adt.Store +} + +func (s *state9) ThisEpochReward() (abi.TokenAmount, error) { + return s.State.ThisEpochReward, nil +} + +func (s *state9) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) { + + return builtin.FilterEstimate{ + PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate, + VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate, + }, nil + +} + +func (s *state9) ThisEpochBaselinePower() (abi.StoragePower, error) { + return s.State.ThisEpochBaselinePower, nil +} + +func (s *state9) TotalStoragePowerReward() (abi.TokenAmount, error) { + return s.State.TotalStoragePowerReward, nil +} + +func (s *state9) EffectiveBaselinePower() (abi.StoragePower, error) { + return s.State.EffectiveBaselinePower, nil +} + +func (s *state9) EffectiveNetworkTime() (abi.ChainEpoch, error) { + return s.State.EffectiveNetworkTime, nil +} + +func (s *state9) CumsumBaseline() (reward9.Spacetime, error) { + return s.State.CumsumBaseline, nil +} + +func (s *state9) CumsumRealized() (reward9.Spacetime, error) { + return s.State.CumsumRealized, nil +} + +func (s *state9) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) { + return miner9.InitialPledgeForPower( + qaPower, + s.State.ThisEpochBaselinePower, + s.State.ThisEpochRewardSmoothed, + smoothing9.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + circSupply, + ), nil +} + +func (s *state9) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) { + return miner9.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed, + smoothing9.FilterEstimate{ + PositionEstimate: networkQAPower.PositionEstimate, + VelocityEstimate: networkQAPower.VelocityEstimate, + }, + sectorWeight), nil +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/system/actor.go.template b/chain/actors/builtin/system/actor.go.template index c5e1af3e42c..12ba9935cea 100644 --- a/chain/actors/builtin/system/actor.go.template +++ b/chain/actors/builtin/system/actor.go.template @@ -1,6 +1,7 @@ package system import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" @@ -11,10 +12,9 @@ import ( {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" ) var ( @@ -30,7 +30,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -49,10 +49,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store{{if (ge . 8)}}, builtinActors{{end}}) {{end}} } diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go index 24cf47d5550..a6737480582 100644 --- a/chain/actors/builtin/system/system.go +++ b/chain/actors/builtin/system/system.go @@ -1,25 +1,33 @@ package system import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/adt" + "github.com/filecoin-project/lotus/chain/types" "github.com/ipfs/go-cid" + "golang.org/x/xerrors" - builtin8 "github.com/filecoin-project/go-state-types/builtin" 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" - "github.com/filecoin-project/lotus/chain/actors" - "github.com/filecoin-project/lotus/chain/actors/adt" - "github.com/filecoin-project/lotus/chain/types" + builtin9 "github.com/filecoin-project/go-state-types/builtin" ) var ( - Address = builtin8.SystemActorAddr + Address = builtin9.SystemActorAddr ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -30,9 +38,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -64,33 +75,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, builtinActors cid.Cid) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store) - case actors.Version2: + case actorstypes.Version2: return make2(store) - case actors.Version3: + case actorstypes.Version3: return make3(store) - case actors.Version4: + case actorstypes.Version4: return make4(store) - case actors.Version5: + case actorstypes.Version5: return make5(store) - case actors.Version6: + case actorstypes.Version6: return make6(store) - case actors.Version7: + case actorstypes.Version7: return make7(store) - case actors.Version8: + case actorstypes.Version8: return make8(store, builtinActors) + case actorstypes.Version9: + return make9(store, builtinActors) + } return nil, xerrors.Errorf("unknown actor version %d", av) } diff --git a/chain/actors/builtin/system/v0.go b/chain/actors/builtin/system/v0.go index efa0741ce9b..a5aa8e8fa1b 100644 --- a/chain/actors/builtin/system/v0.go +++ b/chain/actors/builtin/system/v0.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system0 "github.com/filecoin-project/specs-actors/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system0 "github.com/filecoin-project/specs-actors/actors/builtin/system" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/system/v2.go b/chain/actors/builtin/system/v2.go index e4fefd08d0b..aea9eff7b91 100644 --- a/chain/actors/builtin/system/v2.go +++ b/chain/actors/builtin/system/v2.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/system/v3.go b/chain/actors/builtin/system/v3.go index d2b59c8a8ad..fd5f0cd5051 100644 --- a/chain/actors/builtin/system/v3.go +++ b/chain/actors/builtin/system/v3.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/system" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/system/v4.go b/chain/actors/builtin/system/v4.go index 9528c1779fc..fbdec7e93bf 100644 --- a/chain/actors/builtin/system/v4.go +++ b/chain/actors/builtin/system/v4.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/system" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/system/v5.go b/chain/actors/builtin/system/v5.go index adc1d4553ef..3d3c27a12e4 100644 --- a/chain/actors/builtin/system/v5.go +++ b/chain/actors/builtin/system/v5.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/system" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/system/v6.go b/chain/actors/builtin/system/v6.go index 0cebadce0cd..3143088456c 100644 --- a/chain/actors/builtin/system/v6.go +++ b/chain/actors/builtin/system/v6.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/system" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/system/v7.go b/chain/actors/builtin/system/v7.go index 0009773da96..3987db8dd40 100644 --- a/chain/actors/builtin/system/v7.go +++ b/chain/actors/builtin/system/v7.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/system" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/system/v8.go b/chain/actors/builtin/system/v8.go index 48f150fb9e1..a30d5fa305f 100644 --- a/chain/actors/builtin/system/v8.go +++ b/chain/actors/builtin/system/v8.go @@ -3,9 +3,9 @@ package system import ( "github.com/ipfs/go-cid" - system8 "github.com/filecoin-project/go-state-types/builtin/v8/system" - "github.com/filecoin-project/lotus/chain/actors/adt" + + system8 "github.com/filecoin-project/go-state-types/builtin/v8/system" ) var _ State = (*state8)(nil) diff --git a/chain/actors/builtin/system/v9.go b/chain/actors/builtin/system/v9.go new file mode 100644 index 00000000000..6edbd72b95e --- /dev/null +++ b/chain/actors/builtin/system/v9.go @@ -0,0 +1,43 @@ +package system + +import ( + "github.com/ipfs/go-cid" + + "github.com/filecoin-project/lotus/chain/actors/adt" + + system9 "github.com/filecoin-project/go-state-types/builtin/v9/system" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, builtinActors cid.Cid) (State, error) { + out := state9{store: store} + out.State = system9.State{ + BuiltinActors: builtinActors, + } + return &out, nil +} + +type state9 struct { + system9.State + store adt.Store +} + +func (s *state9) GetState() interface{} { + return &s.State +} + +func (s *state9) GetBuiltinActors() cid.Cid { + + return s.State.BuiltinActors + +} diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index 3df256004ca..3501dd5280f 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -1,6 +1,7 @@ package verifreg import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -10,10 +11,9 @@ import ( {{range .versions}} {{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}} + builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" @@ -34,7 +34,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { {{range .versions}} {{if (ge . 8)}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return load{{.}}(store, act.Head) {{end}} {{end}} @@ -53,10 +53,10 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.Address) (State, error) { switch av { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return make{{.}}(store, rootKeyAddress) {{end}} } diff --git a/chain/actors/builtin/verifreg/v0.go b/chain/actors/builtin/verifreg/v0.go index 8eaf8312024..dcd34c72a21 100644 --- a/chain/actors/builtin/verifreg/v0.go +++ b/chain/actors/builtin/verifreg/v0.go @@ -1,15 +1,15 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" - adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + + verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" + adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" ) var _ State = (*state0)(nil) diff --git a/chain/actors/builtin/verifreg/v2.go b/chain/actors/builtin/verifreg/v2.go index 1857a02e426..dfe25f0540b 100644 --- a/chain/actors/builtin/verifreg/v2.go +++ b/chain/actors/builtin/verifreg/v2.go @@ -1,15 +1,15 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg" - adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" + + verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg" + adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt" ) var _ State = (*state2)(nil) diff --git a/chain/actors/builtin/verifreg/v3.go b/chain/actors/builtin/verifreg/v3.go index 98f529a6182..b7ab18080d2 100644 --- a/chain/actors/builtin/verifreg/v3.go +++ b/chain/actors/builtin/verifreg/v3.go @@ -1,16 +1,17 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "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" ) var _ State = (*state3)(nil) diff --git a/chain/actors/builtin/verifreg/v4.go b/chain/actors/builtin/verifreg/v4.go index 08aac0c7dd5..aee3fbdcab3 100644 --- a/chain/actors/builtin/verifreg/v4.go +++ b/chain/actors/builtin/verifreg/v4.go @@ -1,16 +1,17 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "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" ) var _ State = (*state4)(nil) diff --git a/chain/actors/builtin/verifreg/v5.go b/chain/actors/builtin/verifreg/v5.go index 303b10cd1be..4a74e1ea811 100644 --- a/chain/actors/builtin/verifreg/v5.go +++ b/chain/actors/builtin/verifreg/v5.go @@ -1,16 +1,17 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "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" ) var _ State = (*state5)(nil) diff --git a/chain/actors/builtin/verifreg/v6.go b/chain/actors/builtin/verifreg/v6.go index c1bcd0071e3..a776f11493b 100644 --- a/chain/actors/builtin/verifreg/v6.go +++ b/chain/actors/builtin/verifreg/v6.go @@ -1,16 +1,17 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "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" ) var _ State = (*state6)(nil) diff --git a/chain/actors/builtin/verifreg/v7.go b/chain/actors/builtin/verifreg/v7.go index edce5f56092..39d72a15da1 100644 --- a/chain/actors/builtin/verifreg/v7.go +++ b/chain/actors/builtin/verifreg/v7.go @@ -1,16 +1,17 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + "github.com/ipfs/go-cid" "github.com/filecoin-project/lotus/chain/actors" "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" ) var _ State = (*state7)(nil) diff --git a/chain/actors/builtin/verifreg/v8.go b/chain/actors/builtin/verifreg/v8.go index 00e0636ef4a..95fdf2e6dc1 100644 --- a/chain/actors/builtin/verifreg/v8.go +++ b/chain/actors/builtin/verifreg/v8.go @@ -1,16 +1,16 @@ package verifreg import ( - "github.com/ipfs/go-cid" - "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - 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" + "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) diff --git a/chain/actors/builtin/verifreg/v9.go b/chain/actors/builtin/verifreg/v9.go new file mode 100644 index 00000000000..0430b0a14a9 --- /dev/null +++ b/chain/actors/builtin/verifreg/v9.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" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt" + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" +) + +var _ State = (*state9)(nil) + +func load9(store adt.Store, root cid.Cid) (State, error) { + out := state9{store: store} + err := store.Get(store.Context(), root, &out) + if err != nil { + return nil, err + } + return &out, nil +} + +func make9(store adt.Store, rootKeyAddress address.Address) (State, error) { + out := state9{store: store} + + s, err := verifreg9.ConstructState(store, rootKeyAddress) + if err != nil { + return nil, err + } + + out.State = *s + + return &out, nil +} + +type state9 struct { + verifreg9.State + store adt.Store +} + +func (s *state9) RootKey() (address.Address, error) { + return s.State.RootKey, nil +} + +func (s *state9) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version9, s.verifiedClients, addr) +} + +func (s *state9) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) { + return getDataCap(s.store, actors.Version9, s.verifiers, addr) +} + +func (s *state9) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) { + return getRemoveDataCapProposalID(s.store, actors.Version9, s.removeDataCapProposalIDs, verifier, client) +} + +func (s *state9) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version9, s.verifiers, cb) +} + +func (s *state9) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error { + return forEachCap(s.store, actors.Version9, s.verifiedClients, cb) +} + +func (s *state9) verifiedClients() (adt.Map, error) { + return adt9.AsMap(s.store, s.VerifiedClients, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) verifiers() (adt.Map, error) { + return adt9.AsMap(s.store, s.Verifiers, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) removeDataCapProposalIDs() (adt.Map, error) { + return adt9.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin9.DefaultHamtBitwidth) +} + +func (s *state9) GetState() interface{} { + return &s.State +} diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index 0e35af648b1..41d6d6b49e7 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -1,28 +1,38 @@ package verifreg import ( + actorstypes "github.com/filecoin-project/go-state-types/actors" "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" + "github.com/filecoin-project/go-state-types/cbor" + 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" + builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" + builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin" + builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" + builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" + builtin9 "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/types" ) var ( - Address = builtin8.VerifiedRegistryActorAddr - Methods = builtin8.MethodsVerifiedRegistry + Address = builtin9.VerifiedRegistryActorAddr + Methods = builtin9.MethodsVerifiedRegistry ) func Load(store adt.Store, act *types.Actor) (State, error) { @@ -33,9 +43,12 @@ func Load(store adt.Store, act *types.Actor) (State, error) { switch av { - case actors.Version8: + case actorstypes.Version8: return load8(store, act.Head) + case actorstypes.Version9: + return load9(store, act.Head) + } } @@ -67,33 +80,36 @@ func Load(store adt.Store, act *types.Actor) (State, error) { return nil, xerrors.Errorf("unknown actor code %s", act.Code) } -func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Address) (State, error) { +func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.Address) (State, error) { switch av { - case actors.Version0: + case actorstypes.Version0: return make0(store, rootKeyAddress) - case actors.Version2: + case actorstypes.Version2: return make2(store, rootKeyAddress) - case actors.Version3: + case actorstypes.Version3: return make3(store, rootKeyAddress) - case actors.Version4: + case actorstypes.Version4: return make4(store, rootKeyAddress) - case actors.Version5: + case actorstypes.Version5: return make5(store, rootKeyAddress) - case actors.Version6: + case actorstypes.Version6: return make6(store, rootKeyAddress) - case actors.Version7: + case actorstypes.Version7: return make7(store, rootKeyAddress) - case actors.Version8: + case actorstypes.Version8: return make8(store, rootKeyAddress) + case actorstypes.Version9: + return make9(store, rootKeyAddress) + } return nil, xerrors.Errorf("unknown actor version %d", av) } diff --git a/chain/actors/manifest.go b/chain/actors/manifest.go index 52ed3e77d0a..cb118e1f307 100644 --- a/chain/actors/manifest.go +++ b/chain/actors/manifest.go @@ -9,13 +9,14 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/lotus/chain/actors/adt" ) -var manifestCids map[Version]cid.Cid = make(map[Version]cid.Cid) -var manifests map[Version]map[string]cid.Cid = make(map[Version]map[string]cid.Cid) +var manifestCids map[actorstypes.Version]cid.Cid = make(map[actorstypes.Version]cid.Cid) +var manifests map[actorstypes.Version]map[string]cid.Cid = make(map[actorstypes.Version]map[string]cid.Cid) var actorMeta map[cid.Cid]actorEntry = make(map[cid.Cid]actorEntry) const ( @@ -54,7 +55,7 @@ var ( type actorEntry struct { name string - version Version + version actorstypes.Version } // ClearManifest clears all known manifests. This is usually used in tests that need to switch networks. @@ -62,13 +63,13 @@ func ClearManifests() { manifestMx.Lock() defer manifestMx.Unlock() - manifestCids = make(map[Version]cid.Cid) - manifests = make(map[Version]map[string]cid.Cid) + manifestCids = make(map[actorstypes.Version]cid.Cid) + manifests = make(map[actorstypes.Version]map[string]cid.Cid) actorMeta = make(map[cid.Cid]actorEntry) } // RegisterManifest registers an actors manifest with lotus. -func RegisterManifest(av Version, manifestCid cid.Cid, entries map[string]cid.Cid) { +func RegisterManifest(av actorstypes.Version, manifestCid cid.Cid, entries map[string]cid.Cid) { manifestMx.Lock() defer manifestMx.Unlock() @@ -81,7 +82,7 @@ func RegisterManifest(av Version, manifestCid cid.Cid, entries map[string]cid.Ci } // GetManifest gets a loaded manifest. -func GetManifest(av Version) (cid.Cid, bool) { +func GetManifest(av actorstypes.Version) (cid.Cid, bool) { manifestMx.RLock() defer manifestMx.RUnlock() @@ -114,7 +115,7 @@ func ReadManifest(ctx context.Context, store cbor.IpldStore, mfCid cid.Cid) (map } // GetActorCodeIDsFromManifest looks up all builtin actor's code CIDs by actor version for versions that have a manifest. -func GetActorCodeIDsFromManifest(av Version) (map[string]cid.Cid, bool) { +func GetActorCodeIDsFromManifest(av actorstypes.Version) (map[string]cid.Cid, bool) { manifestMx.RLock() defer manifestMx.RUnlock() @@ -137,7 +138,7 @@ func LoadManifest(ctx context.Context, mfCid cid.Cid, adtStore adt.Store) (*mani return &mf, nil } -func GetActorMetaByCode(c cid.Cid) (string, Version, bool) { +func GetActorMetaByCode(c cid.Cid) (string, actorstypes.Version, bool) { manifestMx.RLock() defer manifestMx.RUnlock() diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index 746b19287a6..f65859bb29e 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -1,55 +1,74 @@ package policy import ( - "sort" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/go-state-types/big" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/big" - 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" - paych8 "github.com/filecoin-project/go-state-types/builtin/v8/paych" - verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg" "github.com/filecoin-project/go-state-types/network" + 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" - "github.com/filecoin-project/lotus/chain/actors" + 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" + + builtin9 "github.com/filecoin-project/go-state-types/builtin" + market9 "github.com/filecoin-project/go-state-types/builtin/v9/market" + miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" + verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" + + paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych" ) const ( - ChainFinality = miner8.ChainFinality + ChainFinality = miner9.ChainFinality SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych8.SettleDelay - MaxPreCommitRandomnessLookback = builtin8.EpochsInDay + SealRandomnessLookback + PaychSettleDelay = paych9.SettleDelay + MaxPreCommitRandomnessLookback = builtin9.EpochsInDay + SealRandomnessLookback ) // SetSupportedProofTypes sets supported proof types, across all actor versions. @@ -76,8 +95,6 @@ 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...) } @@ -134,15 +151,6 @@ 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{}{} - } } @@ -167,11 +175,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) { miner8.PreCommitChallengeDelay = delay + miner9.PreCommitChallengeDelay = delay + } // TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay. func GetPreCommitChallengeDelay() abi.ChainEpoch { - return miner8.PreCommitChallengeDelay + return miner9.PreCommitChallengeDelay } // SetConsensusMinerMinPower sets the minimum power of an individual miner must @@ -209,6 +219,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) { policy.ConsensusMinerMinPower = p } + for _, policy := range builtin9.PoStProofPolicies { + policy.ConsensusMinerMinPower = p + } + } // SetMinVerifiedDealSize sets the minimum size of a verified deal. This should @@ -231,43 +245,49 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { verifreg8.MinVerifiedDealSize = size + verifreg9.MinVerifiedDealSize = size + } -func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { +func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { switch ver { - case actors.Version0: + case actorstypes.Version0: return miner0.MaxSealDuration[t], nil - case actors.Version2: + case actorstypes.Version2: return miner2.MaxProveCommitDuration[t], nil - case actors.Version3: + case actorstypes.Version3: return miner3.MaxProveCommitDuration[t], nil - case actors.Version4: + case actorstypes.Version4: return miner4.MaxProveCommitDuration[t], nil - case actors.Version5: + case actorstypes.Version5: return miner5.MaxProveCommitDuration[t], nil - case actors.Version6: + case actorstypes.Version6: return miner6.MaxProveCommitDuration[t], nil - case actors.Version7: + case actorstypes.Version7: return miner7.MaxProveCommitDuration[t], nil - case actors.Version8: + case actorstypes.Version8: return miner8.MaxProveCommitDuration[t], nil + case actorstypes.Version9: + + return miner9.MaxProveCommitDuration[t], nil + default: return 0, xerrors.Errorf("unsupported actors version") } @@ -313,6 +333,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) { Denominator: denom, } + market9.ProviderCollateralSupplyTarget = builtin9.BigFrac{ + Numerator: num, + Denominator: denom, + } + } func DealProviderCollateralBounds( @@ -320,59 +345,64 @@ func DealProviderCollateralBounds( rawBytePower, qaPower, baselinePower abi.StoragePower, circulatingFil abi.TokenAmount, nwVer network.Version, ) (min, max abi.TokenAmount, err error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), big.Zero(), err } switch v { - case actors.Version0: + case actorstypes.Version0: min, max := market0.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) return min, max, nil - case actors.Version2: + case actorstypes.Version2: min, max := market2.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version3: + case actorstypes.Version3: min, max := market3.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version4: + case actorstypes.Version4: min, max := market4.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version5: + case actorstypes.Version5: min, max := market5.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version6: + case actorstypes.Version6: min, max := market6.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version7: + case actorstypes.Version7: min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil - case actors.Version8: + case actorstypes.Version8: min, max := market8.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil) return min, max, nil + case actorstypes.Version9: + + min, max := market9.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 market8.DealDurationBounds(pieceSize) + return market9.DealDurationBounds(pieceSize) } // Sets the challenge window and scales the proving period to match (such that @@ -427,6 +457,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) { // scale it if we're scaling the challenge period. miner8.WPoStDisputeWindow = period * 30 + miner9.WPoStChallengeWindow = period + miner9.WPoStProvingPeriod = period * abi.ChainEpoch(miner9.WPoStPeriodDeadlines) + + // by default, this is 2x finality which is 30 periods. + // scale it if we're scaling the challenge period. + miner9.WPoStDisputeWindow = period * 30 + } func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { @@ -439,15 +476,15 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { } func GetMaxSectorExpirationExtension() abi.ChainEpoch { - return miner8.MaxSectorExpirationExtension + return miner9.MaxSectorExpirationExtension } func GetMinSectorExpiration() abi.ChainEpoch { - return miner8.MinSectorExpiration + return miner9.MinSectorExpiration } func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) { - sectorsPerPart, err := builtin8.PoStProofWindowPoStPartitionSectors(p) + sectorsPerPart, err := builtin9.PoStProofWindowPoStPartitionSectors(p) if err != nil { return 0, err } @@ -458,25 +495,6 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e return int(uint64(maxSectors) / sectorsPerPart), nil } -func GetDefaultSectorSize() abi.SectorSize { - // supported sector sizes are the same across versions. - szs := make([]abi.SectorSize, 0, len(miner8.PreCommitSealProofTypesV8)) - for spt := range miner8.PreCommitSealProofTypesV8 { - ss, err := spt.SectorSize() - if err != nil { - panic(err) - } - - szs = append(szs, ss) - } - - sort.Slice(szs, func(i, j int) bool { - return szs[i] < szs[j] - }) - - return szs[0] -} - func GetDefaultAggregationProof() abi.RegisteredAggregationProof { return abi.RegisteredAggregationProof_SnarkPackV1 } @@ -486,173 +504,188 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime } - return builtin8.SealProofPoliciesV11[proof].SectorMaxLifetime + return builtin9.SealProofPoliciesV11[proof].SectorMaxLifetime } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { - case actors.Version0: + case actorstypes.Version0: return miner0.AddressedSectorsMax, nil - case actors.Version2: + case actorstypes.Version2: return miner2.AddressedSectorsMax, nil - case actors.Version3: + case actorstypes.Version3: return miner3.AddressedSectorsMax, nil - case actors.Version4: + case actorstypes.Version4: return miner4.AddressedSectorsMax, nil - case actors.Version5: + case actorstypes.Version5: return miner5.AddressedSectorsMax, nil - case actors.Version6: + case actorstypes.Version6: return miner6.AddressedSectorsMax, nil - case actors.Version7: + case actorstypes.Version7: return miner7.AddressedSectorsMax, nil - case actors.Version8: + case actorstypes.Version8: return miner8.AddressedSectorsMax, nil + case actorstypes.Version9: + return miner9.AddressedSectorsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } } func GetDeclarationsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { - case actors.Version0: + case actorstypes.Version0: // TODO: Should we instead error here since the concept doesn't exist yet? return miner0.AddressedPartitionsMax, nil - case actors.Version2: + case actorstypes.Version2: return miner2.DeclarationsMax, nil - case actors.Version3: + case actorstypes.Version3: return miner3.DeclarationsMax, nil - case actors.Version4: + case actorstypes.Version4: return miner4.DeclarationsMax, nil - case actors.Version5: + case actorstypes.Version5: return miner5.DeclarationsMax, nil - case actors.Version6: + case actorstypes.Version6: return miner6.DeclarationsMax, nil - case actors.Version7: + case actorstypes.Version7: return miner7.DeclarationsMax, nil - case actors.Version8: + case actorstypes.Version8: return miner8.DeclarationsMax, nil + case actorstypes.Version9: + + return miner9.DeclarationsMax, nil + default: return 0, xerrors.Errorf("unsupported network version") } } func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { - case actors.Version0: + case actorstypes.Version0: return big.Zero(), nil - case actors.Version2: + case actorstypes.Version2: return big.Zero(), nil - case actors.Version3: + case actorstypes.Version3: return big.Zero(), nil - case actors.Version4: + case actorstypes.Version4: return big.Zero(), nil - case actors.Version5: + case actorstypes.Version5: return miner5.AggregateNetworkFee(aggregateSize, baseFee), nil - case actors.Version6: + case actorstypes.Version6: return miner6.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version7: + case actorstypes.Version7: return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version8: + case actorstypes.Version8: return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version9: + + return miner9.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil + default: return big.Zero(), xerrors.Errorf("unsupported network version") } } func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { - case actors.Version0: + case actorstypes.Version0: return big.Zero(), nil - case actors.Version2: + case actorstypes.Version2: return big.Zero(), nil - case actors.Version3: + case actorstypes.Version3: return big.Zero(), nil - case actors.Version4: + case actorstypes.Version4: return big.Zero(), nil - case actors.Version5: + case actorstypes.Version5: return big.Zero(), nil - case actors.Version6: + case actorstypes.Version6: return miner6.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version7: + case actorstypes.Version7: return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil - case actors.Version8: + case actorstypes.Version8: return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil + case actorstypes.Version9: + + return miner9.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 090e91165f4..f5178500a13 100644 --- a/chain/actors/policy/policy.go.template +++ b/chain/actors/policy/policy.go.template @@ -1,14 +1,13 @@ package policy import ( - "sort" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/chain/actors" {{range .versions}} {{if (ge . 8)}} @@ -50,7 +49,7 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { miner{{.}}.PreCommitSealProofTypesV0 = make(map[abi.RegisteredSealProof]struct{}, len(types)) miner{{.}}.PreCommitSealProofTypesV7 = make(map[abi.RegisteredSealProof]struct{}, len(types)*2) miner{{.}}.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) - {{else}} + {{else if (le . 7)}} miner{{.}}.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types)) {{end}} {{end}} @@ -84,7 +83,7 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { } miner{{.}}.WindowPoStProofTypes[wpp] = struct{}{} - {{else}} + {{else if (le . 7)}} miner{{.}}.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{} wpp, err = t.RegisteredWindowPoStProof() if err != nil { @@ -139,10 +138,10 @@ func SetMinVerifiedDealSize(size abi.StoragePower) { {{end}} } -func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { +func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) { switch ver { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (eq . 0)}} return miner{{.}}.MaxSealDuration[t], nil {{else}} @@ -173,13 +172,13 @@ func DealProviderCollateralBounds( rawBytePower, qaPower, baselinePower abi.StoragePower, circulatingFil abi.TokenAmount, nwVer network.Version, ) (min, max abi.TokenAmount, err error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), big.Zero(), err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (eq . 0)}} min, max := market{{.}}.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil, nwVer) return min, max, nil @@ -240,25 +239,6 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e return int(uint64(maxSectors) / sectorsPerPart), nil } -func GetDefaultSectorSize() abi.SectorSize { - // supported sector sizes are the same across versions. - szs := make([]abi.SectorSize, 0, len(miner{{.latestVersion}}.PreCommitSealProofTypesV8)) - for spt := range miner{{.latestVersion}}.PreCommitSealProofTypesV8 { - ss, err := spt.SectorSize() - if err != nil { - panic(err) - } - - szs = append(szs, ss) - } - - sort.Slice(szs, func(i, j int) bool { - return szs[i] < szs[j] - }) - - return szs[0] -} - func GetDefaultAggregationProof() abi.RegisteredAggregationProof { return abi.RegisteredAggregationProof_SnarkPackV1 } @@ -272,13 +252,13 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) } func GetAddressedSectorsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: return miner{{.}}.AddressedSectorsMax, nil {{end}} default: @@ -287,13 +267,13 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) { } func GetDeclarationsMax(nwVer network.Version) (int, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return 0, err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (eq . 0)}} // TODO: Should we instead error here since the concept doesn't exist yet? return miner{{.}}.AddressedPartitionsMax, nil @@ -307,13 +287,13 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) { } func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (ge . 6)}} return miner{{.}}.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil {{else if (eq . 5)}} @@ -328,13 +308,13 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba } func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, baseFee abi.TokenAmount) (abi.TokenAmount, error) { - v, err := actors.VersionForNetwork(nwVer) + v, err := actorstypes.VersionForNetwork(nwVer) if err != nil { return big.Zero(), err } switch v { {{range .versions}} - case actors.Version{{.}}: + case actorstypes.Version{{.}}: {{if (ge . 6)}} return miner{{.}}.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil {{else}} diff --git a/chain/actors/version.go b/chain/actors/version.go index 1a17a69720f..b9f4c2034d1 100644 --- a/chain/actors/version.go +++ b/chain/actors/version.go @@ -1,11 +1,5 @@ package actors -import ( - "fmt" - - "github.com/filecoin-project/go-state-types/network" -) - type Version int /* inline-gen template @@ -20,9 +14,9 @@ const ({{range .actorVersions}} /* inline-gen start */ -var LatestVersion = 8 +var LatestVersion = 9 -var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8} +var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9} const ( Version0 Version = 0 @@ -33,30 +27,7 @@ const ( Version6 Version = 6 Version7 Version = 7 Version8 Version = 8 + Version9 Version = 9 ) /* inline-gen end */ - -// Converts a network version into an actors adt version. -func VersionForNetwork(version network.Version) (Version, error) { - switch version { - case network.Version0, network.Version1, network.Version2, network.Version3: - return Version0, nil - case network.Version4, network.Version5, network.Version6, network.Version7, network.Version8, network.Version9: - return Version2, nil - case network.Version10, network.Version11: - return Version3, nil - case network.Version12: - return Version4, nil - case network.Version13: - return Version5, nil - case network.Version14: - 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/filcns/compute_state.go b/chain/consensus/filcns/compute_state.go index e735f362e18..9837e265f0f 100644 --- a/chain/consensus/filcns/compute_state.go +++ b/chain/consensus/filcns/compute_state.go @@ -4,20 +4,6 @@ import ( "context" "sync/atomic" - /* 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" - exported4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/exported" - exported5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/exported" - exported6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/exported" - exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported" - exported8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/exported" - - /* inline-gen end */ "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "go.opencensus.io/stats" @@ -25,8 +11,16 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" + exported0 "github.com/filecoin-project/specs-actors/actors/builtin/exported" blockadt "github.com/filecoin-project/specs-actors/actors/util/adt" + exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported" + exported3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/exported" + exported4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/exported" + 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" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" @@ -45,23 +39,15 @@ import ( func NewActorRegistry() *vm.ActorRegistry { inv := vm.NewActorRegistry() - /* inline-gen template - {{range .actorVersions}} - inv.Register(actors.Version{{.}}, vm.ActorsVersionPredicate(actors.Version{{.}}), exported{{.}}.BuiltinActors()...){{end}} - - - /* inline-gen start */ - - inv.Register(actors.Version0, vm.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...) - inv.Register(actors.Version2, vm.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...) - inv.Register(actors.Version3, vm.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...) - inv.Register(actors.Version4, vm.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...) - inv.Register(actors.Version5, vm.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...) - inv.Register(actors.Version6, vm.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...) - inv.Register(actors.Version7, vm.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...) - inv.Register(actors.Version8, vm.ActorsVersionPredicate(actors.Version8), exported8.BuiltinActors()...) - - /* inline-gen end */ + inv.Register(actorstypes.Version0, vm.ActorsVersionPredicate(actorstypes.Version0), exported0.BuiltinActors()...) + inv.Register(actorstypes.Version2, vm.ActorsVersionPredicate(actorstypes.Version2), exported2.BuiltinActors()...) + inv.Register(actorstypes.Version3, vm.ActorsVersionPredicate(actorstypes.Version3), exported3.BuiltinActors()...) + inv.Register(actorstypes.Version4, vm.ActorsVersionPredicate(actorstypes.Version4), exported4.BuiltinActors()...) + inv.Register(actorstypes.Version5, vm.ActorsVersionPredicate(actorstypes.Version5), exported5.BuiltinActors()...) + inv.Register(actorstypes.Version6, vm.ActorsVersionPredicate(actorstypes.Version6), exported6.BuiltinActors()...) + inv.Register(actorstypes.Version7, vm.ActorsVersionPredicate(actorstypes.Version7), exported7.BuiltinActors()...) + inv.Register(actorstypes.Version8, vm.ActorsVersionPredicate(actorstypes.Version8), builtin.MakeRegistry(actorstypes.Version8)...) + inv.Register(actorstypes.Version9, vm.ActorsVersionPredicate(actorstypes.Version9), builtin.MakeRegistry(actorstypes.Version9)...) return inv } diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index d5e6b45fd87..10dc9a12634 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -14,7 +14,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" + nv17 "github.com/filecoin-project/go-state-types/builtin/v9/migration" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/rt" @@ -189,6 +191,17 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule { StopWithin: 5, }}, Expensive: true, + }, { + Height: build.UpgradeV17Height, + Network: network.Version17, + Migration: UpgradeActorsV9, + PreMigrations: []stmgr.PreMigration{{ + PreMigration: PreUpgradeActorsV9, + StartWithin: 180, + DontStartWithin: 60, + StopWithin: 5, + }}, + Expensive: true, }, } @@ -1377,7 +1390,7 @@ func upgradeActorsV8Common( store := store.ActorStore(ctx, buf) // ensure that the manifest is loaded in the blockstore - if err := bundle.LoadBundles(ctx, buf, actors.Version8); err != nil { + if err := bundle.LoadBundles(ctx, buf, actorstypes.Version8); err != nil { return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err) } @@ -1394,7 +1407,7 @@ func upgradeActorsV8Common( ) } - manifest, ok := actors.GetManifest(actors.Version8) + manifest, ok := actors.GetManifest(actorstypes.Version8) if !ok { return cid.Undef, xerrors.Errorf("no manifest CID for v8 upgrade") } @@ -1429,6 +1442,115 @@ func upgradeActorsV8Common( return newRoot, nil } +func UpgradeActorsV9(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 := nv17.Config{ + MaxWorkers: uint(workerCount), + JobQueueSize: 1000, + ResultQueueSize: 100, + ProgressLogPeriod: 10 * time.Second, + } + + newRoot, err := upgradeActorsV9Common(ctx, sm, cache, root, epoch, ts, config) + if err != nil { + return cid.Undef, xerrors.Errorf("migrating actors v8 state: %w", err) + } + + fmt.Print(fvmLiftoffBanner) + + return newRoot, nil +} + +func PreUpgradeActorsV9(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 := nv17.Config{MaxWorkers: uint(workerCount), + ProgressLogPeriod: time.Minute * 5} + + _, err = upgradeActorsV9Common(ctx, sm, cache, lbRoot, epoch, lbts, config) + return err +} + +func upgradeActorsV9Common( + ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, + root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet, + config nv17.Config, +) (cid.Cid, error) { + buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync()) + store := store.ActorStore(ctx, buf) + + // ensure that the manifest is loaded in the blockstore + if err := bundle.LoadBundles(ctx, buf, actorstypes.Version9); err != nil { + return cid.Undef, xerrors.Errorf("failed to load manifest bundle: %w", err) + } + + // Load the state root. + var stateRoot types.StateRoot + if err := store.Get(ctx, root, &stateRoot); err != nil { + return cid.Undef, xerrors.Errorf("failed to decode state root: %w", err) + } + + if stateRoot.Version != types.StateTreeVersion4 { + return cid.Undef, xerrors.Errorf( + "expected state root version 4 for actors v9 upgrade, got %d", + stateRoot.Version, + ) + } + + manifest, ok := actors.GetManifest(actorstypes.Version9) + if !ok { + return cid.Undef, xerrors.Errorf("no manifest CID for v9 upgrade") + } + + // Perform the migration + newHamtRoot, err := nv17.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, + migrationLogger{}, cache) + if err != nil { + return cid.Undef, xerrors.Errorf("upgrading to actors v9: %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 +} + // Example upgrade function if upgrade requires only code changes //func UpgradeActorsV9(ctx context.Context, sm *stmgr.StateManager, _ stmgr.MigrationCache, _ stmgr.ExecMonitor, root cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) (cid.Cid, error) { // buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync()) @@ -1453,7 +1575,7 @@ func upgradeActorsV8Common( // return LiteMigration(ctx, bstore, newActorsManifestCid, root, av, types.StateTreeVersion4, newStateTreeVersion) //} -func LiteMigration(ctx context.Context, bstore blockstore.Blockstore, newActorsManifestCid cid.Cid, root cid.Cid, av actors.Version, oldStateTreeVersion types.StateTreeVersion, newStateTreeVersion types.StateTreeVersion) (cid.Cid, error) { +func LiteMigration(ctx context.Context, bstore blockstore.Blockstore, newActorsManifestCid cid.Cid, root cid.Cid, av actorstypes.Version, oldStateTreeVersion types.StateTreeVersion, newStateTreeVersion types.StateTreeVersion) (cid.Cid, error) { buf := blockstore.NewTieredBstore(bstore, blockstore.NewMemorySync()) store := store.ActorStore(ctx, buf) adtStore := gstStore.WrapStore(ctx, store) diff --git a/chain/exchange/cbor_gen.go b/chain/exchange/cbor_gen.go index d1eb271e99a..9c7f68ab8e1 100644 --- a/chain/exchange/cbor_gen.go +++ b/chain/exchange/cbor_gen.go @@ -8,11 +8,10 @@ import ( "math" "sort" + types "github.com/filecoin-project/lotus/chain/types" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" - - types "github.com/filecoin-project/lotus/chain/types" ) var _ = xerrors.Errorf diff --git a/chain/gen/genesis/f00_system.go b/chain/gen/genesis/f00_system.go index 1cd50f5e11c..209b6db7d2c 100644 --- a/chain/gen/genesis/f00_system.go +++ b/chain/gen/genesis/f00_system.go @@ -7,6 +7,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" systemtypes "github.com/filecoin-project/go-state-types/builtin/v8/system" "github.com/filecoin-project/go-state-types/manifest" @@ -18,7 +19,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) // TODO pass in built-in actors cid for V8 and later @@ -27,7 +28,7 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi return nil, err } - if av >= actors.Version8 { + if av >= actorstypes.Version8 { mfCid, ok := actors.GetManifest(av) if !ok { return nil, xerrors.Errorf("missing manifest for actors version %d", av) diff --git a/chain/gen/genesis/f01_init.go b/chain/gen/genesis/f01_init.go index ddb448de929..26062cf2774 100644 --- a/chain/gen/genesis/f01_init.go +++ b/chain/gen/genesis/f01_init.go @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -21,7 +22,7 @@ import ( "github.com/filecoin-project/lotus/genesis" ) -func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, initialActors []genesis.Actor, rootVerifier genesis.Actor, remainder genesis.Actor, av actors.Version) (int64, *types.Actor, map[address.Address]address.Address, error) { +func SetupInitActor(ctx context.Context, bs bstore.Blockstore, netname string, initialActors []genesis.Actor, rootVerifier genesis.Actor, remainder genesis.Actor, av actorstypes.Version) (int64, *types.Actor, map[address.Address]address.Address, error) { if len(initialActors) > MaxAccounts { return 0, nil, nil, xerrors.New("too many initial actors") } diff --git a/chain/gen/genesis/f02_reward.go b/chain/gen/genesis/f02_reward.go index 0d0c1db0f28..4a5ac9fa145 100644 --- a/chain/gen/genesis/f02_reward.go +++ b/chain/gen/genesis/f02_reward.go @@ -6,6 +6,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" bstore "github.com/filecoin-project/lotus/blockstore" @@ -16,7 +17,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actors.Version) (*types.Actor, error) { +func SetupRewardActor(ctx context.Context, bs bstore.Blockstore, qaPower big.Int, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) rst, err := reward.MakeState(adt.WrapStore(ctx, cst), av, qaPower) if err != nil { diff --git a/chain/gen/genesis/f03_cron.go b/chain/gen/genesis/f03_cron.go index c9fe7c11850..16396c43713 100644 --- a/chain/gen/genesis/f03_cron.go +++ b/chain/gen/genesis/f03_cron.go @@ -6,6 +6,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" bstore "github.com/filecoin-project/lotus/blockstore" @@ -15,7 +16,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupCronActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) st, err := cron.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) if err != nil { diff --git a/chain/gen/genesis/f04_power.go b/chain/gen/genesis/f04_power.go index 20232c9b216..f05b0c746b8 100644 --- a/chain/gen/genesis/f04_power.go +++ b/chain/gen/genesis/f04_power.go @@ -6,6 +6,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -15,7 +16,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupStoragePowerActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) pst, err := power.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) diff --git a/chain/gen/genesis/f05_market.go b/chain/gen/genesis/f05_market.go index 9109e278488..28a258c405e 100644 --- a/chain/gen/genesis/f05_market.go +++ b/chain/gen/genesis/f05_market.go @@ -6,6 +6,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" bstore "github.com/filecoin-project/lotus/blockstore" @@ -15,7 +16,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupStorageMarketActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) mst, err := market.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av) if err != nil { diff --git a/chain/gen/genesis/f06_vreg.go b/chain/gen/genesis/f06_vreg.go index 381a115d4c0..1b3582d4d75 100644 --- a/chain/gen/genesis/f06_vreg.go +++ b/chain/gen/genesis/f06_vreg.go @@ -7,6 +7,7 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -28,7 +29,7 @@ func init() { RootVerifierID = idk } -func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av actors.Version) (*types.Actor, error) { +func SetupVerifiedRegistryActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) { cst := cbor.NewCborStore(bs) vst, err := verifreg.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av, RootVerifierID) if err != nil { diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 4eaed56aae0..34f12db6dc0 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" @@ -137,7 +138,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return nil, nil, xerrors.Errorf("making new state tree: %w", err) } - av, err := actors.VersionForNetwork(template.NetworkVersion) + av, err := actorstypes.VersionForNetwork(template.NetworkVersion) if err != nil { return nil, nil, xerrors.Errorf("getting network version: %w", err) } @@ -356,7 +357,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return state, keyIDs, nil } -func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version, addr address.Address, bal types.BigInt) (*types.Actor, error) { +func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actorstypes.Version, addr address.Address, bal types.BigInt) (*types.Actor, error) { ast, err := account.MakeState(adt.WrapStore(ctx, cst), av, addr) if err != nil { return nil, err @@ -381,7 +382,7 @@ func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actors.Version return act, nil } -func CreateAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, info genesis.Actor, keyIDs map[address.Address]address.Address, av actors.Version) error { +func CreateAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, info genesis.Actor, keyIDs map[address.Address]address.Address, av actorstypes.Version) error { var ainfo genesis.AccountMeta if err := json.Unmarshal(info.Meta, &ainfo); err != nil { return xerrors.Errorf("unmarshaling account meta: %w", err) @@ -404,7 +405,7 @@ func CreateAccountActor(ctx context.Context, cst cbor.IpldStore, state *state.St return nil } -func CreateMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, ida address.Address, info genesis.Actor, keyIDs map[address.Address]address.Address, av actors.Version) error { +func CreateMultisigAccount(ctx context.Context, cst cbor.IpldStore, state *state.StateTree, ida address.Address, info genesis.Actor, keyIDs map[address.Address]address.Address, av actorstypes.Version) error { if info.Type != genesis.TMultisig { return fmt.Errorf("can only call CreateMultisigAccount with multisig Actor info") } diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index a4f43e7faec..0397d38b1ad 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/go-address" cborutil "github.com/filecoin-project/go-cbor-util" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" builtintypes "github.com/filecoin-project/go-state-types/builtin" markettypes "github.com/filecoin-project/go-state-types/builtin/v8/market" @@ -34,7 +35,6 @@ import ( builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin" runtime7 "github.com/filecoin-project/specs-actors/v7/actors/runtime" - "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" @@ -81,7 +81,7 @@ func mkFakedSigSyscalls(base vm.SyscallBuilder) vm.SyscallBuilder { func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.SyscallBuilder, sroot cid.Cid, miners []genesis.Miner, nv network.Version) (cid.Cid, error) { cst := cbor.NewCborStore(cs.StateBlockstore()) - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return cid.Undef, xerrors.Errorf("failed to get network version: %w", err) } @@ -234,7 +234,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal ClientSignature: crypto.Signature{Type: crypto.SigTypeBLS}, } - if av >= actors.Version8 { + if av >= actorstypes.Version8 { buf, err := cborutil.Dump(&preseal.Deal) if err != nil { return cid.Undef, fmt.Errorf("failed to marshal proposal: %w", err) @@ -464,7 +464,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal // Commit one-by-one, otherwise pledge math tends to explode var paramBytes []byte - if av >= actors.Version6 { + if av >= actorstypes.Version6 { // TODO: fixup confirmParams := &builtin6.ConfirmSectorProofsParams{ Sectors: []abi.SectorNumber{preseal.SectorID}, @@ -484,7 +484,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err) } - if av >= actors.Version2 { + if av >= actorstypes.Version2 { // post v0, we need to explicitly Claim this power since ConfirmSectorProofsValid doesn't do it anymore claimParams := &power4.UpdateClaimedPowerParams{ RawByteDelta: types.NewInt(uint64(m.SectorSize)), @@ -617,9 +617,9 @@ func currentTotalPower(ctx context.Context, vm vm.Interface, maddr address.Addre return &pwr, nil } -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) { +func dealWeight(ctx context.Context, vm vm.Interface, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actorstypes.Version) (abi.DealWeight, abi.DealWeight, error) { // TODO: This hack should move to market actor wrapper - if av <= actors.Version2 { + if av <= actorstypes.Version2 { params := &market0.VerifyDealsForActivationParams{ DealIDs: dealIDs, SectorStart: sectorStart, @@ -637,7 +637,7 @@ func dealWeight(ctx context.Context, vm vm.Interface, maddr address.Address, dea return big.Zero(), big.Zero(), err } var weight, verifiedWeight abi.DealWeight - if av < actors.Version2 { + if av < actorstypes.Version2 { var dealWeights market0.VerifyDealsForActivationReturn err = dealWeights.UnmarshalCBOR(bytes.NewReader(ret)) weight = dealWeights.DealWeight @@ -677,7 +677,7 @@ func dealWeight(ctx context.Context, vm vm.Interface, maddr address.Address, dea return dealWeights.Sectors[0].DealWeight, dealWeights.Sectors[0].VerifiedDealWeight, nil } -func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) { +func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address.Address, av actorstypes.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 @@ -685,7 +685,7 @@ func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address // TODO: This hack should move to reward actor wrapper switch av { - case actors.Version0: + case actorstypes.Version0: var epochReward reward0.ThisEpochRewardReturn if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil { @@ -693,7 +693,7 @@ func currentEpochBlockReward(ctx context.Context, vm vm.Interface, maddr address } return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(*epochReward.ThisEpochRewardSmoothed), nil - case actors.Version2: + case actorstypes.Version2: var epochReward reward2.ThisEpochRewardReturn if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil { diff --git a/chain/state/statetree.go b/chain/state/statetree.go index 970ac3c726e..ff921a04d5c 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -158,7 +158,7 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) { /* inline-gen start */ - case network.Version13, network.Version14, network.Version15, network.Version16: + case network.Version13, network.Version14, network.Version15, network.Version16, network.Version17: /* inline-gen end */ return types.StateTreeVersion4, nil diff --git a/chain/stmgr/actors.go b/chain/stmgr/actors.go index 3ef5a3af965..fa51306a6c6 100644 --- a/chain/stmgr/actors.go +++ b/chain/stmgr/actors.go @@ -12,7 +12,6 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - miner_types "github.com/filecoin-project/go-state-types/builtin/v8/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" @@ -89,7 +88,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_types.SectorPreCommitOnChainInfo, error) { +func PreCommitInfo(ctx context.Context, sm *StateManager, maddr address.Address, sid abi.SectorNumber, ts *types.TipSet) (*miner.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_test.go b/chain/stmgr/forks_test.go index 7eb63566ca8..d46d0befe0b 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -17,6 +17,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/network" builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" @@ -167,7 +168,7 @@ func TestForkHeightTriggers(t *testing.T) { } inv := filcns.NewActorRegistry() - inv.Register(actors.Version0, nil, testActor{}) + inv.Register(actorstypes.Version0, nil, testActor{}) sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) { nvm, err := vm.NewLegacyVM(ctx, vmopt) @@ -284,7 +285,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) { } inv := filcns.NewActorRegistry() - inv.Register(actors.Version0, nil, testActor{}) + inv.Register(actorstypes.Version0, nil, testActor{}) sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) { nvm, err := vm.NewLegacyVM(ctx, vmopt) @@ -505,7 +506,7 @@ func TestForkPreMigration(t *testing.T) { }() inv := filcns.NewActorRegistry() - inv.Register(actors.Version0, nil, testActor{}) + inv.Register(actorstypes.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/sync_test.go b/chain/sync_test.go index b1be0b59064..18520a07fe4 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -147,6 +147,10 @@ func prepSyncTestWithV5Height(t testing.TB, h int, v5height abi.ChainEpoch) *syn Network: network.Version16, Height: v5height + 20, Migration: filcns.UpgradeActorsV8, + }, { + Network: network.Version17, + Height: v5height + 25, + Migration: filcns.UpgradeActorsV9, }} g, err := gen.NewGeneratorWithUpgradeSchedule(sched) diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index 78a3449ee82..79ff5d19c49 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -8,14 +8,13 @@ import ( "math" "sort" - cid "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - xerrors "golang.org/x/xerrors" - 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/go-state-types/proof" + cid "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + xerrors "golang.org/x/xerrors" ) var _ = xerrors.Errorf diff --git a/chain/vm/cbor_gen.go b/chain/vm/cbor_gen.go index 64b623f635d..0e1677c95e2 100644 --- a/chain/vm/cbor_gen.go +++ b/chain/vm/cbor_gen.go @@ -8,11 +8,10 @@ import ( "math" "sort" + types "github.com/filecoin-project/lotus/chain/types" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" - - types "github.com/filecoin-project/lotus/chain/types" ) var _ = xerrors.Errorf diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 7ae6bf20300..b87830a3c0a 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -21,6 +21,7 @@ import ( ffi_cgo "github.com/filecoin-project/filecoin-ffi/cgo" "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/lotus/blockstore" @@ -295,7 +296,7 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { } if os.Getenv("LOTUS_USE_FVM_CUSTOM_BUNDLE") == "1" { - av, err := actors.VersionForNetwork(opts.NetworkVersion) + av, err := actorstypes.VersionForNetwork(opts.NetworkVersion) if err != nil { return nil, xerrors.Errorf("mapping network version to actors version: %w", err) } @@ -367,7 +368,7 @@ func NewDebugFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { // create actor redirect mapping actorRedirect := make(map[cid.Cid]cid.Cid) for _, key := range actors.GetBuiltinActorsKeys() { - from, ok := actors.GetActorCodeID(actors.Version8, key) + from, ok := actors.GetActorCodeID(actorstypes.Version8, key) if !ok { log.Warnf("actor missing in the from manifest %s", key) continue @@ -393,13 +394,13 @@ func NewDebugFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { return nil } - av, err := actors.VersionForNetwork(opts.NetworkVersion) + av, err := actorstypes.VersionForNetwork(opts.NetworkVersion) if err != nil { return nil, xerrors.Errorf("error determining actors version for network version %d: %w", opts.NetworkVersion, err) } switch av { - case actors.Version8: + case actorstypes.Version8: if debugBundleV8path != "" { if err := createMapping(debugBundleV8path); err != nil { log.Errorf("failed to create v8 debug mapping") diff --git a/chain/vm/invoker.go b/chain/vm/invoker.go index ad04639e59e..8d9caad3eba 100644 --- a/chain/vm/invoker.go +++ b/chain/vm/invoker.go @@ -5,14 +5,14 @@ import ( "encoding/hex" "fmt" "reflect" - "runtime" - "strings" + "strconv" "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" rtt "github.com/filecoin-project/go-state-types/rt" @@ -25,7 +25,7 @@ import ( ) type MethodMeta struct { - Name string + Num string Params reflect.Type Ret reflect.Type @@ -40,9 +40,9 @@ type ActorRegistry struct { // An ActorPredicate returns an error if the given actor is not valid for the given runtime environment (e.g., chain height, version, etc.). type ActorPredicate func(vmr.Runtime, rtt.VMActor) error -func ActorsVersionPredicate(ver actors.Version) ActorPredicate { +func ActorsVersionPredicate(ver actorstypes.Version) ActorPredicate { return func(rt vmr.Runtime, v rtt.VMActor) error { - aver, err := actors.VersionForNetwork(rt.NetworkVersion()) + aver, err := actorstypes.VersionForNetwork(rt.NetworkVersion()) if err != nil { return xerrors.Errorf("unsupported network version: %w", err) } @@ -86,7 +86,7 @@ func (ar *ActorRegistry) Invoke(codeCid cid.Cid, rt vmr.Runtime, method abi.Meth } -func (ar *ActorRegistry) Register(av actors.Version, pred ActorPredicate, vmactors ...rtt.VMActor) { +func (ar *ActorRegistry) Register(av actorstypes.Version, pred ActorPredicate, vmactors ...rtt.VMActor) { if pred == nil { pred = func(vmr.Runtime, rtt.VMActor) error { return nil } } @@ -108,7 +108,7 @@ func (ar *ActorRegistry) Register(av actors.Version, pred ActorPredicate, vmacto // necessary to make stuff work var realCode cid.Cid - if av >= actors.Version8 { + if av >= actorstypes.Version8 { name := actors.CanonicalName(builtin.ActorNameByCode(ac)) var ok bool @@ -124,7 +124,7 @@ func (ar *ActorRegistry) Register(av actors.Version, pred ActorPredicate, vmacto // Explicitly add send, it's special. methods[builtin.MethodSend] = MethodMeta{ - Name: "Send", + Num: "0", Params: reflect.TypeOf(new(abi.EmptyValue)), Ret: reflect.TypeOf(new(abi.EmptyValue)), } @@ -139,24 +139,8 @@ func (ar *ActorRegistry) Register(av actors.Version, pred ActorPredicate, vmacto ev := reflect.ValueOf(export) et := ev.Type() - // Extract the method names using reflection. These - // method names always match the field names in the - // `builtin.Method*` structs (tested in the specs-actors - // tests). - fnName := runtime.FuncForPC(ev.Pointer()).Name() - fnName = strings.TrimSuffix(fnName[strings.LastIndexByte(fnName, '.')+1:], "-fm") - - switch abi.MethodNum(number) { - case builtin.MethodSend: - panic("method 0 is reserved for Send") - case builtin.MethodConstructor: - if fnName != "Constructor" { - panic("method 1 is reserved for Constructor") - } - } - methods[abi.MethodNum(number)] = MethodMeta{ - Name: fnName, + Num: strconv.Itoa(number), Params: et.In(1), Ret: et.Out(0), } diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index 7e27ee81198..3a0ee66996c 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -7,6 +7,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" @@ -53,7 +54,7 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, add return nil, address.Undef, aerrors.Escalate(err, "registering actor address") } - av, err := actors.VersionForNetwork(rt.NetworkVersion()) + av, err := actorstypes.VersionForNetwork(rt.NetworkVersion()) if err != nil { return nil, address.Undef, aerrors.Escalate(err, "unsupported network version") } @@ -85,7 +86,7 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, add return act, addrID, nil } -func makeAccountActor(ver actors.Version, addr address.Address) (*types.Actor, aerrors.ActorError) { +func makeAccountActor(ver actorstypes.Version, addr address.Address) (*types.Actor, aerrors.ActorError) { switch addr.Protocol() { case address.BLS, address.SECP256K1: return newAccountActor(ver), nil @@ -98,23 +99,23 @@ func makeAccountActor(ver actors.Version, addr address.Address) (*types.Actor, a } } -func newAccountActor(ver actors.Version) *types.Actor { +func newAccountActor(ver actorstypes.Version) *types.Actor { // TODO: ActorsUpgrade use a global actor registry? var code cid.Cid switch ver { - case actors.Version0: + case actorstypes.Version0: code = builtin0.AccountActorCodeID - case actors.Version2: + case actorstypes.Version2: code = builtin2.AccountActorCodeID - case actors.Version3: + case actorstypes.Version3: code = builtin3.AccountActorCodeID - case actors.Version4: + case actorstypes.Version4: code = builtin4.AccountActorCodeID - case actors.Version5: + case actorstypes.Version5: code = builtin5.AccountActorCodeID - case actors.Version6: + case actorstypes.Version6: code = builtin6.AccountActorCodeID - case actors.Version7: + case actorstypes.Version7: code = builtin7.AccountActorCodeID default: panic("unsupported actors version") diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index ce9349a1d84..05f8de2f095 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -16,6 +16,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" @@ -373,7 +374,7 @@ func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid) { // 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) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { panic(aerrors.Fatalf("failed to get actors version for network version %d", nv)) } diff --git a/cli/chain.go b/cli/chain.go index 48fbb849ddc..39f1608f540 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -494,8 +494,8 @@ var ChainInspectUsage = &cli.Command{ mm := filcns.NewActorRegistry().Methods[code][m.Message.Method] // TODO: use remote map - byMethod[mm.Name] += m.Message.GasLimit - byMethodC[mm.Name]++ + byMethod[mm.Num] += m.Message.GasLimit + byMethodC[mm.Num]++ } type keyGasPair struct { diff --git a/cli/multisig.go b/cli/multisig.go index f4b67e14ddc..67c83339796 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -341,7 +341,7 @@ var msigInspectCmd = &cli.Command{ paramStr = string(b) } - fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), method.Name, tx.Method, paramStr) + fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), method.Num, tx.Method, paramStr) } } if err := w.Flush(); err != nil { diff --git a/cli/servicesmock_test.go b/cli/servicesmock_test.go index 11260ab08be..5bae52a5ebc 100644 --- a/cli/servicesmock_test.go +++ b/cli/servicesmock_test.go @@ -8,14 +8,12 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - go_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" - api "github.com/filecoin-project/lotus/api" types "github.com/filecoin-project/lotus/chain/types" + gomock "github.com/golang/mock/gomock" ) // MockServicesAPI is a mock of ServicesAPI interface. diff --git a/cli/state.go b/cli/state.go index f18beb0fbe2..bea7ed0df0a 100644 --- a/cli/state.go +++ b/cli/state.go @@ -29,6 +29,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" @@ -1231,7 +1232,7 @@ var compStateMsg = `
Gas Trace - + {{define "virt" -}} {{- if . -}} +({{.}}) @@ -1243,7 +1244,7 @@ var compStateMsg = ` {{- end}} {{range .GasCharges}} - + {{template "gasC" .}}
NameTotal/Compute/StorageTime TakenLocation
NumTotal/Compute/StorageTime TakenLocation
{{.Name}}{{if .Extra}}:{{.Extra}}{{end}}
{{.Num}}{{if .Extra}}:{{.Extra}}{{end}}{{if PrintTiming}}{{.TimeTaken}}{{end}} @@ -1368,7 +1369,7 @@ func codeStr(c cid.Cid) string { } func getMethod(code cid.Cid, method abi.MethodNum) string { - return filcns.NewActorRegistry().Methods[code][method].Name // todo: use remote + return filcns.NewActorRegistry().Methods[code][method].Num // todo: use remote } func toFil(f types.BigInt) types.FIL { @@ -1904,7 +1905,7 @@ var StateSysActorCIDsCmd = &cli.Command{ fmt.Printf("Network Version: %d\n", nv) - actorVersion, err := actors.VersionForNetwork(nv) + actorVersion, err := actorstypes.VersionForNetwork(nv) if err != nil { return err } diff --git a/cmd/lotus-miner/init.go b/cmd/lotus-miner/init.go index 055df69efe1..dd245f038fc 100644 --- a/cmd/lotus-miner/init.go +++ b/cmd/lotus-miner/init.go @@ -42,7 +42,6 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "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/policy" "github.com/filecoin-project/lotus/chain/gen/slashfilter" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" @@ -91,7 +90,7 @@ var initCmd = &cli.Command{ &cli.StringFlag{ Name: "sector-size", Usage: "specify sector size to use", - Value: units.BytesSize(float64(policy.GetDefaultSectorSize())), + Value: units.BytesSize(float64(abi.SectorSize(2048))), }, &cli.StringSliceFlag{ Name: "pre-sealed-sectors", diff --git a/cmd/lotus-miner/precommits-info.go b/cmd/lotus-miner/precommits-info.go index 034378cff27..0ce7575377d 100644 --- a/cmd/lotus-miner/precommits-info.go +++ b/cmd/lotus-miner/precommits-info.go @@ -7,7 +7,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "github.com/urfave/cli/v2" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/specs-actors/v7/actors/util/adt" "github.com/filecoin-project/lotus/blockstore" diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 84c2d8e959d..45a1256aa83 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -21,7 +21,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/builtin" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" diff --git a/cmd/lotus-pcr/main.go b/cmd/lotus-pcr/main.go index 474ed55f711..f491d9a331a 100644 --- a/cmd/lotus-pcr/main.go +++ b/cmd/lotus-pcr/main.go @@ -27,7 +27,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/builtin" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" diff --git a/cmd/lotus-shed/msg.go b/cmd/lotus-shed/msg.go index bd8bd64f0f2..49412948c2a 100644 --- a/cmd/lotus-shed/msg.go +++ b/cmd/lotus-shed/msg.go @@ -141,7 +141,7 @@ func printMessage(cctx *cli.Context, msg *types.Message) error { return nil } - fmt.Println("Method:", filcns.NewActorRegistry().Methods[toact.Code][msg.Method].Name) // todo use remote + fmt.Println("Method:", filcns.NewActorRegistry().Methods[toact.Code][msg.Method].Num) // todo use remote p, err := lcli.JsonParams(toact.Code, msg.Method, msg.Params) if err != nil { return err diff --git a/cmd/lotus-sim/info.go b/cmd/lotus-sim/info.go index 864adb3bc9b..b92fa4b2f4d 100644 --- a/cmd/lotus-sim/info.go +++ b/cmd/lotus-sim/info.go @@ -66,7 +66,7 @@ func printInfo(ctx context.Context, sim *simulation.Simulation, out io.Writer) e startTime := time.Unix(int64(start.MinTimestamp()), 0) duration := headTime.Sub(startTime) - fmt.Fprintf(tw, "Name:\t%s\n", sim.Name()) + fmt.Fprintf(tw, "Num:\t%s\n", sim.Name()) fmt.Fprintf(tw, "Head:\t%s\n", head) fmt.Fprintf(tw, "Start Epoch:\t%d\n", firstEpoch) fmt.Fprintf(tw, "End Epoch:\t%d\n", headEpoch) diff --git a/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go b/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go index 5e84688ecb7..d9a32481c89 100644 --- a/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go +++ b/cmd/lotus-sim/simulation/blockbuilder/blockbuilder.go @@ -9,10 +9,10 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/network" "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" "github.com/filecoin-project/lotus/chain/actors/builtin/account" @@ -273,8 +273,8 @@ func (bb *BlockBuilder) StateManager() *stmgr.StateManager { } // ActorsVersion returns the actors version for the target block. -func (bb *BlockBuilder) ActorsVersion() (actors.Version, error) { - return actors.VersionForNetwork(bb.NetworkVersion()) +func (bb *BlockBuilder) ActorsVersion() (actorstypes.Version, error) { + return actorstypes.VersionForNetwork(bb.NetworkVersion()) } func (bb *BlockBuilder) L() *zap.SugaredLogger { diff --git a/cmd/lotus-sim/simulation/node.go b/cmd/lotus-sim/simulation/node.go index b0317c66bfb..f115ffe19d3 100644 --- a/cmd/lotus-sim/simulation/node.go +++ b/cmd/lotus-sim/simulation/node.go @@ -115,7 +115,7 @@ func (nd *Node) LoadSim(ctx context.Context, name string) (*Simulation, error) { // Create creates a new simulation. // // - This will fail if a simulation already exists with the given name. -// - Name must not contain a '/'. +// - Num must not contain a '/'. func (nd *Node) CreateSim(ctx context.Context, name string, head *types.TipSet) (*Simulation, error) { if strings.Contains(name, "/") { return nil, xerrors.Errorf("simulation name %q cannot contain a '/'", name) diff --git a/cmd/lotus-sim/simulation/stages/commit_queue.go b/cmd/lotus-sim/simulation/stages/commit_queue.go index ec12c27769a..60cbfa4badf 100644 --- a/cmd/lotus-sim/simulation/stages/commit_queue.go +++ b/cmd/lotus-sim/simulation/stages/commit_queue.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/actors/policy" ) diff --git a/cmd/lotus-sim/simulation/stages/commit_queue_test.go b/cmd/lotus-sim/simulation/stages/commit_queue_test.go index df0de975713..0b9a2ebdbc4 100644 --- a/cmd/lotus-sim/simulation/stages/commit_queue_test.go +++ b/cmd/lotus-sim/simulation/stages/commit_queue_test.go @@ -8,7 +8,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/actors/policy" ) diff --git a/cmd/lotus-sim/simulation/stages/interface.go b/cmd/lotus-sim/simulation/stages/interface.go index d58321d87d8..fffdbec6b54 100644 --- a/cmd/lotus-sim/simulation/stages/interface.go +++ b/cmd/lotus-sim/simulation/stages/interface.go @@ -5,7 +5,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/cmd/lotus-sim/simulation/blockbuilder" diff --git a/cmd/lotus-sim/simulation/stages/precommit_stage.go b/cmd/lotus-sim/simulation/stages/precommit_stage.go index fc61ff08b80..e5f455f74cd 100644 --- a/cmd/lotus-sim/simulation/stages/precommit_stage.go +++ b/cmd/lotus-sim/simulation/stages/precommit_stage.go @@ -11,7 +11,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/builtin" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" diff --git a/cmd/lotus-sim/simulation/stages/provecommit_stage.go b/cmd/lotus-sim/simulation/stages/provecommit_stage.go index efa14e4e8e6..d15ea60f0a9 100644 --- a/cmd/lotus-sim/simulation/stages/provecommit_stage.go +++ b/cmd/lotus-sim/simulation/stages/provecommit_stage.go @@ -8,7 +8,7 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" diff --git a/cmd/lotus-wallet/interactive.go b/cmd/lotus-wallet/interactive.go index 40c3f892231..9770961c028 100644 --- a/cmd/lotus-wallet/interactive.go +++ b/cmd/lotus-wallet/interactive.go @@ -103,7 +103,7 @@ func (c *InteractiveWallet) WalletSign(ctx context.Context, k address.Address, m return xerrors.Errorf("looking up dest actor: %w", err) } - fmt.Println("Method:", filcns.NewActorRegistry().Methods[toact.Code][cmsg.Method].Name) + fmt.Println("Method:", filcns.NewActorRegistry().Methods[toact.Code][cmsg.Method].Num) p, err := lcli.JsonParams(toact.Code, cmsg.Method, cmsg.Params) if err != nil { return err @@ -125,7 +125,7 @@ func (c *InteractiveWallet) WalletSign(ctx context.Context, k address.Address, m return xerrors.Errorf("looking up msig dest actor: %w", err) } - fmt.Println("\tMultiSig Proposal Method:", filcns.NewActorRegistry().Methods[toact.Code][mp.Method].Name) // todo use remote + fmt.Println("\tMultiSig Proposal Method:", filcns.NewActorRegistry().Methods[toact.Code][mp.Method].Num) // todo use remote p, err := lcli.JsonParams(toact.Code, mp.Method, mp.Params) if err != nil { return err diff --git a/cmd/tvx/extract_many.go b/cmd/tvx/extract_many.go index bc5ad2a3037..07bbc8df442 100644 --- a/cmd/tvx/extract_many.go +++ b/cmd/tvx/extract_many.go @@ -164,7 +164,7 @@ func runExtractMany(c *cli.Context) error { } else if methodnum >= len(m) { return fmt.Errorf("unrecognized method number for actor %s: %d", actorcode, methodnum) } else { - methodname = m[abi.MethodNum(methodnum)].Name + methodname = m[abi.MethodNum(methodnum)].Num } // exitcode string representations are of kind ErrType(0); strip out diff --git a/conformance/chaos/cbor_gen.go b/conformance/chaos/cbor_gen.go index 2deaaa53f57..436849cdc85 100644 --- a/conformance/chaos/cbor_gen.go +++ b/conformance/chaos/cbor_gen.go @@ -8,13 +8,12 @@ import ( "math" "sort" - cid "github.com/ipfs/go-cid" - cbg "github.com/whyrusleeping/cbor-gen" - xerrors "golang.org/x/xerrors" - address "github.com/filecoin-project/go-address" abi "github.com/filecoin-project/go-state-types/abi" exitcode "github.com/filecoin-project/go-state-types/exitcode" + cid "github.com/ipfs/go-cid" + cbg "github.com/whyrusleeping/cbor-gen" + xerrors "golang.org/x/xerrors" ) var _ = xerrors.Errorf diff --git a/conformance/driver.go b/conformance/driver.go index 0bb51800e55..2329fe336cf 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -11,13 +11,13 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/test-vectors/schema" "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" @@ -249,7 +249,7 @@ 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" { - av, _ := actors.VersionForNetwork(params.NetworkVersion) + av, _ := actorstypes.VersionForNetwork(params.NetworkVersion) invoker.Register(av, nil, chaos.Actor{}) } diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 88c4d414138..6c1beb8829f 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -71,7 +71,7 @@ OPTIONS: --create-worker-key create separate worker key (default: false) --worker value, -w value worker key to use (overrides --create-worker-key) --owner value, -o value owner key to use - --sector-size value specify sector size to use (default: "32GiB") + --sector-size value specify sector size to use (default: "2KiB") --pre-sealed-sectors value specify set of presealed sectors for starting as a genesis miner (accepts multiple inputs) --pre-sealed-metadata value specify the metadata file for the presealed sectors --nosync don't check full-node sync status (default: false) diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 15178d8e0e0..0a064be7696 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -2029,7 +2029,7 @@ USAGE: lotus state actor-cids [command options] [arguments...] OPTIONS: - --network-version value specify network version (default: 16) + --network-version value specify network version (default: 17) ``` diff --git a/gen/api/proxygen.go b/gen/api/proxygen.go index df39132ff4b..f756c0d0c18 100644 --- a/gen/api/proxygen.go +++ b/gen/api/proxygen.go @@ -140,14 +140,14 @@ func generate(path, pkg, outpkg, outfile string) error { ast.Walk(v, ap) type methodInfo struct { - Name string + Num string node ast.Node Tags map[string][]string NamedParams, ParamNames, Results, DefRes string } type strinfo struct { - Name string + Num string Methods map[string]*methodInfo Include []string } @@ -182,7 +182,7 @@ func generate(path, pkg, outpkg, outfile string) error { for ifname, methods := range v.Methods { if _, ok := m.Infos[ifname]; !ok { m.Infos[ifname] = &strinfo{ - Name: ifname, + Num: ifname, Methods: map[string]*methodInfo{}, Include: v.Include[ifname], } @@ -239,7 +239,7 @@ func generate(path, pkg, outpkg, outfile string) error { } info.Methods[mname] = &methodInfo{ - Name: mname, + Num: mname, node: node.node, Tags: map[string][]string{}, NamedParams: strings.Join(params, ", "), @@ -298,18 +298,18 @@ import ( var ErrNotSupported = xerrors.New("method not supported") {{range .Infos}} -type {{.Name}}Struct struct { +type {{.Num}}Struct struct { {{range .Include}} {{.}}Struct {{end}} Internal struct { {{range .Methods}} - {{.Name}} func({{.NamedParams}}) ({{.Results}}) `+"`"+`{{range .Tags}}{{index . 0}}:"{{index . 1}}"{{end}}`+"`"+` + {{.Num}} func({{.NamedParams}}) ({{.Results}}) `+"`"+`{{range .Tags}}{{index . 0}}:"{{index . 1}}"{{end}}`+"`"+` {{end}} } } -type {{.Name}}Stub struct { +type {{.Num}}Stub struct { {{range .Include}} {{.}}Stub {{end}} @@ -317,22 +317,22 @@ type {{.Name}}Stub struct { {{end}} {{range .Infos}} -{{$name := .Name}} +{{$name := .Num}} {{range .Methods}} -func (s *{{$name}}Struct) {{.Name}}({{.NamedParams}}) ({{.Results}}) { - if s.Internal.{{.Name}} == nil { +func (s *{{$name}}Struct) {{.Num}}({{.NamedParams}}) ({{.Results}}) { + if s.Internal.{{.Num}} == nil { return {{.DefRes}}ErrNotSupported } - return s.Internal.{{.Name}}({{.ParamNames}}) + return s.Internal.{{.Num}}({{.ParamNames}}) } -func (s *{{$name}}Stub) {{.Name}}({{.NamedParams}}) ({{.Results}}) { +func (s *{{$name}}Stub) {{.Num}}({{.NamedParams}}) ({{.Results}}) { return {{.DefRes}}ErrNotSupported } {{end}} {{end}} -{{range .Infos}}var _ {{.Name}} = new({{.Name}}Struct) +{{range .Infos}}var _ {{.Num}} = new({{.Num}}Struct) {{end}} `) diff --git a/gen/inlinegen-data.json b/gen/inlinegen-data.json index 8b8081ac457..e767f990a1a 100644 --- a/gen/inlinegen-data.json +++ b/gen/inlinegen-data.json @@ -1,7 +1,7 @@ { - "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8], - "latestActorsVersion": 8, + "actorVersions": [0, 2, 3, 4, 5, 6, 7, 8, 9], + "latestActorsVersion": 9, - "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], - "latestNetworkVersion": 16 + "networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], + "latestNetworkVersion": 17 } diff --git a/go.mod b/go.mod index 9b89fba0fe7..fb9e4c5893e 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/filecoin-project/go-legs v0.4.4 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.11 + github.com/filecoin-project/go-state-types v0.1.12-0.20220907205406-e8b028ad923f 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 @@ -187,6 +187,7 @@ require ( github.com/filecoin-project/go-amt-ipld/v2 v2.1.0 // indirect github.com/filecoin-project/go-amt-ipld/v3 v3.1.0 // indirect github.com/filecoin-project/go-amt-ipld/v4 v4.0.0 // indirect + github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 // indirect github.com/filecoin-project/go-ds-versioning v0.1.1 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index 79f7c73191a..3fd51d139a3 100644 --- a/go.sum +++ b/go.sum @@ -304,6 +304,8 @@ github.com/filecoin-project/go-cbor-util v0.0.1 h1:E1LYZYTtjfAQwCReho0VXvbu8t3CY github.com/filecoin-project/go-cbor-util v0.0.1/go.mod h1:pqTiPHobNkOVM5thSRsHYjyQfq7O5QSCMhvuu9JoDlg= github.com/filecoin-project/go-commp-utils v0.1.3 h1:rTxbkNXZU7FLgdkBk8RsQIEOuPONHykEoX3xGk41Fkw= github.com/filecoin-project/go-commp-utils v0.1.3/go.mod h1:3ENlD1pZySaUout0p9ANQrY3fDFoXdqyX04J+dWpK30= +github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 h1:4cITW0pwgvqLs86Q9bWQa34+jBfR1V687bDkmv2DgnA= +github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837/go.mod h1:e2YBjSblNVoBckkbv3PPqsq71q98oFkFqL7s1etViGo= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= github.com/filecoin-project/go-crypto v0.0.1 h1:AcvpSGGCgjaY8y1az6AMfKQWreF/pWO2JJGLl6gCq6o= github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= @@ -340,8 +342,9 @@ github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go 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.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= -github.com/filecoin-project/go-state-types v0.1.11 h1:QzKUILRGa9gjJKPCiFlvCfcDGK2IqtJ6CpRQULvZZpA= -github.com/filecoin-project/go-state-types v0.1.11/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= +github.com/filecoin-project/go-state-types v0.1.12-0.20220907205406-e8b028ad923f h1:khCYaU4ieUwhWiRncmGBBI21wXhVF1xaGSgw7Pwcvmw= +github.com/filecoin-project/go-state-types v0.1.12-0.20220907205406-e8b028ad923f/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= 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= diff --git a/itests/kit/ensemble_opts_nv.go b/itests/kit/ensemble_opts_nv.go index b51b82bd546..64bed559b3d 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.Version15, + Network: network.Version16, Height: -1, }, stmgr.Upgrade{ - Network: network.Version16, + Network: network.Version17, Height: upgradeHeight, - Migration: filcns.UpgradeActorsV8, + Migration: filcns.UpgradeActorsV9, }) /* inline-gen end */ } diff --git a/itests/lite_migration_test.go b/itests/lite_migration_test.go index 972f2df70d1..704380da3cd 100644 --- a/itests/lite_migration_test.go +++ b/itests/lite_migration_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/filecoin-project/go-address" + actorstypes "github.com/filecoin-project/go-state-types/actors" system8 "github.com/filecoin-project/go-state-types/builtin/v8/system" "github.com/filecoin-project/go-state-types/manifest" "github.com/filecoin-project/go-state-types/network" @@ -18,7 +19,6 @@ import ( "github.com/filecoin-project/specs-actors/v8/actors/util/adt" "github.com/filecoin-project/lotus/blockstore" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin/system" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/state" @@ -59,7 +59,7 @@ func TestLiteMigration(t *testing.T) { // populate the entries field of the manifest require.NoError(t, newManifest.Load(ctx, ctxStore), "error loading new manifest") - newStateRoot, err := filcns.LiteMigration(ctx, bs, newManifestCid, stateRoot, actors.Version8, types.StateTreeVersion4, types.StateTreeVersion4) + newStateRoot, err := filcns.LiteMigration(ctx, bs, newManifestCid, stateRoot, actorstypes.Version8, types.StateTreeVersion4, types.StateTreeVersion4) require.NoError(t, err) newStateTree, err := state.LoadStateTree(ctxStore, newStateRoot) diff --git a/journal/mockjournal/journal.go b/journal/mockjournal/journal.go index 842c252bd76..3668923e5be 100644 --- a/journal/mockjournal/journal.go +++ b/journal/mockjournal/journal.go @@ -7,9 +7,8 @@ package mockjournal import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - journal "github.com/filecoin-project/lotus/journal" + gomock "github.com/golang/mock/gomock" ) // MockJournal is a mock of Journal interface. diff --git a/lib/retry/retry.go b/lib/retry/retry.go index 0b53c0fa368..88307a8001b 100644 --- a/lib/retry/retry.go +++ b/lib/retry/retry.go @@ -2,10 +2,9 @@ package retry import ( "errors" + logging "github.com/ipfs/go-log/v2" "reflect" "time" - - logging "github.com/ipfs/go-log/v2" ) var log = logging.Logger("retry") diff --git a/lotuspond/front/src/chain/methodgen.go b/lotuspond/front/src/chain/methodgen.go index da174bfaafc..5fd6cde9310 100644 --- a/lotuspond/front/src/chain/methodgen.go +++ b/lotuspond/front/src/chain/methodgen.go @@ -54,7 +54,7 @@ func main() { if !ok { continue } - out[name] = append(out[name], m.Name) + out[name] = append(out[name], m.Num) remaining-- } } diff --git a/markets/dagstore/mocks/mock_lotus_accessor.go b/markets/dagstore/mocks/mock_lotus_accessor.go index 3910512cf2e..19923cc2ae6 100644 --- a/markets/dagstore/mocks/mock_lotus_accessor.go +++ b/markets/dagstore/mocks/mock_lotus_accessor.go @@ -8,10 +8,9 @@ import ( context "context" reflect "reflect" + mount "github.com/filecoin-project/dagstore/mount" gomock "github.com/golang/mock/gomock" cid "github.com/ipfs/go-cid" - - mount "github.com/filecoin-project/dagstore/mount" ) // MockMinerAPI is a mock of MinerAPI interface. diff --git a/markets/storageadapter/ondealsectorcommitted_test.go b/markets/storageadapter/ondealsectorcommitted_test.go index 624cf84aede..5cb5230b449 100644 --- a/markets/storageadapter/ondealsectorcommitted_test.go +++ b/markets/storageadapter/ondealsectorcommitted_test.go @@ -19,7 +19,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "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" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/cbor" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" diff --git a/node/bundle/bundle.go b/node/bundle/bundle.go index cb97838f5c3..abdb34e6960 100644 --- a/node/bundle/bundle.go +++ b/node/bundle/bundle.go @@ -10,6 +10,8 @@ import ( "github.com/ipld/go-car" "golang.org/x/xerrors" + actorstypes "github.com/filecoin-project/go-state-types/actors" + "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" @@ -39,10 +41,10 @@ func LoadBundle(ctx context.Context, bs blockstore.Blockstore, r io.Reader) (cid // LoadBundles loads the bundles for the specified actor versions into the passed blockstore, if and // only if the bundle's manifest is not already present in the blockstore. -func LoadBundles(ctx context.Context, bs blockstore.Blockstore, versions ...actors.Version) error { +func LoadBundles(ctx context.Context, bs blockstore.Blockstore, versions ...actorstypes.Version) error { for _, av := range versions { // No bundles before version 8. - if av < actors.Version8 { + if av < actorstypes.Version8 { continue } diff --git a/node/config/cfgdocgen/gen.go b/node/config/cfgdocgen/gen.go index 5133501523c..d14b1aecfdb 100644 --- a/node/config/cfgdocgen/gen.go +++ b/node/config/cfgdocgen/gen.go @@ -94,7 +94,7 @@ func run() error { package config type DocField struct { - Name string + Num string Type string Comment string } @@ -109,7 +109,7 @@ var Doc = map[string][]DocField{ for _, f := range typ { fmt.Println("\t\t{") - fmt.Printf("\t\t\tName: \"%s\",\n", f.Name) + fmt.Printf("\t\t\tNum: \"%s\",\n", f.Name) fmt.Printf("\t\t\tType: \"%s\",\n\n", f.Type) fmt.Printf("\t\t\tComment: `%s`,\n", f.Comment) fmt.Println("\t\t},") diff --git a/node/hello/cbor_gen.go b/node/hello/cbor_gen.go index 81a1774c17e..68c82e2bbee 100644 --- a/node/hello/cbor_gen.go +++ b/node/hello/cbor_gen.go @@ -8,11 +8,10 @@ import ( "math" "sort" + abi "github.com/filecoin-project/go-state-types/abi" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" - - abi "github.com/filecoin-project/go-state-types/abi" ) var _ = xerrors.Errorf diff --git a/node/impl/full/multisig.go b/node/impl/full/multisig.go index 8438f74193a..886d66d5e4a 100644 --- a/node/impl/full/multisig.go +++ b/node/impl/full/multisig.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig" @@ -29,7 +30,7 @@ func (a *MsigAPI) messageBuilder(ctx context.Context, from address.Address) (mul if err != nil { return nil, err } - av, err := actors.VersionForNetwork(nver) + av, err := actorstypes.VersionForNetwork(nver) if err != nil { return nil, err } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 08800ba108c..97308dcc98a 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -16,8 +16,9 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" @@ -1536,7 +1537,7 @@ func (m *StateModule) StateNetworkVersion(ctx context.Context, tsk types.TipSetK } func (a *StateAPI) StateActorCodeCIDs(ctx context.Context, nv network.Version) (map[string]cid.Cid, error) { - actorVersion, err := actors.VersionForNetwork(nv) + actorVersion, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, xerrors.Errorf("invalid network version %d: %w", nv, err) } @@ -1550,7 +1551,7 @@ func (a *StateAPI) StateActorCodeCIDs(ctx context.Context, nv network.Version) ( } func (a *StateAPI) StateActorManifestCID(ctx context.Context, nv network.Version) (cid.Cid, error) { - actorVersion, err := actors.VersionForNetwork(nv) + actorVersion, err := actorstypes.VersionForNetwork(nv) if err != nil { return cid.Undef, xerrors.Errorf("invalid network version") } diff --git a/node/impl/storminer.go b/node/impl/storminer.go index bab72d63107..a4ff2dd595d 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -35,7 +35,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" builtintypes "github.com/filecoin-project/go-state-types/builtin" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" diff --git a/paychmgr/cbor_gen.go b/paychmgr/cbor_gen.go index 78a55488ea2..450d526d858 100644 --- a/paychmgr/cbor_gen.go +++ b/paychmgr/cbor_gen.go @@ -8,12 +8,11 @@ import ( "math" "sort" + address "github.com/filecoin-project/go-address" + 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" - - address "github.com/filecoin-project/go-address" - paych "github.com/filecoin-project/go-state-types/builtin/v8/paych" ) var _ = xerrors.Errorf diff --git a/paychmgr/paych.go b/paychmgr/paych.go index 45703a6c8e1..c683aaadde5 100644 --- a/paychmgr/paych.go +++ b/paychmgr/paych.go @@ -9,11 +9,11 @@ import ( "github.com/filecoin-project/go-address" cborutil "github.com/filecoin-project/go-cbor-util" + actorstypes "github.com/filecoin-project/go-state-types/actors" "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" lpaych "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/sigs" @@ -89,7 +89,7 @@ func (ca *channelAccessor) messageBuilder(ctx context.Context, from address.Addr return nil, err } - av, err := actors.VersionForNetwork(nwVersion) + av, err := actorstypes.VersionForNetwork(nwVersion) if err != nil { return nil, err } diff --git a/storage/paths/mocks/index.go b/storage/paths/mocks/index.go index 6fdcb03b9ec..fa2c8c8301b 100644 --- a/storage/paths/mocks/index.go +++ b/storage/paths/mocks/index.go @@ -8,12 +8,10 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - abi "github.com/filecoin-project/go-state-types/abi" - fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" + gomock "github.com/golang/mock/gomock" ) // MockSectorIndex is a mock of SectorIndex interface. diff --git a/storage/paths/mocks/pf.go b/storage/paths/mocks/pf.go index 50b020aaa8f..7c4836a68c7 100644 --- a/storage/paths/mocks/pf.go +++ b/storage/paths/mocks/pf.go @@ -8,12 +8,10 @@ import ( os "os" reflect "reflect" - gomock "github.com/golang/mock/gomock" - abi "github.com/filecoin-project/go-state-types/abi" - partialfile "github.com/filecoin-project/lotus/storage/sealer/partialfile" storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" + gomock "github.com/golang/mock/gomock" ) // MockPartialFileHandler is a mock of PartialFileHandler interface. diff --git a/storage/paths/mocks/store.go b/storage/paths/mocks/store.go index 72be4832378..16deda2e503 100644 --- a/storage/paths/mocks/store.go +++ b/storage/paths/mocks/store.go @@ -8,12 +8,10 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - abi "github.com/filecoin-project/go-state-types/abi" - fsutil "github.com/filecoin-project/lotus/storage/sealer/fsutil" storiface "github.com/filecoin-project/lotus/storage/sealer/storiface" + gomock "github.com/golang/mock/gomock" ) // MockStore is a mock of Store interface. diff --git a/storage/pipeline/cbor_gen.go b/storage/pipeline/cbor_gen.go index 2fb8c445c84..c330392f7cc 100644 --- a/storage/pipeline/cbor_gen.go +++ b/storage/pipeline/cbor_gen.go @@ -8,14 +8,12 @@ import ( "math" "sort" + abi "github.com/filecoin-project/go-state-types/abi" + miner "github.com/filecoin-project/go-state-types/builtin/v9/miner" + api "github.com/filecoin-project/lotus/api" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" - - 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" ) var _ = xerrors.Errorf diff --git a/storage/pipeline/commit_batch.go b/storage/pipeline/commit_batch.go index 2011ad92ec9..b5651c5fb83 100644 --- a/storage/pipeline/commit_batch.go +++ b/storage/pipeline/commit_batch.go @@ -13,15 +13,15 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "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/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/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/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/config" @@ -583,7 +583,7 @@ func (b *CommitBatcher) getCommitCutoff(si SectorInfo) (time.Time, error) { if pci == nil { return time.Now(), xerrors.Errorf("precommit info not found") } - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { log.Errorf("unsupported network vrsion: %s", err) return time.Now(), err diff --git a/storage/pipeline/commit_batch_test.go b/storage/pipeline/commit_batch_test.go index cece591d3a3..a8948edcf76 100644 --- a/storage/pipeline/commit_batch_test.go +++ b/storage/pipeline/commit_batch_test.go @@ -16,7 +16,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" prooftypes "github.com/filecoin-project/go-state-types/proof" diff --git a/storage/pipeline/fsm_events.go b/storage/pipeline/fsm_events.go index eb108715101..8ddd529a616 100644 --- a/storage/pipeline/fsm_events.go +++ b/storage/pipeline/fsm_events.go @@ -8,7 +8,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/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/storage/sealer/storiface" diff --git a/storage/pipeline/mocks/api.go b/storage/pipeline/mocks/api.go index 4e0813194f5..015e69c1555 100644 --- a/storage/pipeline/mocks/api.go +++ b/storage/pipeline/mocks/api.go @@ -8,21 +8,19 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - cid "github.com/ipfs/go-cid" - address "github.com/filecoin-project/go-address" 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" - miner "github.com/filecoin-project/go-state-types/builtin/v8/miner" + miner "github.com/filecoin-project/go-state-types/builtin/v9/miner" crypto "github.com/filecoin-project/go-state-types/crypto" dline "github.com/filecoin-project/go-state-types/dline" network "github.com/filecoin-project/go-state-types/network" - api "github.com/filecoin-project/lotus/api" miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" types "github.com/filecoin-project/lotus/chain/types" + gomock "github.com/golang/mock/gomock" + cid "github.com/ipfs/go-cid" ) // MockSealingAPI is a mock of SealingAPI interface. diff --git a/storage/pipeline/mocks/mock_commit_batcher.go b/storage/pipeline/mocks/mock_commit_batcher.go index d61fde91228..71c973b2abd 100644 --- a/storage/pipeline/mocks/mock_commit_batcher.go +++ b/storage/pipeline/mocks/mock_commit_batcher.go @@ -8,16 +8,14 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - 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" + miner "github.com/filecoin-project/go-state-types/builtin/v9/miner" network "github.com/filecoin-project/go-state-types/network" - api "github.com/filecoin-project/lotus/api" types "github.com/filecoin-project/lotus/chain/types" + gomock "github.com/golang/mock/gomock" ) // MockCommitBatcherApi is a mock of CommitBatcherApi interface. diff --git a/storage/pipeline/mocks/mock_precommit_batcher.go b/storage/pipeline/mocks/mock_precommit_batcher.go index 2f65e3e034e..e8435276d75 100644 --- a/storage/pipeline/mocks/mock_precommit_batcher.go +++ b/storage/pipeline/mocks/mock_precommit_batcher.go @@ -8,14 +8,12 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" - address "github.com/filecoin-project/go-address" big "github.com/filecoin-project/go-state-types/big" network "github.com/filecoin-project/go-state-types/network" - api "github.com/filecoin-project/lotus/api" types "github.com/filecoin-project/lotus/chain/types" + gomock "github.com/golang/mock/gomock" ) // MockPreCommitBatcherApi is a mock of PreCommitBatcherApi interface. diff --git a/storage/pipeline/precommit_batch.go b/storage/pipeline/precommit_batch.go index d0de68daaff..7f7ea806986 100644 --- a/storage/pipeline/precommit_batch.go +++ b/storage/pipeline/precommit_batch.go @@ -14,7 +14,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/builtin" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/lotus/api" @@ -328,7 +328,14 @@ func (b *PreCommitBatcher) processBatch(cfg sealiface.Config, tsk types.TipSetKe } res.Sectors = append(res.Sectors, p.pci.SectorNumber) - params.Sectors = append(params.Sectors, *p.pci) + params.Sectors = append(params.Sectors, miner.PreCommitSectorParams{ + SealProof: p.pci.SealProof, + SectorNumber: p.pci.SectorNumber, + SealedCID: p.pci.SealedCID, + SealRandEpoch: p.pci.SealRandEpoch, + DealIDs: p.pci.DealIDs, + Expiration: p.pci.Expiration, + }) deposit = big.Add(deposit, p.deposit) } diff --git a/storage/pipeline/precommit_batch_test.go b/storage/pipeline/precommit_batch_test.go index 735474f072a..1779128bd62 100644 --- a/storage/pipeline/precommit_batch_test.go +++ b/storage/pipeline/precommit_batch_test.go @@ -15,7 +15,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/network" miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner" diff --git a/storage/pipeline/sealing.go b/storage/pipeline/sealing.go index 8a1540d34f8..153a4cc3216 100644 --- a/storage/pipeline/sealing.go +++ b/storage/pipeline/sealing.go @@ -15,7 +15,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/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" diff --git a/storage/pipeline/states_failed.go b/storage/pipeline/states_failed.go index c57bef61b38..38f030333e3 100644 --- a/storage/pipeline/states_failed.go +++ b/storage/pipeline/states_failed.go @@ -10,7 +10,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-commp-utils/zerocomm" "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/v9/miner" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-statemachine" diff --git a/storage/pipeline/states_replica_update.go b/storage/pipeline/states_replica_update.go index 3392b92e700..ae90d253586 100644 --- a/storage/pipeline/states_replica_update.go +++ b/storage/pipeline/states_replica_update.go @@ -10,7 +10,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/builtin" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-statemachine" diff --git a/storage/pipeline/states_sealing.go b/storage/pipeline/states_sealing.go index 5ec8f077f66..96e1f5a7e48 100644 --- a/storage/pipeline/states_sealing.go +++ b/storage/pipeline/states_sealing.go @@ -9,9 +9,10 @@ import ( "github.com/filecoin-project/go-commp-utils/zerocomm" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "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/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/network" @@ -20,7 +21,6 @@ import ( "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/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/storage/pipeline/lib/nullreader" @@ -153,7 +153,7 @@ func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.Se return nil, 0, allocated, xerrors.Errorf("getTicket: StateNetworkVersion: api error, not proceeding: %+v", err) } - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, 0, allocated, xerrors.Errorf("getTicket: actor version for network error, not proceeding: %w", err) } @@ -240,7 +240,7 @@ func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo) return nil } - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { log.Errorf("handlePreCommit1: VersionForNetwork error, not proceeding: %w", err) return nil @@ -327,7 +327,7 @@ func (m *Sealing) preCommitParams(ctx statemachine.Context, sector SectorInfo) ( return nil, big.Zero(), types.EmptyTSK, ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("failed to get network version: %w", err)}) } - av, err := actors.VersionForNetwork(nv) + av, err := actorstypes.VersionForNetwork(nv) if err != nil { return nil, big.Zero(), types.EmptyTSK, ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("failed to get actors version: %w", err)}) } diff --git a/storage/pipeline/types.go b/storage/pipeline/types.go index 5889588bd86..0419aabc250 100644 --- a/storage/pipeline/types.go +++ b/storage/pipeline/types.go @@ -7,7 +7,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/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" diff --git a/storage/sealer/cbor_gen.go b/storage/sealer/cbor_gen.go index 48bf0146a45..6db7d96a4ec 100644 --- a/storage/sealer/cbor_gen.go +++ b/storage/sealer/cbor_gen.go @@ -8,11 +8,10 @@ import ( "math" "sort" + sealtasks "github.com/filecoin-project/lotus/storage/sealer/sealtasks" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" - - sealtasks "github.com/filecoin-project/lotus/storage/sealer/sealtasks" ) var _ = xerrors.Errorf diff --git a/storage/wdpost/wdpost_changehandler.go b/storage/wdpost/wdpost_changehandler.go index 5778aaf9dbc..266b8b0421a 100644 --- a/storage/wdpost/wdpost_changehandler.go +++ b/storage/wdpost/wdpost_changehandler.go @@ -6,7 +6,7 @@ import ( "github.com/filecoin-project/go-address" "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/v9/miner" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/chain/types" diff --git a/storage/wdpost/wdpost_changehandler_test.go b/storage/wdpost/wdpost_changehandler_test.go index 3e7ca3f4996..dac6c455847 100644 --- a/storage/wdpost/wdpost_changehandler_test.go +++ b/storage/wdpost/wdpost_changehandler_test.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" tutils "github.com/filecoin-project/specs-actors/support/testing" diff --git a/storage/wdpost/wdpost_journal.go b/storage/wdpost/wdpost_journal.go index b4c790eb0c2..406628f681b 100644 --- a/storage/wdpost/wdpost_journal.go +++ b/storage/wdpost/wdpost_journal.go @@ -4,7 +4,7 @@ import ( "github.com/ipfs/go-cid" "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/v9/miner" "github.com/filecoin-project/go-state-types/dline" ) diff --git a/storage/wdpost/wdpost_run.go b/storage/wdpost/wdpost_run.go index 0e715f10162..b1527a508a3 100644 --- a/storage/wdpost/wdpost_run.go +++ b/storage/wdpost/wdpost_run.go @@ -14,7 +14,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/builtin" - "github.com/filecoin-project/go-state-types/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" diff --git a/storage/wdpost/wdpost_run_faults.go b/storage/wdpost/wdpost_run_faults.go index 0b7a3323852..9153ce9a685 100644 --- a/storage/wdpost/wdpost_run_faults.go +++ b/storage/wdpost/wdpost_run_faults.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/go-bitfield" "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/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/api" diff --git a/storage/wdpost/wdpost_run_test.go b/storage/wdpost/wdpost_run_test.go index 466fd6905d3..cb110cc0d05 100644 --- a/storage/wdpost/wdpost_run_test.go +++ b/storage/wdpost/wdpost_run_test.go @@ -13,9 +13,10 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner" + minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network" @@ -500,7 +501,7 @@ func (m *mockStorageMinerAPI) StateMinerProvingDeadline(ctx context.Context, add } func (m *mockStorageMinerAPI) StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error) { - code, ok := actors.GetActorCodeID(actors.Version7, actors.MinerKey) + code, ok := actors.GetActorCodeID(actorstypes.Version7, actors.MinerKey) if !ok { return nil, xerrors.Errorf("failed to get miner actor code ID for actors version %d", actors.Version7) } diff --git a/storage/wdpost/wdpost_sched.go b/storage/wdpost/wdpost_sched.go index 2739bc3868e..5bfc041d204 100644 --- a/storage/wdpost/wdpost_sched.go +++ b/storage/wdpost/wdpost_sched.go @@ -12,7 +12,7 @@ import ( "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/builtin/v8/miner" + "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/network"