// If a FullFault message includes a signature from the Audit server // which was nominated in the Fault, pledgedByAudit will return true func (s *State) pledgedByAudit(fullFault *messages.FullServerFault) bool { for _, a := range s.Authorities { if a.AuthorityChainID.IsSameAs(fullFault.AuditServerID) { marshalledSF, err := fullFault.MarshalForSF() if err == nil { for _, sig := range fullFault.SignatureList.List { sigVer, err := a.VerifySignature(marshalledSF, sig.GetSignature()) if err == nil && sigVer { return true } } } break } } return false }
// regularFullFaultExecution does the same thing as regularFaultExecution, except // it will make sure to add every signature from the FullFault to the corresponding // FaultState's VoteMap func (s *State) regularFullFaultExecution(sf *messages.FullServerFault, pl *ProcessList) { coreHash := sf.GetCoreHash().Fixed() for _, signature := range sf.SignatureList.List { var issuerID [32]byte rawIssuerID := signature.GetKey() for i := 0; i < 32; i++ { if i < len(rawIssuerID) { issuerID[i] = rawIssuerID[i] } } faultState := pl.GetFaultState(coreHash) if !faultState.IsNil() { // We already have a map entry } else { // We don't have a map entry yet; let's create one fcore := ExtractFaultCore(sf) faultState = FaultState{FaultCore: fcore, AmINegotiator: false, MyVoteTallied: false, VoteMap: make(map[[32]byte]interfaces.IFullSignature)} if isMyNegotiation(fcore, pl) { faultState.AmINegotiator = true pl.AmINegotiator = true } if faultState.VoteMap == nil { faultState.VoteMap = make(map[[32]byte]interfaces.IFullSignature) } pl.AddFaultState(coreHash, faultState) } if s.Leader || s.IdentityChainID.IsSameAs(sf.AuditServerID) { if !faultState.MyVoteTallied { nsf := messages.NewServerFault(sf.ServerID, sf.AuditServerID, int(sf.VMIndex), sf.DBHeight, sf.Height, int(sf.SystemHeight), sf.Timestamp) sfbytes, err := nsf.MarshalForSignature() myAuth, _ := s.GetAuthority(s.IdentityChainID) if myAuth == nil || err != nil { return } valid, err := myAuth.VerifySignature(sfbytes, signature.GetSignature()) if err == nil && valid { faultState.MyVoteTallied = true pl.AddFaultState(coreHash, faultState) } } } lbytes := sf.GetCoreHash().Bytes() isPledge := false auth, _ := s.GetAuthority(sf.AuditServerID) if auth == nil { isPledge = false } else { valid, err := auth.VerifySignature(lbytes, signature.GetSignature()) if err == nil && valid { isPledge = true faultState.PledgeDone = true pl.AddFaultState(coreHash, faultState) } } sfSigned, err := s.FastVerifyAuthoritySignature(lbytes, signature, sf.DBHeight) if err == nil && (sfSigned > 0 || (sfSigned == 0 && isPledge)) { faultState.VoteMap[issuerID] = sf.GetSignature() pl.AddFaultState(coreHash, faultState) } } faultState := pl.GetFaultState(coreHash) if !faultState.IsNil() { if s.Leader || s.IdentityChainID.IsSameAs(sf.AuditServerID) { if !faultState.MyVoteTallied { now := time.Now().Unix() if int(now-s.LastTiebreak) > s.FaultTimeout/2 { if faultState.SigTally(s) >= len(pl.FedServers)-1 { s.LastTiebreak = now } nsf := messages.NewServerFault(sf.ServerID, sf.AuditServerID, int(sf.VMIndex), sf.DBHeight, sf.Height, int(sf.SystemHeight), sf.Timestamp) s.matchFault(nsf) } } } } }