-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Base OVM interfaces defining the core components (#355)
Adding Base OVM interfaces defining the core components
- Loading branch information
1 parent
95e5ab9
commit bc4c0c6
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export interface ProofElement { | ||
property: Property | ||
witness: {} | ||
} | ||
|
||
export type Proof = ProofElement[] | ||
|
||
export interface Property { | ||
decider: Decider | ||
input: {} | ||
} | ||
|
||
export type PropertyFactory = (input: any) => Property | ||
|
||
export interface ImplicationProofElement { | ||
implication: Property | ||
implicationWitness: any | ||
} | ||
|
||
export interface Decision { | ||
outcome: boolean | ||
implicationProof: ImplicationProofElement[] // constructed such that claim[N] --> claim[N-1] --> claim[N-2]... Claim[0] | ||
} | ||
|
||
export const UNDECIDED = undefined | ||
export type Undecided = undefined | ||
export type DecisionStatus = boolean | Undecided | ||
|
||
/** | ||
* Defines the Decider interface that implementations capable of making decisions | ||
* on the provided input according to the logic of the specific implementation. | ||
* | ||
* For example: A PreimageExistsDecider would be able to make decisions on whether | ||
* or not the provided _witness, when hashed, results in the provided _input. | ||
*/ | ||
export interface Decider { | ||
/** | ||
* Makes a Decision on the provided input | ||
* @param _input | ||
* @param _witness | ||
*/ | ||
decide(_input: any, _witness: any): Decision | ||
|
||
/** | ||
* Checks whether or not a decision has been made for the provided Input | ||
* Note: This should access a cache decisions that have been made | ||
* @param _input | ||
* @returns the DecisionStatus, indicating if one was made. | ||
*/ | ||
checkDecision(_input: any): DecisionStatus | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface QuantifierResult { | ||
results: any[] | ||
allResultsQuantified: boolean | ||
} | ||
|
||
/** | ||
* Interface defining the contract for all Quantifiers. Quantifiers return a collection of | ||
* results that pass their logic. | ||
* | ||
* For example: A LessThanQuantifier would return all numbers less than the provided input. | ||
* PositiveIntegerLessThanQuantifier.getAllQuantified(5) => [1,2,3,4] | ||
*/ | ||
export interface Quantifier { | ||
/** | ||
* Gets all of the results that meet the criteria of the quantifier logic and provided parameters. | ||
* | ||
* @param parameters the input indicating how the results will be quantified | ||
* @returns the QuantifierResult with results and our level of knowledge of the results. | ||
*/ | ||
getAllQuantified(parameters: any): QuantifierResult | ||
} |