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 # 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. 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.

View File

@ -303,17 +303,10 @@ clean-services: clean-all-services
buildall: $(BINS) buildall: $(BINS)
completions:
./scripts/make-completions.sh lotus
./scripts/make-completions.sh lotus-miner
.PHONY: completions
install-completions: install-completions:
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/ 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 /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 /usr/local/share/zsh/site-functions/_lotus
install -C ./scripts/zsh-completion/lotus-miner /usr/local/share/zsh/site-functions/_lotus-miner
clean: clean:
rm -rf $(CLEAN) $(BINS) 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" @echo ">>> IF YOU'VE MODIFIED THE CLI, REMEMBER TO ALSO MAKE docsgen-cli"
.PHONY: gen .PHONY: gen
snap: lotus lotus-miner lotus-worker
snapcraft
# snapcraft upload ./lotus_*.snap
# separate from gen because it needs binaries # separate from gen because it needs binaries
docsgen-cli: lotus lotus-miner lotus-worker docsgen-cli: lotus lotus-miner lotus-worker
python ./scripts/generate-lotus-cli.py 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 ClientRemoveImport(ctx context.Context, importID multistore.StoreID) error //perm:admin
// ClientStartDeal proposes a deal with a miner. // ClientStartDeal proposes a deal with a miner.
ClientStartDeal(ctx context.Context, params *StartDealParams) (*cid.Cid, error) //perm:admin 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 returns the latest information about a given deal.
ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error) //perm:read ClientGetDealInfo(context.Context, cid.Cid) (*DealInfo, error) //perm:read
// ClientListDeals returns information about the deals made by the local client. // 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) 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 // Closing mocks base method
func (m *MockFullNode) Closing(arg0 context.Context) (<-chan struct{}, error) { func (m *MockFullNode) Closing(arg0 context.Context) (<-chan struct{}, error) {
m.ctrl.T.Helper() 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"` 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"` 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"` 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") 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 { func (s *FullNodeStruct) CreateBackup(p0 context.Context, p1 string) error {
return s.Internal.CreateBackup(p0, p1) 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 ClientRemoveImport(ctx context.Context, importID multistore.StoreID) error //perm:admin
// ClientStartDeal proposes a deal with a miner. // ClientStartDeal proposes a deal with a miner.
ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) //perm:admin 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 returns the latest information about a given deal.
ClientGetDealInfo(context.Context, cid.Cid) (*api.DealInfo, error) //perm:read ClientGetDealInfo(context.Context, cid.Cid) (*api.DealInfo, error) //perm:read
// ClientListDeals returns information about the deals made by the local client. // 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"` 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"` 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"` 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") 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 { func (s *FullNodeStruct) CreateBackup(p0 context.Context, p1 string) error {
return s.Internal.CreateBackup(p0, p1) 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) 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 // Closing mocks base method
func (m *MockFullNode) Closing(arg0 context.Context) (<-chan struct{}, error) { func (m *MockFullNode) Closing(arg0 context.Context) (<-chan struct{}, error) {
m.ctrl.T.Helper() 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 UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4) var UpgradeTapeHeight = abi.ChainEpoch(-4)
var UpgradeActorsV2Height = abi.ChainEpoch(10) var UpgradeActorsV2Height = abi.ChainEpoch(-5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-5) var UpgradeLiftoffHeight = abi.ChainEpoch(-6)
var UpgradeKumquatHeight = abi.ChainEpoch(15) var UpgradeKumquatHeight = abi.ChainEpoch(-7)
var UpgradeCalicoHeight = abi.ChainEpoch(20) var UpgradeCalicoHeight = abi.ChainEpoch(-8)
var UpgradePersianHeight = abi.ChainEpoch(25) var UpgradePersianHeight = abi.ChainEpoch(-9)
var UpgradeOrangeHeight = abi.ChainEpoch(27) var UpgradeOrangeHeight = abi.ChainEpoch(-10)
var UpgradeClausHeight = abi.ChainEpoch(30) 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{ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet, 0: DrandMainnet,
} }
func init() { func init() {
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1) policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1, abi.RegisteredSealProof_StackedDrg8MiBV1)
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048)) policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
policy.SetMinVerifiedDealSize(abi.NewStoragePower(256)) policy.SetMinVerifiedDealSize(abi.NewStoragePower(256))
policy.SetPreCommitChallengeDelay(abi.ChainEpoch(10)) policy.SetPreCommitChallengeDelay(abi.ChainEpoch(10))

