Skip to content

Commit edc8051

Browse files
committed
skip unsettleable rails
1 parent 873d4fe commit edc8051

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

pdp/contract/FWSS/settle_resolver.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ func pdpSettleTarget(rail filecoinpayment.PaymentsRailView, currentEpoch, activa
105105
return nil, false
106106
}
107107

108+
if shouldSkipFWSSActivationTerminationBoundary(rail, activationEpoch) {
109+
return nil, false
110+
}
111+
108112
if activationEpoch != nil && activationEpoch.Sign() > 0 {
109113
if maxProvingPeriod == nil || maxProvingPeriod.Sign() <= 0 {
110114
return nil, false
@@ -142,3 +146,23 @@ func pdpSettleTarget(rail filecoinpayment.PaymentsRailView, currentEpoch, activa
142146

143147
return target, true
144148
}
149+
150+
// shouldSkipFWSSActivationTerminationBoundary is a temporary FWSS contract
151+
// workaround. When a terminated PDP rail ends exactly at proving activation,
152+
// FWSS accepts toEpoch == activationEpoch in its outer range check but then
153+
// treats the same epoch as an invalid proving period internally. Lower targets
154+
// are also invalid for that rail, so Curio has no settlement epoch to submit
155+
// until the contract edge case is fixed.
156+
func shouldSkipFWSSActivationTerminationBoundary(rail filecoinpayment.PaymentsRailView, activationEpoch *big.Int) bool {
157+
if activationEpoch == nil || activationEpoch.Sign() <= 0 {
158+
return false
159+
}
160+
if rail.SettledUpTo == nil || rail.EndEpoch == nil || rail.EndEpoch.Sign() <= 0 {
161+
return false
162+
}
163+
if rail.EndEpoch.Cmp(activationEpoch) != 0 {
164+
return false
165+
}
166+
167+
return rail.SettledUpTo.Cmp(rail.EndEpoch) < 0
168+
}

pdp/contract/FWSS/settle_resolver_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ func TestFWSSPDPSettleTarget(t *testing.T) {
125125
wantTarget: 900,
126126
wantResolvable: true,
127127
},
128+
{
129+
name: "terminated rail ending at activation is skipped for FWSS contract bug",
130+
settledUpTo: 997,
131+
endEpoch: 1000,
132+
currentEpoch: 7000,
133+
activation: 1000,
134+
provingPeriod: 2880,
135+
wantResolvable: false,
136+
},
128137
{
129138
name: "no progress skips settlement",
130139
settledUpTo: 6760,

0 commit comments

Comments
 (0)