-
Notifications
You must be signed in to change notification settings - Fork 92
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
Anti Header Spam v2 #656
Anti Header Spam v2 #656
Conversation
A new build of cfcbfaa has completed succesfully! |
utACK.
I've just read the issue details and skimmed over the code changes.
Will test once I get some time tomorrow.
…On Fri, Dec 27, 2019, 03:36 navbuilder ***@***.***> wrote:
A new build of cfcbfaa
<cfcbfaa>
has completed succesfully!
Binaries available at
https://build.nav.community/binaries/antiheaderspam_v2
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#656?email_source=notifications&email_token=AAIDAKPI7C46I7AUAPYMAKTQ2UBVRA5CNFSM4J7NSHW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHWBUUQ#issuecomment-569121362>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIDAKI7U7GXUFJBIF3ONXTQ2UBVRANCNFSM4J7NSHWQ>
.
|
A new build of b98b4c5 has completed succesfully! |
src/main.cpp
Outdated
@@ -422,6 +391,7 @@ struct CNodeState { | |||
nStallingSince = 0; | |||
nDownloadingSince = 0; | |||
nBlocksInFlight = 0; | |||
nHeadersInFlight = 0; |
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.
it doesn't seem like this parameter is ever used?
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.
yes, its left from some code idea i was sketching. ill remove it, good eye
tested with ubuntu 18.04 (local build) syncing from scrach: giving me an error message and the wallet closed. terminate called after throwing an instance of 'std::ios_base::failure[abi:cxx11]' the debug log looks like it was just syncing except for the last line 2019-12-27 05:05:41 UpdateTip: new best=b95e7593fe09f65ac78a2f57dc2303a809061144fa926a45f9a18576e1dbd17a height=3768909 version=0x7135e1ff log2_work=73.214486 tx=7842332 date='2019-12-27 03:50:08' progress=0.999903 cache=163.5MiB(727363tx) My windows node (running gitian build) is runing normally. synced up to tip from a week behind and then bootstrapped to two days ago and synced up to tip as expected. |
Tested on windows 10 64bit ( Gitian build b98b4c5 ) I was able to fully sync 1 week behind. I've just cleared the datadir and trying a full sync from genesis. |
A new build of 78af416 has completed succesfully! |
Tested gitian build 78af416 Synced fully from 3 days behind on testnet. |
@@ -7328,6 +7300,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, | |||
break; | |||
} | |||
} | |||
vHeaderHashes.push_back(pblockheader.GetHash()); |
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.
is there ever a situation where this loop never runs and the vector is never populated? what effect would that have?
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.
the hash is only added if AcceptBlockHeader returns true, which means the header has been inserted in mapBlockIndex
built locally on OSX using the depends directory. Synced from scratch without issue. trying to sync from within the spam filter activation range using the bootstrap now. |
I synced this client from 18 hours behind without issue. What is the status of this PR? Any known issues? @chasingkirkjufell @mxaddict @aguycalled |
I have found a potential bug with qt creator and aguycalled said he was looking into it. The potential bug is causing my nodes to fail to sync from genesis with qt wallet. I have only been able to reproduce it on my Ubuntu 19.04 node and not on windows. |
A new build of a3cf89c has completed succesfully! |
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.
Tested
headless on Ubuntu 19.04 and 18.10 with local builds.
Qt wallet local builds on 19.04 and 18.10.
Qt wallet gitian build on Windows.
Syncing from genesis completed without error. for 19.04 and 18.10 with local builds on QT and headless wallets.
Syncing from within a day behind worked without issue for 19.04, 18.10, and Windows
Tested Patching and spamming normal nodes, normal nodes were able to block spamming nodes.
This Pull Request proposes a new anti header spam system which aims to fix some of the issues of the previous implementation (including those reported by art-of-bug).
Features:
points
list associated with the peer.points
list. This can be changed with-headerspamfilterignoreport
(default:true
).points
list will be cleared removing all the hashes of blocks whose scripts have already been correctly validated.points
list is greater thanMAX_HEADERS_RESULTS*2
once cleared of already validated blocks.points
list can be changed using the-headerspamfiltermaxsize
parameter.headerspam
has been added, which prints to the log the current size of a peerspoints
list.-debug=bench
is specified, execution time for theupdateState
function is logged.Considerations
points
list by default is 4,000. With a block time of 30 seconds, NavCoin sees an average of 2,880 blocks per day. A maximum value of 4000 is roughly one and a half times more than the count of blocks a peer needs to be behind the chain tip to be in Initial Block Download mode. When on IBD, the header spam filter is turned off. This ensures that normal synchronisation is not affected by this filter.points
list + 181 bytes from theCBlockIndex
inserted inmapBlockIndex
for every invalid header/block before being banned. Thepoints
list is cleared when the attacker is banned, but those headers are not removed frommapBlockIndex
or the hard disk in the current implementation. The size of CBlockIndex has been measured with:3,999*213=831 kilobytes
without being banned or4,000*181=707 kilobytes
being banned.What to test
Then build and start one node and bootstrap a devnet chain with:
Now start the spammer node with:
We should be able to see in node1 log output how it tries to ban node2 after the spam: