Skip to content
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

Logic for Checking if Essential Nodes are Confirmable #630

Closed
wants to merge 14 commits into from

Conversation

rauljordan
Copy link
Collaborator

@rauljordan rauljordan commented Apr 26, 2024

Background

As part of reimbursing challenge bonds in-protocol, our researchers at Offchain Labs have determined that honest parties may need to keep defending honest edges within subchallenges for a period of time that may extend beyond the confirmation of a challenge. Defending honest edges within a subchallenge can stop once the closest "essential edge" of an edge within the subchallenge is confirmable.

We can think of an essential edge, for purposes of this PR, as the honest root of a subchallenge, or of a top-level challenge. To check if an essential node is confirmable, all essential paths down from it to terminal edges must have a path weight >= CHALLENGE_PERIOD. This path weight is the sum of the local timers of edges along the path. To achieve this, we do a depth-first search of the graph to extract all essential paths. For each path, we store its weight in a min-heap. Once the min element of this heap has a weight >= CHALLENGE_PERIOD, we know the essential edge is confirmable.

This PR includes the DFS computation and a function called IsConfirmableEssentialNode which performs the operations above. It is tested across challenge levels and uses algorithmic utilities from the standard library. We perform DFS using a visitor stack to avoid recursion in our algorithm.

Note

See the test Test_findEssentialPaths to understand how the algorithm works and what it is meant to output for a sample challenge tree under paths_test.go and also setupEssentialPathsTest

@rauljordan rauljordan marked this pull request as draft April 26, 2024 18:56
@rauljordan rauljordan changed the title Logic for Is Essential Confirmable Logic for Checking if Essential Nodes are Confirmable May 2, 2024
@rauljordan rauljordan marked this pull request as ready for review May 2, 2024 23:33
Copy link

codecov bot commented May 2, 2024

Codecov Report

Attention: Patch coverage is 87.11340% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 60.00%. Comparing base (c3d517f) to head (43f4cee).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #630      +/-   ##
==========================================
+ Coverage   59.34%   60.00%   +0.65%     
==========================================
  Files          48       49       +1     
  Lines        8231     8420     +189     
==========================================
+ Hits         4885     5052     +167     
- Misses       3340     3362      +22     
  Partials        6        6              

@rauljordan rauljordan closed this May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant