Skip to content

Commit 802e606

Browse files
minor corrections
1 parent 882bec6 commit 802e606

4 files changed

Lines changed: 45 additions & 69 deletions

File tree

‎.github/workflows/miner-tests.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
make-default: false
5454
- name: Checkout Sources
5555
uses: actions/checkout@v7
56+
with:
57+
persist-credentials: false
5658
- name: Setup sccache
5759
uses: mozilla-actions/sccache-action@v0.0.11
5860
timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}
@@ -103,6 +105,8 @@ jobs:
103105
"$SHELL_IMAGE" \
104106
sh -c "cp /cache/* /proofs"
105107
- uses: actions/checkout@v7
108+
with:
109+
persist-credentials: false
106110
- uses: actions/download-artifact@v8
107111
with:
108112
name: "forest-${{ runner.os }}"
@@ -148,6 +152,8 @@ jobs:
148152
runs-on: ubuntu-24.04
149153
steps:
150154
- uses: actions/checkout@v7
155+
with:
156+
persist-credentials: false
151157
- name: Set WORKFLOW_URL
152158
run: |
153159
export WORKFLOW_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"

‎scripts/devnet-forest-miner/docker-compose.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ services:
176176
command:
177177
- |
178178
set -euxo pipefail
179+
set +x
179180
export TOKEN=$$(cat ${FOREST_DATA_DIR}/token.jwt)
180181
export FULLNODE_API_INFO=$$TOKEN:/dns/forest/tcp/${FOREST_RPC_PORT}/http
182+
set -x
181183
forest-wallet --remote-wallet import --as-default ${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${MINER_ACTOR_ADDRESS}.key
182184
183185
# Lotus Miner: the block producer. Its full-node API points at FOREST, so it
@@ -208,7 +210,9 @@ services:
208210
- |
209211
set -euxo pipefail
210212
lotus-miner --version
213+
set +x
211214
export FULLNODE_API_INFO=$$(cat ${FOREST_DATA_DIR}/token.jwt):/dns/forest/tcp/${FOREST_RPC_PORT}/http
215+
set -x
212216
until lotus chain head >/dev/null 2>&1; do echo "waiting for Forest RPC ..."; sleep 2; done
213217
if [ ! -f $$LOTUS_MINER_PATH/config.toml ]; then
214218
lotus-miner init --genesis-miner --actor=${MINER_ACTOR_ADDRESS} --sector-size=2KiB --pre-sealed-sectors=${LOTUS_DATA_DIR}/genesis-sectors --pre-sealed-metadata=${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${MINER_ACTOR_ADDRESS}.json --nosync

‎src/dev/subcommands/devnet_cmd/miner.rs‎

Lines changed: 28 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -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

88104
async 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)]
180195
enum 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;

‎src/dev/subcommands/devnet_cmd/miner/onboarding.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
//! `testNonGenesisMiner` and `TestPledgeSectors` (single sector, real 2 KiB proofs).
66
77
use super::{
8-
MinerApi, ensure_lotus_accepts_forest_head, genesis_miner, miner_info, sector_info,
9-
wait_until_proving,
8+
MinerApi, genesis_miner, lotus_accepts_forest_head, miner_info, sector_info, wait_until_proving,
109
};
1110
use crate::dev::subcommands::tests_cmd::helpers::*;
1211
use crate::key_management::generate_key;
@@ -59,7 +58,6 @@ async fn create_miner() -> anyhow::Result<()> {
5958
"StateMinerCreationDeposit at epoch {}: forest {forest_deposit}, lotus {lotus_deposit}",
6059
lotus_head.epoch()
6160
);
62-
// The deposit is the per-byte cap here, so a supply disagreement does not change it.
6361
let supply = StateVMCirculatingSupplyInternal::request((at_lotus_head,))?;
6462
let forest_supply = forest.call(supply.clone()).await?;
6563
let lotus_supply = lotus.call(supply).await?;
@@ -108,7 +106,9 @@ async fn create_miner() -> anyhow::Result<()> {
108106
);
109107

110108
poll(&format!("lotus StateGetActor {miner}"), || async {
111-
ensure_lotus_accepts_forest_head(&forest, &lotus).await?;
109+
if !lotus_accepts_forest_head(&forest, &lotus).await? {
110+
return Ok(None);
111+
}
112112
get_actor(&lotus, *miner).await
113113
})
114114
.await?;
@@ -150,7 +150,9 @@ async fn pledge_sector() -> anyhow::Result<()> {
150150
let lotus_info = poll(
151151
&format!("lotus StateSectorGetInfo {miner} {sector}"),
152152
|| async {
153-
ensure_lotus_accepts_forest_head(&forest, &lotus).await?;
153+
if !lotus_accepts_forest_head(&forest, &lotus).await? {
154+
return Ok(None);
155+
}
154156
sector_info(&lotus, miner, sector).await
155157
},
156158
)

0 commit comments

Comments
 (0)