@@ -6464,9 +6464,7 @@ void Node::Validator::GenerateProposal()
64646464 rd.m_Proposal = std::move (m_FutureCandidate);
64656465 m_FutureCandidate.m_State = Proposal::State::None;
64666466
6467- Block::SystemState::Full s;
6468- MakeFullHdr (s, rd.m_Proposal .m_Msg .m_Hdr );
6469- rd.SetHashes (s);
6467+ rd.SetHashes ();
64706468 }
64716469 else
64726470 {
@@ -6709,7 +6707,7 @@ void Node::Validator::OnMsg(proto::PbftVote&& msg, const Peer& src)
67096707 if (!msg.m_Address .CheckSignature (pwr.m_hv , msg.m_Signature ))
67106708 src.ThrowUnexpected (" invalid validator sig" );
67116709
6712- if ((VoteKind::Commit == msg.m_iKind ) && (vp.m_hvCommitted != pwr .m_hv ))
6710+ if ((VoteKind::Commit == msg.m_iKind ) && (vp.m_hvCommitted != rd. m_Proposal .m_hv ))
67136711 {
67146712 if (vp.m_hvCommitted != Zero)
67156713 {
@@ -6846,6 +6844,8 @@ void Node::Validator::OnSigRequestReceived(uint32_t iR, const Peer* pSrc)
68466844
68476845 // 2nd phase: derive the challenges
68486846 ECC::Oracle oracle;
6847+ ms.m_SigAggregate .Expose (oracle, rd.m_Proposal .m_hv );
6848+
68496849 iIdx = 0 ;
68506850 for (auto & vp : m_ValidatorSet.m_mapValidators )
68516851 {
@@ -6961,7 +6961,8 @@ void Node::Validator::OnMsg(proto::PbftProposal&& msg, const Peer& src)
69616961
69626962 Block::SystemState::Full s;
69636963 MakeFullHdr (s, rd.m_Proposal .m_Msg .m_Hdr );
6964- rd.SetHashes (s);
6964+ s.get_Hash (rd.m_Proposal .m_hv );
6965+ rd.SetHashes ();
69656966
69666967 Merkle::Hash hv;
69676968 get_ProposalMsg (hv, rd);
@@ -6980,7 +6981,7 @@ void Node::Validator::OnMsg(proto::PbftProposal&& msg, const Peer& src)
69806981 }
69816982
69826983 HeightHash id;
6983- id.m_Hash = rd.m_pPwr [VoteKind::Commit] .m_hv ;
6984+ id.m_Hash = rd.m_Proposal .m_hv ;
69846985 id.m_Height = s.get_Height ();
69856986
69866987 if (!p.TestBlock (id, s, rd.m_Proposal .m_Msg .m_Body ))
@@ -7002,7 +7003,7 @@ void Node::Validator::OnProposalReceived(uint32_t iR, const Peer* pSrc)
70027003 auto & rd = m_pR[iR];
70037004 assert (Proposal::State::Received == rd.m_Proposal .m_State );
70047005
7005- PBFT_LOG (INFO, " proposal received " << rd.m_pPwr [VoteKind::Commit] .m_hv << " , iR=" << iR);
7006+ PBFT_LOG (INFO, " proposal received " << rd.m_Proposal .m_hv << " , iR=" << iR);
70067007 Broadcast (rd.m_Proposal .m_Msg , pSrc);
70077008}
70087009
@@ -7011,7 +7012,7 @@ void Node::Validator::get_ProposalMsg(Merkle::Hash& hv, const RoundData& rd) con
70117012 ECC::Hash::Processor ()
70127013 << m_hAnchor.v
70137014 << " pbft.propose.2"
7014- << rd.m_pPwr [VoteKind::Commit] .m_hv
7015+ << rd.m_Proposal .m_hv
70157016 << rd.m_Proposal .m_Msg .m_iRound
70167017 >> hv;
70177018}
@@ -7021,7 +7022,7 @@ void Node::Validator::get_SigRequestMsg(Merkle::Hash& hv, const RoundData& rd, c
70217022 ECC::Hash::Processor ()
70227023 << m_hAnchor.v
70237024 << " pbft.sigreq.2"
7024- << rd.m_pPwr [VoteKind::Commit] .m_hv
7025+ << rd.m_Proposal .m_hv
70257026 << msg.m_iRound
70267027 << msg.m_Mask .size ()
70277028 << Blob (msg.m_Mask )
@@ -7051,14 +7052,14 @@ void Node::Validator::MakeFullHdr(Block::SystemState::Full& s, const Block::Syst
70517052 Cast::Down<Block::SystemState::Sequence::Element>(s) = el;
70527053}
70537054
7054- void Node::Validator::RoundData::SetHashes (const Block::SystemState::Full& s )
7055+ void Node::Validator::RoundData::SetHashes ()
70557056{
7056- s. get_Hash ( m_pPwr[VoteKind::Commit]. m_hv );
7057-
7058- ECC::Hash::Processor ()
7059- << " pbft.vote.1 "
7060- << m_pPwr[VoteKind::Commit]. m_hv
7061- >> m_pPwr[VoteKind::PreVote ].m_hv ;
7057+ for ( uint32_t iKind = 0 ; iKind < _countof ( m_pPwr); iKind++)
7058+ ECC::Hash::Processor ()
7059+ << " pbft.vote.2.kind "
7060+ << m_Proposal. m_hv
7061+ << iKind
7062+ >> m_pPwr[iKind ].m_hv ;
70627063}
70637064
70647065void Node::Validator::CheckState (uint32_t iR)
@@ -7070,7 +7071,10 @@ void Node::Validator::CheckState(uint32_t iR)
70707071 CheckStateCurrent ();
70717072
70727073 auto & rd = m_pR[iR];
7073- if (!rd.m_Multisig || rd.m_Multisig ->m_SigsRemaining )
7074+ if (!rd.m_Multisig )
7075+ return ;
7076+ auto & ms = *rd.m_Multisig ;
7077+ if (ms.m_SigsRemaining )
70747078 return ;
70757079
70767080 // We have the quorum
@@ -7079,23 +7083,8 @@ void Node::Validator::CheckState(uint32_t iR)
70797083
70807084 Block::Pbft::Quorum qc;
70817085 const Rules& r = Rules::get ();
7082-
7083- uint32_t iIdx = 0 ;
7084- for (const auto & v : m_ValidatorSet.m_mapValidators )
7085- {
7086- const auto & sig = v.m_pR [iR].m_pVote [VoteKind::Commit];
7087- if (sig)
7088- {
7089- qc.m_vSigs .push_back (*sig);
7090-
7091- uint32_t iByte = iIdx >> 3 ;
7092- if (qc.m_vValidatorsMsk .size () <= iByte)
7093- qc.m_vValidatorsMsk .resize (iByte + 1 );
7094- qc.m_vValidatorsMsk [iByte] |= (1 << (7 & iIdx));
7095- }
7096-
7097- iIdx++;
7098- }
7086+ qc.m_vValidatorsMsk = ms.m_Msg .m_Mask ; // copy
7087+ qc.m_Signature = ms.m_SigAggregate ;
70997088
71007089 Block::SystemState::Full s;
71017090 MakeFullHdr (s, rd.m_Proposal .m_Msg .m_Hdr );
@@ -7118,7 +7107,7 @@ void Node::Validator::CheckState(uint32_t iR)
71187107 ser.swap_buf (m_Stamp.m_vSer );
71197108
71207109 m_Stamp.m_ID .m_Height = s.get_Height ();
7121- m_Stamp.m_ID .m_Hash = rd.m_pPwr [VoteKind::Commit] .m_hv ;
7110+ m_Stamp.m_ID .m_Hash = rd.m_Proposal .m_hv ;
71227111
71237112 SaveStamp ();
71247113 }
@@ -7149,7 +7138,7 @@ void Node::Validator::CheckState(uint32_t iR)
71497138
71507139 Block::SystemState::ID id;
71517140 id.m_Number = s.m_Number ;
7152- id.m_Hash = rd.m_pPwr [VoteKind::Commit] .m_hv ;
7141+ id.m_Hash = rd.m_Proposal .m_hv ;
71537142
71547143 eVal = p.OnBlock (id, rd.m_Proposal .m_Msg .m_Body .m_Perishable , rd.m_Proposal .m_Msg .m_Body .m_Eternal , Zero);
71557144
@@ -7191,7 +7180,7 @@ void Node::Validator::CheckStateCurrent()
71917180 OnProposalReceived (iR, nullptr );
71927181 }
71937182
7194- bool bAlreadyCommitted = (m_pMe->m_hvCommitted == rd.m_pPwr [VoteKind::Commit] .m_hv );
7183+ bool bAlreadyCommitted = (m_pMe->m_hvCommitted == rd.m_Proposal .m_hv );
71957184 if (!bAlreadyCommitted && !ShouldAcceptProposal ())
71967185 return ;
71977186
@@ -7215,7 +7204,7 @@ void Node::Validator::CheckStateCurrent()
72157204
72167205 PBFT_LOG (INFO, " committed" );
72177206 m_State = State::Committed;
7218- m_pMe->m_hvCommitted = rd.m_pPwr [VoteKind::Commit] .m_hv ;
7207+ m_pMe->m_hvCommitted = rd.m_Proposal .m_hv ;
72197208 }
72207209
72217210 if (!rd.m_pPwr [VoteKind::Commit].IsMajorityReached (m_wTotal))
@@ -7433,9 +7422,10 @@ bool Node::Validator::CreateProposal()
74337422 if (bRes)
74347423 {
74357424 auto & rdcurr = m_pR[0 ];
7436- rdcurr. SetHashes ( bc.m_Hdr );
7425+ bc.m_Hdr . get_Hash (rdcurr. m_Proposal . m_hv );
74377426 rdcurr.m_Proposal .m_Msg .m_Hdr = std::move (bc.m_Hdr );
74387427 rdcurr.m_Proposal .m_Msg .m_Body = std::move (bc.m_Body );
7428+ rdcurr.SetHashes ();
74397429 }
74407430
74417431 return bRes;
0 commit comments