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

Support for fixed arrays and structs as function parameters #121

Closed
wants to merge 24 commits into from

Conversation

spencerhaoxiao
Copy link
Contributor

  1. Support fixed arrays as function arguments
  2. Support the combination of, nested structs and multi-dimensional arrays and all their combinations
  3. The predicate on an array argument is to add the relevant predicates on its element type.

src/kontrol/solc_to_k.py Outdated Show resolved Hide resolved
src/kontrol/solc_to_k.py Outdated Show resolved Hide resolved
@anvacaru
Copy link
Contributor

@spencerhaoxiao spencerhaoxiao marked this pull request as draft October 24, 2023 13:29
@spencerhaoxiao spencerhaoxiao changed the title [WIP]Support for fixed arrays as function parameters Support for fixed arrays as function parameters Oct 24, 2023
@palinatolmach
Copy link
Collaborator

@spencerhaoxiao could you please move a Solidity StructTest from #78 to this PR?

@palinatolmach palinatolmach changed the title Support for fixed arrays as function parameters Support for fixed arrays and structs as function parameters Nov 20, 2023
@palinatolmach palinatolmach self-assigned this Nov 20, 2023
@palinatolmach
Copy link
Collaborator

palinatolmach commented Nov 24, 2023

As discussed with @anvacaru, we might want to remove references to array elements within #array and the rule generated for a test function accepting arrays as parameters — at the moment, the later looks like this (note that it doesn't kompile):

rule  ( S2KArrayTypeTest . S2KtestZUndstaticZUndarray ( V0_arr : uint256[3] ) => 
   #abiCallData ( "test_static_array" , #array ( #uint256 ( V0_arr_0_ ) , 3:Int , #uint256 ( V0_arr_0_ ) , #uint256 ( V0_arr_1_ ) , #uint256 ( V0_arr_2_ ) , .TypedArgs ) , .TypedArgs ) )
    ensures ( #rangeUInt ( 256 , V0_arr_0_ )
    andBool ( #rangeUInt ( 256 , V0_arr_1_ )
    andBool ( #rangeUInt ( 256 , V0_arr_2_ )
   )))

Referencing array elements is impractical for dynamically-sized arrays or statically-sized ones with a large number of elements. This, however, would make generation of range predicates for elements less straightforward, so I'll continue the investigation on it.

@palinatolmach
Copy link
Collaborator

Based on a discussion with @anvacaru and @PetarMax: for static arrays, we should try adding array elements to the left-hand side too.

@palinatolmach
Copy link
Collaborator

palinatolmach commented Nov 29, 2023

As @anvacaru has suggested, we'll proceed in three different directions: we will

  • factor out struct support as implemented in Support for user-defined struct #78 back to merge it sooner
  • attempt adding support for dynamic arrays by allowing calldata to be symbolic
  • continue working on statically-sized array support as proposed in this PR, i.e., involving references to the elements of the array in the rules generated in solc_to_k,

in this order.

@anvacaru
Copy link
Contributor

anvacaru commented Feb 2, 2024

I'm closing this due to staleness.

@anvacaru anvacaru closed this Feb 2, 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.

Functions with array arguments give "Unsupported ABI type for method` error
3 participants