Merge pull request #8915 from filecoin-project/v16

build: release: v1.16.0
This commit is contained in:
Jiaying Wang 2022-06-24 16:49:19 -04:00 committed by GitHub
commit 01254ab320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
351 changed files with 9809 additions and 4424 deletions

View File

@ -83,7 +83,6 @@ commands:
name: fetch all tags
command: |
git fetch --all
packer_build:
description: "Run a packer build"
parameters:
@ -197,6 +196,7 @@ jobs:
environment:
TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >>
SKIP_CONFORMANCE: "1"
LOTUS_SRC_DIR: /home/circleci/project
command: |
mkdir -p /tmp/test-reports/<< parameters.suite >>
mkdir -p /tmp/test-artifacts
@ -223,7 +223,7 @@ jobs:
test-conformance:
description: |
Run tests using a corpus of interoperable test vectors for Filecoin
Run tests using a corpus of interoperable test vectors for Filecoin
implementations to test their correctness and compliance with the Filecoin
specifications.
parameters:
@ -803,6 +803,11 @@ workflows:
suite: itest-deals_concurrent
target: "./itests/deals_concurrent_test.go"
- test:
name: test-itest-deals_invalid_utf8_label
suite: itest-deals_invalid_utf8_label
target: "./itests/deals_invalid_utf8_label_test.go"
- test:
name: test-itest-deals_max_staging_deals
suite: itest-deals_max_staging_deals
@ -863,6 +868,11 @@ workflows:
suite: itest-get_messages_in_ts
target: "./itests/get_messages_in_ts_test.go"
- test:
name: test-itest-lite_migration
suite: itest-lite_migration
target: "./itests/lite_migration_test.go"
- test:
name: test-itest-lookup_robust_address
suite: itest-lookup_robust_address

View File

@ -83,7 +83,6 @@ commands:
name: fetch all tags
command: |
git fetch --all
packer_build:
description: "Run a packer build"
parameters:
@ -197,6 +196,7 @@ jobs:
environment:
TEST_RUSTPROOFS_LOGS: << parameters.proofs-log-test >>
SKIP_CONFORMANCE: "1"
LOTUS_SRC_DIR: /home/circleci/project
command: |
mkdir -p /tmp/test-reports/<< parameters.suite >>
mkdir -p /tmp/test-artifacts
@ -223,7 +223,7 @@ jobs:
test-conformance:
description: |
Run tests using a corpus of interoperable test vectors for Filecoin
Run tests using a corpus of interoperable test vectors for Filecoin
implementations to test their correctness and compliance with the Filecoin
specifications.
parameters:

4
.gitignore vendored
View File

