-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
block validate height #4091
block validate height #4091
Conversation
Hey @zgfzgf, thanks for submitting this. Could you add a test case that triggers this please? Or explain what would be the code flow that leads to this case? We normally check that the incoming blocks are in decreasing order when fetching the chain so one block always has a higher height than its parent. If we were to receive a block with a lower height that the heaviest one we have then that would mean a possible fork that would trigger a different logic ( |
When I was learning mining synchronization code, I found no place to verify block height information So I changed some of the code (keeping the height unchanged) as an attack node Attack nodes can synchronize blocks to normal nodes. The normal node is compiled by GitHub source code Therefore, it is better to increase block height verification, and at the same time, it is better to increase the judgment of height in mining code. Now, it mainly verifies weight |
hello @schomatis If you don't quite understand what I mean, I'll submit the modified code to implement the attack node |
https://github.com/zgfzgf/lotus/tree/height-unchanged As shown above
Of course, there are other attack programs |
Hey @zgfzgf, thanks for the information. I understand and agree with what you're saying, what I was trying to say in #4091 (comment) is that I think that change only affects the miner who generated the fake block, other nodes will verify the height difference and reject it. If you have observed otherwise please let me know. |
As a demonstration of what I'm saying, try to rebase your commit zgfzgf@3f1cfa0 on top of #4192 (which removes the bypass of the checks for the miner that produces the block) to see if you can reproduce the error. |
@schomatis The normal node accept it |
other nodes accept it |
Lines 1385 to 1388 in 8f35a5c
Node Online Block by block synchronization repeat the test |
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.
Would prefer the check phrased as if h.Height <= baseTs.Height...
, but this LGTM.
fix #4090
Node evil
lotus chain list
... ...
7: (Sep 29 15:26:54) [ bafy2bzaceaphw3y7mv557lhpf2k3wmmbnfvr52r7zsc2qogitokfafpxq6jnw: t01000, ]
8: (Sep 29 15:26:58) [ bafy2bzaced577iipshzvvwpyn2kmpaqo3jrjxrkfauylq7wavhrqpkwdnu5e4: t01000, ]
9: (Sep 29 15:27:02) [ bafy2bzacecvw64pu527dh7554chhid2bmklffefvxu77dklt4aafgdghwm45i: t01000, ]
10: (Sep 29 15:27:06) [ bafy2bzacebscylcsnsecx7ct2ivzr6wkzd732o6tmdmukmtyf6xb7ewlxy63k: t01000, ]
10: (Sep 29 15:27:06) [ bafy2bzacebyt52vq3nqoo4pbd2xovdwutojqtthqtefbwemmmezbm4csvjlhk: t01000, ]
10: (Sep 29 15:27:06) [ bafy2bzacecgf3sfhjylbe7jp6n47jes7xb67clpeuj6im5rfevg6szsl2vkni: t01000, ]
Normal node
lotus chain list
... ...
7: (Sep 29 15:26:54) [ bafy2bzaceaphw3y7mv557lhpf2k3wmmbnfvr52r7zsc2qogitokfafpxq6jnw: t01000, ]
8: (Sep 29 15:26:58) [ bafy2bzaced577iipshzvvwpyn2kmpaqo3jrjxrkfauylq7wavhrqpkwdnu5e4: t01000, ]
9: (Sep 29 15:27:02) [ bafy2bzacecvw64pu527dh7554chhid2bmklffefvxu77dklt4aafgdghwm45i: t01000, ]
10: (Sep 29 15:27:06) [ bafy2bzacebscylcsnsecx7ct2ivzr6wkzd732o6tmdmukmtyf6xb7ewlxy63k: t01000, ]