commit
58203559e7
40
extern/storage-sealing/fsm_test.go
vendored
40
extern/storage-sealing/fsm_test.go
vendored
@ -210,3 +210,43 @@ func TestBrokenState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTicketExpired(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)
|
||||
|
||||
expired := checkTicketExpired(0, MaxTicketAge+1)
|
||||
require.True(t, expired)
|
||||
|
||||
m.planSingle(SectorOldTicket{})
|
||||
require.Equal(m.t, m.state.State, GetTicket)
|
||||
|
||||
expected := []SectorState{Packing, GetTicket, PreCommit1, GetTicket}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
extern/storage-sealing/states_sealing.go
vendored
8
extern/storage-sealing/states_sealing.go
vendored
@ -99,8 +99,8 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func checkTicketExpired(sector SectorInfo, epoch abi.ChainEpoch) bool {
|
||||
return epoch-sector.TicketEpoch > MaxTicketAge // TODO: allow configuring expected seal durations
|
||||
func checkTicketExpired(ticket, head abi.ChainEpoch) bool {
|
||||
return head-ticket > MaxTicketAge // TODO: allow configuring expected seal durations
|
||||
}
|
||||
|
||||
func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.SealRandomness, abi.ChainEpoch, error) {
|
||||
@ -124,7 +124,7 @@ func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.Se
|
||||
if pci != nil {
|
||||
ticketEpoch = pci.Info.SealRandEpoch
|
||||
|
||||
if checkTicketExpired(sector, ticketEpoch) {
|
||||
if checkTicketExpired(ticketEpoch, epoch) {
|
||||
return nil, 0, xerrors.Errorf("ticket expired for precommitted sector")
|
||||
}
|
||||
}
|
||||
@ -186,7 +186,7 @@ func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo)
|
||||
return nil
|
||||
}
|
||||
|
||||
if checkTicketExpired(sector, height) {
|
||||
if checkTicketExpired(sector.TicketEpoch, height) {
|
||||
return ctx.Send(SectorOldTicket{}) // go get new ticket
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user