spacemeshos / go-spacemesh

Go Implementation of the Spacemesh protocol full node. 💾⏰💪
https://spacemesh.io
MIT License
770 stars 215 forks source link

tortoise: revert counted ballots and atxs after learning that identity is malicious #4620

Open dshulyak opened 1 year ago

dshulyak commented 1 year ago

this behavior was learned in https://github.com/spacemeshos/go-spacemesh/pull/4571

assume equal partition that lasts for long period of time, atleast one epoch. during this time equivocator submits distinct atxs and ballots on both side of the partition, so each side of the partition crosses same global threshold in terms of weight, but for different blocks. after recovery from a partition both sides will learn about equivocation. without discarding previously counted objects both sides will be on the different side of local threshold, that break self-healing property

the solution is to keep track of objects from a particular identity. when OnMalfeasance handler is called go over such objects that are in the window and discard them from counted weight.

note that it is more important to get https://github.com/spacemeshos/go-spacemesh/issues/4587 correctly first

dshulyak commented 9 months ago

this is actually not very clear how to do it efficiently, the brute force will scan all objects. but that would be very slow and will require keeping identities on every object. maybe it makes more sense to recount from disk. but what would be the criteria?