Flatten return tuples of storage variables - #191
Open
langfield wants to merge 14 commits into
Open
Conversation
In this commit, we add a function `userAnnotatedSources` which replaces `isStandardSource`. It generates a list of all the user annotated ScopedFunctions. This list is used to filter modules for solving. This requires a slight refactor within `FunctionAnalysis.hs`. * Add `extern_remove_dirty` test. The basic idea is this: 1. Find all wrapper functions. 2. Compute their respective set of reachable functions. 3. Mark them all as 'don't check' unless they are referenced from a different source as well.
langfield
force-pushed
the
langfield/flattening
branch
3 times, most recently
from
March 26, 2023 12:24
85082ea to
21c0aec
Compare
Don't verify `@external`-generated wrapper functions
* Use `ssh-agent` to clone with specific private key * Set `0o400` permissions on private key file * Add `mathsat` to list of solvers used in tests
Add mathsat installation to Github actions workflow
Cairo semantics comments
…ted-specs Add FAQ about commenting-out annotations
…eadme-additions Add `README.md` section on details of `CairoSemanticsL`
langfield
force-pushed
the
langfield/flattening
branch
from
March 28, 2023 15:33
21c0aec to
c3e0670
Compare
* Update a storage var test for the new syntax. * Update `display.sh` and `oneoff.sh` testing scripts.
This commit makes changes to match the new `spec.json` format in: NethermindEth/horus-compile#63 In particular, return types of storage variables which are `struct`s are flattened (deeply) into a tuple, and internally, we use an extra argument to index into this tuple. Parsing the new JSON format =========================== For example, the keys in the `storage_update` object in the `spec.json` file have been modified as follows: ```diff - "__main__.complex_var_1.s.x": [ + "__main__.complex_var_1 0": [ ``` The relevants bits of the source file are: ```cairo struct Point { x: felt, y: felt, } @storage_var func complex_var_1(arg: Uint256) -> (s: Point) { } ``` Note that instead of using dot-accessor notation, we use an index `0` to indicate the first member of the return tuple of `complex_var_1()`, which is identified with the field `x` of `Point`. In order to parse this index argument from the key in the JSON, as seen in the diff above, we implicitly change the `FromJSON` instance of `FuncSpec`/`Storage`, and define `StorageUpdateKey` which is basically `"__main__.complex_var_1 0"`, as is obvious from its name. So instead of parsing a value of type `Storage` from the JSON, we parse a value of type `IndexedStorage`: ``` +type IndexedStorage = Map StorageUpdateKey [([Expr TFelt], Expr TFelt)] ``` and then convert it to a map of type `Storage` with a `unindexStorage` function. Standard specs for `<storage>.read()` and `<storage>.write()` ============================================================= We refactor `storageVarsSpecs` heavily, folding over the `ContractDefinition` field: ```diff + , cd_storageVars :: Map ScopedName (Arity, Coarity) ``` which now includes the arity and coarity of each storage variable. In order to manage this, we add helper functions: ```diff +mkReadSpecs :: ScopedName -> (Int, Int) -> [(ScopedName, FuncSpec)] +mkWriteSpecs :: ScopedName -> (Int, Int) -> [(ScopedName, FuncSpec)] ``` which basically construct a separate `FuncSpec` for each element of the flattened return tuple. We use a `mergeFuncSpecs` function to nicely take the conjunction of the preconditions and postconditions, and take the union of the `Storage` maps.
We put `dropMain` in `SW/ScopedName.hs`
Contributor
Author
|
There may be an infinite loop or something here. CI tests never finish and it can't be the SMT queries because they have a timeout. |
langfield
force-pushed
the
langfield/flattening
branch
from
March 28, 2023 15:53
c3e0670 to
5233a9b
Compare
langfield
force-pushed
the
master
branch
2 times, most recently
from
March 31, 2023 15:01
9f9928b to
3397b7c
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Corresponds to NethermindEth/horus-compile#61.