View File

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

View File

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

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

View File

View File

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

View File

@ -1,6 +1,7 @@
package account package account
import ( import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
PubkeyAddress() (address.Address, error) 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 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 { type state{{.v}} struct {
account{{.v}}.State account{{.v}}.State
store adt.Store store adt.Store
@ -28,3 +34,7 @@ type state{{.v}} struct {
func (s *state{{.v}}) PubkeyAddress() (address.Address, error) { func (s *state{{.v}}) PubkeyAddress() (address.Address, error) {
return s.Address, nil 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 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 { type state0 struct {
account0.State account0.State
store adt.Store store adt.Store
@ -28,3 +34,7 @@ type state0 struct {
func (s *state0) PubkeyAddress() (address.Address, error) { func (s *state0) PubkeyAddress() (address.Address, error) {
return s.Address, nil 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 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 { type state2 struct {
account2.State account2.State
store adt.Store store adt.Store
@ -28,3 +34,7 @@ type state2 struct {
func (s *state2) PubkeyAddress() (address.Address, error) { func (s *state2) PubkeyAddress() (address.Address, error) {
return s.Address, nil 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 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 { type state3 struct {
account3.State account3.State
store adt.Store store adt.Store
@ -28,3 +34,7 @@ type state3 struct {
func (s *state3) PubkeyAddress() (address.Address, error) { func (s *state3) PubkeyAddress() (address.Address, error) {
return s.Address, nil 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 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 { type state4 struct {
account4.State account4.State
store adt.Store store adt.Store
@ -28,3 +34,7 @@ type state4 struct {
func (s *state4) PubkeyAddress() (address.Address, error) { func (s *state4) PubkeyAddress() (address.Address, error) {
return s.Address, nil return s.Address, nil
} }
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -1,10 +1,42 @@
package cron package cron
import ( 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 ( var (
Address = builtin{{.latestVersion}}.CronActorAddr Address = builtin{{.latestVersion}}.CronActorAddr
Methods = builtin{{.latestVersion}}.MethodsCron Methods = builtin{{.latestVersion}}.MethodsCron
) )
type State interface {
GetState() interface{}
}

View File

@ -1,10 +1,64 @@
package cron package cron
import ( 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" 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 ( var (
Address = builtin4.CronActorAddr Address = builtin4.CronActorAddr
Methods = builtin4.MethodsCron 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 package init
import ( import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -56,5 +78,12 @@ type State interface {
// Sets the network's name. This should only be used on upgrade/fork. // Sets the network's name. This should only be used on upgrade/fork.
SetNetworkName(name string) error 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) { func DiffAddressMap(pre, cur State) (*AddressMapChanges, error) {
prem, err := pre.addressMap() prem, err := pre.AddressMap()
if err != nil { if err != nil {
return nil, err return nil, err
} }
curm, err := cur.addressMap() curm, err := cur.AddressMap()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,6 +1,7 @@
package init package init
import ( import (
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -82,5 +122,12 @@ type State interface {
// Sets the network's name. This should only be used on upgrade/fork. // Sets the network's name. This should only be used on upgrade/fork.
SetNetworkName(name string) error 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 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 { type state{{.v}} struct {
init{{.v}}.State init{{.v}}.State
store adt.Store store adt.Store
@ -66,6 +86,11 @@ func (s *state{{.v}}) SetNetworkName(name string) error {
return nil 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) { 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}}) m, err := adt{{.v}}.AsMap(s.store, s.State.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
if err != nil { if err != nil {
@ -84,6 +109,15 @@ func (s *state{{.v}}) Remove(addrs ...address.Address) (err error) {
return nil return nil
} }
func (s *state{{.v}}) addressMap() (adt.Map, error) { func (s *state{{.v}}) SetAddressMap(mcid cid.Cid) error {
return adt{{.v}}.AsMap(s.store, s.AddressMap{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) 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 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 { type state0 struct {
init0.State init0.State
store adt.Store store adt.Store
@ -62,6 +75,11 @@ func (s *state0) SetNetworkName(name string) error {
return nil 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) { func (s *state0) Remove(addrs ...address.Address) (err error) {
m, err := adt0.AsMap(s.store, s.State.AddressMap) m, err := adt0.AsMap(s.store, s.State.AddressMap)
if err != nil { if err != nil {
@ -80,6 +98,15 @@ func (s *state0) Remove(addrs ...address.Address) (err error) {
return nil return nil
} }
func (s *state0) addressMap() (adt.Map, error) { func (s *state0) SetAddressMap(mcid cid.Cid) error {
return adt0.AsMap(s.store, s.AddressMap) 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 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 { type state2 struct {
init2.State init2.State
store adt.Store store adt.Store
@ -62,6 +75,11 @@ func (s *state2) SetNetworkName(name string) error {
return nil 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) { func (s *state2) Remove(addrs ...address.Address) (err error) {
m, err := adt2.AsMap(s.store, s.State.AddressMap) m, err := adt2.AsMap(s.store, s.State.AddressMap)
if err != nil { if err != nil {
@ -80,6 +98,15 @@ func (s *state2) Remove(addrs ...address.Address) (err error) {
return nil return nil
} }
func (s *state2) addressMap() (adt.Map, error) { func (s *state2) SetAddressMap(mcid cid.Cid) error {
return adt2.AsMap(s.store, s.AddressMap) 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 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 { type state3 struct {
init3.State init3.State
store adt.Store store adt.Store
@ -64,6 +77,11 @@ func (s *state3) SetNetworkName(name string) error {
return nil 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) { func (s *state3) Remove(addrs ...address.Address) (err error) {
m, err := adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth) m, err := adt3.AsMap(s.store, s.State.AddressMap, builtin3.DefaultHamtBitwidth)
if err != nil { if err != nil {
@ -82,6 +100,15 @@ func (s *state3) Remove(addrs ...address.Address) (err error) {
return nil return nil
} }
func (s *state3) addressMap() (adt.Map, error) { func (s *state3) SetAddressMap(mcid cid.Cid) error {
return adt3.AsMap(s.store, s.AddressMap, builtin3.DefaultHamtBitwidth) 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 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 { type state4 struct {
init4.State init4.State
store adt.Store store adt.Store
@ -64,6 +77,11 @@ func (s *state4) SetNetworkName(name string) error {
return nil 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) { func (s *state4) Remove(addrs ...address.Address) (err error) {
m, err := adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth) m, err := adt4.AsMap(s.store, s.State.AddressMap, builtin4.DefaultHamtBitwidth)
if err != nil { if err != nil {
@ -82,6 +100,15 @@ func (s *state4) Remove(addrs ...address.Address) (err error) {
return nil return nil
} }
func (s *state4) addressMap() (adt.Map, error) { func (s *state4) SetAddressMap(mcid cid.Cid) error {
return adt4.AsMap(s.store, s.AddressMap, builtin4.DefaultHamtBitwidth) 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}} {{end}}
"github.com/filecoin-project/lotus/chain/actors/adt" "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/actors/builtin"
"github.com/filecoin-project/lotus/chain/types" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
BalancesChanged(State) (bool, error) BalancesChanged(State) (bool, error)
@ -56,6 +78,7 @@ type State interface {
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error) ) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error) NextID() (abi.DealID, error)
GetState() interface{}
} }
type BalanceTable interface { type BalanceTable interface {
@ -81,7 +104,6 @@ type DealProposals interface {
type PublishStorageDealsParams = market0.PublishStorageDealsParams type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn type PublishStorageDealsReturn = market0.PublishStorageDealsReturn
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams type WithdrawBalanceParams = market0.WithdrawBalanceParams
type ClientDealProposal = market0.ClientDealProposal type ClientDealProposal = market0.ClientDealProposal

View File

@ -20,6 +20,7 @@ import (
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin" 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/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/types" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
BalancesChanged(State) (bool, error) BalancesChanged(State) (bool, error)
@ -82,6 +122,7 @@ type State interface {
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch, minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
) (weight, verifiedWeight abi.DealWeight, err error) ) (weight, verifiedWeight abi.DealWeight, err error)
NextID() (abi.DealID, error) NextID() (abi.DealID, error)
GetState() interface{}
} }
type BalanceTable interface { type BalanceTable interface {
@ -107,7 +148,6 @@ type DealProposals interface {
type PublishStorageDealsParams = market0.PublishStorageDealsParams type PublishStorageDealsParams = market0.PublishStorageDealsParams
type PublishStorageDealsReturn = market0.PublishStorageDealsReturn type PublishStorageDealsReturn = market0.PublishStorageDealsReturn
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
type WithdrawBalanceParams = market0.WithdrawBalanceParams type WithdrawBalanceParams = market0.WithdrawBalanceParams
type ClientDealProposal = market0.ClientDealProposal type ClientDealProposal = market0.ClientDealProposal

View File

@ -26,6 +26,31 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil 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 { type state{{.v}} struct {
market{{.v}}.State market{{.v}}.State
store adt.Store store adt.Store
@ -207,3 +232,7 @@ func (s *dealProposals{{.v}}) array() adt.Array {
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal { func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal {
return (DealProposal)(v{{.v}}) 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 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 { type state0 struct {
market0.State market0.State
store adt.Store store adt.Store
@ -207,3 +225,7 @@ func (s *dealProposals0) array() adt.Array {
func fromV0DealProposal(v0 market0.DealProposal) DealProposal { func fromV0DealProposal(v0 market0.DealProposal) DealProposal {
return (DealProposal)(v0) 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 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 { type state2 struct {
market2.State market2.State
store adt.Store store adt.Store
@ -207,3 +225,7 @@ func (s *dealProposals2) array() adt.Array {
func fromV2DealProposal(v2 market2.DealProposal) DealProposal { func fromV2DealProposal(v2 market2.DealProposal) DealProposal {
return (DealProposal)(v2) 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 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 { type state3 struct {
market3.State market3.State
store adt.Store store adt.Store
@ -207,3 +220,7 @@ func (s *dealProposals3) array() adt.Array {
func fromV3DealProposal(v3 market3.DealProposal) DealProposal { func fromV3DealProposal(v3 market3.DealProposal) DealProposal {
return (DealProposal)(v3) 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 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 { type state4 struct {
market4.State market4.State
store adt.Store store adt.Store
@ -207,3 +220,7 @@ func (s *dealProposals4) array() adt.Array {
func fromV4DealProposal(v4 market4.DealProposal) DealProposal { func fromV4DealProposal(v4 market4.DealProposal) DealProposal {
return (DealProposal)(v4) return (DealProposal)(v4)
} }
func (s *state4) GetState() interface{} {
return &s.State
}

View File

@ -3,6 +3,7 @@ package miner
import ( import (
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen" 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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -79,6 +101,11 @@ type State interface {
NumLiveSectors() (uint64, error) NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, 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) LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
NumDeadlines() (uint64, error) NumDeadlines() (uint64, error)
@ -95,6 +122,7 @@ type State interface {
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error) precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error) decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
GetState() interface{}
} }
type Deadline interface { type Deadline interface {

View File

@ -3,6 +3,7 @@ package miner
import ( import (
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network" "github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
cbg "github.com/whyrusleeping/cbor-gen" 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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -105,6 +145,11 @@ type State interface {
NumLiveSectors() (uint64, error) NumLiveSectors() (uint64, error)
IsAllocated(abi.SectorNumber) (bool, 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) LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
NumDeadlines() (uint64, error) NumDeadlines() (uint64, error)
@ -121,6 +166,7 @@ type State interface {
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error) decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
precommits() (adt.Map, error) precommits() (adt.Map, error)
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error) decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
GetState() interface{}
} }
type Deadline interface { type Deadline interface {

View File

@ -35,6 +35,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil 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 { type state{{.v}} struct {
miner{{.v}}.State miner{{.v}}.State
store adt.Store store adt.Store
@ -245,6 +251,10 @@ func (s *state{{.v}}) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num)) 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) { func (s *state{{.v}}) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store) dls, err := s.State.LoadDeadlines(s.store)
if err != nil { if err != nil {
@ -366,6 +376,45 @@ func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (Secto
return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil 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) { func (d *deadline{{.v}}) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx) p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil { if err != nil {
@ -458,3 +507,7 @@ func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOn
return (SectorPreCommitOnChainInfo)(v0) return (SectorPreCommitOnChainInfo)(v0)
{{end}} {{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 return &out, nil
} }
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = miner0.State{}
return &out, nil
}
type state0 struct { type state0 struct {
miner0.State miner0.State
store adt.Store store adt.Store
@ -242,6 +248,10 @@ func (s *state0) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num)) 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) { func (s *state0) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store) dls, err := s.State.LoadDeadlines(s.store)
if err != nil { if err != nil {
@ -363,6 +373,13 @@ func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV0SectorPreCommitOnChainInfo(sp), nil 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) { func (d *deadline0) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx) p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil { if err != nil {
@ -426,3 +443,7 @@ func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) Sect
return (SectorPreCommitOnChainInfo)(v0) 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 return &out, nil
} }
func make2(store adt.Store) (State, error) {
out := state2{store: store}
out.State = miner2.State{}
return &out, nil
}
type state2 struct { type state2 struct {
miner2.State miner2.State
store adt.Store store adt.Store
@ -240,6 +246,10 @@ func (s *state2) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num)) 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) { func (s *state2) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store) dls, err := s.State.LoadDeadlines(s.store)
if err != nil { if err != nil {
@ -361,6 +371,43 @@ func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV2SectorPreCommitOnChainInfo(sp), nil 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) { func (d *deadline2) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx) p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil { 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 return &out, nil
} }
func make3(store adt.Store) (State, error) {
out := state3{store: store}
out.State = miner3.State{}
return &out, nil
}
type state3 struct { type state3 struct {
miner3.State miner3.State
store adt.Store store adt.Store
@ -242,6 +248,10 @@ func (s *state3) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num)) 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) { func (s *state3) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store) dls, err := s.State.LoadDeadlines(s.store)
if err != nil { if err != nil {
@ -358,6 +368,43 @@ func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV3SectorPreCommitOnChainInfo(sp), nil 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) { func (d *deadline3) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx) p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil { 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 return &out, nil
} }
func make4(store adt.Store) (State, error) {
out := state4{store: store}
out.State = miner4.State{}
return &out, nil
}
type state4 struct { type state4 struct {
miner4.State miner4.State
store adt.Store store adt.Store
@ -242,6 +248,10 @@ func (s *state4) IsAllocated(num abi.SectorNumber) (bool, error) {
return allocatedSectors.IsSet(uint64(num)) 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) { func (s *state4) LoadDeadline(idx uint64) (Deadline, error) {
dls, err := s.State.LoadDeadlines(s.store) dls, err := s.State.LoadDeadlines(s.store)
if err != nil { if err != nil {
@ -358,6 +368,43 @@ func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreC
return fromV4SectorPreCommitOnChainInfo(sp), nil 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) { func (d *deadline4) LoadPartition(idx uint64) (Partition, error) {
p, err := d.Deadline.LoadPartition(d.store, idx) p, err := d.Deadline.LoadPartition(d.store, idx)
if err != nil { 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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -55,6 +76,7 @@ type State interface {
transactions() (adt.Map, error) transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error) decodeTransaction(val *cbg.Deferred) (Transaction, error)
GetState() interface{}
} }
type Transaction = msig{{.latestVersion}}.Transaction type Transaction = msig{{.latestVersion}}.Transaction

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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -81,6 +120,7 @@ type State interface {
transactions() (adt.Map, error) transactions() (adt.Map, error)
decodeTransaction(val *cbg.Deferred) (Transaction, error) decodeTransaction(val *cbg.Deferred) (Transaction, error)
GetState() interface{}
} }
type Transaction = msig4.Transaction type Transaction = msig4.Transaction

View File

@ -31,6 +31,32 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil 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 { type state{{.v}} struct {
msig{{.v}}.State msig{{.v}}.State
store adt.Store store adt.Store
@ -95,3 +121,7 @@ func (s *state{{.v}}) decodeTransaction(val *cbg.Deferred) (Transaction, error)
} }
return tx, nil 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 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 { type state0 struct {
msig0.State msig0.State
store adt.Store store adt.Store
@ -92,3 +111,7 @@ func (s *state0) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
} }
return tx, nil 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 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 { type state2 struct {
msig2.State msig2.State
store adt.Store store adt.Store
@ -92,3 +111,7 @@ func (s *state2) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
} }
return tx, nil 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 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 { type state3 struct {
msig3.State msig3.State
store adt.Store store adt.Store
@ -94,3 +113,7 @@ func (s *state3) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
} }
return tx, nil 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 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 { type state4 struct {
msig4.State msig4.State
store adt.Store store adt.Store
@ -94,3 +113,7 @@ func (s *state4) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
} }
return tx, nil 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) 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 // State is an abstract version of payment channel state that works across
// versions // versions
type State interface { type State interface {
@ -62,6 +83,8 @@ type State interface {
// Iterate lane states // Iterate lane states
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
GetState() interface{}
} }
// LaneState is an abstract copy of the state of a single lane // LaneState is an abstract copy of the state of a single lane

View File

@ -17,6 +17,10 @@ type mockState struct {
lanes map[uint64]paych.LaneState lanes map[uint64]paych.LaneState
} }
func (ms *mockState) GetState() interface{} {
panic("implement me")
}
type mockLaneState struct { type mockLaneState struct {
redeemed big.Int redeemed big.Int
nonce uint64 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) 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 // State is an abstract version of payment channel state that works across
// versions // versions
type State interface { type State interface {
@ -88,6 +127,8 @@ type State interface {
// Iterate lane states // Iterate lane states
ForEachLaneState(cb func(idx uint64, dl LaneState) error) error ForEachLaneState(cb func(idx uint64, dl LaneState) error) error
GetState() interface{}
} }
// LaneState is an abstract copy of the state of a single lane // 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 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 { type state{{.v}} struct {
paych{{.v}}.State paych{{.v}}.State
store adt.Store store adt.Store
@ -74,6 +80,10 @@ func (s *state{{.v}}) LaneCount() (uint64, error) {
return lsamt.Length(), nil return lsamt.Length(), nil
} }
func (s *state{{.v}}) GetState() interface{} {
return &s.State
}
// Iterate lane states // Iterate lane states
func (s *state{{.v}}) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { func (s *state{{.v}}) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain // 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 return &out, nil
} }
func make0(store adt.Store) (State, error) {
out := state0{store: store}
out.State = paych0.State{}
return &out, nil
}
type state0 struct { type state0 struct {
paych0.State paych0.State
store adt.Store store adt.Store
@ -74,6 +80,10 @@ func (s *state0) LaneCount() (uint64, error) {
return lsamt.Length(), nil return lsamt.Length(), nil
} }
func (s *state0) GetState() interface{} {
return &s.State
}
// Iterate lane states // Iterate lane states
func (s *state0) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { func (s *state0) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain // 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 return &out, nil
} }
func make2(store adt.Store) (State, error) {
out := state2{store: store}
out.State = paych2.State{}
return &out, nil
}
type state2 struct { type state2 struct {
paych2.State paych2.State
store adt.Store store adt.Store
@ -74,6 +80,10 @@ func (s *state2) LaneCount() (uint64, error) {
return lsamt.Length(), nil return lsamt.Length(), nil
} }
func (s *state2) GetState() interface{} {
return &s.State
}
// Iterate lane states // Iterate lane states
func (s *state2) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { func (s *state2) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain // 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 return &out, nil
} }
func make3(store adt.Store) (State, error) {
out := state3{store: store}
out.State = paych3.State{}
return &out, nil
}
type state3 struct { type state3 struct {
paych3.State paych3.State
store adt.Store store adt.Store
@ -74,6 +80,10 @@ func (s *state3) LaneCount() (uint64, error) {
return lsamt.Length(), nil return lsamt.Length(), nil
} }
func (s *state3) GetState() interface{} {
return &s.State
}
// Iterate lane states // Iterate lane states
func (s *state3) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { func (s *state3) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain // 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 return &out, nil
} }
func make4(store adt.Store) (State, error) {
out := state4{store: store}
out.State = paych4.State{}
return &out, nil
}
type state4 struct { type state4 struct {
paych4.State paych4.State
store adt.Store store adt.Store
@ -74,6 +80,10 @@ func (s *state4) LaneCount() (uint64, error) {
return lsamt.Length(), nil return lsamt.Length(), nil
} }
func (s *state4) GetState() interface{} {
return &s.State
}
// Iterate lane states // Iterate lane states
func (s *state4) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error { func (s *state4) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
// Get the lane state from the chain // Get the lane state from the chain

View File

@ -3,6 +3,7 @@ package power
import ( import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -47,6 +69,7 @@ type State interface {
TotalPower() (Claim, error) TotalPower() (Claim, error)
TotalCommitted() (Claim, error) TotalCommitted() (Claim, error)
TotalPowerSmoothed() (builtin.FilterEstimate, error) TotalPowerSmoothed() (builtin.FilterEstimate, error)
GetState() interface{}
// MinerCounts returns the number of miners. Participating is the number // MinerCounts returns the number of miners. Participating is the number
// with power above the minimum miner threshold. // with power above the minimum miner threshold.
@ -57,6 +80,12 @@ type State interface {
ForEachClaim(func(miner address.Address, claim Claim) error) error ForEachClaim(func(miner address.Address, claim Claim) error) error
ClaimsChanged(State) (bool, 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. // Diff helpers. Used by Diff* functions internally.
claims() (adt.Map, error) claims() (adt.Map, error)
decodeClaim(*cbg.Deferred) (Claim, error) decodeClaim(*cbg.Deferred) (Claim, error)

View File

@ -3,6 +3,7 @@ package power
import ( import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -73,6 +113,7 @@ type State interface {
TotalPower() (Claim, error) TotalPower() (Claim, error)
TotalCommitted() (Claim, error) TotalCommitted() (Claim, error)
TotalPowerSmoothed() (builtin.FilterEstimate, error) TotalPowerSmoothed() (builtin.FilterEstimate, error)
GetState() interface{}
// MinerCounts returns the number of miners. Participating is the number // MinerCounts returns the number of miners. Participating is the number
// with power above the minimum miner threshold. // with power above the minimum miner threshold.
@ -83,6 +124,12 @@ type State interface {
ForEachClaim(func(miner address.Address, claim Claim) error) error ForEachClaim(func(miner address.Address, claim Claim) error) error
ClaimsChanged(State) (bool, 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. // Diff helpers. Used by Diff* functions internally.
claims() (adt.Map, error) claims() (adt.Map, error)
decodeClaim(*cbg.Deferred) (Claim, 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 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 { type state{{.v}} struct {
power{{.v}}.State power{{.v}}.State
store adt.Store store adt.Store
@ -131,6 +157,30 @@ func (s *state{{.v}}) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other{{.v}}.State.Claims), nil 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) { func (s *state{{.v}}) claims() (adt.Map, error) {
return adt{{.v}}.AsMap(s.store, s.Claims{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}}) return adt{{.v}}.AsMap(s.store, s.Claims{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
} }

View File

View File

@ -26,6 +26,24 @@ func load0(store adt.Store, root cid.Cid) (State, error) {
return &out, nil 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 { type state0 struct {
power0.State power0.State
store adt.Store store adt.Store
@ -128,6 +146,30 @@ func (s *state0) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other0.State.Claims), nil 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) { func (s *state0) claims() (adt.Map, error) {
return adt0.AsMap(s.store, s.Claims) 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 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 { type state2 struct {
power2.State power2.State
store adt.Store store adt.Store
@ -128,6 +146,30 @@ func (s *state2) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other2.State.Claims), nil 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) { func (s *state2) claims() (adt.Map, error) {
return adt2.AsMap(s.store, s.Claims) 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 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 { type state3 struct {
power3.State power3.State
store adt.Store store adt.Store
@ -130,6 +143,30 @@ func (s *state3) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other3.State.Claims), nil 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) { func (s *state3) claims() (adt.Map, error) {
return adt3.AsMap(s.store, s.Claims, builtin3.DefaultHamtBitwidth) 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 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 { type state4 struct {
power4.State power4.State
store adt.Store store adt.Store
@ -130,6 +143,30 @@ func (s *state4) ClaimsChanged(other State) (bool, error) {
return !s.State.Claims.Equals(other4.State.Claims), nil 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) { func (s *state4) claims() (adt.Map, error) {
return adt4.AsMap(s.store, s.Claims, builtin4.DefaultHamtBitwidth) return adt4.AsMap(s.store, s.Claims, builtin4.DefaultHamtBitwidth)
} }

View File

@ -4,6 +4,7 @@ import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/cbor" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -55,6 +77,7 @@ type State interface {
InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error) InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error)
PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error) PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error)
GetState() interface{}
} }
type AwardBlockRewardParams = reward0.AwardBlockRewardParams type AwardBlockRewardParams = reward0.AwardBlockRewardParams

View File

@ -2,6 +2,7 @@ package reward
import ( import (
"github.com/filecoin-project/go-state-types/abi" "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" reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"golang.org/x/xerrors" "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) 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 { type State interface {
cbor.Marshaler cbor.Marshaler
@ -81,6 +121,7 @@ type State interface {
InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error) InitialPledgeForPower(abi.StoragePower, abi.TokenAmount, *builtin.FilterEstimate, abi.TokenAmount) (abi.TokenAmount, error)
PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error) PreCommitDepositForPower(builtin.FilterEstimate, abi.StoragePower) (abi.TokenAmount, error)
GetState() interface{}
} }
type AwardBlockRewardParams = reward0.AwardBlockRewardParams type AwardBlockRewardParams = reward0.AwardBlockRewardParams

View File

@ -23,6 +23,12 @@ func load{{.v}}(store adt.Store, root cid.Cid) (State, error) {
return &out, nil 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 { type state{{.v}} struct {
reward{{.v}}.State reward{{.v}}.State
store adt.Store store adt.Store
@ -101,3 +107,7 @@ func (s *state{{.v}}) PreCommitDepositForPower(networkQAPower builtin.FilterEsti
}, },
sectorWeight), nil 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 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 { type state0 struct {
reward0.State reward0.State
store adt.Store store adt.Store
@ -83,3 +89,7 @@ func (s *state0) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
}, },
sectorWeight), nil 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 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 { type state2 struct {
reward2.State reward2.State
store adt.Store store adt.Store
@ -86,3 +92,7 @@ func (s *state2) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
}, },
sectorWeight), nil 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 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 { type state3 struct {
reward3.State reward3.State
store adt.Store store adt.Store
@ -86,3 +92,7 @@ func (s *state3) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
}, },
sectorWeight), nil 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 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 { type state4 struct {
reward4.State reward4.State
store adt.Store store adt.Store
@ -86,3 +92,7 @@ func (s *state4) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate,
}, },
sectorWeight), nil 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{}
}

View File

View File

@ -0,0 +1,35 @@
package system
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
system0 "github.com/filecoin-project/specs-actors/actors/builtin/system"
)
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 = system0.State{}
return &out, nil
}
type state0 struct {
system0.State
store adt.Store
}
func (s *state0) GetState() interface{} {
return &s.State
}

View File

@ -0,0 +1,35 @@
package system
import (
"github.com/ipfs/go-cid"
"github.com/filecoin-project/lotus/chain/actors/adt"
system2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/system"
)
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 = system2.State{}
return &out, nil
}
type state2 struct {
system2.State
store adt.Store
}
func (s *state2) GetState() interface{} {
return &s.State
}

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