Closed nodiesBlade closed 1 year ago
Added all the comments as suggested! Thanks for the review.
In regards to the tests, I haven't made any progress to them - don't think I will have the bandwidth moving forward to diagnose / fix the integration tests. The changes here are minimal and only guard rails for proof tx, not consensus. If needed, we can push an additional hot fix without the need for consensus upgrades.
I'm handing it off as is. The PR is already merged into Poktscan's fork.
Since I don't have time to dedicate more to this issue, please cherry pick or fork my changes and move forward.
Closing since it won't be merged in / blocked.
@Olshansk all the request you ask about test are not fair to be handle by the community people trying to help if pocket has people that get a salary for this. This is why then people hesitate to help on the project. I think u guys may need to figure out a way to work on v0 because has a lot of things that are not working and should be working like TESTs and that is pocket responsibility, not the community indeed.
@Olshansk all the request you ask about test are not fair to be handle by the community people trying to help if pocket has people that get a salary for this. This is why then people hesitate to help on the project. I think u guys may need to figure out a way to work on v0 because has a lot of things that are not working and should be working like TESTs and that is pocket responsibility, not the community indeed.
Thanks for the feedback.
I will work on adding the tests myself this time and reach out about getting a budget for it in the future.
Description
Whenever the evidence does not match the total proofs, the node tries to delete the evidence and submits a claim. It should never submit a proof whenever there is LESS than the number of relay proofs as that can cause an array index of out-bounds exception if the randomly selected index is more than what we have in the store. This can cause a node crash.
Example: Servicer starts off with 10 relays in the evidence store
Solution: If the number of relay proofs in the evidence store is less than the submitted claims total relay proofs then delete the evidence and don't submit a proof.
There is a potential race condition where the evidence is not sealed while submitting a claim, allowing for more relays to enter the evidence claim. Whenever a proof is generated via
GenerateMerkleRoot
, it will result in an incorrect Merkle proof from being generated due to a mismatch of how many relays are in the store and how many was submitted on chain. This can inadvertently happen more often as we accept session rollover relaysExample: Servicer starts off with 10 relays in the evidence store
Solution
maxRelays
based off:The
GenerateMerkleRoot
already accepts amaxRelays
parameter which was introduced to fix the Chocalate Rain/Overservicing vulnerability. It discards relays above maxRelays with the following implementationNote: The more ideal solution is to only submit the claim whenever we are done servicing for sure, but this involves locks and potential side effects that Pocket core was never really built with in mind
Note: Something tells me that we were missing a
continue
statement in the old code whenever the evidence does not match the total proofs in the claim. It shouldn't submit if there is a mismatch / if we deleted the evidence. My solution adds acontinue
for less than, and tries a best effort to submit proof if we do have enough relay proofs in our evidence store.Summary generated by Reviewpad on 17 Jul 23 19:44 UTC
This pull request adds better proof validation to the
proof.go
file in thex/pocketcore/keeper
package. It includes changes to handle a potential race condition where the evidence is not sealed while submitting a claim, allowing for more relays to enter the evidence claim. It also generates a merkle proof for the claim's total proof count if it doesn't exceed the maximum number of relays per session, otherwise it falls back to the max relays per session. Additionally, it includes validation of the level count on the claim by the total relays.