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

WIP: Integrate FIP0013 #6235

Merged
merged 46 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
506f39b
WIP: Integrate FIP0013
magik6k Mar 10, 2021
5f8c805
Update to latest actors and FFI
arajasek May 17, 2021
8f42f37
Update ffi
magik6k May 17, 2021
6278bdc
Make things build
magik6k May 17, 2021
578bef4
Update gen
magik6k May 17, 2021
2afe725
Get PreCommitting to work
magik6k May 17, 2021
ba2032c
Fix some aggregation bugs
magik6k May 17, 2021
febf7cf
sane config defaults
vyzo May 18, 2021
357c086
proper config for termination batching and commit wait
vyzo May 18, 2021
e56960f
Merge pull request #6281 from filecoin-project/feat/fip-0013-addenda
magik6k May 18, 2021
fe9311e
update ffi
magik6k May 18, 2021
74bad49
correctly handle commit batch timer
vyzo May 18, 2021
6b3e04b
cache sector deadlines.
vyzo May 18, 2021
7512748
wire in sealing config values
vyzo May 18, 2021
c544f4c
avoid extraneous rpc call for storage start epoch
vyzo May 18, 2021
5614520
Merge pull request #6282 from filecoin-project/feat/fip-0013-addenda
magik6k May 18, 2021
c7ba083
Import precommit batcher
magik6k May 18, 2021
81b5d8c
Make things build with both batchers
magik6k May 18, 2021
d92c5e1
Missing precommit batcher
magik6k May 18, 2021
f66b9c5
Maybe working precommit batching
magik6k May 18, 2021
1946d2f
Wire up Precommit Batching
magik6k May 18, 2021
9690bc8
Test to trigger batching logic
magik6k May 18, 2021
e400bdf
Order proofs before aggregation
magik6k May 18, 2021
0419c64
CLI for precommit batching
magik6k May 18, 2021
dd393b4
Fix aggregation inputs
magik6k May 18, 2021
5112b9f
Lower default batch slack
magik6k May 18, 2021
2a0c0e3
Working default batching config
magik6k May 19, 2021
eafaf6d
Don't block on batching in node tests
magik6k May 19, 2021
a5677d1
ffiwrapper: Separate Prover interface
magik6k May 19, 2021
2a1b359
config: fmt
magik6k May 19, 2021
e088c71
marketadapter: Handle batch sealing messages
magik6k May 19, 2021
5113936
sealing: Handle full batches correctly
magik6k May 19, 2021
44bf9bf
tests: Better state logging in pledgeSectors
magik6k May 20, 2021
7edffcd
Update ffi
magik6k May 20, 2021
678812f
gofmt, lint
magik6k May 20, 2021
bb889a5
sealing: Fix max commit batch size check
magik6k May 20, 2021
d71334c
Address self-review
magik6k May 20, 2021
f3fda4a
Better asserts in TestPledgeBatching
magik6k May 20, 2021
13ff6ed
Test pledging before nv13 upgrade
magik6k May 20, 2021
e3255a0
sealing: Add missing states to SubmitPreCommitBatch planner
magik6k May 20, 2021
f540984
Some review addressing
magik6k May 25, 2021
d90ab2b
config: Document batching fields
magik6k May 25, 2021
04658e1
fix lint
magik6k May 25, 2021
7bd0fcb
sealing: Don't start batch timers with empty batches
magik6k May 25, 2021
4c6c9a0
Fix windowpost/deadline tests
magik6k May 25, 2021
fc76a09
mock: Use real aggregate lengths
magik6k May 26, 2021
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
7 changes: 7 additions & 0 deletions api/api_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ type StorageMiner interface {
// SectorTerminatePending returns a list of pending sector terminations to be sent in the next batch message
SectorTerminatePending(ctx context.Context) ([]abi.SectorID, error) //perm:admin
SectorMarkForUpgrade(ctx context.Context, id abi.SectorNumber) error //perm:admin
// SectorPreCommitFlush immediately sends a PreCommit message with sectors batched for PreCommit.
// Returns null if message wasn't sent
SectorPreCommitFlush(ctx context.Context) (*cid.Cid, error) //perm:admin
// SectorPreCommitPending returns a list of pending PreCommit sectors to be sent in the next batch message
SectorPreCommitPending(ctx context.Context) ([]abi.SectorID, error) //perm:admin
SectorCommitFlush(ctx context.Context) (*cid.Cid, error) //perm:admin
SectorCommitPending(ctx context.Context) ([]abi.SectorID, error) //perm:admin

// WorkerConnect tells the node to connect to workers RPC
WorkerConnect(context.Context, string) error //perm:admin retry:true
Expand Down
24 changes: 24 additions & 0 deletions api/apistruct/struct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions api/test/window_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,52 @@ func TestSDRUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) {
<-done
}

