Merge pull request #8429 from filecoin-project/vyzo/fip-0031
FIP0031 refinements
This commit is contained in:
commit
d1fd3f56a7
@ -48,6 +48,7 @@ commands:
|
||||
- run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev
|
||||
- run: git submodule sync
|
||||
- run: git submodule update --init
|
||||
- fetch_builtin_actors
|
||||
download-params:
|
||||
steps:
|
||||
- restore_cache:
|
||||
@ -83,6 +84,23 @@ commands:
|
||||
name: fetch all tags
|
||||
command: |
|
||||
git fetch --all
|
||||
fetch_builtin_actors:
|
||||
steps:
|
||||
- restore_cache:
|
||||
name: restore builtin actors bundle cache
|
||||
keys:
|
||||
- 'builtin-actors-v8.car'
|
||||
paths:
|
||||
- build/builtin-actors/
|
||||
- run:
|
||||
name: fetch builtin actor bundles
|
||||
command: |
|
||||
build/builtin-actors/fetch-bundles.sh
|
||||
- save_cache:
|
||||
name: save builtin actors bundle cache
|
||||
key: 'builtin-actors-v8.car'
|
||||
paths:
|
||||
- build/builtin-actors/
|
||||
|
||||
packer_build:
|
||||
description: "Run a packer build"
|
||||
@ -224,7 +242,7 @@ jobs:
|
||||
|
||||
test-conformance:
|
||||
description: |
|
||||
Run tests using a corpus of interoperable test vectors for Filecoin
|
||||
Run tests using a corpus of interoperable test vectors for Filecoin
|
||||
implementations to test their correctness and compliance with the Filecoin
|
||||
specifications.
|
||||
parameters:
|
||||
|
@ -48,6 +48,7 @@ commands:
|
||||
- run: sudo apt-get install ocl-icd-opencl-dev libhwloc-dev
|
||||
- run: git submodule sync
|
||||
- run: git submodule update --init
|
||||
- fetch_builtin_actors
|
||||
download-params:
|
||||
steps:
|
||||
- restore_cache:
|
||||
@ -83,6 +84,23 @@ commands:
|
||||
name: fetch all tags
|
||||
command: |
|
||||
git fetch --all
|
||||
fetch_builtin_actors:
|
||||
steps:
|
||||
- restore_cache:
|
||||
name: restore builtin actors bundle cache
|
||||
keys:
|
||||
- 'builtin-actors-v8.car'
|
||||
paths:
|
||||
- build/builtin-actors/
|
||||
- run:
|
||||
name: fetch builtin actor bundles
|
||||
command: |
|
||||
build/builtin-actors/fetch-bundles.sh
|
||||
- save_cache:
|
||||
name: save builtin actors bundle cache
|
||||
key: 'builtin-actors-v8.car'
|
||||
paths:
|
||||
- build/builtin-actors/
|
||||
|
||||
packer_build:
|
||||
description: "Run a packer build"
|
||||
@ -224,7 +242,7 @@ jobs:
|
||||
|
||||
test-conformance:
|
||||
description: |
|
||||
Run tests using a corpus of interoperable test vectors for Filecoin
|
||||
Run tests using a corpus of interoperable test vectors for Filecoin
|
||||
implementations to test their correctness and compliance with the Filecoin
|
||||
specifications.
|
||||
parameters:
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -48,3 +48,5 @@ bin/ipget
|
||||
bin/tmp/*
|
||||
.idea
|
||||
scratchpad
|
||||
|
||||
build/builtin-actors/*.car
|
||||
|
10
Makefile
10
Makefile
@ -57,6 +57,14 @@ build/.update-modules:
|
||||
|
||||
# end git modules
|
||||
|
||||
# builtin actor bundles
|
||||
builtin-actor-bundles:
|
||||
./build/builtin-actors/fetch-bundles.sh
|
||||
|
||||
BUILD_DEPS+=builtin-actor-bundles
|
||||
|
||||
.PHONY: builtin-actor-bundles
|
||||
|
||||
## MAIN BINARIES
|
||||
|
||||
CLEAN+=build/.update-modules
|
||||
@ -362,4 +370,4 @@ print-%:
|
||||
@echo $*=$($*)
|
||||
|
||||
circleci:
|
||||
go generate -x ./.circleci
|
||||
go generate -x ./.circleci
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
abinetwork "github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
"github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
|
||||
"github.com/filecoin-project/go-fil-markets/piecestore"
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
"sort"
|
||||
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
market "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
paych "github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||
market "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
xerrors "golang.org/x/xerrors"
|
||||
|
3
build/builtin-actors/README.md
Normal file
3
build/builtin-actors/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
This directory contains the builtin actors v8 bundle, to be emdedded in the binary.
|
||||
To change your actor bundle, prior to fixing for nv16 upgrade, generate a bundle using the actor
|
||||
bundler and place it in this directory, in a file named builtin-actors-v8.car
|
52
build/builtin-actors/fetch-bundles.sh
Executable file
52
build/builtin-actors/fetch-bundles.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# gateway to use
|
||||
dweb="dweb.link"
|
||||
|
||||
actors7_cid=""
|
||||
actors7_hash=""
|
||||
actors8_cid="bafybeictmywrut5tprz5fnoti6adfwuvixvrfardhqwldxosmdsfavc56e"
|
||||
actors8_hash="687b38f59b0c32800f55a8f1f303de214ec173c90e653984d67f393bc41c1416"
|
||||
|
||||
die() {
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
check() {
|
||||
file=$1
|
||||
hash=$2
|
||||
if [ -e "$file" ]; then
|
||||
echo "$hash $file" | shasum -a 256 --check
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
fetch() {
|
||||
output=$1
|
||||
cid=$2
|
||||
hash=$3
|
||||
if (check "$output" "$hash"); then
|
||||
return 0
|
||||
else
|
||||
echo "fetching $cid to $output"
|
||||
curl --retry 3 -k "https://$dweb/ipfs/$cid" -o "$output"
|
||||
check "$output" "$hash" || die "hash mismatch"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "$actors7_cid" ]; then
|
||||
fetch builtin-actors-v7.car "$actors7_cid" "$actors7_hash"
|
||||
else
|
||||
touch builtin-actors-v7.car
|
||||
fi
|
||||
|
||||
if [ -n "$actors8_cid" ]; then
|
||||
fetch builtin-actors-v8.car "$actors8_cid" "$actors8_hash"
|
||||
else
|
||||
touch builtin-actors-v8.car
|
||||
fi
|
19
build/builtin_actors.go
Normal file
19
build/builtin_actors.go
Normal file
@ -0,0 +1,19 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed builtin-actors/builtin-actors-v8.car
|
||||
var actorsv8 []byte
|
||||
|
||||
func BuiltinActorsV8Bundle() []byte {
|
||||
return actorsv8
|
||||
}
|
||||
|
||||
//go:embed builtin-actors/builtin-actors-v7.car
|
||||
var actorsv7 []byte
|
||||
|
||||
func BuiltinActorsV7Bundle() []byte {
|
||||
return actorsv7
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -48,6 +48,7 @@ var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
|
||||
var UpgradeChocolateHeight = abi.ChainEpoch(-17)
|
||||
|
||||
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(-19)
|
||||
|
||||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
@ -91,6 +92,7 @@ func init() {
|
||||
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
|
||||
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
|
||||
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
|
||||
UpgradeFVM1Height = getUpgradeHeight("LOTUS_FVM1_HEIGHT", UpgradeFVM1Height)
|
||||
|
||||
BuildType |= Build2k
|
||||
|
||||
|
@ -44,6 +44,8 @@ const UpgradeChocolateHeight = -17
|
||||
|
||||
const UpgradeOhSnapHeight = 240
|
||||
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)
|
||||
|
||||
func init() {
|
||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2 << 30))
|
||||
policy.SetSupportedProofTypes(
|
||||
|
@ -57,6 +57,8 @@ const UpgradeChocolateHeight = 312746
|
||||
// 2022-02-10T19:23:00Z
|
||||
const UpgradeOhSnapHeight = 682006
|
||||
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)
|
||||
|
||||
func init() {
|
||||
policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30))
|
||||
policy.SetSupportedProofTypes(
|
||||
|
@ -48,6 +48,7 @@ var UpgradeTurboHeight = abi.ChainEpoch(-15)
|
||||
var UpgradeHyperdriveHeight = abi.ChainEpoch(-16)
|
||||
var UpgradeChocolateHeight = abi.ChainEpoch(-17)
|
||||
var UpgradeOhSnapHeight = abi.ChainEpoch(-18)
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(-19)
|
||||
|
||||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
@ -93,6 +94,9 @@ func init() {
|
||||
UpgradeNorwegianHeight = getUpgradeHeight("LOTUS_NORWEGIAN_HEIGHT", UpgradeNorwegianHeight)
|
||||
UpgradeTurboHeight = getUpgradeHeight("LOTUS_ACTORSV4_HEIGHT", UpgradeTurboHeight)
|
||||
UpgradeHyperdriveHeight = getUpgradeHeight("LOTUS_HYPERDRIVE_HEIGHT", UpgradeHyperdriveHeight)
|
||||
UpgradeChocolateHeight = getUpgradeHeight("LOTUS_CHOCOLATE_HEIGHT", UpgradeChocolateHeight)
|
||||
UpgradeOhSnapHeight = getUpgradeHeight("LOTUS_OHSNAP_HEIGHT", UpgradeOhSnapHeight)
|
||||
UpgradeFVM1Height = getUpgradeHeight("LOTUS_FVM1_HEIGHT", UpgradeFVM1Height)
|
||||
|
||||
BuildType |= BuildInteropnet
|
||||
SetAddressNetwork(address.Testnet)
|
||||
|
@ -70,6 +70,8 @@ const UpgradeChocolateHeight = 1231620
|
||||
// 2022-03-01T15:00:00Z
|
||||
var UpgradeOhSnapHeight = abi.ChainEpoch(1594680)
|
||||
|
||||
var UpgradeFVM1Height = abi.ChainEpoch(99999999999999)
|
||||
|
||||
func init() {
|
||||
if os.Getenv("LOTUS_USE_TEST_ADDRESSES") != "1" {
|
||||
SetAddressNetwork(address.Mainnet)
|
||||
|
@ -34,7 +34,7 @@ const NewestNetworkVersion = network.Version{{.latestNetworkVersion}}
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
const NewestNetworkVersion = network.Version15
|
||||
const NewestNetworkVersion = network.Version16
|
||||
|
||||
/* inline-gen end */
|
||||
|
||||
|
@ -100,6 +100,7 @@ var (
|
||||
UpgradeHyperdriveHeight abi.ChainEpoch = -15
|
||||
UpgradeChocolateHeight abi.ChainEpoch = -16
|
||||
UpgradeOhSnapHeight abi.ChainEpoch = -17
|
||||
UpgradeFVM1Height abi.ChainEpoch = -18
|
||||
|
||||
DrandSchedule = map[abi.ChainEpoch]DrandEnum{
|
||||
0: DrandMainnet,
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -77,7 +78,12 @@ func generateAdapters() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), b.Bytes(), 0666); err != nil {
|
||||
fmted, err := format.Source(b.Bytes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(actDir, fmt.Sprintf("%s.go", act)), fmted, 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import (
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -56,11 +58,51 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.AccountActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
var Methods = builtin4.MethodsAccount
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "account" {
|
||||
return nil, xerrors.Errorf("actor code is not account: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.AccountActorCodeID:
|
||||
@ -84,6 +126,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.AccountActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.AccountActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -112,11 +157,18 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
|
||||
case actors.Version7:
|
||||
return make7(store, addr)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store, addr)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "account"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -140,6 +192,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.AccountActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.AccountActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
|
@ -26,6 +26,21 @@ func init() {
|
||||
var Methods = builtin4.MethodsAccount
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "account" {
|
||||
return nil, xerrors.Errorf("actor code is not account: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.AccountActorCodeID:
|
||||
@ -46,6 +61,10 @@ func MakeState(store adt.Store, av actors.Version, addr address.Address) (State,
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "account"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
40
chain/actors/builtin/account/v8.go
Normal file
40
chain/actors/builtin/account/v8.go
Normal file
@ -0,0 +1,40 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
account8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/account"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store, addr address.Address) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = account8.State{Address: addr}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
account8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) PubkeyAddress() (address.Address, error) {
|
||||
return s.Address, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -26,47 +26,51 @@ import (
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
smoothing7 "github.com/filecoin-project/specs-actors/v7/actors/util/smoothing"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
smoothing8 "github.com/filecoin-project/specs-actors/v8/actors/util/smoothing"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"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"
|
||||
|
||||
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
|
||||
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
|
||||
miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner"
|
||||
proof8 "github.com/filecoin-project/specs-actors/v8/actors/runtime/proof"
|
||||
)
|
||||
|
||||
var SystemActorAddr = builtin7.SystemActorAddr
|
||||
var BurntFundsActorAddr = builtin7.BurntFundsActorAddr
|
||||
var CronActorAddr = builtin7.CronActorAddr
|
||||
var SystemActorAddr = builtin8.SystemActorAddr
|
||||
var BurntFundsActorAddr = builtin8.BurntFundsActorAddr
|
||||
var CronActorAddr = builtin8.CronActorAddr
|
||||
var SaftAddress = makeAddress("t0122")
|
||||
var ReserveAddress = makeAddress("t090")
|
||||
var RootVerifierAddress = makeAddress("t080")
|
||||
|
||||
var (
|
||||
ExpectedLeadersPerEpoch = builtin7.ExpectedLeadersPerEpoch
|
||||
ExpectedLeadersPerEpoch = builtin8.ExpectedLeadersPerEpoch
|
||||
)
|
||||
|
||||
const (
|
||||
EpochDurationSeconds = builtin7.EpochDurationSeconds
|
||||
EpochsInDay = builtin7.EpochsInDay
|
||||
SecondsInDay = builtin7.SecondsInDay
|
||||
EpochDurationSeconds = builtin8.EpochDurationSeconds
|
||||
EpochsInDay = builtin8.EpochsInDay
|
||||
SecondsInDay = builtin8.SecondsInDay
|
||||
)
|
||||
|
||||
const (
|
||||
MethodSend = builtin7.MethodSend
|
||||
MethodConstructor = builtin7.MethodConstructor
|
||||
MethodSend = builtin8.MethodSend
|
||||
MethodConstructor = builtin8.MethodConstructor
|
||||
)
|
||||
|
||||
// These are all just type aliases across actor versions. In the future, that might change
|
||||
// and we might need to do something fancier.
|
||||
type SectorInfo = proof7.SectorInfo
|
||||
type ExtendedSectorInfo = proof7.ExtendedSectorInfo
|
||||
type PoStProof = proof7.PoStProof
|
||||
type SectorInfo = proof8.SectorInfo
|
||||
type ExtendedSectorInfo = proof8.ExtendedSectorInfo
|
||||
type PoStProof = proof8.PoStProof
|
||||
type FilterEstimate = smoothing0.FilterEstimate
|
||||
|
||||
func QAPowerForWeight(size abi.SectorSize, duration abi.ChainEpoch, dealWeight, verifiedWeight abi.DealWeight) abi.StoragePower {
|
||||
return miner7.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
|
||||
return miner8.QAPowerForWeight(size, duration, dealWeight, verifiedWeight)
|
||||
}
|
||||
|
||||
func FromV0FilterEstimate(v0 smoothing0.FilterEstimate) FilterEstimate {
|
||||
@ -111,6 +115,12 @@ func FromV7FilterEstimate(v7 smoothing7.FilterEstimate) FilterEstimate {
|
||||
|
||||
}
|
||||
|
||||
func FromV8FilterEstimate(v8 smoothing8.FilterEstimate) FilterEstimate {
|
||||
|
||||
return (FilterEstimate)(v8)
|
||||
|
||||
}
|
||||
|
||||
type ActorStateLoader func(store adt.Store, root cid.Cid) (cbor.Marshaler, error)
|
||||
|
||||
var ActorStateLoaders = make(map[cid.Cid]ActorStateLoader)
|
||||
@ -128,6 +138,11 @@ func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
|
||||
}
|
||||
|
||||
func ActorNameByCode(c cid.Cid) string {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name
|
||||
}
|
||||
|
||||
switch {
|
||||
|
||||
case builtin0.IsBuiltinActor(c):
|
||||
@ -151,12 +166,19 @@ func ActorNameByCode(c cid.Cid) string {
|
||||
case builtin7.IsBuiltinActor(c):
|
||||
return builtin7.ActorNameByCode(c)
|
||||
|
||||
case builtin8.IsBuiltinActor(c):
|
||||
return builtin8.ActorNameByCode(c)
|
||||
|
||||
default:
|
||||
return "<unknown>"
|
||||
}
|
||||
}
|
||||
|
||||
func IsBuiltinActor(c cid.Cid) bool {
|
||||
_, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return true
|
||||
}
|
||||
|
||||
if builtin0.IsBuiltinActor(c) {
|
||||
return true
|
||||
@ -186,10 +208,18 @@ func IsBuiltinActor(c cid.Cid) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if builtin8.IsBuiltinActor(c) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func IsAccountActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "account"
|
||||
}
|
||||
|
||||
if c == builtin0.AccountActorCodeID {
|
||||
return true
|
||||
@ -219,10 +249,18 @@ func IsAccountActor(c cid.Cid) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if c == builtin8.AccountActorCodeID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func IsStorageMinerActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "storageminer"
|
||||
}
|
||||
|
||||
if c == builtin0.StorageMinerActorCodeID {
|
||||
return true
|
||||
@ -252,10 +290,18 @@ func IsStorageMinerActor(c cid.Cid) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if c == builtin8.StorageMinerActorCodeID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func IsMultisigActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "multisig"
|
||||
}
|
||||
|
||||
if c == builtin0.MultisigActorCodeID {
|
||||
return true
|
||||
@ -285,10 +331,18 @@ func IsMultisigActor(c cid.Cid) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if c == builtin8.MultisigActorCodeID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "paymentchannel"
|
||||
}
|
||||
|
||||
if c == builtin0.PaymentChannelActorCodeID {
|
||||
return true
|
||||
@ -318,6 +372,10 @@ func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if c == builtin8.PaymentChannelActorCodeID {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"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"
|
||||
|
||||
@ -80,6 +81,11 @@ func Load(store adt.Store, act *types.Actor) (cbor.Marshaler, error) {
|
||||
}
|
||||
|
||||
func ActorNameByCode(c cid.Cid) string {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name
|
||||
}
|
||||
|
||||
switch {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.IsBuiltinActor(c):
|
||||
@ -91,6 +97,11 @@ func ActorNameByCode(c cid.Cid) string {
|
||||
}
|
||||
|
||||
func IsBuiltinActor(c cid.Cid) bool {
|
||||
_, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return true
|
||||
}
|
||||
|
||||
{{range .versions}}
|
||||
if builtin{{.}}.IsBuiltinActor(c) {
|
||||
return true
|
||||
@ -100,6 +111,11 @@ func IsBuiltinActor(c cid.Cid) bool {
|
||||
}
|
||||
|
||||
func IsAccountActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "account"
|
||||
}
|
||||
|
||||
{{range .versions}}
|
||||
if c == builtin{{.}}.AccountActorCodeID {
|
||||
return true
|
||||
@ -109,6 +125,11 @@ func IsAccountActor(c cid.Cid) bool {
|
||||
}
|
||||
|
||||
func IsStorageMinerActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "storageminer"
|
||||
}
|
||||
|
||||
{{range .versions}}
|
||||
if c == builtin{{.}}.StorageMinerActorCodeID {
|
||||
return true
|
||||
@ -118,6 +139,11 @@ func IsStorageMinerActor(c cid.Cid) bool {
|
||||
}
|
||||
|
||||
func IsMultisigActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "multisig"
|
||||
}
|
||||
|
||||
{{range .versions}}
|
||||
if c == builtin{{.}}.MultisigActorCodeID {
|
||||
return true
|
||||
@ -127,6 +153,11 @@ func IsMultisigActor(c cid.Cid) bool {
|
||||
}
|
||||
|
||||
func IsPaymentChannelActor(c cid.Cid) bool {
|
||||
name, _, ok := actors.GetActorMetaByCode(c)
|
||||
if ok {
|
||||
return name == "paymentchannel"
|
||||
}
|
||||
|
||||
{{range .versions}}
|
||||
if c == builtin{{.}}.PaymentChannelActorCodeID {
|
||||
return true
|
||||
|
@ -21,6 +21,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "cron"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
@ -19,6 +19,8 @@ import (
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
)
|
||||
|
||||
func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
@ -45,11 +47,18 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version7:
|
||||
return make7(store)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "cron"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -73,14 +82,17 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.CronActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.CronActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin7.CronActorAddr
|
||||
Methods = builtin7.MethodsCron
|
||||
Address = builtin8.CronActorAddr
|
||||
Methods = builtin8.MethodsCron
|
||||
)
|
||||
|
||||
type State interface {
|
||||
|
35
chain/actors/builtin/cron/v8.go
Normal file
35
chain/actors/builtin/cron/v8.go
Normal file
@ -0,0 +1,35 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
cron8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/cron"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = *cron8.ConstructState(cron8.BuiltInEntries())
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
cron8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -31,6 +31,21 @@ var (
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "init" {
|
||||
return nil, xerrors.Errorf("actor code is not init: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.InitActorCodeID:
|
||||
@ -51,6 +66,10 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "init"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
@ -27,6 +27,8 @@ import (
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -58,14 +60,54 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.InitActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin7.InitActorAddr
|
||||
Methods = builtin7.MethodsInit
|
||||
Address = builtin8.InitActorAddr
|
||||
Methods = builtin8.MethodsInit
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "init" {
|
||||
return nil, xerrors.Errorf("actor code is not init: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.InitActorCodeID:
|
||||
@ -89,6 +131,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.InitActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.InitActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -117,11 +162,18 @@ func MakeState(store adt.Store, av actors.Version, networkName string) (State, e
|
||||
case actors.Version7:
|
||||
return make7(store, networkName)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store, networkName)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "init"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -145,6 +197,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.InitActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.InitActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
|
114
chain/actors/builtin/init/v8.go
Normal file
114
chain/actors/builtin/init/v8.go
Normal file
@ -0,0 +1,114 @@
|
||||
package init
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
init8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/init"
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store, networkName string) (State, error) {
|
||||
out := state8{store: store}
|
||||
|
||||
s, err := init8.ConstructState(store, networkName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
init8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) ResolveAddress(address address.Address) (address.Address, bool, error) {
|
||||
return s.State.ResolveAddress(s.store, address)
|
||||
}
|
||||
|
||||
func (s *state8) MapAddressToNewID(address address.Address) (address.Address, error) {
|
||||
return s.State.MapAddressToNewID(s.store, address)
|
||||
}
|
||||
|
||||
func (s *state8) ForEachActor(cb func(id abi.ActorID, address address.Address) error) error {
|
||||
addrs, err := adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var actorID cbg.CborInt
|
||||
return addrs.ForEach(&actorID, func(key string) error {
|
||||
addr, err := address.NewFromBytes([]byte(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(abi.ActorID(actorID), addr)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state8) NetworkName() (dtypes.NetworkName, error) {
|
||||
return dtypes.NetworkName(s.State.NetworkName), nil
|
||||
}
|
||||
|
||||
func (s *state8) SetNetworkName(name string) error {
|
||||
s.State.NetworkName = name
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) SetNextID(id abi.ActorID) error {
|
||||
s.State.NextID = id
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) Remove(addrs ...address.Address) (err error) {
|
||||
m, err := adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
if err = m.Delete(abi.AddrKey(addr)); err != nil {
|
||||
return xerrors.Errorf("failed to delete entry for address: %s; err: %w", addr, err)
|
||||
}
|
||||
}
|
||||
amr, err := m.Root()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to get address map root: %w", err)
|
||||
}
|
||||
s.State.AddressMap = amr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) SetAddressMap(mcid cid.Cid) error {
|
||||
s.State.AddressMap = mcid
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) AddressMap() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.State.AddressMap, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package market
|
||||
|
||||
import (
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -12,6 +14,7 @@ import (
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
market{{.latestVersion}} "github.com/filecoin-project/specs-actors{{import .latestVersion}}actors/builtin/market"
|
||||
{{range .versions}}
|
||||
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
|
||||
{{end}}
|
||||
@ -35,6 +38,21 @@ var (
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "storagemarket" {
|
||||
return nil, xerrors.Errorf("actor code is not storagemarket: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.StorageMarketActorCodeID:
|
||||
@ -55,6 +73,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "storagemarket"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
@ -103,7 +125,7 @@ type DealProposals interface {
|
||||
decode(*cbg.Deferred) (*DealProposal, error)
|
||||
}
|
||||
|
||||
type PublishStorageDealsParams = market0.PublishStorageDealsParams
|
||||
type PublishStorageDealsParams = market{{.latestVersion}}.PublishStorageDealsParams
|
||||
|
||||
type PublishStorageDealsReturn interface {
|
||||
DealIDs() ([]abi.DealID, error)
|
||||
@ -129,7 +151,7 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
|
||||
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
|
||||
type WithdrawBalanceParams = market0.WithdrawBalanceParams
|
||||
|
||||
type ClientDealProposal = market0.ClientDealProposal
|
||||
type ClientDealProposal = market{{.latestVersion}}.ClientDealProposal
|
||||
|
||||
type DealState struct {
|
||||
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
|
||||
@ -143,7 +165,7 @@ type DealProposal struct {
|
||||
VerifiedDeal bool
|
||||
Client address.Address
|
||||
Provider address.Address
|
||||
Label string
|
||||
Label market{{.latestVersion}}.DealLabel
|
||||
StartEpoch abi.ChainEpoch
|
||||
EndEpoch abi.ChainEpoch
|
||||
StoragePricePerEpoch abi.TokenAmount
|
||||
@ -202,3 +224,11 @@ func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, ab
|
||||
|
||||
return ef, big.Sub(tf, ef)
|
||||
}
|
||||
|
||||
func labelFromGoString(s string) (market{{.latestVersion}}.DealLabel, error) {
|
||||
if utf8.ValidString(s) {
|
||||
return market{{.latestVersion}}.NewLabelFromString(s)
|
||||
} else {
|
||||
return market{{.latestVersion}}.NewLabelFromBytes([]byte(s))
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package market
|
||||
|
||||
import (
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -12,6 +14,7 @@ import (
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
@ -27,6 +30,8 @@ import (
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
@ -62,14 +67,54 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.StorageMarketActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin7.StorageMarketActorAddr
|
||||
Methods = builtin7.MethodsMarket
|
||||
Address = builtin8.StorageMarketActorAddr
|
||||
Methods = builtin8.MethodsMarket
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "storagemarket" {
|
||||
return nil, xerrors.Errorf("actor code is not storagemarket: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.StorageMarketActorCodeID:
|
||||
@ -93,6 +138,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.StorageMarketActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.StorageMarketActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -121,11 +169,18 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version7:
|
||||
return make7(store)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "storagemarket"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -149,6 +204,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.StorageMarketActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.StorageMarketActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
@ -192,7 +250,7 @@ type DealProposals interface {
|
||||
decode(*cbg.Deferred) (*DealProposal, error)
|
||||
}
|
||||
|
||||
type PublishStorageDealsParams = market0.PublishStorageDealsParams
|
||||
type PublishStorageDealsParams = market8.PublishStorageDealsParams
|
||||
|
||||
type PublishStorageDealsReturn interface {
|
||||
DealIDs() ([]abi.DealID, error)
|
||||
@ -229,6 +287,9 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
|
||||
case actors.Version7:
|
||||
return decodePublishStorageDealsReturn7(b)
|
||||
|
||||
case actors.Version8:
|
||||
return decodePublishStorageDealsReturn8(b)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
@ -236,7 +297,7 @@ func DecodePublishStorageDealsReturn(b []byte, nv network.Version) (PublishStora
|
||||
type VerifyDealsForActivationParams = market0.VerifyDealsForActivationParams
|
||||
type WithdrawBalanceParams = market0.WithdrawBalanceParams
|
||||
|
||||
type ClientDealProposal = market0.ClientDealProposal
|
||||
type ClientDealProposal = market8.ClientDealProposal
|
||||
|
||||
type DealState struct {
|
||||
SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector
|
||||
@ -250,7 +311,7 @@ type DealProposal struct {
|
||||
VerifiedDeal bool
|
||||
Client address.Address
|
||||
Provider address.Address
|
||||
Label string
|
||||
Label market8.DealLabel
|
||||
StartEpoch abi.ChainEpoch
|
||||
EndEpoch abi.ChainEpoch
|
||||
StoragePricePerEpoch abi.TokenAmount
|
||||
@ -309,3 +370,11 @@ func (deal DealProposal) GetDealFees(height abi.ChainEpoch) (abi.TokenAmount, ab
|
||||
|
||||
return ef, big.Sub(tf, ef)
|
||||
}
|
||||
|
||||
func labelFromGoString(s string) (market8.DealLabel, error) {
|
||||
if utf8.ValidString(s) {
|
||||
return market8.NewLabelFromString(s)
|
||||
} else {
|
||||
return market8.NewLabelFromBytes([]byte(s))
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ func (s *dealStates{{.v}}) array() adt.Array {
|
||||
}
|
||||
|
||||
func fromV{{.v}}DealState(v{{.v}} market{{.v}}.DealState) DealState {
|
||||
return (DealState)(v{{.v}})
|
||||
return (DealState)(v{{.v}})
|
||||
}
|
||||
|
||||
type dealProposals{{.v}} struct {
|
||||
@ -206,14 +206,24 @@ func (s *dealProposals{{.v}}) Get(dealID abi.DealID) (*DealProposal, bool, error
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV{{.v}}DealProposal(proposal{{.v}})
|
||||
return &proposal, true, nil
|
||||
|
||||
proposal, err := fromV{{.v}}DealProposal(proposal{{.v}})
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals{{.v}}) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp{{.v}} market{{.v}}.DealProposal
|
||||
return s.Array.ForEach(&dp{{.v}}, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV{{.v}}DealProposal(dp{{.v}}))
|
||||
dp, err := fromV{{.v}}DealProposal(dp{{.v}})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -222,18 +232,48 @@ func (s *dealProposals{{.v}}) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp{{.v}}.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV{{.v}}DealProposal(dp{{.v}})
|
||||
return &dp, nil
|
||||
|
||||
dp, err := fromV{{.v}}DealProposal(dp{{.v}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals{{.v}}) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) DealProposal {
|
||||
return (DealProposal)(v{{.v}})
|
||||
func fromV{{.v}}DealProposal(v{{.v}} market{{.v}}.DealProposal) (DealProposal, error) {
|
||||
{{if (le .v 7)}}
|
||||
label, err := labelFromGoString(v{{.v}}.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
{{else}}
|
||||
label := v{{.v}}.Label
|
||||
{{end}}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v{{.v}}.PieceCID,
|
||||
PieceSize: v{{.v}}.PieceSize,
|
||||
VerifiedDeal: v{{.v}}.VerifiedDeal,
|
||||
Client: v{{.v}}.Client,
|
||||
Provider: v{{.v}}.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v{{.v}}.StartEpoch,
|
||||
EndEpoch: v{{.v}}.EndEpoch,
|
||||
StoragePricePerEpoch: v{{.v}}.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v{{.v}}.ProviderCollateral,
|
||||
ClientCollateral: v{{.v}}.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
func (s *state{{.v}}) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
@ -199,14 +199,24 @@ func (s *dealProposals0) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV0DealProposal(proposal0)
|
||||
|
||||
proposal, err := fromV0DealProposal(proposal0)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals0) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp0 market0.DealProposal
|
||||
return s.Array.ForEach(&dp0, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV0DealProposal(dp0))
|
||||
dp, err := fromV0DealProposal(dp0)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -215,7 +225,12 @@ func (s *dealProposals0) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp0.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV0DealProposal(dp0)
|
||||
|
||||
dp, err := fromV0DealProposal(dp0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -223,8 +238,29 @@ func (s *dealProposals0) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV0DealProposal(v0 market0.DealProposal) DealProposal {
|
||||
return (DealProposal)(v0)
|
||||
func fromV0DealProposal(v0 market0.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v0.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v0.PieceCID,
|
||||
PieceSize: v0.PieceSize,
|
||||
VerifiedDeal: v0.VerifiedDeal,
|
||||
Client: v0.Client,
|
||||
Provider: v0.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v0.StartEpoch,
|
||||
EndEpoch: v0.EndEpoch,
|
||||
StoragePricePerEpoch: v0.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v0.ProviderCollateral,
|
||||
ClientCollateral: v0.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state0) GetState() interface{} {
|
||||
|
@ -199,14 +199,24 @@ func (s *dealProposals2) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV2DealProposal(proposal2)
|
||||
|
||||
proposal, err := fromV2DealProposal(proposal2)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals2) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp2 market2.DealProposal
|
||||
return s.Array.ForEach(&dp2, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV2DealProposal(dp2))
|
||||
dp, err := fromV2DealProposal(dp2)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -215,7 +225,12 @@ func (s *dealProposals2) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp2.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV2DealProposal(dp2)
|
||||
|
||||
dp, err := fromV2DealProposal(dp2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -223,8 +238,29 @@ func (s *dealProposals2) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV2DealProposal(v2 market2.DealProposal) DealProposal {
|
||||
return (DealProposal)(v2)
|
||||
func fromV2DealProposal(v2 market2.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v2.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v2.PieceCID,
|
||||
PieceSize: v2.PieceSize,
|
||||
VerifiedDeal: v2.VerifiedDeal,
|
||||
Client: v2.Client,
|
||||
Provider: v2.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v2.StartEpoch,
|
||||
EndEpoch: v2.EndEpoch,
|
||||
StoragePricePerEpoch: v2.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v2.ProviderCollateral,
|
||||
ClientCollateral: v2.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state2) GetState() interface{} {
|
||||
|
@ -194,14 +194,24 @@ func (s *dealProposals3) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV3DealProposal(proposal3)
|
||||
|
||||
proposal, err := fromV3DealProposal(proposal3)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals3) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp3 market3.DealProposal
|
||||
return s.Array.ForEach(&dp3, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV3DealProposal(dp3))
|
||||
dp, err := fromV3DealProposal(dp3)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -210,7 +220,12 @@ func (s *dealProposals3) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp3.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV3DealProposal(dp3)
|
||||
|
||||
dp, err := fromV3DealProposal(dp3)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -218,8 +233,29 @@ func (s *dealProposals3) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV3DealProposal(v3 market3.DealProposal) DealProposal {
|
||||
return (DealProposal)(v3)
|
||||
func fromV3DealProposal(v3 market3.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v3.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v3.PieceCID,
|
||||
PieceSize: v3.PieceSize,
|
||||
VerifiedDeal: v3.VerifiedDeal,
|
||||
Client: v3.Client,
|
||||
Provider: v3.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v3.StartEpoch,
|
||||
EndEpoch: v3.EndEpoch,
|
||||
StoragePricePerEpoch: v3.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v3.ProviderCollateral,
|
||||
ClientCollateral: v3.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state3) GetState() interface{} {
|
||||
|
@ -194,14 +194,24 @@ func (s *dealProposals4) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV4DealProposal(proposal4)
|
||||
|
||||
proposal, err := fromV4DealProposal(proposal4)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals4) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp4 market4.DealProposal
|
||||
return s.Array.ForEach(&dp4, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV4DealProposal(dp4))
|
||||
dp, err := fromV4DealProposal(dp4)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -210,7 +220,12 @@ func (s *dealProposals4) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp4.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV4DealProposal(dp4)
|
||||
|
||||
dp, err := fromV4DealProposal(dp4)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -218,8 +233,29 @@ func (s *dealProposals4) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV4DealProposal(v4 market4.DealProposal) DealProposal {
|
||||
return (DealProposal)(v4)
|
||||
func fromV4DealProposal(v4 market4.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v4.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v4.PieceCID,
|
||||
PieceSize: v4.PieceSize,
|
||||
VerifiedDeal: v4.VerifiedDeal,
|
||||
Client: v4.Client,
|
||||
Provider: v4.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v4.StartEpoch,
|
||||
EndEpoch: v4.EndEpoch,
|
||||
StoragePricePerEpoch: v4.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v4.ProviderCollateral,
|
||||
ClientCollateral: v4.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state4) GetState() interface{} {
|
||||
|
@ -194,14 +194,24 @@ func (s *dealProposals5) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV5DealProposal(proposal5)
|
||||
|
||||
proposal, err := fromV5DealProposal(proposal5)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals5) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp5 market5.DealProposal
|
||||
return s.Array.ForEach(&dp5, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV5DealProposal(dp5))
|
||||
dp, err := fromV5DealProposal(dp5)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -210,7 +220,12 @@ func (s *dealProposals5) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp5.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV5DealProposal(dp5)
|
||||
|
||||
dp, err := fromV5DealProposal(dp5)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -218,8 +233,29 @@ func (s *dealProposals5) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV5DealProposal(v5 market5.DealProposal) DealProposal {
|
||||
return (DealProposal)(v5)
|
||||
func fromV5DealProposal(v5 market5.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v5.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v5.PieceCID,
|
||||
PieceSize: v5.PieceSize,
|
||||
VerifiedDeal: v5.VerifiedDeal,
|
||||
Client: v5.Client,
|
||||
Provider: v5.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v5.StartEpoch,
|
||||
EndEpoch: v5.EndEpoch,
|
||||
StoragePricePerEpoch: v5.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v5.ProviderCollateral,
|
||||
ClientCollateral: v5.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state5) GetState() interface{} {
|
||||
|
@ -194,14 +194,24 @@ func (s *dealProposals6) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV6DealProposal(proposal6)
|
||||
|
||||
proposal, err := fromV6DealProposal(proposal6)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals6) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp6 market6.DealProposal
|
||||
return s.Array.ForEach(&dp6, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV6DealProposal(dp6))
|
||||
dp, err := fromV6DealProposal(dp6)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -210,7 +220,12 @@ func (s *dealProposals6) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp6.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV6DealProposal(dp6)
|
||||
|
||||
dp, err := fromV6DealProposal(dp6)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -218,8 +233,29 @@ func (s *dealProposals6) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV6DealProposal(v6 market6.DealProposal) DealProposal {
|
||||
return (DealProposal)(v6)
|
||||
func fromV6DealProposal(v6 market6.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v6.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v6.PieceCID,
|
||||
PieceSize: v6.PieceSize,
|
||||
VerifiedDeal: v6.VerifiedDeal,
|
||||
Client: v6.Client,
|
||||
Provider: v6.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v6.StartEpoch,
|
||||
EndEpoch: v6.EndEpoch,
|
||||
StoragePricePerEpoch: v6.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v6.ProviderCollateral,
|
||||
ClientCollateral: v6.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state6) GetState() interface{} {
|
||||
|
@ -194,14 +194,24 @@ func (s *dealProposals7) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
proposal := fromV7DealProposal(proposal7)
|
||||
|
||||
proposal, err := fromV7DealProposal(proposal7)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals7) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp7 market7.DealProposal
|
||||
return s.Array.ForEach(&dp7, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV7DealProposal(dp7))
|
||||
dp, err := fromV7DealProposal(dp7)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
@ -210,7 +220,12 @@ func (s *dealProposals7) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
if err := dp7.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dp := fromV7DealProposal(dp7)
|
||||
|
||||
dp, err := fromV7DealProposal(dp7)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
@ -218,8 +233,29 @@ func (s *dealProposals7) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV7DealProposal(v7 market7.DealProposal) DealProposal {
|
||||
return (DealProposal)(v7)
|
||||
func fromV7DealProposal(v7 market7.DealProposal) (DealProposal, error) {
|
||||
|
||||
label, err := labelFromGoString(v7.Label)
|
||||
if err != nil {
|
||||
return DealProposal{}, xerrors.Errorf("error setting deal label: %w", err)
|
||||
}
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v7.PieceCID,
|
||||
PieceSize: v7.PieceSize,
|
||||
VerifiedDeal: v7.VerifiedDeal,
|
||||
Client: v7.Client,
|
||||
Provider: v7.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v7.StartEpoch,
|
||||
EndEpoch: v7.EndEpoch,
|
||||
StoragePricePerEpoch: v7.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v7.ProviderCollateral,
|
||||
ClientCollateral: v7.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state7) GetState() interface{} {
|
||||
|
285
chain/actors/builtin/market/v8.go
Normal file
285
chain/actors/builtin/market/v8.go
Normal file
@ -0,0 +1,285 @@
|
||||
package market
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store) (State, error) {
|
||||
out := state8{store: store}
|
||||
|
||||
s, err := market8.ConstructState(store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
market8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) TotalLocked() (abi.TokenAmount, error) {
|
||||
fml := types.BigAdd(s.TotalClientLockedCollateral, s.TotalProviderLockedCollateral)
|
||||
fml = types.BigAdd(fml, s.TotalClientStorageFee)
|
||||
return fml, nil
|
||||
}
|
||||
|
||||
func (s *state8) BalancesChanged(otherState State) (bool, error) {
|
||||
otherState8, ok := otherState.(*state8)
|
||||
if !ok {
|
||||
// there's no way to compare different versions of the state, so let's
|
||||
// just say that means the state of balances has changed
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.EscrowTable.Equals(otherState8.State.EscrowTable) || !s.State.LockedTable.Equals(otherState8.State.LockedTable), nil
|
||||
}
|
||||
|
||||
func (s *state8) StatesChanged(otherState State) (bool, error) {
|
||||
otherState8, ok := otherState.(*state8)
|
||||
if !ok {
|
||||
// there's no way to compare different versions of the state, so let's
|
||||
// just say that means the state of balances has changed
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.States.Equals(otherState8.State.States), nil
|
||||
}
|
||||
|
||||
func (s *state8) States() (DealStates, error) {
|
||||
stateArray, err := adt8.AsArray(s.store, s.State.States, market8.StatesAmtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dealStates8{stateArray}, nil
|
||||
}
|
||||
|
||||
func (s *state8) ProposalsChanged(otherState State) (bool, error) {
|
||||
otherState8, ok := otherState.(*state8)
|
||||
if !ok {
|
||||
// there's no way to compare different versions of the state, so let's
|
||||
// just say that means the state of balances has changed
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.Proposals.Equals(otherState8.State.Proposals), nil
|
||||
}
|
||||
|
||||
func (s *state8) Proposals() (DealProposals, error) {
|
||||
proposalArray, err := adt8.AsArray(s.store, s.State.Proposals, market8.ProposalsAmtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &dealProposals8{proposalArray}, nil
|
||||
}
|
||||
|
||||
func (s *state8) EscrowTable() (BalanceTable, error) {
|
||||
bt, err := adt8.AsBalanceTable(s.store, s.State.EscrowTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &balanceTable8{bt}, nil
|
||||
}
|
||||
|
||||
func (s *state8) LockedTable() (BalanceTable, error) {
|
||||
bt, err := adt8.AsBalanceTable(s.store, s.State.LockedTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &balanceTable8{bt}, nil
|
||||
}
|
||||
|
||||
func (s *state8) VerifyDealsForActivation(
|
||||
minerAddr address.Address, deals []abi.DealID, currEpoch, sectorExpiry abi.ChainEpoch,
|
||||
) (weight, verifiedWeight abi.DealWeight, err error) {
|
||||
w, vw, _, err := market8.ValidateDealsForActivation(&s.State, s.store, deals, minerAddr, sectorExpiry, currEpoch)
|
||||
return w, vw, err
|
||||
}
|
||||
|
||||
func (s *state8) NextID() (abi.DealID, error) {
|
||||
return s.State.NextID, nil
|
||||
}
|
||||
|
||||
type balanceTable8 struct {
|
||||
*adt8.BalanceTable
|
||||
}
|
||||
|
||||
func (bt *balanceTable8) ForEach(cb func(address.Address, abi.TokenAmount) error) error {
|
||||
asMap := (*adt8.Map)(bt.BalanceTable)
|
||||
var ta abi.TokenAmount
|
||||
return asMap.ForEach(&ta, func(key string) error {
|
||||
a, err := address.NewFromBytes([]byte(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return cb(a, ta)
|
||||
})
|
||||
}
|
||||
|
||||
type dealStates8 struct {
|
||||
adt.Array
|
||||
}
|
||||
|
||||
func (s *dealStates8) Get(dealID abi.DealID) (*DealState, bool, error) {
|
||||
var deal8 market8.DealState
|
||||
found, err := s.Array.Get(uint64(dealID), &deal8)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
deal := fromV8DealState(deal8)
|
||||
return &deal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealStates8) ForEach(cb func(dealID abi.DealID, ds DealState) error) error {
|
||||
var ds8 market8.DealState
|
||||
return s.Array.ForEach(&ds8, func(idx int64) error {
|
||||
return cb(abi.DealID(idx), fromV8DealState(ds8))
|
||||
})
|
||||
}
|
||||
|
||||
func (s *dealStates8) decode(val *cbg.Deferred) (*DealState, error) {
|
||||
var ds8 market8.DealState
|
||||
if err := ds8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ds := fromV8DealState(ds8)
|
||||
return &ds, nil
|
||||
}
|
||||
|
||||
func (s *dealStates8) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV8DealState(v8 market8.DealState) DealState {
|
||||
return (DealState)(v8)
|
||||
}
|
||||
|
||||
type dealProposals8 struct {
|
||||
adt.Array
|
||||
}
|
||||
|
||||
func (s *dealProposals8) Get(dealID abi.DealID) (*DealProposal, bool, error) {
|
||||
var proposal8 market8.DealProposal
|
||||
found, err := s.Array.Get(uint64(dealID), &proposal8)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
if !found {
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
proposal, err := fromV8DealProposal(proposal8)
|
||||
if err != nil {
|
||||
return nil, true, xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return &proposal, true, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals8) ForEach(cb func(dealID abi.DealID, dp DealProposal) error) error {
|
||||
var dp8 market8.DealProposal
|
||||
return s.Array.ForEach(&dp8, func(idx int64) error {
|
||||
dp, err := fromV8DealProposal(dp8)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("decoding proposal: %w", err)
|
||||
}
|
||||
|
||||
return cb(abi.DealID(idx), dp)
|
||||
})
|
||||
}
|
||||
|
||||
func (s *dealProposals8) decode(val *cbg.Deferred) (*DealProposal, error) {
|
||||
var dp8 market8.DealProposal
|
||||
if err := dp8.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dp, err := fromV8DealProposal(dp8)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &dp, nil
|
||||
}
|
||||
|
||||
func (s *dealProposals8) array() adt.Array {
|
||||
return s.Array
|
||||
}
|
||||
|
||||
func fromV8DealProposal(v8 market8.DealProposal) (DealProposal, error) {
|
||||
|
||||
label := v8.Label
|
||||
|
||||
return DealProposal{
|
||||
PieceCID: v8.PieceCID,
|
||||
PieceSize: v8.PieceSize,
|
||||
VerifiedDeal: v8.VerifiedDeal,
|
||||
Client: v8.Client,
|
||||
Provider: v8.Provider,
|
||||
|
||||
Label: label,
|
||||
|
||||
StartEpoch: v8.StartEpoch,
|
||||
EndEpoch: v8.EndEpoch,
|
||||
StoragePricePerEpoch: v8.StoragePricePerEpoch,
|
||||
|
||||
ProviderCollateral: v8.ProviderCollateral,
|
||||
ClientCollateral: v8.ClientCollateral,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
var _ PublishStorageDealsReturn = (*publishStorageDealsReturn8)(nil)
|
||||
|
||||
func decodePublishStorageDealsReturn8(b []byte) (PublishStorageDealsReturn, error) {
|
||||
var retval market8.PublishStorageDealsReturn
|
||||
if err := retval.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
|
||||
return nil, xerrors.Errorf("failed to unmarshal PublishStorageDealsReturn: %w", err)
|
||||
}
|
||||
|
||||
return &publishStorageDealsReturn8{retval}, nil
|
||||
}
|
||||
|
||||
type publishStorageDealsReturn8 struct {
|
||||
market8.PublishStorageDealsReturn
|
||||
}
|
||||
|
||||
func (r *publishStorageDealsReturn8) IsDealValid(index uint64) (bool, error) {
|
||||
|
||||
return r.ValidDeals.IsSet(index)
|
||||
|
||||
}
|
||||
|
||||
func (r *publishStorageDealsReturn8) DealIDs() ([]abi.DealID, error) {
|
||||
return r.IDs, nil
|
||||
}
|
@ -54,6 +54,21 @@ var DeclarationsMax = miner2.DeclarationsMax
|
||||
var AddressedSectorsMax = miner2.AddressedSectorsMax
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "storageminer" {
|
||||
return nil, xerrors.Errorf("actor code is not storageminer: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.StorageMinerActorCodeID:
|
||||
@ -74,6 +89,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "storageminer"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
@ -38,6 +38,8 @@ import (
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -70,9 +72,13 @@ func init() {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.StorageMinerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
var Methods = builtin7.MethodsMiner
|
||||
var Methods = builtin8.MethodsMiner
|
||||
|
||||
// Unchanged between v0, v2, v3, v4, and v5 actors
|
||||
var WPoStProvingPeriod = miner0.WPoStProvingPeriod
|
||||
@ -89,6 +95,42 @@ var DeclarationsMax = miner2.DeclarationsMax
|
||||
var AddressedSectorsMax = miner2.AddressedSectorsMax
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "storageminer" {
|
||||
return nil, xerrors.Errorf("actor code is not storageminer: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.StorageMinerActorCodeID:
|
||||
@ -112,6 +154,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.StorageMinerActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.StorageMinerActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -140,11 +185,18 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version7:
|
||||
return make7(store)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "storageminer"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -168,6 +220,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.StorageMinerActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.StorageMinerActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
|
571
chain/actors/builtin/miner/v8.go
Normal file
571
chain/actors/builtin/miner/v8.go
Normal file
@ -0,0 +1,571 @@
|
||||
package miner
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
rle "github.com/filecoin-project/go-bitfield/rle"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner"
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = miner8.State{}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
miner8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
type deadline8 struct {
|
||||
miner8.Deadline
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
type partition8 struct {
|
||||
miner8.Partition
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) AvailableBalance(bal abi.TokenAmount) (available abi.TokenAmount, err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = xerrors.Errorf("failed to get available balance: %w", r)
|
||||
available = abi.NewTokenAmount(0)
|
||||
}
|
||||
}()
|
||||
// this panics if the miner doesnt have enough funds to cover their locked pledge
|
||||
available, err = s.GetAvailableBalance(bal)
|
||||
return available, err
|
||||
}
|
||||
|
||||
func (s *state8) VestedFunds(epoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||
return s.CheckVestedFunds(s.store, epoch)
|
||||
}
|
||||
|
||||
func (s *state8) LockedFunds() (LockedFunds, error) {
|
||||
return LockedFunds{
|
||||
VestingFunds: s.State.LockedFunds,
|
||||
InitialPledgeRequirement: s.State.InitialPledge,
|
||||
PreCommitDeposits: s.State.PreCommitDeposits,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state8) FeeDebt() (abi.TokenAmount, error) {
|
||||
return s.State.FeeDebt, nil
|
||||
}
|
||||
|
||||
func (s *state8) InitialPledge() (abi.TokenAmount, error) {
|
||||
return s.State.InitialPledge, nil
|
||||
}
|
||||
|
||||
func (s *state8) PreCommitDeposits() (abi.TokenAmount, error) {
|
||||
return s.State.PreCommitDeposits, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetSector(num abi.SectorNumber) (*SectorOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := fromV8SectorOnChainInfo(*info)
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state8) FindSector(num abi.SectorNumber) (*SectorLocation, error) {
|
||||
dlIdx, partIdx, err := s.State.FindSector(s.store, num)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SectorLocation{
|
||||
Deadline: dlIdx,
|
||||
Partition: partIdx,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state8) NumLiveSectors() (uint64, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var total uint64
|
||||
if err := dls.ForEach(s.store, func(dlIdx uint64, dl *miner8.Deadline) error {
|
||||
total += dl.LiveSectors
|
||||
return nil
|
||||
}); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return total, nil
|
||||
}
|
||||
|
||||
// GetSectorExpiration returns the effective expiration of the given sector.
|
||||
//
|
||||
// If the sector does not expire early, the Early expiration field is 0.
|
||||
func (s *state8) GetSectorExpiration(num abi.SectorNumber) (*SectorExpiration, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// NOTE: this can be optimized significantly.
|
||||
// 1. If the sector is non-faulty, it will expire on-time (can be
|
||||
// learned from the sector info).
|
||||
// 2. If it's faulty, it will expire early within the first 42 entries
|
||||
// of the expiration queue.
|
||||
|
||||
stopErr := errors.New("stop")
|
||||
out := SectorExpiration{}
|
||||
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner8.Deadline) error {
|
||||
partitions, err := dl.PartitionsArray(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
quant := s.State.QuantSpecForDeadline(dlIdx)
|
||||
var part miner8.Partition
|
||||
return partitions.ForEach(&part, func(partIdx int64) error {
|
||||
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if !found {
|
||||
return nil
|
||||
}
|
||||
if found, err := part.Terminated.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if found {
|
||||
// already terminated
|
||||
return stopErr
|
||||
}
|
||||
|
||||
q, err := miner8.LoadExpirationQueue(s.store, part.ExpirationsEpochs, quant, miner8.PartitionExpirationAmtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var exp miner8.ExpirationSet
|
||||
return q.ForEach(&exp, func(epoch int64) error {
|
||||
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if early {
|
||||
out.Early = abi.ChainEpoch(epoch)
|
||||
return nil
|
||||
}
|
||||
if onTime, err := exp.OnTimeSectors.IsSet(uint64(num)); err != nil {
|
||||
return err
|
||||
} else if onTime {
|
||||
out.OnTime = abi.ChainEpoch(epoch)
|
||||
return stopErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
})
|
||||
})
|
||||
if err == stopErr {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out.Early == 0 && out.OnTime == 0 {
|
||||
return nil, xerrors.Errorf("failed to find sector %d", num)
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) {
|
||||
info, ok, err := s.State.GetPrecommittedSector(s.store, num)
|
||||
if !ok || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := fromV8SectorPreCommitOnChainInfo(*info)
|
||||
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
func (s *state8) ForEachPrecommittedSector(cb func(SectorPreCommitOnChainInfo) error) error {
|
||||
precommitted, err := adt8.AsMap(s.store, s.State.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var info miner8.SectorPreCommitOnChainInfo
|
||||
if err := precommitted.ForEach(&info, func(_ string) error {
|
||||
return cb(fromV8SectorPreCommitOnChainInfo(info))
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) LoadSectors(snos *bitfield.BitField) ([]*SectorOnChainInfo, error) {
|
||||
sectors, err := miner8.LoadSectors(s.store, s.State.Sectors)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If no sector numbers are specified, load all.
|
||||
if snos == nil {
|
||||
infos := make([]*SectorOnChainInfo, 0, sectors.Length())
|
||||
var info8 miner8.SectorOnChainInfo
|
||||
if err := sectors.ForEach(&info8, func(_ int64) error {
|
||||
info := fromV8SectorOnChainInfo(info8)
|
||||
infos = append(infos, &info)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
// Otherwise, load selected.
|
||||
infos8, err := sectors.Load(*snos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
infos := make([]*SectorOnChainInfo, len(infos8))
|
||||
for i, info8 := range infos8 {
|
||||
info := fromV8SectorOnChainInfo(*info8)
|
||||
infos[i] = &info
|
||||
}
|
||||
return infos, nil
|
||||
}
|
||||
|
||||
func (s *state8) loadAllocatedSectorNumbers() (bitfield.BitField, error) {
|
||||
var allocatedSectors bitfield.BitField
|
||||
err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors)
|
||||
return allocatedSectors, err
|
||||
}
|
||||
|
||||
func (s *state8) IsAllocated(num abi.SectorNumber) (bool, error) {
|
||||
allocatedSectors, err := s.loadAllocatedSectorNumbers()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return allocatedSectors.IsSet(uint64(num))
|
||||
}
|
||||
|
||||
func (s *state8) GetProvingPeriodStart() (abi.ChainEpoch, error) {
|
||||
return s.State.ProvingPeriodStart, nil
|
||||
}
|
||||
|
||||
func (s *state8) UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error) {
|
||||
allocatedSectors, err := s.loadAllocatedSectorNumbers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
allocatedRuns, err := allocatedSectors.RunIterator()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
unallocatedRuns, err := rle.Subtract(
|
||||
&rle.RunSliceIterator{Runs: []rle.Run{{Val: true, Len: abi.MaxSectorNumber}}},
|
||||
allocatedRuns,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iter, err := rle.BitsFromRuns(unallocatedRuns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sectors := make([]abi.SectorNumber, 0, count)
|
||||
for iter.HasNext() && len(sectors) < count {
|
||||
nextNo, err := iter.Next()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sectors = append(sectors, abi.SectorNumber(nextNo))
|
||||
}
|
||||
|
||||
return sectors, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetAllocatedSectors() (*bitfield.BitField, error) {
|
||||
var allocatedSectors bitfield.BitField
|
||||
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &allocatedSectors, nil
|
||||
}
|
||||
|
||||
func (s *state8) LoadDeadline(idx uint64) (Deadline, error) {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dl, err := dls.LoadDeadline(s.store, idx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &deadline8{*dl, s.store}, nil
|
||||
}
|
||||
|
||||
func (s *state8) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return dls.ForEach(s.store, func(i uint64, dl *miner8.Deadline) error {
|
||||
return cb(i, &deadline8{*dl, s.store})
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state8) NumDeadlines() (uint64, error) {
|
||||
return miner8.WPoStPeriodDeadlines, nil
|
||||
}
|
||||
|
||||
func (s *state8) DeadlinesChanged(other State) (bool, error) {
|
||||
other8, ok := other.(*state8)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return !s.State.Deadlines.Equals(other8.Deadlines), nil
|
||||
}
|
||||
|
||||
func (s *state8) MinerInfoChanged(other State) (bool, error) {
|
||||
other0, ok := other.(*state8)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.Info.Equals(other0.State.Info), nil
|
||||
}
|
||||
|
||||
func (s *state8) Info() (MinerInfo, error) {
|
||||
info, err := s.State.GetInfo(s.store)
|
||||
if err != nil {
|
||||
return MinerInfo{}, err
|
||||
}
|
||||
|
||||
var pid *peer.ID
|
||||
if peerID, err := peer.IDFromBytes(info.PeerId); err == nil {
|
||||
pid = &peerID
|
||||
}
|
||||
|
||||
mi := MinerInfo{
|
||||
Owner: info.Owner,
|
||||
Worker: info.Worker,
|
||||
ControlAddresses: info.ControlAddresses,
|
||||
|
||||
NewWorker: address.Undef,
|
||||
WorkerChangeEpoch: -1,
|
||||
|
||||
PeerId: pid,
|
||||
Multiaddrs: info.Multiaddrs,
|
||||
WindowPoStProofType: info.WindowPoStProofType,
|
||||
SectorSize: info.SectorSize,
|
||||
WindowPoStPartitionSectors: info.WindowPoStPartitionSectors,
|
||||
ConsensusFaultElapsed: info.ConsensusFaultElapsed,
|
||||
}
|
||||
|
||||
if info.PendingWorkerKey != nil {
|
||||
mi.NewWorker = info.PendingWorkerKey.NewWorker
|
||||
mi.WorkerChangeEpoch = info.PendingWorkerKey.EffectiveAt
|
||||
}
|
||||
|
||||
return mi, nil
|
||||
}
|
||||
|
||||
func (s *state8) DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error) {
|
||||
return s.State.RecordedDeadlineInfo(epoch), nil
|
||||
}
|
||||
|
||||
func (s *state8) DeadlineCronActive() (bool, error) {
|
||||
return s.State.DeadlineCronActive, nil
|
||||
}
|
||||
|
||||
func (s *state8) sectors() (adt.Array, error) {
|
||||
return adt8.AsArray(s.store, s.Sectors, miner8.SectorsAmtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) decodeSectorOnChainInfo(val *cbg.Deferred) (SectorOnChainInfo, error) {
|
||||
var si miner8.SectorOnChainInfo
|
||||
err := si.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return SectorOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV8SectorOnChainInfo(si), nil
|
||||
}
|
||||
|
||||
func (s *state8) precommits() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.PreCommittedSectors, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) decodeSectorPreCommitOnChainInfo(val *cbg.Deferred) (SectorPreCommitOnChainInfo, error) {
|
||||
var sp miner8.SectorPreCommitOnChainInfo
|
||||
err := sp.UnmarshalCBOR(bytes.NewReader(val.Raw))
|
||||
if err != nil {
|
||||
return SectorPreCommitOnChainInfo{}, err
|
||||
}
|
||||
|
||||
return fromV8SectorPreCommitOnChainInfo(sp), nil
|
||||
}
|
||||
|
||||
func (s *state8) EraseAllUnproven() error {
|
||||
|
||||
dls, err := s.State.LoadDeadlines(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = dls.ForEach(s.store, func(dindx uint64, dl *miner8.Deadline) error {
|
||||
ps, err := dl.PartitionsArray(s.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var part miner8.Partition
|
||||
err = ps.ForEach(&part, func(pindx int64) error {
|
||||
_ = part.ActivateUnproven()
|
||||
err = ps.Set(uint64(pindx), &part)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dl.Partitions, err = ps.Root()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dls.UpdateDeadline(s.store, dindx, dl)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.State.SaveDeadlines(s.store, dls)
|
||||
|
||||
}
|
||||
|
||||
func (d *deadline8) LoadPartition(idx uint64) (Partition, error) {
|
||||
p, err := d.Deadline.LoadPartition(d.store, idx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &partition8{*p, d.store}, nil
|
||||
}
|
||||
|
||||
func (d *deadline8) ForEachPartition(cb func(uint64, Partition) error) error {
|
||||
ps, err := d.Deadline.PartitionsArray(d.store)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var part miner8.Partition
|
||||
return ps.ForEach(&part, func(i int64) error {
|
||||
return cb(uint64(i), &partition8{part, d.store})
|
||||
})
|
||||
}
|
||||
|
||||
func (d *deadline8) PartitionsChanged(other Deadline) (bool, error) {
|
||||
other8, ok := other.(*deadline8)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return !d.Deadline.Partitions.Equals(other8.Deadline.Partitions), nil
|
||||
}
|
||||
|
||||
func (d *deadline8) PartitionsPoSted() (bitfield.BitField, error) {
|
||||
return d.Deadline.PartitionsPoSted, nil
|
||||
}
|
||||
|
||||
func (d *deadline8) DisputableProofCount() (uint64, error) {
|
||||
|
||||
ops, err := d.OptimisticProofsSnapshotArray(d.store)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return ops.Length(), nil
|
||||
|
||||
}
|
||||
|
||||
func (p *partition8) AllSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Sectors, nil
|
||||
}
|
||||
|
||||
func (p *partition8) FaultySectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Faults, nil
|
||||
}
|
||||
|
||||
func (p *partition8) RecoveringSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Recoveries, nil
|
||||
}
|
||||
|
||||
func (p *partition8) UnprovenSectors() (bitfield.BitField, error) {
|
||||
return p.Partition.Unproven, nil
|
||||
}
|
||||
|
||||
func fromV8SectorOnChainInfo(v8 miner8.SectorOnChainInfo) SectorOnChainInfo {
|
||||
info := SectorOnChainInfo{
|
||||
SectorNumber: v8.SectorNumber,
|
||||
SealProof: v8.SealProof,
|
||||
SealedCID: v8.SealedCID,
|
||||
DealIDs: v8.DealIDs,
|
||||
Activation: v8.Activation,
|
||||
Expiration: v8.Expiration,
|
||||
DealWeight: v8.DealWeight,
|
||||
VerifiedDealWeight: v8.VerifiedDealWeight,
|
||||
InitialPledge: v8.InitialPledge,
|
||||
ExpectedDayReward: v8.ExpectedDayReward,
|
||||
ExpectedStoragePledge: v8.ExpectedStoragePledge,
|
||||
|
||||
SectorKeyCID: v8.SectorKeyCID,
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func fromV8SectorPreCommitOnChainInfo(v8 miner8.SectorPreCommitOnChainInfo) SectorPreCommitOnChainInfo {
|
||||
|
||||
return SectorPreCommitOnChainInfo{
|
||||
Info: (SectorPreCommitInfo)(v8.Info),
|
||||
PreCommitDeposit: v8.PreCommitDeposit,
|
||||
PreCommitEpoch: v8.PreCommitEpoch,
|
||||
DealWeight: v8.DealWeight,
|
||||
VerifiedDealWeight: v8.VerifiedDealWeight,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -32,6 +32,21 @@ func init() {
|
||||
{{end}}}
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "multisig" {
|
||||
return nil, xerrors.Errorf("actor code is not multisig: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.MultisigActorCodeID:
|
||||
@ -52,6 +67,10 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "multisig"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
71
chain/actors/builtin/multisig/message8.go
Normal file
71
chain/actors/builtin/multisig/message8.go
Normal file
@ -0,0 +1,71 @@
|
||||
package multisig
|
||||
|
||||
import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
init8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/init"
|
||||
multisig8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/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 message8 struct{ message0 }
|
||||
|
||||
func (m message8) Create(
|
||||
signers []address.Address, threshold uint64,
|
||||
unlockStart, unlockDuration abi.ChainEpoch,
|
||||
initialAmount abi.TokenAmount,
|
||||
) (*types.Message, error) {
|
||||
|
||||
lenAddrs := uint64(len(signers))
|
||||
|
||||
if lenAddrs < threshold {
|
||||
return nil, xerrors.Errorf("cannot require signing of more addresses than provided for multisig")
|
||||
}
|
||||
|
||||
if threshold == 0 {
|
||||
threshold = lenAddrs
|
||||
}
|
||||
|
||||
if m.from == address.Undef {
|
||||
return nil, xerrors.Errorf("must provide source address")
|
||||
}
|
||||
|
||||
// Set up constructor parameters for multisig
|
||||
msigParams := &multisig8.ConstructorParams{
|
||||
Signers: signers,
|
||||
NumApprovalsThreshold: threshold,
|
||||
UnlockDuration: unlockDuration,
|
||||
StartEpoch: unlockStart,
|
||||
}
|
||||
|
||||
enc, actErr := actors.SerializeParams(msigParams)
|
||||
if actErr != nil {
|
||||
return nil, actErr
|
||||
}
|
||||
|
||||
// new actors are created by invoking 'exec' on the init actor with the constructor params
|
||||
execParams := &init8.ExecParams{
|
||||
CodeCID: builtin8.MultisigActorCodeID,
|
||||
ConstructorParams: enc,
|
||||
}
|
||||
|
||||
enc, actErr = actors.SerializeParams(execParams)
|
||||
if actErr != nil {
|
||||
return nil, actErr
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
To: init_.Address,
|
||||
From: m.from,
|
||||
Method: builtin8.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
Value: initialAmount,
|
||||
}, nil
|
||||
}
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
msig0 "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
msig7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/multisig"
|
||||
msig8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/multisig"
|
||||
|
||||
builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
|
||||
@ -29,6 +29,8 @@ import (
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
@ -64,9 +66,49 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.MultisigActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "multisig" {
|
||||
return nil, xerrors.Errorf("actor code is not multisig: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.MultisigActorCodeID:
|
||||
@ -90,6 +132,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.MultisigActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.MultisigActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -118,11 +163,18 @@ func MakeState(store adt.Store, av actors.Version, signers []address.Address, th
|
||||
case actors.Version7:
|
||||
return make7(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store, signers, threshold, startEpoch, unlockDuration, initialBalance)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "multisig"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -146,6 +198,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.MultisigActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.MultisigActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
@ -171,7 +226,7 @@ type State interface {
|
||||
|
||||
type Transaction = msig0.Transaction
|
||||
|
||||
var Methods = builtin7.MethodsMultisig
|
||||
var Methods = builtin8.MethodsMultisig
|
||||
|
||||
func Message(version actors.Version, from address.Address) MessageBuilder {
|
||||
switch version {
|
||||
@ -196,6 +251,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
|
||||
|
||||
case actors.Version7:
|
||||
return message7{message0{from}}
|
||||
|
||||
case actors.Version8:
|
||||
return message8{message0{from}}
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported actors version: %d", version))
|
||||
}
|
||||
@ -219,13 +277,13 @@ type MessageBuilder interface {
|
||||
}
|
||||
|
||||
// this type is the same between v0 and v2
|
||||
type ProposalHashData = msig7.ProposalHashData
|
||||
type ProposeReturn = msig7.ProposeReturn
|
||||
type ProposeParams = msig7.ProposeParams
|
||||
type ApproveReturn = msig7.ApproveReturn
|
||||
type ProposalHashData = msig8.ProposalHashData
|
||||
type ProposeReturn = msig8.ProposeReturn
|
||||
type ProposeParams = msig8.ProposeParams
|
||||
type ApproveReturn = msig8.ApproveReturn
|
||||
|
||||
func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
|
||||
params := msig7.TxnIDParams{ID: msig7.TxnID(id)}
|
||||
params := msig8.TxnIDParams{ID: msig8.TxnID(id)}
|
||||
if data != nil {
|
||||
if data.Requester.Protocol() != address.ID {
|
||||
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)
|
||||
|
119
chain/actors/builtin/multisig/v8.go
Normal file
119
chain/actors/builtin/multisig/v8.go
Normal file
@ -0,0 +1,119 @@
|
||||
package multisig
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
msig8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/multisig"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store, signers []address.Address, threshold uint64, startEpoch abi.ChainEpoch, unlockDuration abi.ChainEpoch, initialBalance abi.TokenAmount) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = msig8.State{}
|
||||
out.State.Signers = signers
|
||||
out.State.NumApprovalsThreshold = threshold
|
||||
out.State.StartEpoch = startEpoch
|
||||
out.State.UnlockDuration = unlockDuration
|
||||
out.State.InitialBalance = initialBalance
|
||||
|
||||
em, err := adt8.StoreEmptyMap(store, builtin8.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State.PendingTxns = em
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
msig8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) LockedBalance(currEpoch abi.ChainEpoch) (abi.TokenAmount, error) {
|
||||
return s.State.AmountLocked(currEpoch - s.State.StartEpoch), nil
|
||||
}
|
||||
|
||||
func (s *state8) StartEpoch() (abi.ChainEpoch, error) {
|
||||
return s.State.StartEpoch, nil
|
||||
}
|
||||
|
||||
func (s *state8) UnlockDuration() (abi.ChainEpoch, error) {
|
||||
return s.State.UnlockDuration, nil
|
||||
}
|
||||
|
||||
func (s *state8) InitialBalance() (abi.TokenAmount, error) {
|
||||
return s.State.InitialBalance, nil
|
||||
}
|
||||
|
||||
func (s *state8) Threshold() (uint64, error) {
|
||||
return s.State.NumApprovalsThreshold, nil
|
||||
}
|
||||
|
||||
func (s *state8) Signers() ([]address.Address, error) {
|
||||
return s.State.Signers, nil
|
||||
}
|
||||
|
||||
func (s *state8) ForEachPendingTxn(cb func(id int64, txn Transaction) error) error {
|
||||
arr, err := adt8.AsMap(s.store, s.State.PendingTxns, builtin8.DefaultHamtBitwidth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var out msig8.Transaction
|
||||
return arr.ForEach(&out, func(key string) error {
|
||||
txid, n := binary.Varint([]byte(key))
|
||||
if n <= 0 {
|
||||
return xerrors.Errorf("invalid pending transaction key: %v", key)
|
||||
}
|
||||
return cb(txid, (Transaction)(out)) //nolint:unconvert
|
||||
})
|
||||
}
|
||||
|
||||
func (s *state8) PendingTxnChanged(other State) (bool, error) {
|
||||
other8, ok := other.(*state8)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.PendingTxns.Equals(other8.PendingTxns), nil
|
||||
}
|
||||
|
||||
func (s *state8) transactions() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.PendingTxns, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) decodeTransaction(val *cbg.Deferred) (Transaction, error) {
|
||||
var tx msig8.Transaction
|
||||
if err := tx.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return Transaction{}, err
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -33,6 +33,21 @@ func init() {
|
||||
|
||||
// Load returns an abstract copy of payment channel state, irregardless of actor version
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "paymentchannel" {
|
||||
return nil, xerrors.Errorf("actor code is not paymentchannel: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.PaymentChannelActorCodeID:
|
||||
@ -53,6 +68,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "paymentchannel"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
76
chain/actors/builtin/paych/message8.go
Normal file
76
chain/actors/builtin/paych/message8.go
Normal file
@ -0,0 +1,76 @@
|
||||
package paych
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
init8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/init"
|
||||
paych8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/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 message8 struct{ from address.Address }
|
||||
|
||||
func (m message8) Create(to address.Address, initialAmount abi.TokenAmount) (*types.Message, error) {
|
||||
params, aerr := actors.SerializeParams(&paych8.ConstructorParams{From: m.from, To: to})
|
||||
if aerr != nil {
|
||||
return nil, aerr
|
||||
}
|
||||
enc, aerr := actors.SerializeParams(&init8.ExecParams{
|
||||
CodeCID: builtin8.PaymentChannelActorCodeID,
|
||||
ConstructorParams: params,
|
||||
})
|
||||
if aerr != nil {
|
||||
return nil, aerr
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
To: init_.Address,
|
||||
From: m.from,
|
||||
Value: initialAmount,
|
||||
Method: builtin8.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m message8) Update(paych address.Address, sv *SignedVoucher, secret []byte) (*types.Message, error) {
|
||||
params, aerr := actors.SerializeParams(&paych8.UpdateChannelStateParams{
|
||||
|
||||
Sv: toV8SignedVoucher(*sv),
|
||||
|
||||
Secret: secret,
|
||||
})
|
||||
if aerr != nil {
|
||||
return nil, aerr
|
||||
}
|
||||
|
||||
return &types.Message{
|
||||
To: paych,
|
||||
From: m.from,
|
||||
Value: abi.NewTokenAmount(0),
|
||||
Method: builtin8.MethodsPaych.UpdateChannelState,
|
||||
Params: params,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m message8) Settle(paych address.Address) (*types.Message, error) {
|
||||
return &types.Message{
|
||||
To: paych,
|
||||
From: m.from,
|
||||
Value: abi.NewTokenAmount(0),
|
||||
Method: builtin8.MethodsPaych.Settle,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m message8) Collect(paych address.Address) (*types.Message, error) {
|
||||
return &types.Message{
|
||||
To: paych,
|
||||
From: m.from,
|
||||
Value: abi.NewTokenAmount(0),
|
||||
Method: builtin8.MethodsPaych.Collect,
|
||||
}, nil
|
||||
}
|
@ -29,6 +29,8 @@ import (
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
@ -64,10 +66,50 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.PaymentChannelActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
// Load returns an abstract copy of payment channel state, irregardless of actor version
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "paymentchannel" {
|
||||
return nil, xerrors.Errorf("actor code is not paymentchannel: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.PaymentChannelActorCodeID:
|
||||
@ -91,6 +133,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.PaymentChannelActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.PaymentChannelActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -119,11 +164,18 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version7:
|
||||
return make7(store)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "paymentchannel"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -147,6 +199,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.PaymentChannelActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.PaymentChannelActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
@ -200,7 +255,7 @@ func DecodeSignedVoucher(s string) (*SignedVoucher, error) {
|
||||
return &sv, nil
|
||||
}
|
||||
|
||||
var Methods = builtin7.MethodsPaych
|
||||
var Methods = builtin8.MethodsPaych
|
||||
|
||||
func Message(version actors.Version, from address.Address) MessageBuilder {
|
||||
switch version {
|
||||
@ -226,6 +281,9 @@ func Message(version actors.Version, from address.Address) MessageBuilder {
|
||||
case actors.Version7:
|
||||
return message7{from}
|
||||
|
||||
case actors.Version8:
|
||||
return message8{from}
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported actors version: %d", version))
|
||||
}
|
||||
|
130
chain/actors/builtin/paych/v8.go
Normal file
130
chain/actors/builtin/paych/v8.go
Normal file
@ -0,0 +1,130 @@
|
||||
package paych
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
paych8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/paych"
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = paych8.State{}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
paych8.State
|
||||
store adt.Store
|
||||
lsAmt *adt8.Array
|
||||
}
|
||||
|
||||
// Channel owner, who has funded the actor
|
||||
func (s *state8) From() (address.Address, error) {
|
||||
return s.State.From, nil
|
||||
}
|
||||
|
||||
// Recipient of payouts from channel
|
||||
func (s *state8) To() (address.Address, error) {
|
||||
return s.State.To, nil
|
||||
}
|
||||
|
||||
// Height at which the channel can be `Collected`
|
||||
func (s *state8) SettlingAt() (abi.ChainEpoch, error) {
|
||||
return s.State.SettlingAt, nil
|
||||
}
|
||||
|
||||
// Amount successfully redeemed through the payment channel, paid out on `Collect()`
|
||||
func (s *state8) ToSend() (abi.TokenAmount, error) {
|
||||
return s.State.ToSend, nil
|
||||
}
|
||||
|
||||
func (s *state8) getOrLoadLsAmt() (*adt8.Array, error) {
|
||||
if s.lsAmt != nil {
|
||||
return s.lsAmt, nil
|
||||
}
|
||||
|
||||
// Get the lane state from the chain
|
||||
lsamt, err := adt8.AsArray(s.store, s.State.LaneStates, paych8.LaneStatesAmtBitwidth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.lsAmt = lsamt
|
||||
return lsamt, nil
|
||||
}
|
||||
|
||||
// Get total number of lanes
|
||||
func (s *state8) LaneCount() (uint64, error) {
|
||||
lsamt, err := s.getOrLoadLsAmt()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return lsamt.Length(), nil
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
// Iterate lane states
|
||||
func (s *state8) 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 paych8.LaneState
|
||||
return lsamt.ForEach(&ls, func(i int64) error {
|
||||
return cb(uint64(i), &laneState8{ls})
|
||||
})
|
||||
}
|
||||
|
||||
type laneState8 struct {
|
||||
paych8.LaneState
|
||||
}
|
||||
|
||||
func (ls *laneState8) Redeemed() (big.Int, error) {
|
||||
return ls.LaneState.Redeemed, nil
|
||||
}
|
||||
|
||||
func (ls *laneState8) Nonce() (uint64, error) {
|
||||
return ls.LaneState.Nonce, nil
|
||||
}
|
||||
|
||||
func toV8SignedVoucher(sv SignedVoucher) paych8.SignedVoucher {
|
||||
return paych8.SignedVoucher{
|
||||
ChannelAddr: sv.ChannelAddr,
|
||||
TimeLockMin: sv.TimeLockMin,
|
||||
TimeLockMax: sv.TimeLockMax,
|
||||
SecretHash: sv.SecretPreimage,
|
||||
Extra: sv.Extra,
|
||||
Lane: sv.Lane,
|
||||
Nonce: sv.Nonce,
|
||||
Amount: sv.Amount,
|
||||
MinSettleHeight: sv.MinSettleHeight,
|
||||
Merges: sv.Merges,
|
||||
Signature: sv.Signature,
|
||||
}
|
||||
}
|
@ -32,6 +32,21 @@ var (
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "storagepower" {
|
||||
return nil, xerrors.Errorf("actor code is not storagepower: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.StoragePowerActorCodeID:
|
||||
@ -52,6 +67,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "storagepower"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
@ -28,6 +28,8 @@ import (
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -59,14 +61,54 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.StoragePowerActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin7.StoragePowerActorAddr
|
||||
Methods = builtin7.MethodsPower
|
||||
Address = builtin8.StoragePowerActorAddr
|
||||
Methods = builtin8.MethodsPower
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "storagepower" {
|
||||
return nil, xerrors.Errorf("actor code is not storagepower: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.StoragePowerActorCodeID:
|
||||
@ -90,6 +132,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.StoragePowerActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.StoragePowerActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -118,11 +163,18 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version7:
|
||||
return make7(store)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "storagepower"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -146,6 +198,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.StoragePowerActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.StoragePowerActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
|
187
chain/actors/builtin/power/v8.go
Normal file
187
chain/actors/builtin/power/v8.go
Normal file
@ -0,0 +1,187 @@
|
||||
package power
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
power8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/power"
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store) (State, error) {
|
||||
out := state8{store: store}
|
||||
|
||||
s, err := power8.ConstructState(store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
power8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) TotalLocked() (abi.TokenAmount, error) {
|
||||
return s.TotalPledgeCollateral, nil
|
||||
}
|
||||
|
||||
func (s *state8) 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 *state8) TotalCommitted() (Claim, error) {
|
||||
return Claim{
|
||||
RawBytePower: s.TotalBytesCommitted,
|
||||
QualityAdjPower: s.TotalQABytesCommitted,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *state8) MinerPower(addr address.Address) (Claim, bool, error) {
|
||||
claims, err := s.claims()
|
||||
if err != nil {
|
||||
return Claim{}, false, err
|
||||
}
|
||||
var claim power8.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 *state8) MinerNominalPowerMeetsConsensusMinimum(a address.Address) (bool, error) {
|
||||
return s.State.MinerNominalPowerMeetsConsensusMinimum(s.store, a)
|
||||
}
|
||||
|
||||
func (s *state8) TotalPowerSmoothed() (builtin.FilterEstimate, error) {
|
||||
return builtin.FromV8FilterEstimate(s.State.ThisEpochQAPowerSmoothed), nil
|
||||
}
|
||||
|
||||
func (s *state8) MinerCounts() (uint64, uint64, error) {
|
||||
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
|
||||
}
|
||||
|
||||
func (s *state8) 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 *state8) ForEachClaim(cb func(miner address.Address, claim Claim) error) error {
|
||||
claims, err := s.claims()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var claim power8.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 *state8) ClaimsChanged(other State) (bool, error) {
|
||||
other8, ok := other.(*state8)
|
||||
if !ok {
|
||||
// treat an upgrade as a change, always
|
||||
return true, nil
|
||||
}
|
||||
return !s.State.Claims.Equals(other8.State.Claims), nil
|
||||
}
|
||||
|
||||
func (s *state8) SetTotalQualityAdjPower(p abi.StoragePower) error {
|
||||
s.State.TotalQualityAdjPower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) SetTotalRawBytePower(p abi.StoragePower) error {
|
||||
s.State.TotalRawBytePower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) SetThisEpochQualityAdjPower(p abi.StoragePower) error {
|
||||
s.State.ThisEpochQualityAdjPower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) SetThisEpochRawBytePower(p abi.StoragePower) error {
|
||||
s.State.ThisEpochRawBytePower = p
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
||||
|
||||
func (s *state8) claims() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.Claims, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) decodeClaim(val *cbg.Deferred) (Claim, error) {
|
||||
var ci power8.Claim
|
||||
if err := ci.UnmarshalCBOR(bytes.NewReader(val.Raw)); err != nil {
|
||||
return Claim{}, err
|
||||
}
|
||||
return fromV8Claim(ci), nil
|
||||
}
|
||||
|
||||
func fromV8Claim(v8 power8.Claim) Claim {
|
||||
return Claim{
|
||||
RawBytePower: v8.RawBytePower,
|
||||
QualityAdjPower: v8.QualityAdjPower,
|
||||
}
|
||||
}
|
@ -30,6 +30,21 @@ var (
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "reward" {
|
||||
return nil, xerrors.Errorf("actor code is not reward: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.RewardActorCodeID:
|
||||
@ -50,6 +65,10 @@ func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.Storage
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "reward"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
@ -23,6 +23,8 @@ import (
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -57,14 +59,54 @@ func init() {
|
||||
builtin.RegisterActorState(builtin7.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.RewardActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin7.RewardActorAddr
|
||||
Methods = builtin7.MethodsReward
|
||||
Address = builtin8.RewardActorAddr
|
||||
Methods = builtin8.MethodsReward
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "reward" {
|
||||
return nil, xerrors.Errorf("actor code is not reward: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.RewardActorCodeID:
|
||||
@ -88,6 +130,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.RewardActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.RewardActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -116,11 +161,18 @@ func MakeState(store adt.Store, av actors.Version, currRealizedPower abi.Storage
|
||||
case actors.Version7:
|
||||
return make7(store, currRealizedPower)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store, currRealizedPower)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "reward"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -144,6 +196,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.RewardActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.RewardActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
|
98
chain/actors/builtin/reward/v8.go
Normal file
98
chain/actors/builtin/reward/v8.go
Normal file
@ -0,0 +1,98 @@
|
||||
package reward
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner"
|
||||
reward8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/reward"
|
||||
smoothing8 "github.com/filecoin-project/specs-actors/v8/actors/util/smoothing"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store, currRealizedPower abi.StoragePower) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = *reward8.ConstructState(currRealizedPower)
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
reward8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) ThisEpochReward() (abi.TokenAmount, error) {
|
||||
return s.State.ThisEpochReward, nil
|
||||
}
|
||||
|
||||
func (s *state8) ThisEpochRewardSmoothed() (builtin.FilterEstimate, error) {
|
||||
|
||||
return builtin.FilterEstimate{
|
||||
PositionEstimate: s.State.ThisEpochRewardSmoothed.PositionEstimate,
|
||||
VelocityEstimate: s.State.ThisEpochRewardSmoothed.VelocityEstimate,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *state8) ThisEpochBaselinePower() (abi.StoragePower, error) {
|
||||
return s.State.ThisEpochBaselinePower, nil
|
||||
}
|
||||
|
||||
func (s *state8) TotalStoragePowerReward() (abi.TokenAmount, error) {
|
||||
return s.State.TotalStoragePowerReward, nil
|
||||
}
|
||||
|
||||
func (s *state8) EffectiveBaselinePower() (abi.StoragePower, error) {
|
||||
return s.State.EffectiveBaselinePower, nil
|
||||
}
|
||||
|
||||
func (s *state8) EffectiveNetworkTime() (abi.ChainEpoch, error) {
|
||||
return s.State.EffectiveNetworkTime, nil
|
||||
}
|
||||
|
||||
func (s *state8) CumsumBaseline() (reward8.Spacetime, error) {
|
||||
return s.State.CumsumBaseline, nil
|
||||
}
|
||||
|
||||
func (s *state8) CumsumRealized() (reward8.Spacetime, error) {
|
||||
return s.State.CumsumRealized, nil
|
||||
}
|
||||
|
||||
func (s *state8) InitialPledgeForPower(qaPower abi.StoragePower, networkTotalPledge abi.TokenAmount, networkQAPower *builtin.FilterEstimate, circSupply abi.TokenAmount) (abi.TokenAmount, error) {
|
||||
return miner8.InitialPledgeForPower(
|
||||
qaPower,
|
||||
s.State.ThisEpochBaselinePower,
|
||||
s.State.ThisEpochRewardSmoothed,
|
||||
smoothing8.FilterEstimate{
|
||||
PositionEstimate: networkQAPower.PositionEstimate,
|
||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||
},
|
||||
circSupply,
|
||||
), nil
|
||||
}
|
||||
|
||||
func (s *state8) PreCommitDepositForPower(networkQAPower builtin.FilterEstimate, sectorWeight abi.StoragePower) (abi.TokenAmount, error) {
|
||||
return miner8.PreCommitDepositForPower(s.State.ThisEpochRewardSmoothed,
|
||||
smoothing8.FilterEstimate{
|
||||
PositionEstimate: networkQAPower.PositionEstimate,
|
||||
VelocityEstimate: networkQAPower.VelocityEstimate,
|
||||
},
|
||||
sectorWeight), nil
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -26,6 +26,10 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "system"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
@ -19,10 +19,12 @@ import (
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
)
|
||||
|
||||
var (
|
||||
Address = builtin7.SystemActorAddr
|
||||
Address = builtin8.SystemActorAddr
|
||||
)
|
||||
|
||||
func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
@ -49,11 +51,18 @@ func MakeState(store adt.Store, av actors.Version) (State, error) {
|
||||
case actors.Version7:
|
||||
return make7(store)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "system"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -77,6 +86,9 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.SystemActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.SystemActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
|
35
chain/actors/builtin/system/v8.go
Normal file
35
chain/actors/builtin/system/v8.go
Normal file
@ -0,0 +1,35 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
system8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/system"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store) (State, error) {
|
||||
out := state8{store: store}
|
||||
out.State = system8.State{}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
system8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
|
||||
verifreg{{.latestVersion}} "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -33,6 +33,21 @@ var (
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "verifiedregistry" {
|
||||
return nil, xerrors.Errorf("actor code is not verifiedregistry: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
return load{{.}}(store, act.Head)
|
||||
{{end}}
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
{{range .versions}}
|
||||
case builtin{{.}}.VerifiedRegistryActorCodeID:
|
||||
@ -53,6 +68,10 @@ func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Addres
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "verifiedregistry"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
{{range .versions}}
|
||||
case actors.Version{{.}}:
|
||||
|
83
chain/actors/builtin/verifreg/v8.go
Normal file
83
chain/actors/builtin/verifreg/v8.go
Normal file
@ -0,0 +1,83 @@
|
||||
package verifreg
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
verifreg8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/verifreg"
|
||||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt"
|
||||
)
|
||||
|
||||
var _ State = (*state8)(nil)
|
||||
|
||||
func load8(store adt.Store, root cid.Cid) (State, error) {
|
||||
out := state8{store: store}
|
||||
err := store.Get(store.Context(), root, &out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func make8(store adt.Store, rootKeyAddress address.Address) (State, error) {
|
||||
out := state8{store: store}
|
||||
|
||||
s, err := verifreg8.ConstructState(store, rootKeyAddress)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.State = *s
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type state8 struct {
|
||||
verifreg8.State
|
||||
store adt.Store
|
||||
}
|
||||
|
||||
func (s *state8) RootKey() (address.Address, error) {
|
||||
return s.State.RootKey, nil
|
||||
}
|
||||
|
||||
func (s *state8) VerifiedClientDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||
return getDataCap(s.store, actors.Version8, s.verifiedClients, addr)
|
||||
}
|
||||
|
||||
func (s *state8) VerifierDataCap(addr address.Address) (bool, abi.StoragePower, error) {
|
||||
return getDataCap(s.store, actors.Version8, s.verifiers, addr)
|
||||
}
|
||||
|
||||
func (s *state8) RemoveDataCapProposalID(verifier address.Address, client address.Address) (bool, uint64, error) {
|
||||
return getRemoveDataCapProposalID(s.store, actors.Version8, s.removeDataCapProposalIDs, verifier, client)
|
||||
}
|
||||
|
||||
func (s *state8) ForEachVerifier(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||
return forEachCap(s.store, actors.Version8, s.verifiers, cb)
|
||||
}
|
||||
|
||||
func (s *state8) ForEachClient(cb func(addr address.Address, dcap abi.StoragePower) error) error {
|
||||
return forEachCap(s.store, actors.Version8, s.verifiedClients, cb)
|
||||
}
|
||||
|
||||
func (s *state8) verifiedClients() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.VerifiedClients, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) verifiers() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.Verifiers, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) removeDataCapProposalIDs() (adt.Map, error) {
|
||||
return adt8.AsMap(s.store, s.RemoveDataCapProposalIDs, builtin8.DefaultHamtBitwidth)
|
||||
}
|
||||
|
||||
func (s *state8) GetState() interface{} {
|
||||
return &s.State
|
||||
}
|
@ -23,11 +23,13 @@ import (
|
||||
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
|
||||
verifreg8 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -60,14 +62,54 @@ func init() {
|
||||
return load7(store, root)
|
||||
})
|
||||
|
||||
builtin.RegisterActorState(builtin8.VerifiedRegistryActorCodeID, func(store adt.Store, root cid.Cid) (cbor.Marshaler, error) {
|
||||
return load8(store, root)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
Address = builtin7.VerifiedRegistryActorAddr
|
||||
Methods = builtin7.MethodsVerifiedRegistry
|
||||
Address = builtin8.VerifiedRegistryActorAddr
|
||||
Methods = builtin8.MethodsVerifiedRegistry
|
||||
)
|
||||
|
||||
func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
||||
if name != "verifiedregistry" {
|
||||
return nil, xerrors.Errorf("actor code is not verifiedregistry: %s", name)
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
return load0(store, act.Head)
|
||||
|
||||
case actors.Version2:
|
||||
return load2(store, act.Head)
|
||||
|
||||
case actors.Version3:
|
||||
return load3(store, act.Head)
|
||||
|
||||
case actors.Version4:
|
||||
return load4(store, act.Head)
|
||||
|
||||
case actors.Version5:
|
||||
return load5(store, act.Head)
|
||||
|
||||
case actors.Version6:
|
||||
return load6(store, act.Head)
|
||||
|
||||
case actors.Version7:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case actors.Version8:
|
||||
return load8(store, act.Head)
|
||||
|
||||
default:
|
||||
return nil, xerrors.Errorf("unknown actor version: %d", av)
|
||||
}
|
||||
}
|
||||
|
||||
switch act.Code {
|
||||
|
||||
case builtin0.VerifiedRegistryActorCodeID:
|
||||
@ -91,6 +133,9 @@ func Load(store adt.Store, act *types.Actor) (State, error) {
|
||||
case builtin7.VerifiedRegistryActorCodeID:
|
||||
return load7(store, act.Head)
|
||||
|
||||
case builtin8.VerifiedRegistryActorCodeID:
|
||||
return load8(store, act.Head)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
||||
}
|
||||
@ -119,11 +164,18 @@ func MakeState(store adt.Store, av actors.Version, rootKeyAddress address.Addres
|
||||
case actors.Version7:
|
||||
return make7(store, rootKeyAddress)
|
||||
|
||||
case actors.Version8:
|
||||
return make8(store, rootKeyAddress)
|
||||
|
||||
}
|
||||
return nil, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
if c, ok := actors.GetActorCodeID(av, "verifiedregistry"); ok {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
switch av {
|
||||
|
||||
case actors.Version0:
|
||||
@ -147,17 +199,20 @@ func GetActorCodeID(av actors.Version) (cid.Cid, error) {
|
||||
case actors.Version7:
|
||||
return builtin7.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
case actors.Version8:
|
||||
return builtin8.VerifiedRegistryActorCodeID, nil
|
||||
|
||||
}
|
||||
|
||||
return cid.Undef, xerrors.Errorf("unknown actor version %d", av)
|
||||
}
|
||||
|
||||
type RemoveDataCapProposal = verifreg7.RemoveDataCapProposal
|
||||
type RemoveDataCapRequest = verifreg7.RemoveDataCapRequest
|
||||
type RemoveDataCapParams = verifreg7.RemoveDataCapParams
|
||||
type RmDcProposalID = verifreg7.RmDcProposalID
|
||||
type RemoveDataCapProposal = verifreg8.RemoveDataCapProposal
|
||||
type RemoveDataCapRequest = verifreg8.RemoveDataCapRequest
|
||||
type RemoveDataCapParams = verifreg8.RemoveDataCapParams
|
||||
type RmDcProposalID = verifreg8.RmDcProposalID
|
||||
|
||||
const SignatureDomainSeparation_RemoveDataCap = verifreg7.SignatureDomainSeparation_RemoveDataCap
|
||||
const SignatureDomainSeparation_RemoveDataCap = verifreg8.SignatureDomainSeparation_RemoveDataCap
|
||||
|
||||
type State interface {
|
||||
cbor.Marshaler
|
||||
|
137
chain/actors/manifest.go
Normal file
137
chain/actors/manifest.go
Normal file
@ -0,0 +1,137 @@
|
||||
package actors
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
cid "github.com/ipfs/go-cid"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
car "github.com/ipld/go-car"
|
||||
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/specs-actors/v8/actors/builtin/manifest"
|
||||
)
|
||||
|
||||
var manifestCids map[Version]cid.Cid = map[Version]cid.Cid{
|
||||
// TODO fill in manifest CIDs for v8 and upwards once these are fixed
|
||||
}
|
||||
|
||||
var manifests map[Version]*manifest.Manifest
|
||||
var actorMeta map[cid.Cid]actorEntry
|
||||
|
||||
var (
|
||||
loadOnce sync.Once
|
||||
loadError error
|
||||
|
||||
manifestMx sync.Mutex
|
||||
)
|
||||
|
||||
type actorEntry struct {
|
||||
name string
|
||||
version Version
|
||||
}
|
||||
|
||||
func AddManifest(av Version, manifestCid cid.Cid) {
|
||||
manifestMx.Lock()
|
||||
defer manifestMx.Unlock()
|
||||
|
||||
manifestCids[av] = manifestCid
|
||||
}
|
||||
|
||||
func GetManifest(av Version) (cid.Cid, bool) {
|
||||
manifestMx.Lock()
|
||||
defer manifestMx.Unlock()
|
||||
|
||||
c, ok := manifestCids[av]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
func LoadManifests(ctx context.Context, store cbor.IpldStore) error {
|
||||
// tests may invoke this concurrently, so we wrap it in a sync.Once
|
||||
loadOnce.Do(func() { loadError = loadManifests(ctx, store) })
|
||||
return loadError
|
||||
}
|
||||
|
||||
func loadManifests(ctx context.Context, store cbor.IpldStore) error {
|
||||
adtStore := adt.WrapStore(ctx, store)
|
||||
|
||||
manifests = make(map[Version]*manifest.Manifest)
|
||||
actorMeta = make(map[cid.Cid]actorEntry)
|
||||
|
||||
for av, mfCid := range manifestCids {
|
||||
mf := &manifest.Manifest{}
|
||||
if err := adtStore.Get(ctx, mfCid, mf); err != nil {
|
||||
return xerrors.Errorf("error reading manifest for network version %d (cid: %s): %w", av, mfCid, err)
|
||||
}
|
||||
|
||||
if err := mf.Load(ctx, adtStore); err != nil {
|
||||
return xerrors.Errorf("error loading manifest for network version %d: %w", av, err)
|
||||
}
|
||||
|
||||
manifests[av] = mf
|
||||
|
||||
for _, name := range []string{"system", "init", "cron", "account", "storagepower", "storageminer", "storagemarket", "paymentchannel", "multisig", "reward", "verifiedregistry"} {
|
||||
c, ok := mf.Get(name)
|
||||
if ok {
|
||||
actorMeta[c] = actorEntry{name: name, version: av}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetActorCodeID(av Version, name string) (cid.Cid, bool) {
|
||||
mf, ok := manifests[av]
|
||||
if ok {
|
||||
return mf.Get(name)
|
||||
}
|
||||
|
||||
return cid.Undef, false
|
||||
}
|
||||
|
||||
func GetActorMetaByCode(c cid.Cid) (string, Version, bool) {
|
||||
entry, ok := actorMeta[c]
|
||||
if !ok {
|
||||
return "", -1, false
|
||||
}
|
||||
|
||||
return entry.name, entry.version, true
|
||||
}
|
||||
|
||||
func CanonicalName(name string) string {
|
||||
idx := strings.LastIndex(name, "/")
|
||||
if idx >= 0 {
|
||||
return name[idx+1:]
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
|
||||
func LoadBundle(ctx context.Context, bs blockstore.Blockstore, av Version, data []byte) error {
|
||||
blobr := bytes.NewReader(data)
|
||||
|
||||
hdr, err := car.LoadCar(ctx, bs, blobr)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error loading builtin actors v%d bundle: %w", av, err)
|
||||
}
|
||||
|
||||
manifestCid := hdr.Roots[0]
|
||||
AddManifest(av, manifestCid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func LoadManifestFromBundle(ctx context.Context, bs blockstore.Blockstore, av Version, data []byte) error {
|
||||
if err := LoadBundle(ctx, bs, av, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cborStore := cbor.NewCborStore(bs)
|
||||
return LoadManifests(ctx, cborStore)
|
||||
}
|
@ -45,14 +45,19 @@ import (
|
||||
miner7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/miner"
|
||||
verifreg7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/verifreg"
|
||||
|
||||
paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych"
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
miner8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/miner"
|
||||
verifreg8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/verifreg"
|
||||
|
||||
paych8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/paych"
|
||||
)
|
||||
|
||||
const (
|
||||
ChainFinality = miner7.ChainFinality
|
||||
ChainFinality = miner8.ChainFinality
|
||||
SealRandomnessLookback = ChainFinality
|
||||
PaychSettleDelay = paych7.SettleDelay
|
||||
MaxPreCommitRandomnessLookback = builtin7.EpochsInDay + SealRandomnessLookback
|
||||
PaychSettleDelay = paych8.SettleDelay
|
||||
MaxPreCommitRandomnessLookback = builtin8.EpochsInDay + SealRandomnessLookback
|
||||
)
|
||||
|
||||
// SetSupportedProofTypes sets supported proof types, across all actor versions.
|
||||
@ -79,6 +84,8 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) {
|
||||
|
||||
miner7.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
|
||||
|
||||
miner8.PreCommitSealProofTypesV8 = make(map[abi.RegisteredSealProof]struct{}, len(types))
|
||||
|
||||
AddSupportedProofTypes(types...)
|
||||
}
|
||||
|
||||
@ -135,6 +142,15 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
|
||||
|
||||
miner7.WindowPoStProofTypes[wpp] = struct{}{}
|
||||
|
||||
miner8.PreCommitSealProofTypesV8[t+abi.RegisteredSealProof_StackedDrg2KiBV1_1] = struct{}{}
|
||||
wpp, err = t.RegisteredWindowPoStProof()
|
||||
if err != nil {
|
||||
// Fine to panic, this is a test-only method
|
||||
panic(err)
|
||||
}
|
||||
|
||||
miner8.WindowPoStProofTypes[wpp] = struct{}{}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,11 +173,13 @@ func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
|
||||
|
||||
miner7.PreCommitChallengeDelay = delay
|
||||
|
||||
miner8.PreCommitChallengeDelay = delay
|
||||
|
||||
}
|
||||
|
||||
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
|
||||
func GetPreCommitChallengeDelay() abi.ChainEpoch {
|
||||
return miner7.PreCommitChallengeDelay
|
||||
return miner8.PreCommitChallengeDelay
|
||||
}
|
||||
|
||||
// SetConsensusMinerMinPower sets the minimum power of an individual miner must
|
||||
@ -195,6 +213,10 @@ func SetConsensusMinerMinPower(p abi.StoragePower) {
|
||||
policy.ConsensusMinerMinPower = p
|
||||
}
|
||||
|
||||
for _, policy := range builtin8.PoStProofPolicies {
|
||||
policy.ConsensusMinerMinPower = p
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
|
||||
@ -215,6 +237,8 @@ func SetMinVerifiedDealSize(size abi.StoragePower) {
|
||||
|
||||
verifreg7.MinVerifiedDealSize = size
|
||||
|
||||
verifreg8.MinVerifiedDealSize = size
|
||||
|
||||
}
|
||||
|
||||
func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (abi.ChainEpoch, error) {
|
||||
@ -248,6 +272,10 @@ func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) (a
|
||||
|
||||
return miner7.MaxProveCommitDuration[t], nil
|
||||
|
||||
case actors.Version8:
|
||||
|
||||
return miner8.MaxProveCommitDuration[t], nil
|
||||
|
||||
default:
|
||||
return 0, xerrors.Errorf("unsupported actors version")
|
||||
}
|
||||
@ -288,6 +316,11 @@ func SetProviderCollateralSupplyTarget(num, denom big.Int) {
|
||||
Denominator: denom,
|
||||
}
|
||||
|
||||
market8.ProviderCollateralSupplyTarget = builtin8.BigFrac{
|
||||
Numerator: num,
|
||||
Denominator: denom,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func DealProviderCollateralBounds(
|
||||
@ -336,13 +369,18 @@ func DealProviderCollateralBounds(
|
||||
min, max := market7.DealProviderCollateralBounds(size, verified, rawBytePower, qaPower, baselinePower, circulatingFil)
|
||||
return min, max, nil
|
||||
|
||||
case actors.Version8:
|
||||
|
||||
min, max := market8.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 market7.DealDurationBounds(pieceSize)
|
||||
return market8.DealDurationBounds(pieceSize)
|
||||
}
|
||||
|
||||
// Sets the challenge window and scales the proving period to match (such that
|
||||
@ -390,6 +428,13 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) {
|
||||
// scale it if we're scaling the challenge period.
|
||||
miner7.WPoStDisputeWindow = period * 30
|
||||
|
||||
miner8.WPoStChallengeWindow = period
|
||||
miner8.WPoStProvingPeriod = period * abi.ChainEpoch(miner8.WPoStPeriodDeadlines)
|
||||
|
||||
// by default, this is 2x finality which is 30 periods.
|
||||
// scale it if we're scaling the challenge period.
|
||||
miner8.WPoStDisputeWindow = period * 30
|
||||
|
||||
}
|
||||
|
||||
func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
|
||||
@ -402,15 +447,15 @@ func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch {
|
||||
}
|
||||
|
||||
func GetMaxSectorExpirationExtension() abi.ChainEpoch {
|
||||
return miner7.MaxSectorExpirationExtension
|
||||
return miner8.MaxSectorExpirationExtension
|
||||
}
|
||||
|
||||
func GetMinSectorExpiration() abi.ChainEpoch {
|
||||
return miner7.MinSectorExpiration
|
||||
return miner8.MinSectorExpiration
|
||||
}
|
||||
|
||||
func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, error) {
|
||||
sectorsPerPart, err := builtin7.PoStProofWindowPoStPartitionSectors(p)
|
||||
sectorsPerPart, err := builtin8.PoStProofWindowPoStPartitionSectors(p)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -423,8 +468,8 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e
|
||||
|
||||
func GetDefaultSectorSize() abi.SectorSize {
|
||||
// supported sector sizes are the same across versions.
|
||||
szs := make([]abi.SectorSize, 0, len(miner7.PreCommitSealProofTypesV8))
|
||||
for spt := range miner7.PreCommitSealProofTypesV8 {
|
||||
szs := make([]abi.SectorSize, 0, len(miner8.PreCommitSealProofTypesV8))
|
||||
for spt := range miner8.PreCommitSealProofTypesV8 {
|
||||
ss, err := spt.SectorSize()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -449,7 +494,7 @@ func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version)
|
||||
return builtin4.SealProofPoliciesV0[proof].SectorMaxLifetime
|
||||
}
|
||||
|
||||
return builtin7.SealProofPoliciesV11[proof].SectorMaxLifetime
|
||||
return builtin8.SealProofPoliciesV11[proof].SectorMaxLifetime
|
||||
}
|
||||
|
||||
func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
|
||||
@ -480,6 +525,9 @@ func GetAddressedSectorsMax(nwVer network.Version) (int, error) {
|
||||
case actors.Version7:
|
||||
return miner7.AddressedSectorsMax, nil
|
||||
|
||||
case actors.Version8:
|
||||
return miner8.AddressedSectorsMax, nil
|
||||
|
||||
default:
|
||||
return 0, xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
@ -521,6 +569,10 @@ func GetDeclarationsMax(nwVer network.Version) (int, error) {
|
||||
|
||||
return miner7.DeclarationsMax, nil
|
||||
|
||||
case actors.Version8:
|
||||
|
||||
return miner8.DeclarationsMax, nil
|
||||
|
||||
default:
|
||||
return 0, xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
@ -561,6 +613,10 @@ func AggregateProveCommitNetworkFee(nwVer network.Version, aggregateSize int, ba
|
||||
|
||||
return miner7.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
case actors.Version8:
|
||||
|
||||
return miner8.AggregateProveCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
default:
|
||||
return big.Zero(), xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
@ -601,6 +657,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base
|
||||
|
||||
return miner7.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
case actors.Version8:
|
||||
|
||||
return miner8.AggregatePreCommitNetworkFee(aggregateSize, baseFee), nil
|
||||
|
||||
default:
|
||||
return big.Zero(), xerrors.Errorf("unsupported network version")
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ const ({{range .actorVersions}}
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
var LatestVersion = 7
|
||||
var LatestVersion = 8
|
||||
|
||||
var Versions = []int{0, 2, 3, 4, 5, 6, 7}
|
||||
var Versions = []int{0, 2, 3, 4, 5, 6, 7, 8}
|
||||
|
||||
const (
|
||||
Version0 Version = 0
|
||||
@ -32,6 +32,7 @@ const (
|
||||
Version5 Version = 5
|
||||
Version6 Version = 6
|
||||
Version7 Version = 7
|
||||
Version8 Version = 8
|
||||
)
|
||||
|
||||
/* inline-gen end */
|
||||
@ -53,6 +54,8 @@ func VersionForNetwork(version network.Version) (Version, error) {
|
||||
return Version6, nil
|
||||
case network.Version15:
|
||||
return Version7, nil
|
||||
case network.Version16:
|
||||
return Version8, nil
|
||||
default:
|
||||
return -1, fmt.Errorf("unsupported network version %d", version)
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import (
|
||||
exported5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/exported"
|
||||
exported6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/exported"
|
||||
exported7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/exported"
|
||||
exported8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/exported"
|
||||
|
||||
/* inline-gen end */
|
||||
|
||||
@ -52,17 +53,18 @@ func NewActorRegistry() *vm.ActorRegistry {
|
||||
// TODO: define all these properties on the actors themselves, in specs-actors.
|
||||
/* inline-gen template
|
||||
{{range .actorVersions}}
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version{{.}}), exported{{.}}.BuiltinActors()...){{end}}
|
||||
inv.Register(actors.Version{{.}}, vm.ActorsVersionPredicate(actors.Version{{.}}), exported{{.}}.BuiltinActors()...){{end}}
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...)
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...)
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...)
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...)
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...)
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...)
|
||||
inv.Register(vm.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...)
|
||||
inv.Register(actors.Version0, vm.ActorsVersionPredicate(actors.Version0), exported0.BuiltinActors()...)
|
||||
inv.Register(actors.Version2, vm.ActorsVersionPredicate(actors.Version2), exported2.BuiltinActors()...)
|
||||
inv.Register(actors.Version3, vm.ActorsVersionPredicate(actors.Version3), exported3.BuiltinActors()...)
|
||||
inv.Register(actors.Version4, vm.ActorsVersionPredicate(actors.Version4), exported4.BuiltinActors()...)
|
||||
inv.Register(actors.Version5, vm.ActorsVersionPredicate(actors.Version5), exported5.BuiltinActors()...)
|
||||
inv.Register(actors.Version6, vm.ActorsVersionPredicate(actors.Version6), exported6.BuiltinActors()...)
|
||||
inv.Register(actors.Version7, vm.ActorsVersionPredicate(actors.Version7), exported7.BuiltinActors()...)
|
||||
inv.Register(actors.Version8, vm.ActorsVersionPredicate(actors.Version8), exported8.BuiltinActors()...)
|
||||
|
||||
/* inline-gen end */
|
||||
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/v8/actors/migration/nv16"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/v6/actors/migration/nv14"
|
||||
@ -34,6 +36,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
|
||||
"github.com/filecoin-project/lotus/chain/state"
|
||||
@ -170,6 +173,17 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
|
||||
StopWithin: 5,
|
||||
}},
|
||||
Expensive: true,
|
||||
}, {
|
||||
Height: build.UpgradeFVM1Height,
|
||||
Network: network.Version16,
|
||||
Migration: UpgradeActorsV8,
|
||||
PreMigrations: []stmgr.PreMigration{{
|
||||
PreMigration: PreUpgradeActorsV8,
|
||||
StartWithin: 180,
|
||||
DontStartWithin: 60,
|
||||
StopWithin: 5,
|
||||
}},
|
||||
Expensive: true,
|
||||
},
|
||||
}
|
||||
|
||||
@ -1304,6 +1318,105 @@ func upgradeActorsV7Common(
|
||||
return newRoot, nil
|
||||
}
|
||||
|
||||
func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||
// Use all the CPUs except 3.
|
||||
workerCount := runtime.NumCPU() - 3
|
||||
if workerCount <= 0 {
|
||||
workerCount = 1
|
||||
}
|
||||
|
||||
config := nv16.Config{
|
||||
MaxWorkers: uint(workerCount),
|
||||
JobQueueSize: 1000,
|
||||
ResultQueueSize: 100,
|
||||
ProgressLogPeriod: 10 * time.Second,
|
||||
}
|
||||
|
||||
newRoot, err := upgradeActorsV8Common(ctx, sm, cache, root, epoch, ts, config)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("migrating actors v6 state: %w", err)
|
||||
}
|
||||
|
||||
return newRoot, nil
|
||||
}
|
||||
|
||||
func PreUpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
|
||||
// Use half the CPUs for pre-migration, but leave at least 3.
|
||||
workerCount := runtime.NumCPU()
|
||||
if workerCount <= 4 {
|
||||
workerCount = 1
|
||||
} else {
|
||||
workerCount /= 2
|
||||
}
|
||||
|
||||
lbts, lbRoot, err := stmgr.GetLookbackTipSetForRound(ctx, sm, ts, epoch)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error getting lookback ts for premigration: %w", err)
|
||||
}
|
||||
|
||||
config := nv16.Config{MaxWorkers: uint(workerCount),
|
||||
ProgressLogPeriod: time.Minute * 5}
|
||||
|
||||
_, err = upgradeActorsV8Common(ctx, sm, cache, lbRoot, epoch, lbts, config)
|
||||
return err
|
||||
}
|
||||
|
||||
func upgradeActorsV8Common(
|
||||
ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
||||
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet,
|
||||
config nv16.Config,
|
||||
) (cid.Cid, error) {
|
||||
buf := blockstore.NewTieredBstore(sm.ChainStore().StateBlockstore(), blockstore.NewMemorySync())
|
||||
store := store.ActorStore(ctx, buf)
|
||||
|
||||
// Load the state root.
|
||||
var stateRoot types.StateRoot
|
||||
if err := store.Get(ctx, root, &stateRoot); err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to decode state root: %w", err)
|
||||
}
|
||||
|
||||
if stateRoot.Version != types.StateTreeVersion4 {
|
||||
return cid.Undef, xerrors.Errorf(
|
||||
"expected state root version 4 for actors v8 upgrade, got %d",
|
||||
stateRoot.Version,
|
||||
)
|
||||
}
|
||||
|
||||
manifest, ok := actors.GetManifest(actors.Version8)
|
||||
if !ok {
|
||||
return cid.Undef, xerrors.Errorf("no manifest CID for v8 upgrade")
|
||||
}
|
||||
|
||||
// Perform the migration
|
||||
newHamtRoot, err := nv16.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, migrationLogger{}, cache)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("upgrading to actors v8: %w", err)
|
||||
}
|
||||
|
||||
// Persist the result.
|
||||
newRoot, err := store.Put(ctx, &types.StateRoot{
|
||||
Version: types.StateTreeVersion4,
|
||||
Actors: newHamtRoot,
|
||||
Info: stateRoot.Info,
|
||||
})
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err)
|
||||
}
|
||||
|
||||
// Persist the new tree.
|
||||
|
||||
{
|
||||
from := buf
|
||||
to := buf.Read()
|
||||
|
||||
if err := vm.Copy(ctx, from, to, newRoot); err != nil {
|
||||
return cid.Undef, xerrors.Errorf("copying migrated tree: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return newRoot, nil
|
||||
}
|
||||
|
||||
type migrationLogger struct{}
|
||||
|
||||
func (ml migrationLogger) Log(level rt.LogLevel, msg string, args ...interface{}) {
|
||||
|
@ -3,11 +3,16 @@ package genesis
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/system"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/v8/actors/builtin/manifest"
|
||||
system8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/system"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
|
||||
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||
@ -22,6 +27,21 @@ func SetupSystemActor(ctx context.Context, bs bstore.Blockstore, av actors.Versi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if av >= actors.Version8 {
|
||||
mfCid, ok := actors.GetManifest(av)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("missing manifest for actors version %d", av)
|
||||
}
|
||||
|
||||
mf := manifest.Manifest{}
|
||||
if err := cst.Get(ctx, mfCid, &mf); err != nil {
|
||||
return nil, xerrors.Errorf("loading manifest for actors version %d: %w", av, err)
|
||||
}
|
||||
|
||||
st8 := st.GetState().(*system8.State)
|
||||
st8.BuiltinActors = mf.Data
|
||||
}
|
||||
|
||||
statecid, err := cst.Put(ctx, st.GetState())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -580,6 +580,23 @@ func MakeGenesisBlock(ctx context.Context, j journal.Journal, bs bstore.Blocksto
|
||||
return nil, xerrors.Errorf("setup miners failed: %w", err)
|
||||
}
|
||||
|
||||
if template.NetworkVersion >= network.Version16 {
|
||||
st, err := state.LoadStateTree(cbor.NewCborStore(bs), stateroot)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("error loading state tree")
|
||||
}
|
||||
|
||||
err = patchManifestCodeCids(st, template.NetworkVersion)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("error patching state tree: %w", err)
|
||||
}
|
||||
|
||||
stateroot, err = st.Flush(ctx)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("flush state tree failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
store := adt.WrapStore(ctx, cbor.NewCborStore(bs))
|
||||
emptyroot, err := adt0.MakeEmptyArray(store).Root()
|
||||
if err != nil {
|
||||
|
@ -5,10 +5,13 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/state"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/vm"
|
||||
)
|
||||
@ -46,3 +49,36 @@ func doExecValue(ctx context.Context, vm *vm.LegacyVM, to, from address.Address,
|
||||
|
||||
return ret.Return, nil
|
||||
}
|
||||
|
||||
func patchManifestCodeCids(st *state.StateTree, nv network.Version) error {
|
||||
av, err := actors.VersionForNetwork(nv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var acts []address.Address
|
||||
err = st.ForEach(func(a address.Address, _ *types.Actor) error {
|
||||
acts = append(acts, a)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error collecting actors: %w", err)
|
||||
}
|
||||
|
||||
for _, a := range acts {
|
||||
err = st.MutateActor(a, func(act *types.Actor) error {
|
||||
name := actors.CanonicalName(builtin.ActorNameByCode(act.Code))
|
||||
code, ok := actors.GetActorCodeID(av, name)
|
||||
if ok {
|
||||
act.Code = code
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error mutating actor %s: %w", a, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) {
|
||||
|
||||
/* inline-gen start */
|
||||
|
||||
case network.Version13, network.Version14, network.Version15:
|
||||
case network.Version13, network.Version14, network.Version15, network.Version16:
|
||||
|
||||
/* inline-gen end */
|
||||
return types.StateTreeVersion4, nil
|
||||
|
@ -8,9 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/v7/actors/migration/nv15"
|
||||
"github.com/filecoin-project/specs-actors/v8/actors/migration/nv16"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
@ -19,6 +17,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init"
|
||||
@ -49,7 +48,8 @@ type MigrationCache interface {
|
||||
type MigrationFunc func(
|
||||
ctx context.Context,
|
||||
sm *StateManager, cache MigrationCache,
|
||||
cb ExecMonitor, oldState cid.Cid,
|
||||
cb ExecMonitor,
|
||||
oldState cid.Cid,
|
||||
height abi.ChainEpoch, ts *types.TipSet,
|
||||
) (newState cid.Cid, err error)
|
||||
|
||||
@ -214,7 +214,7 @@ func (sm *StateManager) hasExpensiveFork(height abi.ChainEpoch) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func runPreMigration(ctx context.Context, sm *StateManager, fn PreMigrationFunc, cache *nv15.MemMigrationCache, ts *types.TipSet) {
|
||||
func runPreMigration(ctx context.Context, sm *StateManager, fn PreMigrationFunc, cache *nv16.MemMigrationCache, ts *types.TipSet) {
|
||||
height := ts.Height()
|
||||
parent := ts.ParentState()
|
||||
|
||||
|
@ -168,7 +168,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
||||
}
|
||||
|
||||
inv := filcns.NewActorRegistry()
|
||||
inv.Register(nil, testActor{})
|
||||
inv.Register(actors.Version0, nil, testActor{})
|
||||
|
||||
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) {
|
||||
nvm, err := vm.NewLegacyVM(ctx, vmopt)
|
||||
@ -285,7 +285,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) {
|
||||
}
|
||||
|
||||
inv := filcns.NewActorRegistry()
|
||||
inv.Register(nil, testActor{})
|
||||
inv.Register(actors.Version0, nil, testActor{})
|
||||
|
||||
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) {
|
||||
nvm, err := vm.NewLegacyVM(ctx, vmopt)
|
||||
@ -506,7 +506,7 @@ func TestForkPreMigration(t *testing.T) {
|
||||
}()
|
||||
|
||||
inv := filcns.NewActorRegistry()
|
||||
inv.Register(nil, testActor{})
|
||||
inv.Register(actors.Version0, nil, testActor{})
|
||||
|
||||
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) {
|
||||
nvm, err := vm.NewLegacyVM(ctx, vmopt)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/v7/actors/migration/nv15"
|
||||
"github.com/filecoin-project/specs-actors/v8/actors/migration/nv16"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/rand"
|
||||
|
||||
@ -54,7 +54,7 @@ type versionSpec struct {
|
||||
type migration struct {
|
||||
upgrade MigrationFunc
|
||||
preMigrations []PreMigration
|
||||
cache *nv15.MemMigrationCache
|
||||
cache *nv16.MemMigrationCache
|
||||
}
|
||||
|
||||
type Executor interface {
|
||||
@ -122,7 +122,7 @@ func NewStateManager(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder,
|
||||
migration := &migration{
|
||||
upgrade: upgrade.Migration,
|
||||
preMigrations: upgrade.PreMigrations,
|
||||
cache: nv15.NewMemMigrationCache(),
|
||||
cache: nv16.NewMemMigrationCache(),
|
||||
}
|
||||
stateMigrations[upgrade.Height] = migration
|
||||
}
|
||||
|
@ -143,6 +143,14 @@ func prepSyncTestWithV5Height(t testing.TB, h int, v5height abi.ChainEpoch) *syn
|
||||
Network: network.Version14,
|
||||
Height: v5height + 10,
|
||||
Migration: filcns.UpgradeActorsV6,
|
||||
}, {
|
||||
Network: network.Version15,
|
||||
Height: v5height + 15,
|
||||
Migration: filcns.UpgradeActorsV7,
|
||||
}, {
|
||||
Network: network.Version16,
|
||||
Height: v5height + 20,
|
||||
Migration: filcns.UpgradeActorsV8,
|
||||
}}
|
||||
|
||||
g, err := gen.NewGeneratorWithUpgradeSchedule(sched)
|
||||
|
@ -3,6 +3,7 @@ package vm
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -29,6 +30,7 @@ import (
|
||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||
ffi_cgo "github.com/filecoin-project/filecoin-ffi/cgo"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -241,9 +243,15 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) {
|
||||
}
|
||||
}
|
||||
|
||||
fvmOpts := ffi.FVMOpts{
|
||||
FVMVersion: 0,
|
||||
Externs: &FvmExtern{Rand: opts.Rand, Blockstore: opts.Bstore, lbState: opts.LookbackState, base: opts.StateBase, epoch: opts.Epoch, nv: opts.NetworkVersion},
|
||||
fvmopts := &ffi.FVMOpts{
|
||||
FVMVersion: 0,
|
||||
Externs: &FvmExtern{
|
||||
Rand: opts.Rand,
|
||||
Blockstore: opts.Bstore,
|
||||
lbState: opts.LookbackState,
|
||||
base: opts.StateBase,
|
||||
epoch: opts.Epoch,
|
||||
},
|
||||
Epoch: opts.Epoch,
|
||||
BaseFee: opts.BaseFee,
|
||||
BaseCircSupply: circToReport,
|
||||
@ -251,7 +259,21 @@ func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) {
|
||||
StateBase: opts.StateBase,
|
||||
}
|
||||
|
||||
fvm, err := ffi.CreateFVM(&fvmOpts)
|
||||
if os.Getenv("LOTUS_USE_FVM_CUSTOM_BUNDLE") == "1" {
|
||||
av, err := actors.VersionForNetwork(opts.NetworkVersion)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("mapping network version to actors version: %w", err)
|
||||
}
|
||||
|
||||
c, ok := actors.GetManifest(av)
|
||||
if !ok {
|
||||
return nil, xerrors.Errorf("no manifest for custom bundle (actors version %d)", av)
|
||||
}
|
||||
|
||||
fvmopts.Manifest = c
|
||||
}
|
||||
|
||||
fvm, err := ffi.CreateFVM(fvmopts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -89,22 +89,38 @@ func (ar *ActorRegistry) Invoke(codeCid cid.Cid, rt vmr.Runtime, method abi.Meth
|
||||
|
||||
}
|
||||
|
||||
func (ar *ActorRegistry) Register(pred ActorPredicate, actors ...rtt.VMActor) {
|
||||
func (ar *ActorRegistry) Register(av actors.Version, pred ActorPredicate, vmactors ...rtt.VMActor) {
|
||||
if pred == nil {
|
||||
pred = func(vmr.Runtime, rtt.VMActor) error { return nil }
|
||||
}
|
||||
for _, a := range actors {
|
||||
for _, a := range vmactors {
|
||||
// register in the `actors` map (for the invoker)
|
||||
code, err := ar.transform(a)
|
||||
if err != nil {
|
||||
panic(xerrors.Errorf("%s: %w", string(a.Code().Hash()), err))
|
||||
}
|
||||
ar.actors[a.Code()] = &actorInfo{
|
||||
|
||||
ai := &actorInfo{
|
||||
methods: code,
|
||||
vmActor: a,
|
||||
predicate: pred,
|
||||
}
|
||||
|
||||
ac := a.Code()
|
||||
ar.actors[ac] = ai
|
||||
|
||||
// necessary to make stuff work
|
||||
var realCode cid.Cid
|
||||
if av >= actors.Version8 {
|
||||
name := actors.CanonicalName(builtin.ActorNameByCode(ac))
|
||||
|
||||
var ok bool
|
||||
realCode, ok = actors.GetActorCodeID(av, name)
|
||||
if ok {
|
||||
ar.actors[realCode] = ai
|
||||
}
|
||||
}
|
||||
|
||||
// register in the `Methods` map (used by statemanager utils)
|
||||
exports := a.Exports()
|
||||
methods := make(map[abi.MethodNum]MethodMeta, len(exports))
|
||||
@ -149,6 +165,9 @@ func (ar *ActorRegistry) Register(pred ActorPredicate, actors ...rtt.VMActor) {
|
||||
}
|
||||
}
|
||||
ar.Methods[a.Code()] = methods
|
||||
if realCode.Defined() {
|
||||
ar.Methods[realCode] = methods
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
builtin5 "github.com/filecoin-project/specs-actors/v5/actors/builtin"
|
||||
builtin6 "github.com/filecoin-project/specs-actors/v6/actors/builtin"
|
||||
builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin"
|
||||
builtin8 "github.com/filecoin-project/specs-actors/v8/actors/builtin"
|
||||
|
||||
/* inline-gen end */
|
||||
|
||||
@ -133,6 +134,8 @@ func newAccountActor(ver actors.Version) *types.Actor {
|
||||
code = builtin6.AccountActorCodeID
|
||||
case actors.Version7:
|
||||
code = builtin7.AccountActorCodeID
|
||||
case actors.Version8:
|
||||
code = builtin8.AccountActorCodeID
|
||||
/* inline-gen end */
|
||||
default:
|
||||
panic("unsupported actors version")
|
||||
|
@ -23,13 +23,17 @@ import (
|
||||
rt5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"
|
||||
rt6 "github.com/filecoin-project/specs-actors/v6/actors/runtime"
|
||||
rt7 "github.com/filecoin-project/specs-actors/v7/actors/runtime"
|
||||
rt8 "github.com/filecoin-project/specs-actors/v8/actors/runtime"
|
||||
"github.com/ipfs/go-cid"
|
||||
ipldcbor "github.com/ipfs/go-ipld-cbor"
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
"go.opencensus.io/trace"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/state"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -153,6 +157,7 @@ var _ rt4.Runtime = (*Runtime)(nil)
|
||||
var _ rt5.Runtime = (*Runtime)(nil)
|
||||
var _ rt6.Runtime = (*Runtime)(nil)
|
||||
var _ rt7.Runtime = (*Runtime)(nil)
|
||||
var _ rt8.Runtime = (*Runtime)(nil)
|
||||
|
||||
func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.ActorError) {
|
||||
defer func() {
|
||||
@ -220,6 +225,23 @@ func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool)
|
||||
panic(aerrors.Fatalf("failed to get actor: %s", err))
|
||||
}
|
||||
|
||||
// required for genesis/testing
|
||||
if nv := rt.NetworkVersion(); nv >= network.Version16 {
|
||||
name, av, ok := actors.GetActorMetaByCode(act.Code)
|
||||
|
||||
if ok {
|
||||
// lies, lies, lies
|
||||
builder := cid.V1Builder{Codec: cid.Raw, MhType: mh.IDENTITY}
|
||||
synthetic := fmt.Sprintf("fil/%d/%s", av, name)
|
||||
syntheticCid, err := builder.Sum([]byte(synthetic))
|
||||
if err != nil {
|
||||
panic(aerrors.Fatalf("failed to generate synthetic CID: %s", err))
|
||||
}
|
||||
|
||||
return syntheticCid, true
|
||||
}
|
||||
}
|
||||
|
||||
return act.Code, true
|
||||
}
|
||||
|
||||
@ -365,6 +387,20 @@ func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid) {
|
||||
if t == callerCid {
|
||||
return
|
||||
}
|
||||
|
||||
// this really only for genesis in tests; nv16 will be running on FVM anyway.
|
||||
if nv := rt.NetworkVersion(); nv >= network.Version16 {
|
||||
av, err := actors.VersionForNetwork(nv)
|
||||
if err != nil {
|
||||
panic(aerrors.Fatalf("failed to get actors version for network version %d", nv))
|
||||
}
|
||||
|
||||
name := actors.CanonicalName(builtin.ActorNameByCode(t))
|
||||
ac, ok := actors.GetActorCodeID(av, name)
|
||||
if ok && ac == callerCid {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
rt.Abortf(exitcode.SysErrForbidden, "caller cid type %q was not one of %v", callerCid, ts)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/ipfs/go-cid"
|
||||
)
|
||||
@ -19,6 +20,11 @@ type Interface interface {
|
||||
}
|
||||
|
||||
func NewVM(ctx context.Context, opts *VMOpts) (Interface, error) {
|
||||
if opts.NetworkVersion >= network.Version16 {
|
||||
return NewFVM(ctx, opts)
|
||||
}
|
||||
|
||||
// Remove after v16 upgrade, this is only to support testing and validation of the FVM
|
||||
if os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" {
|
||||
return NewFVM(ctx, opts)
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
|
||||
power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
@ -36,13 +38,13 @@ import (
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||
|
||||
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
||||
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
@ -214,6 +216,14 @@ var initCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if len(build.BuiltinActorsV8Bundle()) > 0 {
|
||||
bs := blockstore.NewMemory()
|
||||
|
||||
if err := actors.LoadManifestFromBundle(context.TODO(), bs, actors.Version8, build.BuiltinActorsV8Bundle()); err != nil {
|
||||
return xerrors.Errorf("error loading actor manifest: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
var localPaths []stores.LocalPath
|
||||
|
||||
if pssb := cctx.StringSlice("pre-sealed-sectors"); len(pssb) != 0 {
|
||||
@ -391,7 +401,7 @@ func migratePreSealMeta(ctx context.Context, api v1api.FullNode, metadata string
|
||||
return mds.Put(ctx, datastore.NewKey(modules.StorageCounterDSPrefix), buf[:size])
|
||||
}
|
||||
|
||||
func findMarketDealID(ctx context.Context, api v1api.FullNode, deal market2.DealProposal) (abi.DealID, error) {
|
||||
func findMarketDealID(ctx context.Context, api v1api.FullNode, deal market8.DealProposal) (abi.DealID, error) {
|
||||
// TODO: find a better way
|
||||
// (this is only used by genesis miners)
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
|
||||
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/wallet"
|
||||
@ -252,12 +252,17 @@ func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner,
|
||||
|
||||
func createDeals(m *genesis.Miner, k *wallet.Key, maddr address.Address, ssize abi.SectorSize) error {
|
||||
for i, sector := range m.Sectors {
|
||||
proposal := &market2.DealProposal{
|
||||
label, err := market8.NewLabelFromString(fmt.Sprintf("%d", i))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("error creating deal label: %w", err)
|
||||
}
|
||||
|
||||
proposal := &market8.DealProposal{
|
||||
PieceCID: sector.CommD,
|
||||
PieceSize: abi.PaddedPieceSize(ssize),
|
||||
Client: k.Address,
|
||||
Provider: maddr,
|
||||
Label: fmt.Sprintf("%d", i),
|
||||
Label: label,
|
||||
StartEpoch: 0,
|
||||
EndEpoch: 9001,
|
||||
StoragePricePerEpoch: big.Zero(),
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
|
||||
@ -99,7 +98,7 @@ var dealLabelCmd = &cli.Command{
|
||||
|
||||
var deals []abi.DealID
|
||||
if err = ps.ForEach(func(id abi.DealID, dp market.DealProposal) error {
|
||||
if !utf8.Valid([]byte(dp.Label)) {
|
||||
if dp.Label.IsBytes() {
|
||||
deals = append(deals, id)
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,16 @@ var terminationsCmd = &cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
label, err := prop.Label.ToString()
|
||||
if err != nil {
|
||||
labelBs, err := prop.Label.ToBytes()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
label = string(labelBs)
|
||||
}
|
||||
if find {
|
||||
fmt.Printf("%s, %d, %d, %s, %s, %s\n", msg.To, sector.SectorNumber, deal, prop.Client, prop.PieceCID, prop.Label)
|
||||
fmt.Printf("%s, %d, %d, %s, %s, %s\n", msg.To, sector.SectorNumber, deal, prop.Client, prop.PieceCID, label)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
||||
"github.com/filecoin-project/lotus/chain/state"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
@ -235,7 +236,8 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
|
||||
|
||||
// register the chaos actor if required by the vector.
|
||||
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
|
||||
invoker.Register(nil, chaos.Actor{})
|
||||
av, _ := actors.VersionForNetwork(params.NetworkVersion)
|
||||
invoker.Register(av, nil, chaos.Actor{})
|
||||
}
|
||||
|
||||
lvm.SetInvoker(invoker)
|
||||
|
@ -381,7 +381,7 @@ Inputs:
|
||||
],
|
||||
"Bw==",
|
||||
10101,
|
||||
15
|
||||
16
|
||||
]
|
||||
```
|
||||
|
||||
@ -707,7 +707,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -1158,7 +1158,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -1300,7 +1300,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -1335,7 +1335,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -1456,7 +1456,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -2711,7 +2711,7 @@ Inputs:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -3079,7 +3079,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
|
@ -5447,7 +5447,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -5525,7 +5525,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -6078,7 +6078,7 @@ Inputs:
|
||||
]
|
||||
```
|
||||
|
||||
Response: `15`
|
||||
Response: `16`
|
||||
|
||||
### StateReadState
|
||||
StateReadState returns the indicated actor's state.
|
||||
|
@ -5863,7 +5863,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -5941,7 +5941,7 @@ Response:
|
||||
"VerifiedDeal": true,
|
||||
"Client": "f01234",
|
||||
"Provider": "f01234",
|
||||
"Label": "string value",
|
||||
"Label": {},
|
||||
"StartEpoch": 10101,
|
||||
"EndEpoch": 10101,
|
||||
"StoragePricePerEpoch": "0",
|
||||
@ -6494,7 +6494,7 @@ Inputs:
|
||||
]
|
||||
```
|
||||
|
||||
Response: `15`
|
||||
Response: `16`
|
||||
|
||||
### StateReadState
|
||||
StateReadState returns the indicated actor's state.
|
||||
|
2
extern/filecoin-ffi
vendored
2
extern/filecoin-ffi
vendored
@ -1 +1 @@
|
||||
Subproject commit 38f10cf6fa078b989fc774081cd65ba5c53636d8
|
||||
Subproject commit 0c6d698610a98c9efcefc58d5277ee8813d80033
|
9
extern/storage-sealing/currentdealinfo.go
vendored
9
extern/storage-sealing/currentdealinfo.go
vendored
@ -4,15 +4,16 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
@ -120,7 +121,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context
|
||||
return dealID, nil, xerrors.Errorf("getting publish deal message %s: %w", publishCid, err)
|
||||
}
|
||||
|
||||
var pubDealsParams market2.PublishStorageDealsParams
|
||||
var pubDealsParams market8.PublishStorageDealsParams
|
||||
if err := pubDealsParams.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil {
|
||||
return dealID, nil, xerrors.Errorf("unmarshalling publish deal message params for message %s: %w", publishCid, err)
|
||||
}
|
||||
@ -173,7 +174,7 @@ func (mgr *CurrentDealInfoManager) CheckDealEquality(ctx context.Context, tok Ti
|
||||
return p1.PieceCID.Equals(p2.PieceCID) &&
|
||||
p1.PieceSize == p2.PieceSize &&
|
||||
p1.VerifiedDeal == p2.VerifiedDeal &&
|
||||
p1.Label == p2.Label &&
|
||||
p1.Label.Equals(p2.Label) &&
|
||||
p1.StartEpoch == p2.StartEpoch &&
|
||||
p1.EndEpoch == p2.EndEpoch &&
|
||||
p1.StoragePricePerEpoch.Equals(p2.StoragePricePerEpoch) &&
|
||||
|
25
extern/storage-sealing/currentdealinfo_test.go
vendored
25
extern/storage-sealing/currentdealinfo_test.go
vendored
@ -8,10 +8,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -23,7 +25,6 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
evtmock "github.com/filecoin-project/lotus/chain/events/state/mock"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
tutils "github.com/filecoin-project/specs-actors/v2/support/testing"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -32,6 +33,12 @@ import (
|
||||
var errNotFound = errors.New("could not find")
|
||||
|
||||
func TestGetCurrentDealInfo(t *testing.T) {
|
||||
success, err := market8.NewLabelFromString("success")
|
||||
require.NoError(t, err)
|
||||
|
||||
other, err := market8.NewLabelFromString("other")
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := context.Background()
|
||||
dummyCid, _ := cid.Parse("bafkqaaa")
|
||||
dummyCid2, _ := cid.Parse("bafkqaab")
|
||||
@ -46,7 +53,7 @@ func TestGetCurrentDealInfo(t *testing.T) {
|
||||
StoragePricePerEpoch: abi.NewTokenAmount(1),
|
||||
ProviderCollateral: abi.NewTokenAmount(1),
|
||||
ClientCollateral: abi.NewTokenAmount(1),
|
||||
Label: "success",
|
||||
Label: success,
|
||||
}
|
||||
otherProposal := market.DealProposal{
|
||||
PieceCID: dummyCid2,
|
||||
@ -56,7 +63,7 @@ func TestGetCurrentDealInfo(t *testing.T) {
|
||||
StoragePricePerEpoch: abi.NewTokenAmount(1),
|
||||
ProviderCollateral: abi.NewTokenAmount(1),
|
||||
ClientCollateral: abi.NewTokenAmount(1),
|
||||
Label: "other",
|
||||
Label: other,
|
||||
}
|
||||
successDeal := &api.MarketDeal{
|
||||
Proposal: proposal,
|
||||
@ -260,11 +267,11 @@ type CurrentDealInfoMockAPI struct {
|
||||
|
||||
func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.Cid) (*types.Message, error) {
|
||||
var dealIDs []abi.DealID
|
||||
var deals []market2.ClientDealProposal
|
||||
var deals []market.ClientDealProposal
|
||||
for k, dl := range mapi.MarketDeals {
|
||||
dealIDs = append(dealIDs, k.DealID)
|
||||
deals = append(deals, market2.ClientDealProposal{
|
||||
Proposal: market2.DealProposal(dl.Proposal),
|
||||
deals = append(deals, market.ClientDealProposal{
|
||||
Proposal: market8.DealProposal(dl.Proposal),
|
||||
ClientSignature: crypto.Signature{
|
||||
Data: []byte("foo bar cat dog"),
|
||||
Type: crypto.SigTypeBLS,
|
||||
@ -275,7 +282,7 @@ func (mapi *CurrentDealInfoMockAPI) ChainGetMessage(ctx context.Context, c cid.C
|
||||
return dealIDs[i] < dealIDs[j]
|
||||
})
|
||||
buf := new(bytes.Buffer)
|
||||
params := market2.PublishStorageDealsParams{Deals: deals}
|
||||
params := market.PublishStorageDealsParams{Deals: deals}
|
||||
err := params.MarshalCBOR(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
4
extern/storage-sealing/types_test.go
vendored
4
extern/storage-sealing/types_test.go
vendored
@ -11,8 +11,8 @@ import (
|
||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
api "github.com/filecoin-project/lotus/api"
|
||||
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
tutils "github.com/filecoin-project/specs-actors/v2/support/testing"
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
)
|
||||
|
||||
func TestSectorInfoSerialization(t *testing.T) {
|
||||
@ -29,7 +29,7 @@ func TestSectorInfoSerialization(t *testing.T) {
|
||||
StartEpoch: 0,
|
||||
EndEpoch: 100,
|
||||
},
|
||||
DealProposal: &market2.DealProposal{
|
||||
DealProposal: &market8.DealProposal{
|
||||
PieceCID: dummyCid,
|
||||
PieceSize: 5,
|
||||
Client: tutils.NewActorAddr(t, "client"),
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"actorVersions": [0, 2, 3, 4, 5, 6, 7],
|
||||
"latestActorsVersion": 7,
|
||||
"actorVersions": [0, 2, 3, 4, 5, 6, 7, 8],
|
||||
"latestActorsVersion": 8,
|
||||
|
||||
"networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
"latestNetworkVersion": 15
|
||||
"networkVersions": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
"latestNetworkVersion": 16
|
||||
}
|
||||
|
@ -3,14 +3,12 @@ package genesis
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
market8 "github.com/filecoin-project/specs-actors/v8/actors/builtin/market"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
||||
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
|
||||
)
|
||||
|
||||
type ActorType string
|
||||
@ -24,7 +22,7 @@ type PreSeal struct {
|
||||
CommR cid.Cid
|
||||
CommD cid.Cid
|
||||
SectorID abi.SectorNumber
|
||||
Deal market2.DealProposal
|
||||
Deal market8.DealProposal
|
||||
ProofType abi.RegisteredSealProof
|
||||
}
|
||||
|
||||
|
7
go.mod
7
go.mod
@ -38,16 +38,16 @@ require (
|
||||
github.com/filecoin-project/go-data-transfer v1.15.1
|
||||
github.com/filecoin-project/go-fil-commcid v0.1.0
|
||||
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0
|
||||
github.com/filecoin-project/go-fil-markets v1.20.1
|
||||
github.com/filecoin-project/go-fil-markets v1.20.2
|
||||
github.com/filecoin-project/go-jsonrpc v0.1.5
|
||||
github.com/filecoin-project/go-legs v0.3.7
|
||||
github.com/filecoin-project/go-legs v0.3.10
|
||||
github.com/filecoin-project/go-padreader v0.0.1
|
||||
github.com/filecoin-project/go-paramfetch v0.0.4
|
||||
github.com/filecoin-project/go-state-types v0.1.3
|
||||
github.com/filecoin-project/go-statemachine v1.0.2
|
||||
github.com/filecoin-project/go-statestore v0.2.0
|
||||
github.com/filecoin-project/go-storedcounter v0.1.0
|
||||
github.com/filecoin-project/index-provider v0.5.0
|
||||
github.com/filecoin-project/index-provider v0.6.1
|
||||
github.com/filecoin-project/specs-actors v0.9.14
|
||||
github.com/filecoin-project/specs-actors/v2 v2.3.6
|
||||
github.com/filecoin-project/specs-actors/v3 v3.1.1
|
||||
@ -55,6 +55,7 @@ require (
|
||||
github.com/filecoin-project/specs-actors/v5 v5.0.4
|
||||
github.com/filecoin-project/specs-actors/v6 v6.0.1
|
||||
github.com/filecoin-project/specs-actors/v7 v7.0.0
|
||||
github.com/filecoin-project/specs-actors/v8 v8.0.0-20220414161338-8ff313b3258a
|
||||
github.com/filecoin-project/specs-storage v0.2.2
|
||||
github.com/filecoin-project/test-vectors/schema v0.0.5
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.1
|
||||
|
33
go.sum
33
go.sum
@ -298,6 +298,7 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL
|
||||
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/filecoin-project/dagstore v0.5.2 h1:Nd6oXdnolbbVhpMpkYT5PJHOjQp4OBSntHpMV5pxj3c=
|
||||
github.com/filecoin-project/dagstore v0.5.2/go.mod h1:mdqKzYrRBHf1pRMthYfMv3n37oOw0Tkx7+TxPt240M0=
|
||||
github.com/filecoin-project/go-address v0.0.3/go.mod h1:jr8JxKsYx+lQlQZmF5i2U0Z+cGQ59wMIps/8YW/lDj8=
|
||||
@ -335,8 +336,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq
|
||||
github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
|
||||
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo=
|
||||
github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8=
|
||||
github.com/filecoin-project/go-fil-markets v1.20.1 h1:DwrFuNIWC0a2c2ESpHtdEMH3QCpR/hoZ5DwjNT+VJ+E=
|
||||
github.com/filecoin-project/go-fil-markets v1.20.1/go.mod h1:QV767KIWHrikVK8R0u2wTc5wkee4gXOf5/AfxDoQckw=
|
||||
github.com/filecoin-project/go-fil-markets v1.20.2 h1:OnfT3ggxksjz0IpPeWF4SvwVqQPmsQE3Ei4CB1Y/d0A=
|
||||
github.com/filecoin-project/go-fil-markets v1.20.2/go.mod h1:lhA01KAScD9S/N4J5On9Y3vXmqm/r2yWlKrbKRItLGY=
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM=
|
||||
github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24=
|
||||
github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM=
|
||||
@ -344,11 +345,11 @@ github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0/go.mod h1:7aWZdaQ1b16BVoQUYR+
|
||||
github.com/filecoin-project/go-hamt-ipld/v3 v3.0.1/go.mod h1:gXpNmr3oQx8l3o7qkGyDjJjYSRX7hp/FGOStdqrWyDI=
|
||||
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 h1:rVVNq0x6RGQIzCo1iiJlGFm9AGIZzeifggxtKMU7zmI=
|
||||
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBwFmYdT8SOFUwB3ovSUfG1Ux0g=
|
||||
github.com/filecoin-project/go-indexer-core v0.2.8/go.mod h1:IagNfTdFuX4057kla43PjRCn3yBuUiZgIxuA0hTUamY=
|
||||
github.com/filecoin-project/go-indexer-core v0.2.9/go.mod h1:u03I3HB6ZnqCc3cm8Tq+QkTWBbfKOvNxM8K6Ny/IHRw=
|
||||
github.com/filecoin-project/go-jsonrpc v0.1.5 h1:ckxqZ09ivBAVf5CSmxxrqqNHC7PJm3GYGtYKiNQ+vGk=
|
||||
github.com/filecoin-project/go-jsonrpc v0.1.5/go.mod h1:XBBpuKIMaXIIzeqzO1iucq4GvbF8CxmXRFoezRh+Cx4=
|
||||
github.com/filecoin-project/go-legs v0.3.7 h1:yfm7fx+iy1nPtgPEQ6kQjvhoJOVbXide50STYdy+yos=
|
||||
github.com/filecoin-project/go-legs v0.3.7/go.mod h1:pgekGm8/gKY5zCtQ/qGAoSjGP92wTLFqpO3GPHeu8YU=
|
||||
github.com/filecoin-project/go-legs v0.3.10 h1:B14z78do63gkxf5Br7rPnxZsZk/m9PR3Mx5aOf2WTIs=
|
||||
github.com/filecoin-project/go-legs v0.3.10/go.mod h1:5psVRe2nRQDa3PDtcd+2Ud4CirxOr2DI5VsDVMq7sIk=
|
||||
github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20/go.mod h1:mPn+LRRd5gEKNAtc+r3ScpW2JRU/pj4NBKdADYWHiak=
|
||||
github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6XHig+ynSGJg8ZOs=
|
||||
github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ=
|
||||
@ -359,11 +360,10 @@ github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go
|
||||
github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
|
||||
github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
|
||||
github.com/filecoin-project/go-state-types v0.1.1-0.20210810190654-139e0e79e69e/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
|
||||
github.com/filecoin-project/go-state-types v0.1.1/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
|
||||
github.com/filecoin-project/go-state-types v0.1.3 h1:rzIJyQo5HO2ptc8Jcu8P0qTutnI7NWwTle54eAHoNO0=
|
||||
github.com/filecoin-project/go-state-types v0.1.3/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
|
||||
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
|
||||
github.com/filecoin-project/go-statemachine v1.0.1/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
|
||||
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
|
||||
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
|
||||
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
|
||||
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
|
||||
@ -372,8 +372,8 @@ github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNd
|
||||
github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo=
|
||||
github.com/filecoin-project/go-storedcounter v0.1.0 h1:Mui6wSUBC+cQGHbDUBcO7rfh5zQkWJM/CpAZa/uOuus=
|
||||
github.com/filecoin-project/go-storedcounter v0.1.0/go.mod h1:4ceukaXi4vFURIoxYMfKzaRF5Xv/Pinh2oTnoxpv+z8=
|
||||
github.com/filecoin-project/index-provider v0.5.0 h1:k2C1RFvOvxmA2i8bhmkb3b4qun7RDRDzzs/y25/TwQg=
|
||||
github.com/filecoin-project/index-provider v0.5.0/go.mod h1:KHVrP2vU3YuScb+fawObwTFoR882up9U07kk0ZrfP0c=
|
||||
github.com/filecoin-project/index-provider v0.6.1 h1:yVpmtm1ASl2JZMNDC6H2Fe0neYo5akYgaJJB2wlcsMU=
|
||||
github.com/filecoin-project/index-provider v0.6.1/go.mod h1:iAbSQ6sUpKC4GqfUSheGnYwj9d9B+X8pPi4BV1PgwZA=
|
||||
github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
|
||||
github.com/filecoin-project/specs-actors v0.9.14 h1:68PVstg2UB3ZsMLF+DKFTAs/YKsqhKWynkr0IqmVRQY=
|
||||
github.com/filecoin-project/specs-actors v0.9.14/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
|
||||
@ -394,10 +394,13 @@ github.com/filecoin-project/specs-actors/v6 v6.0.1/go.mod h1:V1AYfi5GkHXipx1mnVi
|
||||
github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1.0.20220118005651-2470cb39827e/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M=
|
||||
github.com/filecoin-project/specs-actors/v7 v7.0.0 h1:FQN7tjt3o68hfb3qLFSJBoLMuOFY0REkFVLO/zXj8RU=
|
||||
github.com/filecoin-project/specs-actors/v7 v7.0.0/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M=
|
||||
github.com/filecoin-project/specs-actors/v8 v8.0.0-20220407202104-e375a8763a1c/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA=
|
||||
github.com/filecoin-project/specs-actors/v8 v8.0.0-20220414161338-8ff313b3258a h1:5M+1REWUeMsplhcrPwrU/ltUwiUqtaumPm7hwcZ3Ddg=
|
||||
github.com/filecoin-project/specs-actors/v8 v8.0.0-20220414161338-8ff313b3258a/go.mod h1:UYIPg65iPWoFw5NEftREdJwv9b/5yaLKdCgTvNI/2FA=
|
||||
github.com/filecoin-project/specs-storage v0.2.2 h1:6ugbtKQ6LTcTEnEIX9HkeCtTp1PCYO497P/bokF5tF4=
|
||||
github.com/filecoin-project/specs-storage v0.2.2/go.mod h1:6cc/lncmAxMUocPi0z1EPCX63beIX7F7UnlmUZ3hLQo=
|
||||
github.com/filecoin-project/storetheindex v0.3.5 h1:KoS9TvjPm6zIZfUH8atAHJbVHOO7GTP1MdTG+v0eE+Q=
|
||||
github.com/filecoin-project/storetheindex v0.3.5/go.mod h1:0r3d0kSpK63O6AvLr1CjAINLi+nWD49clzcnKV+GLpI=
|
||||
github.com/filecoin-project/storetheindex v0.4.0 h1:MPIDJYBknPbwBcVf+2/WEIK6LKxhZmfQGCrqKmvhFyU=
|
||||
github.com/filecoin-project/storetheindex v0.4.0/go.mod h1:LIwqpXoKeGxOGEjmxPfdYVPQYoZOSI3oXMUd9XTCpjc=
|
||||
github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg=
|
||||
github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
@ -588,6 +591,7 @@ github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f h1:KMlcu9X58lhTA
|
||||
github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
||||
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
|
||||
@ -934,7 +938,7 @@ github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd
|
||||
github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73/go.mod h1:2PJ0JgxyB08t0b2WKrcuqI3di0V+5n6RS/LTUJhkoxY=
|
||||
github.com/ipld/go-ipld-selector-text-lite v0.0.1 h1:lNqFsQpBHc3p5xHob2KvEg/iM5dIFn6iw4L/Hh+kS1Y=
|
||||
github.com/ipld/go-ipld-selector-text-lite v0.0.1/go.mod h1:U2CQmFb+uWzfIEF3I1arrDa5rwtj00PrpiwwCO+k1RM=
|
||||
github.com/ipld/go-storethehash v0.0.1/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ=
|
||||
github.com/ipld/go-storethehash v0.0.2/go.mod h1:w8cQfWInks8lvvbQTiKbCPusU9v0sqiViBihTHbavpQ=
|
||||
github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52 h1:QG4CGBqCeuBo6aZlGAamSkxWdgWfZGeE49eUOWJPA4c=
|
||||
github.com/ipsn/go-secp256k1 v0.0.0-20180726113642-9d62b9f0bc52/go.mod h1:fdg+/X9Gg4AsAIzWpEHwnqd+QY3b7lajxyjE1m4hkq4=
|
||||
github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA=
|
||||
@ -1070,7 +1074,7 @@ github.com/libp2p/go-libp2p v0.14.4/go.mod h1:EIRU0Of4J5S8rkockZM7eJp2S0UrCyi55m
|
||||
github.com/libp2p/go-libp2p v0.16.0/go.mod h1:ump42BsirwAWxKzsCiFnTtN1Yc+DuPu76fyMX364/O4=
|
||||
github.com/libp2p/go-libp2p v0.17.0/go.mod h1:Fkin50rsGdv5mm5BshBUtPRZknt9esfmYXBOYcwOTgw=
|
||||
github.com/libp2p/go-libp2p v0.18.0-rc1/go.mod h1:RgYlH7IIWHXREimC92bw5Lg1V2R5XmSzuLHb5fTnr+8=
|
||||
github.com/libp2p/go-libp2p v0.18.0-rc3/go.mod h1:WYL+Xw1iuwi6rdfzw5VIEpD+HqzYucHZ6fcUuumbI3M=
|
||||
github.com/libp2p/go-libp2p v0.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI=
|
||||
github.com/libp2p/go-libp2p v0.18.1 h1:IK9EOGNO2ZghU4F+dx9c4xfhMNZr45x06CijJaZE/ms=
|
||||
github.com/libp2p/go-libp2p v0.18.1/go.mod h1:ll44MqmrIFKpL3BwCexxzm+7RZ8exEtN96V1rRdMG7Y=
|
||||
github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo=
|
||||
@ -1269,7 +1273,6 @@ github.com/libp2p/go-libp2p-swarm v0.5.3/go.mod h1:NBn7eNW2lu568L7Ns9wdFrOhgRlkR
|
||||
github.com/libp2p/go-libp2p-swarm v0.8.0/go.mod h1:sOMp6dPuqco0r0GHTzfVheVBh6UEL0L1lXUZ5ot2Fvc=
|
||||
github.com/libp2p/go-libp2p-swarm v0.9.0/go.mod h1:2f8d8uxTJmpeqHF/1ujjdXZp+98nNIbujVOMEZxCbZ8=
|
||||
github.com/libp2p/go-libp2p-swarm v0.10.0/go.mod h1:71ceMcV6Rg/0rIQ97rsZWMzto1l9LnNquef+efcRbmA=
|
||||
github.com/libp2p/go-libp2p-swarm v0.10.1/go.mod h1:Pdkq0QU5a+qu+oyqIV3bknMsnzk9lnNyKvB9acJ5aZs=
|
||||
github.com/libp2p/go-libp2p-swarm v0.10.2 h1:UaXf+CTq6Ns1N2V1EgqJ9Q3xaRsiN7ImVlDMpirMAWw=
|
||||
github.com/libp2p/go-libp2p-swarm v0.10.2/go.mod h1:Pdkq0QU5a+qu+oyqIV3bknMsnzk9lnNyKvB9acJ5aZs=
|
||||
github.com/libp2p/go-libp2p-testing v0.0.1/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
|
||||
@ -1325,6 +1328,7 @@ github.com/libp2p/go-libp2p-yamux v0.6.0/go.mod h1:MRhd6mAYnFRnSISp4M8i0ClV/j+mW
|
||||
github.com/libp2p/go-libp2p-yamux v0.7.0/go.mod h1:fMyA0CsPfHkIuBU0wjRGrCjTBFiXTXxG0k5M4ETv+08=
|
||||
github.com/libp2p/go-libp2p-yamux v0.8.0/go.mod h1:yTkPgN2ib8FHyU1ZcVD7aelzyAqXXwEPbyx+aSKm9h8=
|
||||
github.com/libp2p/go-libp2p-yamux v0.8.1/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE=
|
||||
github.com/libp2p/go-libp2p-yamux v0.8.2/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE=
|
||||
github.com/libp2p/go-libp2p-yamux v0.9.0 h1:j+gnKykADCI/3cZlacOYBjQXDsncxgcwzJ1zw6Z6pts=
|
||||
github.com/libp2p/go-libp2p-yamux v0.9.0/go.mod h1:tpJKkRH9LlHj0VQh9Y9RP1pmF7yCS9ixxY/oSv+hhhQ=
|
||||
github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q=
|
||||
@ -1949,7 +1953,6 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20210118024343-169e9d70c0c2/go.mod h1:f
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20210303213153-67a261a1d291/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20210713220151-be142a5ae1a8/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20220224212727-7a699437a831/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14 h1:vo2wkP2ceHyGyZwFFtAabpot03EeSxxwAe57pOI9E/4=
|
||||
github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ=
|
||||
github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E=
|
||||
|
@ -26,8 +26,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/go-statestore"
|
||||
"github.com/filecoin-project/go-storedcounter"
|
||||
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
@ -59,6 +57,8 @@ import (
|
||||
testing2 "github.com/filecoin-project/lotus/node/modules/testing"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage/mockstorage"
|
||||
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||
power3 "github.com/filecoin-project/specs-actors/v3/actors/builtin/power"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -408,17 +408,20 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
|
||||
// we get the proof type for the requested sector size, for
|
||||
// the current network version.
|
||||
nv, err := m.FullNode.FullNode.StateNetworkVersion(ctx, types.EmptyTSK)
|
||||
require.NoError(n.t, err)
|
||||
// nv, err := m.FullNode.FullNode.StateNetworkVersion(ctx, types.EmptyTSK)
|
||||
// require.NoError(n.t, err)
|
||||
|
||||
proofType, err := miner.SealProofTypeFromSectorSize(m.options.sectorSize, nv)
|
||||
require.NoError(n.t, err)
|
||||
// TODO this doesn't currently work with the FVM -- we need to specify policy somehow
|
||||
// proofType, err := miner.WindowPoStProofTypeFromSectorSize(m.options.sectorSize)
|
||||
// require.NoError(n.t, err)
|
||||
// so do this instead, which works:
|
||||
proofType := abi.RegisteredPoStProof_StackedDrgWindow64GiBV1
|
||||
|
||||
params, aerr := actors.SerializeParams(&power2.CreateMinerParams{
|
||||
Owner: m.OwnerKey.Address,
|
||||
Worker: m.OwnerKey.Address,
|
||||
SealProofType: proofType,
|
||||
Peer: abi.PeerID(m.Libp2p.PeerID),
|
||||
params, aerr := actors.SerializeParams(&power3.CreateMinerParams{
|
||||
Owner: m.OwnerKey.Address,
|
||||
Worker: m.OwnerKey.Address,
|
||||
WindowPoStProofType: proofType,
|
||||
Peer: abi.PeerID(m.Libp2p.PeerID),
|
||||
})
|
||||
require.NoError(n.t, aerr)
|
||||
|
||||
@ -437,7 +440,7 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
require.NoError(n.t, err)
|
||||
require.Equal(n.t, exitcode.Ok, mw.Receipt.ExitCode)
|
||||
|
||||
var retval power2.CreateMinerReturn
|
||||
var retval power3.CreateMinerReturn
|
||||
err = retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return))
|
||||
require.NoError(n.t, err, "failed to create miner")
|
||||
|
||||
|
@ -49,12 +49,12 @@ func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt {
|
||||
})
|
||||
/* inline-gen start */
|
||||
return UpgradeSchedule(stmgr.Upgrade{
|
||||
Network: network.Version14,
|
||||
Network: network.Version15,
|
||||
Height: -1,
|
||||
}, stmgr.Upgrade{
|
||||
Network: network.Version15,
|
||||
Network: network.Version16,
|
||||
Height: upgradeHeight,
|
||||
Migration: filcns.UpgradeActorsV7,
|
||||
Migration: filcns.UpgradeActorsV8,
|
||||
})
|
||||
/* inline-gen end */
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user