Merge branch 'main' into btrfly-calib-all-in-one
This commit is contained in:
commit
e8d769a574
@ -7,7 +7,7 @@ executors:
|
||||
golang:
|
||||
docker:
|
||||
# Must match GO_VERSION_MIN in project root
|
||||
- image: cimg/go:1.18.1
|
||||
- image: cimg/go:1.18.8
|
||||
resource_class: 2xlarge
|
||||
ubuntu:
|
||||
docker:
|
||||
@ -1073,8 +1073,6 @@ workflows:
|
||||
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
|
||||
- release:
|
||||
name: "Release"
|
||||
context:
|
||||
- filecoin-goreleaser-key
|
||||
requires:
|
||||
- "Build ( darwin / amd64 )"
|
||||
- "Build ( linux / amd64 )"
|
||||
@ -1088,8 +1086,6 @@ workflows:
|
||||
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
|
||||
- release:
|
||||
name: "Release (dry-run)"
|
||||
context:
|
||||
- filecoin-goreleaser-key
|
||||
dry-run: true
|
||||
requires:
|
||||
- "Build ( darwin / amd64 )"
|
||||
|
@ -7,7 +7,7 @@ executors:
|
||||
golang:
|
||||
docker:
|
||||
# Must match GO_VERSION_MIN in project root
|
||||
- image: cimg/go:1.18.1
|
||||
- image: cimg/go:1.18.8
|
||||
resource_class: 2xlarge
|
||||
ubuntu:
|
||||
docker:
|
||||
@ -758,8 +758,6 @@ workflows:
|
||||
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
|
||||
- release:
|
||||
name: "Release"
|
||||
context:
|
||||
- filecoin-goreleaser-key
|
||||
requires:
|
||||
- "Build ( darwin / amd64 )"
|
||||
- "Build ( linux / amd64 )"
|
||||
@ -773,8 +771,6 @@ workflows:
|
||||
- /^v\d+\.\d+\.\d+(-rc\d+)?$/
|
||||
- release:
|
||||
name: "Release (dry-run)"
|
||||
context:
|
||||
- filecoin-goreleaser-key
|
||||
dry-run: true
|
||||
requires:
|
||||
- "Build ( darwin / amd64 )"
|
||||
|
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.18.1'
|
||||
go-version: '1.18.8'
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
|
@ -1,5 +1,5 @@
|
||||
#####################################
|
||||
FROM golang:1.18.1-buster AS lotus-builder
|
||||
FROM golang:1.18.8-buster AS lotus-builder
|
||||
MAINTAINER Lotus Development Team
|
||||
|
||||
RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev
|
||||
|
@ -1,6 +1,6 @@
|
||||
##### DEPRECATED
|
||||
|
||||
FROM golang:1.18.1-buster AS builder-deps
|
||||
FROM golang:1.18.8-buster AS builder-deps
|
||||
MAINTAINER Lotus Development Team
|
||||
|
||||
RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev
|
||||
|
@ -1 +1 @@
|
||||
1.18.1
|
||||
1.18.8
|
||||
|
@ -10,7 +10,7 @@
|
||||
<a href="https://circleci.com/gh/filecoin-project/lotus"><img src="https://circleci.com/gh/filecoin-project/lotus.svg?style=svg"></a>
|
||||
<a href="https://codecov.io/gh/filecoin-project/lotus"><img src="https://codecov.io/gh/filecoin-project/lotus/branch/master/graph/badge.svg"></a>
|
||||
<a href="https://goreportcard.com/report/github.com/filecoin-project/lotus"><img src="https://goreportcard.com/badge/github.com/filecoin-project/lotus" /></a>
|
||||
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.18.1-blue.svg" /></a>
|
||||
<a href=""><img src="https://img.shields.io/badge/golang-%3E%3D1.18.8-blue.svg" /></a>
|
||||
<br>
|
||||
</p>
|
||||
|
||||
@ -71,10 +71,10 @@ For other distributions you can find the required dependencies [here.](https://l
|
||||
|
||||
#### Go
|
||||
|
||||
To build Lotus, you need a working installation of [Go 1.18.1 or higher](https://golang.org/dl/):
|
||||
To build Lotus, you need a working installation of [Go 1.18.8 or higher](https://golang.org/dl/):
|
||||
|
||||
```bash
|
||||
wget -c https://golang.org/dl/go1.18.1.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
|
||||
wget -c https://golang.org/dl/go1.18.8.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
|
||||
```
|
||||
|
||||
**TIP:**
|
||||
|
@ -24,6 +24,8 @@ import (
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/protocol"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
@ -456,7 +458,8 @@ func exampleStruct(method string, t, parent reflect.Type) interface{} {
|
||||
if f.Type == parent {
|
||||
continue
|
||||
}
|
||||
if strings.Title(f.Name) == f.Name {
|
||||
caser := cases.Title(language.English)
|
||||
if caser.String(f.Name) == f.Name {
|
||||
ns.Elem().Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
|
||||
}
|
||||
}
|
||||
|
@ -2394,10 +2394,10 @@ func (mr *MockFullNodeMockRecorder) StateCall(arg0, arg1, arg2 interface{}) *gom
|
||||
}
|
||||
|
||||
// StateChangedActors mocks base method.
|
||||
func (m *MockFullNode) StateChangedActors(arg0 context.Context, arg1, arg2 cid.Cid) (map[string]types.Actor, error) {
|
||||
func (m *MockFullNode) StateChangedActors(arg0 context.Context, arg1, arg2 cid.Cid) (map[string]types.ActorV5, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateChangedActors", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(map[string]types.Actor)
|
||||
ret0, _ := ret[0].(map[string]types.ActorV5)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -2499,10 +2499,10 @@ func (mr *MockFullNodeMockRecorder) StateEncodeParams(arg0, arg1, arg2, arg3 int
|
||||
}
|
||||
|
||||
// StateGetActor mocks base method.
|
||||
func (m *MockFullNode) StateGetActor(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (*types.Actor, error) {
|
||||
func (m *MockFullNode) StateGetActor(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (*types.ActorV5, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateGetActor", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*types.Actor)
|
||||
ret0, _ := ret[0].(*types.ActorV5)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
@ -2249,10 +2249,10 @@ func (mr *MockFullNodeMockRecorder) StateCall(arg0, arg1, arg2 interface{}) *gom
|
||||
}
|
||||
|
||||
// StateChangedActors mocks base method.
|
||||
func (m *MockFullNode) StateChangedActors(arg0 context.Context, arg1, arg2 cid.Cid) (map[string]types.Actor, error) {
|
||||
func (m *MockFullNode) StateChangedActors(arg0 context.Context, arg1, arg2 cid.Cid) (map[string]types.ActorV5, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateChangedActors", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(map[string]types.Actor)
|
||||
ret0, _ := ret[0].(map[string]types.ActorV5)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -2324,10 +2324,10 @@ func (mr *MockFullNodeMockRecorder) StateDecodeParams(arg0, arg1, arg2, arg3, ar
|
||||
}
|
||||
|
||||
// StateGetActor mocks base method.
|
||||
func (m *MockFullNode) StateGetActor(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (*types.Actor, error) {
|
||||
func (m *MockFullNode) StateGetActor(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (*types.ActorV5, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateGetActor", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*types.Actor)
|
||||
ret0, _ := ret[0].(*types.ActorV5)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
BIN
build/actors/v10.tar.zst
Normal file
BIN
build/actors/v10.tar.zst
Normal file
Binary file not shown.
@ -41,6 +41,27 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzacedylltr57b2n6zpadh4i2c2kis4fzzvhao3kgvfaggrrbqyacew7q"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacecjkesz766626ab4svnzpq3jfs26a75vfktlfaku5fjdao2eyiqyq"),
|
||||
},
|
||||
}, {
|
||||
Network: "butterflynet",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzacedrip7ekfxytqyx2dj5ggg7itm6w3lywgqsfs4lr4hlcrve6vgiqc"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzacebui5xw2dlftdkdo7lalrcjceohc6xpqnmmyrtdhsihi555c34w3m"),
|
||||
"cron": MustParseCid("bafk2bzacea7kk5jbwcl3hmy7lmuoswj2vwvm7enbibt4hwxoqdla7yuoqn3hy"),
|
||||
"datacap": MustParseCid("bafk2bzacebnhnt3tubzngnzmlgxrfbjaf6dcsijplaz5nbdzye75fexdlpndq"),
|
||||
"eam": MustParseCid("bafk2bzaceb5tc576ogvaafng6wm5qt5vonyha6dcfzyieu7zsaseulo6hogka"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzaceaxcgbhb2smi7yp7vjdqcclxc3iuma4rharhuavpwzgqxnhx6plss"),
|
||||
"init": MustParseCid("bafk2bzaceddlj7vpdmsjhpafxfb3ltgwgzlckcss6khxllwiwwu5ml3d46pga"),
|
||||
"multisig": MustParseCid("bafk2bzacecxryfy3nips4lmoehiim2gbhm5brxdeefslbenlhg2tix3rpkpnc"),
|
||||
"paymentchannel": MustParseCid("bafk2bzacedu3xgcuftzf5xthcbwm55sd5rp4ptc2ulwciw56jajfy54kswiw6"),
|
||||
"reward": MustParseCid("bafk2bzacedoojima37co6gllv35osnewurtycv6yudvjq2cgdwavll7sn6gbc"),
|
||||
"storagemarket": MustParseCid("bafk2bzacedvtynnpaxuyunegh3x3cql3sidflwkjtrxkkaqcukdrmdox7xziw"),
|
||||
"storageminer": MustParseCid("bafk2bzacednwhb2l4xth5tqgtmftybaj52rpehidesp2xjg7xbi7u62dgst6g"),
|
||||
"storagepower": MustParseCid("bafk2bzacebx5cu7mkxiqxcwht3j45yd3mrstcvncpipgrqv2velnwpzkrcvzs"),
|
||||
"system": MustParseCid("bafk2bzacedigfwdw7pjmmvsyzo2vajmfa53ctyp2yz35hsd5c63h4xrxskmmq"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacedfq3vluteepuco72n6f7jlp6sbfsstpecjhukiou6g4jivrtkvx2"),
|
||||
},
|
||||
}, {
|
||||
Network: "calibrationnet",
|
||||
Version: 8,
|
||||
@ -76,6 +97,27 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzaceaue3nzucbom3tcclgyaahy3iwvbqejsxrohiquakvvsjgbw3shac"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacebh7dj6j7yi5vadh7lgqjtq42qi2uq4n6zy2g5vjeathacwn2tscu"),
|
||||
},
|
||||
}, {
|
||||
Network: "calibrationnet",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzacebenfsnosatbwn2vskkduv5dd4fclymp3szy5rudwjjnpacjwgabw"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzacebvkqmplmi4qta56c3o7xenxfnh52ubcru4oqaavx2mel6h7f3r26"),
|
||||
"cron": MustParseCid("bafk2bzaceddqlwubzbrhdnkvgzoo6jinmn35qqnh4vtmkxhhnqmvoy7z3ovm4"),
|
||||
"datacap": MustParseCid("bafk2bzacedce7wj2kdujhvo55bfqwxup4gccdahvxpxtn4oqand67cnm7oaes"),
|
||||
"eam": MustParseCid("bafk2bzacebvs75jzsh74vs43i5ve4ikbiy4h2sbg7fbqiv53lybwufhk6gntc"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzacebni52v7johlrrvfagunysb5b7ssruapbuw3lkw4raavhrf5dbjy2"),
|
||||
"init": MustParseCid("bafk2bzacebdjvjkidqczhk2dfmmfastxihuru7qssdsegxibx2u6zsmwxbr6y"),
|
||||
"multisig": MustParseCid("bafk2bzacea53zxqqchdykxyklsuuxr2nxavzym5prtw5jrnarrjldttcqxluo"),
|
||||
"paymentchannel": MustParseCid("bafk2bzaceck54j7jukcc22ubrzf4yyiaxz6p5hmwkxqgzvevsn7x5nrpghxf4"),
|
||||
"reward": MustParseCid("bafk2bzacedlh4i2phmiqfbfl2zyajpzaigbgqp3fcdwtphststpap6e3pe2xg"),
|
||||
"storagemarket": MustParseCid("bafk2bzacednr26koccefqs3pkab4e3bu7g2hxtwodrqaidj7lmxtaj4l4qbyw"),
|
||||
"storageminer": MustParseCid("bafk2bzaceb2vgdzj7ydnhfr4exyat2aiuigglhwqv7pu5p65l5syankhjbaeo"),
|
||||
"storagepower": MustParseCid("bafk2bzacedbqdw62m5fah32bkvns2ubz32lgqu4fngp77aezzm3af7b6vmvsu"),
|
||||
"system": MustParseCid("bafk2bzaceazgpbdm5nzg35jwmt6s4nqgy5ok2ne3ndhomkq6erits4l2ruyac"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacebs7l5v7b74fy5eqkmcdccbkjqpxykn6au34p4si7m2hc3utrpwhq"),
|
||||
},
|
||||
}, {
|
||||
Network: "caterpillarnet",
|
||||
Version: 8,
|
||||
@ -111,6 +153,27 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzacecisuqj2ln7ep72xaejvs2lrgh2logc7retxxpd3qvobymwyz7bxo"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacebyjosiripwqyf56yhjfs5hg26mch7totsqth4rgpt5j32hqg6ric"),
|
||||
},
|
||||
}, {
|
||||
Network: "caterpillarnet",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzacecprcdvekabbiozu6jaferly4jpw4uxoxy55ouioopv2uhsyfnatg"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzaceasuszw5iqejn3afhc2oftpmnhgwg5gt7d3fryfi3pzyuv4vaifzq"),
|
||||
"cron": MustParseCid("bafk2bzaceadt6coa6p7cgwt7k7sz7hafpy3ilma4q4obghn6xsywjedar43om"),
|
||||
"datacap": MustParseCid("bafk2bzacec3hswe3wucjxlqavck4ijdto65gwuzlqlhstpj22icx3xgy6y25m"),
|
||||
"eam": MustParseCid("bafk2bzaceb52bwd7ikj7dnpeebaak2aaoeqdp6sm5n3qu75gyhym7o7sa64oo"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzacecw44r27pmmurhlkf5vqnqjxpivnh5oopegonnl2o7rtu3wyc4h4s"),
|
||||
"init": MustParseCid("bafk2bzaceb2hcbworiltqg5227d6xcuhypgd2x2olsnqdk5ung5rzps5hze4y"),
|
||||
"multisig": MustParseCid("bafk2bzacecwcqghlxf76d5a6uwn65ryb4ogrgktlfb6pc2625v5uznnz5sshc"),
|
||||
"paymentchannel": MustParseCid("bafk2bzacebk5bxknqhlsrvgdnleflwpmkc25hfx4zrqxasszo3ktkkvp7w6oo"),
|
||||
"reward": MustParseCid("bafk2bzacebdl4woa2et6x2cg2gnw3zpx3a6jhuw3xnkcy4vjhu2zsd52cpgbc"),
|
||||
"storagemarket": MustParseCid("bafk2bzacectrnbmdzux4ktjezov2eghyf4b6khne5bbx57fbw4ubdrplpkesi"),
|
||||
"storageminer": MustParseCid("bafk2bzacebzwofvflpycvpl2oikql3o4gcd2alhoa7vtz4crj34ioegzl6h7i"),
|
||||
"storagepower": MustParseCid("bafk2bzaced7p4fzea2j4hs2cz52uxtxy2pie4avjs5hsdrjwxas2d247v645c"),
|
||||
"system": MustParseCid("bafk2bzacea4nhoud6kwlrnayplpwfwlo5jlqqplu3gj5kp5e3i3pxzwzdmakq"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacecuz22dwb56p4z67fyqsb4qfw3qk3lz6tq5kc3lsxuo7znlbjczqu"),
|
||||
},
|
||||
}, {
|
||||
Network: "devnet",
|
||||
Version: 8,
|
||||
@ -146,6 +209,27 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzacebgafb6h2o2g5whrujc2uvsttrussyc5t56rvhrjqkqhzdu4jopwa"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacednorhcy446agy7ecpmfms2u4aoa3mj2eqomffuoerbik5yavrxyi"),
|
||||
},
|
||||
}, {
|
||||
Network: "devnet",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzacecwysahkxh4jgpmby7lboxalqv2fbvoohi4tcf6unllzwlrgb6n3u"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzacecui4vegcaloi3dt2rob6dytzr7iag257jfszwdtvqgcun6vi2ggi"),
|
||||
"cron": MustParseCid("bafk2bzacedukjjklhrahhnbwqcbe3ppowu6cdd3ev2ncsynjg63ese36zg5es"),
|
||||
"datacap": MustParseCid("bafk2bzaceaucxyfovggh3hn3iwfqm45z2wxovyasp47ji6vhwv4zlfmtcfg3s"),
|
||||
"eam": MustParseCid("bafk2bzaceazgazurwhvwoj4evuxmw5sd2bje2dr4kvyklunlapvw7kyhpzn46"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzaceam256namf22qqvbj4owo6jhsz5ai2lv6bgp2cqe6mqpyklzl4v2c"),
|
||||
"init": MustParseCid("bafk2bzacecwy6qxelpbblzgq5ehzqjfe2k47olme3a2kmegth6qsyvykxyfui"),
|
||||
"multisig": MustParseCid("bafk2bzaceab6p4qg2jmqdylrgcam5u4md3ho7wiigxtnrj7h5qwplvuhe3qm2"),
|
||||
"paymentchannel": MustParseCid("bafk2bzaceda4axurklqhlb3w3t2skgqj2xqi66cdufcdkgsl5v3f6qdvp7neg"),
|
||||
"reward": MustParseCid("bafk2bzaceax2wjon7qzsfha3cm3w2cl6rplwxg4onhyvermyhmeu7gubzdcha"),
|
||||
"storagemarket": MustParseCid("bafk2bzacechmh6ufrhsodqxt2kf5kys2e7mtzom73l6qqemrebsatxxzvfkfy"),
|
||||
"storageminer": MustParseCid("bafk2bzacebvtukozkvkmcj74o3wvozvi5iese5ijmhjd7u73aqcp55oc3z2tq"),
|
||||
"storagepower": MustParseCid("bafk2bzaceaun3ipavgb3axpt7zjkkfserw6rhnorpvoicqihdmsyxuhymv6mq"),
|
||||
"system": MustParseCid("bafk2bzacecrpokwc27mww4zf3l7kaxe2m6sgbzuuvouzzpkk7uh5ax4ufrx2w"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacecnbhvtkipjzczzwekkgmohikkeftconlvpdqkmuxrke24eb7trzq"),
|
||||
},
|
||||
}, {
|
||||
Network: "mainnet",
|
||||
Version: 8,
|
||||
@ -181,6 +265,27 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzaceagvlo2jtahj7dloshrmwfulrd6e2izqev32qm46eumf754weec6c"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacecf3yodlyudzukumehbuabgqljyhjt5ifiv4vetcfohnvsxzynwga"),
|
||||
},
|
||||
}, {
|
||||
Network: "mainnet",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzaceb2ssutz56smwc6vwigjgo2kfqirnwkwq7zthxscynvtzn7ebywt4"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzacea34fwixc5x473laalyitolzttxxus5ulxi2ukylsubhrl2m32zhc"),
|
||||
"cron": MustParseCid("bafk2bzacebxkofxwtkzmncfb77slj4hvwlhazb2x7li7gbdhfbh3gxdmud2eq"),
|
||||
"datacap": MustParseCid("bafk2bzaceac4u53w2fwsez4fmk5to4u5f6tls2obsutsep24nswiclqme75uy"),
|
||||
"eam": MustParseCid("bafk2bzaced25owr5v4k4ypzm5qxi7c3juobbudekogapqaqia23chcyo43ofu"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzacechckrenio2m67kvacfbzmpm2uosnrw5zmrzsj4b6cukwmhpjfg6c"),
|
||||
"init": MustParseCid("bafk2bzaceblbm5moflcetob6wbl3tjbi2zhyangfrmp4jux7wyeixi7ptctu6"),
|
||||
"multisig": MustParseCid("bafk2bzaceadileikmkovoi4ewl4jbyjgnntl7rqsqlxs2plj2ruv776qxp5hq"),
|
||||
"paymentchannel": MustParseCid("bafk2bzaceasjtgnksm3infcphwhyg675hip3t65q3pzknatf6aqb3mi57pj2c"),
|
||||
"reward": MustParseCid("bafk2bzacecozr3gal2ywayykdgrhjbttqvwktptyvlvph6dunqrlp2rnl5rbq"),
|
||||
"storagemarket": MustParseCid("bafk2bzacedv5grgmgmoxjvvrszb4phdnhzvlsjv6g3ugirjhgghfuncc67zvu"),
|
||||
"storageminer": MustParseCid("bafk2bzaceb7wvvvx6dduzodqanerefg5q6k2qvbrlzcbhal5yjhkzun64vtvk"),
|
||||
"storagepower": MustParseCid("bafk2bzacecauoq7xxccmc3hrbbsktonlivg7pibysrnplelsvgdzpzpryv6mm"),
|
||||
"system": MustParseCid("bafk2bzaceapfdn6eteiqvvhape3iyybobhcyg6lbmncmerhcpckcj444uk6qo"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacec4v5cozakcgq5btelyjz6hkmcmftj35a2qvcjfcynb6hw4ifxbeq"),
|
||||
},
|
||||
}, {
|
||||
Network: "testing",
|
||||
Version: 8,
|
||||
@ -216,6 +321,27 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzacedo4pu3iwx2gu72hinsstpiokhl5iicnb3rumzffsnhy7zhmnxhyy"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzaceatmqip2o3ausbntvdhj7yemu6hb3b5yqv6hm42gylbbmz7geocpm"),
|
||||
},
|
||||
}, {
|
||||
Network: "testing",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzaceaxppo7nkcn456lgend7oqb4pcxdtvk4rw7xqu4qfxsg76hpgjzdm"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzacecasu6oljznrdqpljjomlstq3yf2c6jbofwn5eoivjkgnl65a52lq"),
|
||||
"cron": MustParseCid("bafk2bzacec535ytbuh2ycyjwyhnnyjz2jolzfzuny6kdyg6a4h6jtjwqfwfdo"),
|
||||
"datacap": MustParseCid("bafk2bzaceay7k6yf5ccms37l2pggjioffyklnzyz4b3sm6567k5dvetlpctfo"),
|
||||
"eam": MustParseCid("bafk2bzaceb5c32bdqtnpteri5okrwyg6m57vvcjqf5hggvhgqxgarpdski7e6"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzacedq6wp33m7oif4hgro52g4h2gdaxoymaic5js4cyyb5emqjfevi5k"),
|
||||
"init": MustParseCid("bafk2bzacedk5bo33m4bjhii6mc35wmth6sx36azjgc4qbus3q45rtsb4xwl26"),
|
||||
"multisig": MustParseCid("bafk2bzaceal376rbj6h6g3wlrs2kiik57ie7rcdb4jldzhd5i2vhq6lgsek3i"),
|
||||
"paymentchannel": MustParseCid("bafk2bzacec7nsh23sha54ete2jl4eupj2hz4rxzyp4wm4jfu466czhkg7vdwq"),
|
||||
"reward": MustParseCid("bafk2bzacecc4kkj7shrexyjb4bamnjlficb2hfnoqnmobcflx2bmzl4b5vqay"),
|
||||
"storagemarket": MustParseCid("bafk2bzaceat4aedqcvjb42nl2yotog462uy5brffvpnurrvxaghem4ppwdn3y"),
|
||||
"storageminer": MustParseCid("bafk2bzaceaeefkoaj7qpae6hivizqau6me4xdbajl2eny5hnexfbzqyooe4kg"),
|
||||
"storagepower": MustParseCid("bafk2bzacecgejk3gyjauoalkdbwaq5kfdx7nnlvkjh4yfa6g7a43332xc2ajm"),
|
||||
"system": MustParseCid("bafk2bzacebtg7ijnioa4xmscxvu6kk4mrnehfrddqgj4nqmj6f32nmvcc2ray"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacecvdxtzrbtrrgtgw6t3nxw3zsslzdz6dybefzti45qbrlvuwqqt3q"),
|
||||
},
|
||||
}, {
|
||||
Network: "testing-fake-proofs",
|
||||
Version: 8,
|
||||
@ -251,4 +377,25 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
|
||||
"system": MustParseCid("bafk2bzacedo4pu3iwx2gu72hinsstpiokhl5iicnb3rumzffsnhy7zhmnxhyy"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzaceatmqip2o3ausbntvdhj7yemu6hb3b5yqv6hm42gylbbmz7geocpm"),
|
||||
},
|
||||
}, {
|
||||
Network: "testing-fake-proofs",
|
||||
Version: 10,
|
||||
ManifestCid: MustParseCid("bafy2bzaceb2ablvyxqk2vjhwxq5f5ptat7xiv3euwshwruppxp6ui7b64tvbu"),
|
||||
Actors: map[string]cid.Cid{
|
||||
"account": MustParseCid("bafk2bzacecasu6oljznrdqpljjomlstq3yf2c6jbofwn5eoivjkgnl65a52lq"),
|
||||
"cron": MustParseCid("bafk2bzacec535ytbuh2ycyjwyhnnyjz2jolzfzuny6kdyg6a4h6jtjwqfwfdo"),
|
||||
"datacap": MustParseCid("bafk2bzaceay7k6yf5ccms37l2pggjioffyklnzyz4b3sm6567k5dvetlpctfo"),
|
||||
"eam": MustParseCid("bafk2bzaceb5c32bdqtnpteri5okrwyg6m57vvcjqf5hggvhgqxgarpdski7e6"),
|
||||
"embryo": MustParseCid("bafk2bzaceb5shyqwqsogg2izzfteoxcqji6pzqakuc3auvjo44uv5ndhaxt5i"),
|
||||
"evm": MustParseCid("bafk2bzacedq6wp33m7oif4hgro52g4h2gdaxoymaic5js4cyyb5emqjfevi5k"),
|
||||
"init": MustParseCid("bafk2bzacedk5bo33m4bjhii6mc35wmth6sx36azjgc4qbus3q45rtsb4xwl26"),
|
||||
"multisig": MustParseCid("bafk2bzaceal376rbj6h6g3wlrs2kiik57ie7rcdb4jldzhd5i2vhq6lgsek3i"),
|
||||
"paymentchannel": MustParseCid("bafk2bzacec7nsh23sha54ete2jl4eupj2hz4rxzyp4wm4jfu466czhkg7vdwq"),
|
||||
"reward": MustParseCid("bafk2bzacecc4kkj7shrexyjb4bamnjlficb2hfnoqnmobcflx2bmzl4b5vqay"),
|
||||
"storagemarket": MustParseCid("bafk2bzaceat4aedqcvjb42nl2yotog462uy5brffvpnurrvxaghem4ppwdn3y"),
|
||||
"storageminer": MustParseCid("bafk2bzacec4sgyamy6iobuxesdwkg3zwffkwxnur57tisfpotbbs6kammr4ds"),
|
||||
"storagepower": MustParseCid("bafk2bzacecqxuizz2wxujshjeh7rsric3fkwpa5mucizzamevdpafqewdtm4y"),
|
||||
"system": MustParseCid("bafk2bzacebtg7ijnioa4xmscxvu6kk4mrnehfrddqgj4nqmj6f32nmvcc2ray"),
|
||||
"verifiedregistry": MustParseCid("bafk2bzacecvdxtzrbtrrgtgw6t3nxw3zsslzdz6dybefzti45qbrlvuwqqt3q"),
|
||||
},
|
||||
}}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,7 +22,7 @@ const GenesisFile = ""
|
||||
var NetworkBundle = "devnet"
|
||||
var BundleOverrides map[actorstypes.Version]string
|
||||
|
||||
const GenesisNetworkVersion = network.Version16
|
||||
const GenesisNetworkVersion = network.Version18
|
||||
|
||||
var UpgradeBreezeHeight = abi.ChainEpoch(-1)
|
||||
|
||||
@ -56,7 +56,7 @@ var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
|
||||
|
||||
var UpgradeSkyrHeight = abi.ChainEpoch(-19)
|
||||
|
||||
var UpgradeSharkHeight = abi.ChainEpoch(100)
|
||||
var UpgradeSharkHeight = abi.ChainEpoch(-20)
|
||||
|
||||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
|
@ -33,7 +33,7 @@ const TestNetworkVersion = network.Version{{.latestNetworkVersion}}
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
const TestNetworkVersion = network.Version17
|
||||
const TestNetworkVersion = network.Version18
|
||||
|
||||
/* inline-gen end */
|
||||
|
||||
|
@ -28,6 +28,7 @@ var actors = map[string][]int{
|
||||
"reward": lotusactors.Versions,
|
||||
"verifreg": lotusactors.Versions,
|
||||
"datacap": lotusactors.Versions[8:],
|
||||
"evm": lotusactors.Versions[9:],
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var Methods = builtin9.MethodsAccount
|
||||
var Methods = builtin10.MethodsAccount
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
@ -37,6 +37,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,6 +101,9 @@ func MakeState(store adt.Store, av actorstypes.Version, addr address.Address) (S
|
||||
case actorstypes.Version9:
|
||||
return make9(store, addr)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, addr)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -124,5 +130,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
61
chain/actors/builtin/account/v10.go
generated
Normal file
61
chain/actors/builtin/account/v10.go
generated
Normal file
@ -0,0 +1,61 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
account10 "github.com/filecoin-project/go-state-types/builtin/v10/account"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, addr address.Address) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = account10.State{Address: addr}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
account10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) PubkeyAddress() (address.Address, error) {
|
||||
return s.Address, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.AccountKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -5,7 +5,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
|
||||
@ -33,6 +33,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,13 +97,16 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return make9(store)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin9.CronActorAddr
|
||||
Methods = builtin9.MethodsCron
|
||||
Address = builtin10.CronActorAddr
|
||||
Methods = builtin10.MethodsCron
|
||||
)
|
||||
|
||||
type State interface {
|
||||
@ -122,5 +128,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
56
chain/actors/builtin/cron/v10.go
generated
Normal file
56
chain/actors/builtin/cron/v10.go
generated
Normal file
@ -0,0 +1,56 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
cron10 "github.com/filecoin-project/go-state-types/builtin/v10/cron"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = *cron10.ConstructState(cron10.BuiltInEntries())
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
cron10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.CronKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -43,9 +43,8 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address
|
||||
{{range .versions}}
|
||||
case actorstypes.Version{{.}}:
|
||||
return make{{.}}(store, governor, bitwidth)
|
||||
|
||||
default: return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av)
|
||||
{{end}}
|
||||
default: return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
@ -16,8 +16,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin9.DatacapActorAddr
|
||||
Methods = builtin9.MethodsDatacap
|
||||
Address = builtin10.DatacapActorAddr
|
||||
Methods = builtin10.MethodsDatacap
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
@ -31,6 +31,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,9 +46,11 @@ func MakeState(store adt.Store, av actorstypes.Version, governor address.Address
|
||||
case actorstypes.Version9:
|
||||
return make9(store, governor, bitwidth)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, governor, bitwidth)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("datacap actor only valid for actors v9 and above, got %d", av)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,5 +70,6 @@ type State interface {
|
||||
func AllCodes() []cid.Cid {
|
||||
return []cid.Cid{
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
81
chain/actors/builtin/datacap/v10.go
generated
Normal file
81
chain/actors/builtin/datacap/v10.go
generated
Normal file
@ -0,0 +1,81 @@
|
||||
package datacap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
datacap10 "github.com/filecoin-project/go-state-types/builtin/v10/datacap"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, governor address.Address, bitwidth uint64) (State, error) {
|
||||
out := state10{store: store}
|
||||
s, err := datacap10.ConstructState(store, governor, bitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
datacap10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) Governor() (address.Address, error) {
|
||||
return s.State.Governor, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||
return forEachClient(s.store, actors.Version10, s.verifiedClients, cb)
|
||||
}
|
||||
|
||||
func (s *state10) verifiedClients() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.Token.Balances, int(s.Token.HamtBitWidth))
|
||||
}
|
||||
|
||||
func (s *state10) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||
return getDataCap(s.store, actors.Version10, s.verifiedClients, addr)
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.DatacapKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
51
chain/actors/builtin/evm/actor.go.template
Normal file
51
chain/actors/builtin/evm/actor.go.template
Normal file
@ -0,0 +1,51 @@
|
||||
package evm
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
|
||||
builtin{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin"
|
||||
)
|
||||
|
||||
var Methods = builtin{{.latestVersion}}.MethodsEVM
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != actors.EvmKey {
|
||||
return nil, xerrors.Errorf("actor code is not evm: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actorstypes.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
||||
func MakeState(store adt.Store, av actorstypes.Version, bytecode cid.Cid) (State, error) {
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actorstypes.Version{{.}}:
|
||||
return make{{.}}(store, bytecode)
|
||||
{{end}}
|
||||
default: return nil, xerrors.Errorf("evm actor only valid for actors v10 and above, got %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
type State interface {
|
||||
cbor.Marshaler
|
||||
|
||||
Nonce() (uint64, error)
|
||||
GetState() interface{}
|
||||
}
|
51
chain/actors/builtin/evm/evm.go
Normal file
51
chain/actors/builtin/evm/evm.go
Normal file
@ -0,0 +1,51 @@
|
||||
package evm
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var Methods = builtin10.MethodsEVM
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != actors.EvmKey {
|
||||
return nil, xerrors.Errorf("actor code is not evm: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
|
||||
func MakeState(store adt.Store, av actorstypes.Version, bytecode cid.Cid) (State, error) {
|
||||
switch av {
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, bytecode)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("evm actor only valid for actors v10 and above, got %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
type State interface {
|
||||
cbor.Marshaler
|
||||
|
||||
Nonce() (uint64, error)
|
||||
GetState() interface{}
|
||||
}
|
45
chain/actors/builtin/evm/state.go.template
Normal file
45
chain/actors/builtin/evm/state.go.template
Normal file
@ -0,0 +1,45 @@
|
||||
package evm
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
evm{{.v}} "github.com/filecoin-project/go-state-types/builtin{{.import}}evm"
|
||||
)
|
||||
|
||||
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, bytecode cid.Cid) (State, error) {
|
||||
out := state{{.v}}{store: store}
|
||||
s, err := evm{{.v}}.ConstructState(store, bytecode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state{{.v}} struct {
|
||||
evm{{.v}}.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) Nonce() (uint64, error) {
|
||||
return s.State.Nonce, nil
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
45
chain/actors/builtin/evm/v10.go
generated
Normal file
45
chain/actors/builtin/evm/v10.go
generated
Normal file
@ -0,0 +1,45 @@
|
||||
package evm
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
evm10 "github.com/filecoin-project/go-state-types/builtin/v10/evm"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, bytecode cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
s, err := evm10.ConstructState(store, bytecode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
evm10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) Nonce() (uint64, error) {
|
||||
return s.State.Nonce, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -7,7 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
@ -24,8 +24,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin9.InitActorAddr
|
||||
Methods = builtin9.MethodsInit
|
||||
Address = builtin10.InitActorAddr
|
||||
Methods = builtin10.MethodsInit
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
@ -42,6 +42,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +106,9 @@ func MakeState(store adt.Store, av actorstypes.Version, networkName string) (Sta
|
||||
case actorstypes.Version9:
|
||||
return make9(store, networkName)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, networkName)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -152,5 +158,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
146
chain/actors/builtin/init/v10.go
generated
Normal file
146
chain/actors/builtin/init/v10.go
generated
Normal file
@ -0,0 +1,146 @@
|
||||
package init
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, networkName string) (State, error) {
|
||||
out := state10{store: store}
|
||||
|
||||
s, err := init10.ConstructState(store, networkName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
init10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) ResolveAddress(address address.Address) (address.Address, bool, error) {
|
||||
return s.State.ResolveAddress(s.store, address)
|
||||
}
|
||||
|
||||
func (s *state10) MapAddressToNewID(address address.Address) (address.Address, error) {
|
||||
return s.State.MapAddressToNewID(s.store, address)
|
||||
}
|
||||
|
||||
func (s *state10) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
|
||||
addrs, err := adt10.AsMap(s.store, s.State.AddressMap, builtin10.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var actorID cbg.CborInt
|
||||
return addrs.ForEach(&actorID, func(key string) error {
|
||||
addr, err := address.NewFromBytes([]byte(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(abi.ActorID(actorID), addr)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state10) NetworkName() (dtypes.NetworkName, error) {
|
||||
return dtypes.NetworkName(s.State.NetworkName), nil
|
||||
}
|
||||
|
||||
func (s *state10) SetNetworkName(name string) error {
|
||||
s.State.NetworkName = name
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) SetNextID(id abi.ActorID) error {
|
||||
s.State.NextID = id
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) Remove(addrs ...address.Address) (err error) {
|
||||
m, err := adt10.AsMap(s.store, s.State.AddressMap, builtin10.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
if err = m.Delete(abi.AddrKey(addr)); err != nil {
|
||||
return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err)
|
||||
}
|
||||
}
|
||||
amr, err := m.Root()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to get address map root: %w", err)
|
||||
}
|
||||
s.State.AddressMap = amr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) SetAddressMap(mcid cid.Cid) error {
|
||||
s.State.AddressMap = mcid
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) AddressMap() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.State.AddressMap, builtin10.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) AddressMapBitWidth() int {
|
||||
return builtin10.DefaultHamtBitwidth
|
||||
}
|
||||
|
||||
func (s *state10) AddressMapHashFunction() func(input []byte) []byte {
|
||||
return func(input []byte) []byte {
|
||||
res := sha256.Sum256(input)
|
||||
return res[:]
|
||||
}
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.InitKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -48,6 +48,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,6 +112,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return make9(store)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -198,6 +204,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
|
||||
case actorstypes.Version9:
|
||||
return decodePublishStorageDealsReturn9(b)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return decodePublishStorageDealsReturn10(b)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -282,5 +291,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
@ -208,16 +208,17 @@ func (s *dealStates{{.v}}) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState {
|
||||
{{if (le .v 8)}}
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v{{.v}}.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v{{.v}}.LastUpdatedEpoch,
|
||||
SlashEpoch: v{{.v}}.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
{{else}}
|
||||
return (DealState)(v{{.v}})
|
||||
{{if (ge .v 9)}}
|
||||
ret.VerifiedClaim = verifregtypes.AllocationId(v{{.v}}.VerifiedClaim)
|
||||
{{end}}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals{{.v}} struct {
|
||||
@ -373,7 +374,7 @@ func (s *state{{.v}}) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifreg
|
||||
{{if (le .v 8)}}
|
||||
return verifregtypes.NoAllocationID, xerrors.Errorf("unsupported before actors v9")
|
||||
{{else}}
|
||||
allocations, err := adt9.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth)
|
||||
allocations, err := adt{{.v}}.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err)
|
||||
}
|
||||
|
4
chain/actors/builtin/market/v0.go
generated
4
chain/actors/builtin/market/v0.go
generated
@ -187,14 +187,14 @@ func (s *dealStates0) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV0DealState(v0 market0.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v0.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v0.LastUpdatedEpoch,
|
||||
SlashEpoch: v0.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals0 struct {
|
||||
|
376
chain/actors/builtin/market/v10.go
generated
Normal file
376
chain/actors/builtin/market/v10.go
generated
Normal file
@ -0,0 +1,376 @@
|
||||
package market
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
rlepluslazy "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/builtin"
|
||||
market10 "github.com/filecoin-project/go-state-types/builtin/v10/market"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
|
||||
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store) (State, error) {
|
||||
out := state10{store: store}
|
||||
|
||||
s, err := market10.ConstructState(store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
market10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) TotalLocked() (abi.TokenAmount, error) {
|
||||
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
|
||||
fml = types.BigAdd(fml, s.TotalClientStorageFee)
|
||||
return fml, nil
|
||||
}
|
||||
|
||||
func (s *state10) BalancesChanged(otherState State) (bool, error) {
|
||||
otherState10, ok := otherState.(*state10)
|
||||
if !ok {
|
||||
// there's no way to compare different versions of the state, so let's
|
||||
// just say that means the state of balances has changed
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.EscrowTable.Equals(otherState10.State.EscrowTable) || !s.State.LockedTable.Equals(otherState10.State.LockedTable), nil
|
||||
}
|
||||
|
||||
func (s *state10) StatesChanged(otherState State) (bool, error) {
|
||||
otherState10, ok := otherState.(*state10)
|
||||
if !ok {
|
||||
// there's no way to compare different versions of the state, so let's
|
||||
// just say that means the state of balances has changed
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.States.Equals(otherState10.State.States), nil
|
||||
}
|
||||
|
||||
func (s *state10) States() (DealStates, error) {
|
||||
stateArray, err := adt10.AsArray(s.store, s.State.States, market10.StatesAmtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dealStates10{stateArray}, nil
|
||||
}
|
||||
|
||||
func (s *state10) ProposalsChanged(otherState State) (bool, error) {
|
||||
otherState10, ok := otherState.(*state10)
|
||||
if !ok {
|
||||
// there's no way to compare different versions of the state, so let's
|
||||
// just say that means the state of balances has changed
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.Proposals.Equals(otherState10.State.Proposals), nil
|
||||
}
|
||||
|
||||
func (s *state10) Proposals() (DealProposals, error) {
|
||||
proposalArray, err := adt10.AsArray(s.store, s.State.Proposals, market10.ProposalsAmtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dealProposals10{proposalArray}, nil
|
||||
}
|
||||
|
||||
func (s *state10) EscrowTable() (BalanceTable, error) {
|
||||
bt, err := adt10.AsBalanceTable(s.store, s.State.EscrowTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &balanceTable10{bt}, nil
|
||||
}
|
||||
|
||||
func (s *state10) LockedTable() (BalanceTable, error) {
|
||||
bt, err := adt10.AsBalanceTable(s.store, s.State.LockedTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &balanceTable10{bt}, nil
|
||||
}
|
||||
|
||||
func (s *state10) VerifyDealsForActivation(
|
||||
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
||||
) (weight, verifiedWeight abi.DealWeight, err error) {
|
||||
w, vw, _, err := market10.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
|
||||
return w, vw, err
|
||||
}
|
||||
|
||||
func (s *state10) NextID() (abi.DealID, error) {
|
||||
return s.State.NextID, nil
|
||||
}
|
||||
|
||||
type balanceTable10 struct {
|
||||
*adt10.BalanceTable
|
||||
}
|
||||
|
||||
func (bt *balanceTable10) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
|
||||
asMap := (*adt10.Map)(bt.BalanceTable)
|
||||
var ta abi.TokenAmount
|
||||
return asMap.ForEach(&ta, func(key string) error {
|
||||
a, err := address.NewFromBytes([]byte(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(a, ta)
|
||||
})
|
||||
}
|
||||
|
||||
type dealStates10 struct {
|
||||
adt.Array
|
||||
}
|
||||
|
||||
func (s *dealStates10) Get(dealID abi.DealID) (*DealState, bool, error) {
|
||||
var deal10 market10.DealState
|
||||
found, err := s.Array.Get(uint64(dealID), &deal10)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
deal := fromV10DealState(deal10)
|
||||
return &deal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealStates10) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
|
||||
var ds10 market10.DealState
|
||||
return s.Array.ForEach(&ds10, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV10DealState(ds10))
|
||||
})
|
||||
}
|
||||
|
||||
func (s *dealStates10) decode(val *cbg.Deferred) (*DealState, error) {
|
||||
var ds10 market10.DealState
|
||||
if err := ds10.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ds := fromV10DealState(ds10)
|
||||
return &ds, nil
|
||||
}
|
||||
|
||||
func (s *dealStates10) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV10DealState(v10 market10.DealState) DealState {
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v10.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v10.LastUpdatedEpoch,
|
||||
SlashEpoch: v10.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
ret.VerifiedClaim = verifregtypes.AllocationId(v10.VerifiedClaim)
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals10 struct {
|
||||
adt.Array
|
||||
}
|
||||
|
||||
func (s *dealProposals10) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
var proposal10 market10.DealProposal
|
||||
found, err := s.Array.Get(uint64(dealID), &proposal10)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
proposal, err := fromV10DealProposal(proposal10)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals10) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp10 market10.DealProposal
|
||||
return s.Array.ForEach(&dp10, func(idx int64) error {
|
||||
dp, err := fromV10DealProposal(dp10)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *dealProposals10) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
var dp10 market10.DealProposal
|
||||
if err := dp10.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dp, err := fromV10DealProposal(dp10)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals10) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV10DealProposal(v10 market10.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := fromV10Label(v10.Label)
|
||||
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v10.PieceCID,
|
||||
PieceSize: v10.PieceSize,
|
||||
VerifiedDeal: v10.VerifiedDeal,
|
||||
Client: v10.Client,
|
||||
Provider: v10.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v10.StartEpoch,
|
||||
EndEpoch: v10.EndEpoch,
|
||||
StoragePricePerEpoch: v10.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v10.ProviderCollateral,
|
||||
ClientCollateral: v10.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func fromV10Label(v10 market10.DealLabel) (DealLabel, error) {
|
||||
if v10.IsString() {
|
||||
str, err := v10.ToString()
|
||||
if err != nil {
|
||||
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert string label to string: %w", err)
|
||||
}
|
||||
return markettypes.NewLabelFromString(str)
|
||||
}
|
||||
|
||||
bs, err := v10.ToBytes()
|
||||
if err != nil {
|
||||
return markettypes.EmptyDealLabel, xerrors.Errorf("failed to convert bytes label to bytes: %w", err)
|
||||
}
|
||||
return markettypes.NewLabelFromBytes(bs)
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
var _ PublishStorageDealsReturn = (*publishStorageDealsReturn10)(nil)
|
||||
|
||||
func decodePublishStorageDealsReturn10(b []byte) (PublishStorageDealsReturn, error) {
|
||||
var retval market10.PublishStorageDealsReturn
|
||||
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
|
||||
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
|
||||
}
|
||||
|
||||
return &publishStorageDealsReturn10{retval}, nil
|
||||
}
|
||||
|
||||
type publishStorageDealsReturn10 struct {
|
||||
market10.PublishStorageDealsReturn
|
||||
}
|
||||
|
||||
func (r *publishStorageDealsReturn10) IsDealValid(index uint64) (bool, int, error) {
|
||||
|
||||
set, err := r.ValidDeals.IsSet(index)
|
||||
if err != nil || !set {
|
||||
return false, -1, err
|
||||
}
|
||||
maskBf, err := bitfield.NewFromIter(&rlepluslazy.RunSliceIterator{
|
||||
Runs: []rlepluslazy.Run{rlepluslazy.Run{Val: true, Len: index}}})
|
||||
if err != nil {
|
||||
return false, -1, err
|
||||
}
|
||||
before, err := bitfield.IntersectBitField(maskBf, r.ValidDeals)
|
||||
if err != nil {
|
||||
return false, -1, err
|
||||
}
|
||||
outIdx, err := before.Count()
|
||||
if err != nil {
|
||||
return false, -1, err
|
||||
}
|
||||
return set, int(outIdx), nil
|
||||
|
||||
}
|
||||
|
||||
func (r *publishStorageDealsReturn10) DealIDs() ([]abi.DealID, error) {
|
||||
return r.IDs, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetAllocationIdForPendingDeal(dealId abi.DealID) (verifregtypes.AllocationId, error) {
|
||||
|
||||
allocations, err := adt10.AsMap(s.store, s.PendingDealAllocationIds, builtin.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err)
|
||||
}
|
||||
|
||||
var allocationId cbg.CborInt
|
||||
found, err := allocations.Get(abi.UIntKey(uint64(dealId)), &allocationId)
|
||||
if err != nil {
|
||||
return verifregtypes.NoAllocationID, xerrors.Errorf("failed to load allocation id for %d: %w", dealId, err)
|
||||
}
|
||||
if !found {
|
||||
return verifregtypes.NoAllocationID, nil
|
||||
}
|
||||
|
||||
return verifregtypes.AllocationId(allocationId), nil
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.MarketKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
4
chain/actors/builtin/market/v2.go
generated
4
chain/actors/builtin/market/v2.go
generated
@ -187,14 +187,14 @@ func (s *dealStates2) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV2DealState(v2 market2.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v2.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v2.LastUpdatedEpoch,
|
||||
SlashEpoch: v2.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals2 struct {
|
||||
|
4
chain/actors/builtin/market/v3.go
generated
4
chain/actors/builtin/market/v3.go
generated
@ -182,14 +182,14 @@ func (s *dealStates3) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV3DealState(v3 market3.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v3.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v3.LastUpdatedEpoch,
|
||||
SlashEpoch: v3.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals3 struct {
|
||||
|
4
chain/actors/builtin/market/v4.go
generated
4
chain/actors/builtin/market/v4.go
generated
@ -182,14 +182,14 @@ func (s *dealStates4) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV4DealState(v4 market4.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v4.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v4.LastUpdatedEpoch,
|
||||
SlashEpoch: v4.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals4 struct {
|
||||
|
4
chain/actors/builtin/market/v5.go
generated
4
chain/actors/builtin/market/v5.go
generated
@ -182,14 +182,14 @@ func (s *dealStates5) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV5DealState(v5 market5.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v5.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v5.LastUpdatedEpoch,
|
||||
SlashEpoch: v5.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals5 struct {
|
||||
|
4
chain/actors/builtin/market/v6.go
generated
4
chain/actors/builtin/market/v6.go
generated
@ -184,14 +184,14 @@ func (s *dealStates6) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV6DealState(v6 market6.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v6.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v6.LastUpdatedEpoch,
|
||||
SlashEpoch: v6.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals6 struct {
|
||||
|
4
chain/actors/builtin/market/v7.go
generated
4
chain/actors/builtin/market/v7.go
generated
@ -184,14 +184,14 @@ func (s *dealStates7) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV7DealState(v7 market7.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v7.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v7.LastUpdatedEpoch,
|
||||
SlashEpoch: v7.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals7 struct {
|
||||
|
4
chain/actors/builtin/market/v8.go
generated
4
chain/actors/builtin/market/v8.go
generated
@ -185,14 +185,14 @@ func (s *dealStates8) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV8DealState(v8 market8.DealState) DealState {
|
||||
|
||||
return DealState{
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v8.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v8.LastUpdatedEpoch,
|
||||
SlashEpoch: v8.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals8 struct {
|
||||
|
9
chain/actors/builtin/market/v9.go
generated
9
chain/actors/builtin/market/v9.go
generated
@ -186,9 +186,16 @@ func (s *dealStates9) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV9DealState(v9 market9.DealState) DealState {
|
||||
ret := DealState{
|
||||
SectorStartEpoch: v9.SectorStartEpoch,
|
||||
LastUpdatedEpoch: v9.LastUpdatedEpoch,
|
||||
SlashEpoch: v9.SlashEpoch,
|
||||
VerifiedClaim: 0,
|
||||
}
|
||||
|
||||
return (DealState)(v9)
|
||||
ret.VerifiedClaim = verifregtypes.AllocationId(v9.VerifiedClaim)
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
type dealProposals9 struct {
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
miner{{.latestVersion}} "github.com/filecoin-project/go-state-types/builtin{{import .latestVersion}}miner"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
|
||||
{{range .versions}}
|
||||
{{if (le . 7)}}
|
||||
@ -82,8 +82,8 @@ type State interface {
|
||||
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
||||
FindSector(abi.SectorNumber) (*SectorLocation, error)
|
||||
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
|
||||
GetPrecommittedSector(abi.SectorNumber) (*miner{{.latestVersion}}.SectorPreCommitOnChainInfo, error)
|
||||
ForEachPrecommittedSector(func(miner{{.latestVersion}}.SectorPreCommitOnChainInfo) error) error
|
||||
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
|
||||
ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error
|
||||
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
|
||||
NumLiveSectors() (uint64, error)
|
||||
IsAllocated(abi.SectorNumber) (bool, error)
|
||||
@ -112,7 +112,7 @@ type State interface {
|
||||
sectors() (adt.Array, error)
|
||||
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
|
||||
precommits() (adt.Map, error)
|
||||
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner{{.latestVersion}}.SectorPreCommitOnChainInfo, error)
|
||||
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
|
||||
GetState() interface{}
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ type Partition interface {
|
||||
UnprovenSectors() (bitfield.BitField, error)
|
||||
}
|
||||
|
||||
type SectorOnChainInfo = miner{{.latestVersion}}.SectorOnChainInfo
|
||||
type SectorOnChainInfo = minertypes.SectorOnChainInfo
|
||||
|
||||
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
|
||||
// We added support for the new proofs in network version 7, and removed support for the old
|
||||
@ -205,9 +205,12 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi
|
||||
}
|
||||
}
|
||||
|
||||
type MinerInfo = miner{{.latestVersion}}.MinerInfo
|
||||
type WorkerKeyChange = miner{{.latestVersion}}.WorkerKeyChange
|
||||
type SectorPreCommitOnChainInfo = miner{{.latestVersion}}.SectorPreCommitOnChainInfo
|
||||
type MinerInfo = minertypes.MinerInfo
|
||||
type BeneficiaryTerm = minertypes.BeneficiaryTerm
|
||||
type PendingBeneficiaryChange = minertypes.PendingBeneficiaryChange
|
||||
type WorkerKeyChange = minertypes.WorkerKeyChange
|
||||
type SectorPreCommitOnChainInfo = minertypes.SectorPreCommitOnChainInfo
|
||||
type SectorPreCommitInfo = minertypes.SectorPreCommitInfo
|
||||
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
|
||||
|
||||
type SectorExpiration struct {
|
||||
@ -235,8 +238,8 @@ type SectorExtensions struct {
|
||||
}
|
||||
|
||||
type PreCommitChanges struct {
|
||||
Added []miner{{.latestVersion}}.SectorPreCommitOnChainInfo
|
||||
Removed []miner{{.latestVersion}}.SectorPreCommitOnChainInfo
|
||||
Added []SectorPreCommitOnChainInfo
|
||||
Removed []SectorPreCommitOnChainInfo
|
||||
}
|
||||
|
||||
type LockedFunds struct {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
@ -41,6 +41,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,6 +105,9 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version9:
|
||||
return make9(store)
|
||||
|
||||
case actors.Version10:
|
||||
return make10(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -124,8 +130,8 @@ type State interface {
|
||||
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
||||
FindSector(abi.SectorNumber) (*SectorLocation, error)
|
||||
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
|
||||
GetPrecommittedSector(abi.SectorNumber) (*miner9.SectorPreCommitOnChainInfo, error)
|
||||
ForEachPrecommittedSector(func(miner9.SectorPreCommitOnChainInfo) error) error
|
||||
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
|
||||
ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error
|
||||
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
|
||||
NumLiveSectors() (uint64, error)
|
||||
IsAllocated(abi.SectorNumber) (bool, error)
|
||||
@ -154,7 +160,7 @@ type State interface {
|
||||
sectors() (adt.Array, error)
|
||||
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
|
||||
precommits() (adt.Map, error)
|
||||
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (miner9.SectorPreCommitOnChainInfo, error)
|
||||
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
|
||||
GetState() interface{}
|
||||
}
|
||||
|
||||
@ -192,7 +198,7 @@ type Partition interface {
|
||||
UnprovenSectors() (bitfield.BitField, error)
|
||||
}
|
||||
|
||||
type SectorOnChainInfo = miner9.SectorOnChainInfo
|
||||
type SectorOnChainInfo = minertypes.SectorOnChainInfo
|
||||
|
||||
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
|
||||
// We added support for the new proofs in network version 7, and removed support for the old
|
||||
@ -247,9 +253,12 @@ func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi
|
||||
}
|
||||
}
|
||||
|
||||
type MinerInfo = miner9.MinerInfo
|
||||
type WorkerKeyChange = miner9.WorkerKeyChange
|
||||
type SectorPreCommitOnChainInfo = miner9.SectorPreCommitOnChainInfo
|
||||
type MinerInfo = minertypes.MinerInfo
|
||||
type BeneficiaryTerm = minertypes.BeneficiaryTerm
|
||||
type PendingBeneficiaryChange = minertypes.PendingBeneficiaryChange
|
||||
type WorkerKeyChange = minertypes.WorkerKeyChange
|
||||
type SectorPreCommitOnChainInfo = minertypes.SectorPreCommitOnChainInfo
|
||||
type SectorPreCommitInfo = minertypes.SectorPreCommitInfo
|
||||
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
|
||||
|
||||
type SectorExpiration struct {
|
||||
@ -277,8 +286,8 @@ type SectorExtensions struct {
|
||||
}
|
||||
|
||||
type PreCommitChanges struct {
|
||||
Added []miner9.SectorPreCommitOnChainInfo
|
||||
Removed []miner9.SectorPreCommitOnChainInfo
|
||||
Added []SectorPreCommitOnChainInfo
|
||||
Removed []SectorPreCommitOnChainInfo
|
||||
}
|
||||
|
||||
type LockedFunds struct {
|
||||
@ -302,5 +311,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v{{.latestVersion}}/miner"
|
||||
|
||||
{{if (le .v 7)}}
|
||||
{{if (ge .v 3)}}
|
||||
@ -218,7 +217,7 @@ func (s *state{{.v}}) GetSectorExpiration(num abi.SectorNumber) (*SectorExpirati
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -229,7 +228,7 @@ func (s *state{{.v}}) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.S
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state{{.v}}) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
{{if (ge .v 3) -}}
|
||||
precommitted, err := adt{{.v}}.AsMap(s.store, s.State.PreCommittedSectors, builtin{{.v}}.DefaultHamtBitwidth)
|
||||
{{- else -}}
|
||||
@ -417,9 +416,10 @@ func (s *state{{.v}}) Info() (MinerInfo, error) {
|
||||
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
||||
ConsensusFaultElapsed: {{if (ge .v 2)}}info.ConsensusFaultElapsed{{else}}-1{{end}},
|
||||
{{if (ge .v 9)}}
|
||||
Beneficiary: info.Beneficiary,
|
||||
BeneficiaryTerm: info.BeneficiaryTerm,
|
||||
PendingBeneficiaryTerm: info.PendingBeneficiaryTerm,{{end}}
|
||||
Beneficiary: info.Beneficiary,
|
||||
BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm),
|
||||
PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm),
|
||||
{{end}}
|
||||
}
|
||||
|
||||
return mi, nil
|
||||
@ -451,11 +451,11 @@ func (s *state{{.v}}) precommits() (adt.Map, error) {
|
||||
return adt{{.v}}.AsMap(s.store, s.PreCommittedSectors{{if (ge .v 3)}}, builtin{{.v}}.DefaultHamtBitwidth{{end}})
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state{{.v}}) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner{{.v}}.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV{{.v}}SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -586,9 +586,9 @@ func fromV{{.v}}SectorOnChainInfo(v{{.v}} miner{{.v}}.SectorOnChainInfo) SectorO
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
{{if (le .v 8)}}return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v{{.v}}.Info.SealProof,
|
||||
SectorNumber: v{{.v}}.Info.SectorNumber,
|
||||
SealedCID: v{{.v}}.Info.SealedCID,
|
||||
@ -599,7 +599,13 @@ func fromV{{.v}}SectorPreCommitOnChainInfo(v{{.v}} miner{{.v}}.SectorPreCommitOn
|
||||
},
|
||||
PreCommitDeposit: v{{.v}}.PreCommitDeposit,
|
||||
PreCommitEpoch: v{{.v}}.PreCommitEpoch,
|
||||
}{{else}}return v{{.v}}{{end}}
|
||||
}
|
||||
|
||||
{{if (ge .v 9)}}
|
||||
ret.Info.UnsealedCid = v{{.v}}.Info.UnsealedCid
|
||||
{{end}}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v0.go
generated
17
chain/actors/builtin/miner/v0.go
generated
@ -14,7 +14,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
adt0 "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
@ -198,7 +197,7 @@ func (s *state0) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -209,7 +208,7 @@ func (s *state0) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state0) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state0) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt0.AsMap(s.store, s.State.PreCommittedSectors)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -422,11 +421,11 @@ func (s *state0) precommits() (adt.Map, error) {
|
||||
return adt0.AsMap(s.store, s.PreCommittedSectors)
|
||||
}
|
||||
|
||||
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state0) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner0.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV0SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -512,9 +511,9 @@ func fromV0SectorOnChainInfo(v0 miner0.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v0.Info.SealProof,
|
||||
SectorNumber: v0.Info.SectorNumber,
|
||||
SealedCID: v0.Info.SealedCID,
|
||||
@ -526,6 +525,8 @@ func fromV0SectorPreCommitOnChainInfo(v0 miner0.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v0.PreCommitDeposit,
|
||||
PreCommitEpoch: v0.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state0) GetState() interface{} {
|
||||
|
589
chain/actors/builtin/miner/v10.go
generated
Normal file
589
chain/actors/builtin/miner/v10.go
generated
Normal file
@ -0,0 +1,589 @@
|
||||
package miner
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
miner10 "github.com/filecoin-project/go-state-types/builtin/v10/miner"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = miner10.State{}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
miner10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
type deadline10 struct {
|
||||
miner10.Deadline
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
type partition10 struct {
|
||||
miner10.Partition
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = xerrors.Errorf("failed to get available balance: %w", r)
|
||||
available = abi.NewTokenAmount(0)
|
||||
}
|
||||
}()
|
||||
// this panics if the miner doesnt have enough funds to cover their locked pledge
|
||||
available, err = s.GetAvailableBalance(bal)
|
||||
return available, err
|
||||
}
|
||||
|
||||
func (s *state10) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||
return s.CheckVestedFunds(s.store, epoch)
|
||||
}
|
||||
|
||||
func (s *state10) LockedFunds() (LockedFunds, error) {
|
||||
return LockedFunds{
|
||||
VestingFunds: s.State.LockedFunds,
|
||||
InitialPledgeRequirement: s.State.InitialPledge,
|
||||
PreCommitDeposits: s.State.PreCommitDeposits,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state10) FeeDebt() (abi.TokenAmount, error) {
|
||||
return s.State.FeeDebt, nil
|
||||
}
|
||||
|
||||
func (s *state10) InitialPledge() (abi.TokenAmount, error) {
|
||||
return s.State.InitialPledge, nil
|
||||
}
|
||||
|
||||
func (s *state10) PreCommitDeposits() (abi.TokenAmount, error) {
|
||||
return s.State.PreCommitDeposits, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := fromV10SectorOnChainInfo(*info)
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state10) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
||||
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SectorLocation{
|
||||
Deadline: dlIdx,
|
||||
Partition: partIdx,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state10) NumLiveSectors() (uint64, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var total uint64
|
||||
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner10.Deadline) error {
|
||||
total += dl.LiveSectors
|
||||
return nil
|
||||
}); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return total, nil
|
||||
}
|
||||
|
||||
// GetSectorExpiration returns the effective expiration of the given sector.
|
||||
//
|
||||
// If the sector does not expire early, the Early expiration field is 0.
|
||||
func (s *state10) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// NOTE: this can be optimized significantly.
|
||||
// 1. If the sector is non-faulty, it will expire on-time (can be
|
||||
// learned from the sector info).
|
||||
// 2. If it's faulty, it will expire early within the first 42 entries
|
||||
// of the expiration queue.
|
||||
|
||||
stopErr := errors.New("stop")
|
||||
out := SectorExpiration{}
|
||||
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner10.Deadline) error {
|
||||
partitions, err := dl.PartitionsArray(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
quant := s.State.QuantSpecForDeadline(dlIdx)
|
||||
var part miner10.Partition
|
||||
return partitions.ForEach(&part, func(partIdx int64) error {
|
||||
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if !found {
|
||||
return nil
|
||||
}
|
||||
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if found {
|
||||
// already terminated
|
||||
return stopErr
|
||||
}
|
||||
|
||||
q, err := miner10.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner10.PartitionExpirationAmtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var exp miner10.ExpirationSet
|
||||
return q.ForEach(&exp, func(epoch int64) error {
|
||||
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if early {
|
||||
out.Early = abi.ChainEpoch(epoch)
|
||||
return nil
|
||||
}
|
||||
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if onTime {
|
||||
out.OnTime = abi.ChainEpoch(epoch)
|
||||
return stopErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
})
|
||||
})
|
||||
if err == stopErr {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.Early == 0 && out.OnTime == 0 {
|
||||
return nil, xerrors.Errorf("failed to find sector %d", num)
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := fromV10SectorPreCommitOnChainInfo(*info)
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state10) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt10.AsMap(s.store, s.State.PreCommittedSectors, builtin10.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var info miner10.SectorPreCommitOnChainInfo
|
||||
if err := precommitted.ForEach(&info, func(_ string) error {
|
||||
return cb(fromV10SectorPreCommitOnChainInfo(info))
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
|
||||
sectors, err := miner10.LoadSectors(s.store, s.State.Sectors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If no sector numbers are specified, load all.
|
||||
if snos == nil {
|
||||
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
|
||||
var info10 miner10.SectorOnChainInfo
|
||||
if err := sectors.ForEach(&info10, func(_ int64) error {
|
||||
info := fromV10SectorOnChainInfo(info10)
|
||||
infos = append(infos, &info)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
// Otherwise, load selected.
|
||||
infos10, err := sectors.Load(*snos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
infos := make([]*SectorOnChainInfo, len(infos10))
|
||||
for i, info10 := range infos10 {
|
||||
info := fromV10SectorOnChainInfo(*info10)
|
||||
infos[i] = &info
|
||||
}
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
func (s *state10) loadAllocatedSectorNumbers() (bitfield.BitField, error) {
|
||||
var allocatedSectors bitfield.BitField
|
||||
err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors)
|
||||
return allocatedSectors, err
|
||||
}
|
||||
|
||||
func (s *state10) IsAllocated(num abi.SectorNumber) (bool, error) {
|
||||
allocatedSectors, err := s.loadAllocatedSectorNumbers()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return allocatedSectors.IsSet(uint64(num))
|
||||
}
|
||||
|
||||
func (s *state10) GetProvingPeriodStart() (abi.ChainEpoch, error) {
|
||||
return s.State.ProvingPeriodStart, nil
|
||||
}
|
||||
|
||||
func (s *state10) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) {
|
||||
allocatedSectors, err := s.loadAllocatedSectorNumbers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allocatedRuns, err := allocatedSectors.RunIterator()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
unallocatedRuns, err := rle.Subtract(
|
||||
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
|
||||
allocatedRuns,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iter, err := rle.BitsFromRuns(unallocatedRuns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sectors := make([]abi.SectorNumber, 0, count)
|
||||
for iter.HasNext() && len(sectors) < count {
|
||||
nextNo, err := iter.Next()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sectors = append(sectors, abi.SectorNumber(nextNo))
|
||||
}
|
||||
|
||||
return sectors, nil
|
||||
}
|
||||
|
||||
func (s *state10) GetAllocatedSectors() (*bitfield.BitField, error) {
|
||||
var allocatedSectors bitfield.BitField
|
||||
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &allocatedSectors, nil
|
||||
}
|
||||
|
||||
func (s *state10) LoadDeadline(idx uint64) (Deadline, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dl, err := dls.LoadDeadline(s.store, idx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &deadline10{*dl, s.store}, nil
|
||||
}
|
||||
|
||||
func (s *state10) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return dls.ForEach(s.store, func(i uint64, dl *miner10.Deadline) error {
|
||||
return cb(i, &deadline10{*dl, s.store})
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state10) NumDeadlines() (uint64, error) {
|
||||
return miner10.WPoStPeriodDeadlines, nil
|
||||
}
|
||||
|
||||
func (s *state10) DeadlinesChanged(other State) (bool, error) {
|
||||
other10, ok := other.(*state10)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return !s.State.Deadlines.Equals(other10.Deadlines), nil
|
||||
}
|
||||
|
||||
func (s *state10) MinerInfoChanged(other State) (bool, error) {
|
||||
other0, ok := other.(*state10)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.Info.Equals(other0.State.Info), nil
|
||||
}
|
||||
|
||||
func (s *state10) Info() (MinerInfo, error) {
|
||||
info, err := s.State.GetInfo(s.store)
|
||||
if err != nil {
|
||||
return MinerInfo{}, err
|
||||
}
|
||||
|
||||
mi := MinerInfo{
|
||||
Owner: info.Owner,
|
||||
Worker: info.Worker,
|
||||
ControlAddresses: info.ControlAddresses,
|
||||
|
||||
PendingWorkerKey: (*WorkerKeyChange)(info.PendingWorkerKey),
|
||||
|
||||
PeerId: info.PeerId,
|
||||
Multiaddrs: info.Multiaddrs,
|
||||
WindowPoStProofType: info.WindowPoStProofType,
|
||||
SectorSize: info.SectorSize,
|
||||
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
||||
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
|
||||
|
||||
Beneficiary: info.Beneficiary,
|
||||
BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm),
|
||||
PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm),
|
||||
}
|
||||
|
||||
return mi, nil
|
||||
}
|
||||
|
||||
func (s *state10) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
|
||||
return s.State.RecordedDeadlineInfo(epoch), nil
|
||||
}
|
||||
|
||||
func (s *state10) DeadlineCronActive() (bool, error) {
|
||||
return s.State.DeadlineCronActive, nil
|
||||
}
|
||||
|
||||
func (s *state10) sectors() (adt.Array, error) {
|
||||
return adt10.AsArray(s.store, s.Sectors, miner10.SectorsAmtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
||||
var si miner10.SectorOnChainInfo
|
||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return SectorOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV10SectorOnChainInfo(si), nil
|
||||
}
|
||||
|
||||
func (s *state10) precommits() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.PreCommittedSectors, builtin10.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner10.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV10SectorPreCommitOnChainInfo(sp), nil
|
||||
}
|
||||
|
||||
func (s *state10) EraseAllUnproven() error {
|
||||
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = dls.ForEach(s.store, func(dindx uint64, dl *miner10.Deadline) error {
|
||||
ps, err := dl.PartitionsArray(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var part miner10.Partition
|
||||
err = ps.ForEach(&part, func(pindx int64) error {
|
||||
_ = part.ActivateUnproven()
|
||||
err = ps.Set(uint64(pindx), &part)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dl.Partitions, err = ps.Root()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dls.UpdateDeadline(s.store, dindx, dl)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.State.SaveDeadlines(s.store, dls)
|
||||
|
||||
}
|
||||
|
||||
func (d *deadline10) LoadPartition(idx uint64) (Partition, error) {
|
||||
p, err := d.Deadline.LoadPartition(d.store, idx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &partition10{*p, d.store}, nil
|
||||
}
|
||||
|
||||
func (d *deadline10) ForEachPartition(cb func(uint64, Partition) error) error {
|
||||
ps, err := d.Deadline.PartitionsArray(d.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var part miner10.Partition
|
||||
return ps.ForEach(&part, func(i int64) error {
|
||||
return cb(uint64(i), &partition10{part, d.store})
|
||||
})
|
||||
}
|
||||
|
||||
func (d *deadline10) PartitionsChanged(other Deadline) (bool, error) {
|
||||
other10, ok := other.(*deadline10)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return !d.Deadline.Partitions.Equals(other10.Deadline.Partitions), nil
|
||||
}
|
||||
|
||||
func (d *deadline10) PartitionsPoSted() (bitfield.BitField, error) {
|
||||
return d.Deadline.PartitionsPoSted, nil
|
||||
}
|
||||
|
||||
func (d *deadline10) DisputableProofCount() (uint64, error) {
|
||||
|
||||
ops, err := d.OptimisticProofsSnapshotArray(d.store)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ops.Length(), nil
|
||||
|
||||
}
|
||||
|
||||
func (p *partition10) AllSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Sectors, nil
|
||||
}
|
||||
|
||||
func (p *partition10) FaultySectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Faults, nil
|
||||
}
|
||||
|
||||
func (p *partition10) RecoveringSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Recoveries, nil
|
||||
}
|
||||
|
||||
func (p *partition10) UnprovenSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Unproven, nil
|
||||
}
|
||||
|
||||
func fromV10SectorOnChainInfo(v10 miner10.SectorOnChainInfo) SectorOnChainInfo {
|
||||
info := SectorOnChainInfo{
|
||||
SectorNumber: v10.SectorNumber,
|
||||
SealProof: v10.SealProof,
|
||||
SealedCID: v10.SealedCID,
|
||||
DealIDs: v10.DealIDs,
|
||||
Activation: v10.Activation,
|
||||
Expiration: v10.Expiration,
|
||||
DealWeight: v10.DealWeight,
|
||||
VerifiedDealWeight: v10.VerifiedDealWeight,
|
||||
InitialPledge: v10.InitialPledge,
|
||||
ExpectedDayReward: v10.ExpectedDayReward,
|
||||
ExpectedStoragePledge: v10.ExpectedStoragePledge,
|
||||
|
||||
SectorKeyCID: v10.SectorKeyCID,
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV10SectorPreCommitOnChainInfo(v10 miner10.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v10.Info.SealProof,
|
||||
SectorNumber: v10.Info.SectorNumber,
|
||||
SealedCID: v10.Info.SealedCID,
|
||||
SealRandEpoch: v10.Info.SealRandEpoch,
|
||||
DealIDs: v10.Info.DealIDs,
|
||||
Expiration: v10.Info.Expiration,
|
||||
UnsealedCid: nil,
|
||||
},
|
||||
PreCommitDeposit: v10.PreCommitDeposit,
|
||||
PreCommitEpoch: v10.PreCommitEpoch,
|
||||
}
|
||||
|
||||
ret.Info.UnsealedCid = v10.Info.UnsealedCid
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.MinerKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
17
chain/actors/builtin/miner/v2.go
generated
17
chain/actors/builtin/miner/v2.go
generated
@ -13,7 +13,6 @@ import (
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
adt2 "github.com/filecoin-project/specs-actors/v2/actors/util/adt"
|
||||
@ -197,7 +196,7 @@ func (s *state2) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -208,7 +207,7 @@ func (s *state2) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state2) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state2) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt2.AsMap(s.store, s.State.PreCommittedSectors)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -421,11 +420,11 @@ func (s *state2) precommits() (adt.Map, error) {
|
||||
return adt2.AsMap(s.store, s.PreCommittedSectors)
|
||||
}
|
||||
|
||||
func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state2) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner2.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV2SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -543,9 +542,9 @@ func fromV2SectorOnChainInfo(v2 miner2.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v2.Info.SealProof,
|
||||
SectorNumber: v2.Info.SectorNumber,
|
||||
SealedCID: v2.Info.SealedCID,
|
||||
@ -557,6 +556,8 @@ func fromV2SectorPreCommitOnChainInfo(v2 miner2.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v2.PreCommitDeposit,
|
||||
PreCommitEpoch: v2.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state2) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v3.go
generated
17
chain/actors/builtin/miner/v3.go
generated
@ -13,7 +13,6 @@ import (
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
|
||||
miner3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/miner"
|
||||
@ -198,7 +197,7 @@ func (s *state3) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -209,7 +208,7 @@ func (s *state3) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state3) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state3) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt3.AsMap(s.store, s.State.PreCommittedSectors, builtin3.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -417,11 +416,11 @@ func (s *state3) precommits() (adt.Map, error) {
|
||||
return adt3.AsMap(s.store, s.PreCommittedSectors, builtin3.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state3) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner3.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV3SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -543,9 +542,9 @@ func fromV3SectorOnChainInfo(v3 miner3.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v3.Info.SealProof,
|
||||
SectorNumber: v3.Info.SectorNumber,
|
||||
SealedCID: v3.Info.SealedCID,
|
||||
@ -557,6 +556,8 @@ func fromV3SectorPreCommitOnChainInfo(v3 miner3.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v3.PreCommitDeposit,
|
||||
PreCommitEpoch: v3.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state3) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v4.go
generated
17
chain/actors/builtin/miner/v4.go
generated
@ -13,7 +13,6 @@ import (
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
builtin4 "github.com/filecoin-project/specs-actors/v4/actors/builtin"
|
||||
miner4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/miner"
|
||||
@ -198,7 +197,7 @@ func (s *state4) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -209,7 +208,7 @@ func (s *state4) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state4) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state4) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt4.AsMap(s.store, s.State.PreCommittedSectors, builtin4.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -417,11 +416,11 @@ func (s *state4) precommits() (adt.Map, error) {
|
||||
return adt4.AsMap(s.store, s.PreCommittedSectors, builtin4.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state4) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner4.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV4SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -543,9 +542,9 @@ func fromV4SectorOnChainInfo(v4 miner4.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v4.Info.SealProof,
|
||||
SectorNumber: v4.Info.SectorNumber,
|
||||
SealedCID: v4.Info.SealedCID,
|
||||
@ -557,6 +556,8 @@ func fromV4SectorPreCommitOnChainInfo(v4 miner4.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v4.PreCommitDeposit,
|
||||
PreCommitEpoch: v4.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state4) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v5.go
generated
17
chain/actors/builtin/miner/v5.go
generated
@ -13,7 +13,6 @@ import (
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
|
||||
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
|
||||
@ -198,7 +197,7 @@ func (s *state5) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -209,7 +208,7 @@ func (s *state5) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state5) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state5) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt5.AsMap(s.store, s.State.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -417,11 +416,11 @@ func (s *state5) precommits() (adt.Map, error) {
|
||||
return adt5.AsMap(s.store, s.PreCommittedSectors, builtin5.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state5) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner5.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV5SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -543,9 +542,9 @@ func fromV5SectorOnChainInfo(v5 miner5.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v5.Info.SealProof,
|
||||
SectorNumber: v5.Info.SectorNumber,
|
||||
SealedCID: v5.Info.SealedCID,
|
||||
@ -557,6 +556,8 @@ func fromV5SectorPreCommitOnChainInfo(v5 miner5.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v5.PreCommitDeposit,
|
||||
PreCommitEpoch: v5.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state5) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v6.go
generated
17
chain/actors/builtin/miner/v6.go
generated
@ -13,7 +13,6 @@ import (
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
miner6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/miner"
|
||||
@ -198,7 +197,7 @@ func (s *state6) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -209,7 +208,7 @@ func (s *state6) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state6) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state6) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt6.AsMap(s.store, s.State.PreCommittedSectors, builtin6.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -417,11 +416,11 @@ func (s *state6) precommits() (adt.Map, error) {
|
||||
return adt6.AsMap(s.store, s.PreCommittedSectors, builtin6.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state6) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner6.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV6SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -543,9 +542,9 @@ func fromV6SectorOnChainInfo(v6 miner6.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v6.Info.SealProof,
|
||||
SectorNumber: v6.Info.SectorNumber,
|
||||
SealedCID: v6.Info.SealedCID,
|
||||
@ -557,6 +556,8 @@ func fromV6SectorPreCommitOnChainInfo(v6 miner6.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v6.PreCommitDeposit,
|
||||
PreCommitEpoch: v6.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state6) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v7.go
generated
17
chain/actors/builtin/miner/v7.go
generated
@ -13,7 +13,6 @@ import (
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
|
||||
@ -197,7 +196,7 @@ func (s *state7) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -208,7 +207,7 @@ func (s *state7) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state7) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state7) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt7.AsMap(s.store, s.State.PreCommittedSectors, builtin7.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -416,11 +415,11 @@ func (s *state7) precommits() (adt.Map, error) {
|
||||
return adt7.AsMap(s.store, s.PreCommittedSectors, builtin7.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state7) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner7.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV7SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -544,9 +543,9 @@ func fromV7SectorOnChainInfo(v7 miner7.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v7.Info.SealProof,
|
||||
SectorNumber: v7.Info.SectorNumber,
|
||||
SealedCID: v7.Info.SealedCID,
|
||||
@ -558,6 +557,8 @@ func fromV7SectorPreCommitOnChainInfo(v7 miner7.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v7.PreCommitDeposit,
|
||||
PreCommitEpoch: v7.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state7) GetState() interface{} {
|
||||
|
17
chain/actors/builtin/miner/v8.go
generated
17
chain/actors/builtin/miner/v8.go
generated
@ -16,7 +16,6 @@ import (
|
||||
builtin8 "github.com/filecoin-project/go-state-types/builtin"
|
||||
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
@ -197,7 +196,7 @@ func (s *state8) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -208,7 +207,7 @@ func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state8) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state8) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt8.AsMap(s.store, s.State.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -416,11 +415,11 @@ func (s *state8) precommits() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state8) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner8.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV8SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -544,9 +543,9 @@ func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return minertypes.SectorPreCommitOnChainInfo{
|
||||
Info: minertypes.SectorPreCommitInfo{
|
||||
func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v8.Info.SealProof,
|
||||
SectorNumber: v8.Info.SectorNumber,
|
||||
SealedCID: v8.Info.SealedCID,
|
||||
@ -558,6 +557,8 @@ func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) mine
|
||||
PreCommitDeposit: v8.PreCommitDeposit,
|
||||
PreCommitEpoch: v8.PreCommitEpoch,
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
|
33
chain/actors/builtin/miner/v9.go
generated
33
chain/actors/builtin/miner/v9.go
generated
@ -15,7 +15,6 @@ import (
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
|
||||
@ -197,7 +196,7 @@ func (s *state9) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, e
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state9) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state9) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
@ -208,7 +207,7 @@ func (s *state9) GetPrecommittedSector(num abi.SectorNumber) (*minertypes.Sector
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state9) ForEachPrecommittedSector(cb func(minertypes.SectorPreCommitOnChainInfo) error) error {
|
||||
func (s *state9) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt9.AsMap(s.store, s.State.PreCommittedSectors, builtin9.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -387,8 +386,8 @@ func (s *state9) Info() (MinerInfo, error) {
|
||||
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
|
||||
|
||||
Beneficiary: info.Beneficiary,
|
||||
BeneficiaryTerm: info.BeneficiaryTerm,
|
||||
PendingBeneficiaryTerm: info.PendingBeneficiaryTerm,
|
||||
BeneficiaryTerm: BeneficiaryTerm(info.BeneficiaryTerm),
|
||||
PendingBeneficiaryTerm: (*PendingBeneficiaryChange)(info.PendingBeneficiaryTerm),
|
||||
}
|
||||
|
||||
return mi, nil
|
||||
@ -420,11 +419,11 @@ func (s *state9) precommits() (adt.Map, error) {
|
||||
return adt9.AsMap(s.store, s.PreCommittedSectors, builtin9.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state9) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (s *state9) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner9.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV9SectorPreCommitOnChainInfo(sp), nil
|
||||
@ -548,8 +547,24 @@ func fromV9SectorOnChainInfo(v9 miner9.SectorOnChainInfo) SectorOnChainInfo {
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV9SectorPreCommitOnChainInfo(v9 miner9.SectorPreCommitOnChainInfo) minertypes.SectorPreCommitOnChainInfo {
|
||||
return v9
|
||||
func fromV9SectorPreCommitOnChainInfo(v9 miner9.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
ret := SectorPreCommitOnChainInfo{
|
||||
Info: SectorPreCommitInfo{
|
||||
SealProof: v9.Info.SealProof,
|
||||
SectorNumber: v9.Info.SectorNumber,
|
||||
SealedCID: v9.Info.SealedCID,
|
||||
SealRandEpoch: v9.Info.SealRandEpoch,
|
||||
DealIDs: v9.Info.DealIDs,
|
||||
Expiration: v9.Info.Expiration,
|
||||
UnsealedCid: nil,
|
||||
},
|
||||
PreCommitDeposit: v9.PreCommitDeposit,
|
||||
PreCommitEpoch: v9.PreCommitEpoch,
|
||||
}
|
||||
|
||||
ret.Info.UnsealedCid = v9.Info.UnsealedCid
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *state9) GetState() interface{} {
|
||||
|
76
chain/actors/builtin/multisig/message10.go
generated
Normal file
76
chain/actors/builtin/multisig/message10.go
generated
Normal file
@ -0,0 +1,76 @@
|
||||
package multisig
|
||||
|
||||
import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||
multisig10 "github.com/filecoin-project/go-state-types/builtin/v10/multisig"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
type message10 struct{ message0 }
|
||||
|
||||
func (m message10) Create(
|
||||
signers []address.Address, threshold uint64,
|
||||
unlockStart, unlockDuration abi.ChainEpoch,
|
||||
initialAmount abi.TokenAmount,
|
||||
) (*types.Message, error) {
|
||||
|
||||
lenAddrs := uint64(len(signers))
|
||||
|
||||
if lenAddrs < threshold {
|
||||
return nil, xerrors.Errorf("cannot require signing of more addresses than provided for multisig")
|
||||
}
|
||||
|
||||
if threshold == 0 {
|
||||
threshold = lenAddrs
|
||||
}
|
||||
|
||||
if m.from == address.Undef {
|
||||
return nil, xerrors.Errorf("must provide source address")
|
||||
}
|
||||
|
||||
// Set up constructor parameters for multisig
|
||||
msigParams := &multisig10.ConstructorParams{
|
||||
Signers: signers,
|
||||
NumApprovalsThreshold: threshold,
|
||||
UnlockDuration: unlockDuration,
|
||||
StartEpoch: unlockStart,
|
||||
}
|
||||
|
||||
enc, actErr := actors.SerializeParams(msigParams)
|
||||
if actErr != nil {
|
||||
return nil, actErr
|
||||
}
|
||||
|
||||
code, ok := actors.GetActorCodeID(actorstypes.Version10, actors.MultisigKey)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("failed to get multisig code ID")
|
||||
}
|
||||
|
||||
// new actors are created by invoking 'exec' on the init actor with the constructor params
|
||||
execParams := &init10.ExecParams{
|
||||
CodeCID: code,
|
||||
ConstructorParams: enc,
|
||||
}
|
||||
|
||||
enc, actErr = actors.SerializeParams(execParams)
|
||||
if actErr != nil {
|
||||
return nil, actErr
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
To: init_.Address,
|
||||
From: m.from,
|
||||
Method: builtintypes.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
Value: initialAmount,
|
||||
}, nil
|
||||
}
|
4
chain/actors/builtin/multisig/message8.go
generated
4
chain/actors/builtin/multisig/message8.go
generated
@ -7,8 +7,8 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||
multisig8 "github.com/filecoin-project/go-state-types/builtin/v8/multisig"
|
||||
init9 "github.com/filecoin-project/go-state-types/builtin/v9/init"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
@ -56,7 +56,7 @@ func (m message8) Create(
|
||||
}
|
||||
|
||||
// new actors are created by invoking 'exec' on the init actor with the constructor params
|
||||
execParams := &init9.ExecParams{
|
||||
execParams := &init10.ExecParams{
|
||||
CodeCID: code,
|
||||
ConstructorParams: enc,
|
||||
}
|
||||
|
4
chain/actors/builtin/multisig/message9.go
generated
4
chain/actors/builtin/multisig/message9.go
generated
@ -7,7 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||
init9 "github.com/filecoin-project/go-state-types/builtin/v9/init"
|
||||
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||
multisig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
@ -56,7 +56,7 @@ func (m message9) Create(
|
||||
}
|
||||
|
||||
// new actors are created by invoking 'exec' on the init actor with the constructor params
|
||||
execParams := &init9.ExecParams{
|
||||
execParams := &init10.ExecParams{
|
||||
CodeCID: code,
|
||||
ConstructorParams: enc,
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||
msig9 "github.com/filecoin-project/go-state-types/builtin/v9/multisig"
|
||||
msig10 "github.com/filecoin-project/go-state-types/builtin/v10/multisig"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
@ -41,6 +41,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,6 +105,9 @@ func MakeState(store adt.Store, av actorstypes.Version, signers []address.Addres
|
||||
case actorstypes.Version9:
|
||||
return make9(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -128,7 +134,7 @@ type State interface {
|
||||
GetState() interface{}
|
||||
}
|
||||
|
||||
type Transaction = msig9.Transaction
|
||||
type Transaction = msig10.Transaction
|
||||
|
||||
var Methods = builtintypes.MethodsMultisig
|
||||
|
||||
@ -161,6 +167,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder {
|
||||
|
||||
case actorstypes.Version9:
|
||||
return message9{message0{from}}
|
||||
|
||||
case actorstypes.Version10:
|
||||
return message10{message0{from}}
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported actors version: %d", version))
|
||||
}
|
||||
@ -184,13 +193,13 @@ type MessageBuilder interface {
|
||||
}
|
||||
|
||||
// this type is the same between v0 and v2
|
||||
type ProposalHashData = msig9.ProposalHashData
|
||||
type ProposeReturn = msig9.ProposeReturn
|
||||
type ProposeParams = msig9.ProposeParams
|
||||
type ApproveReturn = msig9.ApproveReturn
|
||||
type ProposalHashData = msig10.ProposalHashData
|
||||
type ProposeReturn = msig10.ProposeReturn
|
||||
type ProposeParams = msig10.ProposeParams
|
||||
type ApproveReturn = msig10.ApproveReturn
|
||||
|
||||
func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
|
||||
params := msig9.TxnIDParams{ID: msig9.TxnID(id)}
|
||||
params := msig10.TxnIDParams{ID: msig10.TxnID(id)}
|
||||
if data != nil {
|
||||
if data.Requester.Protocol() != address.ID {
|
||||
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)
|
||||
@ -223,5 +232,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
137
chain/actors/builtin/multisig/v10.go
generated
Normal file
137
chain/actors/builtin/multisig/v10.go
generated
Normal file
@ -0,0 +1,137 @@
|
||||
package multisig
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
msig10 "github.com/filecoin-project/go-state-types/builtin/v10/multisig"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = msig10.State{}
|
||||
out.State.Signers = signers
|
||||
out.State.NumApprovalsThreshold = threshold
|
||||
out.State.StartEpoch = startEpoch
|
||||
out.State.UnlockDuration = unlockDuration
|
||||
out.State.InitialBalance = initialBalance
|
||||
|
||||
em, err := adt10.StoreEmptyMap(store, builtin10.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State.PendingTxns = em
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
msig10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
|
||||
}
|
||||
|
||||
func (s *state10) StartEpoch() (abi.ChainEpoch, error) {
|
||||
return s.State.StartEpoch, nil
|
||||
}
|
||||
|
||||
func (s *state10) UnlockDuration() (abi.ChainEpoch, error) {
|
||||
return s.State.UnlockDuration, nil
|
||||
}
|
||||
|
||||
func (s *state10) InitialBalance() (abi.TokenAmount, error) {
|
||||
return s.State.InitialBalance, nil
|
||||
}
|
||||
|
||||
func (s *state10) Threshold() (uint64, error) {
|
||||
return s.State.NumApprovalsThreshold, nil
|
||||
}
|
||||
|
||||
func (s *state10) Signers() ([]address.Address, error) {
|
||||
return s.State.Signers, nil
|
||||
}
|
||||
|
||||
func (s *state10) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
|
||||
arr, err := adt10.AsMap(s.store, s.State.PendingTxns, builtin10.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var out msig10.Transaction
|
||||
return arr.ForEach(&out, func(key string) error {
|
||||
txid, n := binary.Varint([]byte(key))
|
||||
if n <= 0 {
|
||||
return xerrors.Errorf("invalid pending transaction key: %v", key)
|
||||
}
|
||||
return cb(txid, (Transaction)(out)) //nolint:unconvert
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state10) PendingTxnChanged(other State) (bool, error) {
|
||||
other10, ok := other.(*state10)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.PendingTxns.Equals(other10.PendingTxns), nil
|
||||
}
|
||||
|
||||
func (s *state10) transactions() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.PendingTxns, builtin10.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
|
||||
var tx msig10.Transaction
|
||||
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return Transaction{}, err
|
||||
}
|
||||
return Transaction(tx), nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.MultisigKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
109
chain/actors/builtin/paych/message10.go
generated
Normal file
109
chain/actors/builtin/paych/message10.go
generated
Normal file
@ -0,0 +1,109 @@
|
||||
package paych
|
||||
|
||||
import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||
paych10 "github.com/filecoin-project/go-state-types/builtin/v10/paych"
|
||||
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
type message10 struct{ from address.Address }
|
||||
|
||||
func (m message10) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
|
||||
|
||||
actorCodeID, ok := actors.GetActorCodeID(actorstypes.Version10, "paymentchannel")
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("error getting actor paymentchannel code id for actor version %d", 10)
|
||||
}
|
||||
|
||||
params, aerr := actors.SerializeParams(&paych10.ConstructorParams{From: m.from, To: to})
|
||||
if aerr != nil {
|
||||
return nil, aerr
|
||||
}
|
||||
enc, aerr := actors.SerializeParams(&init10.ExecParams{
|
||||
CodeCID: actorCodeID,
|
||||
ConstructorParams: params,
|
||||
})
|
||||
if aerr != nil {
|
||||
return nil, aerr
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
To: init_.Address,
|
||||
From: m.from,
|
||||
Value: initialAmount,
|
||||
Method: builtin10.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m message10) Update(paych address.Address, sv *paychtypes.SignedVoucher, secret []byte) (*types.Message, error) {
|
||||
params, aerr := actors.SerializeParams(&paych10.UpdateChannelStateParams{
|
||||
|
||||
Sv: toV10SignedVoucher(*sv),
|
||||
|
||||
Secret: secret,
|
||||
})
|
||||
if aerr != nil {
|
||||
return nil, aerr
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
To: paych,
|
||||
From: m.from,
|
||||
Value: abi.NewTokenAmount(0),
|
||||
Method: builtin10.MethodsPaych.UpdateChannelState,
|
||||
Params: params,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func toV10SignedVoucher(sv paychtypes.SignedVoucher) paych10.SignedVoucher {
|
||||
merges := make([]paych10.Merge, len(sv.Merges))
|
||||
for i := range sv.Merges {
|
||||
merges[i] = paych10.Merge{
|
||||
Lane: sv.Merges[i].Lane,
|
||||
Nonce: sv.Merges[i].Nonce,
|
||||
}
|
||||
}
|
||||
|
||||
return paych10.SignedVoucher{
|
||||
ChannelAddr: sv.ChannelAddr,
|
||||
TimeLockMin: sv.TimeLockMin,
|
||||
TimeLockMax: sv.TimeLockMax,
|
||||
SecretHash: sv.SecretHash,
|
||||
Extra: (*paych10.ModVerifyParams)(sv.Extra),
|
||||
Lane: sv.Lane,
|
||||
Nonce: sv.Nonce,
|
||||
Amount: sv.Amount,
|
||||
MinSettleHeight: sv.MinSettleHeight,
|
||||
Merges: merges,
|
||||
Signature: sv.Signature,
|
||||
}
|
||||
}
|
||||
|
||||
func (m message10) Settle(paych address.Address) (*types.Message, error) {
|
||||
return &types.Message{
|
||||
To: paych,
|
||||
From: m.from,
|
||||
Value: abi.NewTokenAmount(0),
|
||||
Method: builtin10.MethodsPaych.Settle,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m message10) Collect(paych address.Address) (*types.Message, error) {
|
||||
return &types.Message{
|
||||
To: paych,
|
||||
From: m.from,
|
||||
Value: abi.NewTokenAmount(0),
|
||||
Method: builtin10.MethodsPaych.Collect,
|
||||
}, nil
|
||||
}
|
@ -43,6 +43,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,6 +157,9 @@ func Message(version actorstypes.Version, from address.Address) MessageBuilder {
|
||||
case actorstypes.Version9:
|
||||
return message9{from}
|
||||
|
||||
case actorstypes.Version10:
|
||||
return message10{from}
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported actors version: %d", version))
|
||||
}
|
||||
@ -193,5 +199,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
134
chain/actors/builtin/paych/v10.go
generated
Normal file
134
chain/actors/builtin/paych/v10.go
generated
Normal file
@ -0,0 +1,134 @@
|
||||
package paych
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
paych10 "github.com/filecoin-project/go-state-types/builtin/v10/paych"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = paych10.State{}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
paych10.State
|
||||
store adt.Store
|
||||
lsAmt *adt10.Array
|
||||
}
|
||||
|
||||
// Channel owner, who has funded the actor
|
||||
func (s *state10) From() (address.Address, error) {
|
||||
return s.State.From, nil
|
||||
}
|
||||
|
||||
// Recipient of payouts from channel
|
||||
func (s *state10) To() (address.Address, error) {
|
||||
return s.State.To, nil
|
||||
}
|
||||
|
||||
// Height at which the channel can be `Collected`
|
||||
func (s *state10) SettlingAt() (abi.ChainEpoch, error) {
|
||||
return s.State.SettlingAt, nil
|
||||
}
|
||||
|
||||
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||
func (s *state10) ToSend() (abi.TokenAmount, error) {
|
||||
return s.State.ToSend, nil
|
||||
}
|
||||
|
||||
func (s *state10) getOrLoadLsAmt() (*adt10.Array, error) {
|
||||
if s.lsAmt != nil {
|
||||
return s.lsAmt, nil
|
||||
}
|
||||
|
||||
// Get the lane state from the chain
|
||||
lsamt, err := adt10.AsArray(s.store, s.State.LaneStates, paych10.LaneStatesAmtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.lsAmt = lsamt
|
||||
return lsamt, nil
|
||||
}
|
||||
|
||||
// Get total number of lanes
|
||||
func (s *state10) LaneCount() (uint64, error) {
|
||||
lsamt, err := s.getOrLoadLsAmt()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return lsamt.Length(), nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
// Iterate lane states
|
||||
func (s *state10) ForEachLaneState(cb func(idx uint64, dl LaneState) error) error {
|
||||
// Get the lane state from the chain
|
||||
lsamt, err := s.getOrLoadLsAmt()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Note: we use a map instead of an array to store laneStates because the
|
||||
// client sets the lane ID (the index) and potentially they could use a
|
||||
// very large index.
|
||||
var ls paych10.LaneState
|
||||
return lsamt.ForEach(&ls, func(i int64) error {
|
||||
return cb(uint64(i), &laneState10{ls})
|
||||
})
|
||||
}
|
||||
|
||||
type laneState10 struct {
|
||||
paych10.LaneState
|
||||
}
|
||||
|
||||
func (ls *laneState10) Redeemed() (big.Int, error) {
|
||||
return ls.LaneState.Redeemed, nil
|
||||
}
|
||||
|
||||
func (ls *laneState10) Nonce() (uint64, error) {
|
||||
return ls.LaneState.Nonce, nil
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.PaychKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
@ -26,8 +26,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin9.StoragePowerActorAddr
|
||||
Methods = builtin9.MethodsPower
|
||||
Address = builtin10.StoragePowerActorAddr
|
||||
Methods = builtin10.MethodsPower
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
@ -44,6 +44,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +108,9 @@ func MakeState(store adt.Store, av actorstypes.Version) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return make9(store)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -168,5 +174,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
206
chain/actors/builtin/power/v10.go
generated
Normal file
206
chain/actors/builtin/power/v10.go
generated
Normal file
@ -0,0 +1,206 @@
|
||||
package power
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
power10 "github.com/filecoin-project/go-state-types/builtin/v10/power"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store) (State, error) {
|
||||
out := state10{store: store}
|
||||
|
||||
s, err := power10.ConstructState(store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
power10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) TotalLocked() (abi.TokenAmount, error) {
|
||||
return s.TotalPledgeCollateral, nil
|
||||
}
|
||||
|
||||
func (s *state10) TotalPower() (Claim, error) {
|
||||
return Claim{
|
||||
RawBytePower: s.TotalRawBytePower,
|
||||
QualityAdjPower: s.TotalQualityAdjPower,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Committed power to the network. Includes miners below the minimum threshold.
|
||||
func (s *state10) TotalCommitted() (Claim, error) {
|
||||
return Claim{
|
||||
RawBytePower: s.TotalBytesCommitted,
|
||||
QualityAdjPower: s.TotalQABytesCommitted,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state10) MinerPower(addr address.Address) (Claim, bool, error) {
|
||||
claims, err := s.claims()
|
||||
if err != nil {
|
||||
return Claim{}, false, err
|
||||
}
|
||||
var claim power10.Claim
|
||||
ok, err := claims.Get(abi.AddrKey(addr), &claim)
|
||||
if err != nil {
|
||||
return Claim{}, false, err
|
||||
}
|
||||
return Claim{
|
||||
RawBytePower: claim.RawBytePower,
|
||||
QualityAdjPower: claim.QualityAdjPower,
|
||||
}, ok, nil
|
||||
}
|
||||
|
||||
func (s *state10) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
|
||||
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
|
||||
}
|
||||
|
||||
func (s *state10) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
||||
return builtin.FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
|
||||
}
|
||||
|
||||
func (s *state10) MinerCounts() (uint64, uint64, error) {
|
||||
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
|
||||
}
|
||||
|
||||
func (s *state10) ListAllMiners() ([]address.Address, error) {
|
||||
claims, err := s.claims()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var miners []address.Address
|
||||
err = claims.ForEach(nil, func(k string) error {
|
||||
a, err := address.NewFromBytes([]byte(k))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
miners = append(miners, a)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return miners, nil
|
||||
}
|
||||
|
||||
func (s *state10) ForEachClaim(cb func(miner address.Address, claim Claim) error) error {
|
||||
claims, err := s.claims()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var claim power10.Claim
|
||||
return claims.ForEach(&claim, func(k string) error {
|
||||
a, err := address.NewFromBytes([]byte(k))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(a, Claim{
|
||||
RawBytePower: claim.RawBytePower,
|
||||
QualityAdjPower: claim.QualityAdjPower,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state10) ClaimsChanged(other State) (bool, error) {
|
||||
other10, ok := other.(*state10)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.Claims.Equals(other10.State.Claims), nil
|
||||
}
|
||||
|
||||
func (s *state10) SetTotalQualityAdjPower(p abi.StoragePower) error {
|
||||
s.State.TotalQualityAdjPower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) SetTotalRawBytePower(p abi.StoragePower) error {
|
||||
s.State.TotalRawBytePower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
|
||||
s.State.ThisEpochQualityAdjPower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) SetThisEpochRawBytePower(p abi.StoragePower) error {
|
||||
s.State.ThisEpochRawBytePower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) claims() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.Claims, builtin10.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) decodeClaim(val *cbg.Deferred) (Claim, error) {
|
||||
var ci power10.Claim
|
||||
if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return Claim{}, err
|
||||
}
|
||||
return fromV10Claim(ci), nil
|
||||
}
|
||||
|
||||
func fromV10Claim(v10 power10.Claim) Claim {
|
||||
return Claim{
|
||||
RawBytePower: v10.RawBytePower,
|
||||
QualityAdjPower: v10.QualityAdjPower,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.PowerKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -9,6 +9,18 @@ import (
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/builtin"
|
||||
account10 "github.com/filecoin-project/go-state-types/builtin/v10/account"
|
||||
cron10 "github.com/filecoin-project/go-state-types/builtin/v10/cron"
|
||||
datacap10 "github.com/filecoin-project/go-state-types/builtin/v10/datacap"
|
||||
_init10 "github.com/filecoin-project/go-state-types/builtin/v10/init"
|
||||
market10 "github.com/filecoin-project/go-state-types/builtin/v10/market"
|
||||
miner10 "github.com/filecoin-project/go-state-types/builtin/v10/miner"
|
||||
multisig10 "github.com/filecoin-project/go-state-types/builtin/v10/multisig"
|
||||
paych10 "github.com/filecoin-project/go-state-types/builtin/v10/paych"
|
||||
power10 "github.com/filecoin-project/go-state-types/builtin/v10/power"
|
||||
reward10 "github.com/filecoin-project/go-state-types/builtin/v10/reward"
|
||||
system10 "github.com/filecoin-project/go-state-types/builtin/v10/system"
|
||||
verifreg10 "github.com/filecoin-project/go-state-types/builtin/v10/verifreg"
|
||||
account8 "github.com/filecoin-project/go-state-types/builtin/v8/account"
|
||||
cron8 "github.com/filecoin-project/go-state-types/builtin/v8/cron"
|
||||
_init8 "github.com/filecoin-project/go-state-types/builtin/v8/init"
|
||||
@ -254,6 +266,84 @@ func MakeRegistry(av actorstypes.Version) []RegistryEntry {
|
||||
}
|
||||
}
|
||||
|
||||
case actorstypes.Version10:
|
||||
for key, codeID := range codeIDs {
|
||||
switch key {
|
||||
case actors.AccountKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: account10.Methods,
|
||||
state: new(account10.State),
|
||||
})
|
||||
case actors.CronKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: cron10.Methods,
|
||||
state: new(cron10.State),
|
||||
})
|
||||
case actors.InitKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: _init10.Methods,
|
||||
state: new(_init10.State),
|
||||
})
|
||||
case actors.MarketKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: market10.Methods,
|
||||
state: new(market10.State),
|
||||
})
|
||||
case actors.MinerKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: miner10.Methods,
|
||||
state: new(miner10.State),
|
||||
})
|
||||
case actors.MultisigKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: multisig10.Methods,
|
||||
state: new(multisig10.State),
|
||||
})
|
||||
case actors.PaychKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: paych10.Methods,
|
||||
state: new(paych10.State),
|
||||
})
|
||||
case actors.PowerKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: power10.Methods,
|
||||
state: new(power10.State),
|
||||
})
|
||||
case actors.RewardKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: reward10.Methods,
|
||||
state: new(reward10.State),
|
||||
})
|
||||
case actors.SystemKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: system10.Methods,
|
||||
state: new(system10.State),
|
||||
})
|
||||
case actors.VerifregKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: verifreg10.Methods,
|
||||
state: new(verifreg10.State),
|
||||
})
|
||||
case actors.DatacapKey:
|
||||
registry = append(registry, RegistryEntry{
|
||||
code: codeID,
|
||||
methods: datacap10.Methods,
|
||||
state: new(datacap10.State),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
panic("expected version v8 and up only, use specs-actors for v0-7")
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||
@ -24,8 +24,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin9.RewardActorAddr
|
||||
Methods = builtin9.MethodsReward
|
||||
Address = builtin10.RewardActorAddr
|
||||
Methods = builtin10.MethodsReward
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
@ -42,6 +42,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +106,9 @@ func MakeState(store adt.Store, av actorstypes.Version, currRealizedPower abi.St
|
||||
case actorstypes.Version9:
|
||||
return make9(store, currRealizedPower)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, currRealizedPower)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -144,5 +150,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
119
chain/actors/builtin/reward/v10.go
generated
Normal file
119
chain/actors/builtin/reward/v10.go
generated
Normal file
@ -0,0 +1,119 @@
|
||||
package reward
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
miner10 "github.com/filecoin-project/go-state-types/builtin/v10/miner"
|
||||
reward10 "github.com/filecoin-project/go-state-types/builtin/v10/reward"
|
||||
smoothing10 "github.com/filecoin-project/go-state-types/builtin/v10/util/smoothing"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = *reward10.ConstructState(currRealizedPower)
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
reward10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) ThisEpochReward() (abi.TokenAmount, error) {
|
||||
return s.State.ThisEpochReward, nil
|
||||
}
|
||||
|
||||
func (s *state10) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
||||
|
||||
return builtin.FilterEstimate{
|
||||
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
|
||||
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
||||
return s.State.ThisEpochBaselinePower, nil
|
||||
}
|
||||
|
||||
func (s *state10) TotalStoragePowerReward() (abi.TokenAmount, error) {
|
||||
return s.State.TotalStoragePowerReward, nil
|
||||
}
|
||||
|
||||
func (s *state10) EffectiveBaselinePower() (abi.StoragePower, error) {
|
||||
return s.State.EffectiveBaselinePower, nil
|
||||
}
|
||||
|
||||
func (s *state10) EffectiveNetworkTime() (abi.ChainEpoch, error) {
|
||||
return s.State.EffectiveNetworkTime, nil
|
||||
}
|
||||
|
||||
func (s *state10) CumsumBaseline() (reward10.Spacetime, error) {
|
||||
return s.State.CumsumBaseline, nil
|
||||
}
|
||||
|
||||
func (s *state10) CumsumRealized() (reward10.Spacetime, error) {
|
||||
return s.State.CumsumRealized, nil
|
||||
}
|
||||
|
||||
func (s *state10) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
|
||||
return miner10.InitialPledgeForPower(
|
||||
qaPower,
|
||||
s.State.ThisEpochBaselinePower,
|
||||
s.State.ThisEpochRewardSmoothed,
|
||||
smoothing10.FilterEstimate{
|
||||
PositionEstimate: networkQAPower.PositionEstimate,
|
||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||
},
|
||||
circSupply,
|
||||
), nil
|
||||
}
|
||||
|
||||
func (s *state10) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
|
||||
return miner10.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
|
||||
smoothing10.FilterEstimate{
|
||||
PositionEstimate: networkQAPower.PositionEstimate,
|
||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||
},
|
||||
sectorWeight), nil
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.RewardKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -5,7 +5,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||
builtin3 "github.com/filecoin-project/specs-actors/v3/actors/builtin"
|
||||
@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin9.SystemActorAddr
|
||||
Address = builtin10.SystemActorAddr
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
@ -37,6 +37,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,6 +101,9 @@ func MakeState(store adt.Store, av actorstypes.Version, builtinActors cid.Cid) (
|
||||
case actorstypes.Version9:
|
||||
return make9(store, builtinActors)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, builtinActors)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -123,5 +129,6 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
71
chain/actors/builtin/system/v10.go
generated
Normal file
71
chain/actors/builtin/system/v10.go
generated
Normal file
@ -0,0 +1,71 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
system10 "github.com/filecoin-project/go-state-types/builtin/v10/system"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, builtinActors cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
out.State = system10.State{
|
||||
BuiltinActors: builtinActors,
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
system10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) GetBuiltinActors() cid.Cid {
|
||||
|
||||
return s.State.BuiltinActors
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) SetBuiltinActors(c cid.Cid) error {
|
||||
|
||||
s.State.BuiltinActors = c
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.SystemKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
@ -78,10 +78,10 @@ type State interface {
|
||||
RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error)
|
||||
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
|
||||
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
|
||||
GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
|
||||
GetAllocations(clientIdAddr address.Address) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error)
|
||||
GetClaim(providerIdAddr address.Address, claimId verifregtypes.ClaimId) (*verifregtypes.Claim, bool, error)
|
||||
GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)
|
||||
GetAllocation(clientIdAddr address.Address, allocationId AllocationId) (*Allocation, bool, error)
|
||||
GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error)
|
||||
GetClaim(providerIdAddr address.Address, claimId ClaimId) (*Claim, bool, error)
|
||||
GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error)
|
||||
GetState() interface{}
|
||||
}
|
||||
|
||||
@ -91,3 +91,8 @@ func AllCodes() []cid.Cid {
|
||||
{{- end}}
|
||||
}
|
||||
}
|
||||
|
||||
type Allocation = verifregtypes.Allocation
|
||||
type AllocationId = verifregtypes.AllocationId
|
||||
type Claim = verifregtypes.Claim
|
||||
type ClaimId = verifregtypes.ClaimId
|
@ -24,6 +24,9 @@ import (
|
||||
{{end}}
|
||||
{{if (ge .v 9)}}
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
{{if (gt .v 9)}}
|
||||
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
{{end}}
|
||||
{{else}}
|
||||
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
{{end}}
|
||||
@ -118,35 +121,51 @@ func (s *state{{.v}}) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state{{.v}}) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
{{if (le .v 8)}}
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v{{.v}}")
|
||||
{{else}}
|
||||
return s.FindAllocation(s.store, clientIdAddr, allocationId)
|
||||
{{end}}
|
||||
alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg{{.v}}.AllocationId(allocationId))
|
||||
return (*Allocation)(alloc), ok, err{{end}}
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state{{.v}}) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
{{if (le .v 8)}}
|
||||
return nil, xerrors.Errorf("unsupported in actors v{{.v}}")
|
||||
{{else}}
|
||||
return s.LoadAllocationsToMap(s.store, clientIdAddr)
|
||||
v{{.v}}Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr)
|
||||
|
||||
retMap := make(map[AllocationId]Allocation, len(v{{.v}}Map))
|
||||
for k, v := range v{{.v}}Map {
|
||||
retMap[AllocationId(k)] = Allocation(v)
|
||||
}
|
||||
|
||||
return retMap, err
|
||||
{{end}}
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state{{.v}}) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
{{if (le .v 8)}}
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v{{.v}}")
|
||||
{{else}}
|
||||
return s.FindClaim(s.store, providerIdAddr, claimId)
|
||||
claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg{{.v}}.ClaimId(claimId))
|
||||
return (*Claim)(claim), ok, err
|
||||
{{end}}
|
||||
}
|
||||
|
||||
func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
{{if (le .v 8)}}
|
||||
return nil, xerrors.Errorf("unsupported in actors v{{.v}}")
|
||||
{{else}}
|
||||
return s.LoadClaimsToMap(s.store, providerIdAddr)
|
||||
v{{.v}}Map, err := s.LoadClaimsToMap(s.store, providerIdAddr)
|
||||
|
||||
retMap := make(map[ClaimId]Claim, len(v{{.v}}Map))
|
||||
for k, v := range v{{.v}}Map {
|
||||
retMap[ClaimId(k)] = Claim(v)
|
||||
}
|
||||
|
||||
return retMap, err
|
||||
|
||||
{{end}}
|
||||
}
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v0.go
generated
8
chain/actors/builtin/verifreg/v0.go
generated
@ -93,25 +93,25 @@ func (s *state0) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state0) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state0) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v0")
|
||||
|
||||
}
|
||||
|
||||
func (s *state0) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state0) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v0")
|
||||
|
||||
}
|
||||
|
||||
func (s *state0) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state0) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v0")
|
||||
|
||||
}
|
||||
|
||||
func (s *state0) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state0) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v0")
|
||||
|
||||
|
151
chain/actors/builtin/verifreg/v10.go
generated
Normal file
151
chain/actors/builtin/verifreg/v10.go
generated
Normal file
@ -0,0 +1,151 @@
|
||||
package verifreg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
adt10 "github.com/filecoin-project/go-state-types/builtin/v10/util/adt"
|
||||
verifreg10 "github.com/filecoin-project/go-state-types/builtin/v10/verifreg"
|
||||
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state10)(nil)
|
||||
|
||||
func load10(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state10{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make10(store adt.Store, rootKeyAddress address.Address) (State, error) {
|
||||
out := state10{store: store}
|
||||
|
||||
s, err := verifreg10.ConstructState(store, rootKeyAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state10 struct {
|
||||
verifreg10.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state10) RootKey() (address.Address, error) {
|
||||
return s.State.RootKey, nil
|
||||
}
|
||||
|
||||
func (s *state10) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||
|
||||
return false, big.Zero(), xerrors.Errorf("unsupported in actors v10")
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||
return getDataCap(s.store, actors.Version10, s.verifiers, addr)
|
||||
}
|
||||
|
||||
func (s *state10) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) {
|
||||
return getRemoveDataCapProposalID(s.store, actors.Version10, s.removeDataCapProposalIDs, verifier, client)
|
||||
}
|
||||
|
||||
func (s *state10) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||
return forEachCap(s.store, actors.Version10, s.verifiers, cb)
|
||||
}
|
||||
|
||||
func (s *state10) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||
|
||||
return xerrors.Errorf("unsupported in actors v10")
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) verifiedClients() (adt.Map, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v10")
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) verifiers() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.Verifiers, builtin10.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) removeDataCapProposalIDs() (adt.Map, error) {
|
||||
return adt10.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin10.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state10) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state10) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg10.AllocationId(allocationId))
|
||||
return (*Allocation)(alloc), ok, err
|
||||
}
|
||||
|
||||
func (s *state10) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
v10Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr)
|
||||
|
||||
retMap := make(map[AllocationId]Allocation, len(v10Map))
|
||||
for k, v := range v10Map {
|
||||
retMap[AllocationId(k)] = Allocation(v)
|
||||
}
|
||||
|
||||
return retMap, err
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg10.ClaimId(claimId))
|
||||
return (*Claim)(claim), ok, err
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
v10Map, err := s.LoadClaimsToMap(s.store, providerIdAddr)
|
||||
|
||||
retMap := make(map[ClaimId]Claim, len(v10Map))
|
||||
for k, v := range v10Map {
|
||||
retMap[ClaimId(k)] = Claim(v)
|
||||
}
|
||||
|
||||
return retMap, err
|
||||
|
||||
}
|
||||
|
||||
func (s *state10) ActorKey() string {
|
||||
return actors.VerifregKey
|
||||
}
|
||||
|
||||
func (s *state10) ActorVersion() actorstypes.Version {
|
||||
return actorstypes.Version10
|
||||
}
|
||||
|
||||
func (s *state10) Code() cid.Cid {
|
||||
code, ok := actors.GetActorCodeID(s.ActorVersion(), s.ActorKey())
|
||||
if !ok {
|
||||
panic(fmt.Errorf("didn't find actor %v code id for actor version %d", s.ActorKey(), s.ActorVersion()))
|
||||
}
|
||||
|
||||
return code
|
||||
}
|
8
chain/actors/builtin/verifreg/v2.go
generated
8
chain/actors/builtin/verifreg/v2.go
generated
@ -93,25 +93,25 @@ func (s *state2) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state2) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state2) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v2")
|
||||
|
||||
}
|
||||
|
||||
func (s *state2) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state2) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v2")
|
||||
|
||||
}
|
||||
|
||||
func (s *state2) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state2) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v2")
|
||||
|
||||
}
|
||||
|
||||
func (s *state2) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state2) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v2")
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v3.go
generated
8
chain/actors/builtin/verifreg/v3.go
generated
@ -94,25 +94,25 @@ func (s *state3) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state3) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state3) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v3")
|
||||
|
||||
}
|
||||
|
||||
func (s *state3) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state3) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v3")
|
||||
|
||||
}
|
||||
|
||||
func (s *state3) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state3) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v3")
|
||||
|
||||
}
|
||||
|
||||
func (s *state3) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state3) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v3")
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v4.go
generated
8
chain/actors/builtin/verifreg/v4.go
generated
@ -94,25 +94,25 @@ func (s *state4) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state4) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state4) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v4")
|
||||
|
||||
}
|
||||
|
||||
func (s *state4) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state4) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v4")
|
||||
|
||||
}
|
||||
|
||||
func (s *state4) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state4) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v4")
|
||||
|
||||
}
|
||||
|
||||
func (s *state4) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state4) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v4")
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v5.go
generated
8
chain/actors/builtin/verifreg/v5.go
generated
@ -94,25 +94,25 @@ func (s *state5) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state5) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state5) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v5")
|
||||
|
||||
}
|
||||
|
||||
func (s *state5) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state5) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v5")
|
||||
|
||||
}
|
||||
|
||||
func (s *state5) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state5) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v5")
|
||||
|
||||
}
|
||||
|
||||
func (s *state5) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state5) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v5")
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v6.go
generated
8
chain/actors/builtin/verifreg/v6.go
generated
@ -94,25 +94,25 @@ func (s *state6) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state6) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state6) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v6")
|
||||
|
||||
}
|
||||
|
||||
func (s *state6) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state6) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v6")
|
||||
|
||||
}
|
||||
|
||||
func (s *state6) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state6) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v6")
|
||||
|
||||
}
|
||||
|
||||
func (s *state6) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state6) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v6")
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v7.go
generated
8
chain/actors/builtin/verifreg/v7.go
generated
@ -93,25 +93,25 @@ func (s *state7) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state7) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state7) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v7")
|
||||
|
||||
}
|
||||
|
||||
func (s *state7) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state7) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v7")
|
||||
|
||||
}
|
||||
|
||||
func (s *state7) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state7) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v7")
|
||||
|
||||
}
|
||||
|
||||
func (s *state7) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state7) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v7")
|
||||
|
||||
|
8
chain/actors/builtin/verifreg/v8.go
generated
8
chain/actors/builtin/verifreg/v8.go
generated
@ -93,25 +93,25 @@ func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state8) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state8) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v8")
|
||||
|
||||
}
|
||||
|
||||
func (s *state8) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state8) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v8")
|
||||
|
||||
}
|
||||
|
||||
func (s *state8) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state8) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return nil, false, xerrors.Errorf("unsupported in actors v8")
|
||||
|
||||
}
|
||||
|
||||
func (s *state8) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
func (s *state8) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return nil, xerrors.Errorf("unsupported in actors v8")
|
||||
|
||||
|
35
chain/actors/builtin/verifreg/v9.go
generated
35
chain/actors/builtin/verifreg/v9.go
generated
@ -93,27 +93,42 @@ func (s *state9) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state9) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*verifreg9.Allocation, bool, error) {
|
||||
func (s *state9) GetAllocation(clientIdAddr address.Address, allocationId verifreg9.AllocationId) (*Allocation, bool, error) {
|
||||
|
||||
return s.FindAllocation(s.store, clientIdAddr, allocationId)
|
||||
alloc, ok, err := s.FindAllocation(s.store, clientIdAddr, verifreg9.AllocationId(allocationId))
|
||||
return (*Allocation)(alloc), ok, err
|
||||
}
|
||||
|
||||
func (s *state9) GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error) {
|
||||
|
||||
v9Map, err := s.LoadAllocationsToMap(s.store, clientIdAddr)
|
||||
|
||||
retMap := make(map[AllocationId]Allocation, len(v9Map))
|
||||
for k, v := range v9Map {
|
||||
retMap[AllocationId(k)] = Allocation(v)
|
||||
}
|
||||
|
||||
return retMap, err
|
||||
|
||||
}
|
||||
|
||||
func (s *state9) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
|
||||
func (s *state9) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*Claim, bool, error) {
|
||||
|
||||
return s.LoadAllocationsToMap(s.store, clientIdAddr)
|
||||
claim, ok, err := s.FindClaim(s.store, providerIdAddr, verifreg9.ClaimId(claimId))
|
||||
return (*Claim)(claim), ok, err
|
||||
|
||||
}
|
||||
|
||||
func (s *state9) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
|
||||
func (s *state9) GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error) {
|
||||
|
||||
return s.FindClaim(s.store, providerIdAddr, claimId)
|
||||
v9Map, err := s.LoadClaimsToMap(s.store, providerIdAddr)
|
||||
|
||||
}
|
||||
retMap := make(map[ClaimId]Claim, len(v9Map))
|
||||
for k, v := range v9Map {
|
||||
retMap[ClaimId(k)] = Claim(v)
|
||||
}
|
||||
|
||||
func (s *state9) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
|
||||
|
||||
return s.LoadClaimsToMap(s.store, providerIdAddr)
|
||||
return retMap, err
|
||||
|
||||
}
|
||||
|
||||
|
26
chain/actors/builtin/verifreg/verifreg.go
generated
26
chain/actors/builtin/verifreg/verifreg.go
generated
@ -7,7 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
@ -24,8 +24,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin9.VerifiedRegistryActorAddr
|
||||
Methods = builtin9.MethodsVerifiedRegistry
|
||||
Address = builtin10.VerifiedRegistryActorAddr
|
||||
Methods = builtin10.MethodsVerifiedRegistry
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
@ -42,6 +42,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case actorstypes.Version9:
|
||||
return load9(store, act.Head)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return load10(store, act.Head)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +106,9 @@ func MakeState(store adt.Store, av actorstypes.Version, rootKeyAddress address.A
|
||||
case actorstypes.Version9:
|
||||
return make9(store, rootKeyAddress)
|
||||
|
||||
case actorstypes.Version10:
|
||||
return make10(store, rootKeyAddress)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -120,10 +126,10 @@ type State interface {
|
||||
RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error)
|
||||
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
|
||||
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
|
||||
GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
|
||||
GetAllocations(clientIdAddr address.Address) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error)
|
||||
GetClaim(providerIdAddr address.Address, claimId verifregtypes.ClaimId) (*verifregtypes.Claim, bool, error)
|
||||
GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)
|
||||
GetAllocation(clientIdAddr address.Address, allocationId AllocationId) (*Allocation, bool, error)
|
||||
GetAllocations(clientIdAddr address.Address) (map[AllocationId]Allocation, error)
|
||||
GetClaim(providerIdAddr address.Address, claimId ClaimId) (*Claim, bool, error)
|
||||
GetClaims(providerIdAddr address.Address) (map[ClaimId]Claim, error)
|
||||
GetState() interface{}
|
||||
}
|
||||
|
||||
@ -138,5 +144,11 @@ func AllCodes() []cid.Cid {
|
||||
(&state7{}).Code(),
|
||||
(&state8{}).Code(),
|
||||
(&state9{}).Code(),
|
||||
(&state10{}).Code(),
|
||||
}
|
||||
}
|
||||
|
||||
type Allocation = verifregtypes.Allocation
|
||||
type AllocationId = verifregtypes.AllocationId
|
||||
type Claim = verifregtypes.Claim
|
||||
type ClaimId = verifregtypes.ClaimId
|
||||
|
@ -32,6 +32,9 @@ const (
|
||||
SystemKey = "system"
|
||||
VerifregKey = "verifiedregistry"
|
||||
DatacapKey = "datacap"
|
||||
EvmKey = "evm"
|
||||
EamKey = "eam"
|
||||
EmbryoKey = "embryo"
|
||||
)
|
||||
|
||||
func GetBuiltinActorsKeys(av actorstypes.Version) []string {
|
||||
@ -51,6 +54,9 @@ func GetBuiltinActorsKeys(av actorstypes.Version) []string {
|
||||
if av >= 9 {
|
||||
keys = append(keys, DatacapKey)
|
||||
}
|
||||
if av >= 10 {
|
||||
keys = append(keys, EvmKey, EamKey, EmbryoKey)
|
||||
}
|
||||
return keys
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,18 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
builtin10 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin8 "github.com/filecoin-project/go-state-types/builtin"
|
||||
builtin9 "github.com/filecoin-project/go-state-types/builtin"
|
||||
market10 "github.com/filecoin-project/go-state-types/builtin/v10/market"
|
||||
miner10 "github.com/filecoin-project/go-state-types/builtin/v10/miner"
|
||||
paych10 "github.com/filecoin-project/go-state-types/builtin/v10/paych"
|
||||
verifreg10 "github.com/filecoin-project/go-state-types/builtin/v10/verifreg"
|
||||
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||
miner8 "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
verifreg8 "github.com/filecoin-project/go-state-types/builtin/v8/verifreg"
|
||||
market9 "github.com/filecoin-project/go-state-types/builtin/v9/market"
|
||||
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
paych9 "github.com/filecoin-project/go-state-types/builtin/v9/paych"
|
||||
verifreg9 "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
@ -47,10 +51,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ChainFinality = miner9.ChainFinality
|
||||
ChainFinality = miner10.ChainFinality
|
||||
SealRandomnessLookback = ChainFinality
|
||||
PaychSettleDelay = paych9.SettleDelay
|
||||
MaxPreCommitRandomnessLookback = builtin9.EpochsInDay + SealRandomnessLookback
|
||||
PaychSettleDelay = paych10.SettleDelay
|
||||
MaxPreCommitRandomnessLookback = builtin10.EpochsInDay + SealRandomnessLookback
|
||||
)
|
||||
|
||||
// SetSupportedProofTypes sets supported proof types, across all actor versions.
|
||||
@ -159,11 +163,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
|
||||
|
||||
miner9.PreCommitChallengeDelay = delay
|
||||
|
||||
miner10.PreCommitChallengeDelay = delay
|
||||
|
||||
}
|
||||
|
||||
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
|
||||
func GetPreCommitChallengeDelay() abi.ChainEpoch {
|
||||
return miner9.PreCommitChallengeDelay
|
||||
return miner10.PreCommitChallengeDelay
|
||||
}
|
||||
|
||||
// SetConsensusMinerMinPower sets the minimum power of an individual miner must
|
||||
@ -205,6 +211,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) {
|
||||
policy.ConsensusMinerMinPower = p
|
||||
}
|
||||
|
||||
for _, policy := range builtin10.PoStProofPolicies {
|
||||
policy.ConsensusMinerMinPower = p
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
|
||||
@ -229,6 +239,8 @@ func SetMinVerifiedDealSize(size abi.StoragePower) {
|
||||
|
||||
verifreg9.MinVerifiedDealSize = size
|
||||
|
||||
verifreg10.MinVerifiedDealSize = size
|
||||
|
||||
}
|
||||
|
||||
func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) {
|
||||
@ -270,6 +282,10 @@ func GetMaxProveCommitDuration(ver actorstypes.Version, t abi.RegisteredSealProo
|
||||
|
||||
return miner9.MaxProveCommitDuration[t], nil
|
||||
|
||||
case actorstypes.Version10:
|
||||
|
||||
return miner10.MaxProveCommitDuration[t], nil
|
||||
|
||||
default:
|
||||
return 0, xerrors.Errorf("unsupported actors version")
|
||||
}
|
||||
@ -320,6 +336,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) {
|
||||
Denominator: denom,
|
||||
}
|
||||
|
||||
market10.ProviderCollateralSupplyTarget = builtin10.BigFrac{
|
||||
Numerator: num,
|
||||
Denominator: denom,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func DealProviderCollateralBounds(
|
||||
@ -378,13 +399,18 @@ func DealProviderCollateralBounds(
|
||||
min, max := market9.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
|
||||
return min, max, nil
|
||||
|
||||
case actorstypes.Version10:
|
||||
|
||||
min, max := market10.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
|
||||
return min, max, nil
|
||||
|
||||
default:
|
||||
return big.Zero(), big.Zero(), xerrors.Errorf("unsupported actors version")
|
||||
}
|
||||
}
|
||||
|
||||
func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) {
|
||||
return market9.DealDurationBounds(pieceSize)
|
||||
return market10.DealDurationBounds(pieceSize)
|
||||
}
|
||||
|
||||
// Sets the challenge window and scales the proving period to match (such that
|
||||
@ -446,6 +472,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) {
|
||||
// scale it if we're scaling the challenge period.
|
||||
miner9.WPoStDisputeWindow = period * 30
|
||||
|
||||
miner10.WPoStChallengeWindow = period
|
||||
miner10.WPoStProvingPeriod = period * abi.ChainEpoch(miner10.WPoStPeriodDeadlines)
|
||||
|
||||
// by default, this is 2x finality which is 30 periods.
|
||||
// scale it if we're scaling the challenge period.
|
||||
miner10.WPoStDisputeWindow = period * 30
|
||||
|
||||
}
|
||||
|
||||
func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
|
||||
@ -458,15 +491,15 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
|
||||
}
|
||||
|
||||
func GetMaxSectorExpirationExtension() abi.ChainEpoch {
|
||||
return miner9.MaxSectorExpirationExtension
|
||||
return miner10.MaxSectorExpirationExtension
|
||||
}
|
||||
|
||||
func GetMinSectorExpiration() abi.ChainEpoch {
|
||||
return miner9.MinSectorExpiration
|
||||
return miner10.MinSectorExpiration
|
||||
}
|
||||
|
||||
func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) {
|
||||
sectorsPerPart, err := builtin9.PoStProofWindowPoStPartitionSectors(p)
|
||||
sectorsPerPart, err := builtin10.PoStProofWindowPoStPartitionSectors(p)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -486,7 +519,7 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version)
|
||||
return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime
|
||||
}
|
||||
|
||||
return builtin9.SealProofPoliciesV11[proof].SectorMaxLifetime
|
||||
return builtin10.SealProofPoliciesV11[proof].SectorMaxLifetime
|
||||
}
|
||||
|
||||
func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
|
||||
@ -523,6 +556,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
|
||||
case actorstypes.Version9:
|
||||
return miner9.AddressedSectorsMax, nil
|
||||
|
||||
case actorstypes.Version10:
|
||||
return miner10.AddressedSectorsMax, nil
|
||||
|
||||
default:
|
||||
return 0, xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
@ -572,6 +608,10 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) {
|
||||
|
||||
return miner9.DeclarationsMax, nil
|
||||
|
||||
case actorstypes.Version10:
|
||||
|
||||
return miner10.DeclarationsMax, nil
|
||||
|
||||
default:
|
||||
return 0, xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
@ -620,6 +660,10 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba
|
||||
|
||||
return miner9.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
case actorstypes.Version10:
|
||||
|
||||
return miner10.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
default:
|
||||
return big.Zero(), xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
@ -668,6 +712,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base
|
||||
|
||||
return miner9.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
case actorstypes.Version10:
|
||||
|
||||
return miner10.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
default:
|
||||
return big.Zero(), xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
|
@ -14,20 +14,21 @@ const ({{range .actorVersions}}
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
var LatestVersion = 9
|
||||
var LatestVersion = 10
|
||||
|
||||
var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8, 9, 10}
|
||||
|
||||
const (
|
||||
Version0 Version = 0
|
||||
Version2 Version = 2
|
||||
Version3 Version = 3
|
||||
Version4 Version = 4
|
||||
Version5 Version = 5
|
||||
Version6 Version = 6
|
||||
Version7 Version = 7
|
||||
Version8 Version = 8
|
||||
Version9 Version = 9
|
||||
Version0 Version = 0
|
||||
Version2 Version = 2
|
||||
Version3 Version = 3
|
||||
Version4 Version = 4
|
||||
Version5 Version = 5
|
||||
Version6 Version = 6
|
||||
Version7 Version = 7
|
||||
Version8 Version = 8
|
||||
Version9 Version = 9
|
||||
Version10 Version = 10
|
||||
)
|
||||
|
||||
/* inline-gen end */
|
||||
|
@ -48,6 +48,7 @@ func NewActorRegistry() *vm.ActorRegistry {
|
||||
inv.Register(actorstypes.Version7, vm.ActorsVersionPredicate(actorstypes.Version7), builtin.MakeRegistryLegacy(exported7.BuiltinActors()))
|
||||
inv.Register(actorstypes.Version8, vm.ActorsVersionPredicate(actorstypes.Version8), builtin.MakeRegistry(actorstypes.Version8))
|
||||
inv.Register(actorstypes.Version9, vm.ActorsVersionPredicate(actorstypes.Version9), builtin.MakeRegistry(actorstypes.Version9))
|
||||
inv.Register(actorstypes.Version10, vm.ActorsVersionPredicate(actorstypes.Version10), builtin.MakeRegistry(actorstypes.Version10))
|
||||
|
||||
return inv
|
||||
}
|
||||
|
@ -208,6 +208,7 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
|
||||
}},
|
||||
Expensive: true,
|
||||
},
|
||||
// TODO v10 upgrade
|
||||
}
|
||||
|
||||
for _, u := range updates {
|
||||
@ -1552,6 +1553,15 @@ func upgradeActorsV9Common(
|
||||
return newRoot, nil
|
||||
}
|
||||
|
||||
func UpgradeActorsV10(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor,
|
||||
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||
|
||||
// TODO migration
|
||||
// - the init actor state to include the (empty) installed actors field
|
||||
// - state tree migration to v5
|
||||
return cid.Undef, fmt.Errorf("IMPLEMENTME: v10 migration")
|
||||
}
|
||||
|
||||
// Example upgrade function if upgrade requires only code changes
|
||||
//func UpgradeActorsV9(ctx context.Context, sm *stmgr.StateManager, _ stmgr.MigrationCache, _ stmgr.ExecMonitor, root cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) (cid.Cid, error) {
|
||||
// buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync())
|
||||
|
@ -29,7 +29,7 @@ func Weight(ctx context.Context, stateBs bstore.Blockstore, ts *types.TipSet) (t
|
||||
|
||||
// >>> wFunction(totalPowerAtTipset(ts)) * 2^8 <<< + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
|
||||
|
||||
tpow := big2.Zero()
|
||||
var tpow big2.Int
|
||||
{
|
||||
cst := cbor.NewCborStore(stateBs)
|
||||
state, err := state.LoadStateTree(cst, ts.ParentState())
|
||||
|
@ -389,6 +389,7 @@ func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actorstypes.Ve
|
||||
Code: actcid,
|
||||
Head: statecid,
|
||||
Balance: bal,
|
||||
Address: &addr,
|
||||
}
|
||||
|
||||
return act, nil
|
||||
|
@ -105,7 +105,7 @@ func TestFundManagerBasic(t *testing.T) {
|
||||
// Note: Expect failure because there is no available balance to withdraw:
|
||||
// balance - reserved = 16 - 16 = 0
|
||||
amt = abi.NewTokenAmount(1)
|
||||
sentinel, err = s.fm.Withdraw(s.ctx, s.walletAddr, s.acctAddr, amt)
|
||||
_, err = s.fm.Withdraw(s.ctx, s.walletAddr, s.acctAddr, amt)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
|
@ -219,6 +219,7 @@ func CapGasFee(mff dtypes.DefaultMaxFeeFunc, msg *types.Message, sendSpec *api.M
|
||||
totalFee := types.BigMul(msg.GasFeeCap, gl)
|
||||
|
||||
if totalFee.LessThanEqual(maxFee) {
|
||||
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1081,3 +1081,40 @@ func TestRemoveMessage(t *testing.T) {
|
||||
assert.Len(t, msgs, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCapGasFee(t *testing.T) {
|
||||
t.Run("use default maxfee", func(t *testing.T) {
|
||||
msg := &types.Message{
|
||||
GasLimit: 100_000_000,
|
||||
GasFeeCap: abi.NewTokenAmount(100_000_000),
|
||||
GasPremium: abi.NewTokenAmount(100_000),
|
||||
}
|
||||
CapGasFee(func() (abi.TokenAmount, error) {
|
||||
return abi.NewTokenAmount(100_000_000_000), nil
|
||||
}, msg, nil)
|
||||
assert.Equal(t, msg.GasFeeCap.Int64(), int64(1000))
|
||||
assert.Equal(t, msg.GasPremium.Int.Int64(), int64(1000))
|
||||
})
|
||||
|
||||
t.Run("use spec maxfee", func(t *testing.T) {
|
||||
msg := &types.Message{
|
||||
GasLimit: 100_000_000,
|
||||
GasFeeCap: abi.NewTokenAmount(100_000_000),
|
||||
GasPremium: abi.NewTokenAmount(100_000),
|
||||
}
|
||||
CapGasFee(nil, msg, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(100_000_000_000)})
|
||||
assert.Equal(t, msg.GasFeeCap.Int64(), int64(1000))
|
||||
assert.Equal(t, msg.GasPremium.Int.Int64(), int64(1000))
|
||||
})
|
||||
|
||||
t.Run("use smaller feecap value when fee is enough", func(t *testing.T) {
|
||||
msg := &types.Message{
|
||||
GasLimit: 100_000_000,
|
||||
GasFeeCap: abi.NewTokenAmount(100_000),
|
||||
GasPremium: abi.NewTokenAmount(100_000_000),
|
||||
}
|
||||
CapGasFee(nil, msg, &api.MessageSendSpec{MaxFee: abi.NewTokenAmount(100_000_000_000_000)})
|
||||
assert.Equal(t, msg.GasFeeCap.Int64(), int64(100_000))
|
||||
assert.Equal(t, msg.GasPremium.Int.Int64(), int64(100_000))
|
||||
})
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
builtin_types "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
states0 "github.com/filecoin-project/specs-actors/actors/states"
|
||||
states2 "github.com/filecoin-project/specs-actors/v2/actors/states"
|
||||
@ -152,16 +153,12 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) {
|
||||
case network.Version12:
|
||||
return types.StateTreeVersion3, nil
|
||||
|
||||
/* inline-gen template
|
||||
{{$lastNv := .latestNetworkVersion}}
|
||||
case{{range .networkVersions}} {{if (ge . 13.)}} network.Version{{.}}{{if (lt . $lastNv)}},{{end}}{{end}}{{end}}:
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
case network.Version13, network.Version14, network.Version15, network.Version16, network.Version17:
|
||||
|
||||
/* inline-gen end */
|
||||
return types.StateTreeVersion4, nil
|
||||
|
||||
case network.Version18:
|
||||
return types.StateTreeVersion5, nil
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported network version %d", ver))
|
||||
}
|
||||
@ -172,7 +169,7 @@ func NewStateTree(cst cbor.IpldStore, ver types.StateTreeVersion) (*StateTree, e
|
||||
switch ver {
|
||||
case types.StateTreeVersion0:
|
||||
// info is undefined
|
||||
case types.StateTreeVersion1, types.StateTreeVersion2, types.StateTreeVersion3, types.StateTreeVersion4:
|
||||
case types.StateTreeVersion1, types.StateTreeVersion2, types.StateTreeVersion3, types.StateTreeVersion4, types.StateTreeVersion5:
|
||||
var err error
|
||||
info, err = cst.Put(context.TODO(), new(types.StateInfo0))
|
||||
if err != nil {
|
||||
@ -215,6 +212,13 @@ func NewStateTree(cst cbor.IpldStore, ver types.StateTreeVersion) (*StateTree, e
|
||||
return nil, xerrors.Errorf("failed to create state tree: %w", err)
|
||||
}
|
||||
hamt = tree.Map
|
||||
case types.StateTreeVersion5:
|
||||
tree, err := builtin_types.NewTree(store)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to create state tree: %w", err)
|
||||
}
|
||||
hamt = tree.Map
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unsupported state tree version: %d", ver)
|
||||
}
|
||||
@ -276,6 +280,13 @@ func LoadStateTree(cst cbor.IpldStore, c cid.Cid) (*StateTree, error) {
|
||||
if tree != nil {
|
||||
hamt = tree.Map
|
||||
}
|
||||
case types.StateTreeVersion5:
|
||||
var tree *builtin_types.ActorTree
|
||||
tree, err = builtin_types.LoadTree(store, root.Actors)
|
||||
if tree != nil {
|
||||
hamt = tree.Map
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unsupported state tree version: %d", root.Version)
|
||||
}
|
||||
@ -374,7 +385,17 @@ func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) {
|
||||
}
|
||||
|
||||
var act types.Actor
|
||||
if found, err := st.root.Get(abi.AddrKey(addr), &act); err != nil {
|
||||
var found bool
|
||||
if st.version <= types.StateTreeVersion4 {
|
||||
var act4 types.ActorV4
|
||||
found, err = st.root.Get(abi.AddrKey(addr), &act4)
|
||||
if found {
|
||||
act = *types.AsActorV5(&act4)
|
||||
}
|
||||
} else {
|
||||
found, err = st.root.Get(abi.AddrKey(addr), &act)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("hamt find failed: %w", err)
|
||||
} else if !found {
|
||||
return nil, types.ErrActorNotFound
|
||||
@ -423,8 +444,15 @@ func (st *StateTree) Flush(ctx context.Context) (cid.Cid, error) {
|
||||
return cid.Undef, err
|
||||
}
|
||||
} else {
|
||||
if err := st.root.Put(abi.AddrKey(addr), &sto.Act); err != nil {
|
||||
return cid.Undef, err
|
||||
if st.version <= types.StateTreeVersion4 {
|
||||
act4 := types.AsActorV4(&sto.Act)
|
||||
if err := st.root.Put(abi.AddrKey(addr), act4); err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
} else {
|
||||
if err := st.root.Put(abi.AddrKey(addr), &sto.Act); err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -532,6 +560,25 @@ func (st *StateTree) ForEach(f func(address.Address, *types.Actor) error) error
|
||||
}
|
||||
|
||||
// Now walk through the saved actors.
|
||||
if st.version <= types.StateTreeVersion4 {
|
||||
var act types.ActorV4
|
||||
return st.root.ForEach(&act, func(k string) error {
|
||||
act := act // copy
|
||||
addr, err := address.NewFromBytes([]byte(k))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("invalid address (%x) found in state tree key: %w", []byte(k), err)
|
||||
}
|
||||
|
||||
// no need to record anything here, there are no duplicates in the actors HAMT
|
||||
// iself.
|
||||
if _, ok := seen[addr]; ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
return f(addr, types.AsActorV5(&act))
|
||||
})
|
||||
}
|
||||
|
||||
var act types.Actor
|
||||
return st.root.ForEach(&act, func(k string) error {
|
||||
act := act // copy
|
||||
@ -567,8 +614,6 @@ func Diff(ctx context.Context, oldTree, newTree *StateTree) (map[string]types.Ac
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
var act types.Actor
|
||||
|
||||
addr, err := address.NewFromBytes([]byte(k))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("address in state tree was not valid: %w", err)
|
||||
@ -583,16 +628,33 @@ func Diff(ctx context.Context, oldTree, newTree *StateTree) (map[string]types.Ac
|
||||
return nil // not changed
|
||||
}
|
||||
|
||||
buf.Reset(ncval.Raw)
|
||||
err = act.UnmarshalCBOR(buf)
|
||||
buf.Reset(nil)
|
||||
if newTree.version <= types.StateTreeVersion4 {
|
||||
var act types.ActorV4
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
buf.Reset(ncval.Raw)
|
||||
err = act.UnmarshalCBOR(buf)
|
||||
buf.Reset(nil)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out[addr.String()] = *types.AsActorV5(&act)
|
||||
|
||||
} else {
|
||||
var act types.Actor
|
||||
|
||||
buf.Reset(ncval.Raw)
|
||||
err = act.UnmarshalCBOR(buf)
|
||||
buf.Reset(nil)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out[addr.String()] = act
|
||||
}
|
||||
|
||||
out[addr.String()] = act
|
||||
|
||||
return nil
|
||||
}
|
||||
}); err != nil {
|
||||
|
@ -4,14 +4,48 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
)
|
||||
|
||||
var ErrActorNotFound = errors.New("actor not found")
|
||||
|
||||
type Actor struct {
|
||||
// Actor State for state tree version up to 4
|
||||
type ActorV4 struct {
|
||||
// Identifies the type of actor (string coded as a CID), see `chain/actors/actors.go`.
|
||||
Code cid.Cid
|
||||
Head cid.Cid
|
||||
Nonce uint64
|
||||
Balance BigInt
|
||||
}
|
||||
|
||||
// Actor State for state tree version 5
|
||||
type ActorV5 struct {
|
||||
// Identifies the type of actor (string coded as a CID), see `chain/actors/actors.go`.
|
||||
Code cid.Cid
|
||||
Head cid.Cid
|
||||
Nonce uint64
|
||||
Balance BigInt
|
||||
// Predictable Address
|
||||
Address *address.Address
|
||||
}
|
||||
|
||||
type Actor = ActorV5
|
||||
|
||||
func AsActorV4(a *ActorV5) *ActorV4 {
|
||||
return &ActorV4{
|
||||
Code: a.Code,
|
||||
Head: a.Head,
|
||||
Nonce: a.Nonce,
|
||||
Balance: a.Balance,
|
||||
}
|
||||
}
|
||||
|
||||
func AsActorV5(a *ActorV4) *ActorV5 {
|
||||
return &ActorV5{
|
||||
Code: a.Code,
|
||||
Head: a.Head,
|
||||
Nonce: a.Nonce,
|
||||
Balance: a.Balance,
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
xerrors "golang.org/x/xerrors"
|
||||
|
||||
address "github.com/filecoin-project/go-address"
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
crypto "github.com/filecoin-project/go-state-types/crypto"
|
||||
exitcode "github.com/filecoin-project/go-state-types/exitcode"
|
||||
@ -1040,9 +1041,9 @@ func (t *MsgMeta) UnmarshalCBOR(r io.Reader) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var lengthBufActor = []byte{132}
|
||||
var lengthBufActorV4 = []byte{132}
|
||||
|
||||
func (t *Actor) MarshalCBOR(w io.Writer) error {
|
||||
func (t *ActorV4) MarshalCBOR(w io.Writer) error {
|
||||
if t == nil {
|
||||
_, err := w.Write(cbg.CborNull)
|
||||
return err
|
||||
@ -1050,7 +1051,7 @@ func (t *Actor) MarshalCBOR(w io.Writer) error {
|
||||
|
||||
cw := cbg.NewCborWriter(w)
|
||||
|
||||
if _, err := cw.Write(lengthBufActor); err != nil {
|
||||
if _, err := cw.Write(lengthBufActorV4); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -1079,8 +1080,8 @@ func (t *Actor) MarshalCBOR(w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Actor) UnmarshalCBOR(r io.Reader) (err error) {
|
||||
*t = Actor{}
|
||||
func (t *ActorV4) UnmarshalCBOR(r io.Reader) (err error) {
|
||||
*t = ActorV4{}
|
||||
|
||||
cr := cbg.NewCborReader(r)
|
||||
|
||||
@ -1152,6 +1153,142 @@ func (t *Actor) UnmarshalCBOR(r io.Reader) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
var lengthBufActorV5 = []byte{133}
|
||||
|
||||
func (t *ActorV5) MarshalCBOR(w io.Writer) error {
|
||||
if t == nil {
|
||||
_, err := w.Write(cbg.CborNull)
|
||||
return err
|
||||
}
|
||||
|
||||
cw := cbg.NewCborWriter(w)
|
||||
|
||||
if _, err := cw.Write(lengthBufActorV5); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.Code (cid.Cid) (struct)
|
||||
|
||||
if err := cbg.WriteCid(cw, t.Code); err != nil {
|
||||
return xerrors.Errorf("failed to write cid field t.Code: %w", err)
|
||||
}
|
||||
|
||||
// t.Head (cid.Cid) (struct)
|
||||
|
||||
if err := cbg.WriteCid(cw, t.Head); err != nil {
|
||||
return xerrors.Errorf("failed to write cid field t.Head: %w", err)
|
||||
}
|
||||
|
||||
// t.Nonce (uint64) (uint64)
|
||||
|
||||
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Nonce)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.Balance (big.Int) (struct)
|
||||
if err := t.Balance.MarshalCBOR(cw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.Address (address.Address) (struct)
|
||||
if err := t.Address.MarshalCBOR(cw); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *ActorV5) UnmarshalCBOR(r io.Reader) (err error) {
|
||||
*t = ActorV5{}
|
||||
|
||||
cr := cbg.NewCborReader(r)
|
||||
|
||||
maj, extra, err := cr.ReadHeader()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err == io.EOF {
|
||||
err = io.ErrUnexpectedEOF
|
||||
}
|
||||
}()
|
||||
|
||||
if maj != cbg.MajArray {
|
||||
return fmt.Errorf("cbor input should be of type array")
|
||||
}
|
||||
|
||||
if extra != 5 {
|
||||
return fmt.Errorf("cbor input had wrong number of fields")
|
||||
}
|
||||
|
||||
// t.Code (cid.Cid) (struct)
|
||||
|
||||
{
|
||||
|
||||
c, err := cbg.ReadCid(cr)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to read cid field t.Code: %w", err)
|
||||
}
|
||||
|
||||
t.Code = c
|
||||
|
||||
}
|
||||
// t.Head (cid.Cid) (struct)
|
||||
|
||||
{
|
||||
|
||||
c, err := cbg.ReadCid(cr)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to read cid field t.Head: %w", err)
|
||||
}
|
||||
|
||||
t.Head = c
|
||||
|
||||
}
|
||||
// t.Nonce (uint64) (uint64)
|
||||
|
||||
{
|
||||
|
||||
maj, extra, err = cr.ReadHeader()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if maj != cbg.MajUnsignedInt {
|
||||
return fmt.Errorf("wrong type for uint64 field")
|
||||
}
|
||||
t.Nonce = uint64(extra)
|
||||
|
||||
}
|
||||
// t.Balance (big.Int) (struct)
|
||||
|
||||
{
|
||||
|
||||
if err := t.Balance.UnmarshalCBOR(cr); err != nil {
|
||||
return xerrors.Errorf("unmarshaling t.Balance: %w", err)
|
||||
}
|
||||
|
||||
}
|
||||
// t.Address (address.Address) (struct)
|
||||
|
||||
{
|
||||
|
||||
b, err := cr.ReadByte()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if b != cbg.CborNull[0] {
|
||||
if err := cr.UnreadByte(); err != nil {
|
||||
return err
|
||||
}
|
||||
t.Address = new(address.Address)
|
||||
if err := t.Address.UnmarshalCBOR(cr); err != nil {
|
||||
return xerrors.Errorf("unmarshaling t.Address pointer: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var lengthBufMessageReceipt = []byte{131}
|
||||
|
||||
func (t *MessageReceipt) MarshalCBOR(w io.Writer) error {
|
||||
|
@ -102,7 +102,7 @@ func ParseFIL(s string) (FIL, error) {
|
||||
return FIL{}, fmt.Errorf("string length too large: %d", len(s))
|
||||
}
|
||||
|
||||
r, ok := new(big.Rat).SetString(s)
|
||||
r, ok := new(big.Rat).SetString(s) //nolint:gosec
|
||||
if !ok {
|
||||
return FIL{}, fmt.Errorf("failed to parse %q as a decimal number", s)
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ const (
|
||||
StateTreeVersion3
|
||||
// StateTreeVersion4 corresponds to actors v5 and above.
|
||||
StateTreeVersion4
|
||||
// StateTreeVersion5 corresponds to actors v10 and above.
|
||||
StateTreeVersion5
|
||||
)
|
||||
|
||||
type StateRoot struct {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user