func TestPledgeBatching(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
magik6k marked this conversation as resolved.
Show resolved Hide resolved
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

n, sn := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(-1)}, OneMiner)
client := n[0].FullNode.(*impl.FullNodeAPI)
miner := sn[0]

addrinfo, err := client.NetAddrsListen(ctx)
if err != nil {
t.Fatal(err)
}

if err := miner.NetConnect(ctx, addrinfo); err != nil {
t.Fatal(err)
}
build.Clock.Sleep(time.Second)

mine := int64(1)
done := make(chan struct{})
go func() {
defer close(done)
for atomic.LoadInt64(&mine) != 0 {
build.Clock.Sleep(blocktime)
if err := sn[0].MineOne(ctx, bminer.MineReq{Done: func(bool, abi.ChainEpoch, error) {

}}); err != nil {
t.Error(err)
}
}
}()

for {
h, err := client.ChainHead(ctx)
require.NoError(t, err)
if h.Height() > 10 {
break
}
}

pledgeSectors(t, ctx, miner, nSectors, 0, nil)
magik6k marked this conversation as resolved.
Show resolved Hide resolved

atomic.StoreInt64(&mine, 0)
<-done
}

func TestPledgeSector(t *testing.T, b APIBuilder, blocktime time.Duration, nSectors int) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -188,6 +234,12 @@ func pledgeSectors(t *testing.T, ctx context.Context, miner TestStorageNode, n,
}

for len(toCheck) > 0 {
cb, err := miner.SectorCommitFlush(ctx)
require.NoError(t, err)
if cb != nil {
fmt.Printf("BATCH: %s\n", *cb)
}

for n := range toCheck {
st, err := miner.SectorsStatus(ctx, n, false)
require.NoError(t, err)
Expand Down
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions build/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ import rice "github.com/GeertJohan/go.rice"
func ParametersJSON() []byte {
return rice.MustFindBox("proof-params").MustBytes("parameters.json")
}

func SrsJSON() []byte {
return rice.MustFindBox("proof-params").MustBytes("srs-inner-product.json")
}
20 changes: 10 additions & 10 deletions build/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ var UpgradeIgnitionHeight = abi.ChainEpoch(-2)
var UpgradeRefuelHeight = abi.ChainEpoch(-3)
var UpgradeTapeHeight = abi.ChainEpoch(-4)

var UpgradeAssemblyHeight = abi.ChainEpoch(10)
var UpgradeAssemblyHeight = abi.ChainEpoch(5)
var UpgradeLiftoffHeight = abi.ChainEpoch(-5)

var UpgradeKumquatHeight = abi.ChainEpoch(15)
var UpgradeCalicoHeight = abi.ChainEpoch(20)
var UpgradePersianHeight = abi.ChainEpoch(25)
var UpgradeOrangeHeight = abi.ChainEpoch(27)
var UpgradeClausHeight = abi.ChainEpoch(30)
var UpgradeKumquatHeight = abi.ChainEpoch(6)
var UpgradeCalicoHeight = abi.ChainEpoch(7)
var UpgradePersianHeight = abi.ChainEpoch(8)
var UpgradeOrangeHeight = abi.ChainEpoch(9)
var UpgradeClausHeight = abi.ChainEpoch(10)

var UpgradeTrustHeight = abi.ChainEpoch(35)
var UpgradeTrustHeight = abi.ChainEpoch(11)

var UpgradeNorwegianHeight = abi.ChainEpoch(40)
var UpgradeNorwegianHeight = abi.ChainEpoch(12)

var UpgradeTurboHeight = abi.ChainEpoch(45)
var UpgradeTurboHeight = abi.ChainEpoch(13)

var UpgradeHyperdriveHeight = abi.ChainEpoch(50)
var UpgradeHyperdriveHeight = abi.ChainEpoch(14)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
Expand Down
7 changes: 7 additions & 0 deletions build/proof-params/srs-inner-product.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"v28-fil-inner-product-v1.srs": {
"cid": "Qmdq44DjcQnFfU3PJcdX7J49GCqcUYszr1TxMbHtAkvQ3g",
"digest": "ae20310138f5ba81451d723f858e3797",
"sector_size": 0
}
}
6 changes: 5 additions & 1 deletion chain/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
ChainFinality = miner5.ChainFinality
SealRandomnessLookback = ChainFinality
PaychSettleDelay = paych5.SettleDelay
MaxPreCommitRandomnessLookback = builtin5.EpochsInDay + SealRandomnessLookback
MaxPreCommitRandomnessLookback = builtin5.EpochsInDay + SealRandomnessLookback // todo fix
)

