From 0379adc9f1d88a09a1c9f130ed3b506d1f798335 Mon Sep 17 00:00:00 2001 From: Jennifer Wang Date: Wed, 9 Jun 2021 23:27:58 -0400 Subject: [PATCH 1/9] Set ntwk v13 HyperDrive Calibration upgrade epoch --- build/params_calibnet.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/params_calibnet.go b/build/params_calibnet.go index 4685ec30c..d4cea7e07 100644 --- a/build/params_calibnet.go +++ b/build/params_calibnet.go @@ -45,7 +45,8 @@ const UpgradeNorwegianHeight = 114000 const UpgradeTurboHeight = 193789 -const UpgradeHyperdriveHeight = 9999999 +// 2021-06-11T14:30:00Z +const UpgradeHyperdriveHeight = 321519 func init() { policy.SetConsensusMinerMinPower(abi.NewStoragePower(32 << 30)) From c4c71802f2f95d88d4b374b3beb25de5db2652a9 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 9 Jun 2021 23:21:58 -0400 Subject: [PATCH 2/9] Lotus version 1.10.0-rc2 --- CHANGELOG.md | 6 +++--- build/openrpc/full.json.gz | Bin 22811 -> 22811 bytes build/openrpc/miner.json.gz | Bin 8066 -> 8066 bytes build/openrpc/worker.json.gz | Bin 2578 -> 2578 bytes build/version.go | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7fdd052e..bfc1b98e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Lotus changelog -# 1.10.0-rc1 / 2021-06-02 +# 1.10.0-rc2 / 2021-06-09 -This is the first release candidate for Lotus v1.10.0, an upcoming mandatory release of Lotus that will introduce Filecoin network v13. Included in the new network version are the following FIPs: +This is the second release candidate for Lotus v1.10.0, an upcoming mandatory release of Lotus that will introduce Filecoin network v13. Included in the new network version are the following FIPs: - [FIP-0008](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0008.md): Add miner batched sector pre-commit method - [FIP-0011](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0011.md): Remove reward auction from reporting consensus faults @@ -10,7 +10,7 @@ This is the first release candidate for Lotus v1.10.0, an upcoming mandatory rel - [FIP-0013](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0013.md): Add ProveCommitSectorAggregated method to reduce on-chain congestion - [FIP-0015](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0015.md): Revert FIP-0009(Exempt Window PoSts from BaseFee burn) -This release candidate does not set the upgrade epochs for any of the networks, including test networks. It is primarily intended for node operators to begin integration work, especially miners wishing to get familiar with the new `ProveCommit` aggregation. +This release candidate does not set the upgrade epochs for mainnet, but does set the upgrade epoch for the calibration network to 321519. Note that this release is built on top of Lotus v1.9.0. Enterprising users can use the `master` branch of Lotus to get the latest functionality, including all changes in this release candidate. diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index b99a3c9f54e84458ac8c66345852b6ec53ef944a..388ae30271184f5d05b85a9b83010946b4c009d2 100644 GIT binary patch delta 23 fcmbQeiE;KO#tGewc^iA$BRFg;E=sD_urL4sbkPWp delta 23 ecmbQeiE;KO#tGewej9t*BRHbU-Aq(#SQr3tHwYU5 diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index 3035cb96f1de98163745ef63eaa3957fc50fef18..a712e6abe57b5275b9cded86927e5de83c42189f 100644 GIT binary patch delta 22 ecmZp&Z?d1z!Nl`rW7h{cj{UP&b1vy;WB>qeatSa1 delta 22 ecmZp&Z?d1z!Sv Date: Wed, 9 Jun 2021 18:04:11 -0400 Subject: [PATCH 3/9] updated configuration comments for docs --- node/config/def.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/node/config/def.go b/node/config/def.go index 08129b7f9..3b981940f 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -93,7 +93,7 @@ type SealingConfig struct { MinPreCommitBatch int // how long to wait before submitting a batch after crossing the minimum batch size PreCommitBatchWait Duration - // time buffer for forceful batch submission before sectors in batch would start expiring + // time buffer for forceful batch submission before sectors/deal in batch would start expiring PreCommitBatchSlack Duration // enable / disable commit aggregation (takes effect after nv13) @@ -103,7 +103,7 @@ type SealingConfig struct { MaxCommitBatch int // how long to wait before submitting a batch after crossing the minimum batch size CommitBatchWait Duration - // time buffer for forceful batch submission before sectors in batch would start expiring + // time buffer for forceful batch submission before sectors/deals in batch would start expiring CommitBatchSlack Duration TerminateBatchMax uint64 @@ -281,16 +281,16 @@ func DefaultStorageMiner() *StorageMiner { AlwaysKeepUnsealedCopy: true, BatchPreCommits: true, - MinPreCommitBatch: 1, // we must have at least one proof to aggregate - MaxPreCommitBatch: miner5.PreCommitSectorBatchMaxSize, // - PreCommitBatchWait: Duration(24 * time.Hour), // this can be up to 6 days - PreCommitBatchSlack: Duration(3 * time.Hour), + MinPreCommitBatch: 1, // we must have at least one precommit to batch + MaxPreCommitBatch: miner5.PreCommitSectorBatchMaxSize, // up to 256 sectors + PreCommitBatchWait: Duration(24 * time.Hour), // this should be less than 31.5 hours, which is the expiration of a precommit ticket + PreCommitBatchSlack: Duration(3 * time.Hour), // time buffer for forceful batch submission before sectors/deals in batch would start expiring, higher value will lower the chances for message fail due to expiration AggregateCommits: true, - MinCommitBatch: miner5.MinAggregatedSectors, // we must have at least four proofs to aggregate - MaxCommitBatch: miner5.MaxAggregatedSectors, // this is the maximum aggregation per FIP13 - CommitBatchWait: Duration(24 * time.Hour), // this can be up to 6 days - CommitBatchSlack: Duration(1 * time.Hour), + MinCommitBatch: miner5.MinAggregatedSectors, // per FIP13, we must have at least four proofs to aggregate, where 4 is the cross over point where aggregation wins out on single provecommit gas costs + MaxCommitBatch: miner5.MaxAggregatedSectors, // maximum 819 sectors, this is the maximum aggregation per FIP13 + CommitBatchWait: Duration(24 * time.Hour), // this can be up to 30 days + CommitBatchSlack: Duration(1 * time.Hour), // time buffer for forceful batch submission before sectors/deals in batch would start expiring, higher value will lower the chances for message fail due to expiration TerminateBatchMin: 1, TerminateBatchMax: 100, @@ -329,12 +329,12 @@ func DefaultStorageMiner() *StorageMiner { MaxCommitGasFee: types.MustParseFIL("0.05"), MaxPreCommitBatchGasFee: BatchFeeConfig{ - Base: types.MustParseFIL("0.025"), // todo: come up with good values - PerSector: types.MustParseFIL("0.025"), + Base: types.MustParseFIL("0.025"), // TODO: update before v1.10.0 + PerSector: types.MustParseFIL("0.025"), // TODO: update before v1.10.0 }, MaxCommitBatchGasFee: BatchFeeConfig{ - Base: types.MustParseFIL("0.05"), - PerSector: types.MustParseFIL("0.05"), + Base: types.MustParseFIL("0.05"), // TODO: update before v1.10.0 + PerSector: types.MustParseFIL("0.05"), // TODO: update before v1.10.0 }, MaxTerminateGasFee: types.MustParseFIL("0.5"), From ec06f086ef92758cadc2ed861dcb74ab5b84ec77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Jun 2021 11:41:28 +0200 Subject: [PATCH 4/9] sealing: Early finalization option --- cmd/lotus-storage-miner/info.go | 2 ++ extern/storage-sealing/fsm.go | 9 ++++++++ extern/storage-sealing/fsm_events.go | 9 ++++++++ extern/storage-sealing/sealiface/config.go | 2 ++ extern/storage-sealing/sector_state.go | 6 +++++- extern/storage-sealing/states_sealing.go | 25 +++++++++++++++++++++- node/config/def.go | 4 ++++ node/modules/storageminer.go | 2 ++ 8 files changed, 57 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 0fe14f1ff..e7c5e7904 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -295,6 +295,7 @@ var stateList = []stateMeta{ {col: color.FgYellow, state: sealing.PreCommitBatchWait}, {col: color.FgYellow, state: sealing.WaitSeed}, {col: color.FgYellow, state: sealing.Committing}, + {col: color.FgYellow, state: sealing.CommitFinalize}, {col: color.FgYellow, state: sealing.SubmitCommit}, {col: color.FgYellow, state: sealing.CommitWait}, {col: color.FgYellow, state: sealing.SubmitCommitAggregate}, @@ -315,6 +316,7 @@ var stateList = []stateMeta{ {col: color.FgRed, state: sealing.PreCommitFailed}, {col: color.FgRed, state: sealing.ComputeProofFailed}, {col: color.FgRed, state: sealing.CommitFailed}, + {col: color.FgRed, state: sealing.CommitFinalizeFailed}, {col: color.FgRed, state: sealing.PackingFailed}, {col: color.FgRed, state: sealing.FinalizeFailed}, {col: color.FgRed, state: sealing.Faulty}, diff --git a/extern/storage-sealing/fsm.go b/extern/storage-sealing/fsm.go index 594f9f2f5..a85c6959b 100644 --- a/extern/storage-sealing/fsm.go +++ b/extern/storage-sealing/fsm.go @@ -102,6 +102,10 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto on(SectorChainPreCommitFailed{}, PreCommitFailed), ), Committing: planCommitting, + CommitFinalize: planOne( + on(SectorFinalized{}, SubmitCommit), + on(SectorFinalizeFailed{}, CommitFinalizeFailed), + ), SubmitCommit: planOne( on(SectorCommitSubmitted{}, CommitWait), on(SectorSubmitCommitAggregate{}, SubmitCommitAggregate), @@ -372,6 +376,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta fallthrough case CommitWait: return m.handleCommitWait, processed, nil + case CommitFinalize: + fallthrough case FinalizeSector: return m.handleFinalizeSector, processed, nil @@ -474,6 +480,9 @@ func planCommitting(events []statemachine.Event, state *SectorInfo) (uint64, err case SectorCommitted: // the normal case e.apply(state) state.State = SubmitCommit + case SectorProofReady: // early finalize + e.apply(state) + state.State = CommitFinalize case SectorSeedReady: // seed changed :/ if e.SeedEpoch == state.SeedEpoch && bytes.Equal(e.SeedValue, state.SeedValue) { log.Warnf("planCommitting: got SectorSeedReady, but the seed didn't change") diff --git a/extern/storage-sealing/fsm_events.go b/extern/storage-sealing/fsm_events.go index 7ec8f3dfc..3dab6d403 100644 --- a/extern/storage-sealing/fsm_events.go +++ b/extern/storage-sealing/fsm_events.go @@ -245,6 +245,15 @@ func (evt SectorCommitted) apply(state *SectorInfo) { state.Proof = evt.Proof } +// like SectorCommitted, but finalizes before sending the proof to the chain +type SectorProofReady struct { + Proof []byte +} + +func (evt SectorProofReady) apply(state *SectorInfo) { + state.Proof = evt.Proof +} + type SectorSubmitCommitAggregate struct{} func (evt SectorSubmitCommitAggregate) apply(*SectorInfo) {} diff --git a/extern/storage-sealing/sealiface/config.go b/extern/storage-sealing/sealiface/config.go index 54ba2ef58..499a2befa 100644 --- a/extern/storage-sealing/sealiface/config.go +++ b/extern/storage-sealing/sealiface/config.go @@ -18,6 +18,8 @@ type Config struct { AlwaysKeepUnsealedCopy bool + FinalizeEarly bool + BatchPreCommits bool MaxPreCommitBatch int MinPreCommitBatch int diff --git a/extern/storage-sealing/sector_state.go b/extern/storage-sealing/sector_state.go index 23c7695e7..3e1494aeb 100644 --- a/extern/storage-sealing/sector_state.go +++ b/extern/storage-sealing/sector_state.go @@ -17,6 +17,8 @@ var ExistSectorStateList = map[SectorState]struct{}{ PreCommitBatchWait: {}, WaitSeed: {}, Committing: {}, + CommitFinalize: {}, + CommitFinalizeFailed: {}, SubmitCommit: {}, CommitWait: {}, SubmitCommitAggregate: {}, @@ -65,6 +67,8 @@ const ( WaitSeed SectorState = "WaitSeed" // waiting for seed Committing SectorState = "Committing" // compute PoRep + CommitFinalize SectorState = "CommitFinalize" // cleanup sector metadata before submitting the proof (early finalize) + CommitFinalizeFailed SectorState = "CommitFinalizeFailed" // single commit SubmitCommit SectorState = "SubmitCommit" // send commit message to the chain @@ -106,7 +110,7 @@ func toStatState(st SectorState) statSectorState { switch st { case UndefinedSectorState, Empty, WaitDeals, AddPiece: return sstStaging - case Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, SubmitCommit, CommitWait, SubmitCommitAggregate, CommitAggregateWait, FinalizeSector: + case Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, SubmitPreCommitBatch, PreCommitBatchWait, WaitSeed, Committing, CommitFinalize, SubmitCommit, CommitWait, SubmitCommitAggregate, CommitAggregateWait, FinalizeSector: return sstSealing case Proving, Removed, Removing, Terminating, TerminateWait, TerminateFinality, TerminateFailed: return sstProving diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 4cd8afd9c..4f0f1dc80 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -478,6 +478,11 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) } } + cfg, err := m.getConfig() + if err != nil { + return xerrors.Errorf("getting config: %w", err) + } + log.Info("scheduling seal proof computation...") log.Infof("KOMIT %d %x(%d); %x(%d); %v; r:%x; d:%x", sector.SectorNumber, sector.TicketValue, sector.TicketEpoch, sector.SeedValue, sector.SeedEpoch, sector.pieceInfos(), sector.CommR, sector.CommD) @@ -500,6 +505,24 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed(2): %w", err)}) } + { + tok, _, err := m.api.ChainHead(ctx.Context()) + if err != nil { + log.Errorf("handleCommitting: api error, not proceeding: %+v", err) + return nil + } + + if err := m.checkCommit(ctx.Context(), sector, proof, tok); err != nil { + return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("commit check error: %w", err)}) + } + } + + if cfg.FinalizeEarly { + return ctx.Send(SectorProofReady{ + Proof: proof, + }) + } + return ctx.Send(SectorCommitted{ Proof: proof, }) @@ -524,7 +547,7 @@ func (m *Sealing) handleSubmitCommit(ctx statemachine.Context, sector SectorInfo tok, _, err := m.api.ChainHead(ctx.Context()) if err != nil { - log.Errorf("handleCommitting: api error, not proceeding: %+v", err) + log.Errorf("handleSubmitCommit: api error, not proceeding: %+v", err) return nil } diff --git a/node/config/def.go b/node/config/def.go index 3b981940f..ccd738420 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -86,6 +86,9 @@ type SealingConfig struct { AlwaysKeepUnsealedCopy bool + // Run sector finalization before submitting sector proof to the chain + FinalizeEarly bool + // enable / disable precommit batching (takes effect after nv13) BatchPreCommits bool // maximum precommit batch size - batches will be sent immediately above this size @@ -279,6 +282,7 @@ func DefaultStorageMiner() *StorageMiner { MaxSealingSectorsForDeals: 0, WaitDealsDelay: Duration(time.Hour * 6), AlwaysKeepUnsealedCopy: true, + FinalizeEarly: true, BatchPreCommits: true, MinPreCommitBatch: 1, // we must have at least one precommit to batch diff --git a/node/modules/storageminer.go b/node/modules/storageminer.go index 122bec519..55b18eac0 100644 --- a/node/modules/storageminer.go +++ b/node/modules/storageminer.go @@ -826,6 +826,7 @@ func NewSetSealConfigFunc(r repo.LockedRepo) (dtypes.SetSealingConfigFunc, error MaxSealingSectorsForDeals: cfg.MaxSealingSectorsForDeals, WaitDealsDelay: config.Duration(cfg.WaitDealsDelay), AlwaysKeepUnsealedCopy: cfg.AlwaysKeepUnsealedCopy, + FinalizeEarly: cfg.FinalizeEarly, BatchPreCommits: cfg.BatchPreCommits, MinPreCommitBatch: cfg.MinPreCommitBatch, @@ -857,6 +858,7 @@ func NewGetSealConfigFunc(r repo.LockedRepo) (dtypes.GetSealingConfigFunc, error MaxSealingSectorsForDeals: cfg.Sealing.MaxSealingSectorsForDeals, WaitDealsDelay: time.Duration(cfg.Sealing.WaitDealsDelay), AlwaysKeepUnsealedCopy: cfg.Sealing.AlwaysKeepUnsealedCopy, + FinalizeEarly: cfg.Sealing.FinalizeEarly, BatchPreCommits: cfg.Sealing.BatchPreCommits, MinPreCommitBatch: cfg.Sealing.MinPreCommitBatch, From 05d9b5ce0f1050d905dd0dfa26f5c57f84c5090e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Jun 2021 11:42:54 +0200 Subject: [PATCH 5/9] sealing: Add missing planner for CommitFinalizeFailed --- extern/storage-sealing/fsm.go | 5 +++++ extern/storage-sealing/sector_state.go | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/extern/storage-sealing/fsm.go b/extern/storage-sealing/fsm.go index a85c6959b..a765d2617 100644 --- a/extern/storage-sealing/fsm.go +++ b/extern/storage-sealing/fsm.go @@ -154,6 +154,9 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto on(SectorRetryComputeProof{}, Committing), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), ), + CommitFinalizeFailed: planOne( + on(SectorRetryFinalize{}, CommitFinalizeFailed), + ), CommitFailed: planOne( on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), on(SectorRetryWaitSeed{}, WaitSeed), @@ -392,6 +395,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta return m.handleComputeProofFailed, processed, nil case CommitFailed: return m.handleCommitFailed, processed, nil + case CommitFinalizeFailed: + fallthrough case FinalizeFailed: return m.handleFinalizeFailed, processed, nil case PackingFailed: // DEPRECATED: remove this for the next reset diff --git a/extern/storage-sealing/sector_state.go b/extern/storage-sealing/sector_state.go index 3e1494aeb..deb5e9f28 100644 --- a/extern/storage-sealing/sector_state.go +++ b/extern/storage-sealing/sector_state.go @@ -65,10 +65,10 @@ const ( SubmitPreCommitBatch SectorState = "SubmitPreCommitBatch" PreCommitBatchWait SectorState = "PreCommitBatchWait" - WaitSeed SectorState = "WaitSeed" // waiting for seed - Committing SectorState = "Committing" // compute PoRep - CommitFinalize SectorState = "CommitFinalize" // cleanup sector metadata before submitting the proof (early finalize) - CommitFinalizeFailed SectorState = "CommitFinalizeFailed" + WaitSeed SectorState = "WaitSeed" // waiting for seed + Committing SectorState = "Committing" // compute PoRep + CommitFinalize SectorState = "CommitFinalize" // cleanup sector metadata before submitting the proof (early finalize) + CommitFinalizeFailed SectorState = "CommitFinalizeFailed" // single commit SubmitCommit SectorState = "SubmitCommit" // send commit message to the chain From 94be3a973adfa6372aa94899d7d59cf39b1bb28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Jun 2021 11:45:20 +0200 Subject: [PATCH 6/9] Don't enable early finalization by default --- node/config/def.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/config/def.go b/node/config/def.go index ccd738420..1f3505e7d 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -282,7 +282,7 @@ func DefaultStorageMiner() *StorageMiner { MaxSealingSectorsForDeals: 0, WaitDealsDelay: Duration(time.Hour * 6), AlwaysKeepUnsealedCopy: true, - FinalizeEarly: true, + FinalizeEarly: false, BatchPreCommits: true, MinPreCommitBatch: 1, // we must have at least one precommit to batch From 733240a2bb0a84625682642c033e8858c528c27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Jun 2021 11:52:00 +0200 Subject: [PATCH 7/9] sealing: Test early finalization fsm planners --- extern/storage-sealing/fsm_test.go | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/extern/storage-sealing/fsm_test.go b/extern/storage-sealing/fsm_test.go index b0ffdecf3..644ddedb4 100644 --- a/extern/storage-sealing/fsm_test.go +++ b/extern/storage-sealing/fsm_test.go @@ -87,6 +87,73 @@ func TestHappyPath(t *testing.T) { } } +func TestHappyPathFinalizeEarly(t *testing.T) { + var notif []struct{ before, after SectorInfo } + ma, _ := address.NewIDAddress(55151) + m := test{ + s: &Sealing{ + maddr: ma, + stats: SectorStats{ + bySector: map[abi.SectorID]statSectorState{}, + }, + notifee: func(before, after SectorInfo) { + notif = append(notif, struct{ before, after SectorInfo }{before, after}) + }, + }, + t: t, + state: &SectorInfo{State: Packing}, + } + + m.planSingle(SectorPacked{}) + require.Equal(m.t, m.state.State, GetTicket) + + m.planSingle(SectorTicket{}) + require.Equal(m.t, m.state.State, PreCommit1) + + m.planSingle(SectorPreCommit1{}) + require.Equal(m.t, m.state.State, PreCommit2) + + m.planSingle(SectorPreCommit2{}) + require.Equal(m.t, m.state.State, PreCommitting) + + m.planSingle(SectorPreCommitted{}) + require.Equal(m.t, m.state.State, PreCommitWait) + + m.planSingle(SectorPreCommitLanded{}) + require.Equal(m.t, m.state.State, WaitSeed) + + m.planSingle(SectorSeedReady{}) + require.Equal(m.t, m.state.State, Committing) + + m.planSingle(SectorProofReady{}) + require.Equal(m.t, m.state.State, CommitFinalize) + + m.planSingle(SectorFinalized{}) + require.Equal(m.t, m.state.State, SubmitCommit) + + m.planSingle(SectorSubmitCommitAggregate{}) + require.Equal(m.t, m.state.State, SubmitCommitAggregate) + + m.planSingle(SectorCommitAggregateSent{}) + require.Equal(m.t, m.state.State, CommitWait) + + m.planSingle(SectorProving{}) + require.Equal(m.t, m.state.State, FinalizeSector) + + m.planSingle(SectorFinalized{}) + require.Equal(m.t, m.state.State, Proving) + + expected := []SectorState{Packing, GetTicket, PreCommit1, PreCommit2, PreCommitting, PreCommitWait, WaitSeed, Committing, CommitFinalize, SubmitCommit, SubmitCommitAggregate, CommitWait, FinalizeSector, Proving} + for i, n := range notif { + if n.before.State != expected[i] { + t.Fatalf("expected before state: %s, got: %s", expected[i], n.before.State) + } + if n.after.State != expected[i+1] { + t.Fatalf("expected after state: %s, got: %s", expected[i+1], n.after.State) + } + } +} + func TestSeedRevert(t *testing.T) { ma, _ := address.NewIDAddress(55151) m := test{ From 534badad2a75d5e5c2bac84efc74f753bf883c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 11 Jun 2021 13:19:26 +0200 Subject: [PATCH 8/9] mpool: Add more metrics --- chain/messagepool/messagepool.go | 32 ++++++++++++++++++++------- chain/sub/incoming.go | 24 ++++++++++++++++++++ metrics/metrics.go | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 8 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 68390885c..59f7b0f75 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -34,6 +34,7 @@ import ( "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/lib/sigs" + "github.com/filecoin-project/lotus/metrics" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/raulk/clock" @@ -577,7 +578,7 @@ func (mp *MessagePool) addLocal(ctx context.Context, m *types.SignedMessage) err return nil } -// verifyMsgBeforeAdd verifies that the message meets the minimum criteria for block inclusio +// verifyMsgBeforeAdd verifies that the message meets the minimum criteria for block inclusion // and whether the message has enough funds to be included in the next 20 blocks. // If the message is not valid for block inclusion, it returns an error. // For local messages, if the message can be included in the next 20 blocks, it returns true to @@ -631,6 +632,9 @@ func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.T } func (mp *MessagePool) Push(ctx context.Context, m *types.SignedMessage) (cid.Cid, error) { + done := metrics.Timer(ctx, metrics.MpoolPushDuration) + defer done() + err := mp.checkMessage(m) if err != nil { return cid.Undef, err @@ -697,6 +701,9 @@ func (mp *MessagePool) checkMessage(m *types.SignedMessage) error { } func (mp *MessagePool) Add(ctx context.Context, m *types.SignedMessage) error { + done := metrics.Timer(ctx, metrics.MpoolAddDuration) + defer done() + err := mp.checkMessage(m) if err != nil { return err @@ -752,7 +759,7 @@ func (mp *MessagePool) VerifyMsgSig(m *types.SignedMessage) error { } func (mp *MessagePool) checkBalance(ctx context.Context, m *types.SignedMessage, curTs *types.TipSet) error { - balance, err := mp.getStateBalance(m.Message.From, curTs) + balance, err := mp.getStateBalance(ctx, m.Message.From, curTs) if err != nil { return xerrors.Errorf("failed to check sender balance: %s: %w", err, ErrSoftValidationFailure) } @@ -785,7 +792,10 @@ func (mp *MessagePool) checkBalance(ctx context.Context, m *types.SignedMessage, } func (mp *MessagePool) addTs(ctx context.Context, m *types.SignedMessage, curTs *types.TipSet, local, untrusted bool) (bool, error) { - snonce, err := mp.getStateNonce(m.Message.From, curTs) + done := metrics.Timer(ctx, metrics.MpoolAddTsDuration) + defer done() + + snonce, err := mp.getStateNonce(ctx, m.Message.From, curTs) if err != nil { return false, xerrors.Errorf("failed to look up actor state nonce: %s: %w", err, ErrSoftValidationFailure) } @@ -833,7 +843,7 @@ func (mp *MessagePool) addLoaded(ctx context.Context, m *types.SignedMessage) er return xerrors.Errorf("current tipset not loaded") } - snonce, err := mp.getStateNonce(m.Message.From, curTs) + snonce, err := mp.getStateNonce(ctx, m.Message.From, curTs) if err != nil { return xerrors.Errorf("failed to look up actor state nonce: %s: %w", err, ErrSoftValidationFailure) } @@ -885,7 +895,7 @@ func (mp *MessagePool) addLocked(ctx context.Context, m *types.SignedMessage, st } if !ok { - nonce, err := mp.getStateNonce(m.Message.From, mp.curTs) + nonce, err := mp.getStateNonce(ctx, m.Message.From, mp.curTs) if err != nil { return xerrors.Errorf("failed to get initial actor nonce: %w", err) } @@ -939,7 +949,7 @@ func (mp *MessagePool) GetNonce(ctx context.Context, addr address.Address) (uint } func (mp *MessagePool) getNonceLocked(ctx context.Context, addr address.Address, curTs *types.TipSet) (uint64, error) { - stateNonce, err := mp.getStateNonce(addr, curTs) // sanity check + stateNonce, err := mp.getStateNonce(ctx, addr, curTs) // sanity check if err != nil { return 0, err } @@ -963,7 +973,10 @@ func (mp *MessagePool) getNonceLocked(ctx context.Context, addr address.Address, return stateNonce, nil } -func (mp *MessagePool) getStateNonce(addr address.Address, curTs *types.TipSet) (uint64, error) { +func (mp *MessagePool) getStateNonce(ctx context.Context, addr address.Address, curTs *types.TipSet) (uint64, error) { + done := metrics.Timer(ctx, metrics.MpoolGetNonceDuration) + defer done() + act, err := mp.api.GetActorAfter(addr, curTs) if err != nil { return 0, err @@ -972,7 +985,10 @@ func (mp *MessagePool) getStateNonce(addr address.Address, curTs *types.TipSet) return act.Nonce, nil } -func (mp *MessagePool) getStateBalance(addr address.Address, ts *types.TipSet) (types.BigInt, error) { +func (mp *MessagePool) getStateBalance(ctx context.Context, addr address.Address, ts *types.TipSet) (types.BigInt, error) { + done := metrics.Timer(ctx, metrics.MpoolGetBalanceDuration) + defer done() + act, err := mp.api.GetActorAfter(addr, ts) if err != nil { return types.EmptyInt, err diff --git a/chain/sub/incoming.go b/chain/sub/incoming.go index 65447bc11..7452d31a9 100644 --- a/chain/sub/incoming.go +++ b/chain/sub/incoming.go @@ -507,6 +507,12 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs return mv.validateLocalMessage(ctx, msg) } + start := time.Now() + defer func() { + ms := time.Now().Sub(start).Microseconds() + stats.Record(ctx, metrics.MessageValidationDuration.M(float64(ms)/1000)) + }() + stats.Record(ctx, metrics.MessageReceived.M(1)) m, err := types.DecodeSignedMessage(msg.Message.GetData()) if err != nil { @@ -538,6 +544,12 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs return pubsub.ValidationReject } } + + ctx, _ = tag.New( + ctx, + tag.Upsert(metrics.MsgValid, "true"), + ) + stats.Record(ctx, metrics.MessageValidationSuccess.M(1)) return pubsub.ValidationAccept } @@ -547,6 +559,13 @@ func (mv *MessageValidator) validateLocalMessage(ctx context.Context, msg *pubsu ctx, tag.Upsert(metrics.Local, "true"), ) + + start := time.Now() + defer func() { + ms := time.Now().Sub(start).Microseconds() + stats.Record(ctx, metrics.MessageValidationDuration.M(float64(ms)/1000)) + }() + // do some lightweight validation stats.Record(ctx, metrics.MessagePublished.M(1)) @@ -581,6 +600,11 @@ func (mv *MessageValidator) validateLocalMessage(ctx context.Context, msg *pubsu return pubsub.ValidationIgnore } + ctx, _ = tag.New( + ctx, + tag.Upsert(metrics.MsgValid, "true"), + ) + stats.Record(ctx, metrics.MessageValidationSuccess.M(1)) return pubsub.ValidationAccept } diff --git a/metrics/metrics.go b/metrics/metrics.go index 5428a81bc..08c20e634 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -38,6 +38,7 @@ var ( MessageTo, _ = tag.NewKey("message_to") MessageNonce, _ = tag.NewKey("message_nonce") ReceivedFrom, _ = tag.NewKey("received_from") + MsgValid, _ = tag.NewKey("message_valid") Endpoint, _ = tag.NewKey("endpoint") APIInterface, _ = tag.NewKey("api") // to distinguish between gateway api and full node api endpoint calls @@ -61,6 +62,12 @@ var ( MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless) MessageValidationFailure = stats.Int64("message/failure", "Counter for message validation failures", stats.UnitDimensionless) MessageValidationSuccess = stats.Int64("message/success", "Counter for message validation successes", stats.UnitDimensionless) + MessageValidationDuration = stats.Float64("message/validation_ms", "Duration of message validation", stats.UnitMilliseconds) + MpoolGetNonceDuration = stats.Float64("mpool/getnonce_ms", "Duration of getStateNonce in mpool", stats.UnitMilliseconds) + MpoolGetBalanceDuration = stats.Float64("mpool/getbalance_ms", "Duration of getStateBalance in mpool", stats.UnitMilliseconds) + MpoolAddTsDuration = stats.Float64("mpool/addts_ms", "Duration of addTs in mpool", stats.UnitMilliseconds) + MpoolAddDuration = stats.Float64("mpool/add_ms", "Duration of Add in mpool", stats.UnitMilliseconds) + MpoolPushDuration = stats.Float64("mpool/push_ms", "Duration of Push in mpool", stats.UnitMilliseconds) BlockPublished = stats.Int64("block/published", "Counter for total locally published blocks", stats.UnitDimensionless) BlockReceived = stats.Int64("block/received", "Counter for total received blocks", stats.UnitDimensionless) BlockValidationFailure = stats.Int64("block/failure", "Counter for block validation failures", stats.UnitDimensionless) @@ -163,6 +170,31 @@ var ( Measure: MessageValidationSuccess, Aggregation: view.Count(), } + MessageValidationDurationView = &view.View{ + Measure: MessageValidationDuration, + Aggregation: defaultMillisecondsDistribution, + TagKeys: []tag.Key{MsgValid, Local}, + } + MpoolGetNonceDurationView = &view.View{ + Measure: MpoolGetNonceDuration, + Aggregation: defaultMillisecondsDistribution, + } + MpoolGetBalanceDurationView = &view.View{ + Measure: MpoolGetBalanceDuration, + Aggregation: defaultMillisecondsDistribution, + } + MpoolAddTsDurationView = &view.View{ + Measure: MpoolAddTsDuration, + Aggregation: defaultMillisecondsDistribution, + } + MpoolAddDurationView = &view.View{ + Measure: MpoolAddDuration, + Aggregation: defaultMillisecondsDistribution, + } + MpoolPushDurationView = &view.View{ + Measure: MpoolPushDuration, + Aggregation: defaultMillisecondsDistribution, + } PeerCountView = &view.View{ Measure: PeerCount, Aggregation: view.LastValue(), @@ -278,6 +310,12 @@ var ChainNodeViews = append([]*view.View{ MessageReceivedView, MessageValidationFailureView, MessageValidationSuccessView, + MessageValidationDurationView, + MpoolGetNonceDurationView, + MpoolGetBalanceDurationView, + MpoolAddTsDurationView, + MpoolAddDurationView, + MpoolPushDurationView, PubsubPublishMessageView, PubsubDeliverMessageView, PubsubRejectMessageView, From 40efafb7cdb1847b4ee2ccc70c0724781339e867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 14 Jun 2021 16:39:20 +0200 Subject: [PATCH 9/9] Update ffi with fixed multicore sdr support --- extern/filecoin-ffi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 1c7190dcc..57a91e861 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 1c7190dcc5bdef8042ca091129d6d3c10898dbdb +Subproject commit 57a91e861d4858379b509db42603a9cbaf0421aa