Merge branch 'master' into nonsense/split-market-miner-processes

This commit is contained in:
Anton Evangelatov 2021-05-31 11:26:11 +02:00
commit d195a12565
192 changed files with 5357 additions and 1492 deletions

16
.github/CODEOWNERS vendored
View File

@ -1,16 +0,0 @@
## filecoin-project/lotus CODEOWNERS
## Refer to https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners.
##
## These users or groups will be automatically assigned as reviewers every time
## a PR is submitted that modifies code in the specified locations.
##
## The Lotus repo configuration requires that at least ONE codeowner approves
## the PR before merging.
### Global owners.
* @magik6k @arajasek
### Conformance testing.
conformance/ @ZenGround0
extern/test-vectors @ZenGround0
cmd/tvx @ZenGround0

View File

@ -1,6 +1,213 @@
# Lotus changelog
# 1.8.0 / 2021-04-27
# 1.9.0 / 2021-05-17
This is an optional Lotus release that introduces various improvements to the sealing, mining, and deal-making processes.
## Highlights
- OpenRPC Support (https://github.com/filecoin-project/lotus/pull/5843)
- Take latency into account when making interactive deals (https://github.com/filecoin-project/lotus/pull/5876)
- Update go-commp-utils for >10x faster client commp calculation (https://github.com/filecoin-project/lotus/pull/5892)
- add `lotus client cancel-retrieval` cmd to lotus CLI (https://github.com/filecoin-project/lotus/pull/5871)
- add `inspect-deal` command to `lotus client` (https://github.com/filecoin-project/lotus/pull/5833)
- Local retrieval support (https://github.com/filecoin-project/lotus/pull/5917)
- go-fil-markets v1.1.9 -> v1.2.5
- For a detailed changelog see https://github.com/filecoin-project/go-fil-markets/blob/master/CHANGELOG.md
- rust-fil-proofs v5.4.1 -> v7.0.1
- For a detailed changelog see https://github.com/filecoin-project/rust-fil-proofs/blob/master/CHANGELOG.md
## Changes
- storagefsm: Apply global events even in broken states (https://github.com/filecoin-project/lotus/pull/5962)
- Default the AlwaysKeepUnsealedCopy flag to true (https://github.com/filecoin-project/lotus/pull/5743)
- splitstore: compact hotstore prior to garbage collection (https://github.com/filecoin-project/lotus/pull/5778)
- ipfs-force bootstrapper update (https://github.com/filecoin-project/lotus/pull/5799)
- better logging when unsealing fails (https://github.com/filecoin-project/lotus/pull/5851)
- perf: add cache for gas permium estimation (https://github.com/filecoin-project/lotus/pull/5709)
- backupds: Compact log on restart (https://github.com/filecoin-project/lotus/pull/5875)
- backupds: Improve truncated log handling (https://github.com/filecoin-project/lotus/pull/5891)
- State CLI improvements (State CLI improvements)
- API proxy struct codegen (https://github.com/filecoin-project/lotus/pull/5854)
- move DI stuff for paychmgr into modules (https://github.com/filecoin-project/lotus/pull/5791)
- Implement Event observer and Settings for 3rd party dep injection (https://github.com/filecoin-project/lotus/pull/5693)
- Export developer and network commands for consumption by derivatives of Lotus (https://github.com/filecoin-project/lotus/pull/5864)
- mock sealer: Simulate randomness sideeffects (https://github.com/filecoin-project/lotus/pull/5805)
- localstorage: Demote reservation stat error to debug (https://github.com/filecoin-project/lotus/pull/5976)
- shed command to unpack miner info dumps (https://github.com/filecoin-project/lotus/pull/5800)
- Add two utils to Lotus-shed (https://github.com/filecoin-project/lotus/pull/5867)
- add shed election estimate command (https://github.com/filecoin-project/lotus/pull/5092)
- Add --actor flag in lotus-shed sectors terminate (https://github.com/filecoin-project/lotus/pull/5819)
- Move lotus mpool clear to lotus-shed (https://github.com/filecoin-project/lotus/pull/5900)
- Centralize everything on ipfs/go-log/v2 (https://github.com/filecoin-project/lotus/pull/5974)
- expose NextID from nice market actor interface (https://github.com/filecoin-project/lotus/pull/5850)
- add available options for perm on error (https://github.com/filecoin-project/lotus/pull/5814)
- API docs clarification: Document StateSearchMsg replaced message behavior (https://github.com/filecoin-project/lotus/pull/5838)
- api: Document StateReplay replaced message behavior (https://github.com/filecoin-project/lotus/pull/5840)
- add godocs to miner objects (https://github.com/filecoin-project/lotus/pull/2184)
- Add description to the client deal CLI command (https://github.com/filecoin-project/lotus/pull/5999)
- lint: don't skip builtin (https://github.com/filecoin-project/lotus/pull/5881)
- use deal duration from actors (https://github.com/filecoin-project/lotus/pull/5270)
- remote calc winningpost proof (https://github.com/filecoin-project/lotus/pull/5884)
- packer: other network images (https://github.com/filecoin-project/lotus/pull/5930)
- Convert the chainstore lock to RW (https://github.com/filecoin-project/lotus/pull/5971)
- Remove CachedBlockstore (https://github.com/filecoin-project/lotus/pull/5972)
- remove messagepool CapGasFee duplicate code (https://github.com/filecoin-project/lotus/pull/5992)
- Add a mining-heartbeat INFO line at every epoch (https://github.com/filecoin-project/lotus/pull/6183)
- chore(ci): Enable build on RC tags (https://github.com/filecoin-project/lotus/pull/6245)
- Upgrade nerpa to actor v4 and bump the version to rc4 (https://github.com/filecoin-project/lotus/pull/6249)
## Fixes
- return buffers after canceling badger operation (https://github.com/filecoin-project/lotus/pull/5796)
- avoid holding a lock while calling the View callback (https://github.com/filecoin-project/lotus/pull/5792)
- storagefsm: Trigger input processing when below limits (https://github.com/filecoin-project/lotus/pull/5801)
- After importing a previously deleted key, be able to delete it again (https://github.com/filecoin-project/lotus/pull/4653)
- fix StateManager.Replay on reward actor (https://github.com/filecoin-project/lotus/pull/5804)
- make sure atomic 64bit fields are 64bit aligned (https://github.com/filecoin-project/lotus/pull/5794)
- Import secp sigs in paych tests (https://github.com/filecoin-project/lotus/pull/5879)
- fix ci build-macos (https://github.com/filecoin-project/lotus/pull/5934)
- Fix creation of remainder account when it's not a multisig (https://github.com/filecoin-project/lotus/pull/5807)
- Fix fallback chainstore (https://github.com/filecoin-project/lotus/pull/6003)
- fix 4857: show help for set-addrs (https://github.com/filecoin-project/lotus/pull/5943)
- fix health report (https://github.com/filecoin-project/lotus/pull/6011)
- fix(ci): Use recent ubuntu LTS release; Update release params ((https://github.com/filecoin-project/lotus/pull/6011))
# 1.9.0-rc4 / 2021-05-13
This is an optional Lotus release that introduces various improvements to the sealing, mining, and deal-making processes.
## Highlights
- OpenRPC Support (https://github.com/filecoin-project/lotus/pull/5843)
- Take latency into account when making interactive deals (https://github.com/filecoin-project/lotus/pull/5876)
- Update go-commp-utils for >10x faster client commp calculation (https://github.com/filecoin-project/lotus/pull/5892)
- add `lotus client cancel-retrieval` cmd to lotus CLI (https://github.com/filecoin-project/lotus/pull/5871)
- add `inspect-deal` command to `lotus client` (https://github.com/filecoin-project/lotus/pull/5833)
- Local retrieval support (https://github.com/filecoin-project/lotus/pull/5917)
- go-fil-markets v1.1.9 -> v1.2.5
- For a detailed changelog see https://github.com/filecoin-project/go-fil-markets/blob/master/CHANGELOG.md
- rust-fil-proofs v5.4.1 -> v7.0.1
- For a detailed changelog see https://github.com/filecoin-project/rust-fil-proofs/blob/master/CHANGELOG.md
## Changes
- storagefsm: Apply global events even in broken states (https://github.com/filecoin-project/lotus/pull/5962)
- Default the AlwaysKeepUnsealedCopy flag to true (https://github.com/filecoin-project/lotus/pull/5743)
- splitstore: compact hotstore prior to garbage collection (https://github.com/filecoin-project/lotus/pull/5778)
- ipfs-force bootstrapper update (https://github.com/filecoin-project/lotus/pull/5799)
- better logging when unsealing fails (https://github.com/filecoin-project/lotus/pull/5851)
- perf: add cache for gas permium estimation (https://github.com/filecoin-project/lotus/pull/5709)
- backupds: Compact log on restart (https://github.com/filecoin-project/lotus/pull/5875)
- backupds: Improve truncated log handling (https://github.com/filecoin-project/lotus/pull/5891)
- State CLI improvements (State CLI improvements)
- API proxy struct codegen (https://github.com/filecoin-project/lotus/pull/5854)
- move DI stuff for paychmgr into modules (https://github.com/filecoin-project/lotus/pull/5791)
- Implement Event observer and Settings for 3rd party dep injection (https://github.com/filecoin-project/lotus/pull/5693)
- Export developer and network commands for consumption by derivatives of Lotus (https://github.com/filecoin-project/lotus/pull/5864)
- mock sealer: Simulate randomness sideeffects (https://github.com/filecoin-project/lotus/pull/5805)
- localstorage: Demote reservation stat error to debug (https://github.com/filecoin-project/lotus/pull/5976)
- shed command to unpack miner info dumps (https://github.com/filecoin-project/lotus/pull/5800)
- Add two utils to Lotus-shed (https://github.com/filecoin-project/lotus/pull/5867)
- add shed election estimate command (https://github.com/filecoin-project/lotus/pull/5092)
- Add --actor flag in lotus-shed sectors terminate (https://github.com/filecoin-project/lotus/pull/5819)
- Move lotus mpool clear to lotus-shed (https://github.com/filecoin-project/lotus/pull/5900)
- Centralize everything on ipfs/go-log/v2 (https://github.com/filecoin-project/lotus/pull/5974)
- expose NextID from nice market actor interface (https://github.com/filecoin-project/lotus/pull/5850)
- add available options for perm on error (https://github.com/filecoin-project/lotus/pull/5814)
- API docs clarification: Document StateSearchMsg replaced message behavior (https://github.com/filecoin-project/lotus/pull/5838)
- api: Document StateReplay replaced message behavior (https://github.com/filecoin-project/lotus/pull/5840)
- add godocs to miner objects (https://github.com/filecoin-project/lotus/pull/2184)
- Add description to the client deal CLI command (https://github.com/filecoin-project/lotus/pull/5999)
- lint: don't skip builtin (https://github.com/filecoin-project/lotus/pull/5881)
- use deal duration from actors (https://github.com/filecoin-project/lotus/pull/5270)
- remote calc winningpost proof (https://github.com/filecoin-project/lotus/pull/5884)
- packer: other network images (https://github.com/filecoin-project/lotus/pull/5930)
- Convert the chainstore lock to RW (https://github.com/filecoin-project/lotus/pull/5971)
- Remove CachedBlockstore (https://github.com/filecoin-project/lotus/pull/5972)
- remove messagepool CapGasFee duplicate code (https://github.com/filecoin-project/lotus/pull/5992)
- Add a mining-heartbeat INFO line at every epoch (https://github.com/filecoin-project/lotus/pull/6183)
- chore(ci): Enable build on RC tags (https://github.com/filecoin-project/lotus/pull/6245)
- Upgrade nerpa to actor v4 and bump the version to rc4 (https://github.com/filecoin-project/lotus/pull/6249)
## Fixes
- return buffers after canceling badger operation (https://github.com/filecoin-project/lotus/pull/5796)
- avoid holding a lock while calling the View callback (https://github.com/filecoin-project/lotus/pull/5792)
- storagefsm: Trigger input processing when below limits (https://github.com/filecoin-project/lotus/pull/5801)
- After importing a previously deleted key, be able to delete it again (https://github.com/filecoin-project/lotus/pull/4653)
- fix StateManager.Replay on reward actor (https://github.com/filecoin-project/lotus/pull/5804)
- make sure atomic 64bit fields are 64bit aligned (https://github.com/filecoin-project/lotus/pull/5794)
- Import secp sigs in paych tests (https://github.com/filecoin-project/lotus/pull/5879)
- fix ci build-macos (https://github.com/filecoin-project/lotus/pull/5934)
- Fix creation of remainder account when it's not a multisig (https://github.com/filecoin-project/lotus/pull/5807)
- Fix fallback chainstore (https://github.com/filecoin-project/lotus/pull/6003)
- fix 4857: show help for set-addrs (https://github.com/filecoin-project/lotus/pull/5943)
- fix health report (https://github.com/filecoin-project/lotus/pull/6011)
# 1.9.0-rc2 / 2021-04-30
This is an optional Lotus release that introduces various improvements to the sealing, mining, and deal-making processes.
## Highlights
- OpenRPC Support (https://github.com/filecoin-project/lotus/pull/5843)
- Take latency into account when making interactive deals (https://github.com/filecoin-project/lotus/pull/5876)
- Update go-commp-utils for >10x faster client commp calculation (https://github.com/filecoin-project/lotus/pull/5892)
- add `lotus client cancel-retrieval` cmd to lotus CLI (https://github.com/filecoin-project/lotus/pull/5871)
- add `inspect-deal` command to `lotus client` (https://github.com/filecoin-project/lotus/pull/5833)
- Local retrieval support (https://github.com/filecoin-project/lotus/pull/5917)
- go-fil-markets v1.1.9 -> v1.2.5
- For a detailed changelog see https://github.com/filecoin-project/go-fil-markets/blob/master/CHANGELOG.md
- rust-fil-proofs v5.4.1 -> v7
- For a detailed changelog see https://github.com/filecoin-project/rust-fil-proofs/blob/master/CHANGELOG.md
## Changes
- storagefsm: Apply global events even in broken states (https://github.com/filecoin-project/lotus/pull/5962)
- Default the AlwaysKeepUnsealedCopy flag to true (https://github.com/filecoin-project/lotus/pull/5743)
- splitstore: compact hotstore prior to garbage collection (https://github.com/filecoin-project/lotus/pull/5778)
- ipfs-force bootstrapper update (https://github.com/filecoin-project/lotus/pull/5799)
- better logging when unsealing fails (https://github.com/filecoin-project/lotus/pull/5851)
- perf: add cache for gas permium estimation (https://github.com/filecoin-project/lotus/pull/5709)
- backupds: Compact log on restart (https://github.com/filecoin-project/lotus/pull/5875)
- backupds: Improve truncated log handling (https://github.com/filecoin-project/lotus/pull/5891)
- State CLI improvements (State CLI improvements)
- API proxy struct codegen (https://github.com/filecoin-project/lotus/pull/5854)
- move DI stuff for paychmgr into modules (https://github.com/filecoin-project/lotus/pull/5791)
- Implement Event observer and Settings for 3rd party dep injection (https://github.com/filecoin-project/lotus/pull/5693)
- Export developer and network commands for consumption by derivatives of Lotus (https://github.com/filecoin-project/lotus/pull/5864)
- mock sealer: Simulate randomness sideeffects (https://github.com/filecoin-project/lotus/pull/5805)
- localstorage: Demote reservation stat error to debug (https://github.com/filecoin-project/lotus/pull/5976)
- shed command to unpack miner info dumps (https://github.com/filecoin-project/lotus/pull/5800)
- Add two utils to Lotus-shed (https://github.com/filecoin-project/lotus/pull/5867)
- add shed election estimate command (https://github.com/filecoin-project/lotus/pull/5092)
- Add --actor flag in lotus-shed sectors terminate (https://github.com/filecoin-project/lotus/pull/5819)
- Move lotus mpool clear to lotus-shed (https://github.com/filecoin-project/lotus/pull/5900)
- Centralize everything on ipfs/go-log/v2 (https://github.com/filecoin-project/lotus/pull/5974)
- expose NextID from nice market actor interface (https://github.com/filecoin-project/lotus/pull/5850)
- add available options for perm on error (https://github.com/filecoin-project/lotus/pull/5814)
- API docs clarification: Document StateSearchMsg replaced message behavior (https://github.com/filecoin-project/lotus/pull/5838)
- api: Document StateReplay replaced message behavior (https://github.com/filecoin-project/lotus/pull/5840)
- add godocs to miner objects (https://github.com/filecoin-project/lotus/pull/2184)
- Add description to the client deal CLI command (https://github.com/filecoin-project/lotus/pull/5999)
- lint: don't skip builtin (https://github.com/filecoin-project/lotus/pull/5881)
- use deal duration from actors (https://github.com/filecoin-project/lotus/pull/5270)
- remote calc winningpost proof (https://github.com/filecoin-project/lotus/pull/5884)
- packer: other network images (https://github.com/filecoin-project/lotus/pull/5930)
- Convert the chainstore lock to RW (https://github.com/filecoin-project/lotus/pull/5971)
- Remove CachedBlockstore (https://github.com/filecoin-project/lotus/pull/5972)
- remove messagepool CapGasFee duplicate code (https://github.com/filecoin-project/lotus/pull/5992)
## Fixes
- return buffers after canceling badger operation (https://github.com/filecoin-project/lotus/pull/5796)
- avoid holding a lock while calling the View callback (https://github.com/filecoin-project/lotus/pull/5792)
- storagefsm: Trigger input processing when below limits (https://github.com/filecoin-project/lotus/pull/5801)
- After importing a previously deleted key, be able to delete it again (https://github.com/filecoin-project/lotus/pull/4653)
- fix StateManager.Replay on reward actor (https://github.com/filecoin-project/lotus/pull/5804)
- make sure atomic 64bit fields are 64bit aligned (https://github.com/filecoin-project/lotus/pull/5794)
- Import secp sigs in paych tests (https://github.com/filecoin-project/lotus/pull/5879)
- fix ci build-macos (https://github.com/filecoin-project/lotus/pull/5934)
- Fix creation of remainder account when it's not a multisig (https://github.com/filecoin-project/lotus/pull/5807)
- Fix fallback chainstore (https://github.com/filecoin-project/lotus/pull/6003)
- fix 4857: show help for set-addrs (https://github.com/filecoin-project/lotus/pull/5943)
- fix health report (https://github.com/filecoin-project/lotus/pull/6011)
# 1.8.0 / 2021-04-05
This is a mandatory release of Lotus that upgrades the network to version 12, which introduces various performance improvements to the cron processing of the power actor. The network will upgrade at height 712320, which is 2021-04-29T06:00:00Z.
@ -140,7 +347,7 @@ FIP-0010 introduces the ability to dispute bad Window PoSts. Node operators are
## Changes
- [#5341](https://github.com/filecoin-project/lotus/pull/5341) Add a `LOTUS_DISABLE_V3_ACTOR_MIGRATION` envvar
- Setting this envvar to 1 disables the v3 actor migration, should only be used in the event of a failed migration
- Setting this envvar to 1 disables the v3 actor migration, should only be used in the event of a failed migration
# 1.4.2 / 2021-02-17
@ -151,10 +358,10 @@ This is a large, and highly recommended, optional release with new features and
Note that this release does NOT set an upgrade epoch for v3 actors to take effect. That will be done in the upcoming 1.5.0 release.
## New Features
## New Features
- [#5341](https://github.com/filecoin-project/lotus/pull/5341) Added sector termination API and CLI
- Run `lotus-miner sectors terminate`
- [#5341](https://github.com/filecoin-project/lotus/pull/5341) Added sector termination API and CLI
- Run `lotus-miner sectors terminate`
- [#5342](https://github.com/filecoin-project/lotus/pull/5342) Added CLI for using a multisig wallet as miner's owner address
- See how to set it up [here](https://github.com/filecoin-project/lotus/pull/5342#issue-554009129)
- [#5363](https://github.com/filecoin-project/lotus/pull/5363), [#5418](https://github.com/filecoin-project/lotus/pull/), [#5476](https://github.com/filecoin-project/lotus/pull/5476), [#5459](https://github.com/filecoin-project/lotus/pull/5459) Integrated [spec-actor v3](https://github.com/filecoin-pro5418ject/specs-actors/releases/tag/v3.0.0)
@ -176,28 +383,28 @@ Note that this release does NOT set an upgrade epoch for v3 actors to take effec
- [#5219](https://github.com/filecoin-project/lotus/pull/5219) Added interactive mode for lotus-wallet
- [5529](https://github.com/filecoin-project/lotus/pull/5529) Added support for minder nodes in `lotus-shed rpc` util
## Bug Fixes
## Bug Fixes
- [#5210](https://github.com/filecoin-project/lotus/pull/5210) Miner should not dial client on restart
- [#5403](https://github.com/filecoin-project/lotus/pull/5403) When estimating GasLimit only apply prior messages up to the nonce
- [#5410](https://github.com/filecoin-project/lotus/pull/510) Fix the calibnet build option
- [#5492](https://github.com/filecoin-project/lotus/pull/5492) Fixed `has` for ipfsbstore for non-existing blocks
- [#5361](https://github.com/filecoin-project/lotus/pull/5361) Fixed retrieval hangs when using `IpfsOnlineMode=true`
- [#5493](https://github.com/filecoin-project/lotus/pull/5493) Fixed retrieval failure when price-per-byte is zero
- [#5506](https://github.com/filecoin-project/lotus/pull/5506) Fixed contexts in the storage adpater
- [#5515](https://github.com/filecoin-project/lotus/pull/5515) Properly wire up `StateReadState` on gateway API
- [#5582](https://github.com/filecoin-project/lotus/pull/5582) Fixed error logging format strings
- [#5614](https://github.com/filecoin-project/lotus/pull/5614) Fixed websocket reconnecting handling
- [#5210](https://github.com/filecoin-project/lotus/pull/5210) Miner should not dial client on restart
- [#5403](https://github.com/filecoin-project/lotus/pull/5403) When estimating GasLimit only apply prior messages up to the nonce
- [#5410](https://github.com/filecoin-project/lotus/pull/510) Fix the calibnet build option
- [#5492](https://github.com/filecoin-project/lotus/pull/5492) Fixed `has` for ipfsbstore for non-existing blocks
- [#5361](https://github.com/filecoin-project/lotus/pull/5361) Fixed retrieval hangs when using `IpfsOnlineMode=true`
- [#5493](https://github.com/filecoin-project/lotus/pull/5493) Fixed retrieval failure when price-per-byte is zero
- [#5506](https://github.com/filecoin-project/lotus/pull/5506) Fixed contexts in the storage adpater
- [#5515](https://github.com/filecoin-project/lotus/pull/5515) Properly wire up `StateReadState` on gateway API
- [#5582](https://github.com/filecoin-project/lotus/pull/5582) Fixed error logging format strings
- [#5614](https://github.com/filecoin-project/lotus/pull/5614) Fixed websocket reconnecting handling
## Improvements
## Improvements
- [#5389](https://github.com/filecoin-project/lotus/pull/5389) Show verified indicator for `./lotus-miner storage-deals list`
- [#5389](https://github.com/filecoin-project/lotus/pull/5389) Show verified indicator for `./lotus-miner storage-deals list`
- [#5229](https://github.com/filecoin-project/lotus/pull/5220) Show power for verified deals in `./lotus-miner setocr list`
- [#5407](https://github.com/filecoin-project/lotus/pull/5407) Added explicit check of the miner address protocol
- [#5399](https://github.com/filecoin-project/lotus/pull/5399) watchdog: increase heapprof capture threshold to 90%
- [#5398](https://github.com/filecoin-project/lotus/pull/5398) storageadapter: Look at precommits on-chain since deal publish msg
- [#5470](https://github.com/filecoin-project/lotus/pull/5470) Added `--no-timing` option for `./lotus state compute-state --html`
- [#5399](https://github.com/filecoin-project/lotus/pull/5399) watchdog: increase heapprof capture threshold to 90%
- [#5398](https://github.com/filecoin-project/lotus/pull/5398) storageadapter: Look at precommits on-chain since deal publish msg
- [#5470](https://github.com/filecoin-project/lotus/pull/5470) Added `--no-timing` option for `./lotus state compute-state --html`
- [#5417](https://github.com/filecoin-project/lotus/pull/5417) Storage Manager: Always unseal full sectors
- [#5393](https://github.com/filecoin-project/lotus/pull/5393) Switched to [filecoin-ffi bls api ](https://github.com/filecoin-project/filecoin-ffi/pull/159)for bls signatures
- [#5380](https://github.com/filecoin-project/lotus/pull/5210) Refactor deals API tests
@ -227,14 +434,14 @@ Note that this release does NOT set an upgrade epoch for v3 actors to take effec
- [#5592](https://github.com/filecoin-project/lotus/pull/5592) Verify FFI version before building
## Dependency Updates
- [#5296](https://github.com/filecoin-project/lotus/pull/5396) Upgraded to [raulk/go-watchdog@v1.0.1](https://github.com/raulk/go-watchdog/releases/tag/v1.0.1)
- [#5450](https://github.com/filecoin-project/lotus/pull/5450) Dependency updates
- [#5425](https://github.com/filecoin-project/lotus/pull/5425) Fixed stale imports in testplans/lotus-soup
- [#5535](https://github.com/filecoin-project/lotus/pull/5535) Updated to [go-fil-markets@v1.1.7](https://github.com/filecoin-project/go-fil-markets/releases/tag/v1.1.7)
- [#5616](https://github.com/filecoin-project/lotus/pull/5600) Updated to [filecoin-ffi@b6e0b35fb49ed0fe](https://github.com/filecoin-project/filecoin-ffi/releases/tag/b6e0b35fb49ed0fe)
- [#5599](https://github.com/filecoin-project/lotus/pull/5599) Updated to [go-bitfield@v0.2.4](https://github.com/filecoin-project/go-bitfield/releases/tag/v0.2.4)
- [#5614](https://github.com/filecoin-project/lotus/pull/5614), , [#5621](https://github.com/filecoin-project/lotus/pull/5621) Updated to [go-jsonrpc@v0.1.3](https://github.com/filecoin-project/go-jsonrpc/releases/tag/v0.1.3)
- [#5459](https://github.com/filecoin-project/lotus/pull/5459) Updated to [spec-actors@v3.0.1](https://github.com/filecoin-project/specs-actors/releases/tag/v3.0.1)
- [#5296](https://github.com/filecoin-project/lotus/pull/5396) Upgraded to [raulk/go-watchdog@v1.0.1](https://github.com/raulk/go-watchdog/releases/tag/v1.0.1)
- [#5450](https://github.com/filecoin-project/lotus/pull/5450) Dependency updates
- [#5425](https://github.com/filecoin-project/lotus/pull/5425) Fixed stale imports in testplans/lotus-soup
- [#5535](https://github.com/filecoin-project/lotus/pull/5535) Updated to [go-fil-markets@v1.1.7](https://github.com/filecoin-project/go-fil-markets/releases/tag/v1.1.7)
- [#5616](https://github.com/filecoin-project/lotus/pull/5600) Updated to [filecoin-ffi@b6e0b35fb49ed0fe](https://github.com/filecoin-project/filecoin-ffi/releases/tag/b6e0b35fb49ed0fe)
- [#5599](https://github.com/filecoin-project/lotus/pull/5599) Updated to [go-bitfield@v0.2.4](https://github.com/filecoin-project/go-bitfield/releases/tag/v0.2.4)
- [#5614](https://github.com/filecoin-project/lotus/pull/5614), , [#5621](https://github.com/filecoin-project/lotus/pull/5621) Updated to [go-jsonrpc@v0.1.3](https://github.com/filecoin-project/go-jsonrpc/releases/tag/v0.1.3)
- [#5459](https://github.com/filecoin-project/lotus/pull/5459) Updated to [spec-actors@v3.0.1](https://github.com/filecoin-project/specs-actors/releases/tag/v3.0.1)
## Network Version v10 Upgrade
@ -1312,12 +1519,12 @@ and go-libp2p-pubsub to [v0.3.5](https://github.com/libp2p/go-libp2p-pubsub/rele
- The following improvements were introduced in https://github.com/filecoin-project/lotus/pull/3350.
- Allow `lotus-miner sectors remove` to remove a sector in any state.
- Create a separate state in the storage FSM dedicated to submitting the Commit message.
- Recovery for when the Deal IDs of deals in a sector get changed in a reorg.
- Auto-retry sending Precommit and Commit messages if they run out of gas
- Auto-retry sector remove tasks when they fail
- Compact worker windows, and allow their tasks to be executed in any order
- Allow `lotus-miner sectors remove` to remove a sector in any state.
- Create a separate state in the storage FSM dedicated to submitting the Commit message.
- Recovery for when the Deal IDs of deals in a sector get changed in a reorg.
- Auto-retry sending Precommit and Commit messages if they run out of gas
- Auto-retry sector remove tasks when they fail
- Compact worker windows, and allow their tasks to be executed in any order
- Don't simply skip PoSt for bad sectors (https://github.com/filecoin-project/lotus/pull/3323)
@ -1385,9 +1592,9 @@ Among the highlights included in this release are:
- Gas changes: We implemented EIP-1559 and introduced real gas values.
- Deal-making: We now support "Committed Capacity" sectors, "fast-retrieval" deals,
and the packing of multiple deals into a single sector.
and the packing of multiple deals into a single sector.
- Renamed features: We renamed some of the binaries, environment variables, and default
paths associated with a Lotus node.
paths associated with a Lotus node.
### Gas changes
@ -1400,9 +1607,9 @@ We implemented something similar to
The `Message` structure had three changes:
- The `GasPrice` field has been removed
- A new `GasFeeCap` field has been added, which controls the maximum cost
the sender incurs for the message
the sender incurs for the message
- A new `GasPremium` field has been added, which controls the reward a miner
earns for including the message
earns for including the message
A sender will never be charged more than `GasFeeCap * GasLimit`.
A miner will typically earn `GasPremium * GasLimit` as a reward.

View File

@ -303,17 +303,10 @@ clean-services: clean-all-services
buildall: $(BINS)
completions:
./scripts/make-completions.sh lotus
./scripts/make-completions.sh lotus-miner
.PHONY: completions
install-completions:
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/
install -C ./scripts/bash-completion/lotus /usr/share/bash-completion/completions/lotus
install -C ./scripts/bash-completion/lotus-miner /usr/share/bash-completion/completions/lotus-miner
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
install -C ./scripts/zsh-completion/lotus-miner /usr/local/share/zsh/site-functions/_lotus-miner
clean:
rm -rf $(CLEAN) $(BINS)
@ -375,6 +368,10 @@ gen: actors-gen type-gen method-gen docsgen api-gen
@echo ">>> IF YOU'VE MODIFIED THE CLI, REMEMBER TO ALSO MAKE docsgen-cli"
.PHONY: gen
snap: lotus lotus-miner lotus-worker
snapcraft
# snapcraft upload ./lotus_*.snap
# separate from gen because it needs binaries
docsgen-cli: lotus lotus-miner lotus-worker
python ./scripts/generate-lotus-cli.py

View File

@ -323,6 +323,8 @@ type FullNode interface {
ClientRemoveImport(ctx context.Context, importID multistore.StoreID) error //perm:admin
// ClientStartDeal proposes a deal with a miner.
ClientStartDeal(ctx context.Context, params *StartDealParams) (*cid.Cid, error) //perm:admin
// ClientStatelessDeal fire-and-forget-proposes an offline deal to a miner without subsequent tracking.
ClientStatelessDeal(ctx context.Context, params *StartDealParams) (*cid.Cid, error) //perm:write
// ClientGetDealInfo returns the latest information about a given deal.
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error) //perm:read
// ClientListDeals returns information about the deals made by the local client.

View File

@ -771,6 +771,21 @@ func (mr *MockFullNodeMockRecorder) ClientStartDeal(arg0, arg1 interface{}) *gom
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClientStartDeal", reflect.TypeOf((*MockFullNode)(nil).ClientStartDeal), arg0, arg1)
}
// ClientStatelessDeal mocks base method
func (m *MockFullNode) ClientStatelessDeal(arg0 context.Context, arg1 *api.StartDealParams) (*cid.Cid, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ClientStatelessDeal", arg0, arg1)
ret0, _ := ret[0].(*cid.Cid)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ClientStatelessDeal indicates an expected call of ClientStatelessDeal
func (mr *MockFullNodeMockRecorder) ClientStatelessDeal(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClientStatelessDeal", reflect.TypeOf((*MockFullNode)(nil).ClientStatelessDeal), arg0, arg1)
}
// Closing mocks base method
func (m *MockFullNode) Closing(arg0 context.Context) (<-chan struct{}, error) {
m.ctrl.T.Helper()

View File

@ -205,6 +205,8 @@ type FullNodeStruct struct {
ClientStartDeal func(p0 context.Context, p1 *StartDealParams) (*cid.Cid, error) `perm:"admin"`
ClientStatelessDeal func(p0 context.Context, p1 *StartDealParams) (*cid.Cid, error) `perm:"write"`
CreateBackup func(p0 context.Context, p1 string) error `perm:"admin"`
GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"`
@ -1399,6 +1401,14 @@ func (s *FullNodeStub) ClientStartDeal(p0 context.Context, p1 *StartDealParams)
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientStatelessDeal(p0 context.Context, p1 *StartDealParams) (*cid.Cid, error) {
return s.Internal.ClientStatelessDeal(p0, p1)
}
func (s *FullNodeStub) ClientStatelessDeal(p0 context.Context, p1 *StartDealParams) (*cid.Cid, error) {
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) CreateBackup(p0 context.Context, p1 string) error {
return s.Internal.CreateBackup(p0, p1)
}

View File

@ -304,6 +304,8 @@ type FullNode interface {
ClientRemoveImport(ctx context.Context, importID multistore.StoreID) error //perm:admin
// ClientStartDeal proposes a deal with a miner.
ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) //perm:admin
// ClientStatelessDeal fire-and-forget-proposes an offline deal to a miner without subsequent tracking.
ClientStatelessDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) //perm:write
// ClientGetDealInfo returns the latest information about a given deal.
ClientGetDealInfo(context.Context, cid.Cid) (*api.DealInfo, error) //perm:read
// ClientListDeals returns information about the deals made by the local client.

View File

@ -123,6 +123,8 @@ type FullNodeStruct struct {
ClientStartDeal func(p0 context.Context, p1 *api.StartDealParams) (*cid.Cid, error) `perm:"admin"`
ClientStatelessDeal func(p0 context.Context, p1 *api.StartDealParams) (*cid.Cid, error) `perm:"write"`
CreateBackup func(p0 context.Context, p1 string) error `perm:"admin"`
GasEstimateFeeCap func(p0 context.Context, p1 *types.Message, p2 int64, p3 types.TipSetKey) (types.BigInt, error) `perm:"read"`
@ -818,6 +820,14 @@ func (s *FullNodeStub) ClientStartDeal(p0 context.Context, p1 *api.StartDealPara
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) ClientStatelessDeal(p0 context.Context, p1 *api.StartDealParams) (*cid.Cid, error) {
return s.Internal.ClientStatelessDeal(p0, p1)
}
func (s *FullNodeStub) ClientStatelessDeal(p0 context.Context, p1 *api.StartDealParams) (*cid.Cid, error) {
return nil, xerrors.New("method not supported")
}
func (s *FullNodeStruct) CreateBackup(p0 context.Context, p1 string) error {
return s.Internal.CreateBackup(p0, p1)
}

View File

@ -771,6 +771,21 @@ func (mr *MockFullNodeMockRecorder) ClientStartDeal(arg0, arg1 interface{}) *gom
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClientStartDeal", reflect.TypeOf((*MockFullNode)(nil).ClientStartDeal), arg0, arg1)
}
// ClientStatelessDeal mocks base method
func (m *MockFullNode) ClientStatelessDeal(arg0 context.Context, arg1 *api.StartDealParams) (*cid.Cid, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ClientStatelessDeal", arg0, arg1)
ret0, _ := ret[0].(*cid.Cid)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ClientStatelessDeal indicates an expected call of ClientStatelessDeal
func (mr *MockFullNodeMockRecorder) ClientStatelessDeal(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClientStatelessDeal", reflect.TypeOf((*MockFullNode)(nil).ClientStatelessDeal), arg0, arg1)
}
// Closing mocks base method
func (m *MockFullNode) Closing(arg0 context.Context) (<-chan struct{}, error) {
m.ctrl.T.Helper()

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -24,27 +24,27 @@ var UpgradeIgnitionHeight = abi.ChainEpoch(-2)
var UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4)
var UpgradeActorsV2Height = abi.ChainEpoch(10)
var UpgradeLiftoffHeight = abi.ChainEpoch(-5)
var UpgradeActorsV2Height = abi.ChainEpoch(-5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-6)
var UpgradeKumquatHeight = abi.ChainEpoch(15)
var UpgradeCalicoHeight = abi.ChainEpoch(20)
var UpgradePersianHeight = abi.ChainEpoch(25)
var UpgradeOrangeHeight = abi.ChainEpoch(27)
var UpgradeClausHeight = abi.ChainEpoch(30)
var UpgradeKumquatHeight = abi.ChainEpoch(-7)
var UpgradeCalicoHeight = abi.ChainEpoch(-8)
var UpgradePersianHeight = abi.ChainEpoch(-9)
var UpgradeOrangeHeight = abi.ChainEpoch(-10)
var UpgradeClausHeight = abi.ChainEpoch(-11)
var UpgradeActorsV3Height = abi.ChainEpoch(35)
var UpgradeActorsV3Height = abi.ChainEpoch(-12)
var UpgradeNorwegianHeight = abi.ChainEpoch(40)
var UpgradeNorwegianHeight = abi.ChainEpoch(-13)
var UpgradeActorsV4Height = abi.ChainEpoch(45)
var UpgradeActorsV4Height = abi.ChainEpoch(-14)
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
}
func init() {
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1)
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))
policy.SetPreCommitChallengeDelay(abi.ChainEpoch(10))

View File

@ -8,12 +8,10 @@
package build
import (
"math"
"os"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/policy"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
)
@ -54,29 +52,19 @@ const UpgradeOrangeHeight = 336458
const UpgradeClausHeight = 343200
// 2021-03-04T00:00:30Z
var UpgradeActorsV3Height = abi.ChainEpoch(550321)
const UpgradeActorsV3Height = 550321
// 2021-04-12T22:00:00Z
const UpgradeNorwegianHeight = 665280
// 2021-04-29T06:00:00Z
var UpgradeActorsV4Height = abi.ChainEpoch(712320)
const UpgradeActorsV4Height = 712320
func init() {
policy.SetConsensusMinerMinPower(abi.NewStoragePower(10 << 40))
if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" {
SetAddressNetwork(address.Mainnet)
}
if os.Getenv("LOTUS_DISABLE_V3_ACTOR_MIGRATION") == "1" {
UpgradeActorsV3Height = math.MaxInt64
}
if os.Getenv("LOTUS_DISABLE_V4_ACTOR_MIGRATION") == "1" {
UpgradeActorsV4Height = math.MaxInt64
}
Devnet = false
BuildType = BuildMainnet

View File

@ -25,7 +25,7 @@ const UnixfsLinksPerLevel = 1024
// Consensus / Network
const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version11
const NewestNetworkVersion = network.Version12
const ActorUpgradeNetworkVersion = network.Version4
// Epochs

0
chain/actors/adt/temp Normal file
View File

View File

View File

@ -6,33 +6,26 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"text/template"
lotusactors "github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
)
var latestVersion = 4
var versions = []int{0, 2, 3, latestVersion}
var versionImports = map[int]string{
0: "/",
2: "/v2/",
3: "/v3/",
latestVersion: "/v4/",
}
var actors = map[string][]int{
"account": versions,
"cron": versions,
"init": versions,
"market": versions,
"miner": versions,
"multisig": versions,
"paych": versions,
"power": versions,
"reward": versions,
"verifreg": versions,
"account": lotusactors.Versions,
"cron": lotusactors.Versions,
"init": lotusactors.Versions,
"market": lotusactors.Versions,
"miner": lotusactors.Versions,
"multisig": lotusactors.Versions,
"paych": lotusactors.Versions,
"power": lotusactors.Versions,
"system": lotusactors.Versions,
"reward": lotusactors.Versions,
"verifreg": lotusactors.Versions,
}
func main() {
@ -71,14 +64,14 @@ func generateAdapters() error {
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return versionImports[v] },
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(af)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": latestVersion,
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -103,14 +96,14 @@ func generateState(actDir string) error {
return xerrors.Errorf("loading state adapter template: %w", err)
}
for _, version := range versions {
for _, version := range lotusactors.Versions {
tpl := template.Must(template.New("").Funcs(template.FuncMap{}).Parse(string(af)))
var b bytes.Buffer
err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": versionImports[version],
"import": getVersionImports()[version],
})
if err != nil {
return err
@ -134,14 +127,14 @@ func generateMessages(actDir string) error {
return xerrors.Errorf("loading message adapter template: %w", err)
}
for _, version := range versions {
for _, version := range lotusactors.Versions {
tpl := template.Must(template.New("").Funcs(template.FuncMap{}).Parse(string(af)))
var b bytes.Buffer
err := tpl.Execute(&b, map[string]interface{}{
"v": version,
"import": versionImports[version],
"import": getVersionImports()[version],
})
if err != nil {
return err
@ -167,13 +160,13 @@ func generatePolicy(policyPath string) error {
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return versionImports[v] },
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(pf)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": latestVersion,
"versions": lotusactors.Versions,
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -198,13 +191,13 @@ func generateBuiltin(builtinPath string) error {
}
tpl := template.Must(template.New("").Funcs(template.FuncMap{
"import": func(v int) string { return versionImports[v] },
"import": func(v int) string { return getVersionImports()[v] },
}).Parse(string(bf)))
var b bytes.Buffer
err = tpl.Execute(&b, map[string]interface{}{
"versions": versions,
"latestVersion": latestVersion,
"versions": lotusactors.Versions,
"latestVersion": lotusactors.LatestVersion,
})
if err != nil {
return err
@ -216,3 +209,16 @@ func generateBuiltin(builtinPath string) error {
return nil
}
func getVersionImports() map[int]string {
versionImports := make(map[int]string, lotusactors.LatestVersion)
for _, v := range lotusactors.Versions {
if v == 0 {
versionImports[v] = "/"
} else {
versionImports[v] = "/v" + strconv.Itoa(v) + "/"
}
}
return versionImports
}

0
chain/actors/agen/temp Normal file
View File

View File

@ -1,6 +1,7 @@
package account
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -60,8 +61,48 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
switch av {
case actors.Version0:
return make0(store, addr)
case actors.Version2:
return make2(store, addr)
case actors.Version3:
return make3(store, addr)
case actors.Version4:
return make4(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
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
PubkeyAddress() (address.Address, error)
GetState() interface{}
}

View File

@ -1,6 +1,7 @@
package account
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -34,8 +35,30 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, addr address.Address) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, addr)
{{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{{.}}.AccountActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
PubkeyAddress() (address.Address, error)
GetState() interface{}
}

View File

@ -20,6 +20,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, addr address.Address) (State, error) {
out := state{{.v}}{store: store}
out.State = account{{.v}}.State{Address:addr}
return &out, nil
}
type state{{.v}} struct {
account{{.v}}.State
store adt.Store
@ -28,3 +34,7 @@ type state{{.v}} struct {
func (s *state{{.v}}) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

View File

@ -20,6 +20,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, addr address.Address) (State, error) {
out := state0{store: store}
out.State = account0.State{Address: addr}
return &out, nil
}
type state0 struct {
account0.State
store adt.Store
@ -28,3 +34,7 @@ type state0 struct {
func (s *state0) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, addr address.Address) (State, error) {
out := state2{store: store}
out.State = account2.State{Address: addr}
return &out, nil
}
type state2 struct {
account2.State
store adt.Store
@ -28,3 +34,7 @@ type state2 struct {
func (s *state2) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, addr address.Address) (State, error) {
out := state3{store: store}
out.State = account3.State{Address: addr}
return &out, nil
}
type state3 struct {
account3.State
store adt.Store
@ -28,3 +34,7 @@ type state3 struct {
func (s *state3) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -20,6 +20,12 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, addr address.Address) (State, error) {
out := state4{store: store}
out.State = account4.State{Address: addr}
return &out, nil
}
type state4 struct {
account4.State
store adt.Store
@ -28,3 +34,7 @@ type state4 struct {
func (s *state4) PubkeyAddress() (address.Address, error) {
return s.Address, nil
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -6,9 +6,9 @@ import (
"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}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
smoothing{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/util/smoothing"
{{end}}
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/cbor"
@ -17,7 +17,7 @@ import (
"github.com/filecoin-project/lotus/chain/types"
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"
proof{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/runtime/proof"
)
var SystemActorAddr = builtin{{.latestVersion}}.SystemActorAddr
@ -33,12 +33,12 @@ var (
const (
EpochDurationSeconds = builtin{{.latestVersion}}.EpochDurationSeconds
EpochsInDay = builtin{{.latestVersion}}.EpochsInDay
SecondsInDay = builtin{{.latestVersion}}.SecondsInDay
EpochsInDay = builtin{{.latestVersion}}.EpochsInDay
SecondsInDay = builtin{{.latestVersion}}.SecondsInDay
)
const (
MethodSend = builtin{{.latestVersion}}.MethodSend
MethodSend = builtin{{.latestVersion}}.MethodSend
MethodConstructor = builtin{{.latestVersion}}.MethodConstructor
)
@ -53,13 +53,13 @@ func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight,
}
{{range .versions}}
func FromV{{.}}FilterEstimate(v{{.}} smoothing{{.}}.FilterEstimate) FilterEstimate {
func FromV{{.}}FilterEstimate(v{{.}} smoothing{{.}}.FilterEstimate) FilterEstimate {
{{if (eq . 0)}}
return (FilterEstimate)(v{{.}}) //nolint:unconvert
{{else}}
return (FilterEstimate)(v{{.}})
{{end}}
}
return (FilterEstimate)(v{{.}}) //nolint:unconvert
{{else}}
return (FilterEstimate)(v{{.}})
{{end}}
}
{{end}}
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
@ -80,58 +80,58 @@ func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
func ActorNameByCode(c cid.Cid) string {
switch {
{{range .versions}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
{{range .versions}}
case builtin{{.}}.IsBuiltinActor(c):
return builtin{{.}}.ActorNameByCode(c)
{{end}}
default:
return "<unknown>"
}
}
func IsBuiltinActor(c cid.Cid) bool {
{{range .versions}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{end}}
return false
{{range .versions}}
if builtin{{.}}.IsBuiltinActor(c) {
return true
}
{{end}}
return false
}
func IsAccountActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.AccountActorCodeID {
return true
}
{{end}}
return false
}
func IsStorageMinerActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.StorageMinerActorCodeID {
return true
}
{{end}}
return false
}
func IsMultisigActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.MultisigActorCodeID {
return true
}
{{end}}
return false
}
func IsPaymentChannelActor(c cid.Cid) bool {
{{range .versions}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{end}}
return false
{{range .versions}}
if c == builtin{{.}}.PaymentChannelActorCodeID {
return true
}
{{end}}
return false
}
func makeAddress(addr string) address.Address {

View File

@ -1,10 +1,42 @@
package cron
import (
builtin{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
)
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{{.}}.CronActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin{{.latestVersion}}.CronActorAddr
Methods = builtin{{.latestVersion}}.MethodsCron
)
type State interface {
GetState() interface{}
}

View File

@ -1,10 +1,64 @@
package cron
import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
)
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
}
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
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
var (
Address = builtin4.CronActorAddr
Methods = builtin4.MethodsCron
)
type State interface {
GetState() interface{}
}

View File

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

View File

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package init
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -39,6 +40,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, networkName)
{{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{{.}}.InitActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -56,5 +78,12 @@ type State interface {
// Sets the network's name. This should only be used on upgrade/fork.
SetNetworkName(name string) error
addressMap() (adt.Map, error)
// Sets the next ID for the init actor. This should only be used for testing.
SetNextID(id abi.ActorID) error
// Sets the address map for the init actor. This should only be used for testing.
SetAddressMap(mcid cid.Cid) error
AddressMap() (adt.Map, error)
GetState() interface{}
}

View File

@ -11,12 +11,12 @@ import (
)
func DiffAddressMap(pre, cur State) (*AddressMapChanges, error) {
prem, err := pre.addressMap()
prem, err := pre.AddressMap()
if err != nil {
return nil, err
}
curm, err := cur.addressMap()
curm, err := cur.AddressMap()
if err != nil {
return nil, err
}

View File

@ -1,6 +1,7 @@
package init
import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
@ -65,6 +66,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, networkName string) (State, error) {
switch av {
case actors.Version0:
return make0(store, networkName)
case actors.Version2:
return make2(store, networkName)
case actors.Version3:
return make3(store, networkName)
case actors.Version4:
return make4(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
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -82,5 +122,12 @@ type State interface {
// Sets the network's name. This should only be used on upgrade/fork.
SetNetworkName(name string) error
addressMap() (adt.Map, error)
// Sets the next ID for the init actor. This should only be used for testing.
SetNextID(id abi.ActorID) error
// Sets the address map for the init actor. This should only be used for testing.
SetAddressMap(mcid cid.Cid) error
AddressMap() (adt.Map, error)
GetState() interface{}
}

View File

@ -29,6 +29,26 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, networkName string) (State, error) {
out := state{{.v}}{store: store}
{{if (le .v 2)}}
mr, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init{{.v}}.ConstructState(mr, networkName)
{{else}}
s, err := init{{.v}}.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
{{end}}
return &out, nil
}
type state{{.v}} struct {
init{{.v}}.State
store adt.Store
@ -66,6 +86,11 @@ func (s *state{{.v}}) SetNetworkName(name string) error {
return nil
}
func (s *state{{.v}}) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) {
m, err := adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
if err != nil {
@ -84,6 +109,15 @@ func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state{{.v}}) addressMap() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
func (s *state{{.v}}) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state{{.v}}) AddressMap() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

View File

@ -25,6 +25,19 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, networkName string) (State, error) {
out := state0{store: store}
mr, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init0.ConstructState(mr, networkName)
return &out, nil
}
type state0 struct {
init0.State
store adt.Store
@ -62,6 +75,11 @@ func (s *state0) SetNetworkName(name string) error {
return nil
}
func (s *state0) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state0) Remove(addrs ...address.Address) (err error) {
m, err := adt0.AsMap(s.store, s.State.AddressMap)
if err != nil {
@ -80,6 +98,15 @@ func (s *state0) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state0) addressMap() (adt.Map, error) {
return adt0.AsMap(s.store, s.AddressMap)
func (s *state0) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state0) AddressMap() (adt.Map, error) {
return adt0.AsMap(s.store, s.State.AddressMap)
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -25,6 +25,19 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, networkName string) (State, error) {
out := state2{store: store}
mr, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *init2.ConstructState(mr, networkName)
return &out, nil
}
type state2 struct {
init2.State
store adt.Store
@ -62,6 +75,11 @@ func (s *state2) SetNetworkName(name string) error {
return nil
}
func (s *state2) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state2) Remove(addrs ...address.Address) (err error) {
m, err := adt2.AsMap(s.store, s.State.AddressMap)
if err != nil {
@ -80,6 +98,15 @@ func (s *state2) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state2) addressMap() (adt.Map, error) {
return adt2.AsMap(s.store, s.AddressMap)
func (s *state2) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state2) AddressMap() (adt.Map, error) {
return adt2.AsMap(s.store, s.State.AddressMap)
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -27,6 +27,19 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, networkName string) (State, error) {
out := state3{store: store}
s, err := init3.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state3 struct {
init3.State
store adt.Store
@ -64,6 +77,11 @@ func (s *state3) SetNetworkName(name string) error {
return nil
}
func (s *state3) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state3) Remove(addrs ...address.Address) (err error) {
m, err := adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth)
if err != nil {
@ -82,6 +100,15 @@ func (s *state3) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state3) addressMap() (adt.Map, error) {
return adt3.AsMap(s.store, s.AddressMap, builtin3.DefaultHamtBitwidth)
func (s *state3) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state3) AddressMap() (adt.Map, error) {
return adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth)
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -27,6 +27,19 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, networkName string) (State, error) {
out := state4{store: store}
s, err := init4.ConstructState(store, networkName)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state4 struct {
init4.State
store adt.Store
@ -64,6 +77,11 @@ func (s *state4) SetNetworkName(name string) error {
return nil
}
func (s *state4) SetNextID(id abi.ActorID) error {
s.State.NextID = id
return nil
}
func (s *state4) Remove(addrs ...address.Address) (err error) {
m, err := adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth)
if err != nil {
@ -82,6 +100,15 @@ func (s *state4) Remove(addrs ...address.Address) (err error) {
return nil
}
func (s *state4) addressMap() (adt.Map, error) {
return adt4.AsMap(s.store, s.AddressMap, builtin4.DefaultHamtBitwidth)
func (s *state4) SetAddressMap(mcid cid.Cid) error {
s.State.AddressMap = mcid
return nil
}
func (s *state4) AddressMap() (adt.Map, error) {
return adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth)
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -16,6 +16,7 @@ import (
{{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"
)
@ -42,6 +43,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
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{{.}}.StorageMarketActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
BalancesChanged(State) (bool, error)
@ -56,6 +78,7 @@ type State interface {
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error)
GetState() interface{}
}
type BalanceTable interface {
@ -81,7 +104,6 @@ type DealProposals interface {
type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams
type ClientDealProposal = market0.ClientDealProposal
@ -89,71 +111,71 @@ 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
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
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
ProviderCollateral abi.TokenAmount
ClientCollateral abi.TokenAmount
}
type DealStateChanges struct {
Added []DealIDState
Added []DealIDState
Modified []DealStateChange
Removed []DealIDState
Removed []DealIDState
}
type DealIDState struct {
ID abi.DealID
ID abi.DealID
Deal DealState
}
// DealStateChange is a change in deal state from -> to
type DealStateChange struct {
ID abi.DealID
ID abi.DealID
From *DealState
To *DealState
To *DealState
}
type DealProposalChanges struct {
Added []ProposalIDState
Added []ProposalIDState
Removed []ProposalIDState
}
type ProposalIDState struct {
ID abi.DealID
ID abi.DealID
Proposal DealProposal
}
func EmptyDealState() *DealState {
return &DealState{
SectorStartEpoch: -1,
SlashEpoch: -1,
SlashEpoch: -1,
LastUpdatedEpoch: -1,
}
}
// returns the earned fees and pending fees for a given deal
func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, abi.TokenAmount) {
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
tf := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(deal.EndEpoch-deal.StartEpoch)))
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
if ef.LessThan(big.Zero()) {
ef = big.Zero()
}
ef := big.Mul(deal.StoragePricePerEpoch, big.NewInt(int64(height-deal.StartEpoch)))
if ef.LessThan(big.Zero()) {
ef = big.Zero()
}
if ef.GreaterThan(tf) {
ef = tf
}
if ef.GreaterThan(tf) {
ef = tf
}
return ef, big.Sub(tf, ef)
return ef, big.Sub(tf, ef)
}

View File

@ -20,6 +20,7 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types"
@ -68,6 +69,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
}
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
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
BalancesChanged(State) (bool, error)
@ -82,6 +122,7 @@ type State interface {
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error)
GetState() interface{}
}
type BalanceTable interface {
@ -107,7 +148,6 @@ type DealProposals interface {
type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams
type ClientDealProposal = market0.ClientDealProposal

View File

@ -26,6 +26,31 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
{{if (le .v 2)}}
ea, err := adt{{.v}}.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market{{.v}}.ConstructState(ea, em, em)
{{else}}
s, err := market{{.v}}.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
{{end}}
return &out, nil
}
type state{{.v}} struct {
market{{.v}}.State
store adt.Store
@ -207,3 +232,7 @@ func (s *dealProposals{{.v}}) array() adt.Array {
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal {
return (DealProposal)(v{{.v}})
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

View File

@ -26,6 +26,24 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
ea, err := adt0.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market0.ConstructState(ea, em, em)
return &out, nil
}
type state0 struct {
market0.State
store adt.Store
@ -207,3 +225,7 @@ func (s *dealProposals0) array() adt.Array {
func fromV0DealProposal(v0 market0.DealProposal) DealProposal {
return (DealProposal)(v0)
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,24 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
ea, err := adt2.MakeEmptyArray(store).Root()
if err != nil {
return nil, err
}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State = *market2.ConstructState(ea, em, em)
return &out, nil
}
type state2 struct {
market2.State
store adt.Store
@ -207,3 +225,7 @@ func (s *dealProposals2) array() adt.Array {
func fromV2DealProposal(v2 market2.DealProposal) DealProposal {
return (DealProposal)(v2)
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,19 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
s, err := market3.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state3 struct {
market3.State
store adt.Store
@ -207,3 +220,7 @@ func (s *dealProposals3) array() adt.Array {
func fromV3DealProposal(v3 market3.DealProposal) DealProposal {
return (DealProposal)(v3)
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -26,6 +26,19 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
s, err := market4.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state4 struct {
market4.State
store adt.Store
@ -207,3 +220,7 @@ func (s *dealProposals4) array() adt.Array {
func fromV4DealProposal(v4 market4.DealProposal) DealProposal {
return (DealProposal)(v4)
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -3,6 +3,7 @@ package miner
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"
@ -60,6 +61,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
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{{.}}.StorageMinerActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -79,6 +101,11 @@ type State interface {
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
// Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors
GetProvingPeriodStart() (abi.ChainEpoch, error)
// Testing only
EraseAllUnproven() error
LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
NumDeadlines() (uint64, error)
@ -95,6 +122,7 @@ type State interface {
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
type Deadline interface {
@ -115,26 +143,26 @@ type Partition interface {
}
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
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
}
type SectorPreCommitInfo = miner0.SectorPreCommitInfo
type SectorPreCommitOnChainInfo struct {
Info SectorPreCommitInfo
Info SectorPreCommitInfo
PreCommitDeposit abi.TokenAmount
PreCommitEpoch abi.ChainEpoch
DealWeight abi.DealWeight
PreCommitEpoch abi.ChainEpoch
DealWeight abi.DealWeight
VerifiedDealWeight abi.DealWeight
}
@ -203,17 +231,17 @@ 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
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
ConsensusFaultElapsed abi.ChainEpoch
}
func (mi MinerInfo) IsController(addr address.Address) bool {
@ -244,25 +272,25 @@ type SectorLocation struct {
}
type SectorChanges struct {
Added []SectorOnChainInfo
Added []SectorOnChainInfo
Extended []SectorExtensions
Removed []SectorOnChainInfo
Removed []SectorOnChainInfo
}
type SectorExtensions struct {
From SectorOnChainInfo
To SectorOnChainInfo
To SectorOnChainInfo
}
type PreCommitChanges struct {
Added []SectorPreCommitOnChainInfo
Added []SectorPreCommitOnChainInfo
Removed []SectorPreCommitOnChainInfo
}
type LockedFunds struct {
VestingFunds abi.TokenAmount
VestingFunds abi.TokenAmount
InitialPledgeRequirement abi.TokenAmount
PreCommitDeposits abi.TokenAmount
PreCommitDeposits abi.TokenAmount
}
func (lf LockedFunds) TotalLockedFunds() abi.TokenAmount {

View File

@ -3,6 +3,7 @@ package miner
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"
@ -86,6 +87,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
}
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
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -105,6 +145,11 @@ type State interface {
NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, error)
// Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors
GetProvingPeriodStart() (abi.ChainEpoch, error)
// Testing only
EraseAllUnproven() error
LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
NumDeadlines() (uint64, error)
@ -121,6 +166,7 @@ type State interface {
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
GetState() interface{}
}
type Deadline interface {

View File

@ -35,6 +35,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
out.State = miner{{.v}}.State{}
return &out, nil
}
type state{{.v}} struct {
miner{{.v}}.State
store adt.Store
@ -68,9 +74,9 @@ func (s *state{{.v}}) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error)
func (s *state{{.v}}) LockedFunds() (LockedFunds, error) {
return LockedFunds{
VestingFunds: s.State.LockedFunds,
VestingFunds: s.State.LockedFunds,
InitialPledgeRequirement: s.State.InitialPledge{{if (le .v 1)}}Requirement{{end}},
PreCommitDeposits: s.State.PreCommitDeposits,
PreCommitDeposits: s.State.PreCommitDeposits,
}, nil
}
@ -245,6 +251,10 @@ func (s *state{{.v}}) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state{{.v}}) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state{{.v}}) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -307,19 +317,19 @@ func (s *state{{.v}}) Info() (MinerInfo, error) {
}
{{end}}
mi := MinerInfo{
Owner: info.Owner,
Worker: info.Worker,
Owner: info.Owner,
Worker: info.Worker,
ControlAddresses: info.ControlAddresses,
NewWorker: address.Undef,
NewWorker: address.Undef,
WorkerChangeEpoch: -1,
PeerId: pid,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: {{if (ge .v 3)}}info.WindowPoStProofType{{else}}wpp{{end}},
SectorSize: info.SectorSize,
PeerId: pid,
Multiaddrs: info.Multiaddrs,
WindowPoStProofType: {{if (ge .v 3)}}info.WindowPoStProofType{{else}}wpp{{end}},
SectorSize: info.SectorSize,
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}},
ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}},
}
if info.PendingWorkerKey != nil {
@ -366,6 +376,45 @@ func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (Secto
return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil
}
func (s *state{{.v}}) EraseAllUnproven() error {
{{if (ge .v 2)}}
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner{{.v}}.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner{{.v}}.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)
})
return s.State.SaveDeadlines(s.store, dls)
{{else}}
// field doesn't exist until v2
{{end}}
return nil
}
func (d *deadline{{.v}}) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -428,16 +477,16 @@ func (p *partition{{.v}}) RecoveringSectors() (bitfield.BitField, error) {
func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorOnChainInfo {
{{if (ge .v 2)}}
return SectorOnChainInfo{
SectorNumber: v{{.v}}.SectorNumber,
SealProof: v{{.v}}.SealProof,
SealedCID: v{{.v}}.SealedCID,
DealIDs: v{{.v}}.DealIDs,
Activation: v{{.v}}.Activation,
Expiration: v{{.v}}.Expiration,
DealWeight: v{{.v}}.DealWeight,
VerifiedDealWeight: v{{.v}}.VerifiedDealWeight,
InitialPledge: v{{.v}}.InitialPledge,
ExpectedDayReward: v{{.v}}.ExpectedDayReward,
SectorNumber: v{{.v}}.SectorNumber,
SealProof: v{{.v}}.SealProof,
SealedCID: v{{.v}}.SealedCID,
DealIDs: v{{.v}}.DealIDs,
Activation: v{{.v}}.Activation,
Expiration: v{{.v}}.Expiration,
DealWeight: v{{.v}}.DealWeight,
VerifiedDealWeight: v{{.v}}.VerifiedDealWeight,
InitialPledge: v{{.v}}.InitialPledge,
ExpectedDayReward: v{{.v}}.ExpectedDayReward,
ExpectedStoragePledge: v{{.v}}.ExpectedStoragePledge,
}
{{else}}
@ -448,13 +497,17 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO
func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
{{if (ge .v 2)}}
return SectorPreCommitOnChainInfo{
Info: (SectorPreCommitInfo)(v{{.v}}.Info),
PreCommitDeposit: v{{.v}}.PreCommitDeposit,
PreCommitEpoch: v{{.v}}.PreCommitEpoch,
DealWeight: v{{.v}}.DealWeight,
Info: (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{} {
return &s.State
}

View File

View File

@ -32,6 +32,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = miner0.State{}
return &out, nil
}
type state0 struct {
miner0.State
store adt.Store
@ -242,6 +248,10 @@ func (s *state0) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state0) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state0) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -363,6 +373,13 @@ func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV0SectorPreCommitOnChainInfo(sp), nil
}
func (s *state0) EraseAllUnproven() error {
// field doesn't exist until v2
return nil
}
func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -426,3 +443,7 @@ func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) Sect
return (SectorPreCommitOnChainInfo)(v0)
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -30,6 +30,12 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
out.State = miner2.State{}
return &out, nil
}
type state2 struct {
miner2.State
store adt.Store
@ -240,6 +246,10 @@ func (s *state2) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state2) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state2) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -361,6 +371,43 @@ func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV2SectorPreCommitOnChainInfo(sp), nil
}
func (s *state2) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner2.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner2.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)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline2) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -442,3 +489,7 @@ func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) Sect
}
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -32,6 +32,12 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
out.State = miner3.State{}
return &out, nil
}
type state3 struct {
miner3.State
store adt.Store
@ -242,6 +248,10 @@ func (s *state3) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state3) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state3) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -358,6 +368,43 @@ func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV3SectorPreCommitOnChainInfo(sp), nil
}
func (s *state3) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner3.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner3.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)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline3) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -443,3 +490,7 @@ func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) Sect
}
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -32,6 +32,12 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
out.State = miner4.State{}
return &out, nil
}
type state4 struct {
miner4.State
store adt.Store
@ -242,6 +248,10 @@ func (s *state4) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num))
}
func (s *state4) GetProvingPeriodStart() (abi.ChainEpoch, error) {
return s.State.ProvingPeriodStart, nil
}
func (s *state4) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
@ -358,6 +368,43 @@ func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV4SectorPreCommitOnChainInfo(sp), nil
}
func (s *state4) EraseAllUnproven() error {
dls, err := s.State.LoadDeadlines(s.store)
if err != nil {
return err
}
err = dls.ForEach(s.store, func(dindx uint64, dl *miner4.Deadline) error {
ps, err := dl.PartitionsArray(s.store)
if err != nil {
return err
}
var part miner4.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)
})
return s.State.SaveDeadlines(s.store, dls)
return nil
}
func (d *deadline4) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil {
@ -443,3 +490,7 @@ func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) Sect
}
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -40,6 +40,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
{{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{{.}}.MultisigActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -55,6 +76,7 @@ type State interface {
transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error)
GetState() interface{}
}
type Transaction = msig{{.latestVersion}}.Transaction
@ -66,7 +88,7 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
{{range .versions}}
case actors.Version{{.}}:
return message{{.}}{{"{"}}{{if (ge . 2)}}message0{from}{{else}}from{{end}}}
{{end}} default:
{{end}} default:
panic(fmt.Sprintf("unsupported actors version: %d", version))
}
}

View File

@ -43,10 +43,10 @@ func (m message{{.v}}) Create(
{{end}}
// Set up constructor parameters for multisig
msigParams := &multisig{{.v}}.ConstructorParams{
Signers: signers,
Signers: signers,
NumApprovalsThreshold: threshold,
UnlockDuration: unlockDuration,{{if (ge .v 2)}}
StartEpoch: unlockStart,{{end}}
UnlockDuration: unlockDuration,{{if (ge .v 2)}}
StartEpoch: unlockStart,{{end}}
}
enc, actErr := actors.SerializeParams(msigParams)
@ -56,7 +56,7 @@ func (m message{{.v}}) Create(
// new actors are created by invoking 'exec' on the init actor with the constructor params
execParams := &init{{.v}}.ExecParams{
CodeCID: builtin{{.v}}.MultisigActorCodeID,
CodeCID: builtin{{.v}}.MultisigActorCodeID,
ConstructorParams: enc,
}
@ -66,11 +66,11 @@ func (m message{{.v}}) Create(
}
return &types.Message{
To: init_.Address,
From: m.from,
To: init_.Address,
From: m.from,
Method: builtin{{.v}}.MethodsInit.Exec,
Params: enc,
Value: initialAmount,
Value: initialAmount,
}, nil
}
@ -96,8 +96,8 @@ func (m message0) Propose(msig, to address.Address, amt abi.TokenAmount,
}
enc, actErr := actors.SerializeParams(&multisig0.ProposeParams{
To: to,
Value: amt,
To: to,
Value: amt,
Method: method,
Params: params,
})
@ -106,9 +106,9 @@ func (m message0) Propose(msig, to address.Address, amt abi.TokenAmount,
}
return &types.Message{
To: msig,
From: m.from,
Value: abi.NewTokenAmount(0),
To: msig,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin0.MethodsMultisig.Propose,
Params: enc,
}, nil
@ -121,9 +121,9 @@ func (m message0) Approve(msig address.Address, txID uint64, hashData *ProposalH
}
return &types.Message{
To: msig,
From: m.from,
Value: types.NewInt(0),
To: msig,
From: m.from,
Value: types.NewInt(0),
Method: builtin0.MethodsMultisig.Approve,
Params: enc,
}, nil
@ -136,9 +136,9 @@ func (m message0) Cancel(msig address.Address, txID uint64, hashData *ProposalHa
}
return &types.Message{
To: msig,
From: m.from,
Value: types.NewInt(0),
To: msig,
From: m.from,
Value: types.NewInt(0),
Method: builtin0.MethodsMultisig.Cancel,
Params: enc,
}, nil

View File

@ -66,6 +66,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
switch av {
case actors.Version0:
return make0(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version2:
return make2(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version3:
return make3(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
case actors.Version4:
return make4(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
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -81,6 +120,7 @@ type State interface {
transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error)
GetState() interface{}
}
type Transaction = msig4.Transaction

View File

@ -31,6 +31,32 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state{{.v}}{store: store}
out.State = msig{{.v}}.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
{{if (le .v 2)}}
em, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
{{else}}
em, err := adt{{.v}}.StoreEmptyMap(store, builtin{{.v}}.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
{{end}}
return &out, nil
}
type state{{.v}} struct {
msig{{.v}}.State
store adt.Store
@ -95,3 +121,7 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error)
}
return tx, nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

View File

@ -28,6 +28,25 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state0{store: store}
out.State = msig0.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state0 struct {
msig0.State
store adt.Store
@ -92,3 +111,7 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -28,6 +28,25 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state2{store: store}
out.State = msig2.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state2 struct {
msig2.State
store adt.Store
@ -92,3 +111,7 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -30,6 +30,25 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state3{store: store}
out.State = msig3.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt3.StoreEmptyMap(store, builtin3.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state3 struct {
msig3.State
store adt.Store
@ -94,3 +113,7 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -30,6 +30,25 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
out := state4{store: store}
out.State = msig4.State{}
out.State.Signers = signers
out.State.NumApprovalsThreshold = threshold
out.State.StartEpoch = startEpoch
out.State.UnlockDuration = unlockDuration
out.State.InitialBalance = initialBalance
em, err := adt4.StoreEmptyMap(store, builtin4.DefaultHamtBitwidth)
if err != nil {
return nil, err
}
out.State.PendingTxns = em
return &out, nil
}
type state4 struct {
msig4.State
store adt.Store
@ -94,3 +113,7 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
}
return tx, nil
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -42,6 +42,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
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 {
@ -62,6 +83,8 @@ type State interface {
// Iterate lane states
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
GetState() interface{}
}
// LaneState is an abstract copy of the state of a single lane

View File

@ -21,7 +21,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount)
return nil, aerr
}
enc, aerr := actors.SerializeParams(&init{{.v}}.ExecParams{
CodeCID: builtin{{.v}}.PaymentChannelActorCodeID,
CodeCID: builtin{{.v}}.PaymentChannelActorCodeID,
ConstructorParams: params,
})
if aerr != nil {
@ -29,9 +29,9 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount)
}
return &types.Message{
To: init_.Address,
From: m.from,
Value: initialAmount,
To: init_.Address,
From: m.from,
Value: initialAmount,
Method: builtin{{.v}}.MethodsInit.Exec,
Params: enc,
}, nil
@ -39,7 +39,7 @@ func (m message{{.v}}) Create(to address.Address, initialAmount abi.TokenAmount)
func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
params, aerr := actors.SerializeParams(&paych{{.v}}.UpdateChannelStateParams{
Sv: *sv,
Sv: *sv,
Secret: secret,
})
if aerr != nil {
@ -47,9 +47,9 @@ func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret [
}
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin{{.v}}.MethodsPaych.UpdateChannelState,
Params: params,
}, nil
@ -57,18 +57,18 @@ func (m message{{.v}}) Update(paych address.Address, sv *SignedVoucher, secret [
func (m message{{.v}}) Settle(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin{{.v}}.MethodsPaych.Settle,
}, nil
}
func (m message{{.v}}) Collect(paych address.Address) (*types.Message, error) {
return &types.Message{
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
To: paych,
From: m.from,
Value: abi.NewTokenAmount(0),
Method: builtin{{.v}}.MethodsPaych.Collect,
}, nil
}

View File

@ -17,6 +17,10 @@ type mockState struct {
lanes map[uint64]paych.LaneState
}
func (ms *mockState) GetState() interface{} {
panic("implement me")
}
type mockLaneState struct {
redeemed big.Int
nonce uint64

View File

View File

@ -68,6 +68,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.PaymentChannelActorCodeID, nil
case actors.Version2:
return builtin2.PaymentChannelActorCodeID, nil
case actors.Version3:
return builtin3.PaymentChannelActorCodeID, nil
case actors.Version4:
return builtin4.PaymentChannelActorCodeID, nil
}
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 {
@ -88,6 +127,8 @@ type State interface {
// Iterate lane states
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
GetState() interface{}
}
// LaneState is an abstract copy of the state of a single lane

View File

@ -24,6 +24,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
out.State = paych{{.v}}.State{}
return &out, nil
}
type state{{.v}} struct {
paych{{.v}}.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state{{.v}}) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state{{.v}}) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

View File

View File

@ -24,6 +24,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = paych0.State{}
return &out, nil
}
type state0 struct {
paych0.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state0) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state0) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state0) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

View File

@ -24,6 +24,12 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
out.State = paych2.State{}
return &out, nil
}
type state2 struct {
paych2.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state2) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state2) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state2) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

View File

@ -24,6 +24,12 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
out.State = paych3.State{}
return &out, nil
}
type state3 struct {
paych3.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state3) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state3) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state3) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

View File

@ -24,6 +24,12 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
out.State = paych4.State{}
return &out, nil
}
type state4 struct {
paych4.State
store adt.Store
@ -74,6 +80,10 @@ func (s *state4) LaneCount() (uint64, error) {
return lsamt.Length(), nil
}
func (s *state4) GetState() interface{} {
return &s.State
}
// Iterate lane states
func (s *state4) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain

View File

@ -3,6 +3,7 @@ package power
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
@ -40,6 +41,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
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{{.}}.StoragePowerActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -47,6 +69,7 @@ type State interface {
TotalPower() (Claim, error)
TotalCommitted() (Claim, error)
TotalPowerSmoothed() (builtin.FilterEstimate, error)
GetState() interface{}
// MinerCounts returns the number of miners. Participating is the number
// with power above the minimum miner threshold.
@ -57,6 +80,12 @@ type State interface {
ForEachClaim(func(miner address.Address, claim Claim) error) error
ClaimsChanged(State) (bool, error)
// Testing or genesis setup only
SetTotalQualityAdjPower(abi.StoragePower) error
SetTotalRawBytePower(abi.StoragePower) error
SetThisEpochQualityAdjPower(abi.StoragePower) error
SetThisEpochRawBytePower(abi.StoragePower) error
// Diff helpers. Used by Diff* functions internally.
claims() (adt.Map, error)
decodeClaim(*cbg.Deferred) (Claim, error)
@ -72,7 +101,7 @@ type Claim struct {
func AddClaims(a Claim, b Claim) Claim {
return Claim{
RawBytePower: big.Add(a.RawBytePower, b.RawBytePower),
RawBytePower: big.Add(a.RawBytePower, b.RawBytePower),
QualityAdjPower: big.Add(a.QualityAdjPower, b.QualityAdjPower),
}
}

View File

@ -3,6 +3,7 @@ package power
import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
@ -66,6 +67,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.StoragePowerActorCodeID, nil
case actors.Version2:
return builtin2.StoragePowerActorCodeID, nil
case actors.Version3:
return builtin3.StoragePowerActorCodeID, nil
case actors.Version4:
return builtin4.StoragePowerActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -73,6 +113,7 @@ type State interface {
TotalPower() (Claim, error)
TotalCommitted() (Claim, error)
TotalPowerSmoothed() (builtin.FilterEstimate, error)
GetState() interface{}
// MinerCounts returns the number of miners. Participating is the number
// with power above the minimum miner threshold.
@ -83,6 +124,12 @@ type State interface {
ForEachClaim(func(miner address.Address, claim Claim) error) error
ClaimsChanged(State) (bool, error)
// Testing or genesis setup only
SetTotalQualityAdjPower(abi.StoragePower) error
SetTotalRawBytePower(abi.StoragePower) error
SetThisEpochQualityAdjPower(abi.StoragePower) error
SetThisEpochRawBytePower(abi.StoragePower) error
// Diff helpers. Used by Diff* functions internally.
claims() (adt.Map, error)
decodeClaim(*cbg.Deferred) (Claim, error)

View File

@ -29,6 +29,32 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
{{if (le .v 2)}}
em, err := adt{{.v}}.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt{{.v}}.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
out.State = *power{{.v}}.ConstructState(em, emm)
{{else}}
s, err := power{{.v}}.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
{{end}}
return &out, nil
}
type state{{.v}} struct {
power{{.v}}.State
store adt.Store
@ -40,7 +66,7 @@ func (s *state{{.v}}) TotalLocked() (abi.TokenAmount, error) {
func (s *state{{.v}}) TotalPower() (Claim, error) {
return Claim{
RawBytePower: s.TotalRawBytePower,
RawBytePower: s.TotalRawBytePower,
QualityAdjPower: s.TotalQualityAdjPower,
}, nil
}
@ -48,7 +74,7 @@ func (s *state{{.v}}) TotalPower() (Claim, error) {
// Committed power to the network. Includes miners below the minimum threshold.
func (s *state{{.v}}) TotalCommitted() (Claim, error) {
return Claim{
RawBytePower: s.TotalBytesCommitted,
RawBytePower: s.TotalBytesCommitted,
QualityAdjPower: s.TotalQABytesCommitted,
}, nil
}
@ -64,7 +90,7 @@ func (s *state{{.v}}) MinerPower(addr address.Address) (Claim, bool, error) {
return Claim{}, false, err
}
return Claim{
RawBytePower: claim.RawBytePower,
RawBytePower: claim.RawBytePower,
QualityAdjPower: claim.QualityAdjPower,
}, ok, nil
}
@ -116,7 +142,7 @@ func (s *state{{.v}}) ForEachClaim(cb func(miner address.Address, claim Claim) e
return err
}
return cb(a, Claim{
RawBytePower: claim.RawBytePower,
RawBytePower: claim.RawBytePower,
QualityAdjPower: claim.QualityAdjPower,
})
})
@ -131,6 +157,30 @@ func (s *state{{.v}}) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other{{.v}}.State.Claims), nil
}
func (s *state{{.v}}) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state{{.v}}) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state{{.v}}) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state{{.v}}) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
func (s *state{{.v}}) claims() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.Claims{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
}
@ -145,7 +195,7 @@ func (s *state{{.v}}) decodeClaim(val *cbg.Deferred) (Claim, error) {
func fromV{{.v}}Claim(v{{.v}} power{{.v}}.Claim) Claim {
return Claim{
RawBytePower: v{{.v}}.RawBytePower,
RawBytePower: v{{.v}}.RawBytePower,
QualityAdjPower: v{{.v}}.QualityAdjPower,
}
}

View File

View File

@ -26,6 +26,24 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store) (State, error) {
out := state0{store: store}
em, err := adt0.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt0.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
out.State = *power0.ConstructState(em, emm)
return &out, nil
}
type state0 struct {
power0.State
store adt.Store
@ -128,6 +146,30 @@ func (s *state0) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other0.State.Claims), nil
}
func (s *state0) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state0) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state0) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state0) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state0) GetState() interface{} {
return &s.State
}
func (s *state0) claims() (adt.Map, error) {
return adt0.AsMap(s.store, s.Claims)
}

View File

@ -26,6 +26,24 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store) (State, error) {
out := state2{store: store}
em, err := adt2.MakeEmptyMap(store).Root()
if err != nil {
return nil, err
}
emm, err := adt2.MakeEmptyMultimap(store).Root()
if err != nil {
return nil, err
}
out.State = *power2.ConstructState(em, emm)
return &out, nil
}
type state2 struct {
power2.State
store adt.Store
@ -128,6 +146,30 @@ func (s *state2) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other2.State.Claims), nil
}
func (s *state2) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state2) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state2) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state2) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state2) GetState() interface{} {
return &s.State
}
func (s *state2) claims() (adt.Map, error) {
return adt2.AsMap(s.store, s.Claims)
}

View File

@ -28,6 +28,19 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store) (State, error) {
out := state3{store: store}
s, err := power3.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state3 struct {
power3.State
store adt.Store
@ -130,6 +143,30 @@ func (s *state3) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other3.State.Claims), nil
}
func (s *state3) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state3) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state3) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state3) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state3) GetState() interface{} {
return &s.State
}
func (s *state3) claims() (adt.Map, error) {
return adt3.AsMap(s.store, s.Claims, builtin3.DefaultHamtBitwidth)
}

View File

@ -28,6 +28,19 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store) (State, error) {
out := state4{store: store}
s, err := power4.ConstructState(store)
if err != nil {
return nil, err
}
out.State = *s
return &out, nil
}
type state4 struct {
power4.State
store adt.Store
@ -130,6 +143,30 @@ func (s *state4) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other4.State.Claims), nil
}
func (s *state4) SetTotalQualityAdjPower(p abi.StoragePower) error {
s.State.TotalQualityAdjPower = p
return nil
}
func (s *state4) SetTotalRawBytePower(p abi.StoragePower) error {
s.State.TotalRawBytePower = p
return nil
}
func (s *state4) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
s.State.ThisEpochQualityAdjPower = p
return nil
}
func (s *state4) SetThisEpochRawBytePower(p abi.StoragePower) error {
s.State.ThisEpochRawBytePower = p
return nil
}
func (s *state4) GetState() interface{} {
return &s.State
}
func (s *state4) claims() (adt.Map, error) {
return adt4.AsMap(s.store, s.Claims, builtin4.DefaultHamtBitwidth)
}

View File

@ -4,6 +4,7 @@ import (
"github.com/filecoin-project/go-state-types/abi"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/cbor"
@ -38,6 +39,27 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) {
switch av {
{{range .versions}}
case actors.Version{{.}}:
return make{{.}}(store, currRealizedPower)
{{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{{.}}.RewardActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -55,6 +77,7 @@ type State interface {
InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error)
PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error)
GetState() interface{}
}
type AwardBlockRewardParams = reward0.AwardBlockRewardParams

View File

@ -2,6 +2,7 @@ package reward
import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
@ -64,6 +65,45 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
}
func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.StoragePower) (State, error) {
switch av {
case actors.Version0:
return make0(store, currRealizedPower)
case actors.Version2:
return make2(store, currRealizedPower)
case actors.Version3:
return make3(store, currRealizedPower)
case actors.Version4:
return make4(store, currRealizedPower)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.RewardActorCodeID, nil
case actors.Version2:
return builtin2.RewardActorCodeID, nil
case actors.Version3:
return builtin3.RewardActorCodeID, nil
case actors.Version4:
return builtin4.RewardActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
cbor.Marshaler
@ -81,6 +121,7 @@ type State interface {
InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error)
PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error)
GetState() interface{}
}
type AwardBlockRewardParams = reward0.AwardBlockRewardParams

View File

@ -23,6 +23,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make{{.v}}(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state{{.v}}{store: store}
out.State = *reward{{.v}}.ConstructState(currRealizedPower)
return &out, nil
}
type state{{.v}} struct {
reward{{.v}}.State
store adt.Store
@ -101,3 +107,7 @@ func (s *state{{.v}}) PreCommitDepositForPower(networkQAPower builtin.FilterEsti
},
sectorWeight), nil
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

View File

@ -23,6 +23,12 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make0(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state0{store: store}
out.State = *reward0.ConstructState(currRealizedPower)
return &out, nil
}
type state0 struct {
reward0.State
store adt.Store
@ -83,3 +89,7 @@ func (s *state0) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
},
sectorWeight), nil
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -23,6 +23,12 @@ func load2(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make2(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state2{store: store}
out.State = *reward2.ConstructState(currRealizedPower)
return &out, nil
}
type state2 struct {
reward2.State
store adt.Store
@ -86,3 +92,7 @@ func (s *state2) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
},
sectorWeight), nil
}
func (s *state2) GetState() interface{} {
return &s.State
}

View File

@ -23,6 +23,12 @@ func load3(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make3(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state3{store: store}
out.State = *reward3.ConstructState(currRealizedPower)
return &out, nil
}
type state3 struct {
reward3.State
store adt.Store
@ -86,3 +92,7 @@ func (s *state3) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
},
sectorWeight), nil
}
func (s *state3) GetState() interface{} {
return &s.State
}

View File

@ -23,6 +23,12 @@ func load4(store adt.Store, root cid.Cid) (State, error) {
return &out, nil
}
func make4(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
out := state4{store: store}
out.State = *reward4.ConstructState(currRealizedPower)
return &out, nil
}
type state4 struct {
reward4.State
store adt.Store
@ -86,3 +92,7 @@ func (s *state4) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
},
sectorWeight), nil
}
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,41 @@
package system
import (
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors"
"github.com/ipfs/go-cid"
{{range .versions}}
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
{{end}}
)
var (
Address = builtin{{.latestVersion}}.SystemActorAddr
)
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{{.}}.SystemActorCodeID, nil
{{end}}
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
GetState() interface{}
}

View File

@ -0,0 +1,35 @@
package system
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
system{{.v}} "github.com/filecoin-project/specs-actors{{.import}}actors/builtin/system"
)
var _ State = (*state{{.v}})(nil)
func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
out := state{{.v}}{store: store}
err := store.Get(store.Context(), root, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func make{{.v}}(store adt.Store) (State, error) {
out := state{{.v}}{store: store}
out.State = system{{.v}}.State{}
return &out, nil
}
type state{{.v}} struct {
system{{.v}}.State
store adt.Store
}
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,63 @@
package system
import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
)
var (
Address = builtin4.SystemActorAddr
)
func MakeState(store adt.Store, av actors.Version) (State, error) {
switch av {
case actors.Version0:
return make0(store)
case actors.Version2:
return make2(store)
case actors.Version3:
return make3(store)
case actors.Version4:
return make4(store)
}
return nil, xerrors.Errorf("unknown actor version %d", av)
}
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
switch av {
case actors.Version0:
return builtin0.SystemActorCodeID, nil
case actors.Version2:
return builtin2.SystemActorCodeID, nil
case actors.Version3:
return builtin3.SystemActorCodeID, nil
case actors.Version4:
return builtin4.SystemActorCodeID, nil
}
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
}
type State interface {
GetState() interface{}
}

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