// SetSupportedProofTypes sets supported proof types, across all actor versions.
Expand Down Expand Up @@ -302,6 +302,10 @@ func GetDefaultSectorSize() abi.SectorSize {
return szs[0]
}

func GetDefaultAggregationProof() abi.RegisteredAggregationProof {
return abi.RegisteredAggregationProof_SnarkPackV1
}

func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) abi.ChainEpoch {
if nwVer <= network.Version10 {
return builtin5.SealProofPoliciesV0[proof].SectorMaxLifetime
Expand Down
4 changes: 4 additions & 0 deletions chain/actors/policy/policy.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ func GetDefaultSectorSize() abi.SectorSize {
return szs[0]
}

func GetDefaultAggregationProof() abi.RegisteredAggregationProof {
return abi.RegisteredAggregationProof_SnarkPackV1
}

func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) abi.ChainEpoch {
if nwVer <= network.Version10 {
return builtin{{.latestVersion}}.SealProofPoliciesV0[proof].SectorMaxLifetime
Expand Down
24 changes: 16 additions & 8 deletions chain/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"go.opencensus.io/trace"
"golang.org/x/xerrors"

proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/blockstore"
Expand All @@ -51,7 +51,7 @@ const msgsPerBlock = 20
//nolint:deadcode,varcheck
var log = logging.Logger("gen")

var ValidWpostForTesting = []proof2.PoStProof{{
var ValidWpostForTesting = []proof5.PoStProof{{
ProofBytes: []byte("valid proof"),
}}

Expand Down Expand Up @@ -460,7 +460,7 @@ func (cg *ChainGen) NextTipSetFromMinersWithMessages(base *types.TipSet, miners

func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticket *types.Ticket,
eticket *types.ElectionProof, bvals []types.BeaconEntry, height abi.ChainEpoch,
wpost []proof2.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {
wpost []proof5.PoStProof, msgs []*types.SignedMessage) (*types.FullBlock, error) {

var ts uint64
if cg.Timestamper != nil {
Expand Down Expand Up @@ -598,7 +598,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, []proof2.SectorInfo, abi.PoStRandomness) ([]proof2.PoStProof, error)
ComputeProof(context.Context, []proof5.SectorInfo, abi.PoStRandomness) ([]proof5.PoStProof, error)
}

type wppProvider struct{}
Expand All @@ -607,7 +607,7 @@ func (wpp *wppProvider) GenerateCandidates(ctx context.Context, _ abi.PoStRandom
return []uint64{0}, nil
}

func (wpp *wppProvider) ComputeProof(context.Context, []proof2.SectorInfo, abi.PoStRandomness) ([]proof2.PoStProof, error) {
func (wpp *wppProvider) ComputeProof(context.Context, []proof5.SectorInfo, abi.PoStRandomness) ([]proof5.PoStProof, error) {
return ValidWpostForTesting, nil
}

Expand Down Expand Up @@ -685,15 +685,23 @@ type genFakeVerifier struct{}

var _ ffiwrapper.Verifier = (*genFakeVerifier)(nil)

func (m genFakeVerifier) VerifySeal(svi proof2.SealVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifySeal(svi proof5.SealVerifyInfo) (bool, error) {
return true, nil
}

func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof2.WinningPoStVerifyInfo) (bool, error) {
func (m genFakeVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStVerifyInfo) (bool, error) {
func (m genFakeVerifier) AggregateSealProofs(ai proof5.AggregateSealVerifyProofAndInfos, proofs [][]byte) ([]byte, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWinningPoSt(ctx context.Context, info proof5.WinningPoStVerifyInfo) (bool, error) {
panic("not supported")
}

func (m genFakeVerifier) VerifyWindowPoSt(ctx context.Context, info proof5.WindowPoStVerifyInfo) (bool, error) {
panic("not supported")
}

Expand Down
6 changes: 3 additions & 3 deletions chain/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
runtime2 "github.com/filecoin-project/specs-actors/v2/actors/runtime"
runtime5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"

"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
Expand All @@ -46,15 +46,15 @@ func MinerAddress(genesisIndex uint64) address.Address {
}

type fakedSigSyscalls struct {
runtime2.Syscalls
runtime5.Syscalls
}

func (fss *fakedSigSyscalls) VerifySignature(signature crypto.Signature, signer address.Address, plaintext []byte) error {
return nil
}

func mkFakedSigSyscalls(base vm.SyscallBuilder) vm.SyscallBuilder {
return func(ctx context.Context, rt *vm.Runtime) runtime2.Syscalls {
return func(ctx context.Context, rt *vm.Runtime) runtime5.Syscalls {
return &fakedSigSyscalls{
base(ctx, rt),
}
Expand Down
13 changes: 13 additions & 0 deletions chain/state/statetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
states2 "github.com/filecoin-project/specs-actors/v2/actors/states"
states3 "github.com/filecoin-project/specs-actors/v3/actors/states"
states4 "github.com/filecoin-project/specs-actors/v4/actors/states"
states5 "github.com/filecoin-project/specs-actors/v5/actors/states"
)

var log = logging.Logger("statetree")
Expand Down Expand Up @@ -191,6 +192,12 @@ func NewStateTree(cst cbor.IpldStore, ver types.StateTreeVersion) (*StateTree, e
return nil, xerrors.Errorf("failed to create state tree: %w", err)
}
hamt = tree.Map
case types.StateTreeVersion4:
tree, err := states5.NewTree(store)
if err != nil {
return nil, xerrors.Errorf("failed to create state tree: %w", err)
}
hamt = tree.Map
default:
return nil, xerrors.Errorf("unsupported state tree version: %d", ver)
}
Expand Down Expand Up @@ -246,6 +253,12 @@ func LoadStateTree(cst cbor.IpldStore, c cid.Cid) (*StateTree, error) {
if tree != nil {
hamt = tree.Map
}
case types.StateTreeVersion4:
var tree *states5.Tree
tree, err = states5.LoadTree(store, root.Actors)
if tree != nil {
hamt = tree.Map
}
default:
return nil, xerrors.Errorf("unsupported state tree version: %d", root.Version)
}
Expand Down
2 changes: 1 addition & 1 deletion chain/stmgr/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ func upgradeActorsV5Common(

// Persist the result.
newRoot, err := store.Put(ctx, &types.StateRoot{
Version: types.StateTreeVersion3,
Version: types.StateTreeVersion4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that bumping to version 3 in actors v4 was a mistake and that we were not planning to continue bumping the version every time. Is this intentional? If so what changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just assumed that /something/ is expecting this to be bumped based on the nv12 diff, might have been wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the only good reason for it is version check in chain/stmgr/forks.go:upgradeActorsV5Common, I'm ok with dropping that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defer to you and @arajasek

Actors: newHamtRoot,
Info: stateRoot.Info,
})
Expand Down
4 changes: 3 additions & 1 deletion chain/types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const (
StateTreeVersion1
// StateTreeVersion2 corresponds to actors v3.
StateTreeVersion2
// StateTreeVersion3 corresponds to actors >= v4.
// StateTreeVersion3 corresponds to actors v4.
StateTreeVersion3
// StateTreeVersion4 corresponds to actors v5.
StateTreeVersion4
)

type StateRoot struct {
Expand Down
Loading