diff --git a/rpc/rpc_server.go b/rpc/rpc_server.go index ef4c5b3..0f45c74 100644 --- a/rpc/rpc_server.go +++ b/rpc/rpc_server.go @@ -271,7 +271,6 @@ func (s *Server) GetQuorumTickData(ctx context.Context, req *protobuff.GetQuorum nextTick := req.TickNumber + 1 - //Get quorum data for next tick nextTickQuorumData, err := s.store.GetQuorumTickDataV2(ctx, nextTick) if err != nil { if errors.Is(err, store.ErrNotFound) { @@ -280,7 +279,6 @@ func (s *Server) GetQuorumTickData(ctx context.Context, req *protobuff.GetQuorum return nil, status.Errorf(codes.Internal, "getting tick data: %v", err) } - //Get quorum data for current tick currentTickQuorumData, err := s.store.GetQuorumTickDataV2(ctx, req.TickNumber) if err != nil { if errors.Is(err, store.ErrNotFound) { @@ -289,7 +287,6 @@ func (s *Server) GetQuorumTickData(ctx context.Context, req *protobuff.GetQuorum return nil, status.Errorf(codes.Internal, "getting tick data: %v", err) } - //Get computors computors, err := s.store.GetComputors(ctx, currentTickQuorumData.QuorumTickStructure.Epoch) if err != nil { return nil, status.Errorf(codes.Internal, "getting computor list") @@ -300,12 +297,9 @@ func (s *Server) GetQuorumTickData(ctx context.Context, req *protobuff.GetQuorum return nil, status.Errorf(codes.Internal, "reconstructing quorum data: %v", err) } - //Response object - res := protobuff.GetQuorumTickDataResponse{ + return &protobuff.GetQuorumTickDataResponse{ QuorumTickData: reconstructedQuorumData, - } - - return &res, nil + }, nil } func (s *Server) GetComputors(ctx context.Context, req *protobuff.GetComputorsRequest) (*protobuff.GetComputorsResponse, error) { computors, err := s.store.GetComputors(ctx, req.Epoch) diff --git a/validator/quorum/models.go b/validator/quorum/models.go index bfd3bd2..725da5d 100644 --- a/validator/quorum/models.go +++ b/validator/quorum/models.go @@ -88,7 +88,6 @@ func ReconstructQuorumData(currentTickQuorumData, nextTickQuorumData *protobuff. QuorumDiffPerComputor: make(map[uint32]*protobuff.QuorumDiff), } - //Digests spectrumDigest, err := hex.DecodeString(nextTickQuorumData.QuorumTickStructure.PrevSpectrumDigestHex) if err != nil { return nil, errors.Wrap(err, "obtaining spectrum digest from next tick quorum data") @@ -106,7 +105,6 @@ func ReconstructQuorumData(currentTickQuorumData, nextTickQuorumData *protobuff. return nil, errors.Wrap(err, "obtaining resource testing digest from next tick quorum data") } - //Loop over all computors in current tick data for id, voteDiff := range currentTickQuorumData.QuorumDiffPerComputor { identity := types.Identity(computors.Identities[id]) @@ -117,39 +115,34 @@ func ReconstructQuorumData(currentTickQuorumData, nextTickQuorumData *protobuff. } var tmp [64]byte - copy(tmp[:32], computorPublicKey[:]) // Public key as the first part + copy(tmp[:32], computorPublicKey[:]) - //Salted spectrum digest copy(tmp[32:], spectrumDigest[:]) saltedSpectrumDigest, err := utils.K12Hash(tmp[:]) if err != nil { return nil, errors.Wrap(err, "hashing salted spectrum digest") } - //Salted universe digest copy(tmp[32:], universeDigest[:]) saltedUniverseDigest, err := utils.K12Hash(tmp[:]) if err != nil { return nil, errors.Wrap(err, "hashing salted universe digest") } - //Salted computer digest copy(tmp[32:], computerDigest[:]) saltedComputerDigest, err := utils.K12Hash(tmp[:]) if err != nil { return nil, errors.Wrap(err, "hashing salted computer digest") } - //Salted resource digest var tmp2 [40]byte - copy(tmp2[:32], computorPublicKey[:]) // Public key as the first part + copy(tmp2[:32], computorPublicKey[:]) copy(tmp2[32:], resourceDigest[:]) saltedResourceTestingDigest, err := utils.K12Hash(tmp2[:]) if err != nil { return nil, errors.Wrap(err, "hashing salted resource testing digest") } - //Add reconstructed object to response reconstructedQuorumData.QuorumDiffPerComputor[id] = &protobuff.QuorumDiff{ SaltedResourceTestingDigestHex: hex.EncodeToString(saltedResourceTestingDigest[:8]), SaltedSpectrumDigestHex: hex.EncodeToString(saltedSpectrumDigest[:]),