@@ -342,7 +342,7 @@ func New(
342342
343343 // Choose a leader for the new orderer instance.
344344 // TODO: Use the corresponding epoch's leader set to pick a leader, instead of just selecting one from all nodes.
345- leader := maputil .GetSortedKeys (membership .Nodes )[int (epoch )% len (membership .Nodes )]
345+ leader := maputil .GetSortedKeys (membership .Nodes )[int (epoch )% len (membership .Nodes )] //nolint:gosec
346346
347347 // Serialize checkpoint, so it can be proposed as a value.
348348 stableCheckpoint := checkpointpbtypes.StableCheckpoint {
@@ -408,7 +408,7 @@ func New(
408408 // that are not yet part of the system for those checkpoints.
409409 var delayed []stdtypes.NodeID
410410 for n := range membership .Nodes {
411- if epoch > iss .nodeEpochMap [n ]+ tt .EpochNr (iss .Params .RetainedEpochs ) {
411+ if epoch > iss .nodeEpochMap [n ]+ tt .EpochNr (iss .Params .RetainedEpochs ) { //nolint:gosec
412412 delayed = append (delayed , n )
413413 }
414414 }
@@ -438,7 +438,7 @@ func New(
438438
439439 sc := checkpoint .StableCheckpointFromPb (chkp .Pb ())
440440 // Check how far the received stable checkpoint is ahead of the local node's state.
441- chkpMembershipOffset := int ( sc .Epoch ()) - 1 - int ( iss .epoch .Nr () )
441+ chkpMembershipOffset := sc .Epoch () - tt . EpochNr ( 1 ) - iss .epoch .Nr ()
442442 if chkpMembershipOffset <= 0 {
443443 // Ignore stable checkpoints that are not far enough
444444 // ahead of the current state of the local node.
@@ -465,7 +465,7 @@ func New(
465465 }
466466
467467 chkp := checkpoint .StableCheckpointFromPb (c .checkpoint .Pb ())
468- chkpMembershipOffset := int ( chkp .Epoch ()) - 1 - int ( iss .epoch .Nr () )
468+ chkpMembershipOffset := chkp .Epoch () - tt . EpochNr ( 1 ) - iss .epoch .Nr ()
469469 if chkpMembershipOffset <= 0 {
470470 // Ignore stable checkpoints that have been lagged behind
471471 // during validation
@@ -564,7 +564,7 @@ func InitialStateSnapshot(
564564 return nil , err
565565 }
566566
567- firstEpochLength := uint64 (params .SegmentLength * len (params .InitialMembership .Nodes ))
567+ firstEpochLength := uint64 (params .SegmentLength * len (params .InitialMembership .Nodes )) //nolint:gosec
568568 return & trantorpbtypes.StateSnapshot {
569569 AppData : appState ,
570570 EpochData : & trantorpbtypes.EpochData {
@@ -624,7 +624,7 @@ func (iss *ISS) initAvailability() {
624624 (* multisigcollector .InstanceParams )(& mscpbtypes.InstanceParams {
625625 Epoch : iss .epoch .Nr (),
626626 Membership : iss .memberships [0 ],
627- MaxRequests : uint64 (iss .Params .SegmentLength ),
627+ MaxRequests : uint64 (iss .Params .SegmentLength ), //nolint:gosec
628628 }),
629629 stdtypes .RetentionIndex (iss .epoch .Nr ()),
630630 )
@@ -640,12 +640,12 @@ func (iss *ISS) initOrderers() error {
640640
641641 // Create segment.
642642 // The sequence proposals are all set to nil, so that the orderer proposes new availability certificates.
643- proposals := freeProposals (iss .nextDeliveredSN + tt .SeqNr (i ), tt .SeqNr (len (leaders )), iss .Params .SegmentLength )
643+ proposals := freeProposals (iss .nextDeliveredSN + tt .SeqNr (i ), tt .SeqNr (len (leaders )), iss .Params .SegmentLength ) //nolint:gosec
644644 seg , err := common .NewSegment (leader , iss .epoch .Membership , proposals )
645645 if err != nil {
646646 return es .Errorf ("error creating new segment: %w" , err )
647647 }
648- iss .newEpochSN += tt .SeqNr (seg .Len ())
648+ iss .newEpochSN += tt .SeqNr (seg .Len ()) //nolint:gosec
649649
650650 // Instantiate a new PBFT orderer.
651651 stddsl .NewSubmodule (iss .m , iss .moduleConfig .Ordering ,
@@ -792,7 +792,7 @@ func (iss *ISS) advanceEpoch() error {
792792 EpochConfig : & trantorpbtypes.EpochConfig { // nolint:govet
793793 iss .epoch .Nr (),
794794 iss .epoch .FirstSN (),
795- uint64 (iss .epoch .Len ()),
795+ uint64 (iss .epoch .Len ()), //nolint:gosec
796796 iss .memberships ,
797797 },
798798 },
@@ -904,8 +904,8 @@ func (iss *ISS) deliverCommonCheckpoint(chkpData []byte) error {
904904 // The state to prune is determined according to the retention index
905905 // which is derived from the epoch number the new
906906 // stable checkpoint is associated with.
907- pruneIndex := int ( chkp .Epoch ()) - iss .Params .RetainedEpochs
908- if pruneIndex > 0 { // "> 0" and not ">= 0", since only entries strictly smaller than the index are pruned.
907+ pruneIndex := chkp .Epoch () - tt . EpochNr ( iss .Params .RetainedEpochs ) //nolint:gosec
908+ if pruneIndex > 0 { // "> 0" and not ">= 0", since only entries strictly smaller than the index are pruned.
909909
910910 // Prune timer, checkpointing, availability, orderers, and other modules.
911911 stddsl .GarbageCollect (iss .m , iss .moduleConfig .Timer , stdtypes .RetentionIndex (pruneIndex ))
@@ -917,7 +917,7 @@ func (iss *ISS) deliverCommonCheckpoint(chkpData []byte) error {
917917
918918 // Prune epoch state.
919919 for epoch := range iss .epochs {
920- if epoch < tt . EpochNr ( pruneIndex ) {
920+ if epoch < pruneIndex {
921921 delete (iss .epochs , epoch )
922922 }
923923 }
@@ -931,7 +931,7 @@ func (iss *ISS) deliverCommonCheckpoint(chkpData []byte) error {
931931 // Note that we are not using the current epoch number here, because it is not relevant for checkpoints.
932932 // Using pruneIndex makes sure that the re-transmission is stopped
933933 // on every stable checkpoint (when another one is started).
934- stdtypes .RetentionIndex (pruneIndex ),
934+ stdtypes .RetentionIndex (pruneIndex ), //nolint:gosec
935935 isspbevents .PushCheckpoint (iss .moduleConfig .Self ).Pb (),
936936 )
937937
0 commit comments