@@ -70,10 +70,26 @@ async fn miner_info(client: &Client, miner: Address) -> anyhow::Result<MinerInfo
7070 . await ?)
7171}
7272
73- /// Lotus also marks every descendant of a rejected block bad, so checking Forest's head catches
74- /// an earlier split.
75- async fn ensure_lotus_accepts_forest_head ( forest : & Client , lotus : & Client ) -> anyhow:: Result < ( ) > {
73+ /// `Ok(true)` if Lotus shares Forest's head tipset and has not marked it bad; `Ok(false)` if Lotus still trails.
74+ async fn lotus_accepts_forest_head ( forest : & Client , lotus : & Client ) -> anyhow:: Result < bool > {
7675 let head = forest. call ( ChainHead :: request ( ( ) ) ?) . await ?;
76+ let lotus_head = lotus. call ( ChainHead :: request ( ( ) ) ?) . await ?;
77+ if lotus_head. epoch ( ) < head. epoch ( ) {
78+ return Ok ( false ) ;
79+ }
80+ let lotus_at_height = lotus
81+ . call ( ChainGetTipSetByHeight :: request ( (
82+ head. epoch ( ) ,
83+ ApiTipsetKey ( None ) ,
84+ ) ) ?)
85+ . await ?;
86+ ensure ! (
87+ lotus_at_height. key( ) == head. key( ) ,
88+ "Lotus tipset at Forest head epoch {} differs: forest {}, lotus {}" ,
89+ head. epoch( ) ,
90+ head. key( ) ,
91+ lotus_at_height. key( )
92+ ) ;
7793 for cid in head. cids ( ) {
7894 let reason = lotus. call ( SyncCheckBad :: request ( ( cid, ) ) ?) . await ?;
7995 ensure ! (
@@ -82,7 +98,7 @@ async fn ensure_lotus_accepts_forest_head(forest: &Client, lotus: &Client) -> an
8298 head. epoch( )
8399 ) ;
84100 }
85- Ok ( ( ) )
101+ Ok ( true )
86102}
87103
88104async fn sector_info (
@@ -146,8 +162,7 @@ impl MinerApi {
146162 . await
147163 }
148164
149- /// Sends the queued pre-commit and commit batches now; Lotus Miner otherwise holds them for
150- /// up to a day.
165+ /// Flush pre-commit/commit batches (Lotus may hold them for up to a day).
151166 async fn flush_sealing_batches ( & self ) -> anyhow:: Result < ( ) > {
152167 for method in [
153168 "Filecoin.SectorPreCommitFlush" ,
@@ -175,7 +190,7 @@ struct SectorStatus {
175190 log : Vec < SectorLog > ,
176191}
177192
178- /// Lotus `api.SectorState`. Every state is listed, so one added by a newer Lotus fails to decode.
193+ /// Lotus `api.SectorState`. Unknown Lotus values fail to decode.
179194#[ derive( Debug , Deserialize ) ]
180195enum SectorState {
181196 /// A new sector, before Lotus processes its first event.
@@ -268,7 +283,7 @@ async fn wait_until_proving(miner_api: &MinerApi, sector: u64) -> anyhow::Result
268283 eprintln ! ( "sector {sector} state: {:?}" , status. state) ;
269284 match status. state {
270285 SectorState :: Proving | SectorState :: Available => Ok ( Some ( ( ) ) ) ,
271- // Lotus never moves a sector out of these towards `Proving` .
286+ // Never reaches Proving from these.
272287 SectorState :: FailedUnrecoverable
273288 | SectorState :: PackingFailed
274289 | SectorState :: DealsExpired
@@ -281,62 +296,11 @@ async fn wait_until_proving(miner_api: &MinerApi, sector: u64) -> anyhow::Result
281296 | SectorState :: TerminateFailed
282297 | SectorState :: Removing
283298 | SectorState :: RemoveFailed
284- | SectorState :: Removed => {
285- bail ! (
286- "sector {sector} reached {:?}, which never leads to Proving" ,
287- status. state
288- )
289- }
290- // Lotus can still move a sector out of these towards `Proving`.
291- SectorState :: Undefined
292- | SectorState :: Empty
293- | SectorState :: WaitDeals
294- | SectorState :: AddPiece
295- | SectorState :: Packing
296- | SectorState :: GetTicket
297- | SectorState :: PreCommit1
298- | SectorState :: PreCommit2
299- | SectorState :: PreCommitting
300- | SectorState :: PreCommitWait
301- | SectorState :: SubmitPreCommitBatch
302- | SectorState :: PreCommitBatchWait
303- | SectorState :: WaitSeed
304- | SectorState :: Committing
305- | SectorState :: CommitFinalize
306- | SectorState :: CommitFinalizeFailed
307- | SectorState :: SubmitCommit
308- | SectorState :: CommitWait
309- | SectorState :: SubmitCommitAggregate
310- | SectorState :: CommitAggregateWait
311- | SectorState :: FinalizeSector
312- | SectorState :: SnapDealsWaitDeals
313- | SectorState :: SnapDealsAddPiece
314- | SectorState :: SnapDealsPacking
315- | SectorState :: UpdateReplica
316- | SectorState :: ProveReplicaUpdate
317- | SectorState :: SubmitReplicaUpdate
318- | SectorState :: WaitMutable
319- | SectorState :: ReplicaUpdateWait
320- | SectorState :: FinalizeReplicaUpdate
321- | SectorState :: UpdateActivating
322- | SectorState :: ReleaseSectorKey
323- | SectorState :: ReceiveSector
324- | SectorState :: AddPieceFailed
325- | SectorState :: SealPreCommit1Failed
326- | SectorState :: SealPreCommit2Failed
327- | SectorState :: PreCommitFailed
328- | SectorState :: ComputeProofFailed
329- | SectorState :: RemoteCommitFailed
330- | SectorState :: CommitFailed
331- | SectorState :: FinalizeFailed
332- | SectorState :: RecoverDealIDs
333- | SectorState :: SnapDealsAddPieceFailed
334- | SectorState :: SnapDealsDealsExpired
335- | SectorState :: SnapDealsRecoverDealIDs
336- | SectorState :: AbortUpgrade
337- | SectorState :: ReplicaUpdateFailed
338- | SectorState :: ReleaseSectorKeyFailed
339- | SectorState :: FinalizeReplicaUpdateFailed => Ok ( None ) ,
299+ | SectorState :: Removed => bail ! (
300+ "sector {sector} reached {:?}, which never leads to Proving" ,
301+ status. state
302+ ) ,
303+ _ => Ok ( None ) ,
340304 }
341305 } )
342306 . await ;
0 commit comments