-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: partial bitcoin#25717, #25963 - anti-dos header sync #7514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,7 +222,7 @@ bool BaseIndex::Commit() | |
| CDBBatch batch(GetDB()); | ||
| ok = CustomCommit(batch); | ||
| if (ok) { | ||
| GetDB().WriteBestBlock(batch, GetLocator(*m_chain, m_best_block_index.load()->GetBlockHash())); | ||
| GetDB().WriteBestBlock(batch, GetLocator(m_best_block_index)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. upstream pr doesn't touch this file:: |
||
| ok = GetDB().WriteBatch(batch); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3054,7 +3054,7 @@ void PeerManagerImpl::HandleFewUnconnectingHeaders(CNode& pfrom, Peer& peer, | |
| nodestate->nUnconnectingHeaders++; | ||
| // Try to fill in the missing headers. | ||
| std::string msg_type = UsesCompressedHeaders(peer) ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS; | ||
| if (MaybeSendGetHeaders(pfrom, msg_type, m_chainman.ActiveChain().GetLocator(m_chainman.m_best_header), peer)) { | ||
| if (MaybeSendGetHeaders(pfrom, msg_type, GetLocator(m_chainman.m_best_header), peer)) { | ||
| LogPrint(BCLog::NET, "received header %s: missing prev block %s, sending %s (%d) to end (peer=%d, nUnconnectingHeaders=%d)\n", | ||
| headers[0].GetHash().ToString(), | ||
| headers[0].hashPrevBlock.ToString(), | ||
|
|
@@ -3281,7 +3281,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer, | |
| const std::string msg_type = uses_compressed ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS; | ||
| if (nCount == GetHeadersLimit(pfrom, uses_compressed)) { | ||
| // Headers message had its maximum size; the peer may have more headers. | ||
| if (MaybeSendGetHeaders(pfrom, msg_type, WITH_LOCK(m_chainman.GetMutex(), return m_chainman.ActiveChain().GetLocator(pindexLast)), peer)) { | ||
| if (MaybeSendGetHeaders(pfrom, msg_type, GetLocator(pindexLast), peer)) { | ||
| LogPrint(BCLog::NET, "more %s (%d) to end to peer=%d (startheight:%d)\n", | ||
| msg_type, pindexLast->nHeight, pfrom.GetId(), peer.m_starting_height); | ||
| } | ||
|
|
@@ -4451,7 +4451,7 @@ void PeerManagerImpl::ProcessMessage( | |
| CNodeState& state{*Assert(State(pfrom.GetId()))}; | ||
| if (state.fSyncStarted || (!peer->m_inv_triggered_getheaders_before_sync && *best_block != m_last_block_inv_triggering_headers_sync)) { | ||
| std::string msg_type = UsesCompressedHeaders(*peer) ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS; | ||
| if (MaybeSendGetHeaders(pfrom, msg_type, m_chainman.ActiveChain().GetLocator(m_chainman.m_best_header), *peer)) { | ||
| if (MaybeSendGetHeaders(pfrom, msg_type, GetLocator(m_chainman.m_best_header), *peer)) { | ||
| LogPrint(BCLog::NET, "%s (%d) %s to peer=%d\n", | ||
| msg_type, m_chainman.m_best_header->nHeight, best_block->ToString(), | ||
| pfrom.GetId()); | ||
|
|
@@ -4914,7 +4914,7 @@ void PeerManagerImpl::ProcessMessage( | |
| // Doesn't connect (or is genesis), instead of DoSing in AcceptBlockHeader, request deeper headers | ||
| if (!m_chainman.ActiveChainstate().IsInitialBlockDownload()) { | ||
| std::string ret_val = UsesCompressedHeaders(*peer) ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS; | ||
| MaybeSendGetHeaders(pfrom, ret_val, m_chainman.ActiveChain().GetLocator(m_chainman.m_best_header), *peer); | ||
| MaybeSendGetHeaders(pfrom, ret_val, GetLocator(m_chainman.m_best_header), *peer); | ||
| } | ||
| return; | ||
| } | ||
|
|
@@ -5810,7 +5810,7 @@ void PeerManagerImpl::ConsiderEviction(CNode& pto, Peer& peer, std::chrono::seco | |
| // still respond to us with a sufficiently high work chain tip. | ||
| std::string msg_type = UsesCompressedHeaders(peer) ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS; | ||
| MaybeSendGetHeaders(pto, | ||
| msg_type, m_chainman.ActiveChain().GetLocator(state.m_chain_sync.m_work_header->pprev), | ||
| msg_type, GetLocator(state.m_chain_sync.m_work_header->pprev), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| peer); | ||
| LogPrint(BCLog::NET, "sending %s to outbound peer=%d to verify chain work (current best known block:%s, benchmark blockhash: %s)\n", msg_type, pto.GetId(), state.pindexBestKnownBlock != nullptr ? state.pindexBestKnownBlock->GetBlockHash().ToString() : "<none>", state.m_chain_sync.m_work_header->GetBlockHash().ToString()); | ||
| state.m_chain_sync.m_sent_getheaders = true; | ||
|
|
@@ -6201,7 +6201,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) | |
| if (pindexStart->pprev) | ||
| pindexStart = pindexStart->pprev; | ||
| std::string msg_type = UsesCompressedHeaders(*peer) ? NetMsgType::GETHEADERS2 : NetMsgType::GETHEADERS; | ||
| if (MaybeSendGetHeaders(*pto, msg_type, m_chainman.ActiveChain().GetLocator(pindexStart), *peer)) { | ||
| if (MaybeSendGetHeaders(*pto, msg_type, GetLocator(pindexStart), *peer)) { | ||
| LogPrint(BCLog::NET, "initial %s (%d) to peer=%d (startheight:%d)\n", msg_type, pindexStart->nHeight, pto->GetId(), peer->m_starting_height); | ||
|
|
||
| state.fSyncStarted = true; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the
CChain::GetLocator(const CBlockIndex*)overload here leavessrc/node/interfaces.cpp:1087still callingactive.GetLocator(index), so any build ofChainImpl::findBlock(...FoundBlock().locator(...))fails with no matching member function instead of using the new freeGetLocator(index). The backport guidance specifically warns to resolve these API conflicts rather than only matching upstream shape.AGENTS.md reference: AGENTS.md:L153-L155
Useful? React with 👍 / 👎.