CodeChain-io / foundry

A programmable open source blockchain engine
GNU General Public License v3.0
38 stars 12 forks source link

Do not download invalid block's children #48

Open majecty opened 5 years ago

majecty commented 5 years ago

A CodeChain node downloads child blocks of an invalid block. Since the parent block is invalid, verifying the child blocks always fails.

majecty commented 4 years ago

We may block the peer for a few hours.

Go Ethereum discussed a similar issue. https://github.com/ethereum/go-ethereum/issues/17935

majecty commented 4 years ago

I discussed this issue with @kseo before. @HoOngEe @joojis @Remagpie @sgkim126 What do you think about banning a peer that sent an invalid block for a hour? We may expose the ban time through configuration.

Bitcoin Satoshi client bans IP addresses that misbehave for 24 hours.(link)

majecty commented 4 years ago

I want to add the "Good first issue" label in this issue after deciding the policy.

sgkim126 commented 4 years ago

@majecty I agree on the policy, but I'm not sure blocking one hour is easy to implement.

remagpie commented 4 years ago

I think it's good enough. Are we going to handle only the peers that sent an invalid block? or are we going to handle other misbehaviors(e.g. too late response) too?

majecty commented 4 years ago

@sgkim126 I considered adding duration in the blacklist that is used in the network code. Since we already have the blacklist feature, I thought that adding duration in the list is not that hard.

@Remagpie I intend to ban only the peers that sent invalid blocks. We may ban other peers who do different misbehaviors later.

sgkim126 commented 4 years ago

Okay. Let's try it.

remagpie commented 4 years ago

@sgkim126 I remember you had some plan about "scoring" the peers for managing the connections. Is that still valid? and would it be related to this issue?

sgkim126 commented 4 years ago

@Remagpie Yes, I still had, but it needs some more discussion yet. I think timed-blocking would work well for now.