-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Proof] Implement scalable proof validation (#1031)
## Summary This PR refactors proof validation by distributing it across the proof submission workflow for better scalability. The validation process is divided into two stages: 1. **Proof Submission**: Ensures the proof is well-formed and adheres to the current on-chain state. 2. **Proof Module Endblocker**: Handles computationally intensive tasks using self-contained parallel verification. It includes: - Relay request and response signature verification. - Validation of the `ClosestMerkleProof`. Additionally, the proof module endblocker: - Deletes all the processed proofs - Reflects the verification result in the corresponding claim's `ProofStatus` field. The potential supplier slashing is retained within the `SettlePendingClaims` flow, ensuring a clear separation of concerns. ## Issue - #1013 ## Type of change Select one or more from the following: - [x] New feature, functionality or library - [ ] Consensus breaking; add the `consensus-breaking` label if so. See #791 for details - [ ] Bug fix - [x] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## Testing - [x] **Unit Tests**: `make go_develop_and_test` - [x] **LocalNet E2E Tests**: `make test_e2e` - [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR. ## Sanity Checklist - [x] I have tested my changes using the available tooling - [x] I have commented my code - [x] I have performed a self-review of my own code; both comments & source code - [ ] I create and reference any new tickets, if applicable - [x] I have left TODOs throughout the codebase, if applicable --------- Co-authored-by: Dmitry K <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]>
- Loading branch information
1 parent
3345bd2
commit 2055b0f
Showing
25 changed files
with
1,942 additions
and
348 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
package protocol | ||
|
||
import ( | ||
"crypto/sha256" | ||
|
||
"github.com/pokt-network/smt" | ||
) | ||
|
||
// SMT specification used for the proof verification. | ||
var ( | ||
newHasher = sha256.New | ||
SmtSpec smt.TrieSpec | ||
) | ||
|
||
func init() { | ||
// Use a spec that does not prehash values in the smst. This returns a nil value | ||
// hasher for the proof verification in order to avoid hashing the value twice. | ||
SmtSpec = smt.NewTrieSpec( | ||
newHasher(), true, | ||
smt.WithValueHasher(nil), | ||
) | ||
} | ||
|
||
// GetPathForProof computes the path to be used for proof validation by hashing | ||
// the block hash and session id. | ||
func GetPathForProof(blockHash []byte, sessionId string) []byte { | ||
hasher := newHasher() | ||
hasher := NewTrieHasher() | ||
if _, err := hasher.Write(append(blockHash, []byte(sessionId)...)); err != nil { | ||
panic(err) | ||
} | ||
|
||
return hasher.Sum(nil) | ||
} | ||
|
||
// NewSMTSpec returns the SMT specification used for proof verification. | ||
// A new hasher is created for each call to prevent concurrency issues | ||
// from shared state. | ||
func NewSMTSpec() *smt.TrieSpec { | ||
trieSpec := smt.NewTrieSpec( | ||
NewTrieHasher(), true, | ||
SMTValueHasher(), | ||
) | ||
|
||
return &trieSpec | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.