This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathminer_actor.go
2502 lines (2112 loc) · 101 KB
/
miner_actor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package miner
import (
"bytes"
"encoding/binary"
"fmt"
"math"
addr "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/cbor"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/go-state-types/exitcode"
rtt "github.com/filecoin-project/go-state-types/rt"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/v3/actors/builtin"
"github.com/filecoin-project/specs-actors/v3/actors/builtin/market"
"github.com/filecoin-project/specs-actors/v3/actors/builtin/power"
"github.com/filecoin-project/specs-actors/v3/actors/builtin/reward"
"github.com/filecoin-project/specs-actors/v3/actors/runtime"
"github.com/filecoin-project/specs-actors/v3/actors/runtime/proof"
. "github.com/filecoin-project/specs-actors/v3/actors/util"
"github.com/filecoin-project/specs-actors/v3/actors/util/adt"
"github.com/filecoin-project/specs-actors/v3/actors/util/smoothing"
)
type Runtime = runtime.Runtime
const (
// The first 1000 actor-specific codes are left open for user error, i.e. things that might
// actually happen without programming error in the actor code.
//ErrToBeDetermined = exitcode.FirstActorSpecificExitCode + iota
// The following errors are particular cases of illegal state.
// They're not expected to ever happen, but if they do, distinguished codes can help us
// diagnose the problem.
ErrBalanceInvariantBroken = 1000
)
type Actor struct{}
func (a Actor) Exports() []interface{} {
return []interface{}{
builtin.MethodConstructor: a.Constructor,
2: a.ControlAddresses,
3: a.ChangeWorkerAddress,
4: a.ChangePeerID,
5: a.SubmitWindowedPoSt,
6: a.PreCommitSector,
7: a.ProveCommitSector,
8: a.ExtendSectorExpiration,
9: a.TerminateSectors,
10: a.DeclareFaults,
11: a.DeclareFaultsRecovered,
12: a.OnDeferredCronEvent,
13: a.CheckSectorProven,
14: a.ApplyRewards,
15: a.ReportConsensusFault,
16: a.WithdrawBalance,
17: a.ConfirmSectorProofsValid,
18: a.ChangeMultiaddrs,
19: a.CompactPartitions,
20: a.CompactSectorNumbers,
21: a.ConfirmUpdateWorkerKey,
22: a.RepayDebt,
23: a.ChangeOwnerAddress,
}
}
func (a Actor) Code() cid.Cid {
return builtin.StorageMinerActorCodeID
}
func (a Actor) State() cbor.Er {
return new(State)
}
var _ runtime.VMActor = Actor{}
/////////////////
// Constructor //
/////////////////
// Storage miner actors are created exclusively by the storage power actor. In order to break a circular dependency
// between the two, the construction parameters are defined in the power actor.
type ConstructorParams = power.MinerConstructorParams
func (a Actor) Constructor(rt Runtime, params *ConstructorParams) *abi.EmptyValue {
rt.ValidateImmediateCallerIs(builtin.InitActorAddr)
checkControlAddresses(rt, params.ControlAddrs)
checkPeerInfo(rt, params.PeerId, params.Multiaddrs)
if !CanPreCommitSealProof(params.SealProofType, rt.NetworkVersion()) {
rt.Abortf(exitcode.ErrIllegalArgument, "proof type %d not allowed for new miner actors", params.SealProofType)
}
owner := resolveControlAddress(rt, params.OwnerAddr)
worker := resolveWorkerAddress(rt, params.WorkerAddr)
controlAddrs := make([]addr.Address, 0, len(params.ControlAddrs))
for _, ca := range params.ControlAddrs {
resolved := resolveControlAddress(rt, ca)
controlAddrs = append(controlAddrs, resolved)
}
currEpoch := rt.CurrEpoch()
offset, err := assignProvingPeriodOffset(rt.Receiver(), currEpoch, rt.HashBlake2b)
builtin.RequireNoErr(rt, err, exitcode.ErrSerialization, "failed to assign proving period offset")
periodStart := currentProvingPeriodStart(currEpoch, offset)
builtin.RequireState(rt, periodStart <= currEpoch, "computed proving period start %d after current epoch %d", periodStart, currEpoch)
deadlineIndex := currentDeadlineIndex(currEpoch, periodStart)
builtin.RequireState(rt, deadlineIndex < WPoStPeriodDeadlines, "computed proving deadline index %d invalid", deadlineIndex)
info, err := ConstructMinerInfo(owner, worker, controlAddrs, params.PeerId, params.Multiaddrs, params.SealProofType)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to construct initial miner info")
infoCid := rt.StorePut(info)
store := adt.AsStore(rt)
state, err := ConstructState(store, infoCid, periodStart, deadlineIndex)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to construct state")
rt.StateCreate(state)
// Register first cron callback for epoch before the next deadline starts.
deadlineClose := periodStart + WPoStChallengeWindow*abi.ChainEpoch(1+deadlineIndex)
enrollCronEvent(rt, deadlineClose-1, &CronEventPayload{
EventType: CronEventProvingDeadline,
})
return nil
}
/////////////
// Control //
/////////////
// type GetControlAddressesReturn struct {
// Owner addr.Address
// Worker addr.Address
// ControlAddrs []addr.Address
// }
type GetControlAddressesReturn = miner2.GetControlAddressesReturn
func (a Actor) ControlAddresses(rt Runtime, _ *abi.EmptyValue) *GetControlAddressesReturn {
rt.ValidateImmediateCallerAcceptAny()
var st State
rt.StateReadonly(&st)
info := getMinerInfo(rt, &st)
return &GetControlAddressesReturn{
Owner: info.Owner,
Worker: info.Worker,
ControlAddrs: info.ControlAddresses,
}
}
//type ChangeWorkerAddressParams struct {
// NewWorker addr.Address
// NewControlAddrs []addr.Address
//}
type ChangeWorkerAddressParams = miner0.ChangeWorkerAddressParams
// ChangeWorkerAddress will ALWAYS overwrite the existing control addresses with the control addresses passed in the params.
// If a nil addresses slice is passed, the control addresses will be cleared.
// A worker change will be scheduled if the worker passed in the params is different from the existing worker.
func (a Actor) ChangeWorkerAddress(rt Runtime, params *ChangeWorkerAddressParams) *abi.EmptyValue {
checkControlAddresses(rt, params.NewControlAddrs)
newWorker := resolveWorkerAddress(rt, params.NewWorker)
var controlAddrs []addr.Address
for _, ca := range params.NewControlAddrs {
resolved := resolveControlAddress(rt, ca)
controlAddrs = append(controlAddrs, resolved)
}
var st State
rt.StateTransaction(&st, func() {
info := getMinerInfo(rt, &st)
// Only the Owner is allowed to change the newWorker and control addresses.
rt.ValidateImmediateCallerIs(info.Owner)
// save the new control addresses
info.ControlAddresses = controlAddrs
// save newWorker addr key change request
if newWorker != info.Worker && info.PendingWorkerKey == nil {
info.PendingWorkerKey = &WorkerKeyChange{
NewWorker: newWorker,
EffectiveAt: rt.CurrEpoch() + WorkerKeyChangeDelay,
}
}
err := st.SaveInfo(adt.AsStore(rt), info)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "could not save miner info")
})
return nil
}
// Triggers a worker address change if a change has been requested and its effective epoch has arrived.
func (a Actor) ConfirmUpdateWorkerKey(rt Runtime, params *abi.EmptyValue) *abi.EmptyValue {
var st State
rt.StateTransaction(&st, func() {
info := getMinerInfo(rt, &st)
// Only the Owner is allowed to change the newWorker.
rt.ValidateImmediateCallerIs(info.Owner)
processPendingWorker(info, rt, &st)
})
return nil
}
// Proposes or confirms a change of owner address.
// If invoked by the current owner, proposes a new owner address for confirmation. If the proposed address is the
// current owner address, revokes any existing proposal.
// If invoked by the previously proposed address, with the same proposal, changes the current owner address to be
// that proposed address.
func (a Actor) ChangeOwnerAddress(rt Runtime, newAddress *addr.Address) *abi.EmptyValue {
if newAddress.Empty() {
rt.Abortf(exitcode.ErrIllegalArgument, "empty address")
}
if newAddress.Protocol() != addr.ID {
rt.Abortf(exitcode.ErrIllegalArgument, "owner address must be an ID address")
}
var st State
rt.StateTransaction(&st, func() {
info := getMinerInfo(rt, &st)
if rt.Caller() == info.Owner || info.PendingOwnerAddress == nil {
// Propose new address.
rt.ValidateImmediateCallerIs(info.Owner)
info.PendingOwnerAddress = newAddress
} else { // info.PendingOwnerAddress != nil
// Confirm the proposal.
// This validates that the operator can in fact use the proposed new address to sign messages.
rt.ValidateImmediateCallerIs(*info.PendingOwnerAddress)
if *newAddress != *info.PendingOwnerAddress {
rt.Abortf(exitcode.ErrIllegalArgument, "expected confirmation of %v, got %v",
info.PendingOwnerAddress, newAddress)
}
info.Owner = *info.PendingOwnerAddress
}
// Clear any resulting no-op change.
if info.PendingOwnerAddress != nil && *info.PendingOwnerAddress == info.Owner {
info.PendingOwnerAddress = nil
}
err := st.SaveInfo(adt.AsStore(rt), info)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to save miner info")
})
return nil
}
//type ChangePeerIDParams struct {
// NewID abi.PeerID
//}
type ChangePeerIDParams = miner0.ChangePeerIDParams
func (a Actor) ChangePeerID(rt Runtime, params *ChangePeerIDParams) *abi.EmptyValue {
checkPeerInfo(rt, params.NewID, nil)
var st State
rt.StateTransaction(&st, func() {
info := getMinerInfo(rt, &st)
rt.ValidateImmediateCallerIs(append(info.ControlAddresses, info.Owner, info.Worker)...)
info.PeerId = params.NewID
err := st.SaveInfo(adt.AsStore(rt), info)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "could not save miner info")
})
return nil
}
//type ChangeMultiaddrsParams struct {
// NewMultiaddrs []abi.Multiaddrs
//}
type ChangeMultiaddrsParams = miner0.ChangeMultiaddrsParams
func (a Actor) ChangeMultiaddrs(rt Runtime, params *ChangeMultiaddrsParams) *abi.EmptyValue {
checkPeerInfo(rt, nil, params.NewMultiaddrs)
var st State
rt.StateTransaction(&st, func() {
info := getMinerInfo(rt, &st)
rt.ValidateImmediateCallerIs(append(info.ControlAddresses, info.Owner, info.Worker)...)
info.Multiaddrs = params.NewMultiaddrs
err := st.SaveInfo(adt.AsStore(rt), info)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "could not save miner info")
})
return nil
}
//////////////////
// WindowedPoSt //
//////////////////
//type PoStPartition struct {
// // Partitions are numbered per-deadline, from zero.
// Index uint64
// // Sectors skipped while proving that weren't already declared faulty
// Skipped bitfield.BitField
//}
type PoStPartition = miner0.PoStPartition
// Information submitted by a miner to provide a Window PoSt.
//type SubmitWindowedPoStParams struct {
// // The deadline index which the submission targets.
// Deadline uint64
// // The partitions being proven.
// Partitions []PoStPartition
// // Array of proofs, one per distinct registered proof type present in the sectors being proven.
// // In the usual case of a single proof type, this array will always have a single element (independent of number of partitions).
// Proofs []proof.PoStProof
// // The epoch at which these proofs is being committed to a particular chain.
// // NOTE: This field should be removed in the future. See
// // https://github.com/filecoin-project/specs-actors/issues/1094
// ChainCommitEpoch abi.ChainEpoch
// // The ticket randomness on the chain at the chain commit epoch.
// ChainCommitRand abi.Randomness
//}
type SubmitWindowedPoStParams = miner0.SubmitWindowedPoStParams
// Invoked by miner's worker address to submit their fallback post
func (a Actor) SubmitWindowedPoSt(rt Runtime, params *SubmitWindowedPoStParams) *abi.EmptyValue {
currEpoch := rt.CurrEpoch()
store := adt.AsStore(rt)
var st State
if params.Deadline >= WPoStPeriodDeadlines {
rt.Abortf(exitcode.ErrIllegalArgument, "invalid deadline %d of %d", params.Deadline, WPoStPeriodDeadlines)
}
// Technically, ChainCommitRand should be _exactly_ 32 bytes. However:
// 1. It's convenient to allow smaller slices when testing.
// 2. Nothing bad will happen if the caller provides too little randomness.
if len(params.ChainCommitRand) > abi.RandomnessLength {
rt.Abortf(exitcode.ErrIllegalArgument, "expected at most %d bytes of randomness, got %d", abi.RandomnessLength, len(params.ChainCommitRand))
}
partitionIndexes := bitfield.New()
for _, partition := range params.Partitions {
partitionIndexes.Set(partition.Index)
}
var postResult *PoStResult
var info *MinerInfo
rt.StateTransaction(&st, func() {
info = getMinerInfo(rt, &st)
rt.ValidateImmediateCallerIs(append(info.ControlAddresses, info.Owner, info.Worker)...)
// Verify that the miner has passed 0 or 1 proofs. If they've
// passed 1, verify that it's a good proof.
//
// This can be 0 if the miner isn't actually proving anything,
// just skipping all sectors.
windowPoStProofType, err := info.SealProofType.RegisteredWindowPoStProof()
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to determine window PoSt type")
if len(params.Proofs) != 1 {
rt.Abortf(exitcode.ErrIllegalArgument, "expected exactly one proof, got %d", len(params.Proofs))
} else if params.Proofs[0].PoStProof != windowPoStProofType {
rt.Abortf(exitcode.ErrIllegalArgument, "expected proof of type %s, got proof of type %s", params.Proofs[0], windowPoStProofType)
}
// Validate that the miner didn't try to prove too many partitions at once.
submissionPartitionLimit := loadPartitionsSectorsMax(info.WindowPoStPartitionSectors)
if uint64(len(params.Partitions)) > submissionPartitionLimit {
rt.Abortf(exitcode.ErrIllegalArgument, "too many partitions %d, limit %d", len(params.Partitions), submissionPartitionLimit)
}
currDeadline := st.DeadlineInfo(currEpoch)
// Check that the miner state indicates that the current proving deadline has started.
// This should only fail if the cron actor wasn't invoked, and matters only in case that it hasn't been
// invoked for a whole proving period, and hence the missed PoSt submissions from the prior occurrence
// of this deadline haven't been processed yet.
if !currDeadline.IsOpen() {
rt.Abortf(exitcode.ErrIllegalState, "proving period %d not yet open at %d", currDeadline.PeriodStart, currEpoch)
}
// The miner may only submit a proof for the current deadline.
if params.Deadline != currDeadline.Index {
rt.Abortf(exitcode.ErrIllegalArgument, "invalid deadline %d at epoch %d, expected %d",
params.Deadline, currEpoch, currDeadline.Index)
}
// Verify that the PoSt was committed to the chain at most WPoStChallengeLookback+WPoStChallengeWindow in the past.
if params.ChainCommitEpoch < currDeadline.Challenge {
rt.Abortf(exitcode.ErrIllegalArgument, "expected chain commit epoch %d to be after %d", params.ChainCommitEpoch, currDeadline.Challenge)
}
if params.ChainCommitEpoch >= currEpoch {
rt.Abortf(exitcode.ErrIllegalArgument, "chain commit epoch %d must be less than the current epoch %d", params.ChainCommitEpoch, currEpoch)
}
// Verify the chain commit randomness.
commRand := rt.GetRandomnessFromTickets(crypto.DomainSeparationTag_PoStChainCommit, params.ChainCommitEpoch, nil)
if !bytes.Equal(commRand, params.ChainCommitRand) {
rt.Abortf(exitcode.ErrIllegalArgument, "post commit randomness mismatched")
}
sectors, err := LoadSectors(store, st.Sectors)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load sectors")
deadlines, err := st.LoadDeadlines(adt.AsStore(rt))
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load deadlines")
deadline, err := deadlines.LoadDeadline(store, params.Deadline)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load deadline %d", params.Deadline)
alreadyProven, err := bitfield.IntersectBitField(deadline.PostSubmissions, partitionIndexes)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check proven partitions")
empty, err := alreadyProven.IsEmpty()
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check proven intersection is empty")
if !empty {
rt.Abortf(exitcode.ErrIllegalArgument, "partition already proven: %v", alreadyProven)
}
// Record proven sectors/partitions, returning updates to power and the final set of sectors
// proven/skipped.
//
// NOTE: This function does not actually check the proofs but does assume that they'll be
// successfully validated. The actual proof verification is done below in verifyWindowedPost.
//
// If proof verification fails, the this deadline MUST NOT be saved and this function should
// be aborted.
faultExpiration := currDeadline.Last() + FaultMaxAge
postResult, err = deadline.RecordProvenSectors(store, sectors, info.SectorSize, QuantSpecForDeadline(currDeadline), faultExpiration, params.Partitions)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to process post submission for deadline %d", params.Deadline)
// Skipped sectors (including retracted recoveries) pay nothing at Window PoSt,
// but will incur the "ongoing" fault fee at deadline end.
// Validate proofs
// Load sector infos for proof, substituting a known-good sector for known-faulty sectors.
// Note: this is slightly sub-optimal, loading info for the recovering sectors again after they were already
// loaded above.
sectorInfos, err := sectors.LoadForProof(postResult.Sectors, postResult.IgnoredSectors)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load proven sector info")
if len(sectorInfos) == 0 {
// Abort verification if all sectors are (now) faults. There's nothing to prove.
// It's not rational for a miner to submit a Window PoSt marking *all* non-faulty sectors as skipped,
// since that will just cause them to pay a penalty at deadline end that would otherwise be zero
// if they had *not* declared them.
rt.Abortf(exitcode.ErrIllegalArgument, "cannot prove partitions with no active sectors")
}
// Verify the proof.
// A failed verification doesn't immediately cause a penalty; the miner can try again.
//
// This function aborts on failure.
verifyWindowedPost(rt, currDeadline.Challenge, sectorInfos, params.Proofs)
err = deadlines.UpdateDeadline(store, params.Deadline, deadline)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to update deadline %d", params.Deadline)
err = st.SaveDeadlines(store, deadlines)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to save deadlines")
})
// Restore power for recovered sectors. Remove power for new faults.
// NOTE: It would be permissible to delay the power loss until the deadline closes, but that would require
// additional accounting state.
// https://github.com/filecoin-project/specs-actors/issues/414
requestUpdatePower(rt, postResult.PowerDelta)
rt.StateReadonly(&st)
err := st.CheckBalanceInvariants(rt.CurrentBalance())
builtin.RequireNoErr(rt, err, ErrBalanceInvariantBroken, "balance invariants broken")
return nil
}
///////////////////////
// Sector Commitment //
///////////////////////
//type SectorPreCommitInfo struct {
// SealProof abi.RegisteredSealProof
// SectorNumber abi.SectorNumber
// SealedCID cid.Cid `checked:"true"` // CommR
// SealRandEpoch abi.ChainEpoch
// DealIDs []abi.DealID
// Expiration abi.ChainEpoch
// ReplaceCapacity bool // Whether to replace a "committed capacity" no-deal sector (requires non-empty DealIDs)
// // The committed capacity sector to replace, and it's deadline/partition location
// ReplaceSectorDeadline uint64
// ReplaceSectorPartition uint64
// ReplaceSectorNumber abi.SectorNumber
//}
type PreCommitSectorParams = miner0.SectorPreCommitInfo
// Proposals must be posted on chain via sma.PublishStorageDeals before PreCommitSector.
// Optimization: PreCommitSector could contain a list of deals that are not published yet.
func (a Actor) PreCommitSector(rt Runtime, params *PreCommitSectorParams) *abi.EmptyValue {
nv := rt.NetworkVersion()
if !CanPreCommitSealProof(params.SealProof, nv) {
rt.Abortf(exitcode.ErrIllegalArgument, "unsupported seal proof type %v at network version %v", params.SealProof, nv)
}
if params.SectorNumber > abi.MaxSectorNumber {
rt.Abortf(exitcode.ErrIllegalArgument, "sector number %d out of range 0..(2^63-1)", params.SectorNumber)
}
if !params.SealedCID.Defined() {
rt.Abortf(exitcode.ErrIllegalArgument, "sealed CID undefined")
}
if params.SealedCID.Prefix() != SealedCIDPrefix {
rt.Abortf(exitcode.ErrIllegalArgument, "sealed CID had wrong prefix")
}
if params.SealRandEpoch >= rt.CurrEpoch() {
rt.Abortf(exitcode.ErrIllegalArgument, "seal challenge epoch %v must be before now %v", params.SealRandEpoch, rt.CurrEpoch())
}
challengeEarliest := rt.CurrEpoch() - MaxPreCommitRandomnessLookback
if params.SealRandEpoch < challengeEarliest {
rt.Abortf(exitcode.ErrIllegalArgument, "seal challenge epoch %v too old, must be after %v", params.SealRandEpoch, challengeEarliest)
}
// Require sector lifetime meets minimum by assuming activation happens at last epoch permitted for seal proof.
// This could make sector maximum lifetime validation more lenient if the maximum sector limit isn't hit first.
maxActivation := rt.CurrEpoch() + MaxProveCommitDuration[params.SealProof]
validateExpiration(rt, maxActivation, params.Expiration, params.SealProof)
if params.ReplaceCapacity && len(params.DealIDs) == 0 {
rt.Abortf(exitcode.ErrIllegalArgument, "cannot replace sector without committing deals")
}
if params.ReplaceSectorDeadline >= WPoStPeriodDeadlines {
rt.Abortf(exitcode.ErrIllegalArgument, "invalid deadline %d", params.ReplaceSectorDeadline)
}
if params.ReplaceSectorNumber > abi.MaxSectorNumber {
rt.Abortf(exitcode.ErrIllegalArgument, "invalid sector number %d", params.ReplaceSectorNumber)
}
// gather information from other actors
rewardStats := requestCurrentEpochBlockReward(rt)
pwrTotal := requestCurrentTotalPower(rt)
dealWeights := requestDealWeights(rt, []market.SectorDeals{
{
SectorExpiry: params.Expiration,
DealIDs: params.DealIDs,
},
})
if len(dealWeights.Sectors) == 0 {
rt.Abortf(exitcode.ErrIllegalState, "deal weight request returned no records")
}
dealWeight := dealWeights.Sectors[0]
store := adt.AsStore(rt)
var st State
var err error
newlyVested := big.Zero()
feeToBurn := abi.NewTokenAmount(0)
rt.StateTransaction(&st, func() {
// available balance already accounts for fee debt so it is correct to call
// this before RepayDebts. We would have to
// subtract fee debt explicitly if we called this after.
availableBalance, err := st.GetAvailableBalance(rt.CurrentBalance())
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to calculate available balance")
feeToBurn = RepayDebtsOrAbort(rt, &st)
info := getMinerInfo(rt, &st)
rt.ValidateImmediateCallerIs(append(info.ControlAddresses, info.Owner, info.Worker)...)
if ConsensusFaultActive(info, rt.CurrEpoch()) {
rt.Abortf(exitcode.ErrForbidden, "precommit not allowed during active consensus fault")
}
// From network version 7, the pre-commit seal type must have the same Window PoSt proof type as the miner's
// recorded seal type has, rather than be exactly the same seal type.
// This permits a transition window from V1 to V1_1 seal types (which share Window PoSt proof type).
minerWPoStProof, err := info.SealProofType.RegisteredWindowPoStProof()
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to lookup Window PoSt proof type for miner seal proof %d", info.SealProofType)
sectorWPoStProof, err := params.SealProof.RegisteredWindowPoStProof()
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "failed to lookup Window PoSt proof type for sector seal proof %d", params.SealProof)
if sectorWPoStProof != minerWPoStProof {
rt.Abortf(exitcode.ErrIllegalArgument, "sector Window PoSt proof type %d must match miner Window PoSt proof type %d (seal proof type %d)",
sectorWPoStProof, minerWPoStProof, params.SealProof)
}
dealCountMax := SectorDealsMax(info.SectorSize)
if uint64(len(params.DealIDs)) > dealCountMax {
rt.Abortf(exitcode.ErrIllegalArgument, "too many deals for sector %d > %d", len(params.DealIDs), dealCountMax)
}
// Ensure total deal space does not exceed sector size.
if dealWeight.DealSpace > uint64(info.SectorSize) {
rt.Abortf(exitcode.ErrIllegalArgument, "deals too large to fit in sector %d > %d", dealWeight.DealSpace, info.SectorSize)
}
err = st.AllocateSectorNumber(store, params.SectorNumber)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to allocate sector id %d", params.SectorNumber)
// The following two checks shouldn't be necessary, but it can't
// hurt to double-check (unless it's really just too
// expensive?).
_, preCommitFound, err := st.GetPrecommittedSector(store, params.SectorNumber)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check pre-commit %v", params.SectorNumber)
if preCommitFound {
rt.Abortf(exitcode.ErrIllegalState, "sector %v already pre-committed", params.SectorNumber)
}
sectorFound, err := st.HasSectorNo(store, params.SectorNumber)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to check sector %v", params.SectorNumber)
if sectorFound {
rt.Abortf(exitcode.ErrIllegalState, "sector %v already committed", params.SectorNumber)
}
if params.ReplaceCapacity {
validateReplaceSector(rt, &st, store, params)
}
duration := params.Expiration - rt.CurrEpoch()
sectorWeight := QAPowerForWeight(info.SectorSize, duration, dealWeight.DealWeight, dealWeight.VerifiedDealWeight)
depositReq := PreCommitDepositForPower(rewardStats.ThisEpochRewardSmoothed, pwrTotal.QualityAdjPowerSmoothed, sectorWeight)
if availableBalance.LessThan(depositReq) {
rt.Abortf(exitcode.ErrInsufficientFunds, "insufficient funds for pre-commit deposit: %v", depositReq)
}
err = st.AddPreCommitDeposit(depositReq)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add pre-commit deposit %v", depositReq)
if err := st.PutPrecommittedSector(store, &SectorPreCommitOnChainInfo{
Info: SectorPreCommitInfo(*params),
PreCommitDeposit: depositReq,
PreCommitEpoch: rt.CurrEpoch(),
DealWeight: dealWeight.DealWeight,
VerifiedDealWeight: dealWeight.VerifiedDealWeight,
}); err != nil {
rt.Abortf(exitcode.ErrIllegalState, "failed to write pre-committed sector %v: %v", params.SectorNumber, err)
}
// add precommit expiry to the queue
msd, ok := MaxProveCommitDuration[params.SealProof]
if !ok {
rt.Abortf(exitcode.ErrIllegalArgument, "no max seal duration set for proof type: %d", params.SealProof)
}
// The +1 here is critical for the batch verification of proofs. Without it, if a proof arrived exactly on the
// due epoch, ProveCommitSector would accept it, then the expiry event would remove it, and then
// ConfirmSectorProofsValid would fail to find it.
expiryBound := rt.CurrEpoch() + msd + 1
err = st.AddPreCommitExpiry(store, expiryBound, params.SectorNumber)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add pre-commit expiry to queue")
})
burnFunds(rt, feeToBurn)
rt.StateReadonly(&st)
err = st.CheckBalanceInvariants(rt.CurrentBalance())
builtin.RequireNoErr(rt, err, ErrBalanceInvariantBroken, "balance invariants broken")
notifyPledgeChanged(rt, newlyVested.Neg())
return nil
}
//type ProveCommitSectorParams struct {
// SectorNumber abi.SectorNumber
// Proof []byte
//}
type ProveCommitSectorParams = miner0.ProveCommitSectorParams
// Checks state of the corresponding sector pre-commitment, then schedules the proof to be verified in bulk
// by the power actor.
// If valid, the power actor will call ConfirmSectorProofsValid at the end of the same epoch as this message.
func (a Actor) ProveCommitSector(rt Runtime, params *ProveCommitSectorParams) *abi.EmptyValue {
rt.ValidateImmediateCallerAcceptAny()
if params.SectorNumber > abi.MaxSectorNumber {
rt.Abortf(exitcode.ErrIllegalArgument, "sector number greater than maximum")
}
maxProofSize := MaxProveCommitSize
if len(params.Proof) > maxProofSize {
rt.Abortf(exitcode.ErrIllegalArgument, "sector prove-commit proof of size %d exceeds max size of %d",
len(params.Proof), maxProofSize)
}
store := adt.AsStore(rt)
sectorNo := params.SectorNumber
var st State
rt.StateReadonly(&st)
precommit, found, err := st.GetPrecommittedSector(store, sectorNo)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load pre-committed sector %v", sectorNo)
if !found {
rt.Abortf(exitcode.ErrNotFound, "no pre-committed sector %v", sectorNo)
}
msd, ok := MaxProveCommitDuration[precommit.Info.SealProof]
if !ok {
rt.Abortf(exitcode.ErrIllegalState, "no max seal duration for proof type: %d", precommit.Info.SealProof)
}
proveCommitDue := precommit.PreCommitEpoch + msd
if rt.CurrEpoch() > proveCommitDue {
rt.Abortf(exitcode.ErrIllegalArgument, "commitment proof for %d too late at %d, due %d", sectorNo, rt.CurrEpoch(), proveCommitDue)
}
svi := getVerifyInfo(rt, &SealVerifyStuff{
SealedCID: precommit.Info.SealedCID,
InteractiveEpoch: precommit.PreCommitEpoch + PreCommitChallengeDelay,
SealRandEpoch: precommit.Info.SealRandEpoch,
Proof: params.Proof,
DealIDs: precommit.Info.DealIDs,
SectorNumber: precommit.Info.SectorNumber,
RegisteredSealProof: precommit.Info.SealProof,
})
code := rt.Send(
builtin.StoragePowerActorAddr,
builtin.MethodsPower.SubmitPoRepForBulkVerify,
svi,
abi.NewTokenAmount(0),
&builtin.Discard{},
)
builtin.RequireSuccess(rt, code, "failed to submit proof for bulk verification")
return nil
}
func (a Actor) ConfirmSectorProofsValid(rt Runtime, params *builtin.ConfirmSectorProofsParams) *abi.EmptyValue {
rt.ValidateImmediateCallerIs(builtin.StoragePowerActorAddr)
// This should be enforced by the power actor. We log here just in case
// something goes wrong.
if len(params.Sectors) > power.MaxMinerProveCommitsPerEpoch {
rt.Log(rtt.WARN, "confirmed more prove commits in an epoch than permitted: %d > %d",
len(params.Sectors), power.MaxMinerProveCommitsPerEpoch,
)
}
// get network stats from other actors
rewardStats := requestCurrentEpochBlockReward(rt)
pwrTotal := requestCurrentTotalPower(rt)
circulatingSupply := rt.TotalFilCircSupply()
// 1. Activate deals, skipping pre-commits with invalid deals.
// - calls the market actor.
// 2. Reschedule replacement sector expiration.
// - loads and saves sectors
// - loads and saves deadlines/partitions
// 3. Add new sectors.
// - loads and saves sectors.
// - loads and saves deadlines/partitions
//
// Ideally, we'd combine some of these operations, but at least we have
// a constant number of them.
var st State
rt.StateReadonly(&st)
store := adt.AsStore(rt)
info := getMinerInfo(rt, &st)
//
// Activate storage deals.
//
// This skips missing pre-commits.
precommittedSectors, err := st.FindPrecommittedSectors(store, params.Sectors...)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load pre-committed sectors")
// Committed-capacity sectors licensed for early removal by new sectors being proven.
replaceSectors := make(DeadlineSectorMap)
// Pre-commits for new sectors.
var preCommits []*SectorPreCommitOnChainInfo
for _, precommit := range precommittedSectors {
if len(precommit.Info.DealIDs) > 0 {
// Check (and activate) storage deals associated to sector. Abort if checks failed.
// TODO: we should batch these calls...
// https://github.com/filecoin-project/specs-actors/issues/474
code := rt.Send(
builtin.StorageMarketActorAddr,
builtin.MethodsMarket.ActivateDeals,
&market.ActivateDealsParams{
DealIDs: precommit.Info.DealIDs,
SectorExpiry: precommit.Info.Expiration,
},
abi.NewTokenAmount(0),
&builtin.Discard{},
)
if code != exitcode.Ok {
rt.Log(rtt.INFO, "failed to activate deals on sector %d, dropping from prove commit set", precommit.Info.SectorNumber)
continue
}
}
preCommits = append(preCommits, precommit)
if precommit.Info.ReplaceCapacity {
err := replaceSectors.AddValues(
precommit.Info.ReplaceSectorDeadline,
precommit.Info.ReplaceSectorPartition,
uint64(precommit.Info.ReplaceSectorNumber),
)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument, "failed to record sectors for replacement")
}
}
// When all prove commits have failed abort early
if len(preCommits) == 0 {
rt.Abortf(exitcode.ErrIllegalArgument, "all prove commits failed to validate")
}
totalPledge := big.Zero()
depositToUnlock := big.Zero()
newSectors := make([]*SectorOnChainInfo, 0)
newlyVested := big.Zero()
rt.StateTransaction(&st, func() {
// Schedule expiration for replaced sectors to the end of their next deadline window.
// They can't be removed right now because we want to challenge them immediately before termination.
replaced, err := st.RescheduleSectorExpirations(store, rt.CurrEpoch(), info.SectorSize, replaceSectors)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to replace sector expirations")
replacedBySectorNumber := asMapBySectorNumber(replaced)
newSectorNos := make([]abi.SectorNumber, 0, len(preCommits))
for _, precommit := range preCommits {
// compute initial pledge
activation := rt.CurrEpoch()
duration := precommit.Info.Expiration - activation
// This should have been caught in precommit, but don't let other sectors fail because of it.
if duration < MinSectorExpiration {
rt.Log(rtt.WARN, "precommit %d has lifetime %d less than minimum. ignoring", precommit.Info.SectorNumber, duration, MinSectorExpiration)
continue
}
pwr := QAPowerForWeight(info.SectorSize, duration, precommit.DealWeight, precommit.VerifiedDealWeight)
dayReward := ExpectedRewardForPower(rewardStats.ThisEpochRewardSmoothed, pwrTotal.QualityAdjPowerSmoothed, pwr, builtin.EpochsInDay)
// The storage pledge is recorded for use in computing the penalty if this sector is terminated
// before its declared expiration.
// It's not capped to 1 FIL, so can exceed the actual initial pledge requirement.
storagePledge := ExpectedRewardForPower(rewardStats.ThisEpochRewardSmoothed, pwrTotal.QualityAdjPowerSmoothed, pwr, InitialPledgeProjectionPeriod)
initialPledge := InitialPledgeForPower(pwr, rewardStats.ThisEpochBaselinePower, rewardStats.ThisEpochRewardSmoothed,
pwrTotal.QualityAdjPowerSmoothed, circulatingSupply)
// Lower-bound the pledge by that of the sector being replaced.
// Record the replaced age and reward rate for termination fee calculations.
replacedPledge, replacedAge, replacedDayReward := replacedSectorParameters(rt, precommit, replacedBySectorNumber)
initialPledge = big.Max(initialPledge, replacedPledge)
newSectorInfo := SectorOnChainInfo{
SectorNumber: precommit.Info.SectorNumber,
SealProof: precommit.Info.SealProof,
SealedCID: precommit.Info.SealedCID,
DealIDs: precommit.Info.DealIDs,
Expiration: precommit.Info.Expiration,
Activation: activation,
DealWeight: precommit.DealWeight,
VerifiedDealWeight: precommit.VerifiedDealWeight,
InitialPledge: initialPledge,
ExpectedDayReward: dayReward,
ExpectedStoragePledge: storagePledge,
ReplacedSectorAge: replacedAge,
ReplacedDayReward: replacedDayReward,
}
depositToUnlock = big.Add(depositToUnlock, precommit.PreCommitDeposit)
newSectors = append(newSectors, &newSectorInfo)
newSectorNos = append(newSectorNos, newSectorInfo.SectorNumber)
totalPledge = big.Add(totalPledge, initialPledge)
}
err = st.PutSectors(store, newSectors...)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to put new sectors")
err = st.DeletePrecommittedSectors(store, newSectorNos...)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to delete precommited sectors")
err = st.AssignSectorsToDeadlines(store, rt.CurrEpoch(), newSectors, info.WindowPoStPartitionSectors, info.SectorSize)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to assign new sectors to deadlines")
// Unlock deposit for successful proofs, make it available for lock-up as initial pledge.
err = st.AddPreCommitDeposit(depositToUnlock.Neg())
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add pre-commit deposit %v", depositToUnlock.Neg())
unlockedBalance, err := st.GetUnlockedBalance(rt.CurrentBalance())
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to calculate unlocked balance")
if unlockedBalance.LessThan(totalPledge) {
rt.Abortf(exitcode.ErrInsufficientFunds, "insufficient funds for aggregate initial pledge requirement %s, available: %s", totalPledge, unlockedBalance)
}
err = st.AddInitialPledge(totalPledge)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to add initial pledge %v", totalPledge)
err = st.CheckBalanceInvariants(rt.CurrentBalance())
builtin.RequireNoErr(rt, err, ErrBalanceInvariantBroken, "balance invariants broken")
})
// Request pledge update for activated sector.
notifyPledgeChanged(rt, big.Sub(totalPledge, newlyVested))
return nil
}
//type CheckSectorProvenParams struct {
// SectorNumber abi.SectorNumber
//}
type CheckSectorProvenParams = miner0.CheckSectorProvenParams
func (a Actor) CheckSectorProven(rt Runtime, params *CheckSectorProvenParams) *abi.EmptyValue {
rt.ValidateImmediateCallerAcceptAny()
if params.SectorNumber > abi.MaxSectorNumber {
rt.Abortf(exitcode.ErrIllegalArgument, "sector number out of range")
}
var st State
rt.StateReadonly(&st)
store := adt.AsStore(rt)
sectorNo := params.SectorNumber
if _, found, err := st.GetSector(store, sectorNo); err != nil {
rt.Abortf(exitcode.ErrIllegalState, "failed to load proven sector %v", sectorNo)
} else if !found {
rt.Abortf(exitcode.ErrNotFound, "sector %v not proven", sectorNo)
}
return nil
}
/////////////////////////
// Sector Modification //
/////////////////////////
//type ExtendSectorExpirationParams struct {
// Extensions []ExpirationExtension
//}
type ExtendSectorExpirationParams = miner0.ExtendSectorExpirationParams
//type ExpirationExtension struct {
// Deadline uint64
// Partition uint64
// Sectors bitfield.BitField
// NewExpiration abi.ChainEpoch
//}
type ExpirationExtension = miner0.ExpirationExtension
// Changes the expiration epoch for a sector to a new, later one.
// The sector must not be terminated or faulty.
// The sector's power is recomputed for the new expiration.
func (a Actor) ExtendSectorExpiration(rt Runtime, params *ExtendSectorExpirationParams) *abi.EmptyValue {
if uint64(len(params.Extensions)) > DeclarationsMax {
rt.Abortf(exitcode.ErrIllegalArgument, "too many declarations %d, max %d", len(params.Extensions), DeclarationsMax)
}
// limit the number of sectors declared at once
// https://github.com/filecoin-project/specs-actors/issues/416
var sectorCount uint64
for _, decl := range params.Extensions {
if decl.Deadline >= WPoStPeriodDeadlines {
rt.Abortf(exitcode.ErrIllegalArgument, "deadline %d not in range 0..%d", decl.Deadline, WPoStPeriodDeadlines)
}
count, err := decl.Sectors.Count()
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalArgument,
"failed to count sectors for deadline %d, partition %d",
decl.Deadline, decl.Partition,
)
if sectorCount > math.MaxUint64-count {
rt.Abortf(exitcode.ErrIllegalArgument, "sector bitfield integer overflow")
}
sectorCount += count
}
if sectorCount > AddressedSectorsMax {
rt.Abortf(exitcode.ErrIllegalArgument,
"too many sectors for declaration %d, max %d",
sectorCount, AddressedSectorsMax,
)
}
currEpoch := rt.CurrEpoch()
powerDelta := NewPowerPairZero()
pledgeDelta := big.Zero()
store := adt.AsStore(rt)
var st State
rt.StateTransaction(&st, func() {
info := getMinerInfo(rt, &st)
rt.ValidateImmediateCallerIs(append(info.ControlAddresses, info.Owner, info.Worker)...)
deadlines, err := st.LoadDeadlines(adt.AsStore(rt))
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to load deadlines")
// Group declarations by deadline, and remember iteration order.
// This should be merged with the iteration outside the state transaction.
declsByDeadline := map[uint64][]*ExpirationExtension{}
var deadlinesToLoad []uint64
for i := range params.Extensions {
// Take a pointer to the value inside the slice, don't
// take a reference to the temporary loop variable as it
// will be overwritten every iteration.
decl := ¶ms.Extensions[i]
if _, ok := declsByDeadline[decl.Deadline]; !ok {
deadlinesToLoad = append(deadlinesToLoad, decl.Deadline)