@ -41,7 +41,6 @@ build/paramfetch.sh
/darwin
/linux
*.snap
build/builtin-actors
*-fuzz.zip
/chain/types/work_msg/
@ -49,3 +48,6 @@ bin/ipget
bin/tmp/*
.idea
scratchpad
build/builtin-actors/v*
build/builtin-actors/*.car

View File

@ -1,5 +1,113 @@
# Lotus changelog
# 1.16.0 / 2022-06-24
This is a MANDATORY release of Lotus that introduces [Filecoin network v16,
codenamed the Skyr upgrade](https://github.com/filecoin-project/community/discussions/74?sort=new#discussioncomment-2392151).
The network is scheduled to upgrade to nv16 at epoch 1960320, on July 6th at 2022-07-06T14:00:00Z. All node operators, including storage providers, must upgrade to this release (or a later release) before that time. Storage providers must update their daemons, miners, market and worker(s).
Your lotus node will switch from the Legacy VM (that depended on go-based specs-actors) to Filecoin Virtual Machine FVM (that uses Rust-based builtin-actors) atomically upon the upgrade.
The Skyr upgrade introduces the following FIPs, enhancements and bug fixes, delivered in [built-actors v8](https://github.com/filecoin-project/builtin-actors/releases/tag/v8.0.0) and [ref-fvm v1.0.0](https://github.com/filecoin-project/ref-fvm/releases/tag/fvm%40v1.0.0):,
- [FIP-0030](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0030.md)
- [FIP-0031](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0031.md)
- [FIP-0032](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0032.md))
- [FIP-0027](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0027.md)
- [Bug fix for the ProveReplicaUpdates method](https://github.com/filecoin-project/builtin-actors/pull/138)
- [New proofs version for SnarkPack](https://github.com/filecoin-project/builtin-actors/pull/474/commits/3027c365f516e1cba6f156d4fb9dbd8c893d5b62)
## 🆕 Things you may wanna know
### Actor Code CIDs
As stated in [FIP-0031](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0031.md)- [structure of the code cid](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0031.md#structure-of-code-cids), system actors' code CIDs will be real content-addressing
For lotus users, we are making the change minimal for you. This means the `CODE` output when you run `lotus state get-actor` will now be the actual CID that represents the executable code for the actor, followed by wrapped synthetic id like the ones you've got before, i.e `fil/8/system`.
Moreover, this also means that in the future, whenever the actor code changes, the CID changes accordingly, and a network upgrade is needed for the network participants to have consensus over what executable code we should use for each system actor.
### Built-in actor bundles
As the network introduces FVM, it's also switching from spec-actor (written in GoLang) to [built-in actor](https://github.com/filecoin-project/builtin-actors) (written in rust), in which the latter comes with[ importable bundles](https://github.com/filecoin-project/builtin-actors#importable-bundle). This means, like filecoin proof parameters, node operators now also need to fetch the actor bundles according to the network versions for the nodes to remain operational.
Bundles for all networks(mainnet, calibnet, and etc) are included in the lotus source tree (`build/actors/`) and embedded on build. Lotus verifies that the bundle CIDs are the right ones upon build & upgrade against the values in `build/builtin_actors_gen.go`, according to the network you are building. You may also check the bundle manifest CID matches the bundle gen-ed values by running `lotus state actor-cids --network-version 16`.
The manifest CID & full list of actor code CIDs for nv16 using v8.0.0 is:
```
"_manifest": "bafy2bzacebogjbpiemi7npzxchgcjjki3tfxon4ims55obfyfleqntteljsea"
"account": "bafk2bzacedudbf7fc5va57t3tmo63snmt3en4iaidv4vo3qlyacbxaa6hlx6y"
"cron": "bafk2bzacecqb3eolfurehny6yp7tgmapib4ocazo5ilkopjce2c7wc2bcec62"
"init": "bafk2bzaceaipvjhoxmtofsnv3aj6gj5ida4afdrxa4ewku2hfipdlxpaektlw"
"multisig": "bafk2bzacebhldfjuy4o5v7amrhp5p2gzv2qo5275jut4adnbyp56fxkwy5fag"
"paymentchannel": "bafk2bzacebalad3f72wyk7qyilvfjijcwubdspytnyzlrhvn73254gqis44rq"
"reward": "bafk2bzacecwzzxlgjiavnc3545cqqil3cmq4hgpvfp2crguxy2pl5ybusfsbe"
"storagemarket": "bafk2bzacediohrxkp2fbsl4yj4jlupjdkgsiwqb4zuezvinhdo2j5hrxco62q"
"storageminer": "bafk2bzacecgnynvd3tene3bvqoknuspit56canij5bpra6wl4mrq2mxxwriyu"
"storagepower": "bafk2bzacebjvqva6ppvysn5xpmiqcdfelwbbcxmghx5ww6hr37cgred6dyrpm"
"system": "bafk2bzacedwq5uppsw7vp55zpj7jdieizirmldceehu6wvombw3ixq2tcq57w"
"verifiedregistry": "bafk2bzaceb3zbkjz3auizmoln2unmxep7dyfcmsre64vnqfhdyh7rkqfoxlw4"
```
All bundles are also available at https://github.com/filecoin-project/builtin-actors/releases, thus you can also manually download the bundles and place them in the right path.
Note: use customized bundle will risk you to lose sync with the network!
To get Code CIDs:
- api:`StateActorCodeCIDs`
- cli: `lotus state actor-cids`
- cli: `lotus-shed cid inspect-bundle`
### Execution Trace
For developers that are dependent on lotus execution trace, you will need to enable `LOTUS_VM_ENABLE_TRACING` envvar to get the exact execution trace response as before. Without the envvar enabled, `Subcall` details, Duration` and `GasCharges` fields will be missing from the new FVM trace.
### Deal Proposal Migration
All deal proposals with non-utf8 string as the label in the metadata store will perform a light migration to new format as defined in [v1.1.1](https://github.com/filecoin-project/go-fil-markets/pull/721).
## Others
- Resource manager is now only enabled by default on full daemon node. You can enable it manually for other nodes by setting env var `LOTUS_RCMGR` to `1`.
- Fix: drand: calculation of round from Filecoin epochs ([filecoin-project/lotus#8606](https://github.com/filecoin-project/lotus/pull/8606))
## Dependency Update
- chore: deps: update to go-libp2p v0.19.4 ([filecoin-project/lotus#8801](https://github.com/filecoin-project/lotus/pull/8801))
- github.com/filecoin-project/go-fil-markets (v1.20.1 -> v1.20.1-v16-2):
- github.com/filecoin-project/go-legs (v0.3.7 -> v0.3.10):
- github.com/filecoin-project/go-state-types (v0.1.8 -> v0.1.10):
- github.com/filecoin-project/specs-storage (v0.2.4 -> v0.4.1):
## Contributors
| Contributor | Commits | Lines ± | Files Changed |
|-------------|---------|---------|---------------|
| @geoff-vball | 37 | +10565/-8454 | 150 |
| @arajasek | 33 | +7964/-6340 | 473 |
| @arajasek | 37 | +6220/-6976 | 457 |
| @vyzo | 135 | +7287/-5380 | 546 |
| @ZenGround0 | 19 | +5958/-2920 | 226 |
| @stebalien | 18 | +1566/-1101 | 116 |
| Alex | 5 | +323/-2304 | 32 |
| @zenground0 | 9 | +583/-358 | 56 |
| @jennijuju | 5 | +853/-27 | 19 |
| @jennijuju | 24 | +392/-201 | 60 |
| Marco Munizaga | 3 | +236/-83 | 5 |
| @raulk| 9 | +93/-15 | 15 |
| @travisperson | 3 | +37/-37 | 12 |
| @Kubuxu | 1 | +41/-5 | 1 |
| @koalacxr | 1 | +29/-13 | 3 |
| @gammazero | 2 | +18/-10 | 4 |
| Peter Rabbitson | 1 | +5/-3 | 1 |
| Steve Loeppky | 1 | +6/-0 | 1 |
| @masih | 1 | +3/-3 | 2 |
| @magik6k | 1 | +4/-0 | 1 |
| @jennijuju | 1 | +2/-2 | 1 |
| tian zhou | 1 | +1/-1 | 1 |
# 1.15.3 / 2022-05-31
This is an optional release of lotus that include new APIs, some improvements and bug fixes.
@ -75,7 +183,7 @@ This is an optional release of lotus that include new APIs, some improvements an
# 1.15.2 / 2022-05-06
This is a highly recommended feature lotus release v1.15.2. This feature release introduces many new features and for SPs, including PoSt workers, sealing scheduler, snap deal queue and so on.
This is a highly recommended feature lotus release v1.15.2. This feature release introduces many new features and for SPs, including PoSt workers, sealing scheduler, snap deal queue and so on.
Note: You need to be using go v1.17.9&up from this release onwards.
@ -233,31 +341,31 @@ This feature release introduces Index Provider, GraphSync v2, and many other lat
### 🔥🔥🔥 FVM (Experimental) 🔥🔥🔥
- feat: fvm: FVM integration ([filecoin-project/lotus#8332](https://github.com/filecoin-project/lotus/pull/8332))
The lotus team is excited to announce the launch of experimental non-programmable FVM on mainnet. By enabling `"LOTUS_USE_FVM_EXPERIMENTAL=1` envvar, the lotus daemon will be running the [WASM-compiled built-in actors](https://github.com/filecoin-project/builtin-actors) that is compatible with the existing chain(Network v15 OhSnap). If you are trying it out and having any questions or feedbacks, please leave a comment [here](https://github.com/filecoin-project/lotus/discussions/8334)!
The lotus team is excited to announce the launch of experimental non-programmable FVM on mainnet. By enabling `"LOTUS_USE_FVM_EXPERIMENTAL=1` envvar, the lotus daemon will be running the [WASM-compiled built-in actors](https://github.com/filecoin-project/builtin-actors) that is compatible with the existing chain(Network v15 OhSnap). If you are trying it out and having any questions or feedbacks, please leave a comment [here](https://github.com/filecoin-project/lotus/discussions/8334)!
- chore: FVM: log when fvm is used([filecoin-project/lotus#8363](https://github.com/filecoin-project/lotus/pull/8363))
- chore: ffi: the latest fvm release([filecoin-project/lotus#8382](https://github.com/filecoin-project/lotus/pull/8382))
### 🌟🌟🌟 Index Provider (Production Ready!) 🌟🌟🌟
- feat: markets: Integrate index ingest protocol and retrieve by any CID ([filecoin-project/lotus#7313](https://github.com/filecoin-project/lotus/pull/7313))
More and more useful data is being stored on Filecoin via deals made by clients to Storage Providers. The goal is that this content is discoverable when people need them. To achieve that goal, one of the projects [the Bedrock team](https://www.notion.so/pl-strflt/Bedrock-2e956d5d8143432080a1d84435ccf0ff) is working on is building an Indexer Ecosystem, a project that's focus on content addressing on Filecoin, then potentially have interoperability with IPFS in the future and eventually serve the retrieval market. The Indexer Ecosystem high level architecture overview diagram can be found [here](https://github.com/filecoin-project/storetheindex/blob/main/doc/indexer_ecosys.png) and a detailed write up about can be found [here](https://www.notion.so/pl-strflt/Introducing-Indexer-to-SP-90bf296794174a8281c121d4ce6747a0).
More and more useful data is being stored on Filecoin via deals made by clients to Storage Providers. The goal is that this content is discoverable when people need them. To achieve that goal, one of the projects [the Bedrock team](https://www.notion.so/pl-strflt/Bedrock-2e956d5d8143432080a1d84435ccf0ff) is working on is building an Indexer Ecosystem, a project that's focus on content addressing on Filecoin, then potentially have interoperability with IPFS in the future and eventually serve the retrieval market. The Indexer Ecosystem high level architecture overview diagram can be found [here](https://github.com/filecoin-project/storetheindex/blob/main/doc/indexer_ecosys.png) and a detailed write up about can be found [here](https://www.notion.so/pl-strflt/Introducing-Indexer-to-SP-90bf296794174a8281c121d4ce6747a0).
That being said, with this release, lotus Storage Providers can easily become an Index Provider and serve the Indexer Content Addressing System. Index Providers generate advertisements from the deals made by a storage provider and announces the data to the indexer nodes for further processing:
- To learn more about *what is an Index Provider and how to be an Index Provider*, read it [here](https://lotus.filecoin.io/storage-providers/operate/index-provider/) in lotus docuementation.
- An [one-off migration](https://lotus.filecoin.io/storage-providers/operate/index-provider/#first-time-migration) is needed in order for a Storage Provider to become an Index Provider and announce the proper formatted index. It's *highly recommended* for all Index Provider to do a [force bulk initialization](https://lotus.filecoin.io/storage-providers/configure/dagstore/#forcing-bulk-initialization) to enable index announcement on all existing deals.
- Note that the Initialization places IO workload on your storage system. SP should set a proper `concurrency` based on your hardware or can stop/start initialization at their wish/convenience as proving deadlines approach and elapse, to avoid IOPS starvation or competition with window PoSt.
- After the first one-time migration, being an Index Provider barely puts any extra usage on SP's market system.
- After the first one-time migration, being an Index Provider barely puts any extra usage on SP's market system.
- You can find the testing result by SPX fellows [here](https://github.com/filecoin-project/lotus/discussions/8087).
We recommend all Storage Providers that are serving deals in the Filecoin network to become a Index Provider, make the data you are storing discoverable for the retrieval market and retrieval clients!
- If you have any questions about becoming an index provider, or the indexer system in general, leave a comment [here](https://github.com/filecoin-project/lotus/discussions/8341).
- Follow the indexer project at https://github.com/filecoin-project/go-indexer-core.
- If you have any feature request or bug reports of running an index provider, create an issue in https://github.com/filecoin-project/index-provider.
- You may also join the #storetheindex channel in the Filecoin Slack to engage with the team & the community!
We recommend all Storage Providers that are serving deals in the Filecoin network to become a Index Provider, make the data you are storing discoverable for the retrieval market and retrieval clients!
- If you have any questions about becoming an index provider, or the indexer system in general, leave a comment [here](https://github.com/filecoin-project/lotus/discussions/8341).
- Follow the indexer project at https://github.com/filecoin-project/go-indexer-core.
- If you have any feature request or bug reports of running an index provider, create an issue in https://github.com/filecoin-project/index-provider.
- You may also join the #storetheindex channel in the Filecoin Slack to engage with the team & the community!
### ❗️❗️❗️ Dag Migration For New CAR index format in DagStore ❗️❗️❗️
The index provider leverages the latest CARv2 indexing format `MultihashIndexSorted`, which stores the multihash code as well as the digest of all CIDs in a CAR file. Thus, all Storage Providers SHOULD perform an one-off DAG mirgation to regenerate DagStore CARv2 indices. You have to do it to become an index provider, failing to do so may also impact your future deal making.
Follow the instruction [here](https://lotus.filecoin.io/storage-providers/operate/index-provider/) to perform the migration.
Follow the instruction [here](https://lotus.filecoin.io/storage-providers/operate/index-provider/) to perform the migration.
## New Features
- feat: sealing: Sector upgrade queue ([filecoin-project/lotus#8333](https://github.com/filecoin-project/lotus/pull/8333))
@ -297,7 +405,7 @@ Follow the instruction [here](https://lotus.filecoin.io/storage-providers/operat
## Bug Fixes
- fix: FVM: add finality check for consensus faults #8452
- fix: market: Reuse the market PubSub in index provider #8451
- fix: market: set all index provider options based on lotus config #8444
- fix: market: set all index provider options based on lotus config #8444
- fix: sealing: Fix PR1 worker selection (#8421)
- fix: miner: dead loop on removing sector (#8421)
- fix: sealing: Remove sector copies from workers after snapdeals ([filecoin-project/lotus#8331](https://github.com/filecoin-project/lotus/pull/8331))

View File

@ -64,7 +64,7 @@ CLEAN+=build/.update-modules
deps: $(BUILD_DEPS)
.PHONY: deps
build-devnets: build lotus-seed lotus-shed lotus-wallet lotus-gateway
build-devnets: build lotus-seed lotus-shed lotus-wallet lotus-gateway lotus-fountain lotus-stats
.PHONY: build-devnets
debug: GOFLAGS+=-tags=debug
@ -169,7 +169,7 @@ BINS+=lotus-fountain
lotus-bench:
rm -f lotus-bench
$(GOCC) build -o lotus-bench ./cmd/lotus-bench
$(GOCC) build $(GOFLAGS) -o lotus-bench ./cmd/lotus-bench
.PHONY: lotus-bench
BINS+=lotus-bench
@ -295,6 +295,12 @@ actors-gen:
$(GOCC) run ./chain/actors/agen
$(GOCC) fmt ./...
bundle-gen:
$(GOCC) run ./gen/bundle
$(GOCC) fmt ./build/...
.PHONY: bundle-gen
api-gen:
$(GOCC) run ./gen/api
goimports -w api
@ -341,7 +347,7 @@ docsgen-openrpc-worker: docsgen-openrpc-bin
.PHONY: docsgen docsgen-md-bin docsgen-openrpc-bin
gen: actors-gen type-gen method-gen cfgdoc-gen docsgen api-gen circleci
gen: actors-gen type-gen method-gen cfgdoc-gen docsgen api-gen circleci bundle-gen
@echo ">>> IF YOU'VE MODIFIED THE CLI OR CONFIG, REMEMBER TO ALSO MAKE docsgen-cli"
.PHONY: gen

View File

@ -6,6 +6,9 @@ import (
"fmt"
"time"
abinetwork "github.com/filecoin-project/go-state-types/network"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
@ -20,11 +23,12 @@ import (
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/builtin/v8/market"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
@ -37,6 +41,7 @@ import (
type ChainIO interface {
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainHasObj(context.Context, cid.Cid) (bool, error)
ChainPutObj(context.Context, blocks.Block) error
}
const LookbackNoLimit = abi.ChainEpoch(-1)
@ -122,6 +127,9 @@ type FullNode interface {
// ChainHasObj checks if a given CID exists in the chain blockstore.
ChainHasObj(context.Context, cid.Cid) (bool, error) //perm:read
// ChainPutObj puts a given object into the block store
ChainPutObj(context.Context, blocks.Block) error //perm:admin
// ChainStatObj returns statistics about the graph referenced by 'obj'.
// If 'base' is also specified, then the returned stat will be a diff
// between the two objects.
@ -170,14 +178,6 @@ type FullNode interface {
// ChainBlockstoreInfo returns some basic information about the blockstore
ChainBlockstoreInfo(context.Context) (map[string]interface{}, error) //perm:read
// MethodGroup: Beacon
// The Beacon method group contains methods for interacting with the random beacon (DRAND)
// BeaconGetEntry returns the beacon entry for the given filecoin epoch. If
// the entry has not yet been produced, the call will block until the entry
// becomes available
BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) //perm:read
// GasEstimateFeeCap estimates gas fee cap
GasEstimateFeeCap(context.Context, *types.Message, int64, types.TipSetKey) (types.BigInt, error) //perm:read
@ -443,7 +443,7 @@ type FullNode interface {
// StateMinerPower returns the power of the indicated miner
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error) //perm:read
// StateMinerInfo returns info about the indicated miner
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) //perm:read
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (MinerInfo, error) //perm:read
// StateMinerDeadlines returns all the proving deadlines for the given miner
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]Deadline, error) //perm:read
// StateMinerPartitions returns all partitions in the specified deadline
@ -469,9 +469,9 @@ type FullNode interface {
// expiration epoch
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read
// StateSectorExpiration returns epoch at which given sector will expire
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) //perm:read
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read
// StateSectorPartition finds deadline/partition with the specified sector
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) //perm:read
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) //perm:read
// StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed
//
// NOTE: If a replacing message is found on chain, this method will return
@ -517,7 +517,7 @@ type FullNode interface {
// StateMarketParticipants returns the Escrow and Locked balances of every participant in the Storage Market
StateMarketParticipants(context.Context, types.TipSetKey) (map[string]MarketBalance, error) //perm:read
// StateMarketDeals returns information about every deal in the Storage Market
StateMarketDeals(context.Context, types.TipSetKey) (map[string]MarketDeal, error) //perm:read
StateMarketDeals(context.Context, types.TipSetKey) (map[string]*MarketDeal, error) //perm:read
// StateMarketStorageDeal returns information about the indicated deal
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*MarketDeal, error) //perm:read
// StateLookupID retrieves the ID address of the given address
@ -586,12 +586,19 @@ type FullNode interface {
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (CirculatingSupply, error) //perm:read
// StateNetworkVersion returns the network version at the given tipset
StateNetworkVersion(context.Context, types.TipSetKey) (apitypes.NetworkVersion, error) //perm:read
// StateActorCodeCIDs returns the CIDs of all the builtin actors for the given network version
StateActorCodeCIDs(context.Context, abinetwork.Version) (map[string]cid.Cid, error) //perm:read
// StateGetRandomnessFromTickets is used to sample the chain for randomness.
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read
// StateGetRandomnessFromBeacon is used to sample the beacon for randomness.
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read
// StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If
// the entry has not yet been produced, the call will block until the entry
// becomes available
StateGetBeaconEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) //perm:read
// StateGetNetworkParams return current network params
StateGetNetworkParams(ctx context.Context) (*NetworkParams, error) //perm:read

View File

@ -3,14 +3,15 @@ package api
import (
"context"
blocks "github.com/ipfs/go-block-format"
"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/dline"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
)
@ -30,6 +31,7 @@ import (
type Gateway interface {
ChainHasObj(context.Context, cid.Cid) (bool, error)
ChainPutObj(context.Context, blocks.Block) error
ChainHead(ctx context.Context) (*types.TipSet, error)
ChainGetParentMessages(context.Context, cid.Cid) ([]Message, error)
ChainGetParentReceipts(context.Context, cid.Cid) ([]*types.MessageReceipt, error)
@ -56,7 +58,7 @@ type Gateway interface {
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (MarketBalance, error)
StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*MarketDeal, error)
StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error)
StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (MinerInfo, error)
StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error)
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
StateNetworkVersion(context.Context, types.TipSetKey) (apitypes.NetworkVersion, error)

View File

@ -5,8 +5,8 @@ import (
"context"
"time"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
@ -15,8 +15,8 @@ import (
"github.com/filecoin-project/go-address"
datatransfer "github.com/filecoin-project/go-data-transfer"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/market"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
"github.com/filecoin-project/specs-storage/storage"
"github.com/filecoin-project/go-fil-markets/piecestore"
@ -165,7 +165,7 @@ type StorageMiner interface {
StorageStat(ctx context.Context, id storiface.ID) (fsutil.FsStat, error) //perm:admin
MarketImportDealData(ctx context.Context, propcid cid.Cid, path string) error //perm:write
MarketListDeals(ctx context.Context) ([]MarketDeal, error) //perm:read
MarketListDeals(ctx context.Context) ([]*MarketDeal, error) //perm:read
MarketListRetrievalDeals(ctx context.Context) ([]retrievalmarket.ProviderDealState, error) //perm:read
MarketGetDealUpdates(ctx context.Context) (<-chan storagemarket.MinerDeal, error) //perm:read
MarketListIncompleteDeals(ctx context.Context) ([]storagemarket.MinerDeal, error) //perm:read
@ -242,7 +242,7 @@ type StorageMiner interface {
RuntimeSubsystems(ctx context.Context) (MinerSubsystems, error) //perm:read
DealsImportData(ctx context.Context, dealPropCid cid.Cid, file string) error //perm:admin
DealsList(ctx context.Context) ([]MarketDeal, error) //perm:admin
DealsList(ctx context.Context) ([]*MarketDeal, error) //perm:admin
DealsConsiderOnlineStorageDeals(context.Context) (bool, error) //perm:admin
DealsSetConsiderOnlineStorageDeals(context.Context, bool) error //perm:admin
DealsConsiderOnlineRetrievalDeals(context.Context) (bool, error) //perm:admin

View File

@ -3,12 +3,12 @@ package api
import (
"context"
"github.com/filecoin-project/go-state-types/proof"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
"github.com/filecoin-project/specs-storage/storage"

View File

@ -9,8 +9,8 @@ import (
"sort"
abi "github.com/filecoin-project/go-state-types/abi"
market "github.com/filecoin-project/specs-actors/actors/builtin/market"
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
market "github.com/filecoin-project/go-state-types/builtin/v8/market"
paych "github.com/filecoin-project/go-state-types/builtin/v8/paych"
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors"
@ -26,25 +26,26 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{163}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{163}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Channel (address.Address) (struct)
if len("Channel") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Channel\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Channel"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Channel"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Channel")); err != nil {
return err
}
if err := t.Channel.MarshalCBOR(w); err != nil {
if err := t.Channel.MarshalCBOR(cw); err != nil {
return err
}
@ -53,14 +54,14 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"WaitSentinel\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("WaitSentinel"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("WaitSentinel"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("WaitSentinel")); err != nil {
return err
}
if err := cbg.WriteCidBuf(scratch, w, t.WaitSentinel); err != nil {
if err := cbg.WriteCid(cw, t.WaitSentinel); err != nil {
return xerrors.Errorf("failed to write cid field t.WaitSentinel: %w", err)
}
@ -69,7 +70,7 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"Vouchers\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Vouchers"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Vouchers"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Vouchers")); err != nil {
@ -80,27 +81,32 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field t.Vouchers was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Vouchers))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Vouchers))); err != nil {
return err
}
for _, v := range t.Vouchers {
if err := v.MarshalCBOR(w); err != nil {
if err := v.MarshalCBOR(cw); err != nil {
return err
}
}
return nil
}
func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) (err error) {
*t = PaymentInfo{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -115,7 +121,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -129,7 +135,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
{
if err := t.Channel.UnmarshalCBOR(br); err != nil {
if err := t.Channel.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.Channel: %w", err)
}
@ -139,7 +145,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
{
c, err := cbg.ReadCid(br)
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.WaitSentinel: %w", err)
}
@ -150,7 +156,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
// t.Vouchers ([]*paych.SignedVoucher) (slice)
case "Vouchers":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -170,7 +176,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error {
for i := 0; i < int(extra); i++ {
var v paych.SignedVoucher
if err := v.UnmarshalCBOR(br); err != nil {
if err := v.UnmarshalCBOR(cr); err != nil {
return err
}
@ -190,25 +196,26 @@ func (t *SealedRef) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{163}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{163}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.SectorID (abi.SectorNumber) (uint64)
if len("SectorID") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"SectorID\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("SectorID"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("SectorID"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("SectorID")); err != nil {
return err
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.SectorID)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.SectorID)); err != nil {
return err
}
@ -217,14 +224,14 @@ func (t *SealedRef) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"Offset\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Offset"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Offset"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Offset")); err != nil {
return err
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Offset)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Offset)); err != nil {
return err
}
@ -233,30 +240,35 @@ func (t *SealedRef) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"Size\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Size"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Size"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Size")); err != nil {
return err
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
return err
}
return nil
}
func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
func (t *SealedRef) UnmarshalCBOR(r io.Reader) (err error) {
*t = SealedRef{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -271,7 +283,7 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -285,7 +297,7 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -300,7 +312,7 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -315,7 +327,7 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error {
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -339,18 +351,19 @@ func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{161}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{161}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Refs ([]api.SealedRef) (slice)
if len("Refs") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Refs\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Refs"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Refs"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Refs")); err != nil {
@ -361,27 +374,32 @@ func (t *SealedRefs) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Slice value in field t.Refs was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajArray, uint64(len(t.Refs))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Refs))); err != nil {
return err
}
for _, v := range t.Refs {
if err := v.MarshalCBOR(w); err != nil {
if err := v.MarshalCBOR(cw); err != nil {
return err
}
}
return nil
}
func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
func (t *SealedRefs) UnmarshalCBOR(r io.Reader) (err error) {
*t = SealedRefs{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -396,7 +414,7 @@ func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -408,7 +426,7 @@ func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
// t.Refs ([]api.SealedRef) (slice)
case "Refs":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -428,7 +446,7 @@ func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error {
for i := 0; i < int(extra); i++ {
var v SealedRef
if err := v.UnmarshalCBOR(br); err != nil {
if err := v.UnmarshalCBOR(cr); err != nil {
return err
}
@ -448,18 +466,19 @@ func (t *SealTicket) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{162}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{162}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Value (abi.SealRandomness) (slice)
if len("Value") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Value\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Value"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Value"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Value")); err != nil {
@ -470,11 +489,11 @@ func (t *SealTicket) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Byte array in field t.Value was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Value))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Value))); err != nil {
return err
}
if _, err := w.Write(t.Value[:]); err != nil {
if _, err := cw.Write(t.Value[:]); err != nil {
return err
}
@ -483,7 +502,7 @@ func (t *SealTicket) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"Epoch\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Epoch"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Epoch"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Epoch")); err != nil {
@ -491,27 +510,32 @@ func (t *SealTicket) MarshalCBOR(w io.Writer) error {
}
if t.Epoch >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil {
return err
}
}
return nil
}
func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
func (t *SealTicket) UnmarshalCBOR(r io.Reader) (err error) {
*t = SealTicket{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -526,7 +550,7 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -538,7 +562,7 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
// t.Value (abi.SealRandomness) (slice)
case "Value":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -554,13 +578,13 @@ func (t *SealTicket) UnmarshalCBOR(r io.Reader) error {
t.Value = make([]uint8, extra)
}
if _, err := io.ReadFull(br, t.Value[:]); err != nil {
if _, err := io.ReadFull(cr, t.Value[:]); err != nil {
return err
}
// t.Epoch (abi.ChainEpoch) (int64)
case "Epoch":
{
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
@ -597,18 +621,19 @@ func (t *SealSeed) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{162}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{162}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.Value (abi.InteractiveSealRandomness) (slice)
if len("Value") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"Value\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Value"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Value"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Value")); err != nil {
@ -619,11 +644,11 @@ func (t *SealSeed) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Byte array in field t.Value was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajByteString, uint64(len(t.Value))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajByteString, uint64(len(t.Value))); err != nil {
return err
}
if _, err := w.Write(t.Value[:]); err != nil {
if _, err := cw.Write(t.Value[:]); err != nil {
return err
}
@ -632,7 +657,7 @@ func (t *SealSeed) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"Epoch\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("Epoch"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("Epoch"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("Epoch")); err != nil {
@ -640,27 +665,32 @@ func (t *SealSeed) MarshalCBOR(w io.Writer) error {
}
if t.Epoch >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Epoch)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Epoch-1)); err != nil {
return err
}
}
return nil
}
func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
func (t *SealSeed) UnmarshalCBOR(r io.Reader) (err error) {
*t = SealSeed{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -675,7 +705,7 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -687,7 +717,7 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
// t.Value (abi.InteractiveSealRandomness) (slice)
case "Value":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -703,13 +733,13 @@ func (t *SealSeed) UnmarshalCBOR(r io.Reader) error {
t.Value = make([]uint8, extra)
}
if _, err := io.ReadFull(br, t.Value[:]); err != nil {
if _, err := io.ReadFull(cr, t.Value[:]); err != nil {
return err
}
// t.Epoch (abi.ChainEpoch) (int64)
case "Epoch":
{
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
@ -746,18 +776,19 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{165}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{165}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.PublishCid (cid.Cid) (struct)
if len("PublishCid") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"PublishCid\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("PublishCid"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("PublishCid"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("PublishCid")); err != nil {
@ -765,11 +796,11 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
}
if t.PublishCid == nil {
if _, err := w.Write(cbg.CborNull); err != nil {
if _, err := cw.Write(cbg.CborNull); err != nil {
return err
}
} else {
if err := cbg.WriteCidBuf(scratch, w, *t.PublishCid); err != nil {
if err := cbg.WriteCid(cw, *t.PublishCid); err != nil {
return xerrors.Errorf("failed to write cid field t.PublishCid: %w", err)
}
}
@ -779,14 +810,14 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"DealID\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("DealID"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("DealID"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("DealID")); err != nil {
return err
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.DealID)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.DealID)); err != nil {
return err
}
@ -795,14 +826,14 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"DealProposal\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("DealProposal"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("DealProposal"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("DealProposal")); err != nil {
return err
}
if err := t.DealProposal.MarshalCBOR(w); err != nil {
if err := t.DealProposal.MarshalCBOR(cw); err != nil {
return err
}
@ -811,14 +842,14 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"DealSchedule\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("DealSchedule"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("DealSchedule"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("DealSchedule")); err != nil {
return err
}
if err := t.DealSchedule.MarshalCBOR(w); err != nil {
if err := t.DealSchedule.MarshalCBOR(cw); err != nil {
return err
}
@ -827,7 +858,7 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"KeepUnsealed\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("KeepUnsealed"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("KeepUnsealed"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("KeepUnsealed")); err != nil {
@ -840,16 +871,21 @@ func (t *PieceDealInfo) MarshalCBOR(w io.Writer) error {
return nil
}
func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) (err error) {
*t = PieceDealInfo{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -864,7 +900,7 @@ func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -878,16 +914,16 @@ func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
{
b, err := br.ReadByte()
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := br.UnreadByte(); err != nil {
if err := cr.UnreadByte(); err != nil {
return err
}
c, err := cbg.ReadCid(br)
c, err := cbg.ReadCid(cr)
if err != nil {
return xerrors.Errorf("failed to read cid field t.PublishCid: %w", err)
}
@ -901,7 +937,7 @@ func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
{
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -916,16 +952,16 @@ func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
{
b, err := br.ReadByte()
b, err := cr.ReadByte()
if err != nil {
return err
}
if b != cbg.CborNull[0] {
if err := br.UnreadByte(); err != nil {
if err := cr.UnreadByte(); err != nil {
return err
}
t.DealProposal = new(market.DealProposal)
if err := t.DealProposal.UnmarshalCBOR(br); err != nil {
if err := t.DealProposal.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.DealProposal pointer: %w", err)
}
}
@ -936,7 +972,7 @@ func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
{
if err := t.DealSchedule.UnmarshalCBOR(br); err != nil {
if err := t.DealSchedule.UnmarshalCBOR(cr); err != nil {
return xerrors.Errorf("unmarshaling t.DealSchedule: %w", err)
}
@ -944,7 +980,7 @@ func (t *PieceDealInfo) UnmarshalCBOR(r io.Reader) error {
// t.KeepUnsealed (bool) (bool)
case "KeepUnsealed":
maj, extra, err = cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err = cr.ReadHeader()
if err != nil {
return err
}
@ -973,18 +1009,19 @@ func (t *DealSchedule) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull)
return err
}
if _, err := w.Write([]byte{162}); err != nil {
cw := cbg.NewCborWriter(w)
if _, err := cw.Write([]byte{162}); err != nil {
return err
}
scratch := make([]byte, 9)
// t.StartEpoch (abi.ChainEpoch) (int64)
if len("StartEpoch") > cbg.MaxLength {
return xerrors.Errorf("Value in field \"StartEpoch\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("StartEpoch"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("StartEpoch"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("StartEpoch")); err != nil {
@ -992,11 +1029,11 @@ func (t *DealSchedule) MarshalCBOR(w io.Writer) error {
}
if t.StartEpoch >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.StartEpoch)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.StartEpoch)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.StartEpoch-1)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.StartEpoch-1)); err != nil {
return err
}
}
@ -1006,7 +1043,7 @@ func (t *DealSchedule) MarshalCBOR(w io.Writer) error {
return xerrors.Errorf("Value in field \"EndEpoch\" was too long")
}
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajTextString, uint64(len("EndEpoch"))); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("EndEpoch"))); err != nil {
return err
}
if _, err := io.WriteString(w, string("EndEpoch")); err != nil {
@ -1014,27 +1051,32 @@ func (t *DealSchedule) MarshalCBOR(w io.Writer) error {
}
if t.EndEpoch >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.EndEpoch)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.EndEpoch)); err != nil {
return err
}
} else {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajNegativeInt, uint64(-t.EndEpoch-1)); err != nil {
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.EndEpoch-1)); err != nil {
return err
}
}
return nil
}
func (t *DealSchedule) UnmarshalCBOR(r io.Reader) error {
func (t *DealSchedule) UnmarshalCBOR(r io.Reader) (err error) {
*t = DealSchedule{}
br := cbg.GetPeeker(r)
scratch := make([]byte, 8)
cr := cbg.NewCborReader(r)
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
if err != nil {
return err
}
defer func() {
if err == io.EOF {
err = io.ErrUnexpectedEOF
}
}()
if maj != cbg.MajMap {
return fmt.Errorf("cbor input should be of type map")
}
@ -1049,7 +1091,7 @@ func (t *DealSchedule) UnmarshalCBOR(r io.Reader) error {
for i := uint64(0); i < n; i++ {
{
sval, err := cbg.ReadStringBuf(br, scratch)
sval, err := cbg.ReadString(cr)
if err != nil {
return err
}
@ -1061,7 +1103,7 @@ func (t *DealSchedule) UnmarshalCBOR(r io.Reader) error {
// t.StartEpoch (abi.ChainEpoch) (int64)
case "StartEpoch":
{
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err
@ -1087,7 +1129,7 @@ func (t *DealSchedule) UnmarshalCBOR(r io.Reader) error {
// t.EndEpoch (abi.ChainEpoch) (int64)
case "EndEpoch":
{
maj, extra, err := cbg.CborReadHeaderBuf(br, scratch)
maj, extra, err := cr.ReadHeader()
var extraI int64
if err != nil {
return err

View File

@ -28,6 +28,7 @@ import (
filestore "github.com/filecoin-project/go-fil-markets/filestore"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-jsonrpc/auth"
blocks "github.com/ipfs/go-block-format"
textselector "github.com/ipld/go-ipld-selector-text-lite"
"github.com/filecoin-project/go-state-types/abi"
@ -95,6 +96,9 @@ func init() {
apiSelExample := api.Selector("Links/21/Hash/Links/42/Hash")
clientEvent := retrievalmarket.ClientEventDealAccepted
block := blocks.Block(&blocks.BasicBlock{})
ExampleValues[reflect.TypeOf(&block).Elem()] = block
addExample(bitfield.NewFromSet([]uint64{5}))
addExample(abi.RegisteredSealProof_StackedDrg32GiBV1_1)
addExample(abi.RegisteredPoStProof_StackedDrgWindow32GiBV1)
@ -146,6 +150,10 @@ func init() {
addExample(map[string]api.MarketDeal{
"t026363": ExampleValue("init", reflect.TypeOf(api.MarketDeal{}), nil).(api.MarketDeal),
})
addExample(map[string]*api.MarketDeal{
"t026363": ExampleValue("init", reflect.TypeOf(&api.MarketDeal{}), nil).(*api.MarketDeal),
})
addExample(map[string]api.MarketBalance{
"t026363": ExampleValue("init", reflect.TypeOf(api.MarketBalance{}), nil).(api.MarketBalance),
})
@ -188,6 +196,7 @@ func init() {
addExample(&si)
addExample(retrievalmarket.DealID(5))
addExample(abi.ActorID(1000))
addExample(map[string]cid.Cid{})
addExample(map[string][]api.SealedRef{
"98000": {
api.SealedRef{

View File

@ -17,20 +17,21 @@ import (
auth "github.com/filecoin-project/go-jsonrpc/auth"
abi "github.com/filecoin-project/go-state-types/abi"
big "github.com/filecoin-project/go-state-types/big"
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
paych "github.com/filecoin-project/go-state-types/builtin/v8/paych"
crypto "github.com/filecoin-project/go-state-types/crypto"
dline "github.com/filecoin-project/go-state-types/dline"
network "github.com/filecoin-project/go-state-types/network"
api "github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
types "github.com/filecoin-project/lotus/chain/types"
alerting "github.com/filecoin-project/lotus/journal/alerting"
dtypes "github.com/filecoin-project/lotus/node/modules/dtypes"
imports "github.com/filecoin-project/lotus/node/repo/imports"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
gomock "github.com/golang/mock/gomock"
uuid "github.com/google/uuid"
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"
@ -91,21 +92,6 @@ func (mr *MockFullNodeMockRecorder) AuthVerify(arg0, arg1 interface{}) *gomock.C
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AuthVerify", reflect.TypeOf((*MockFullNode)(nil).AuthVerify), arg0, arg1)
}
// BeaconGetEntry mocks base method.
func (m *MockFullNode) BeaconGetEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BeaconGetEntry", arg0, arg1)
ret0, _ := ret[0].(*types.BeaconEntry)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// BeaconGetEntry indicates an expected call of BeaconGetEntry.
func (mr *MockFullNodeMockRecorder) BeaconGetEntry(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BeaconGetEntry", reflect.TypeOf((*MockFullNode)(nil).BeaconGetEntry), arg0, arg1)
}
// ChainBlockstoreInfo mocks base method.
func (m *MockFullNode) ChainBlockstoreInfo(arg0 context.Context) (map[string]interface{}, error) {
m.ctrl.T.Helper()
@ -389,6 +375,20 @@ func (mr *MockFullNodeMockRecorder) ChainNotify(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainNotify", reflect.TypeOf((*MockFullNode)(nil).ChainNotify), arg0)
}
// ChainPutObj mocks base method.
func (m *MockFullNode) ChainPutObj(arg0 context.Context, arg1 blocks.Block) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ChainPutObj", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ChainPutObj indicates an expected call of ChainPutObj.
func (mr *MockFullNodeMockRecorder) ChainPutObj(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutObj", reflect.TypeOf((*MockFullNode)(nil).ChainPutObj), arg0, arg1)
}
// ChainReadObj mocks base method.
func (m *MockFullNode) ChainReadObj(arg0 context.Context, arg1 cid.Cid) ([]byte, error) {
m.ctrl.T.Helper()
@ -2271,6 +2271,21 @@ func (mr *MockFullNodeMockRecorder) StateAccountKey(arg0, arg1, arg2 interface{}
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateAccountKey", reflect.TypeOf((*MockFullNode)(nil).StateAccountKey), arg0, arg1, arg2)
}
// StateActorCodeCIDs mocks base method.
func (m *MockFullNode) StateActorCodeCIDs(arg0 context.Context, arg1 network.Version) (map[string]cid.Cid, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateActorCodeCIDs", arg0, arg1)
ret0, _ := ret[0].(map[string]cid.Cid)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// StateActorCodeCIDs indicates an expected call of StateActorCodeCIDs.
func (mr *MockFullNodeMockRecorder) StateActorCodeCIDs(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateActorCodeCIDs", reflect.TypeOf((*MockFullNode)(nil).StateActorCodeCIDs), arg0, arg1)
}
// StateAllMinerFaults mocks base method.
func (m *MockFullNode) StateAllMinerFaults(arg0 context.Context, arg1 abi.ChainEpoch, arg2 types.TipSetKey) ([]*api.Fault, error) {
m.ctrl.T.Helper()
@ -2406,6 +2421,21 @@ func (mr *MockFullNodeMockRecorder) StateGetActor(arg0, arg1, arg2 interface{})
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetActor", reflect.TypeOf((*MockFullNode)(nil).StateGetActor), arg0, arg1, arg2)
}
// StateGetBeaconEntry mocks base method.
func (m *MockFullNode) StateGetBeaconEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateGetBeaconEntry", arg0, arg1)
ret0, _ := ret[0].(*types.BeaconEntry)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// StateGetBeaconEntry indicates an expected call of StateGetBeaconEntry.
func (mr *MockFullNodeMockRecorder) StateGetBeaconEntry(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateGetBeaconEntry", reflect.TypeOf((*MockFullNode)(nil).StateGetBeaconEntry), arg0, arg1)
}
// StateGetNetworkParams mocks base method.
func (m *MockFullNode) StateGetNetworkParams(arg0 context.Context) (*api.NetworkParams, error) {
m.ctrl.T.Helper()
@ -2542,10 +2572,10 @@ func (mr *MockFullNodeMockRecorder) StateMarketBalance(arg0, arg1, arg2 interfac
}
// StateMarketDeals mocks base method.
func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]api.MarketDeal, error) {
func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]*api.MarketDeal, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMarketDeals", arg0, arg1)
ret0, _ := ret[0].(map[string]api.MarketDeal)
ret0, _ := ret[0].(map[string]*api.MarketDeal)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -2647,10 +2677,10 @@ func (mr *MockFullNodeMockRecorder) StateMinerFaults(arg0, arg1, arg2 interface{
}
// StateMinerInfo mocks base method.
func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (miner.MinerInfo, error) {
func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2)
ret0, _ := ret[0].(miner.MinerInfo)
ret0, _ := ret[0].(api.MinerInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -2662,7 +2692,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{})
}
// StateMinerInitialPledgeCollateral mocks base method.
func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMinerInitialPledgeCollateral", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(big.Int)
@ -2707,7 +2737,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerPower(arg0, arg1, arg2 interface{}
}
// StateMinerPreCommitDepositForPower mocks base method.
func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMinerPreCommitDepositForPower", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(big.Int)
@ -2872,10 +2902,10 @@ func (mr *MockFullNodeMockRecorder) StateSearchMsg(arg0, arg1, arg2, arg3, arg4
}
// StateSectorExpiration mocks base method.
func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorExpiration, error) {
func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorExpiration, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateSectorExpiration", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(*miner.SectorExpiration)
ret0, _ := ret[0].(*miner0.SectorExpiration)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -2902,10 +2932,10 @@ func (mr *MockFullNodeMockRecorder) StateSectorGetInfo(arg0, arg1, arg2, arg3 in
}
// StateSectorPartition mocks base method.
func (m *MockFullNode) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorLocation, error) {
func (m *MockFullNode) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorLocation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateSectorPartition", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(*miner.SectorLocation)
ret0, _ := ret[0].(*miner0.SectorLocation)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@ -15,13 +15,15 @@ import (
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/go-state-types/proof"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
@ -30,9 +32,9 @@ import (
"github.com/filecoin-project/lotus/journal/alerting"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo/imports"
"github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"github.com/filecoin-project/specs-storage/storage"
"github.com/google/uuid"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
metrics "github.com/libp2p/go-libp2p-core/metrics"
"github.com/libp2p/go-libp2p-core/network"
@ -47,6 +49,8 @@ type ChainIOStruct struct {
Internal struct {
ChainHasObj func(p0 context.Context, p1 cid.Cid) (bool, error) ``
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) ``
}
}
@ -102,8 +106,6 @@ type FullNodeStruct struct {
NetStruct
Internal struct {
BeaconGetEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"`
ChainBlockstoreInfo func(p0 context.Context) (map[string]interface{}, error) `perm:"read"`
ChainCheckBlockstore func(p0 context.Context) error `perm:"admin"`
@ -142,6 +144,8 @@ type FullNodeStruct struct {
ChainNotify func(p0 context.Context) (<-chan []*HeadChange, error) `perm:"read"`
ChainPutObj func(p0 context.Context, p1 blocks.Block) error `perm:"admin"`
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `perm:"read"`
ChainSetHead func(p0 context.Context, p1 types.TipSetKey) error `perm:"admin"`
@ -334,6 +338,8 @@ type FullNodeStruct struct {
StateAccountKey func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `perm:"read"`
StateActorCodeCIDs func(p0 context.Context, p1 abinetwork.Version) (map[string]cid.Cid, error) `perm:"read"`
StateAllMinerFaults func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) ([]*Fault, error) `perm:"read"`
StateCall func(p0 context.Context, p1 *types.Message, p2 types.TipSetKey) (*InvocResult, error) `perm:"read"`
@ -352,6 +358,8 @@ type FullNodeStruct struct {
StateGetActor func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*types.Actor, error) `perm:"read"`
StateGetBeaconEntry func(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"`
StateGetNetworkParams func(p0 context.Context) (*NetworkParams, error) `perm:"read"`
StateGetRandomnessFromBeacon func(p0 context.Context, p1 crypto.DomainSeparationTag, p2 abi.ChainEpoch, p3 []byte, p4 types.TipSetKey) (abi.Randomness, error) `perm:"read"`
@ -370,7 +378,7 @@ type FullNodeStruct struct {
StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MarketBalance, error) `perm:"read"`
StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]MarketDeal, error) `perm:"read"`
StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]*MarketDeal, error) `perm:"read"`
StateMarketParticipants func(p0 context.Context, p1 types.TipSetKey) (map[string]MarketBalance, error) `perm:"read"`
@ -384,7 +392,7 @@ type FullNodeStruct struct {
StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `perm:"read"`
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `perm:"read"`
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) `perm:"read"`
StateMinerInitialPledgeCollateral func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"`
@ -414,11 +422,11 @@ type FullNodeStruct struct {
StateSearchMsg func(p0 context.Context, p1 types.TipSetKey, p2 cid.Cid, p3 abi.ChainEpoch, p4 bool) (*MsgLookup, error) `perm:"read"`
StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"`
StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) `perm:"read"`
StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"`
StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"`
StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
@ -510,6 +518,8 @@ type GatewayStruct struct {
ChainNotify func(p0 context.Context) (<-chan []*HeadChange, error) ``
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) ``
GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) ``
@ -538,7 +548,7 @@ type GatewayStruct struct {
StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*MarketDeal, error) ``
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) ``
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) ``
StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*MinerPower, error) ``
@ -677,7 +687,7 @@ type StorageMinerStruct struct {
DealsImportData func(p0 context.Context, p1 cid.Cid, p2 string) error `perm:"admin"`
DealsList func(p0 context.Context) ([]MarketDeal, error) `perm:"admin"`
DealsList func(p0 context.Context) ([]*MarketDeal, error) `perm:"admin"`
DealsPieceCidBlocklist func(p0 context.Context) ([]cid.Cid, error) `perm:"admin"`
@ -715,7 +725,7 @@ type StorageMinerStruct struct {
MarketListDataTransfers func(p0 context.Context) ([]DataTransferChannel, error) `perm:"write"`
MarketListDeals func(p0 context.Context) ([]MarketDeal, error) `perm:"read"`
MarketListDeals func(p0 context.Context) ([]*MarketDeal, error) `perm:"read"`
MarketListIncompleteDeals func(p0 context.Context) ([]storagemarket.MinerDeal, error) `perm:"read"`
@ -976,6 +986,17 @@ func (s *ChainIOStub) ChainHasObj(p0 context.Context, p1 cid.Cid) (bool, error)
return false, ErrNotSupported
}
func (s *ChainIOStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
if s.Internal.ChainPutObj == nil {
return ErrNotSupported
}
return s.Internal.ChainPutObj(p0, p1)
}
func (s *ChainIOStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
return ErrNotSupported
}
func (s *ChainIOStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
if s.Internal.ChainReadObj == nil {
return *new([]byte), ErrNotSupported
@ -1097,17 +1118,6 @@ func (s *CommonStub) Version(p0 context.Context) (APIVersion, error) {
return *new(APIVersion), ErrNotSupported
}
func (s *FullNodeStruct) BeaconGetEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) {
if s.Internal.BeaconGetEntry == nil {
return nil, ErrNotSupported
}
return s.Internal.BeaconGetEntry(p0, p1)
}
func (s *FullNodeStub) BeaconGetEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) {
return nil, ErrNotSupported
}
func (s *FullNodeStruct) ChainBlockstoreInfo(p0 context.Context) (map[string]interface{}, error) {
if s.Internal.ChainBlockstoreInfo == nil {
return *new(map[string]interface{}), ErrNotSupported
@ -1317,6 +1327,17 @@ func (s *FullNodeStub) ChainNotify(p0 context.Context) (<-chan []*HeadChange, er
return nil, ErrNotSupported
}
func (s *FullNodeStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
if s.Internal.ChainPutObj == nil {
return ErrNotSupported
}
return s.Internal.ChainPutObj(p0, p1)
}
func (s *FullNodeStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
return ErrNotSupported
}
func (s *FullNodeStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
if s.Internal.ChainReadObj == nil {
return *new([]byte), ErrNotSupported
@ -2373,6 +2394,17 @@ func (s *FullNodeStub) StateAccountKey(p0 context.Context, p1 address.Address, p
return *new(address.Address), ErrNotSupported
}
func (s *FullNodeStruct) StateActorCodeCIDs(p0 context.Context, p1 abinetwork.Version) (map[string]cid.Cid, error) {
if s.Internal.StateActorCodeCIDs == nil {
return *new(map[string]cid.Cid), ErrNotSupported
}
return s.Internal.StateActorCodeCIDs(p0, p1)
}
func (s *FullNodeStub) StateActorCodeCIDs(p0 context.Context, p1 abinetwork.Version) (map[string]cid.Cid, error) {
return *new(map[string]cid.Cid), ErrNotSupported
}
func (s *FullNodeStruct) StateAllMinerFaults(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) ([]*Fault, error) {
if s.Internal.StateAllMinerFaults == nil {
return *new([]*Fault), ErrNotSupported
@ -2472,6 +2504,17 @@ func (s *FullNodeStub) StateGetActor(p0 context.Context, p1 address.Address, p2
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) {
if s.Internal.StateGetBeaconEntry == nil {
return nil, ErrNotSupported
}
return s.Internal.StateGetBeaconEntry(p0, p1)
}
func (s *FullNodeStub) StateGetBeaconEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) {
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateGetNetworkParams(p0 context.Context) (*NetworkParams, error) {
if s.Internal.StateGetNetworkParams == nil {
return nil, ErrNotSupported
@ -2571,15 +2614,15 @@ func (s *FullNodeStub) StateMarketBalance(p0 context.Context, p1 address.Address
return *new(MarketBalance), ErrNotSupported
}
func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]MarketDeal, error) {
func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*MarketDeal, error) {
if s.Internal.StateMarketDeals == nil {
return *new(map[string]MarketDeal), ErrNotSupported
return *new(map[string]*MarketDeal), ErrNotSupported
}
return s.Internal.StateMarketDeals(p0, p1)
}
func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]MarketDeal, error) {
return *new(map[string]MarketDeal), ErrNotSupported
func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*MarketDeal, error) {
return *new(map[string]*MarketDeal), ErrNotSupported
}
func (s *FullNodeStruct) StateMarketParticipants(p0 context.Context, p1 types.TipSetKey) (map[string]MarketBalance, error) {
@ -2648,15 +2691,15 @@ func (s *FullNodeStub) StateMinerFaults(p0 context.Context, p1 address.Address,
return *new(bitfield.BitField), ErrNotSupported
}
func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) {
if s.Internal.StateMinerInfo == nil {
return *new(miner.MinerInfo), ErrNotSupported
return *new(MinerInfo), ErrNotSupported
}
return s.Internal.StateMinerInfo(p0, p1, p2)
}
func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
return *new(miner.MinerInfo), ErrNotSupported
func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) {
return *new(MinerInfo), ErrNotSupported
}
func (s *FullNodeStruct) StateMinerInitialPledgeCollateral(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) {
@ -2813,14 +2856,14 @@ func (s *FullNodeStub) StateSearchMsg(p0 context.Context, p1 types.TipSetKey, p2
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) {
func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) {
if s.Internal.StateSectorExpiration == nil {
return nil, ErrNotSupported
}
return s.Internal.StateSectorExpiration(p0, p1, p2, p3)
}
func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) {
func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) {
return nil, ErrNotSupported
}
@ -2835,14 +2878,14 @@ func (s *FullNodeStub) StateSectorGetInfo(p0 context.Context, p1 address.Address
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) {
func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) {
if s.Internal.StateSectorPartition == nil {
return nil, ErrNotSupported
}
return s.Internal.StateSectorPartition(p0, p1, p2, p3)
}
func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) {
func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) {
return nil, ErrNotSupported
}
@ -3286,6 +3329,17 @@ func (s *GatewayStub) ChainNotify(p0 context.Context) (<-chan []*HeadChange, err
return nil, ErrNotSupported
}
func (s *GatewayStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
if s.Internal.ChainPutObj == nil {
return ErrNotSupported
}
return s.Internal.ChainPutObj(p0, p1)
}
func (s *GatewayStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
return ErrNotSupported
}
func (s *GatewayStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
if s.Internal.ChainReadObj == nil {
return *new([]byte), ErrNotSupported
@ -3440,15 +3494,15 @@ func (s *GatewayStub) StateMarketStorageDeal(p0 context.Context, p1 abi.DealID,
return nil, ErrNotSupported
}
func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) {
if s.Internal.StateMinerInfo == nil {
return *new(miner.MinerInfo), ErrNotSupported
return *new(MinerInfo), ErrNotSupported
}
return s.Internal.StateMinerInfo(p0, p1, p2)
}
func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
return *new(miner.MinerInfo), ErrNotSupported
func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (MinerInfo, error) {
return *new(MinerInfo), ErrNotSupported
}
func (s *GatewayStruct) StateMinerPower(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*MinerPower, error) {
@ -4067,15 +4121,15 @@ func (s *StorageMinerStub) DealsImportData(p0 context.Context, p1 cid.Cid, p2 st
return ErrNotSupported
}
func (s *StorageMinerStruct) DealsList(p0 context.Context) ([]MarketDeal, error) {
func (s *StorageMinerStruct) DealsList(p0 context.Context) ([]*MarketDeal, error) {
if s.Internal.DealsList == nil {
return *new([]MarketDeal), ErrNotSupported
return *new([]*MarketDeal), ErrNotSupported
}
return s.Internal.DealsList(p0)
}
func (s *StorageMinerStub) DealsList(p0 context.Context) ([]MarketDeal, error) {
return *new([]MarketDeal), ErrNotSupported
func (s *StorageMinerStub) DealsList(p0 context.Context) ([]*MarketDeal, error) {
return *new([]*MarketDeal), ErrNotSupported
}
func (s *StorageMinerStruct) DealsPieceCidBlocklist(p0 context.Context) ([]cid.Cid, error) {
@ -4276,15 +4330,15 @@ func (s *StorageMinerStub) MarketListDataTransfers(p0 context.Context) ([]DataTr
return *new([]DataTransferChannel), ErrNotSupported
}
func (s *StorageMinerStruct) MarketListDeals(p0 context.Context) ([]MarketDeal, error) {
func (s *StorageMinerStruct) MarketListDeals(p0 context.Context) ([]*MarketDeal, error) {
if s.Internal.MarketListDeals == nil {
return *new([]MarketDeal), ErrNotSupported
return *new([]*MarketDeal), ErrNotSupported
}
return s.Internal.MarketListDeals(p0)
}
func (s *StorageMinerStub) MarketListDeals(p0 context.Context) ([]MarketDeal, error) {
return *new([]MarketDeal), ErrNotSupported
func (s *StorageMinerStub) MarketListDeals(p0 context.Context) ([]*MarketDeal, error) {
return *new([]*MarketDeal), ErrNotSupported
}
func (s *StorageMinerStruct) MarketListIncompleteDeals(p0 context.Context) ([]storagemarket.MinerDeal, error) {

View File

@ -5,6 +5,8 @@ import (
"fmt"
"time"
"github.com/filecoin-project/go-address"
"github.com/libp2p/go-libp2p-core/network"
datatransfer "github.com/filecoin-project/go-data-transfer"
@ -286,6 +288,20 @@ type ExportRef struct {
DealID retrievalmarket.DealID
}
type MinerInfo struct {
Owner address.Address // Must be an ID-address.
Worker address.Address // Must be an ID-address.
NewWorker address.Address // Must be an ID-address.
ControlAddresses []address.Address // Must be an ID-addresses.
WorkerChangeEpoch abi.ChainEpoch
PeerId *peer.ID
Multiaddrs []abi.Multiaddrs
WindowPoStProofType abi.RegisteredPoStProof
SectorSize abi.SectorSize
WindowPoStPartitionSectors uint64
ConsensusFaultElapsed abi.ChainEpoch
}
type NetworkParams struct {
NetworkName dtypes.NetworkName
BlockDelaySecs uint64

View File

@ -3,6 +3,8 @@ package v0api
import (
"context"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
datatransfer "github.com/filecoin-project/go-data-transfer"
@ -11,14 +13,16 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
textselector "github.com/ipld/go-ipld-selector-text-lite"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
marketevents "github.com/filecoin-project/lotus/markets/loggers"
"github.com/filecoin-project/lotus/node/modules/dtypes"
@ -109,6 +113,9 @@ type FullNode interface {
// ChainDeleteObj deletes node referenced by the given CID
ChainDeleteObj(context.Context, cid.Cid) error //perm:admin
// ChainPutObj puts and object into the blockstore
ChainPutObj(context.Context, blocks.Block) error
// ChainHasObj checks if a given CID exists in the chain blockstore.
ChainHasObj(context.Context, cid.Cid) (bool, error) //perm:read
@ -416,7 +423,7 @@ type FullNode interface {
// StateMinerPower returns the power of the indicated miner
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) //perm:read
// StateMinerInfo returns info about the indicated miner
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error) //perm:read
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) //perm:read
// StateMinerDeadlines returns all the proving deadlines for the given miner
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error) //perm:read
// StateMinerPartitions returns all partitions in the specified deadline
@ -442,9 +449,9 @@ type FullNode interface {
// expiration epoch
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) //perm:read
// StateSectorExpiration returns epoch at which given sector will expire
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorExpiration, error) //perm:read
StateSectorExpiration(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read
// StateSectorPartition finds deadline/partition with the specified sector
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) //perm:read
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error) //perm:read
// StateSearchMsg searches for a message in the chain, and returns its receipt and the tipset where it was executed
//
// NOTE: If a replacing message is found on chain, this method will return
@ -521,7 +528,7 @@ type FullNode interface {
// StateMarketParticipants returns the Escrow and Locked balances of every participant in the Storage Market
StateMarketParticipants(context.Context, types.TipSetKey) (map[string]api.MarketBalance, error) //perm:read
// StateMarketDeals returns information about every deal in the Storage Market
StateMarketDeals(context.Context, types.TipSetKey) (map[string]api.MarketDeal, error) //perm:read
StateMarketDeals(context.Context, types.TipSetKey) (map[string]*api.MarketDeal, error) //perm:read
// StateMarketStorageDeal returns information about the indicated deal
StateMarketStorageDeal(context.Context, abi.DealID, types.TipSetKey) (*api.MarketDeal, error) //perm:read
// StateLookupID retrieves the ID address of the given address
@ -598,6 +605,8 @@ type FullNode interface {
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (api.CirculatingSupply, error) //perm:read
// StateNetworkVersion returns the network version at the given tipset
StateNetworkVersion(context.Context, types.TipSetKey) (apitypes.NetworkVersion, error) //perm:read
// StateActorCodeCIDs returns the CIDs of all the builtin actors for the given network version
StateActorCodeCIDs(context.Context, abinetwork.Version) (map[string]cid.Cid, error) //perm:read
// StateGetRandomnessFromTickets is used to sample the chain for randomness.
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read

View File

@ -3,6 +3,7 @@ package v0api
import (
"context"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address"
@ -10,8 +11,8 @@ import (
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
)
@ -34,6 +35,7 @@ import (
type Gateway interface {
ChainHasObj(context.Context, cid.Cid) (bool, error)
ChainPutObj(context.Context, blocks.Block) error
ChainHead(ctx context.Context) (*types.TipSet, error)
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
@ -54,7 +56,7 @@ type Gateway interface {
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error)
StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error)
StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (miner.MinerInfo, error)
StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error)
StateMinerProvingDeadline(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*dline.Info, error)
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error)
StateNetworkVersion(context.Context, types.TipSetKey) (abinetwork.Version, error)

View File

@ -11,17 +11,19 @@ import (
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v8/paych"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
abinetwork "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
marketevents "github.com/filecoin-project/lotus/markets/loggers"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"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"
@ -73,6 +75,8 @@ type FullNodeStruct struct {
ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) `perm:"read"`
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `perm:"read"`
ChainSetHead func(p0 context.Context, p1 types.TipSetKey) error `perm:"admin"`
@ -251,6 +255,8 @@ type FullNodeStruct struct {
StateAccountKey func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (address.Address, error) `perm:"read"`
StateActorCodeCIDs func(p0 context.Context, p1 abinetwork.Version) (map[string]cid.Cid, error) `perm:"read"`
StateAllMinerFaults func(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
StateCall func(p0 context.Context, p1 *types.Message, p2 types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
@ -285,7 +291,7 @@ type FullNodeStruct struct {
StateMarketBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MarketBalance, error) `perm:"read"`
StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketDeal, error) `perm:"read"`
StateMarketDeals func(p0 context.Context, p1 types.TipSetKey) (map[string]*api.MarketDeal, error) `perm:"read"`
StateMarketParticipants func(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketBalance, error) `perm:"read"`
@ -299,7 +305,7 @@ type FullNodeStruct struct {
StateMinerFaults func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (bitfield.BitField, error) `perm:"read"`
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) `perm:"read"`
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) `perm:"read"`
StateMinerInitialPledgeCollateral func(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"`
@ -331,11 +337,11 @@ type FullNodeStruct struct {
StateSearchMsgLimited func(p0 context.Context, p1 cid.Cid, p2 abi.ChainEpoch) (*api.MsgLookup, error) `perm:"read"`
StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) `perm:"read"`
StateSectorExpiration func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) `perm:"read"`
StateSectorGetInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) `perm:"read"`
StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"`
StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
@ -419,6 +425,8 @@ type GatewayStruct struct {
ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) ``
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) ``
GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) ``
@ -447,7 +455,7 @@ type GatewayStruct struct {
StateMarketStorageDeal func(p0 context.Context, p1 abi.DealID, p2 types.TipSetKey) (*api.MarketDeal, error) ``
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) ``
StateMinerInfo func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) ``
StateMinerPower func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) ``
@ -681,6 +689,17 @@ func (s *FullNodeStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadChange
return nil, ErrNotSupported
}
func (s *FullNodeStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
if s.Internal.ChainPutObj == nil {
return ErrNotSupported
}
return s.Internal.ChainPutObj(p0, p1)
}
func (s *FullNodeStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
return ErrNotSupported
}
func (s *FullNodeStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
if s.Internal.ChainReadObj == nil {
return *new([]byte), ErrNotSupported
@ -1660,6 +1679,17 @@ func (s *FullNodeStub) StateAccountKey(p0 context.Context, p1 address.Address, p
return *new(address.Address), ErrNotSupported
}
func (s *FullNodeStruct) StateActorCodeCIDs(p0 context.Context, p1 abinetwork.Version) (map[string]cid.Cid, error) {
if s.Internal.StateActorCodeCIDs == nil {
return *new(map[string]cid.Cid), ErrNotSupported
}
return s.Internal.StateActorCodeCIDs(p0, p1)
}
func (s *FullNodeStub) StateActorCodeCIDs(p0 context.Context, p1 abinetwork.Version) (map[string]cid.Cid, error) {
return *new(map[string]cid.Cid), ErrNotSupported
}
func (s *FullNodeStruct) StateAllMinerFaults(p0 context.Context, p1 abi.ChainEpoch, p2 types.TipSetKey) ([]*api.Fault, error) {
if s.Internal.StateAllMinerFaults == nil {
return *new([]*api.Fault), ErrNotSupported
@ -1847,15 +1877,15 @@ func (s *FullNodeStub) StateMarketBalance(p0 context.Context, p1 address.Address
return *new(api.MarketBalance), ErrNotSupported
}
func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketDeal, error) {
func (s *FullNodeStruct) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*api.MarketDeal, error) {
if s.Internal.StateMarketDeals == nil {
return *new(map[string]api.MarketDeal), ErrNotSupported
return *new(map[string]*api.MarketDeal), ErrNotSupported
}
return s.Internal.StateMarketDeals(p0, p1)
}
func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketDeal, error) {
return *new(map[string]api.MarketDeal), ErrNotSupported
func (s *FullNodeStub) StateMarketDeals(p0 context.Context, p1 types.TipSetKey) (map[string]*api.MarketDeal, error) {
return *new(map[string]*api.MarketDeal), ErrNotSupported
}
func (s *FullNodeStruct) StateMarketParticipants(p0 context.Context, p1 types.TipSetKey) (map[string]api.MarketBalance, error) {
@ -1924,15 +1954,15 @@ func (s *FullNodeStub) StateMinerFaults(p0 context.Context, p1 address.Address,
return *new(bitfield.BitField), ErrNotSupported
}
func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
func (s *FullNodeStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) {
if s.Internal.StateMinerInfo == nil {
return *new(miner.MinerInfo), ErrNotSupported
return *new(api.MinerInfo), ErrNotSupported
}
return s.Internal.StateMinerInfo(p0, p1, p2)
}
func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
return *new(miner.MinerInfo), ErrNotSupported
func (s *FullNodeStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) {
return *new(api.MinerInfo), ErrNotSupported
}
func (s *FullNodeStruct) StateMinerInitialPledgeCollateral(p0 context.Context, p1 address.Address, p2 miner.SectorPreCommitInfo, p3 types.TipSetKey) (types.BigInt, error) {
@ -2100,14 +2130,14 @@ func (s *FullNodeStub) StateSearchMsgLimited(p0 context.Context, p1 cid.Cid, p2
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) {
func (s *FullNodeStruct) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) {
if s.Internal.StateSectorExpiration == nil {
return nil, ErrNotSupported
}
return s.Internal.StateSectorExpiration(p0, p1, p2, p3)
}
func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorExpiration, error) {
func (s *FullNodeStub) StateSectorExpiration(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorExpiration, error) {
return nil, ErrNotSupported
}
@ -2122,14 +2152,14 @@ func (s *FullNodeStub) StateSectorGetInfo(p0 context.Context, p1 address.Address
return nil, ErrNotSupported
}
func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) {
func (s *FullNodeStruct) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) {
if s.Internal.StateSectorPartition == nil {
return nil, ErrNotSupported
}
return s.Internal.StateSectorPartition(p0, p1, p2, p3)
}
func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorLocation, error) {
func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) {
return nil, ErrNotSupported
}
@ -2529,6 +2559,17 @@ func (s *GatewayStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadChange,
return nil, ErrNotSupported
}
func (s *GatewayStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
if s.Internal.ChainPutObj == nil {
return ErrNotSupported
}
return s.Internal.ChainPutObj(p0, p1)
}
func (s *GatewayStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
return ErrNotSupported
}
func (s *GatewayStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
if s.Internal.ChainReadObj == nil {
return *new([]byte), ErrNotSupported
@ -2683,15 +2724,15 @@ func (s *GatewayStub) StateMarketStorageDeal(p0 context.Context, p1 abi.DealID,
return nil, ErrNotSupported
}
func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
func (s *GatewayStruct) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) {
if s.Internal.StateMinerInfo == nil {
return *new(miner.MinerInfo), ErrNotSupported
return *new(api.MinerInfo), ErrNotSupported
}
return s.Internal.StateMinerInfo(p0, p1, p2)
}
func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (miner.MinerInfo, error) {
return *new(miner.MinerInfo), ErrNotSupported
func (s *GatewayStub) StateMinerInfo(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (api.MinerInfo, error) {
return *new(api.MinerInfo), ErrNotSupported
}
func (s *GatewayStruct) StateMinerPower(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*api.MinerPower, error) {

View File

@ -17,22 +17,23 @@ import (
auth "github.com/filecoin-project/go-jsonrpc/auth"
abi "github.com/filecoin-project/go-state-types/abi"
big "github.com/filecoin-project/go-state-types/big"
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
paych "github.com/filecoin-project/go-state-types/builtin/v8/paych"
crypto "github.com/filecoin-project/go-state-types/crypto"
dline "github.com/filecoin-project/go-state-types/dline"
network "github.com/filecoin-project/go-state-types/network"
api "github.com/filecoin-project/lotus/api"
apitypes "github.com/filecoin-project/lotus/api/types"
v0api "github.com/filecoin-project/lotus/api/v0api"
miner "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
types "github.com/filecoin-project/lotus/chain/types"
alerting "github.com/filecoin-project/lotus/journal/alerting"
marketevents "github.com/filecoin-project/lotus/markets/loggers"
dtypes "github.com/filecoin-project/lotus/node/modules/dtypes"
imports "github.com/filecoin-project/lotus/node/repo/imports"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
gomock "github.com/golang/mock/gomock"
uuid "github.com/google/uuid"
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"
@ -377,6 +378,20 @@ func (mr *MockFullNodeMockRecorder) ChainNotify(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainNotify", reflect.TypeOf((*MockFullNode)(nil).ChainNotify), arg0)
}
// ChainPutObj mocks base method.
func (m *MockFullNode) ChainPutObj(arg0 context.Context, arg1 blocks.Block) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ChainPutObj", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ChainPutObj indicates an expected call of ChainPutObj.
func (mr *MockFullNodeMockRecorder) ChainPutObj(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutObj", reflect.TypeOf((*MockFullNode)(nil).ChainPutObj), arg0, arg1)
}
// ChainReadObj mocks base method.
func (m *MockFullNode) ChainReadObj(arg0 context.Context, arg1 cid.Cid) ([]byte, error) {
m.ctrl.T.Helper()
@ -2155,6 +2170,21 @@ func (mr *MockFullNodeMockRecorder) StateAccountKey(arg0, arg1, arg2 interface{}
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateAccountKey", reflect.TypeOf((*MockFullNode)(nil).StateAccountKey), arg0, arg1, arg2)
}
// StateActorCodeCIDs mocks base method.
func (m *MockFullNode) StateActorCodeCIDs(arg0 context.Context, arg1 network.Version) (map[string]cid.Cid, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateActorCodeCIDs", arg0, arg1)
ret0, _ := ret[0].(map[string]cid.Cid)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// StateActorCodeCIDs indicates an expected call of StateActorCodeCIDs.
func (mr *MockFullNodeMockRecorder) StateActorCodeCIDs(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateActorCodeCIDs", reflect.TypeOf((*MockFullNode)(nil).StateActorCodeCIDs), arg0, arg1)
}
// StateAllMinerFaults mocks base method.
func (m *MockFullNode) StateAllMinerFaults(arg0 context.Context, arg1 abi.ChainEpoch, arg2 types.TipSetKey) ([]*api.Fault, error) {
m.ctrl.T.Helper()
@ -2411,10 +2441,10 @@ func (mr *MockFullNodeMockRecorder) StateMarketBalance(arg0, arg1, arg2 interfac
}
// StateMarketDeals mocks base method.
func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]api.MarketDeal, error) {
func (m *MockFullNode) StateMarketDeals(arg0 context.Context, arg1 types.TipSetKey) (map[string]*api.MarketDeal, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMarketDeals", arg0, arg1)
ret0, _ := ret[0].(map[string]api.MarketDeal)
ret0, _ := ret[0].(map[string]*api.MarketDeal)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -2516,10 +2546,10 @@ func (mr *MockFullNodeMockRecorder) StateMinerFaults(arg0, arg1, arg2 interface{
}
// StateMinerInfo mocks base method.
func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (miner.MinerInfo, error) {
func (m *MockFullNode) StateMinerInfo(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (api.MinerInfo, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMinerInfo", arg0, arg1, arg2)
ret0, _ := ret[0].(miner.MinerInfo)
ret0, _ := ret[0].(api.MinerInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -2531,7 +2561,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerInfo(arg0, arg1, arg2 interface{})
}
// StateMinerInitialPledgeCollateral mocks base method.
func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
func (m *MockFullNode) StateMinerInitialPledgeCollateral(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMinerInitialPledgeCollateral", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(big.Int)
@ -2576,7 +2606,7 @@ func (mr *MockFullNodeMockRecorder) StateMinerPower(arg0, arg1, arg2 interface{}
}
// StateMinerPreCommitDepositForPower mocks base method.
func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner0.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
func (m *MockFullNode) StateMinerPreCommitDepositForPower(arg0 context.Context, arg1 address.Address, arg2 miner.SectorPreCommitInfo, arg3 types.TipSetKey) (big.Int, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateMinerPreCommitDepositForPower", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(big.Int)
@ -2756,10 +2786,10 @@ func (mr *MockFullNodeMockRecorder) StateSearchMsgLimited(arg0, arg1, arg2 inter
}
// StateSectorExpiration mocks base method.
func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorExpiration, error) {
func (m *MockFullNode) StateSectorExpiration(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorExpiration, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateSectorExpiration", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(*miner.SectorExpiration)
ret0, _ := ret[0].(*miner0.SectorExpiration)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@ -2786,10 +2816,10 @@ func (mr *MockFullNodeMockRecorder) StateSectorGetInfo(arg0, arg1, arg2, arg3 in
}
// StateSectorPartition mocks base method.
func (m *MockFullNode) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorLocation, error) {
func (m *MockFullNode) StateSectorPartition(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner0.SectorLocation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "StateSectorPartition", arg0, arg1, arg2, arg3)
ret0, _ := ret[0].(*miner.SectorLocation)
ret0, _ := ret[0].(*miner0.SectorLocation)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@ -352,4 +352,8 @@ func (w *WrapperV1Full) ClientQueryAsk(ctx context.Context, p peer.ID, miner add
return a.Response, nil
}
func (w *WrapperV1Full) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
return w.StateGetBeaconEntry(ctx, epoch)
}
var _ FullNode = &WrapperV1Full{}

View File

@ -11,6 +11,7 @@ import (
type ChainIO interface {
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
ChainHasObj(context.Context, cid.Cid) (bool, error)
ChainPutObj(context.Context, blocks.Block) error
}
type apiBlockstore struct {
@ -49,12 +50,18 @@ func (a *apiBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
return len(bb), nil
}
func (a *apiBlockstore) Put(context.Context, blocks.Block) error {
return xerrors.New("not supported")
func (a *apiBlockstore) Put(ctx context.Context, block blocks.Block) error {
return a.api.ChainPutObj(ctx, block)
}
func (a *apiBlockstore) PutMany(context.Context, []blocks.Block) error {
return xerrors.New("not supported")
func (a *apiBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error {
for _, block := range blocks {
err := a.api.ChainPutObj(ctx, block)
if err != nil {
return err
}
}
return nil
}
func (a *apiBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {

26
build/actors/README.md Normal file
View File

@ -0,0 +1,26 @@
# Bundles
This directory includes the actors bundles for each release. Each actor bundle is a zstd compressed
tarfile containing one bundle per network type. These tarfiles are subsequently embedded in the
lotus binary.
## Updating
To update, run the `./pack.sh` script. For example, the following will pack the [builtin actors release](https://github.com/filecoin-project/builtin-actors/releases) `dev/20220602` into the `v8` tarfile.
```bash
./pack.sh v8 dev/20220602
```
This will:
1. Download the actors bundles and pack them into the appropriate tarfile (`$VERSION.tar.zst`).
2. Run `make bundle-gen` in the top-level directory to regenerate the bundle metadata file for _all_ network versions (all `*.tar.zst` files in this directory).
## Overriding
To build a bundle, but specify a different release/tag for a specific network, append `$network=$alternative_release` on the command line. For example:
```bash
./pack.sh v8 dev/20220602 mainnet=v8.0.0 calibrationnet=v8.0.0-rc.1
```

55
build/actors/pack.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
NETWORKS=(devnet mainnet caterpillarnet butterflynet testing testing-fake-proofs calibrationnet)
set -e
if [[ $# -lt 2 ]]; then
echo "Usage: $0 VERSION RELEASE [NETWORK=RELEASE_OVERRIDE]..." >&2
echo "expected at least two arguments, an actors version (e.g., v8), an actors release, and any number of release overrides." >&2
exit 1
fi
VERSION="$1" # actors version
RELEASE="$2" # actors release name
RELEASE_OVERRIDES=("${@:3}")
echo "Downloading bundles for actors version ${VERSION} release ${RELEASE}"
echo "With release overrides ${RELEASE_OVERRIDES[*]}"
TARGET_FILE="$(pwd)/${VERSION}.tar.zst"
WORKDIR=$(mktemp -d -t "actor-bundles-${VERSION}.XXXXXXXXXX")
trap 'rm -rf -- "$WORKDIR"' EXIT
encode_release() {
jq -rn --arg release "$1" '$release | @uri'
}
pushd "${WORKDIR}"
for network in "${NETWORKS[@]}"; do
release="$RELEASE"
# Ideally, we'd use an associative array (map). But that's not supported on macos.
for override in "${RELEASE_OVERRIDES[@]}"; do
if [[ "${network}" = "${override%%=*}" ]]; then
release="${override#*=}"
break
fi
done
encoded_release="$(encode_release "$release")"
echo "Downloading $release for network $network."
wget "https://github.com/filecoin-project/builtin-actors/releases/download/${encoded_release}/builtin-actors-${network}"{.car,.sha256}
done
echo "Checking the checksums..."
sha256sum -c -- *.sha256
echo "Packing..."
rm -f -- "$TARGET_FILE"
tar -cf "$TARGET_FILE" --use-compress-program "zstd -19" -- *.car
popd
echo "Generating metadata..."
make -C ../../ bundle-gen

BIN
build/actors/v8.tar.zst Normal file

Binary file not shown.

View File

@ -1,2 +1,2 @@
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWFHDtFx7CVTy4xoCDutVo1cScvSnQjDeaM8UzwVS1qwkh
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWKt8cwpkiumkT8x32c3YFxsPRwhV5J8hCYPn9mhUmcAXt
/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWSUZhAY3eyoPUboJ1ZWe4dNPFWTr1EPoDjbTDSAN15uhY
/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWDfvNrSRVGWAGbn3sm9C8z98W2x25qCZjaXGHXmGiH24e

View File

@ -1,2 +1,2 @@
/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWLGPq9JL1xwL6gHok7HSNxtK1Q5kyfg4Hk69ifRPghn4i
/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWFYS1f31zafv8mqqYu8U3hEqYvaZ6avWzYU3BmZdpyH3h
/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWDY249nj6gxSiBTocNBnkbBBvnfPgkxq5SBUVrccjwRnr
/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWCwFsKt4NyoJQk7vjiACXL9LznBWANXKjCebKJ7MHh3h4

263
build/builtin_actors.go Normal file
View File

@ -0,0 +1,263 @@
package build
import (
"archive/tar"
"context"
"embed"
"fmt"
"io"
"os"
"path"
"sort"
"strconv"
"strings"
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/DataDog/zstd"
"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/ipld/go-car"
"golang.org/x/xerrors"
)
//go:embed actors/*.tar.zst
var embeddedBuiltinActorReleases embed.FS
func init() {
if BundleOverrides == nil {
BundleOverrides = make(map[actors.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
}
if err := loadManifests(NetworkBundle); err != nil {
panic(err)
}
}
// UseNetworkBundle switches to a different network bundle, by name.
func UseNetworkBundle(netw string) error {
if NetworkBundle == netw {
return nil
}
if err := loadManifests(netw); err != nil {
return err
}
NetworkBundle = netw
return nil
}
func loadManifests(netw string) error {
overridden := make(map[actors.Version]struct{})
var newMetadata []*BuiltinActorsMetadata
// First, prefer overrides.
for av, path := range BundleOverrides {
root, actorCids, err := readBundleManifestFromFile(path)
if err != nil {
return err
}
newMetadata = append(newMetadata, &BuiltinActorsMetadata{
Network: netw,
Version: av,
ManifestCid: root,
Actors: actorCids,
})
overridden[av] = struct{}{}
}
// Then load embedded bundle metadata.
for _, meta := range EmbeddedBuiltinActorsMetadata {
if meta.Network != netw {
continue
}
if _, ok := overridden[meta.Version]; ok {
continue
}
newMetadata = append(newMetadata, meta)
}
actors.ClearManifests()
for _, meta := range newMetadata {
actors.RegisterManifest(meta.Version, meta.ManifestCid, meta.Actors)
}
return nil
}
type BuiltinActorsMetadata struct {
Network string
Version actors.Version
ManifestCid cid.Cid
Actors map[string]cid.Cid
}
// ReadEmbeddedBuiltinActorsMetadata reads the metadata from the embedded built-in actor bundles.
// There should be no need to call this method as the result is cached in the
// `EmbeddedBuiltinActorsMetadata` variable on `make gen`.
func ReadEmbeddedBuiltinActorsMetadata() ([]*BuiltinActorsMetadata, error) {
files, err := embeddedBuiltinActorReleases.ReadDir("actors")
if err != nil {
return nil, xerrors.Errorf("failed to read embedded bundle directory: %s", err)
}
var bundles []*BuiltinActorsMetadata
for _, dirent := range files {
name := dirent.Name()
b, err := readEmbeddedBuiltinActorsMetadata(name)
if err != nil {
return nil, err
}
bundles = append(bundles, b...)
}
// Sort by network, then by bundle.
sort.Slice(bundles, func(i, j int) bool {
if bundles[i].Network == bundles[j].Network {
return bundles[i].Version < bundles[j].Version
}
return bundles[i].Network < bundles[j].Network
})
return bundles, nil
}
func readEmbeddedBuiltinActorsMetadata(bundle string) ([]*BuiltinActorsMetadata, error) {
const (
archiveExt = ".tar.zst"
bundleExt = ".car"
bundlePrefix = "builtin-actors-"
)
if !strings.HasPrefix(bundle, "v") {
return nil, xerrors.Errorf("bundle bundle '%q' doesn't start with a 'v'", bundle)
}
if !strings.HasSuffix(bundle, archiveExt) {
return nil, xerrors.Errorf("bundle bundle '%q' doesn't end with '%s'", bundle, archiveExt)
}
version, err := strconv.ParseInt(bundle[1:len(bundle)-len(archiveExt)], 10, 0)
if err != nil {
return nil, xerrors.Errorf("failed to parse actors version from bundle '%q': %s", bundle, err)
}
fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("actors/%s", bundle))
if err != nil {
return nil, err
}
defer fi.Close() //nolint
uncompressed := zstd.NewReader(fi)
defer uncompressed.Close() //nolint
var bundles []*BuiltinActorsMetadata
tarReader := tar.NewReader(uncompressed)
for {
header, err := tarReader.Next()
switch err {
case io.EOF:
return bundles, nil
case nil:
default:
return nil, err
}
// Read the network name from the bundle name.
name := path.Base(header.Name)
if !strings.HasSuffix(name, bundleExt) {
return nil, xerrors.Errorf("expected bundle to end with .car: %s", name)
}
if !strings.HasPrefix(name, bundlePrefix) {
return nil, xerrors.Errorf("expected bundle to end with .car: %s", name)
}
name = name[len(bundlePrefix) : len(name)-len(bundleExt)]
// Load the bundle.
root, actorCids, err := readBundleManifest(tarReader)
if err != nil {
return nil, xerrors.Errorf("error loading builtin actors bundle: %w", err)
}
bundles = append(bundles, &BuiltinActorsMetadata{
Network: name,
Version: actors.Version(version),
ManifestCid: root,
Actors: actorCids,
})
}
}
func readBundleManifestFromFile(path string) (cid.Cid, map[string]cid.Cid, error) {
fi, err := os.Open(path)
if err != nil {
return cid.Undef, nil, err
}
defer fi.Close() //nolint
return readBundleManifest(fi)
}
func readBundleManifest(r io.Reader) (cid.Cid, map[string]cid.Cid, error) {
// Load the bundle.
bs := blockstore.NewMemory()
hdr, err := car.LoadCar(context.Background(), bs, r)
if err != nil {
return cid.Undef, nil, xerrors.Errorf("error loading builtin actors bundle: %w", err)
}
if len(hdr.Roots) != 1 {
return cid.Undef, nil, xerrors.Errorf("expected one root when loading actors bundle, got %d", len(hdr.Roots))
}
root := hdr.Roots[0]
actorCids, err := actors.ReadManifest(context.Background(), adt.WrapStore(context.Background(), cbor.NewCborStore(bs)), root)
if err != nil {
return cid.Undef, nil, err
}
// Make sure we have all the actors.
for name, c := range actorCids {
if has, err := bs.Has(context.Background(), c); err != nil {
return cid.Undef, nil, xerrors.Errorf("got an error when checking that the bundle has the actor %q: %w", name, err)
} else if !has {
return cid.Undef, nil, xerrors.Errorf("actor %q missing from bundle", name)
}
}
return root, actorCids, nil
}
// GetEmbeddedBuiltinActorsBundle returns the builtin-actors bundle for the given actors version.
func GetEmbeddedBuiltinActorsBundle(version actors.Version) ([]byte, bool) {
fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("actors/v%d.tar.zst", version))
if err != nil {
return nil, false
}
defer fi.Close() //nolint
uncompressed := zstd.NewReader(fi)
defer uncompressed.Close() //nolint
tarReader := tar.NewReader(uncompressed)
targetFileName := fmt.Sprintf("builtin-actors-%s.car", NetworkBundle)
for {
header, err := tarReader.Next()
switch err {
case io.EOF:
return nil, false
case nil:
default:
panic(err)
}
if header.Name != targetFileName {
continue
}
car, err := io.ReadAll(tarReader)
if err != nil {
panic(err)
}
return car, true
}
}

128
build/builtin_actors_gen.go Normal file
View File

@ -0,0 +1,128 @@
// WARNING: This file has automatically been generated
package build
import (
"github.com/ipfs/go-cid"
)
var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMetadata{{
Network: "butterflynet",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacedvaarfyh6q3bk4dyzux46ednlace2ckxp5nbyn6mb3da2apqn6sk"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaceavzeu4gqte7o33vr4htiaapiwpfq6p26tgdkqla2baqhmiqswfso"),
"cron": MustParseCid("bafk2bzacech35onpqxep4yox36k7sr4mj4bch54s3i4b3yyaustrbo5xwfbfs"),
"init": MustParseCid("bafk2bzaceahxin3sf5f6ude5j6we4yeqlg66s5qe4tu7lwp26jcg7yp2ns6hi"),
"multisig": MustParseCid("bafk2bzacectfmzjtniypgl4whm42sws5aupihqgfikwsr7p5yoq3bmqaogldi"),
"paymentchannel": MustParseCid("bafk2bzacecbwu54ce5mjgp2pqxyj6kpn2vlgiu5wv2lj2byjiegxnn3infd5i"),
"reward": MustParseCid("bafk2bzacecskkbhe6c4ud5jt62wg4w7j7shj6xdwoyic74s5y6pgywxxvnw72"),
"storagemarket": MustParseCid("bafk2bzacebycxcwwm7hwhuhpasaskil2kxaqb7tins7azdvvm72rorlciuysi"),
"storageminer": MustParseCid("bafk2bzacecgx3etor5m6lahpmjdwqnryutqe6naiurfhgsju72rd4nqssutbg"),
"storagepower": MustParseCid("bafk2bzaceayvy6xyp5cwtngm457c5hssvihidppgq3o7gy3dlmhgor3yzujoc"),
"system": MustParseCid("bafk2bzacec6xctjxybp7r3kkhase56o6jsaiua7ure5ttu2xfuojt4jhlsoa6"),
"verifiedregistry": MustParseCid("bafk2bzacec2hcqlqcfacylfcrhhliwkisvh4y3adwt47xkf2gdvodwu6ccepc"),
},
}, {
Network: "calibrationnet",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacedrdn6z3z7xz7lx4wll3tlgktirhllzqxb766dxpaqp3ukxsjfsba"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacecruossn66xqbeutqx5r4k2kjzgd43frmwd4qkw6haez44ubvvpxo"),
"cron": MustParseCid("bafk2bzaceaxlezmclw5ugldhhtfgvn7yztux45scqik3ez4yhwiqhg5ssib44"),
"init": MustParseCid("bafk2bzaceadyfilb22bcvzvnpzbg2lyg6npmperyq6es2brvzjdh5rmywc4ry"),
"multisig": MustParseCid("bafk2bzacec66wmb4kohuzvuxsulhcgiwju7sqkldwfpmmgw7dbbwgm5l2574q"),
"paymentchannel": MustParseCid("bafk2bzaceblot4pemhfgwb3lceellwrpgxaqkpselzbpqu32maffpopdunlha"),
"reward": MustParseCid("bafk2bzaceayah37uvj7brl5no4gmvmqbmtndh5raywuts7h6tqbgbq2ge7dhu"),
"storagemarket": MustParseCid("bafk2bzacebotg5coqnglzsdrqxtkqk2eq4krxt6zvds3i3vb2yejgxhexl2n6"),
"storageminer": MustParseCid("bafk2bzacea6rabflc7kpwr6y4lzcqsnuahr4zblyq3rhzrrsfceeiw2lufrb4"),
"storagepower": MustParseCid("bafk2bzacecpwr4mynn55bg5hrlns3osvg7sty3rca6zlai3vl52vbbjk7ulfa"),
"system": MustParseCid("bafk2bzaceaqrkllksxv2jsfgjvmuewx5vbzrammw5mdscod6gkdr3ijih2q64"),
"verifiedregistry": MustParseCid("bafk2bzaceaihibfu625lbtzdp3tcftscshrmbgghgrc7kzqhxn4455pycpdkm"),
},
}, {
Network: "caterpillarnet",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacecsmunz6fzhg53276cixadn6ybhcnzkgbw3la5hf342tfxsdoet26"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzaced6yatl4y2nmqmx2h3btk3np6oelyw2yt57elsb2nfmm33fadzt2g"),
"cron": MustParseCid("bafk2bzacebrujytq4u7g62jbz52gio5k2s6rhruty7nt4eqq7ygitzxuee5zi"),
"init": MustParseCid("bafk2bzacedajw5ptnwfdidv6m4rvd4c2m7dve4lhfbawygl5idkalcxbiiudu"),
"multisig": MustParseCid("bafk2bzaceb3kh5hjh6eebb5236xp7crn2owyyo7irap6sy4ns76uc7om6pxuy"),
"paymentchannel": MustParseCid("bafk2bzacedl5am53e4mtxpzligcycxvmkolfkhfiuavww2dq3ukgaqwowj7vw"),
"reward": MustParseCid("bafk2bzacecbswf242j43cymj3wh7nszawwlofv6z6z4qipb5d32hpxdhxywng"),
"storagemarket": MustParseCid("bafk2bzaceca5ersmg3zxf2cztgktq33bmfjuiqjcjlktwj52xyrpujbdsqvek"),
"storageminer": MustParseCid("bafk2bzacedg2fqaq5udfp3h6cxhywm27dgagxtselfgkyyyunqq362eaxpdm4"),
"storagepower": MustParseCid("bafk2bzaceb3dm2i2q323e6iozo3r6pyded645vvlpf537kga2a3hu5x7abgl4"),
"system": MustParseCid("bafk2bzacebu47th3xerlngqavlipb6cfu2utljkxxzgadc3totogto2tmx2jc"),
"verifiedregistry": MustParseCid("bafk2bzaceci3niq3rmbcmepgn27zvlgci6d5t4dvthx3pbmmx3wcu5elova6i"),
},
}, {
Network: "devnet",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacedq7tuibavyqxzkq4uybjj7ly22eu42mjkoehwn5d47xfunmtjm4k"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacea4tlgnp7m6tlldpz3termlwxlnyq24nwd4zdzv4r6nsjuaktuuzc"),
"cron": MustParseCid("bafk2bzacecgrlf3vg3mufwovddlbgclhpnpp3jftr46stssh3crd3pyljc37w"),
"init": MustParseCid("bafk2bzacedarbnovmucppbjkcwsxopludrj5ttmtm7mzfqsugmxdnqevqso7o"),
"multisig": MustParseCid("bafk2bzaced4gcxjwy6garxwfw6y5a2k4jewj4t5nzopjy4qwnimhjtnsgo3ss"),
"paymentchannel": MustParseCid("bafk2bzaceb3isfguytt6cs4xecyoonbhhekmngfbap2msggbwyde7zch3a6w4"),
"reward": MustParseCid("bafk2bzacedn3fkp27ys5dxn4pwqdq2atj2x6cyezxuekdorvjwi7zazirgvgy"),
"storagemarket": MustParseCid("bafk2bzacecw57fpkqesfhi5g3nr4csy4oy7oc42wmwjuis6l7ijniolo4rt2k"),
"storageminer": MustParseCid("bafk2bzacebze3elvppssc6v5457ukszzy6ndrg6xgaojfsqfbbtg3xfwo4rbs"),
"storagepower": MustParseCid("bafk2bzaceb45l6zhgc34n6clz7xnvd7ek55bhw46q25umuje34t6kroix6hh6"),
"system": MustParseCid("bafk2bzacecf7eta2stfd3cnuxzervd33imbvlaqq6b5tsho7pxmhifrybreru"),
"verifiedregistry": MustParseCid("bafk2bzaceaajgtglewgitshgdi2nzrvq7eihjtyqj5yiamesqun2hujl3xev2"),
},
}, {
Network: "mainnet",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacebogjbpiemi7npzxchgcjjki3tfxon4ims55obfyfleqntteljsea"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacedudbf7fc5va57t3tmo63snmt3en4iaidv4vo3qlyacbxaa6hlx6y"),
"cron": MustParseCid("bafk2bzacecqb3eolfurehny6yp7tgmapib4ocazo5ilkopjce2c7wc2bcec62"),
"init": MustParseCid("bafk2bzaceaipvjhoxmtofsnv3aj6gj5ida4afdrxa4ewku2hfipdlxpaektlw"),
"multisig": MustParseCid("bafk2bzacebhldfjuy4o5v7amrhp5p2gzv2qo5275jut4adnbyp56fxkwy5fag"),
"paymentchannel": MustParseCid("bafk2bzacebalad3f72wyk7qyilvfjijcwubdspytnyzlrhvn73254gqis44rq"),
"reward": MustParseCid("bafk2bzacecwzzxlgjiavnc3545cqqil3cmq4hgpvfp2crguxy2pl5ybusfsbe"),
"storagemarket": MustParseCid("bafk2bzacediohrxkp2fbsl4yj4jlupjdkgsiwqb4zuezvinhdo2j5hrxco62q"),
"storageminer": MustParseCid("bafk2bzacecgnynvd3tene3bvqoknuspit56canij5bpra6wl4mrq2mxxwriyu"),
"storagepower": MustParseCid("bafk2bzacebjvqva6ppvysn5xpmiqcdfelwbbcxmghx5ww6hr37cgred6dyrpm"),
"system": MustParseCid("bafk2bzacedwq5uppsw7vp55zpj7jdieizirmldceehu6wvombw3ixq2tcq57w"),
"verifiedregistry": MustParseCid("bafk2bzaceb3zbkjz3auizmoln2unmxep7dyfcmsre64vnqfhdyh7rkqfoxlw4"),
},
}, {
Network: "testing",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacedkjpqx27wgsvfxzuxfvixuxtbpt2y6yo6igcasez6gqiowron776"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacebmfbtdj5vruje5auacrhhprcjdd6uclhukb7je7t2f6ozfcgqlu2"),
"cron": MustParseCid("bafk2bzacea4gwsbeux7z4yxvpkxpco77iyxijoyqaoikofrxdewunwh3unjem"),
"init": MustParseCid("bafk2bzacecqk6zlwein7tzy7yrrhtj4pzavrkofgpyxvvw5ktr3w4x4ml4lis"),
"multisig": MustParseCid("bafk2bzacea5zp2g6ag5qfuro7zw6kyku2swxs57wjxncaaxbih5iqflqy4ghm"),
"paymentchannel": MustParseCid("bafk2bzaced47dbtbygmfwnyfsp5iihzhhdmnkpuyc5nlnfgc4mkkvlsgvj2do"),
"reward": MustParseCid("bafk2bzacecmcagk32pzdzfg7piobzqhlgla37x3g7jjzyndlz7mqdno2zulfi"),
"storagemarket": MustParseCid("bafk2bzaceballmgd7puoixfwm65f5shi3kzreqdisowtsoufbvduwytydqotw"),
"storageminer": MustParseCid("bafk2bzacebucngwdhxtod2gvv52adtdssafyg43znsoy4omtfkkqe2hbhvxeu"),
"storagepower": MustParseCid("bafk2bzaceakxw5wx3rtqoarrdbzhmxkufg2kx7n34xotzxzacvvbe5iqggmsa"),
"system": MustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"),
"verifiedregistry": MustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"),
},
}, {
Network: "testing-fake-proofs",
Version: 8,
ManifestCid: MustParseCid("bafy2bzacecd3lb5v6tzjylnhnrhexslssyaozy6hogzgpkhztoe76exbrgrug"),
Actors: map[string]cid.Cid{
"account": MustParseCid("bafk2bzacebmfbtdj5vruje5auacrhhprcjdd6uclhukb7je7t2f6ozfcgqlu2"),
"cron": MustParseCid("bafk2bzacea4gwsbeux7z4yxvpkxpco77iyxijoyqaoikofrxdewunwh3unjem"),
"init": MustParseCid("bafk2bzacebwkqd6e7gdphfzw2kdmbokdh2bly6fvzgfopxzy7quq4l67gmkks"),
"multisig": MustParseCid("bafk2bzacea5zp2g6ag5qfuro7zw6kyku2swxs57wjxncaaxbih5iqflqy4ghm"),
"paymentchannel": MustParseCid("bafk2bzaced47dbtbygmfwnyfsp5iihzhhdmnkpuyc5nlnfgc4mkkvlsgvj2do"),
"reward": MustParseCid("bafk2bzacecmcagk32pzdzfg7piobzqhlgla37x3g7jjzyndlz7mqdno2zulfi"),
"storagemarket": MustParseCid("bafk2bzacecxqgajcaednamgolc6wc3lzbjc6tz5alfrbwqez2y3c372vts6dg"),
"storageminer": MustParseCid("bafk2bzaceaqwxllfycpq6decpsnkqjdeycpysh5acubonjae7u3wciydlkvki"),
"storagepower": MustParseCid("bafk2bzaceddmeolsokbxgcr25cuf2skrobtmmoof3dmqfpcfp33lmw63oikvm"),
"system": MustParseCid("bafk2bzaced6kjkbv7lrb2qwq5we2hqaxc6ztch5p52g27qtjy45zdemsk4b7m"),
"verifiedregistry": MustParseCid("bafk2bzacectzxvtoselhnzsair5nv6k5vokvegnht6z2lfee4p3xexo4kg4m6"),
},
}}

View File

@ -0,0 +1,33 @@
package build_test
import (
"testing"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/stretchr/testify/require"
)
// Test that the embedded metadata is correct.
func TestEmbeddedMetadata(t *testing.T) {
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
require.NoError(t, err)
require.Equal(t, metadata, build.EmbeddedBuiltinActorsMetadata)
}
// Test that we're registering the manifest correctly.
func TestRegistration(t *testing.T) {
manifestCid, found := actors.GetManifest(actors.Version8)
require.True(t, found)
require.True(t, manifestCid.Defined())
for _, key := range actors.GetBuiltinActorsKeys() {
actorCid, found := actors.GetActorCodeID(actors.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, key, name)
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,13 +11,18 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
const BootstrappersFile = ""
const GenesisFile = ""
const GenesisNetworkVersion = network.Version15
var NetworkBundle = "devnet"
var BundleOverrides map[actors.Version]string
const GenesisNetworkVersion = network.Version16
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
@ -48,6 +53,7 @@ var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
var UpgradeChocolateHeight = abi.ChainEpoch(-17)
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
var UpgradeSkyrHeight = abi.ChainEpoch(-19)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
@ -99,6 +105,7 @@ func init() {
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight)
BuildType |= Build2k

View File

@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/ipfs/go-cid"
@ -16,7 +17,10 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
const GenesisNetworkVersion = network.Version14
const GenesisNetworkVersion = network.Version15
var NetworkBundle = "butterflynet"
var BundleOverrides map[actors.Version]string
const BootstrappersFile = "butterflynet.pi"
const GenesisFile = "butterflynet.car"
@ -42,7 +46,9 @@ const UpgradeTurboHeight = -15
const UpgradeHyperdriveHeight = -16
const UpgradeChocolateHeight = -17
const UpgradeOhSnapHeight = 240
const UpgradeOhSnapHeight = -18
const UpgradeSkyrHeight = abi.ChainEpoch(50)
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg512MiBV1,

View File

@ -7,6 +7,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/ipfs/go-cid"
@ -18,6 +19,9 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
const GenesisNetworkVersion = network.Version0
var NetworkBundle = "calibrationnet"
var BundleOverrides map[actors.Version]string
const BootstrappersFile = "calibnet.pi"
const GenesisFile = "calibnet.car"
@ -57,6 +61,9 @@ const UpgradeChocolateHeight = 312746
// 2022-02-10T19:23:00Z
const UpgradeOhSnapHeight = 682006
// 2022-06-16T17:30:00Z
const UpgradeSkyrHeight = 1044660
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
abi.RegisteredSealProof_StackedDrg64GiBV1,

View File

@ -7,19 +7,22 @@ import (
"os"
"strconv"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/ipfs/go-cid"
)
var NetworkBundle = "caterpillarnet"
var BundleOverrides map[actors.Version]string
const BootstrappersFile = "interopnet.pi"
const GenesisFile = "interopnet.car"
const GenesisNetworkVersion = network.Version13
const GenesisNetworkVersion = network.Version15
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
@ -48,6 +51,7 @@ 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 DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
@ -98,6 +102,9 @@ func init() {
UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight)
UpgradeTurboHeight = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeTurboHeight)
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
UpgradeSkyrHeight = getUpgradeHeight("LOTUS_SKYR_HEIGHT", UpgradeSkyrHeight)
BuildType |= BuildInteropnet
SetAddressNetwork(address.Testnet)

View File

@ -1,5 +1,5 @@
//go:build !debug && !2k && !testground && !calibnet && !nerpanet && !butterflynet && !interopnet
// +build !debug,!2k,!testground,!calibnet,!nerpanet,!butterflynet,!interopnet
//go:build !debug && !2k && !testground && !calibnet && !butterflynet && !interopnet
// +build !debug,!2k,!testground,!calibnet,!butterflynet,!interopnet
package build
@ -8,6 +8,7 @@ import (
"os"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
@ -19,6 +20,11 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
UpgradeSmokeHeight: DrandMainnet,
}
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
const GenesisNetworkVersion = network.Version0
const BootstrappersFile = "mainnet.pi"
@ -68,7 +74,10 @@ const UpgradeHyperdriveHeight = 892800
const UpgradeChocolateHeight = 1231620
// 2022-03-01T15:00:00Z
var UpgradeOhSnapHeight = abi.ChainEpoch(1594680)
const UpgradeOhSnapHeight = 1594680
// 2022-07-06T14:00:00Z
var UpgradeSkyrHeight = abi.ChainEpoch(1960320)
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
@ -83,8 +92,8 @@ func init() {
SetAddressNetwork(address.Mainnet)
}
if os.Getenv("LOTUS_DISABLE_SNAPDEALS") == "1" {
UpgradeOhSnapHeight = math.MaxInt64
if os.Getenv("LOTUS_DISABLE_SKYR") == "1" {
UpgradeSkyrHeight = math.MaxInt64
}
Devnet = false

View File

@ -1,93 +0,0 @@
//go:build nerpanet
// +build nerpanet
package build
import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/ipfs/go-cid"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
const GenesisNetworkVersion = network.Version0
const BootstrappersFile = "nerpanet.pi"
const GenesisFile = "nerpanet.car"
const UpgradeBreezeHeight = -1
const BreezeGasTampingDuration = 0
const UpgradeSmokeHeight = -1
const UpgradeIgnitionHeight = -2
const UpgradeRefuelHeight = -3
const UpgradeLiftoffHeight = -5
const UpgradeAssemblyHeight = 30 // critical: the network can bootstrap from v1 only
const UpgradeTapeHeight = 60
const UpgradeKumquatHeight = 90
const UpgradeCalicoHeight = 100
const UpgradePersianHeight = UpgradeCalicoHeight + (builtin2.EpochsInHour * 1)
const UpgradeClausHeight = 250
const UpgradeOrangeHeight = 300
const UpgradeTrustHeight = 600
const UpgradeNorwegianHeight = 201000
const UpgradeTurboHeight = 203000
const UpgradeHyperdriveHeight = 379178
const UpgradeChocolateHeight = 999999999
var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg512MiBV1,
abi.RegisteredSealProof_StackedDrg32GiBV1,
abi.RegisteredSealProof_StackedDrg64GiBV1,
}
// Minimum block production power is set to 4 TiB
// Rationale is to discourage small-scale miners from trying to take over the network
// One needs to invest in ~2.3x the compute to break consensus, making it not worth it
//
// DOWNSIDE: the fake-seals need to be kept alive/protected, otherwise network will seize
//
var ConsensusMinerMinPower = abi.NewStoragePower(4 << 40)
var MinVerifiedDealSize = abi.NewStoragePower(1 << 20)
// Lower the most time-consuming parts of PoRep
var PreCommitChallengeDelay = abi.ChainEpoch(10)
func init() {
policy.SetSupportedProofTypes(SupportedProofTypes...)
policy.SetConsensusMinerMinPower(ConsensusMinerMinPower)
policy.SetMinVerifiedDealSize(MinVerifiedDealSize)
policy.SetPreCommitChallengeDelay(PreCommitChallengeDelay)
// TODO - make this a variable
//miner.WPoStChallengeLookback = abi.ChainEpoch(2)
Devnet = false
BuildType = BuildNerpanet
}
const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
const PropagationDelaySecs = uint64(6)
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
const BootstrapPeerThreshold = 4
var WhitelistedBlock = cid.Undef

View File

@ -34,7 +34,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}}
/* inline-gen start */
const NewestNetworkVersion = network.Version15
const NewestNetworkVersion = network.Version16
/* inline-gen end */

