Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean/mv-actors-bundle #11889

Draft
wants to merge 76 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d36245c
cfg edit 1
snadrus Jan 30, 2024
fb86554
jsonschema deps
snadrus Feb 1, 2024
f6f4d0e
feat: lp mig - first few steps
snadrus Feb 12, 2024
229645b
lp mig: default tasks
snadrus Feb 13, 2024
5a61b87
code comments
snadrus Feb 13, 2024
17ffd12
docs
snadrus Feb 13, 2024
0c8969d
lp-mig-progress
snadrus Feb 20, 2024
aa049ba
Merge branch 'master' into easyMigration
snadrus Feb 20, 2024
6765ac1
shared
snadrus Feb 20, 2024
d47b2f7
comments and todos
snadrus Feb 26, 2024
443b05c
fix: curio: rename lotus-provider to curio (#11645)
LexLuthr Feb 29, 2024
b686823
lp: channels doc
snadrus Feb 29, 2024
86f8624
Merge branch 'easyMigration' of https://github.com/filecoin-project/l…
snadrus Feb 29, 2024
5c2a86b
finish easy-migration TODOs
snadrus Mar 2, 2024
345dd9c
out generate
snadrus Mar 2, 2024
94e2a37
Merge branch 'master' into easyMigration
snadrus Mar 2, 2024
ef9e3f2
merging and more renames
snadrus Mar 2, 2024
af19d34
avoid make-all
snadrus Mar 3, 2024
590537e
minor doc stuff
snadrus Mar 5, 2024
3ff1e4d
cu: make gen
snadrus Mar 6, 2024
ea1dd33
make gen fix
snadrus Mar 6, 2024
0c3d0ce
conflict-resolve
snadrus Mar 6, 2024
dedad07
Merge branch 'master' into easyMigration
snadrus Mar 6, 2024
5470aec
make gen
snadrus Mar 7, 2024
6505b90
tryfix
snadrus Mar 7, 2024
9fa63fb
go mod tidy
snadrus Mar 7, 2024
4c7130e
minor ez migration fixes
snadrus Mar 7, 2024
5086714
ez setup - ui cleanups
snadrus Mar 8, 2024
11f21a0
better error message
snadrus Mar 8, 2024
9d4ed63
guided setup colors
snadrus Mar 8, 2024
ea0b09e
better path to saveconfigtolayer
snadrus Mar 8, 2024
b94a75c
loadconfigwithupgrades fix
snadrus Mar 8, 2024
795bc6d
readMiner oops
snadrus Mar 8, 2024
01886bc
guided - homedir
snadrus Mar 8, 2024
97cb2d0
err if miner is running
snadrus Mar 8, 2024
d520d5c
prompt error should exit
snadrus Mar 8, 2024
1e27ea7
process already running, miner_id sectors in migration
snadrus Mar 8, 2024
ded8122
dont prompt for language a second time
snadrus Mar 8, 2024
500c92b
check miner stopped
Mar 8, 2024
aab78c6
unlock repo
Mar 8, 2024
f03c7d3
render and sql oops
snadrus Mar 8, 2024
0daa23d
Merge branch 'easyMigration' of https://github.com/filecoin-project/l…
snadrus Mar 8, 2024
2e4711e
curio easyMig - some fixes
snadrus Mar 12, 2024
01eae29
easyMigration runs successfully
snadrus Mar 12, 2024
daa2df3
lint
snadrus Mar 12, 2024
445c4d2
Merge branch 'master' into feat/config-edit for easy merge later
snadrus Mar 13, 2024
d075e09
Merge branch 'easyMigration' into feat/config-edit for later simplifi…
snadrus Mar 13, 2024
7dedf18
part 2 of last
snadrus Mar 13, 2024
8de43ee
message
snadrus Apr 1, 2024
763bbfe
Merge branch 'master' into feat/config-edit
snadrus Apr 3, 2024
6634520
merge addtl
snadrus Apr 3, 2024
e2a9f2e
fixing guided setup for myself
snadrus Apr 3, 2024
cd78a66
warn-on-no-post
snadrus Apr 4, 2024
e934222
EditorLoads
snadrus Apr 5, 2024
a8da71b
cleanups and styles
snadrus Apr 6, 2024
1ce78fe
Merge branch 'master' into feat/config-edit
snadrus Apr 6, 2024
a69fb0c
create info
LexLuthr Apr 9, 2024
76fc81d
fix tests
LexLuthr Apr 9, 2024
7f822e6
make gen
snadrus Apr 9, 2024
3d6894f
Merge branch 'feat/config-edit' of https://github.com/filecoin-projec…
snadrus Apr 9, 2024
c009921
sector early bird
snadrus Apr 12, 2024
1d49deb
sectors v2
snadrus Apr 13, 2024
af07c48
sector termination v1
snadrus Apr 13, 2024
a3455de
terminate2
snadrus Apr 13, 2024
1dd8546
mjs
snadrus Apr 16, 2024
7454069
minor things
snadrus Apr 16, 2024
5a856c1
flag bad sectors
LexLuthr Apr 16, 2024
e777bed
Merge branch 'master' into feat/sector-ui
LexLuthr Apr 16, 2024
f8c6252
fix errors
LexLuthr Apr 16, 2024
0f294bf
Merge branch 'master' into feat/sector-ui
LexLuthr Apr 16, 2024
cc2429b
add dealweight and deals
LexLuthr Apr 16, 2024
d03b15d
change column width
LexLuthr Apr 17, 2024
e8d5638
1
snadrus Apr 17, 2024
54cf19e
actors
snadrus Apr 17, 2024
05546ba
cut some strings
snadrus Apr 18, 2024
962d9a6
gen fix
snadrus Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions build/builtin_actors.go → build/actors/builtin_actors.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package build
package actors

import (
"archive/tar"
Expand All @@ -21,31 +21,32 @@ import (
actorstypes "github.com/filecoin-project/go-state-types/actors"

"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/adt"
)

//go:embed actors/*.tar.zst
//go:embed *.tar.zst
var embeddedBuiltinActorReleases embed.FS

func init() {
if BundleOverrides == nil {
BundleOverrides = make(map[actorstypes.Version]string)
if build.BundleOverrides == nil {
build.BundleOverrides = make(map[actorstypes.Version]string)
}
for _, av := range actors.Versions {
path := os.Getenv(fmt.Sprintf("LOTUS_BUILTIN_ACTORS_V%d_BUNDLE", av))
if path == "" {
continue
}
BundleOverrides[actorstypes.Version(av)] = path
build.BundleOverrides[actorstypes.Version(av)] = path
}
if err := loadManifests(NetworkBundle); err != nil {
if err := loadManifests(build.NetworkBundle); err != nil {
panic(err)
}

// The following code cid existed temporarily on the calibnet testnet, as a "buggy" storage miner actor implementation.
// We include them in our builtin bundle, but intentionally omit from metadata.
if NetworkBundle == "calibrationnet" {
if build.NetworkBundle == "calibrationnet" {
actors.AddActorMeta("storageminer", cid.MustParse("bafk2bzacecnh2ouohmonvebq7uughh4h3ppmg4cjsk74dzxlbbtlcij4xbzxq"), actorstypes.Version12)
actors.AddActorMeta("storageminer", cid.MustParse("bafk2bzaced7emkbbnrewv5uvrokxpf5tlm4jslu2jsv77ofw2yqdglg657uie"), actorstypes.Version12)
actors.AddActorMeta("verifiedregistry", cid.MustParse("bafk2bzacednskl3bykz5qpo54z2j2p4q44t5of4ktd6vs6ymmg2zebsbxazkm"), actorstypes.Version13)
Expand All @@ -54,21 +55,21 @@ func init() {

// UseNetworkBundle switches to a different network bundle, by name.
func UseNetworkBundle(netw string) error {
if NetworkBundle == netw {
if build.NetworkBundle == netw {
return nil
}
if err := loadManifests(netw); err != nil {
return err
}
NetworkBundle = netw
build.NetworkBundle = netw
return nil
}

func loadManifests(netw string) error {
overridden := make(map[actorstypes.Version]struct{})
var newMetadata []*BuiltinActorsMetadata
// First, prefer overrides.
for av, path := range BundleOverrides {
for av, path := range build.BundleOverrides {
root, actorCids, err := readBundleManifestFromFile(path)
if err != nil {
return err
Expand Down Expand Up @@ -248,7 +249,7 @@ func readBundleManifest(r io.Reader) (cid.Cid, map[string]cid.Cid, error) {
}

// GetEmbeddedBuiltinActorsBundle returns the builtin-actors bundle for the given actors version.
func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version, networkBundleName string) ([]byte, bool) {
func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version, NetworkBundleName string) ([]byte, bool) {
fi, err := embeddedBuiltinActorReleases.Open(fmt.Sprintf("actors/v%d.tar.zst", version))
if err != nil {
return nil, false
Expand All @@ -259,7 +260,7 @@ func GetEmbeddedBuiltinActorsBundle(version actorstypes.Version, networkBundleNa
defer uncompressed.Close() //nolint

tarReader := tar.NewReader(uncompressed)
targetFileName := fmt.Sprintf("builtin-actors-%s.car", networkBundleName)
targetFileName := fmt.Sprintf("builtin-actors-%s.car", NetworkBundleName)
for {
header, err := tarReader.Next()
switch err {
Expand Down
951 changes: 951 additions & 0 deletions build/actors/builtin_actors_gen.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build release
// +build release

package build_test
package actors_test

import (
"archive/tar"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package build_test
package actors_test

import (
"testing"
Expand All @@ -8,17 +8,17 @@ import (
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/manifest"

"github.com/filecoin-project/lotus/build"
actors2 "github.com/filecoin-project/lotus/build/actors"
"github.com/filecoin-project/lotus/chain/actors"
)

// Test that the embedded metadata is correct.
func TestEmbeddedMetadata(t *testing.T) {
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
metadata, err := actors2.ReadEmbeddedBuiltinActorsMetadata()
require.NoError(t, err)

for i, v1 := range metadata {
v2 := build.EmbeddedBuiltinActorsMetadata[i]
v2 := actors2.EmbeddedBuiltinActorsMetadata[i]
require.Equal(t, v1.Network, v2.Network)
require.Equal(t, v1.Version, v2.Version)
require.Equal(t, v1.ManifestCid, v2.ManifestCid)
Expand Down
949 changes: 0 additions & 949 deletions build/builtin_actors_gen.go

This file was deleted.

9 changes: 5 additions & 4 deletions chain/consensus/filcns/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
actors2 "github.com/filecoin-project/lotus/build/actors"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
Expand Down Expand Up @@ -1962,7 +1963,7 @@ func upgradeActorsV12Common(

var manifestCid cid.Cid
if initState.NetworkName == "calibrationnet" {
embedded, ok := build.GetEmbeddedBuiltinActorsBundle(actorstypes.Version12, calibnetv12BuggyBundleSuffix1)
embedded, ok := actors2.GetEmbeddedBuiltinActorsBundle(actorstypes.Version12, calibnetv12BuggyBundleSuffix1)
if !ok {
return cid.Undef, xerrors.Errorf("didn't find buggy calibrationnet bundle")
}
Expand Down Expand Up @@ -2027,7 +2028,7 @@ func buildUpgradeActorsV12MinerFix(oldBuggyMinerCID, newManifestCID cid.Cid) fun
}

// this loads the second buggy bundle, for UpgradeWatermelonFixHeight
embedded, ok := build.GetEmbeddedBuiltinActorsBundle(actorstypes.Version12, calibnetv12BuggyBundleSuffix2)
embedded, ok := actors2.GetEmbeddedBuiltinActorsBundle(actorstypes.Version12, calibnetv12BuggyBundleSuffix2)
if !ok {
return cid.Undef, xerrors.Errorf("didn't find buggy calibrationnet bundle")
}
Expand Down Expand Up @@ -2260,7 +2261,7 @@ func upgradeActorsV13Common(

var manifestCid cid.Cid
if initState.NetworkName == "calibrationnet" {
embedded, ok := build.GetEmbeddedBuiltinActorsBundle(actorstypes.Version13, calibnetv13BuggyBundleSuffix1)
embedded, ok := actors2.GetEmbeddedBuiltinActorsBundle(actorstypes.Version13, calibnetv13BuggyBundleSuffix1)
if !ok {
return cid.Undef, xerrors.Errorf("didn't find buggy calibrationnet bundle")
}
Expand Down Expand Up @@ -2325,7 +2326,7 @@ func upgradeActorsV13VerifregFix(oldBuggyVerifregCID, newManifestCID cid.Cid) fu
}

// this loads the buggy bundle, for UpgradeDragonHeight
embedded, ok := build.GetEmbeddedBuiltinActorsBundle(actorstypes.Version13, calibnetv13BuggyBundleSuffix1)
embedded, ok := actors2.GetEmbeddedBuiltinActorsBundle(actorstypes.Version13, calibnetv13BuggyBundleSuffix1)
if !ok {
return cid.Undef, xerrors.Errorf("didn't find buggy calibrationnet bundle")
}
Expand Down
61 changes: 8 additions & 53 deletions chain/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package gen
import (
"bytes"
"context"
"fmt"
"io"
"os"
"sync/atomic"
Expand Down Expand Up @@ -34,6 +33,8 @@ import (
"github.com/filecoin-project/lotus/chain/consensus"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
"github.com/filecoin-project/lotus/chain/gen/gentypes"
"github.com/filecoin-project/lotus/chain/gen/genutils"
"github.com/filecoin-project/lotus/chain/index"
"github.com/filecoin-project/lotus/chain/rand"
"github.com/filecoin-project/lotus/chain/stmgr"
Expand Down Expand Up @@ -78,7 +79,7 @@ type ChainGen struct {

w *wallet.LocalWallet

eppProvs map[address.Address]WinningPoStProver
eppProvs map[address.Address]gentypes.WinningPoStProver
Miners []address.Address
receivers []address.Address
// a SecP address
Expand Down Expand Up @@ -244,7 +245,7 @@ func NewGeneratorWithSectorsAndUpgradeSchedule(numSectors int, us stmgr.UpgradeS
return nil, xerrors.Errorf("set genesis failed: %w", err)
}

mgen := make(map[address.Address]WinningPoStProver)
mgen := make(map[address.Address]gentypes.WinningPoStProver)
for i := range tpl.Miners {
mgen[genesis2.MinerAddress(uint64(i))] = &wppProvider{}
}
Expand Down Expand Up @@ -362,7 +363,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
rbase = entries[len(entries)-1]
}

eproof, err := IsRoundWinner(ctx, round, m, rbase, mbi, mc)
eproof, err := genutils.IsRoundWinner(ctx, round, m, rbase, mbi, mc)
if err != nil {
return nil, nil, nil, xerrors.Errorf("checking round winner failed: %w", err)
}
Expand Down Expand Up @@ -394,7 +395,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
})
}

vrfout, err := ComputeVRF(ctx, sf, worker, ticketRand)
vrfout, err := genutils.ComputeVRF(ctx, sf, worker, ticketRand)
if err != nil {
return nil, nil, nil, xerrors.Errorf("compute VRF: %w", err)
}
Expand All @@ -420,7 +421,7 @@ func (cg *ChainGen) NextTipSetWithNulls(nulls abi.ChainEpoch) (*MinedTipSet, err
return mts, nil
}

func (cg *ChainGen) SetWinningPoStProver(m address.Address, wpp WinningPoStProver) {
func (cg *ChainGen) SetWinningPoStProver(m address.Address, wpp gentypes.WinningPoStProver) {
cg.eppProvs[m] = wpp
}

Expand Down Expand Up @@ -624,10 +625,7 @@ func (mca mca) WalletSign(ctx context.Context, a address.Address, v []byte) (*cr
})
}

type WinningPoStProver interface {
GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof7.PoStProof, error)
}
type WinningPoStProver gentypes.WinningPoStProver

type wppProvider struct{}

Expand All @@ -639,49 +637,6 @@ func (wpp *wppProvider) ComputeProof(context.Context, []proof7.ExtendedSectorInf
return ValidWpostForTesting, nil
}

func IsRoundWinner(ctx context.Context, round abi.ChainEpoch,
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {

buf := new(bytes.Buffer)
if err := miner.MarshalCBOR(buf); err != nil {
return nil, xerrors.Errorf("failed to cbor marshal address: %w", err)
}

electionRand, err := rand.DrawRandomnessFromBase(brand.Data, crypto.DomainSeparationTag_ElectionProofProduction, round, buf.Bytes())
if err != nil {
return nil, xerrors.Errorf("failed to draw randomness: %w", err)
}

vrfout, err := ComputeVRF(ctx, a.WalletSign, mbi.WorkerKey, electionRand)
if err != nil {
return nil, xerrors.Errorf("failed to compute VRF: %w", err)
}

ep := &types.ElectionProof{VRFProof: vrfout}
j := ep.ComputeWinCount(mbi.MinerPower, mbi.NetworkPower)
ep.WinCount = j
if j < 1 {
return nil, nil
}

return ep, nil
}

type SignFunc func(context.Context, address.Address, []byte) (*crypto.Signature, error)

func ComputeVRF(ctx context.Context, sign SignFunc, worker address.Address, sigInput []byte) ([]byte, error) {
sig, err := sign(ctx, worker, sigInput)
if err != nil {
return nil, err
}

if sig.Type != crypto.SigTypeBLS {
return nil, fmt.Errorf("miner worker address was not a BLS key")
}

return sig.Data, nil
}

type genFakeVerifier struct{}

var _ storiface.Verifier = (*genFakeVerifier)(nil)
Expand Down
14 changes: 14 additions & 0 deletions chain/gen/gentypes/gentypes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gentypes

import (
"context"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
)

type WinningPoStProver interface {
GenerateCandidates(context.Context, abi.PoStRandomness, uint64) ([]uint64, error)
ComputeProof(context.Context, []proof7.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version) ([]proof7.PoStProof, error)
}
69 changes: 69 additions & 0 deletions chain/gen/genutils/genutils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package genutils

import (
"bytes"
"context"
"fmt"

"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/rand"
"github.com/filecoin-project/lotus/chain/types"
)

type MiningCheckAPI interface {
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)

MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*api.MiningBaseInfo, error)

WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
}

func IsRoundWinner(ctx context.Context, round abi.ChainEpoch,
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {

buf := new(bytes.Buffer)
if err := miner.MarshalCBOR(buf); err != nil {
return nil, xerrors.Errorf("failed to cbor marshal address: %w", err)
}

electionRand, err := rand.DrawRandomnessFromBase(brand.Data, crypto.DomainSeparationTag_ElectionProofProduction, round, buf.Bytes())
if err != nil {
return nil, xerrors.Errorf("failed to draw randomness: %w", err)
}

vrfout, err := ComputeVRF(ctx, a.WalletSign, mbi.WorkerKey, electionRand)
if err != nil {
return nil, xerrors.Errorf("failed to compute VRF: %w", err)
}

ep := &types.ElectionProof{VRFProof: vrfout}
j := ep.ComputeWinCount(mbi.MinerPower, mbi.NetworkPower)
ep.WinCount = j
if j < 1 {
return nil, nil
}

return ep, nil
}

type SignFunc func(context.Context, address.Address, []byte) (*crypto.Signature, error)

func ComputeVRF(ctx context.Context, sign SignFunc, worker address.Address, sigInput []byte) ([]byte, error) {
sig, err := sign(ctx, worker, sigInput)
if err != nil {
return nil, err
}

if sig.Type != crypto.SigTypeBLS {
return nil, fmt.Errorf("miner worker address was not a BLS key")
}

return sig.Data, nil
}
Loading