@@ -620,6 +620,7 @@ func SectorsExtendCmd(getActorAddress ActorAddressGetter) *cli.Command {
620
620
& cli.Int64Flag {
621
621
Name : "max-sectors" ,
622
622
Usage : "the maximum number of sectors contained in each message" ,
623
+ Value : 500 ,
623
624
},
624
625
& cli.BoolFlag {
625
626
Name : "really-do-it" ,
@@ -876,84 +877,97 @@ func SectorsExtendCmd(getActorAddress ActorAddressGetter) *cli.Command {
876
877
877
878
for l , exts := range extensions {
878
879
for newExp , numbers := range exts {
879
- sectorsWithoutClaimsToExtend := bitfield .New ()
880
- numbersToExtend := make ([]abi.SectorNumber , 0 , len (numbers ))
881
- var sectorsWithClaims []miner.SectorClaim
882
- for _ , sectorNumber := range numbers {
883
- claimIdsToMaintain := make ([]verifreg.ClaimId , 0 )
884
- claimIdsToDrop := make ([]verifreg.ClaimId , 0 )
885
- cannotExtendSector := false
886
- claimIds , ok := claimIdsBySector [sectorNumber ]
887
- // Nothing to check, add to ccSectors
888
- if ! ok {
889
- sectorsWithoutClaimsToExtend .Set (uint64 (sectorNumber ))
890
- numbersToExtend = append (numbersToExtend , sectorNumber )
891
- } else {
892
- for _ , claimId := range claimIds {
893
- claim , ok := claimsMap [claimId ]
894
- if ! ok {
895
- return xerrors .Errorf ("failed to find claim for claimId %d" , claimId )
896
- }
897
- claimExpiration := claim .TermStart + claim .TermMax
898
- // can be maintained in the extended sector
899
- if claimExpiration > newExp {
900
- claimIdsToMaintain = append (claimIdsToMaintain , claimId )
901
- } else {
902
- sectorInfo , ok := activeSectorsInfo [sectorNumber ]
880
+ batchSize := addrSectors
881
+
882
+ // The unfortunate thing about this approach is that batches less than batchSize in different partitions cannot be aggregated together to send messages.
883
+ for i := 0 ; i < len (numbers ); i += batchSize {
884
+ end := i + batchSize
885
+ if end > len (numbers ) {
886
+ end = len (numbers )
887
+ }
888
+
889
+ batch := numbers [i :end ]
890
+
891
+ sectorsWithoutClaimsToExtend := bitfield .New ()
892
+ numbersToExtend := make ([]abi.SectorNumber , 0 , len (numbers ))
893
+ var sectorsWithClaims []miner.SectorClaim
894
+
895
+ for _ , sectorNumber := range batch {
896
+ claimIdsToMaintain := make ([]verifreg.ClaimId , 0 )
897
+ claimIdsToDrop := make ([]verifreg.ClaimId , 0 )
898
+ cannotExtendSector := false
899
+ claimIds , ok := claimIdsBySector [sectorNumber ]
900
+ // Nothing to check, add to ccSectors
901
+ if ! ok {
902
+ sectorsWithoutClaimsToExtend .Set (uint64 (sectorNumber ))
903
+ numbersToExtend = append (numbersToExtend , sectorNumber )
904
+ } else {
905
+ for _ , claimId := range claimIds {
906
+ claim , ok := claimsMap [claimId ]
903
907
if ! ok {
904
- return xerrors .Errorf ("failed to find sector in active sector set: %w " , err )
908
+ return xerrors .Errorf ("failed to find claim for claimId %d " , claimId )
905
909
}
906
- if ! cctx .Bool ("drop-claims" ) ||
907
- // FIP-0045 requires the claim minimum duration to have passed
908
- currEpoch <= (claim .TermStart + claim .TermMin ) ||
909
- // FIP-0045 requires the sector to be in its last 30 days of life
910
- (currEpoch <= sectorInfo .Expiration - builtin .EndOfLifeClaimDropPeriod ) {
911
- fmt .Printf ("skipping sector %d because claim %d (client f0%s, piece %s) does not live long enough \n " , sectorNumber , claimId , claim .Client , claim .Data )
912
- cannotExtendSector = true
913
- break
910
+ claimExpiration := claim .TermStart + claim .TermMax
911
+ // can be maintained in the extended sector
912
+ if claimExpiration > newExp {
913
+ claimIdsToMaintain = append (claimIdsToMaintain , claimId )
914
+ } else {
915
+ sectorInfo , ok := activeSectorsInfo [sectorNumber ]
916
+ if ! ok {
917
+ return xerrors .Errorf ("failed to find sector in active sector set: %w" , err )
918
+ }
919
+ if ! cctx .Bool ("drop-claims" ) ||
920
+ // FIP-0045 requires the claim minimum duration to have passed
921
+ currEpoch <= (claim .TermStart + claim .TermMin ) ||
922
+ // FIP-0045 requires the sector to be in its last 30 days of life
923
+ (currEpoch <= sectorInfo .Expiration - builtin .EndOfLifeClaimDropPeriod ) {
924
+ fmt .Printf ("skipping sector %d because claim %d (client f0%s, piece %s) does not live long enough \n " , sectorNumber , claimId , claim .Client , claim .Data )
925
+ cannotExtendSector = true
926
+ break
927
+ }
928
+
929
+ claimIdsToDrop = append (claimIdsToDrop , claimId )
914
930
}
915
931
916
- claimIdsToDrop = append (claimIdsToDrop , claimId )
932
+ numbersToExtend = append (numbersToExtend , sectorNumber )
933
+ }
934
+ if cannotExtendSector {
935
+ continue
917
936
}
918
937
919
- numbersToExtend = append (numbersToExtend , sectorNumber )
920
- }
921
- if cannotExtendSector {
922
- continue
938
+ if len (claimIdsToMaintain )+ len (claimIdsToDrop ) != 0 {
939
+ sectorsWithClaims = append (sectorsWithClaims , miner.SectorClaim {
940
+ SectorNumber : sectorNumber ,
941
+ MaintainClaims : claimIdsToMaintain ,
942
+ DropClaims : claimIdsToDrop ,
943
+ })
944
+ }
923
945
}
946
+ }
924
947
925
- if len (claimIdsToMaintain )+ len (claimIdsToDrop ) != 0 {
926
- sectorsWithClaims = append (sectorsWithClaims , miner.SectorClaim {
927
- SectorNumber : sectorNumber ,
928
- MaintainClaims : claimIdsToMaintain ,
929
- DropClaims : claimIdsToDrop ,
930
- })
931
- }
948
+ sectorsWithoutClaimsCount , err := sectorsWithoutClaimsToExtend .Count ()
949
+ if err != nil {
950
+ return xerrors .Errorf ("failed to count cc sectors: %w" , err )
932
951
}
933
- }
934
952
935
- sectorsWithoutClaimsCount , err := sectorsWithoutClaimsToExtend .Count ()
936
- if err != nil {
937
- return xerrors .Errorf ("failed to count cc sectors: %w" , err )
938
- }
953
+ sectorsInDecl := int (sectorsWithoutClaimsCount ) + len (sectorsWithClaims )
954
+ scount += sectorsInDecl
939
955
940
- sectorsInDecl := int (sectorsWithoutClaimsCount ) + len (sectorsWithClaims )
941
- scount += sectorsInDecl
956
+ if scount > addrSectors || len (p .Extensions ) >= declMax {
957
+ params = append (params , p )
958
+ p = miner.ExtendSectorExpiration2Params {}
959
+ scount = sectorsInDecl
960
+ }
942
961
943
- if scount > addrSectors || len (p .Extensions ) >= declMax {
944
- params = append (params , p )
945
- p = miner.ExtendSectorExpiration2Params {}
946
- scount = sectorsInDecl
962
+ p .Extensions = append (p .Extensions , miner.ExpirationExtension2 {
963
+ Deadline : l .Deadline ,
964
+ Partition : l .Partition ,
965
+ Sectors : SectorNumsToBitfield (numbersToExtend ),
966
+ SectorsWithClaims : sectorsWithClaims ,
967
+ NewExpiration : newExp ,
968
+ })
947
969
}
948
970
949
- p .Extensions = append (p .Extensions , miner.ExpirationExtension2 {
950
- Deadline : l .Deadline ,
951
- Partition : l .Partition ,
952
- Sectors : SectorNumsToBitfield (numbersToExtend ),
953
- SectorsWithClaims : sectorsWithClaims ,
954
- NewExpiration : newExp ,
955
- })
956
-
957
971
}
958
972
}
959
973
0 commit comments