View File

@ -17,6 +17,7 @@ import (
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
@ -106,12 +107,15 @@ var (
UpgradeHyperdriveHeight abi.ChainEpoch = -15
UpgradeChocolateHeight abi.ChainEpoch = -16
UpgradeOhSnapHeight abi.ChainEpoch = -17
UpgradeSkyrHeight abi.ChainEpoch = -18
DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
GenesisNetworkVersion = network.Version0
NetworkBundle = "devnet"
BundleOverrides map[actors.Version]string
NewestNetworkVersion = network.Version15
ActorUpgradeNetworkVersion = network.Version15

View File

@ -37,7 +37,7 @@ func BuildTypeString() string {
}
// BuildVersion is the local build version
const BuildVersion = "1.15.3"
const BuildVersion = "1.16.0"
func UserVersion() string {
if os.Getenv("LOTUS_VERSION_IGNORE_COMMIT") == "1" {

View File

@ -3,6 +3,7 @@ package main
import (
"bytes"
"fmt"
"go/format"
"io/ioutil"
"os"
"path/filepath"
@ -77,7 +78,12 @@ func generateAdapters() error {
return err
}
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), b.Bytes(), 0666); err != nil {
fmted, err := format.Source(b.Bytes())
if err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), fmted, 0666); err != nil {
return err
}
}

View File

@ -6,10 +6,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -25,42 +23,26 @@ import (
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
)
func init() {
builtin.RegisterActorState(builtin0.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
builtin.RegisterActorState(builtin2.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
builtin.RegisterActorState(builtin3.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
builtin.RegisterActorState(builtin4.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
builtin.RegisterActorState(builtin6.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
var Methods = builtin4.MethodsAccount
var Methods = builtin8.MethodsAccount
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.AccountKey {
return nil, xerrors.Errorf("actor code is not account: %s", name)
}
switch av {
case actors.Version8:
return load8(store, act.Head)
}
}
switch act.Code {
case builtin0.AccountActorCodeID:
@ -85,6 +67,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return load7(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -112,39 +95,13 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
case actors.Version7:
return make7(store, addr)
case actors.Version8:
return make8(store, addr)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.AccountActorCodeID, nil
case actors.Version2:
return builtin2.AccountActorCodeID, nil
case actors.Version3:
return builtin3.AccountActorCodeID, nil
case actors.Version4:
return builtin4.AccountActorCodeID, nil
case actors.Version5:
return builtin5.AccountActorCodeID, nil
case actors.Version6:
return builtin6.AccountActorCodeID, nil
case actors.Version7:
return builtin7.AccountActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler

View File

@ -6,32 +6,45 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
)
func init() {
{{range .versions}}
builtin.RegisterActorState(builtin{{.}}.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load{{.}}(store, root)
})
{{end}}}
var Methods = builtin4.MethodsAccount
var Methods = builtin{{.latestVersion}}.MethodsAccount
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.AccountKey {
return nil, xerrors.Errorf("actor code is not account: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
case builtin{{.}}.AccountActorCodeID:
return load{{.}}(store, act.Head)
{{if (le . 7)}}
case builtin{{.}}.AccountActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -45,17 +58,6 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.AccountActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler

View File

@ -6,7 +6,11 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
{{if (le .v 7)}}
account{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/account"
{{else}}
account{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}account"
{{end}}
)
var _ State = (*state{{.v}})(nil)

View File

@ -0,0 +1,40 @@
package account
import (
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
account8 "github.com/filecoin-project/go-state-types/builtin/v8/account"
)
var _ State = (*state8)(nil)
func load8(store adt.Store, root cid.Cid) (State, error) {
out := state8{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make8(store adt.Store, addr address.Address) (State, error) {
out := state8{store: store}
out.State = account8.State{Address: addr}
return &out, nil
}
type state8 struct {
account8.State
store adt.Store
}
func (s *state8) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state8) GetState() interface{} {
return &s.State
}

View File

@ -1,133 +1,76 @@
package builtin
import (
"fmt"
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
smoothing0 "github.com/filecoin-project/specs-actors/actors/util/smoothing"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
smoothing2 "github.com/filecoin-project/specs-actors/v2/actors/util/smoothing"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
smoothing3 "github.com/filecoin-project/specs-actors/v3/actors/util/smoothing"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
smoothing4 "github.com/filecoin-project/specs-actors/v4/actors/util/smoothing"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
smoothing5 "github.com/filecoin-project/specs-actors/v5/actors/util/smoothing"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
smoothing6 "github.com/filecoin-project/specs-actors/v6/actors/util/smoothing"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing"
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/proof"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/actors"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing"
)
var SystemActorAddr = builtin7.SystemActorAddr
var BurntFundsActorAddr = builtin7.BurntFundsActorAddr
var CronActorAddr = builtin7.CronActorAddr
var SystemActorAddr = builtin.SystemActorAddr
var BurntFundsActorAddr = builtin.BurntFundsActorAddr
var CronActorAddr = builtin.CronActorAddr
var SaftAddress = makeAddress("t0122")
var ReserveAddress = makeAddress("t090")
var RootVerifierAddress = makeAddress("t080")
var (
ExpectedLeadersPerEpoch = builtin7.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin.ExpectedLeadersPerEpoch
)
const (
EpochDurationSeconds = builtin7.EpochDurationSeconds
EpochsInDay = builtin7.EpochsInDay
SecondsInDay = builtin7.SecondsInDay
EpochDurationSeconds = builtin.EpochDurationSeconds
EpochsInDay = builtin.EpochsInDay
SecondsInDay = builtin.SecondsInDay
)
const (
MethodSend = builtin7.MethodSend
MethodConstructor = builtin7.MethodConstructor
MethodSend = builtin.MethodSend
MethodConstructor = builtin.MethodConstructor
)
// These are all just type aliases across actor versions. In the future, that might change
// and we might need to do something fancier.
type SectorInfo = proof7.SectorInfo
type ExtendedSectorInfo = proof7.ExtendedSectorInfo
type PoStProof = proof7.PoStProof
type FilterEstimate = smoothing0.FilterEstimate
type SectorInfo = proof.SectorInfo
type ExtendedSectorInfo = proof.ExtendedSectorInfo
type PoStProof = proof.PoStProof
type FilterEstimate = smoothingtypes.FilterEstimate
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return miner7.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v0) //nolint:unconvert
}
func FromV2FilterEstimate(v2 smoothing2.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v2)
}
func FromV3FilterEstimate(v3 smoothing3.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v3)
}
func FromV4FilterEstimate(v4 smoothing4.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v4)
}
func FromV5FilterEstimate(v5 smoothing5.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v5)
}
func FromV6FilterEstimate(v6 smoothing6.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v6)
}
func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate {
return (FilterEstimate)(v7)
}
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader)
func RegisterActorState(code cid.Cid, loader ActorStateLoader) {
ActorStateLoaders[code] = loader
}
func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
loader, found := ActorStateLoaders[act.Code]
if !found {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
return loader(store, act.Head)
return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
func ActorNameByCode(c cid.Cid) string {
if name, version, ok := actors.GetActorMetaByCode(c); ok {
return fmt.Sprintf("fil/%d/%s", version, name)
}
switch {
case builtin0.IsBuiltinActor(c):
@ -151,12 +94,19 @@ func ActorNameByCode(c cid.Cid) string {
case builtin7.IsBuiltinActor(c):
return builtin7.ActorNameByCode(c)
case builtin8.IsBuiltinActor(c):
return builtin8.ActorNameByCode(c)
default:
return "<unknown>"
}
}
func IsBuiltinActor(c cid.Cid) bool {
_, _, ok := actors.GetActorMetaByCode(c)
if ok {
return true
}
if builtin0.IsBuiltinActor(c) {
return true
@ -189,7 +139,44 @@ func IsBuiltinActor(c cid.Cid) bool {
return false
}
func GetAccountActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.AccountKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.AccountActorCodeID, nil
case actors.Version2:
return builtin2.AccountActorCodeID, nil
case actors.Version3:
return builtin3.AccountActorCodeID, nil
case actors.Version4:
return builtin4.AccountActorCodeID, nil
case actors.Version5:
return builtin5.AccountActorCodeID, nil
case actors.Version6:
return builtin6.AccountActorCodeID, nil
case actors.Version7:
return builtin7.AccountActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsAccountActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "account"
}
if c == builtin0.AccountActorCodeID {
return true
@ -222,7 +209,143 @@ func IsAccountActor(c cid.Cid) bool {
return false
}
func GetCronActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.CronKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.CronActorCodeID, nil
case actors.Version2:
return builtin2.CronActorCodeID, nil
case actors.Version3:
return builtin3.CronActorCodeID, nil
case actors.Version4:
return builtin4.CronActorCodeID, nil
case actors.Version5:
return builtin5.CronActorCodeID, nil
case actors.Version6:
return builtin6.CronActorCodeID, nil
case actors.Version7:
return builtin7.CronActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetInitActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.InitKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.InitActorCodeID, nil
case actors.Version2:
return builtin2.InitActorCodeID, nil
case actors.Version3:
return builtin3.InitActorCodeID, nil
case actors.Version4:
return builtin4.InitActorCodeID, nil
case actors.Version5:
return builtin5.InitActorCodeID, nil
case actors.Version6:
return builtin6.InitActorCodeID, nil
case actors.Version7:
return builtin7.InitActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetMarketActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.MarketKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.StorageMarketActorCodeID, nil
case actors.Version2:
return builtin2.StorageMarketActorCodeID, nil
case actors.Version3:
return builtin3.StorageMarketActorCodeID, nil
case actors.Version4:
return builtin4.StorageMarketActorCodeID, nil
case actors.Version5:
return builtin5.StorageMarketActorCodeID, nil
case actors.Version6:
return builtin6.StorageMarketActorCodeID, nil
case actors.Version7:
return builtin7.StorageMarketActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetMinerActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.MinerKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.StorageMinerActorCodeID, nil
case actors.Version2:
return builtin2.StorageMinerActorCodeID, nil
case actors.Version3:
return builtin3.StorageMinerActorCodeID, nil
case actors.Version4:
return builtin4.StorageMinerActorCodeID, nil
case actors.Version5:
return builtin5.StorageMinerActorCodeID, nil
case actors.Version6:
return builtin6.StorageMinerActorCodeID, nil
case actors.Version7:
return builtin7.StorageMinerActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsStorageMinerActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MinerKey
}
if c == builtin0.StorageMinerActorCodeID {
return true
@ -255,7 +378,44 @@ func IsStorageMinerActor(c cid.Cid) bool {
return false
}
func GetMultisigActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.MultisigKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.MultisigActorCodeID, nil
case actors.Version2:
return builtin2.MultisigActorCodeID, nil
case actors.Version3:
return builtin3.MultisigActorCodeID, nil
case actors.Version4:
return builtin4.MultisigActorCodeID, nil
case actors.Version5:
return builtin5.MultisigActorCodeID, nil
case actors.Version6:
return builtin6.MultisigActorCodeID, nil
case actors.Version7:
return builtin7.MultisigActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsMultisigActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MultisigKey
}
if c == builtin0.MultisigActorCodeID {
return true
@ -288,7 +448,44 @@ func IsMultisigActor(c cid.Cid) bool {
return false
}
func GetPaymentChannelActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.PaychKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.PaymentChannelActorCodeID, nil
case actors.Version2:
return builtin2.PaymentChannelActorCodeID, nil
case actors.Version3:
return builtin3.PaymentChannelActorCodeID, nil
case actors.Version4:
return builtin4.PaymentChannelActorCodeID, nil
case actors.Version5:
return builtin5.PaymentChannelActorCodeID, nil
case actors.Version6:
return builtin6.PaymentChannelActorCodeID, nil
case actors.Version7:
return builtin7.PaymentChannelActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsPaymentChannelActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "paymentchannel"
}
if c == builtin0.PaymentChannelActorCodeID {
return true
@ -321,6 +518,138 @@ func IsPaymentChannelActor(c cid.Cid) bool {
return false
}
func GetPowerActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.PowerKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.StoragePowerActorCodeID, nil
case actors.Version2:
return builtin2.StoragePowerActorCodeID, nil
case actors.Version3:
return builtin3.StoragePowerActorCodeID, nil
case actors.Version4:
return builtin4.StoragePowerActorCodeID, nil
case actors.Version5:
return builtin5.StoragePowerActorCodeID, nil
case actors.Version6:
return builtin6.StoragePowerActorCodeID, nil
case actors.Version7:
return builtin7.StoragePowerActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetRewardActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.RewardKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.RewardActorCodeID, nil
case actors.Version2:
return builtin2.RewardActorCodeID, nil
case actors.Version3:
return builtin3.RewardActorCodeID, nil
case actors.Version4:
return builtin4.RewardActorCodeID, nil
case actors.Version5:
return builtin5.RewardActorCodeID, nil
case actors.Version6:
return builtin6.RewardActorCodeID, nil
case actors.Version7:
return builtin7.RewardActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetSystemActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.SystemKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.SystemActorCodeID, nil
case actors.Version2:
return builtin2.SystemActorCodeID, nil
case actors.Version3:
return builtin3.SystemActorCodeID, nil
case actors.Version4:
return builtin4.SystemActorCodeID, nil
case actors.Version5:
return builtin5.SystemActorCodeID, nil
case actors.Version6:
return builtin6.SystemActorCodeID, nil
case actors.Version7:
return builtin7.SystemActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetVerifregActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.VerifregKey); ok {
return c, nil
}
switch av {
case actors.Version0:
return builtin0.VerifiedRegistryActorCodeID, nil
case actors.Version2:
return builtin2.VerifiedRegistryActorCodeID, nil
case actors.Version3:
return builtin3.VerifiedRegistryActorCodeID, nil
case actors.Version4:
return builtin4.VerifiedRegistryActorCodeID, nil
case actors.Version5:
return builtin5.VerifiedRegistryActorCodeID, nil
case actors.Version6:
return builtin6.VerifiedRegistryActorCodeID, nil
case actors.Version7:
return builtin7.VerifiedRegistryActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func makeAddress(addr string) address.Address {
ret, err := address.NewFromString(addr)
if err != nil {

View File

@ -1,140 +1,341 @@
package builtin
import (
"fmt"
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
smoothing{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/util/smoothing"
{{end}}
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/proof"
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/actors"
miner{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/miner"
proof{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/runtime/proof"
miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin/v8/miner"
smoothingtypes "github.com/filecoin-project/go-state-types/builtin/v8/util/smoothing"
)
var SystemActorAddr = builtin{{.latestVersion}}.SystemActorAddr
var BurntFundsActorAddr = builtin{{.latestVersion}}.BurntFundsActorAddr
var CronActorAddr = builtin{{.latestVersion}}.CronActorAddr
var SystemActorAddr = builtin.SystemActorAddr
var BurntFundsActorAddr = builtin.BurntFundsActorAddr
var CronActorAddr = builtin.CronActorAddr
var SaftAddress = makeAddress("t0122")
var ReserveAddress = makeAddress("t090")
var RootVerifierAddress = makeAddress("t080")
var (
ExpectedLeadersPerEpoch = builtin{{.latestVersion}}.ExpectedLeadersPerEpoch
ExpectedLeadersPerEpoch = builtin.ExpectedLeadersPerEpoch
)
const (
EpochDurationSeconds = builtin{{.latestVersion}}.EpochDurationSeconds
EpochsInDay = builtin{{.latestVersion}}.EpochsInDay
SecondsInDay = builtin{{.latestVersion}}.SecondsInDay
EpochDurationSeconds = builtin.EpochDurationSeconds
EpochsInDay = builtin.EpochsInDay
SecondsInDay = builtin.SecondsInDay
)
const (
MethodSend = builtin{{.latestVersion}}.MethodSend
MethodConstructor = builtin{{.latestVersion}}.MethodConstructor
MethodSend = builtin.MethodSend
MethodConstructor = builtin.MethodConstructor
)
// These are all just type aliases across actor versions. In the future, that might change
// and we might need to do something fancier.
type SectorInfo = proof{{.latestVersion}}.SectorInfo
type ExtendedSectorInfo = proof{{.latestVersion}}.ExtendedSectorInfo
type PoStProof = proof{{.latestVersion}}.PoStProof
type FilterEstimate = smoothing0.FilterEstimate
type SectorInfo = proof.SectorInfo
type ExtendedSectorInfo = proof.ExtendedSectorInfo
type PoStProof = proof.PoStProof
type FilterEstimate = smoothingtypes.FilterEstimate
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
return miner{{.latestVersion}}.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
}
{{range .versions}}
func FromV{{.}}FilterEstimate(v{{.}} smoothing{{.}}.FilterEstimate) FilterEstimate {
{{if (eq . 0)}}
return (FilterEstimate)(v{{.}}) //nolint:unconvert
{{else}}
return (FilterEstimate)(v{{.}})
{{end}}
}
{{end}}
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader)
func RegisterActorState(code cid.Cid, loader ActorStateLoader) {
ActorStateLoaders[code] = loader
}
func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
loader, found := ActorStateLoaders[act.Code]
if !found {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
return loader(store, act.Head)
}
func ActorNameByCode(c cid.Cid) string {
if name, version, ok := actors.GetActorMetaByCode(c); ok {
return fmt.Sprintf("fil/%d/%s", version, name)
}
switch {
{{range .versions}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
{{range .versions}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
default:
return "<unknown>"
}
}
func IsBuiltinActor(c cid.Cid) bool {
_, _, ok := actors.GetActorMetaByCode(c)
if ok {
return true
}
{{range .versions}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{if (le . 7)}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{end}}
{{end}}
return false
}
func GetAccountActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.AccountKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.AccountActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsAccountActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "account"
}
{{range .versions}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{if (le . 7)}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{end}}
{{end}}
return false
}
func GetCronActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.CronKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.CronActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetInitActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.InitKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.InitActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetMarketActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.MarketKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.StorageMarketActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetMinerActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.MinerKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.StorageMinerActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsStorageMinerActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MinerKey
}
{{range .versions}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{if (le . 7)}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{end}}
{{end}}
return false
}
func GetMultisigActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.MultisigKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.MultisigActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsMultisigActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == actors.MultisigKey
}
{{range .versions}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{if (le . 7)}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{end}}
{{end}}
return false
}
func GetPaymentChannelActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.PaychKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.PaymentChannelActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func IsPaymentChannelActor(c cid.Cid) bool {
name, _, ok := actors.GetActorMetaByCode(c)
if ok {
return name == "paymentchannel"
}
{{range .versions}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{if (le . 7)}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{end}}
{{end}}
return false
}
func GetPowerActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.PowerKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.StoragePowerActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetRewardActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.RewardKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.RewardActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetSystemActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.SystemKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.SystemActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func GetVerifregActorCodeID(av actors.Version) (cid.Cid, error) {
if c, ok := actors.GetActorCodeID(av, actors.VerifregKey); ok {
return c, nil
}
switch av {
{{range .versions}}
{{if (le . 7)}}
case actors.Version{{.}}:
return builtin{{.}}.VerifiedRegistryActorCodeID, nil
{{end}}
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
func makeAddress(addr string) address.Address {
ret, err := address.NewFromString(addr)
if err != nil {

View File

@ -4,12 +4,45 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/types"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.CronKey {
return nil, xerrors.Errorf("actor code is not cron: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
{{if (le . 7)}}
case builtin{{.}}.CronActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
{{range .versions}}
@ -20,17 +53,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.CronActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin{{.latestVersion}}.CronActorAddr
Methods = builtin{{.latestVersion}}.MethodsCron

View File

@ -3,7 +3,7 @@ package cron
import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/types"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -19,8 +19,52 @@ import (
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.CronKey {
return nil, xerrors.Errorf("actor code is not cron: %s", name)
}
switch av {
case actors.Version8:
return load8(store, act.Head)
}
}
switch act.Code {
case builtin0.CronActorCodeID:
return load0(store, act.Head)
case builtin2.CronActorCodeID:
return load2(store, act.Head)
case builtin3.CronActorCodeID:
return load3(store, act.Head)
case builtin4.CronActorCodeID:
return load4(store, act.Head)
case builtin5.CronActorCodeID:
return load5(store, act.Head)
case builtin6.CronActorCodeID:
return load6(store, act.Head)
case builtin7.CronActorCodeID:
return load7(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
@ -45,42 +89,16 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version7:
return make7(store)
case actors.Version8:
return make8(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.CronActorCodeID, nil
case actors.Version2:
return builtin2.CronActorCodeID, nil
case actors.Version3:
return builtin3.CronActorCodeID, nil
case actors.Version4:
return builtin4.CronActorCodeID, nil
case actors.Version5:
return builtin5.CronActorCodeID, nil
case actors.Version6:
return builtin6.CronActorCodeID, nil
case actors.Version7:
return builtin7.CronActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin7.CronActorAddr
Methods = builtin7.MethodsCron
Address = builtin8.CronActorAddr
Methods = builtin8.MethodsCron
)
type State interface {

View File

@ -5,7 +5,11 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
{{if (le .v 7)}}
cron{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/cron"
{{else}}
cron{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}cron"
{{end}}
)
var _ State = (*state{{.v}})(nil)

View File

@ -0,0 +1,35 @@
package cron
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron"
)
var _ State = (*state8)(nil)
func load8(store adt.Store, root cid.Cid) (State, error) {
out := state8{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make8(store adt.Store) (State, error) {
out := state8{store: store}
out.State = *cron8.ConstructState(cron8.BuiltInEntries())
return &out, nil
}
type state8 struct {
cron8.State
store adt.Store
}
func (s *state8) GetState() interface{} {
return &s.State
}

View File

@ -10,33 +10,47 @@ import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
)
func init() {
{{range .versions}}
builtin.RegisterActorState(builtin{{.}}.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load{{.}}(store, root)
})
{{end}}}
var (
Address = builtin{{.latestVersion}}.InitActorAddr
Methods = builtin{{.latestVersion}}.MethodsInit
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.InitKey {
return nil, xerrors.Errorf("actor code is not init: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
case builtin{{.}}.InitActorCodeID:
return load{{.}}(store, act.Head)
{{if (le . 7)}}
case builtin{{.}}.InitActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -50,17 +64,6 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.InitActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler

View File

@ -10,7 +10,6 @@ import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/modules/dtypes"
@ -27,45 +26,29 @@ import (
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
)
func init() {
builtin.RegisterActorState(builtin0.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
builtin.RegisterActorState(builtin2.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
builtin.RegisterActorState(builtin3.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
builtin.RegisterActorState(builtin4.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
builtin.RegisterActorState(builtin6.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
builtin.RegisterActorState(builtin7.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
var (
Address = builtin7.InitActorAddr
Methods = builtin7.MethodsInit
Address = builtin8.InitActorAddr
Methods = builtin8.MethodsInit
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.InitKey {
return nil, xerrors.Errorf("actor code is not init: %s", name)
}
switch av {
case actors.Version8:
return load8(store, act.Head)
}
}
switch act.Code {
case builtin0.InitActorCodeID:
@ -90,6 +73,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return load7(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -117,39 +101,13 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e
case actors.Version7:
return make7(store, networkName)
case actors.Version8:
return make8(store, networkName)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.InitActorCodeID, nil
case actors.Version2:
return builtin2.InitActorCodeID, nil
case actors.Version3:
return builtin3.InitActorCodeID, nil
case actors.Version4:
return builtin4.InitActorCodeID, nil
case actors.Version5:
return builtin5.InitActorCodeID, nil
case actors.Version6:
return builtin6.InitActorCodeID, nil
case actors.Version7:
return builtin7.InitActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler

View File

@ -10,12 +10,17 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
{{if (ge .v 3)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
{{end}}
{{if (le .v 7)}}
{{if (ge .v 3)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
{{end}}
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
{{else}}
init{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}init"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
)
var _ State = (*state{{.v}})(nil)

View File

@ -0,0 +1,113 @@
package init
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/node/modules/dtypes"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
init8 "github.com/filecoin-project/go-state-types/builtin/v8/init"
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
)
var _ State = (*state8)(nil)
func load8(store adt.Store, root cid.Cid) (State, error) {
out := state8{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make8(store adt.Store, networkName string) (State, error) {
out := state8{store: store}
s, err := init8.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state8 struct {
init8.State
store adt.Store
}
func (s *state8) ResolveAddress(address address.Address) (address.Address, bool, error) {
return s.State.ResolveAddress(s.store, address)
}
func (s *state8) MapAddressToNewID(address address.Address) (address.Address, error) {
return s.State.MapAddressToNewID(s.store, address)
}
func (s *state8) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
addrs, err := adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth)
if err != nil {
return err
}
var actorID cbg.CborInt
return addrs.ForEach(&actorID, func(key string) error {
addr, err := address.NewFromBytes([]byte(key))
if err != nil {
return err
}
return cb(abi.ActorID(actorID), addr)
})
}
func (s *state8) NetworkName() (dtypes.NetworkName, error) {
return dtypes.NetworkName(s.State.NetworkName), nil
}
func (s *state8) SetNetworkName(name string) error {
s.State.NetworkName = name
return nil
}
func (s *state8) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state8) Remove(addrs ...address.Address) (err error) {
m, err := adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth)
if err != nil {
return err
}
for _, addr := range addrs {
if err = m.Delete(abi.AddrKey(addr)); err != nil {
return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err)
}
}
amr, err := m.Root()
if err != nil {
return xerrors.Errorf("failed to get address map root: %w", err)
}
s.State.AddressMap = amr
return nil
}
func (s *state8) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state8) AddressMap() (adt.Map, error) {
return adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth)
}
func (s *state8) GetState() interface{} {
return &s.State
}

View File

@ -1,6 +1,8 @@
package market
import (
"unicode/utf8"
"github.com/filecoin-project/go-state-types/network"
"golang.org/x/xerrors"
@ -8,39 +10,52 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
market{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}market"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
func init() {
{{range .versions}}
builtin.RegisterActorState(builtin{{.}}.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load{{.}}(store, root)
})
{{end}}}
var (
Address = builtin{{.latestVersion}}.StorageMarketActorAddr
Methods = builtin{{.latestVersion}}.MethodsMarket
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.MarketKey {
return nil, xerrors.Errorf("actor code is not market: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
case builtin{{.}}.StorageMarketActorCodeID:
return load{{.}}(store, act.Head)
{{if (le . 7)}}
case builtin{{.}}.StorageMarketActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -54,17 +69,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.StorageMarketActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
BalancesChanged(State) (bool, error)
@ -96,14 +100,13 @@ type DealStates interface {
}
type DealProposals interface {
ForEach(cb func(id abi.DealID, dp DealProposal) error) error
Get(id abi.DealID) (*DealProposal, bool, error)
ForEach(cb func(id abi.DealID, dp market{{.latestVersion}}.DealProposal) error) error
Get(id abi.DealID) (*market{{.latestVersion}}.DealProposal, bool, error)
array() adt.Array
decode(*cbg.Deferred) (*DealProposal, error)
decode(*cbg.Deferred) (*market{{.latestVersion}}.DealProposal, error)
}
type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn interface {
DealIDs() ([]abi.DealID, error)
@ -126,30 +129,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
return nil, xerrors.Errorf("unknown actor version %d", av)
}
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams
type DealProposal = market{{.latestVersion}}.DealProposal
type ClientDealProposal = market0.ClientDealProposal
type DealState struct {
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated
SlashEpoch abi.ChainEpoch // -1 if deal never slashed
}
type DealProposal struct {
PieceCID cid.Cid
PieceSize abi.PaddedPieceSize
VerifiedDeal bool
Client address.Address
Provider address.Address
Label string
StartEpoch abi.ChainEpoch
EndEpoch abi.ChainEpoch
StoragePricePerEpoch abi.TokenAmount
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
}
type DealState = market{{.latestVersion}}.DealState
type DealStateChanges struct {
Added []DealIDState
@ -176,7 +158,7 @@ type DealProposalChanges struct {
type ProposalIDState struct {
ID abi.DealID
Proposal DealProposal
Proposal market{{.latestVersion}}.DealProposal
}
func EmptyDealState() *DealState {
@ -188,7 +170,7 @@ func EmptyDealState() *DealState {
}
// returns the earned fees and pending fees for a given deal
func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
func GetDealFees(deal market{{.latestVersion}}.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
@ -202,3 +184,11 @@ func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, ab
return ef, big.Sub(tf, ef)
}
func labelFromGoString(s string) (market{{.latestVersion}}.DealLabel, error) {
if utf8.ValidString(s) {
return market{{.latestVersion}}.NewLabelFromString(s)
} else {
return market{{.latestVersion}}.NewLabelFromBytes([]byte(s))
}
}

View File

@ -1,6 +1,8 @@
package market
import (
"unicode/utf8"
"github.com/filecoin-project/go-state-types/network"
"golang.org/x/xerrors"
@ -8,10 +10,9 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -27,49 +28,32 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
func init() {
builtin.RegisterActorState(builtin0.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
builtin.RegisterActorState(builtin2.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
builtin.RegisterActorState(builtin3.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
builtin.RegisterActorState(builtin4.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
builtin.RegisterActorState(builtin6.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
builtin.RegisterActorState(builtin7.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
var (
Address = builtin7.StorageMarketActorAddr
Methods = builtin7.MethodsMarket
Address = builtin8.StorageMarketActorAddr
Methods = builtin8.MethodsMarket
)
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.MarketKey {
return nil, xerrors.Errorf("actor code is not market: %s", name)
}
switch av {
case actors.Version8:
return load8(store, act.Head)
}
}
switch act.Code {
case builtin0.StorageMarketActorCodeID:
@ -94,6 +78,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return load7(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -121,39 +106,13 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version7:
return make7(store)
case actors.Version8:
return make8(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.StorageMarketActorCodeID, nil
case actors.Version2:
return builtin2.StorageMarketActorCodeID, nil
case actors.Version3:
return builtin3.StorageMarketActorCodeID, nil
case actors.Version4:
return builtin4.StorageMarketActorCodeID, nil
case actors.Version5:
return builtin5.StorageMarketActorCodeID, nil
case actors.Version6:
return builtin6.StorageMarketActorCodeID, nil
case actors.Version7:
return builtin7.StorageMarketActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
BalancesChanged(State) (bool, error)
@ -185,15 +144,13 @@ type DealStates interface {
}
type DealProposals interface {
ForEach(cb func(id abi.DealID, dp DealProposal) error) error
Get(id abi.DealID) (*DealProposal, bool, error)
ForEach(cb func(id abi.DealID, dp market8.DealProposal) error) error
Get(id abi.DealID) (*market8.DealProposal, bool, error)
array() adt.Array
decode(*cbg.Deferred) (*DealProposal, error)
decode(*cbg.Deferred) (*market8.DealProposal, error)
}
type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn interface {
DealIDs() ([]abi.DealID, error)
// Note that this index is based on the batch of deals that were published, NOT the DealID
@ -229,34 +186,16 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
case actors.Version7:
return decodePublishStorageDealsReturn7(b)
case actors.Version8:
return decodePublishStorageDealsReturn8(b)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams
type DealProposal = market8.DealProposal
type ClientDealProposal = market0.ClientDealProposal
type DealState struct {
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated
SlashEpoch abi.ChainEpoch // -1 if deal never slashed
}
type DealProposal struct {
PieceCID cid.Cid
PieceSize abi.PaddedPieceSize
VerifiedDeal bool
Client address.Address
Provider address.Address
Label string
StartEpoch abi.ChainEpoch
EndEpoch abi.ChainEpoch
StoragePricePerEpoch abi.TokenAmount
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
}
type DealState = market8.DealState
type DealStateChanges struct {
Added []DealIDState
@ -283,7 +222,7 @@ type DealProposalChanges struct {
type ProposalIDState struct {
ID abi.DealID
Proposal DealProposal
Proposal market8.DealProposal
}
func EmptyDealState() *DealState {
@ -295,7 +234,7 @@ func EmptyDealState() *DealState {
}
// returns the earned fees and pending fees for a given deal
func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
func GetDealFees(deal market8.DealProposal, height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
@ -309,3 +248,11 @@ func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, ab
return ef, big.Sub(tf, ef)
}
func labelFromGoString(s string) (market8.DealLabel, error) {
if utf8.ValidString(s) {
return market8.NewLabelFromString(s)
} else {
return market8.NewLabelFromBytes([]byte(s))
}
}

View File

@ -17,8 +17,13 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
{{if (le .v 7)}}
market{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/market"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
{{else}}
market{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}market"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
{{end}}
)
var _ State = (*state{{.v}})(nil)
@ -195,7 +200,7 @@ func (s *dealStates{{.v}}) array() adt.Array {
}
func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState {
return (DealState)(v{{.v}})
return (DealState)(v{{.v}})
}
type dealProposals{{.v}} struct {
@ -211,14 +216,24 @@ func (s *dealProposals{{.v}}) Get(dealID abi.DealID) (*DealProposal, bool, error
if !found {
return nil, false, nil
}
proposal := fromV{{.v}}DealProposal(proposal{{.v}})
return &proposal, true, nil
proposal, err := fromV{{.v}}DealProposal(proposal{{.v}})
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals{{.v}}) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp{{.v}} market{{.v}}.DealProposal
return s.Array.ForEach(&dp{{.v}}, func(idx int64) error {
return cb(abi.DealID(idx), fromV{{.v}}DealProposal(dp{{.v}}))
dp, err := fromV{{.v}}DealProposal(dp{{.v}})
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -227,18 +242,48 @@ func (s *dealProposals{{.v}}) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp{{.v}}.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV{{.v}}DealProposal(dp{{.v}})
return &dp, nil
dp, err := fromV{{.v}}DealProposal(dp{{.v}})
if err != nil {
return nil, err
}
return &dp, nil
}
func (s *dealProposals{{.v}}) array() adt.Array {
return s.Array
}
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal {
return (DealProposal)(v{{.v}})
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, error) {
{{if (le .v 7)}}
label, err := labelFromGoString(v{{.v}}.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
{{else}}
label := v{{.v}}.Label
{{end}}
return DealProposal{
PieceCID: v{{.v}}.PieceCID,
PieceSize: v{{.v}}.PieceSize,
VerifiedDeal: v{{.v}}.VerifiedDeal,
Client: v{{.v}}.Client,
Provider: v{{.v}}.Provider,
Label: label,
StartEpoch: v{{.v}}.StartEpoch,
EndEpoch: v{{.v}}.EndEpoch,
StoragePricePerEpoch: v{{.v}}.StoragePricePerEpoch,
ProviderCollateral: v{{.v}}.ProviderCollateral,
ClientCollateral: v{{.v}}.ClientCollateral,
}, nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -199,14 +199,24 @@ func (s *dealProposals0) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV0DealProposal(proposal0)
proposal, err := fromV0DealProposal(proposal0)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals0) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp0 market0.DealProposal
return s.Array.ForEach(&dp0, func(idx int64) error {
return cb(abi.DealID(idx), fromV0DealProposal(dp0))
dp, err := fromV0DealProposal(dp0)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -215,7 +225,12 @@ func (s *dealProposals0) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp0.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV0DealProposal(dp0)
dp, err := fromV0DealProposal(dp0)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -223,8 +238,29 @@ func (s *dealProposals0) array() adt.Array {
return s.Array
}
func fromV0DealProposal(v0 market0.DealProposal) DealProposal {
return (DealProposal)(v0)
func fromV0DealProposal(v0 market0.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v0.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v0.PieceCID,
PieceSize: v0.PieceSize,
VerifiedDeal: v0.VerifiedDeal,
Client: v0.Client,
Provider: v0.Provider,
Label: label,
StartEpoch: v0.StartEpoch,
EndEpoch: v0.EndEpoch,
StoragePricePerEpoch: v0.StoragePricePerEpoch,
ProviderCollateral: v0.ProviderCollateral,
ClientCollateral: v0.ClientCollateral,
}, nil
}
func (s *state0) GetState() interface{} {

View File

@ -199,14 +199,24 @@ func (s *dealProposals2) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV2DealProposal(proposal2)
proposal, err := fromV2DealProposal(proposal2)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals2) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp2 market2.DealProposal
return s.Array.ForEach(&dp2, func(idx int64) error {
return cb(abi.DealID(idx), fromV2DealProposal(dp2))
dp, err := fromV2DealProposal(dp2)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -215,7 +225,12 @@ func (s *dealProposals2) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp2.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV2DealProposal(dp2)
dp, err := fromV2DealProposal(dp2)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -223,8 +238,29 @@ func (s *dealProposals2) array() adt.Array {
return s.Array
}
func fromV2DealProposal(v2 market2.DealProposal) DealProposal {
return (DealProposal)(v2)
func fromV2DealProposal(v2 market2.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v2.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v2.PieceCID,
PieceSize: v2.PieceSize,
VerifiedDeal: v2.VerifiedDeal,
Client: v2.Client,
Provider: v2.Provider,
Label: label,
StartEpoch: v2.StartEpoch,
EndEpoch: v2.EndEpoch,
StoragePricePerEpoch: v2.StoragePricePerEpoch,
ProviderCollateral: v2.ProviderCollateral,
ClientCollateral: v2.ClientCollateral,
}, nil
}
func (s *state2) GetState() interface{} {

View File

@ -194,14 +194,24 @@ func (s *dealProposals3) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV3DealProposal(proposal3)
proposal, err := fromV3DealProposal(proposal3)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals3) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp3 market3.DealProposal
return s.Array.ForEach(&dp3, func(idx int64) error {
return cb(abi.DealID(idx), fromV3DealProposal(dp3))
dp, err := fromV3DealProposal(dp3)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -210,7 +220,12 @@ func (s *dealProposals3) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp3.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV3DealProposal(dp3)
dp, err := fromV3DealProposal(dp3)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -218,8 +233,29 @@ func (s *dealProposals3) array() adt.Array {
return s.Array
}
func fromV3DealProposal(v3 market3.DealProposal) DealProposal {
return (DealProposal)(v3)
func fromV3DealProposal(v3 market3.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v3.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v3.PieceCID,
PieceSize: v3.PieceSize,
VerifiedDeal: v3.VerifiedDeal,
Client: v3.Client,
Provider: v3.Provider,
Label: label,
StartEpoch: v3.StartEpoch,
EndEpoch: v3.EndEpoch,
StoragePricePerEpoch: v3.StoragePricePerEpoch,
ProviderCollateral: v3.ProviderCollateral,
ClientCollateral: v3.ClientCollateral,
}, nil
}
func (s *state3) GetState() interface{} {

View File

@ -194,14 +194,24 @@ func (s *dealProposals4) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV4DealProposal(proposal4)
proposal, err := fromV4DealProposal(proposal4)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals4) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp4 market4.DealProposal
return s.Array.ForEach(&dp4, func(idx int64) error {
return cb(abi.DealID(idx), fromV4DealProposal(dp4))
dp, err := fromV4DealProposal(dp4)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -210,7 +220,12 @@ func (s *dealProposals4) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp4.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV4DealProposal(dp4)
dp, err := fromV4DealProposal(dp4)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -218,8 +233,29 @@ func (s *dealProposals4) array() adt.Array {
return s.Array
}
func fromV4DealProposal(v4 market4.DealProposal) DealProposal {
return (DealProposal)(v4)
func fromV4DealProposal(v4 market4.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v4.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v4.PieceCID,
PieceSize: v4.PieceSize,
VerifiedDeal: v4.VerifiedDeal,
Client: v4.Client,
Provider: v4.Provider,
Label: label,
StartEpoch: v4.StartEpoch,
EndEpoch: v4.EndEpoch,
StoragePricePerEpoch: v4.StoragePricePerEpoch,
ProviderCollateral: v4.ProviderCollateral,
ClientCollateral: v4.ClientCollateral,
}, nil
}
func (s *state4) GetState() interface{} {

View File

@ -194,14 +194,24 @@ func (s *dealProposals5) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV5DealProposal(proposal5)
proposal, err := fromV5DealProposal(proposal5)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals5) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp5 market5.DealProposal
return s.Array.ForEach(&dp5, func(idx int64) error {
return cb(abi.DealID(idx), fromV5DealProposal(dp5))
dp, err := fromV5DealProposal(dp5)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -210,7 +220,12 @@ func (s *dealProposals5) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp5.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV5DealProposal(dp5)
dp, err := fromV5DealProposal(dp5)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -218,8 +233,29 @@ func (s *dealProposals5) array() adt.Array {
return s.Array
}
func fromV5DealProposal(v5 market5.DealProposal) DealProposal {
return (DealProposal)(v5)
func fromV5DealProposal(v5 market5.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v5.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v5.PieceCID,
PieceSize: v5.PieceSize,
VerifiedDeal: v5.VerifiedDeal,
Client: v5.Client,
Provider: v5.Provider,
Label: label,
StartEpoch: v5.StartEpoch,
EndEpoch: v5.EndEpoch,
StoragePricePerEpoch: v5.StoragePricePerEpoch,
ProviderCollateral: v5.ProviderCollateral,
ClientCollateral: v5.ClientCollateral,
}, nil
}
func (s *state5) GetState() interface{} {

View File

@ -197,14 +197,24 @@ func (s *dealProposals6) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV6DealProposal(proposal6)
proposal, err := fromV6DealProposal(proposal6)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals6) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp6 market6.DealProposal
return s.Array.ForEach(&dp6, func(idx int64) error {
return cb(abi.DealID(idx), fromV6DealProposal(dp6))
dp, err := fromV6DealProposal(dp6)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -213,7 +223,12 @@ func (s *dealProposals6) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp6.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV6DealProposal(dp6)
dp, err := fromV6DealProposal(dp6)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -221,8 +236,29 @@ func (s *dealProposals6) array() adt.Array {
return s.Array
}
func fromV6DealProposal(v6 market6.DealProposal) DealProposal {
return (DealProposal)(v6)
func fromV6DealProposal(v6 market6.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v6.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v6.PieceCID,
PieceSize: v6.PieceSize,
VerifiedDeal: v6.VerifiedDeal,
Client: v6.Client,
Provider: v6.Provider,
Label: label,
StartEpoch: v6.StartEpoch,
EndEpoch: v6.EndEpoch,
StoragePricePerEpoch: v6.StoragePricePerEpoch,
ProviderCollateral: v6.ProviderCollateral,
ClientCollateral: v6.ClientCollateral,
}, nil
}
func (s *state6) GetState() interface{} {

View File

@ -197,14 +197,24 @@ func (s *dealProposals7) Get(dealID abi.DealID) (*DealProposal, bool, error) {
if !found {
return nil, false, nil
}
proposal := fromV7DealProposal(proposal7)
proposal, err := fromV7DealProposal(proposal7)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals7) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp7 market7.DealProposal
return s.Array.ForEach(&dp7, func(idx int64) error {
return cb(abi.DealID(idx), fromV7DealProposal(dp7))
dp, err := fromV7DealProposal(dp7)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
@ -213,7 +223,12 @@ func (s *dealProposals7) decode(val *cbg.Deferred) (*DealProposal, error) {
if err := dp7.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp := fromV7DealProposal(dp7)
dp, err := fromV7DealProposal(dp7)
if err != nil {
return nil, err
}
return &dp, nil
}
@ -221,8 +236,29 @@ func (s *dealProposals7) array() adt.Array {
return s.Array
}
func fromV7DealProposal(v7 market7.DealProposal) DealProposal {
return (DealProposal)(v7)
func fromV7DealProposal(v7 market7.DealProposal) (DealProposal, error) {
label, err := labelFromGoString(v7.Label)
if err != nil {
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
}
return DealProposal{
PieceCID: v7.PieceCID,
PieceSize: v7.PieceSize,
VerifiedDeal: v7.VerifiedDeal,
Client: v7.Client,
Provider: v7.Provider,
Label: label,
StartEpoch: v7.StartEpoch,
EndEpoch: v7.EndEpoch,
StoragePricePerEpoch: v7.StoragePricePerEpoch,
ProviderCollateral: v7.ProviderCollateral,
ClientCollateral: v7.ClientCollateral,
}, nil
}
func (s *state7) GetState() interface{} {

View File

@ -0,0 +1,305 @@
package market
import (
"bytes"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-bitfield"
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/types"
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
)
var _ State = (*state8)(nil)
func load8(store adt.Store, root cid.Cid) (State, error) {
out := state8{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make8(store adt.Store) (State, error) {
out := state8{store: store}
s, err := market8.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state8 struct {
market8.State
store adt.Store
}
func (s *state8) TotalLocked() (abi.TokenAmount, error) {
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
fml = types.BigAdd(fml, s.TotalClientStorageFee)
return fml, nil
}
func (s *state8) BalancesChanged(otherState State) (bool, error) {
otherState8, ok := otherState.(*state8)
if !ok {
// there's no way to compare different versions of the state, so let's
// just say that means the state of balances has changed
return true, nil
}
return !s.State.EscrowTable.Equals(otherState8.State.EscrowTable) || !s.State.LockedTable.Equals(otherState8.State.LockedTable), nil
}
func (s *state8) StatesChanged(otherState State) (bool, error) {
otherState8, ok := otherState.(*state8)
if !ok {
// there's no way to compare different versions of the state, so let's
// just say that means the state of balances has changed
return true, nil
}
return !s.State.States.Equals(otherState8.State.States), nil
}
func (s *state8) States() (DealStates, error) {
stateArray, err := adt8.AsArray(s.store, s.State.States, market8.StatesAmtBitwidth)
if err != nil {
return nil, err
}
return &dealStates8{stateArray}, nil
}
func (s *state8) ProposalsChanged(otherState State) (bool, error) {
otherState8, ok := otherState.(*state8)
if !ok {
// there's no way to compare different versions of the state, so let's
// just say that means the state of balances has changed
return true, nil
}
return !s.State.Proposals.Equals(otherState8.State.Proposals), nil
}
func (s *state8) Proposals() (DealProposals, error) {
proposalArray, err := adt8.AsArray(s.store, s.State.Proposals, market8.ProposalsAmtBitwidth)
if err != nil {
return nil, err
}
return &dealProposals8{proposalArray}, nil
}
func (s *state8) EscrowTable() (BalanceTable, error) {
bt, err := adt8.AsBalanceTable(s.store, s.State.EscrowTable)
if err != nil {
return nil, err
}
return &balanceTable8{bt}, nil
}
func (s *state8) LockedTable() (BalanceTable, error) {
bt, err := adt8.AsBalanceTable(s.store, s.State.LockedTable)
if err != nil {
return nil, err
}
return &balanceTable8{bt}, nil
}
func (s *state8) VerifyDealsForActivation(
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error) {
w, vw, _, err := market8.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
return w, vw, err
}
func (s *state8) NextID() (abi.DealID, error) {
return s.State.NextID, nil
}
type balanceTable8 struct {
*adt8.BalanceTable
}
func (bt *balanceTable8) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
asMap := (*adt8.Map)(bt.BalanceTable)
var ta abi.TokenAmount
return asMap.ForEach(&ta, func(key string) error {
a, err := address.NewFromBytes([]byte(key))
if err != nil {
return err
}
return cb(a, ta)
})
}
type dealStates8 struct {
adt.Array
}
func (s *dealStates8) Get(dealID abi.DealID) (*DealState, bool, error) {
var deal8 market8.DealState
found, err := s.Array.Get(uint64(dealID), &deal8)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
deal := fromV8DealState(deal8)
return &deal, true, nil
}
func (s *dealStates8) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
var ds8 market8.DealState
return s.Array.ForEach(&ds8, func(idx int64) error {
return cb(abi.DealID(idx), fromV8DealState(ds8))
})
}
func (s *dealStates8) decode(val *cbg.Deferred) (*DealState, error) {
var ds8 market8.DealState
if err := ds8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
ds := fromV8DealState(ds8)
return &ds, nil
}
func (s *dealStates8) array() adt.Array {
return s.Array
}
func fromV8DealState(v8 market8.DealState) DealState {
return (DealState)(v8)
}
type dealProposals8 struct {
adt.Array
}
func (s *dealProposals8) Get(dealID abi.DealID) (*DealProposal, bool, error) {
var proposal8 market8.DealProposal
found, err := s.Array.Get(uint64(dealID), &proposal8)
if err != nil {
return nil, false, err
}
if !found {
return nil, false, nil
}
proposal, err := fromV8DealProposal(proposal8)
if err != nil {
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
}
return &proposal, true, nil
}
func (s *dealProposals8) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
var dp8 market8.DealProposal
return s.Array.ForEach(&dp8, func(idx int64) error {
dp, err := fromV8DealProposal(dp8)
if err != nil {
return xerrors.Errorf("decoding proposal: %w", err)
}
return cb(abi.DealID(idx), dp)
})
}
func (s *dealProposals8) decode(val *cbg.Deferred) (*DealProposal, error) {
var dp8 market8.DealProposal
if err := dp8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return nil, err
}
dp, err := fromV8DealProposal(dp8)
if err != nil {
return nil, err
}
return &dp, nil
}
func (s *dealProposals8) array() adt.Array {
return s.Array
}
func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) {
label := v8.Label
return DealProposal{
PieceCID: v8.PieceCID,
PieceSize: v8.PieceSize,
VerifiedDeal: v8.VerifiedDeal,
Client: v8.Client,
Provider: v8.Provider,
Label: label,
StartEpoch: v8.StartEpoch,
EndEpoch: v8.EndEpoch,
StoragePricePerEpoch: v8.StoragePricePerEpoch,
ProviderCollateral: v8.ProviderCollateral,
ClientCollateral: v8.ClientCollateral,
}, nil
}
func (s *state8) GetState() interface{} {
return &s.State
}
var _ PublishStorageDealsReturn = (*publishStorageDealsReturn8)(nil)
func decodePublishStorageDealsReturn8(b []byte) (PublishStorageDealsReturn, error) {
var retval market8.PublishStorageDealsReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
}
return &publishStorageDealsReturn8{retval}, nil
}
type publishStorageDealsReturn8 struct {
market8.PublishStorageDealsReturn
}
func (r *publishStorageDealsReturn8) IsDealValid(index uint64) (bool, int, error) {
set, err := r.ValidDeals.IsSet(index)
if err != nil || !set {
return false, -1, err
}
maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{
Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}})
if err != nil {
return false, -1, err
}
before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals)
if err != nil {
return false, -1, err
}
outIdx, err := before.Count()
if err != nil {
return false, -1, err
}
return set, int(outIdx), nil
}
func (r *publishStorageDealsReturn8) DealIDs() ([]abi.DealID, error) {
return r.IDs, nil
}

View File

@ -4,62 +4,51 @@ import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/go-state-types/proof"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}miner"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
{{end}}
)
func init() {
{{range .versions}}
builtin.RegisterActorState(builtin{{.}}.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load{{.}}(store, root)
})
{{end}}
}
var Methods = builtin{{.latestVersion}}.MethodsMiner
// Unchanged between v0, v2, v3, v4, and v5 actors
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
var WPoStPeriodDeadlines = miner0.WPoStPeriodDeadlines
var WPoStChallengeWindow = miner0.WPoStChallengeWindow
var WPoStChallengeLookback = miner0.WPoStChallengeLookback
var FaultDeclarationCutoff = miner0.FaultDeclarationCutoff
const MinSectorExpiration = miner0.MinSectorExpiration
// Not used / checked in v0
// TODO: Abstract over network versions
var DeclarationsMax = miner2.DeclarationsMax
var AddressedSectorsMax = miner2.AddressedSectorsMax
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.MinerKey {
return nil, xerrors.Errorf("actor code is not miner: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
case builtin{{.}}.StorageMinerActorCodeID:
return load{{.}}(store, act.Head)
{{if (le . 7)}}
case builtin{{.}}.StorageMinerActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -73,17 +62,6 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.StorageMinerActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -98,8 +76,8 @@ type State interface {
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
FindSector(abi.SectorNumber) (*SectorLocation, error)
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error
GetPrecommittedSector(abi.SectorNumber) (*miner{{.latestVersion}}.SectorPreCommitOnChainInfo, error)
ForEachPrecommittedSector(func(miner{{.latestVersion}}.SectorPreCommitOnChainInfo) error) error
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
@ -128,7 +106,7 @@ type State interface {
sectors() (adt.Array, error)
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner{{.latestVersion}}.SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
@ -166,44 +144,7 @@ type Partition interface {
UnprovenSectors() (bitfield.BitField, error)
}
type SectorOnChainInfo struct {
SectorNumber abi.SectorNumber
SealProof abi.RegisteredSealProof
SealedCID cid.Cid
DealIDs []abi.DealID
Activation abi.ChainEpoch
Expiration abi.ChainEpoch
DealWeight abi.DealWeight
VerifiedDealWeight abi.DealWeight
InitialPledge abi.TokenAmount
ExpectedDayReward abi.TokenAmount
ExpectedStoragePledge abi.TokenAmount
SectorKeyCID *cid.Cid
}
type SectorPreCommitInfo = miner0.SectorPreCommitInfo
type SectorPreCommitOnChainInfo struct {
Info SectorPreCommitInfo
PreCommitDeposit abi.TokenAmount
PreCommitEpoch abi.ChainEpoch
DealWeight abi.DealWeight
VerifiedDealWeight abi.DealWeight
}
type PoStPartition = miner0.PoStPartition
type RecoveryDeclaration = miner0.RecoveryDeclaration
type FaultDeclaration = miner0.FaultDeclaration
type ReplicaUpdate = miner7.ReplicaUpdate
// Params
type DeclareFaultsParams = miner0.DeclareFaultsParams
type DeclareFaultsRecoveredParams = miner0.DeclareFaultsRecoveredParams
type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams
type ProveCommitSectorParams = miner0.ProveCommitSectorParams
type DisputeWindowedPoStParams = miner3.DisputeWindowedPoStParams
type ProveCommitAggregateParams = miner5.ProveCommitAggregateParams
type ProveReplicaUpdatesParams = miner7.ProveReplicaUpdatesParams
type SectorOnChainInfo = miner{{.latestVersion}}.SectorOnChainInfo
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
// We added support for the new proofs in network version 7, and removed support for the old
@ -258,33 +199,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi
}
}
type MinerInfo struct {
Owner address.Address // Must be an ID-address.
Worker address.Address // Must be an ID-address.
NewWorker address.Address // Must be an ID-address.
ControlAddresses []address.Address // Must be an ID-addresses.
WorkerChangeEpoch abi.ChainEpoch
PeerId *peer.ID
Multiaddrs []abi.Multiaddrs
WindowPoStProofType abi.RegisteredPoStProof
SectorSize abi.SectorSize
WindowPoStPartitionSectors uint64
ConsensusFaultElapsed abi.ChainEpoch
}
func (mi MinerInfo) IsController(addr address.Address) bool {
if addr == mi.Owner || addr == mi.Worker {
return true
}
for _, ca := range mi.ControlAddresses {
if addr == ca {
return true
}
}
return false
}
type MinerInfo = miner{{.latestVersion}}.MinerInfo
type WorkerKeyChange = miner{{.latestVersion}}.WorkerKeyChange
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
type SectorExpiration struct {
OnTime abi.ChainEpoch
@ -311,8 +228,8 @@ type SectorExtensions struct {
}
type PreCommitChanges struct {
Added []SectorPreCommitOnChainInfo
Removed []SectorPreCommitOnChainInfo
Added []miner{{.latestVersion}}.SectorPreCommitOnChainInfo
Removed []miner{{.latestVersion}}.SectorPreCommitOnChainInfo
}
type LockedFunds struct {

View File

@ -4,27 +4,19 @@ import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/go-state-types/proof"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
@ -40,55 +32,20 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
)
func init() {
builtin.RegisterActorState(builtin0.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
builtin.RegisterActorState(builtin2.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
builtin.RegisterActorState(builtin3.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
builtin.RegisterActorState(builtin4.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
builtin.RegisterActorState(builtin6.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
builtin.RegisterActorState(builtin7.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
var Methods = builtin7.MethodsMiner
// Unchanged between v0, v2, v3, v4, and v5 actors
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
var WPoStPeriodDeadlines = miner0.WPoStPeriodDeadlines
var WPoStChallengeWindow = miner0.WPoStChallengeWindow
var WPoStChallengeLookback = miner0.WPoStChallengeLookback
var FaultDeclarationCutoff = miner0.FaultDeclarationCutoff
const MinSectorExpiration = miner0.MinSectorExpiration
// Not used / checked in v0
// TODO: Abstract over network versions
var DeclarationsMax = miner2.DeclarationsMax
var AddressedSectorsMax = miner2.AddressedSectorsMax
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.MinerKey {
return nil, xerrors.Errorf("actor code is not miner: %s", name)
}
switch av {
case actors.Version8:
return load8(store, act.Head)
}
}
switch act.Code {
case builtin0.StorageMinerActorCodeID:
@ -113,6 +70,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return load7(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -140,39 +98,13 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
case actors.Version7:
return make7(store)
case actors.Version8:
return make8(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.StorageMinerActorCodeID, nil
case actors.Version2:
return builtin2.StorageMinerActorCodeID, nil
case actors.Version3:
return builtin3.StorageMinerActorCodeID, nil
case actors.Version4:
return builtin4.StorageMinerActorCodeID, nil
case actors.Version5:
return builtin5.StorageMinerActorCodeID, nil
case actors.Version6:
return builtin6.StorageMinerActorCodeID, nil
case actors.Version7:
return builtin7.StorageMinerActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -187,8 +119,8 @@ type State interface {
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
FindSector(abi.SectorNumber) (*SectorLocation, error)
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error
GetPrecommittedSector(abi.SectorNumber) (*miner8.SectorPreCommitOnChainInfo, error)
ForEachPrecommittedSector(func(miner8.SectorPreCommitOnChainInfo) error) error
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
@ -217,7 +149,7 @@ type State interface {
sectors() (adt.Array, error)
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner8.SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
@ -255,44 +187,7 @@ type Partition interface {
UnprovenSectors() (bitfield.BitField, error)
}
type SectorOnChainInfo struct {
SectorNumber abi.SectorNumber
SealProof abi.RegisteredSealProof
SealedCID cid.Cid
DealIDs []abi.DealID
Activation abi.ChainEpoch
Expiration abi.ChainEpoch
DealWeight abi.DealWeight
VerifiedDealWeight abi.DealWeight
InitialPledge abi.TokenAmount
ExpectedDayReward abi.TokenAmount
ExpectedStoragePledge abi.TokenAmount
SectorKeyCID *cid.Cid
}
type SectorPreCommitInfo = miner0.SectorPreCommitInfo
type SectorPreCommitOnChainInfo struct {
Info SectorPreCommitInfo
PreCommitDeposit abi.TokenAmount
PreCommitEpoch abi.ChainEpoch
DealWeight abi.DealWeight
VerifiedDealWeight abi.DealWeight
}
type PoStPartition = miner0.PoStPartition
type RecoveryDeclaration = miner0.RecoveryDeclaration
type FaultDeclaration = miner0.FaultDeclaration
type ReplicaUpdate = miner7.ReplicaUpdate
// Params
type DeclareFaultsParams = miner0.DeclareFaultsParams
type DeclareFaultsRecoveredParams = miner0.DeclareFaultsRecoveredParams
type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams
type ProveCommitSectorParams = miner0.ProveCommitSectorParams
type DisputeWindowedPoStParams = miner3.DisputeWindowedPoStParams
type ProveCommitAggregateParams = miner5.ProveCommitAggregateParams
type ProveReplicaUpdatesParams = miner7.ProveReplicaUpdatesParams
type SectorOnChainInfo = miner8.SectorOnChainInfo
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
// We added support for the new proofs in network version 7, and removed support for the old
@ -347,33 +242,9 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi
}
}
type MinerInfo struct {
Owner address.Address // Must be an ID-address.
Worker address.Address // Must be an ID-address.
NewWorker address.Address // Must be an ID-address.
ControlAddresses []address.Address // Must be an ID-addresses.
WorkerChangeEpoch abi.ChainEpoch
PeerId *peer.ID
Multiaddrs []abi.Multiaddrs
WindowPoStProofType abi.RegisteredPoStProof
SectorSize abi.SectorSize
WindowPoStPartitionSectors uint64
ConsensusFaultElapsed abi.ChainEpoch
}
func (mi MinerInfo) IsController(addr address.Address) bool {
if addr == mi.Owner || addr == mi.Worker {
return true
}
for _, ca := range mi.ControlAddresses {
if addr == ca {
return true
}
}
return false
}
type MinerInfo = miner8.MinerInfo
type WorkerKeyChange = miner8.WorkerKeyChange
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
type SectorExpiration struct {
OnTime abi.ChainEpoch
@ -400,8 +271,8 @@ type SectorExtensions struct {
}
type PreCommitChanges struct {
Added []SectorPreCommitOnChainInfo
Removed []SectorPreCommitOnChainInfo
Added []miner8.SectorPreCommitOnChainInfo
Removed []miner8.SectorPreCommitOnChainInfo
}
type LockedFunds struct {

View File

@ -6,23 +6,28 @@ import (
{{if (le .v 1)}}
"github.com/filecoin-project/go-state-types/big"
{{end}}
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
{{if (ge .v 3)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
{{if (le .v 7)}}
{{if (ge .v 3)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
{{end}}
miner{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/miner"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
{{else}}
miner{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}miner"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
miner{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/miner"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
)
var _ State = (*state{{.v}})(nil)
@ -210,7 +215,7 @@ func (s *state{{.v}}) GetSectorExpiration(num abi.SectorNumber) (*SectorExpirati
return &out, nil
}
func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -221,7 +226,7 @@ func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCom
return &ret, nil
}
func (s *state{{.v}}) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state{{.v}}) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
{{if (ge .v 3) -}}
precommitted, err := adt{{.v}}.AsMap(s.store, s.State.PreCommittedSectors, builtin{{.v}}.DefaultHamtBitwidth)
{{- else -}}
@ -389,10 +394,6 @@ func (s *state{{.v}}) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
{{if (le .v 2)}}
wpp, err := info.SealProofType.RegisteredWindowPoStProof()
if err != nil {
@ -404,10 +405,9 @@ func (s *state{{.v}}) Info() (MinerInfo, error) {
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: {{if (ge .v 3)}}info.WindowPoStProofType{{else}}wpp{{end}},
SectorSize: info.SectorSize,
@ -415,11 +415,6 @@ func (s *state{{.v}}) Info() (MinerInfo, error) {
ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}},
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -449,11 +444,11 @@ func (s *state{{.v}}) precommits() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.PreCommittedSectors{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
}
func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner{{.v}}.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil
@ -584,18 +579,14 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO
return info
}
func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
{{if (ge .v 2)}}
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v{{.v}}.Info),
func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v{{.v}}.Info),
PreCommitDeposit: v{{.v}}.PreCommitDeposit,
PreCommitEpoch: v{{.v}}.PreCommitEpoch,
DealWeight: v{{.v}}.DealWeight,
VerifiedDealWeight: v{{.v}}.VerifiedDealWeight,
}
{{else}}
return (SectorPreCommitOnChainInfo)(v0)
{{end}}
}
func (s *state{{.v}}) GetState() interface{} {

View File

@ -6,16 +6,15 @@ import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
@ -197,7 +196,7 @@ func (s *state0) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -208,7 +207,7 @@ func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state0) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state0) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt0.AsMap(s.store, s.State.PreCommittedSectors)
if err != nil {
return err
@ -372,11 +371,6 @@ func (s *state0) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
wpp, err := info.SealProofType.RegisteredWindowPoStProof()
if err != nil {
return MinerInfo{}, err
@ -387,10 +381,9 @@ func (s *state0) Info() (MinerInfo, error) {
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: wpp,
SectorSize: info.SectorSize,
@ -398,11 +391,6 @@ func (s *state0) Info() (MinerInfo, error) {
ConsensusFaultElapsed: -1,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -432,11 +420,11 @@ func (s *state0) precommits() (adt.Map, error) {
return adt0.AsMap(s.store, s.PreCommittedSectors)
}
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner0.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV0SectorPreCommitOnChainInfo(sp), nil
@ -522,10 +510,14 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return (SectorPreCommitOnChainInfo)(v0)
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v0.Info),
PreCommitDeposit: v0.PreCommitDeposit,
PreCommitEpoch: v0.PreCommitEpoch,
DealWeight: v0.DealWeight,
VerifiedDealWeight: v0.VerifiedDealWeight,
}
}
func (s *state0) GetState() interface{} {

View File

@ -4,16 +4,15 @@ import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
@ -195,7 +194,7 @@ func (s *state2) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -206,7 +205,7 @@ func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state2) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state2) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt2.AsMap(s.store, s.State.PreCommittedSectors)
if err != nil {
return err
@ -370,11 +369,6 @@ func (s *state2) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
wpp, err := info.SealProofType.RegisteredWindowPoStProof()
if err != nil {
return MinerInfo{}, err
@ -385,10 +379,9 @@ func (s *state2) Info() (MinerInfo, error) {
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: wpp,
SectorSize: info.SectorSize,
@ -396,11 +389,6 @@ func (s *state2) Info() (MinerInfo, error) {
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -430,11 +418,11 @@ func (s *state2) precommits() (adt.Map, error) {
return adt2.AsMap(s.store, s.PreCommittedSectors)
}
func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner2.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV2SectorPreCommitOnChainInfo(sp), nil
@ -552,16 +540,14 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v2.Info),
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v2.Info),
PreCommitDeposit: v2.PreCommitDeposit,
PreCommitEpoch: v2.PreCommitEpoch,
DealWeight: v2.DealWeight,
VerifiedDealWeight: v2.VerifiedDealWeight,
}
}
func (s *state2) GetState() interface{} {

View File

@ -4,16 +4,15 @@ import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
@ -197,7 +196,7 @@ func (s *state3) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -208,7 +207,7 @@ func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state3) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state3) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt3.AsMap(s.store, s.State.PreCommittedSectors, builtin3.DefaultHamtBitwidth)
if err != nil {
return err
@ -372,20 +371,14 @@ func (s *state3) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
@ -393,11 +386,6 @@ func (s *state3) Info() (MinerInfo, error) {
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -427,11 +415,11 @@ func (s *state3) precommits() (adt.Map, error) {
return adt3.AsMap(s.store, s.PreCommittedSectors, builtin3.DefaultHamtBitwidth)
}
func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner3.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV3SectorPreCommitOnChainInfo(sp), nil
@ -553,16 +541,14 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v3.Info),
func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v3.Info),
PreCommitDeposit: v3.PreCommitDeposit,
PreCommitEpoch: v3.PreCommitEpoch,
DealWeight: v3.DealWeight,
VerifiedDealWeight: v3.VerifiedDealWeight,
}
}
func (s *state3) GetState() interface{} {

View File

@ -4,16 +4,15 @@ import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
@ -197,7 +196,7 @@ func (s *state4) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -208,7 +207,7 @@ func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state4) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state4) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt4.AsMap(s.store, s.State.PreCommittedSectors, builtin4.DefaultHamtBitwidth)
if err != nil {
return err
@ -372,20 +371,14 @@ func (s *state4) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
@ -393,11 +386,6 @@ func (s *state4) Info() (MinerInfo, error) {
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -427,11 +415,11 @@ func (s *state4) precommits() (adt.Map, error) {
return adt4.AsMap(s.store, s.PreCommittedSectors, builtin4.DefaultHamtBitwidth)
}
func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner4.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV4SectorPreCommitOnChainInfo(sp), nil
@ -553,16 +541,14 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v4.Info),
func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v4.Info),
PreCommitDeposit: v4.PreCommitDeposit,
PreCommitEpoch: v4.PreCommitEpoch,
DealWeight: v4.DealWeight,
VerifiedDealWeight: v4.VerifiedDealWeight,
}
}
func (s *state4) GetState() interface{} {

View File

@ -4,16 +4,15 @@ import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
@ -197,7 +196,7 @@ func (s *state5) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -208,7 +207,7 @@ func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state5) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state5) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt5.AsMap(s.store, s.State.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
if err != nil {
return err
@ -372,20 +371,14 @@ func (s *state5) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
@ -393,11 +386,6 @@ func (s *state5) Info() (MinerInfo, error) {
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -427,11 +415,11 @@ func (s *state5) precommits() (adt.Map, error) {
return adt5.AsMap(s.store, s.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
}
func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner5.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV5SectorPreCommitOnChainInfo(sp), nil
@ -553,16 +541,14 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v5.Info),
func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v5.Info),
PreCommitDeposit: v5.PreCommitDeposit,
PreCommitEpoch: v5.PreCommitEpoch,
DealWeight: v5.DealWeight,
VerifiedDealWeight: v5.VerifiedDealWeight,
}
}
func (s *state5) GetState() interface{} {

View File

@ -4,16 +4,15 @@ import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
@ -197,7 +196,7 @@ func (s *state6) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -208,7 +207,7 @@ func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state6) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state6) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt6.AsMap(s.store, s.State.PreCommittedSectors, builtin6.DefaultHamtBitwidth)
if err != nil {
return err
@ -372,20 +371,14 @@ func (s *state6) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
@ -393,11 +386,6 @@ func (s *state6) Info() (MinerInfo, error) {
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -427,11 +415,11 @@ func (s *state6) precommits() (adt.Map, error) {
return adt6.AsMap(s.store, s.PreCommittedSectors, builtin6.DefaultHamtBitwidth)
}
func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner6.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV6SectorPreCommitOnChainInfo(sp), nil
@ -553,16 +541,14 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v6.Info),
func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v6.Info),
PreCommitDeposit: v6.PreCommitDeposit,
PreCommitEpoch: v6.PreCommitEpoch,
DealWeight: v6.DealWeight,
VerifiedDealWeight: v6.VerifiedDealWeight,
}
}
func (s *state6) GetState() interface{} {

View File

@ -4,16 +4,15 @@ import (
"bytes"
"errors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
@ -196,7 +195,7 @@ func (s *state7) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
return &out, nil
}
func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
@ -207,7 +206,7 @@ func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOn
return &ret, nil
}
func (s *state7) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
func (s *state7) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt7.AsMap(s.store, s.State.PreCommittedSectors, builtin7.DefaultHamtBitwidth)
if err != nil {
return err
@ -371,20 +370,14 @@ func (s *state7) Info() (MinerInfo, error) {
return MinerInfo{}, err
}
var pid *peer.ID
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
pid = &peerID
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: pid,
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
@ -392,11 +385,6 @@ func (s *state7) Info() (MinerInfo, error) {
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
if info.PendingWorkerKey != nil {
mi.NewWorker = info.PendingWorkerKey.NewWorker
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
}
return mi, nil
}
@ -426,11 +414,11 @@ func (s *state7) precommits() (adt.Map, error) {
return adt7.AsMap(s.store, s.PreCommittedSectors, builtin7.DefaultHamtBitwidth)
}
func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner7.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorPreCommitOnChainInfo{}, err
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV7SectorPreCommitOnChainInfo(sp), nil
@ -554,16 +542,14 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo {
return info
}
func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v7.Info),
func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v7.Info),
PreCommitDeposit: v7.PreCommitDeposit,
PreCommitEpoch: v7.PreCommitEpoch,
DealWeight: v7.DealWeight,
VerifiedDealWeight: v7.VerifiedDealWeight,
}
}
func (s *state7) GetState() interface{} {

View File

@ -0,0 +1,556 @@
package miner
import (
"bytes"
"errors"
"github.com/filecoin-project/go-bitfield"
rle "github.com/filecoin-project/go-bitfield/rle"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
)
var _ State = (*state8)(nil)
func load8(store adt.Store, root cid.Cid) (State, error) {
out := state8{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make8(store adt.Store) (State, error) {
out := state8{store: store}
out.State = miner8.State{}
return &out, nil
}
type state8 struct {
miner8.State
store adt.Store
}
type deadline8 struct {
miner8.Deadline
store adt.Store
}
type partition8 struct {
miner8.Partition
store adt.Store
}
func (s *state8) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) {
defer func() {
if r := recover(); r != nil {
err = xerrors.Errorf("failed to get available balance: %w", r)
available = abi.NewTokenAmount(0)
}
}()
// this panics if the miner doesnt have enough funds to cover their locked pledge
available, err = s.GetAvailableBalance(bal)
return available, err
}
func (s *state8) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.CheckVestedFunds(s.store, epoch)
}
func (s *state8) LockedFunds() (LockedFunds, error) {
return LockedFunds{
VestingFunds: s.State.LockedFunds,
InitialPledgeRequirement: s.State.InitialPledge,
PreCommitDeposits: s.State.PreCommitDeposits,
}, nil
}
func (s *state8) FeeDebt() (abi.TokenAmount, error) {
return s.State.FeeDebt, nil
}
func (s *state8) InitialPledge() (abi.TokenAmount, error) {
return s.State.InitialPledge, nil
}
func (s *state8) PreCommitDeposits() (abi.TokenAmount, error) {
return s.State.PreCommitDeposits, nil
}
func (s *state8) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
info, ok, err := s.State.GetSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV8SectorOnChainInfo(*info)
return &ret, nil
}
func (s *state8) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
if err != nil {
return nil, err
}
return &SectorLocation{
Deadline: dlIdx,
Partition: partIdx,
}, nil
}
func (s *state8) NumLiveSectors() (uint64, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return 0, err
}
var total uint64
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner8.Deadline) error {
total += dl.LiveSectors
return nil
}); err != nil {
return 0, err
}
return total, nil
}
// GetSectorExpiration returns the effective expiration of the given sector.
//
// If the sector does not expire early, the Early expiration field is 0.
func (s *state8) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return nil, err
}
// NOTE: this can be optimized significantly.
// 1. If the sector is non-faulty, it will expire on-time (can be
// learned from the sector info).
// 2. If it's faulty, it will expire early within the first 42 entries
// of the expiration queue.
stopErr := errors.New("stop")
out := SectorExpiration{}
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner8.Deadline) error {
partitions, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
quant := s.State.QuantSpecForDeadline(dlIdx)
var part miner8.Partition
return partitions.ForEach(&part, func(partIdx int64) error {
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
return err
} else if !found {
return nil
}
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
return err
} else if found {
// already terminated
return stopErr
}
q, err := miner8.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner8.PartitionExpirationAmtBitwidth)
if err != nil {
return err
}
var exp miner8.ExpirationSet
return q.ForEach(&exp, func(epoch int64) error {
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
return err
} else if early {
out.Early = abi.ChainEpoch(epoch)
return nil
}
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
return err
} else if onTime {
out.OnTime = abi.ChainEpoch(epoch)
return stopErr
}
return nil
})
})
})
if err == stopErr {
err = nil
}
if err != nil {
return nil, err
}
if out.Early == 0 && out.OnTime == 0 {
return nil, xerrors.Errorf("failed to find sector %d", num)
}
return &out, nil
}
func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
if !ok || err != nil {
return nil, err
}
ret := fromV8SectorPreCommitOnChainInfo(*info)
return &ret, nil
}
func (s *state8) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
precommitted, err := adt8.AsMap(s.store, s.State.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
if err != nil {
return err
}
var info miner8.SectorPreCommitOnChainInfo
if err := precommitted.ForEach(&info, func(_ string) error {
return cb(fromV8SectorPreCommitOnChainInfo(info))
}); err != nil {
return err
}
return nil
}
func (s *state8) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
sectors, err := miner8.LoadSectors(s.store, s.State.Sectors)
if err != nil {
return nil, err
}
// If no sector numbers are specified, load all.
if snos == nil {
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
var info8 miner8.SectorOnChainInfo
if err := sectors.ForEach(&info8, func(_ int64) error {
info := fromV8SectorOnChainInfo(info8)
infos = append(infos, &info)
return nil
}); err != nil {
return nil, err
}
return infos, nil
}
// Otherwise, load selected.
infos8, err := sectors.Load(*snos)
if err != nil {
return nil, err
}
infos := make([]*SectorOnChainInfo, len(infos8))
for i, info8 := range infos8 {
info := fromV8SectorOnChainInfo(*info8)
infos[i] = &info
}
return infos, nil
}
func (s *state8) loadAllocatedSectorNumbers() (bitfield.BitField, error) {
var allocatedSectors bitfield.BitField
err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors)
return allocatedSectors, err
}
func (s *state8) IsAllocated(num abi.SectorNumber) (bool, error) {
allocatedSectors, err := s.loadAllocatedSectorNumbers()
if err != nil {
return false, err
}
return allocatedSectors.IsSet(uint64(num))
}
func (s *state8) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state8) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) {
allocatedSectors, err := s.loadAllocatedSectorNumbers()
if err != nil {
return nil, err
}
allocatedRuns, err := allocatedSectors.RunIterator()
if err != nil {
return nil, err
}
unallocatedRuns, err := rle.Subtract(
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
allocatedRuns,
)
if err != nil {
return nil, err
}
iter, err := rle.BitsFromRuns(unallocatedRuns)
if err != nil {
return nil, err
}
sectors := make([]abi.SectorNumber, 0, count)
for iter.HasNext() && len(sectors) < count {
nextNo, err := iter.Next()
if err != nil {
return nil, err
}
sectors = append(sectors, abi.SectorNumber(nextNo))
}
return sectors, nil
}
func (s *state8) GetAllocatedSectors() (*bitfield.BitField, error) {
var allocatedSectors bitfield.BitField
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
return nil, err
}
return &allocatedSectors, nil
}
func (s *state8) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return nil, err
}
dl, err := dls.LoadDeadline(s.store, idx)
if err != nil {
return nil, err
}
return &deadline8{*dl, s.store}, nil
}
func (s *state8) ForEachDeadline(cb func(uint64, Deadline) error) error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
return dls.ForEach(s.store, func(i uint64, dl *miner8.Deadline) error {
return cb(i, &deadline8{*dl, s.store})
})
}
func (s *state8) NumDeadlines() (uint64, error) {
return miner8.WPoStPeriodDeadlines, nil
}
func (s *state8) DeadlinesChanged(other State) (bool, error) {
other8, ok := other.(*state8)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Deadlines.Equals(other8.Deadlines), nil
}
func (s *state8) MinerInfoChanged(other State) (bool, error) {
other0, ok := other.(*state8)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.Info.Equals(other0.State.Info), nil
}
func (s *state8) Info() (MinerInfo, error) {
info, err := s.State.GetInfo(s.store)
if err != nil {
return MinerInfo{}, err
}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
PeerId: info.PeerId,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: info.WindowPoStProofType,
SectorSize: info.SectorSize,
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
}
return mi, nil
}
func (s *state8) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
return s.State.RecordedDeadlineInfo(epoch), nil
}
func (s *state8) DeadlineCronActive() (bool, error) {
return s.State.DeadlineCronActive, nil
}
func (s *state8) sectors() (adt.Array, error) {
return adt8.AsArray(s.store, s.Sectors, miner8.SectorsAmtBitwidth)
}
func (s *state8) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
var si miner8.SectorOnChainInfo
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return SectorOnChainInfo{}, err
}
return fromV8SectorOnChainInfo(si), nil
}
func (s *state8) precommits() (adt.Map, error) {
return adt8.AsMap(s.store, s.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
}
func (s *state8) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
var sp miner8.SectorPreCommitOnChainInfo
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
if err != nil {
return minertypes.SectorPreCommitOnChainInfo{}, err
}
return fromV8SectorPreCommitOnChainInfo(sp), nil
}
func (s *state8) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner8.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner8.Partition
err = ps.ForEach(&part, func(pindx int64) error {
_ = part.ActivateUnproven()
err = ps.Set(uint64(pindx), &part)
return nil
})
if err != nil {
return err
}
dl.Partitions, err = ps.Root()
if err != nil {
return err
}
return dls.UpdateDeadline(s.store, dindx, dl)
})
if err != nil {
return err
}
return s.State.SaveDeadlines(s.store, dls)
}
func (d *deadline8) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
return nil, err
}
return &partition8{*p, d.store}, nil
}
func (d *deadline8) ForEachPartition(cb func(uint64, Partition) error) error {
ps, err := d.Deadline.PartitionsArray(d.store)
if err != nil {
return err
}
var part miner8.Partition
return ps.ForEach(&part, func(i int64) error {
return cb(uint64(i), &partition8{part, d.store})
})
}
func (d *deadline8) PartitionsChanged(other Deadline) (bool, error) {
other8, ok := other.(*deadline8)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !d.Deadline.Partitions.Equals(other8.Deadline.Partitions), nil
}
func (d *deadline8) PartitionsPoSted() (bitfield.BitField, error) {
return d.Deadline.PartitionsPoSted, nil
}
func (d *deadline8) DisputableProofCount() (uint64, error) {
ops, err := d.OptimisticProofsSnapshotArray(d.store)
if err != nil {
return 0, err
}
return ops.Length(), nil
}
func (p *partition8) AllSectors() (bitfield.BitField, error) {
return p.Partition.Sectors, nil
}
func (p *partition8) FaultySectors() (bitfield.BitField, error) {
return p.Partition.Faults, nil
}
func (p *partition8) RecoveringSectors() (bitfield.BitField, error) {
return p.Partition.Recoveries, nil
}
func (p *partition8) UnprovenSectors() (bitfield.BitField, error) {
return p.Partition.Unproven, nil
}
func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo {
info := SectorOnChainInfo{
SectorNumber: v8.SectorNumber,
SealProof: v8.SealProof,
SealedCID: v8.SealedCID,
DealIDs: v8.DealIDs,
Activation: v8.Activation,
Expiration: v8.Expiration,
DealWeight: v8.DealWeight,
VerifiedDealWeight: v8.VerifiedDealWeight,
InitialPledge: v8.InitialPledge,
ExpectedDayReward: v8.ExpectedDayReward,
ExpectedStoragePledge: v8.ExpectedStoragePledge,
SectorKeyCID: v8.SectorKeyCID,
}
return info
}
func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
return minertypes.SectorPreCommitOnChainInfo{
Info: (minertypes.SectorPreCommitInfo)(v8.Info),
PreCommitDeposit: v8.PreCommitDeposit,
PreCommitEpoch: v8.PreCommitEpoch,
DealWeight: v8.DealWeight,
VerifiedDealWeight: v8.VerifiedDealWeight,
}
}
func (s *state8) GetState() interface{} {
return &s.State
}

View File

@ -10,34 +10,46 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
msig{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/multisig"
msig{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}multisig"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{else}}
builtin{{.}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
{{end}}
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
func init() {
{{range .versions}}
builtin.RegisterActorState(builtin{{.}}.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load{{.}}(store, root)
})
{{end}}}
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.MultisigKey {
return nil, xerrors.Errorf("actor code is not multisig: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
case builtin{{.}}.MultisigActorCodeID:
return load{{.}}(store, act.Head)
{{if (le . 7)}}
case builtin{{.}}.MultisigActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -51,17 +63,6 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.MultisigActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -80,7 +81,7 @@ type State interface {
GetState() interface{}
}
type Transaction = msig0.Transaction
type Transaction = msig{{.latestVersion}}.Transaction
var Methods = builtin{{.latestVersion}}.MethodsMultisig

View File

@ -6,9 +6,17 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
multisig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig"
{{if (le .v 7)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
multisig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig"
{{else}}
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
multisig{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init"
"github.com/filecoin-project/lotus/chain/actors/builtin"
{{end}}
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
@ -54,11 +62,24 @@ func (m message{{.v}}) Create(
return nil, actErr
}
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init{{.v}}.ExecParams{
CodeCID: builtin{{.v}}.MultisigActorCodeID,
ConstructorParams: enc,
}
{{if (le .v 7)}}
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init{{.v}}.ExecParams{
CodeCID: builtin{{.v}}.MultisigActorCodeID,
ConstructorParams: enc,
}
{{else}}
code, err := builtin.GetMultisigActorCodeID(actors.Version{{.v}})
if err != nil {
return nil, xerrors.Errorf("failed to get multisig code ID")
}
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init8.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}
{{end}}
enc, actErr = actors.SerializeParams(execParams)
if actErr != nil {

View File

@ -0,0 +1,77 @@
package multisig
import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
init8 "github.com/filecoin-project/go-state-types/builtin/v8/init"
multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/types"
)
type message8 struct{ message0 }
func (m message8) Create(
signers []address.Address, threshold uint64,
unlockStart, unlockDuration abi.ChainEpoch,
initialAmount abi.TokenAmount,
) (*types.Message, error) {
lenAddrs := uint64(len(signers))
if lenAddrs < threshold {
return nil, xerrors.Errorf("cannot require signing of more addresses than provided for multisig")
}
if threshold == 0 {
threshold = lenAddrs
}
if m.from == address.Undef {
return nil, xerrors.Errorf("must provide source address")
}
// Set up constructor parameters for multisig
msigParams := &multisig8.ConstructorParams{
Signers: signers,
NumApprovalsThreshold: threshold,
UnlockDuration: unlockDuration,
StartEpoch: unlockStart,
}
enc, actErr := actors.SerializeParams(msigParams)
if actErr != nil {
return nil, actErr
}
code, err := builtin.GetMultisigActorCodeID(actors.Version8)
if err != nil {
return nil, xerrors.Errorf("failed to get multisig code ID")
}
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init8.ExecParams{
CodeCID: code,
ConstructorParams: enc,
}
enc, actErr = actors.SerializeParams(execParams)
if actErr != nil {
return nil, actErr
}
return &types.Message{
To: init_.Address,
From: m.from,
Method: builtin8.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
}, nil
}

View File

@ -10,10 +10,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig"
msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
@ -29,44 +27,27 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
func init() {
builtin.RegisterActorState(builtin0.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load0(store, root)
})
builtin.RegisterActorState(builtin2.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load2(store, root)
})
builtin.RegisterActorState(builtin3.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load3(store, root)
})
builtin.RegisterActorState(builtin4.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load4(store, root)
})
builtin.RegisterActorState(builtin5.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load5(store, root)
})
builtin.RegisterActorState(builtin6.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load6(store, root)
})
builtin.RegisterActorState(builtin7.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load7(store, root)
})
}
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.MultisigKey {
return nil, xerrors.Errorf("actor code is not multisig: %s", name)
}
switch av {
case actors.Version8:
return load8(store, act.Head)
}
}
switch act.Code {
case builtin0.MultisigActorCodeID:
@ -91,6 +72,7 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return load7(store, act.Head)
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
@ -118,39 +100,13 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th
case actors.Version7:
return make7(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version8:
return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.MultisigActorCodeID, nil
case actors.Version2:
return builtin2.MultisigActorCodeID, nil
case actors.Version3:
return builtin3.MultisigActorCodeID, nil
case actors.Version4:
return builtin4.MultisigActorCodeID, nil
case actors.Version5:
return builtin5.MultisigActorCodeID, nil
case actors.Version6:
return builtin6.MultisigActorCodeID, nil
case actors.Version7:
return builtin7.MultisigActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -169,9 +125,9 @@ type State interface {
GetState() interface{}
}
type Transaction = msig0.Transaction
type Transaction = msig8.Transaction
var Methods = builtin7.MethodsMultisig
var Methods = builtin8.MethodsMultisig
func Message(version actors.Version, from address.Address) MessageBuilder {
switch version {
@ -196,6 +152,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
case actors.Version7:
return message7{message0{from}}
case actors.Version8:
return message8{message0{from}}
default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}
@ -219,13 +178,13 @@ type MessageBuilder interface {
}
// this type is the same between v0 and v2
type ProposalHashData = msig7.ProposalHashData
type ProposeReturn = msig7.ProposeReturn
type ProposeParams = msig7.ProposeParams
type ApproveReturn = msig7.ApproveReturn
type ProposalHashData = msig8.ProposalHashData
type ProposeReturn = msig8.ProposeReturn
type ProposeParams = msig8.ProposeParams
type ApproveReturn = msig8.ApproveReturn
func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig7.TxnIDParams{ID: msig7.TxnID(id)}
params := msig8.TxnIDParams{ID: msig8.TxnID(id)}
if data != nil {
if data.Requester.Protocol() != address.ID {
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)

View File

@ -4,7 +4,6 @@ import (
"bytes"
"encoding/binary"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
@ -14,10 +13,17 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
{{if (ge .v 3)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
{{if (le .v 7)}}
{{if (ge .v 3)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
{{end}}
msig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig"
adt{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/util/adt"
{{else}}
msig{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}multisig"
adt{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}util/adt"
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
{{end}}
msig{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/multisig"
)
var _ State = (*state{{.v}})(nil)
@ -119,7 +125,7 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error)
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state{{.v}}) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -15,6 +13,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
)
var _ State = (*state0)(nil)
@ -109,7 +108,7 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state0) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -15,6 +13,7 @@ import (
"github.com/filecoin-project/lotus/chain/actors/adt"
msig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
)
var _ State = (*state2)(nil)
@ -109,7 +108,7 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state2) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -17,6 +15,7 @@ import (
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
msig3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/multisig"
adt3 "github.com/filecoin-project/specs-actors/v3/actors/util/adt"
)
var _ State = (*state3)(nil)
@ -111,7 +110,7 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state3) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -17,6 +15,7 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
msig4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/multisig"
adt4 "github.com/filecoin-project/specs-actors/v4/actors/util/adt"
)
var _ State = (*state4)(nil)
@ -111,7 +110,7 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state4) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -17,6 +15,7 @@ import (
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
msig5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/multisig"
adt5 "github.com/filecoin-project/specs-actors/v5/actors/util/adt"
)
var _ State = (*state5)(nil)
@ -111,7 +110,7 @@ func (s *state5) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state5) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -17,6 +15,7 @@ import (
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
msig6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/multisig"
adt6 "github.com/filecoin-project/specs-actors/v6/actors/util/adt"
)
var _ State = (*state6)(nil)
@ -111,7 +110,7 @@ func (s *state6) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state6) GetState() interface{} {

View File

@ -4,8 +4,6 @@ import (
"bytes"
"encoding/binary"
adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
@ -17,6 +15,7 @@ import (
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig"
adt7 "github.com/filecoin-project/specs-actors/v7/actors/util/adt"
)
var _ State = (*state7)(nil)
@ -111,7 +110,7 @@ func (s *state7) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return tx, nil
return Transaction(tx), nil
}
func (s *state7) GetState() interface{} {

View File

@ -0,0 +1,117 @@
package multisig
import (
"bytes"
"encoding/binary"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/adt"
builtin8 "github.com/filecoin-project/go-state-types/builtin"
msig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
)
var _ State = (*state8)(nil)
func load8(store adt.Store, root cid.Cid) (State, error) {
out := state8{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make8(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state8{store: store}
out.State = msig8.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt8.StoreEmptyMap(store, builtin8.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state8 struct {
msig8.State
store adt.Store
}
func (s *state8) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
}
func (s *state8) StartEpoch() (abi.ChainEpoch, error) {
return s.State.StartEpoch, nil
}
func (s *state8) UnlockDuration() (abi.ChainEpoch, error) {
return s.State.UnlockDuration, nil
}
func (s *state8) InitialBalance() (abi.TokenAmount, error) {
return s.State.InitialBalance, nil
}
func (s *state8) Threshold() (uint64, error) {
return s.State.NumApprovalsThreshold, nil
}
func (s *state8) Signers() ([]address.Address, error) {
return s.State.Signers, nil
}
func (s *state8) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
arr, err := adt8.AsMap(s.store, s.State.PendingTxns, builtin8.DefaultHamtBitwidth)
if err != nil {
return err
}
var out msig8.Transaction
return arr.ForEach(&out, func(key string) error {
txid, n := binary.Varint([]byte(key))
if n <= 0 {
return xerrors.Errorf("invalid pending transaction key: %v", key)
}
return cb(txid, (Transaction)(out)) //nolint:unconvert
})
}
func (s *state8) PendingTxnChanged(other State) (bool, error) {
other8, ok := other.(*state8)
if !ok {
// treat an upgrade as a change, always
return true, nil
}
return !s.State.PendingTxns.Equals(other8.PendingTxns), nil
}
func (s *state8) transactions() (adt.Map, error) {
return adt8.AsMap(s.store, s.PendingTxns, builtin8.DefaultHamtBitwidth)
}
func (s *state8) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
var tx msig8.Transaction
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
return Transaction{}, err
}
return Transaction(tx), nil
}
func (s *state8) GetState() interface{} {
return &s.State
}

View File

@ -10,59 +10,50 @@ import (
"github.com/filecoin-project/go-state-types/abi"
big "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/ipfs/go-cid"
ipldcbor "github.com/ipfs/go-ipld-cbor"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{if (le . 7)}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
{{end}}
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
)
func init() {
{{range .versions}}
builtin.RegisterActorState(builtin{{.}}.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
return load{{.}}(store, root)
})
{{end}}}
// Load returns an abstract copy of payment channel state, irregardless of actor version
func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != actors.PaychKey {
return nil, xerrors.Errorf("actor code is not paych: %s", name)
}
switch av {
{{range .versions}}
{{if (ge . 8)}}
case actors.Version{{.}}:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
}
switch act.Code {
{{range .versions}}
case builtin{{.}}.PaymentChannelActorCodeID:
return load{{.}}(store, act.Head)
{{if (le . 7)}}
case builtin{{.}}.PaymentChannelActorCodeID:
return load{{.}}(store, act.Head)
{{end}}
{{end}}
}
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store)
{{end}}
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return builtin{{.}}.PaymentChannelActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
// State is an abstract version of payment channel state that works across
// versions
type State interface {
@ -93,17 +84,14 @@ type LaneState interface {
Nonce() (uint64, error)
}
type SignedVoucher = paych0.SignedVoucher
type ModVerifyParams = paych0.ModVerifyParams
// DecodeSignedVoucher decodes base64 encoded signed voucher.
func DecodeSignedVoucher(s string) (*SignedVoucher, error) {
func DecodeSignedVoucher(s string) (*paychtypes.SignedVoucher, error) {
data, err := base64.RawURLEncoding.DecodeString(s)
if err != nil {
return nil, err
}
var sv SignedVoucher
var sv paychtypes.SignedVoucher
if err := ipldcbor.DecodeInto(data, &sv); err != nil {
return nil, err
}
@ -111,8 +99,6 @@ func DecodeSignedVoucher(s string) (*SignedVoucher, error) {
return &sv, nil
}
var Methods = builtin{{.latestVersion}}.MethodsPaych
func Message(version actors.Version, from address.Address) MessageBuilder {
switch version {
{{range .versions}}
@ -126,7 +112,23 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
type MessageBuilder interface {
Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error)
Update(paych address.Address, voucher *SignedVoucher, secret []byte) (*types.Message, error)
Update(paych address.Address, voucher *paychtypes.SignedVoucher, secret []byte) (*types.Message, error)
Settle(paych address.Address) (*types.Message, error)
Collect(paych address.Address) (*types.Message, error)
}
func toV0SignedVoucher(sv paychtypes.SignedVoucher) paych0.SignedVoucher {
return paych0.SignedVoucher{
ChannelAddr: sv.ChannelAddr,
TimeLockMin: sv.TimeLockMin,
TimeLockMax: sv.TimeLockMax,
SecretPreimage: sv.SecretHash,
Extra: (*paych0.ModVerifyParams)(sv.Extra),
Lane: sv.Lane,
Nonce: sv.Nonce,
Amount: sv.Amount,
MinSettleHeight: sv.MinSettleHeight,
Merges: nil,
Signature: sv.Signature,
}
}

View File

@ -1,12 +1,24 @@
package paych
import (
{{if (ge .v 8)}}
"golang.org/x/xerrors"
{{end}}
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
{{if (le .v 7)}}
builtin{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin"
init{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/init"
paych{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/paych"
{{else}}
builtin{{.v}} "github.com/filecoin-project/go-state-types/builtin"
paych{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/paych"
init{{.v}} "github.com/filecoin-project/go-state-types/builtin/v8/init"
{{end}}
"github.com/filecoin-project/lotus/chain/actors"
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
@ -16,12 +28,21 @@ import (
type message{{.v}} struct{ from address.Address }
func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
{{if (le .v 7)}}
actorCodeID := builtin{{.v}}.PaymentChannelActorCodeID
{{else}}
actorCodeID, ok := actors.GetActorCodeID(actors.Version{{.v}}, "paymentchannel")
if !ok {
return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", {{.v}})
}
{{end}}
params, aerr := actors.SerializeParams(&paych{{.v}}.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init{{.v}}.ExecParams{
CodeCID: builtin{{.v}}.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +58,10 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount)
}, nil
}
func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message{{.v}}) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{
{{if (ge .v 7)}}
Sv: toV{{.v}}SignedVoucher(*sv),
{{if (le .v 6)}}
Sv: toV0SignedVoucher(*sv),
{{else}}
Sv: *sv,
{{end}}

View File

@ -4,6 +4,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
init0 "github.com/filecoin-project/specs-actors/actors/builtin/init"
paych0 "github.com/filecoin-project/specs-actors/actors/builtin/paych"
@ -16,12 +18,15 @@ import (
type message0 struct{ from address.Address }
func (m message0) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID := builtin0.PaymentChannelActorCodeID
params, aerr := actors.SerializeParams(&paych0.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init0.ExecParams{
CodeCID: builtin0.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +42,10 @@ func (m message0) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
}, nil
}
func (m message0) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message0) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych0.UpdateChannelStateParams{
Sv: *sv,
Sv: toV0SignedVoucher(*sv),
Secret: secret,
})

View File

@ -4,6 +4,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
init2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/init"
paych2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/paych"
@ -16,12 +18,15 @@ import (
type message2 struct{ from address.Address }
func (m message2) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID := builtin2.PaymentChannelActorCodeID
params, aerr := actors.SerializeParams(&paych2.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init2.ExecParams{
CodeCID: builtin2.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +42,10 @@ func (m message2) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
}, nil
}
func (m message2) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message2) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych2.UpdateChannelStateParams{
Sv: *sv,
Sv: toV0SignedVoucher(*sv),
Secret: secret,
})

View File

@ -4,6 +4,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
init3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/init"
paych3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/paych"
@ -16,12 +18,15 @@ import (
type message3 struct{ from address.Address }
func (m message3) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID := builtin3.PaymentChannelActorCodeID
params, aerr := actors.SerializeParams(&paych3.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init3.ExecParams{
CodeCID: builtin3.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +42,10 @@ func (m message3) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
}, nil
}
func (m message3) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message3) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych3.UpdateChannelStateParams{
Sv: *sv,
Sv: toV0SignedVoucher(*sv),
Secret: secret,
})

View File

@ -4,6 +4,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
init4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/init"
paych4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/paych"
@ -16,12 +18,15 @@ import (
type message4 struct{ from address.Address }
func (m message4) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID := builtin4.PaymentChannelActorCodeID
params, aerr := actors.SerializeParams(&paych4.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init4.ExecParams{
CodeCID: builtin4.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +42,10 @@ func (m message4) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
}, nil
}
func (m message4) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message4) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych4.UpdateChannelStateParams{
Sv: *sv,
Sv: toV0SignedVoucher(*sv),
Secret: secret,
})

View File

@ -4,6 +4,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
init5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/init"
paych5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/paych"
@ -16,12 +18,15 @@ import (
type message5 struct{ from address.Address }
func (m message5) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID := builtin5.PaymentChannelActorCodeID
params, aerr := actors.SerializeParams(&paych5.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init5.ExecParams{
CodeCID: builtin5.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +42,10 @@ func (m message5) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
}, nil
}
func (m message5) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message5) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych5.UpdateChannelStateParams{
Sv: *sv,
Sv: toV0SignedVoucher(*sv),
Secret: secret,
})

View File

@ -4,6 +4,8 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
init6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/init"
paych6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/paych"
@ -16,12 +18,15 @@ import (
type message6 struct{ from address.Address }
func (m message6) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
actorCodeID := builtin6.PaymentChannelActorCodeID
params, aerr := actors.SerializeParams(&paych6.ConstructorParams{From: m.from, To: to})
if aerr != nil {
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init6.ExecParams{
CodeCID: builtin6.PaymentChannelActorCodeID,
CodeCID: actorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -37,10 +42,10 @@ func (m message6) Create(to address.Address, initialAmount abi.TokenAmount) (*ty
}, nil
}
func (m message6) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
func (m message6) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych6.UpdateChannelStateParams{
Sv: *sv,
Sv: toV0SignedVoucher(*sv),
Secret: secret,
})

Some files were not shown because too many files have changed in this diff Show More