-
Notifications
You must be signed in to change notification settings - Fork 22
added Ranger repo #395
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
base: master
Are you sure you want to change the base?
added Ranger repo #395
Changes from 29 commits
fba3aae
9bb35c8
9879092
2247e56
2e139a0
bcfcbd2
821c409
41a7e8b
6cd89a5
f21b182
4056511
669da9b
4af3d41
fb12791
dafa026
28ff991
1b686eb
c7a4b6e
03f3c08
22e5da9
6f1bcfd
bdef21d
834dcd9
4be35a0
d7d4c2a
eaed893
c937873
48de033
860d84e
22967ae
ab2f870
0f5f5b4
8f4a1ca
1a388e9
5c0cf4b
8f41e0e
b7ff08e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # How Ranger Works | ||
|
|
||
| **Ranger** is a bounded model checker. This means that, in contrast with "full" | ||
| formal verification, its initial state isn't arbitrary, but is instead reached | ||
| by a sequence of legal function calls. | ||
|
|
||
| (the-initial-state)= | ||
| ## The Initial State | ||
|
|
||
| Ranger starts by initializing all storage to 0, assuming all ghosts' | ||
| `init_state` {ref}`axioms <ghost-axioms>`, and then calling the constructors | ||
| of all the contracts in the {term}`scene`. Additionally, if the .spec file has a | ||
| `function setup()` declared then it will run right after the constructors. | ||
|
|
||
| ## Sequences | ||
|
|
||
| In Ranger's terminology, a sequence refers to setting the | ||
| {ref}`initial state <the-initial-state>` followed by a series of contract | ||
| function calls. The depth or range of a sequence is the number of functions the | ||
| sequence calls. Note that a sequence can call the same function twice, and they | ||
| are counted as two distinct calls. | ||
|
|
||
| ## Ranger's flow | ||
|
|
||
| When a Ranger job starts, for each rule/invariant that's to be run it does the | ||
| following: | ||
|
|
||
| 1. Verify that the initial state rule/invariant holds right after the | ||
| {ref}`initial state <the-initial-state>` (it could also hold vacuously, that's | ||
| fine in this case). | ||
| 2. For each range `1 <= i <= N` (`N` is determined by the {ref}`--range` | ||
| option), create a sequence of `i` functions from the scene (could be from any | ||
| contract and could have duplicates), then call them providing each function with | ||
| independent and arbitrary input. Finally, call the rule/invariant and check that | ||
| it holds. | ||
| * In the invariant case, before each function call we insert an assumption | ||
| that the invariant is true. This is done for optimization reasons. | ||
|
|
||
| For each sequence `f_1 -> ... -> f_n` we first check the subsequence | ||
| `f_1 -> ... -> f_n-1` and only if it verifies will we continue to check the | ||
| longer sequence. This promises that if a violation is found it is the shortest | ||
| sequence with these functions that violates the rule/invariant. | ||
|
|
||
| ```{note} | ||
| While in principle for a provided range N there are \sum_{i=0}^N a_i sequences, | ||
| in practice Ranger has several optimizations that prune a significant portion of | ||
| these sequences. | ||
| ``` | ||
johspaeth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| (ranger-intro)= | ||
| Ranger | ||
| ====== | ||
|
|
||
| Text | ||
|
|
||
| ```{toctree} | ||
| :maxdepth: 2 | ||
|
|
||
| ranger_intro.md | ||
| starting_with_ranger.md | ||
| how_ranger_works.md | ||
| ranger_client.md | ||
| ``` | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,113 @@ | ||||||
| # The Ranger Client | ||||||
|
|
||||||
| Ranger introduces a new CLI entry point: `certoraRanger`. | ||||||
|
|
||||||
| This command is part of the `certora-cli` Python package and provides a streamlined interface for bounded model checking, | ||||||
| specifically designed for exploring concrete execution paths up to a limited range. | ||||||
| It comes with new defaults and additional under-approximations to make finding concrete counterexamples easier and faster. | ||||||
|
|
||||||
| The `certoraRanger` client submits jobs to the Certora cloud, just like the Prover. You'll receive a dashboard link with the results once the job is submitted | ||||||
|
|
||||||
| Ranger uses the same input format and job flow as `certoraRun`, allowing teams to reuse existing configuration and spec files. | ||||||
|
|
||||||
| ## Ranger-specific flags | ||||||
|
|
||||||
| (--range)= | ||||||
| ### `range` | ||||||
|
|
||||||
| **What does it do?** | ||||||
| Sets the maximal length of function call sequences to check (0 ≤ K). | ||||||
| This flag controls how deep Ranger explores function call sequences from the initial state. | ||||||
| Higher values can uncover deeper bugs but may increase analysis time. | ||||||
|
|
||||||
| When not assigned, the default value is defined as 5 | ||||||
|
|
||||||
| **When to use it?** | ||||||
| When you wish to assign a different value than the default one. | ||||||
| Increasing this flag will execute longer sequences, or decreasing when you wish to execute faster runs. | ||||||
|
|
||||||
| **Example** | ||||||
|
|
||||||
| ```sh | ||||||
| certoraRanger ranger.conf --range K | ||||||
| ``` | ||||||
|
|
||||||
| [//]: <> ((--ranger_failure_limit)=) | ||||||
|
|
||||||
| [### `ranger_failure_limit` | ||||||
|
||||||
| [### `ranger_failure_limit` | |
| ### `ranger_failure_limit` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is commented on purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it currently just renders strangely on https://certora-certora-prover-documentation--395.com.readthedocs.build/en/395/docs/ranger/ranger_client.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks!
I tried different ways of commenting out lines in markdown, none worked, I've removed the lines entirely
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||
| # Introduction | ||||||
|
|
||||||
| **Ranger** is Certora’s bounded model checker for smart contracts. It complements formal verification by offering a lightweight, developer-friendly approach for quickly identifying violations of contract invariants. | ||||||
|
|
||||||
| Unlike the [Certora Prover](/docs/user-guide/index), which explores all program states, Ranger starts from a specific initial state and explores all function call sequences up to a bounded depth. This ensures that every violation corresponds to a realistic execution path, removing the need to filter out spurious counterexamples. | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Why Ranger? | ||||||
|
|
||||||
| Formal Verification provides strong correctness guarantees and checks more program states, but it can be slow, complex, and prone to false positives from unreachable states. {term}`fuzzing`, on the other hand, is faster, but has a lower coverage as it only checks for specific inputs per run. | ||||||
|
|
||||||
| Ranger offers a practical middle ground: | ||||||
|
|
||||||
| - ✅ **Realistic counterexamples**: All violations are reachable from the initial state. | ||||||
| - ✅ **Faster time to value**: Minimal setup required to get useful results. | ||||||
| - ✅ **Fewer false positives**: No need to precondition rules to filter out invalid states. | ||||||
| - ✅ **High coverage**: Symbolically tests all function call sequences from the initial state up to a certain range. | ||||||
|
||||||
| - ✅ **High coverage**: Symbolically tests all function call sequences from the initial state up to a certain range. | |
| - ✅ **High coverage**: Tests all function call sequences on symbolic inputs from the initial state up to a certain range. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Getting Started | ||
|
|
||
| This guide will help you run your first Ranger job using a Solidity contract and a [CVL](/docs/cvl/index) [invariant](/docs/cvl/invariants). | ||
|
|
||
| Ranger uses the same installation process, configuration files, and spec files as the [Certora Prover](/docs/user-guide/index). If you're already familiar with the Prover, getting started with Ranger will feel familiar. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That Ranger uses CVL could be stated also
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
|
||
| --- | ||
|
|
||
| ## 1. Install Certora Tools | ||
|
|
||
| Ranger is part of the `certora-cli` Python package. You can install or upgrade it using `pip`: | ||
|
|
||
| ```bash | ||
| pip install certora-cli | ||
| ``` | ||
| For full installation instructions and troubleshooting, see the Certora Prover [installation guide](/docs/user-guide/install). | ||
|
|
||
| ## 2. Prepare Your Files | ||
| You'll need three files: | ||
|
|
||
| - A compiled Solidity contract (e.g. `MyContract.sol`) | ||
| - A CVL spec file with at least one invariant (e.g. `MyContract.spec`) | ||
| - A configuration file (e.g. `ranger.conf`) | ||
|
|
||
| Example `ranger.conf`: | ||
|
|
||
| ```json | ||
| { | ||
| "files": ["MyContract.sol"], | ||
| "verify": "MyContract:MyContract.spec" | ||
| } | ||
| ``` | ||
|
|
||
| ## 3. Run Ranger | ||
| Use the `certoraRanger` command to launch the job: | ||
|
|
||
| ```bash | ||
| certoraRanger ranger.conf | ||
| ``` | ||
|
|
||
| This will start the Ranger process. A link to the Ranger Job Report in the dashboard will be pasted into your command line when the job is submitted. | ||
|
|
||
| ```{warning} | ||
| Ranger is compute-intensive: It performs symbolic exploration of many function call sequences. For faster feedback, avoiding timeouts, and better resource usage, consider one of the following: | ||
|
|
||
| 1. Use {ref}`--rule` to focus on a single invariant or rule. | ||
|
|
||
| 2. Use {ref}`--split_rules` to automatically run each rule/invariant in a separate job. | ||
| ``` | ||
|
|
||
|
|
||
| ## 4. View the Results | ||
| A link to the Ranger Job Report in the dashboard will be pasted in your command line | ||
| when the job is submitted. | ||
| You can explore the results in the web-based Ranger Report by following the link. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ Contents | |||||
| * :doc:`docs/sunbeam/index` -- instructions for installing and using *Certora Sunbeam* | ||||||
| for formal verification of `Soroban`_ contracts. | ||||||
| * :doc:`docs/solana/index` -- instructions for installing and using *Certora Solana Prover* | ||||||
| * :doc:`docs/ranger/index` -- TODO | ||||||
|
||||||
| * :doc:`docs/ranger/index` -- TODO | |
| * :doc:`docs/ranger/index` -- explains how to use Ranger, Certora's Bounded Model Checker. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.