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

Functions with array arguments give "Unsupported ABI type for method` error #55

Closed
lucasmt opened this issue Apr 24, 2023 · 5 comments
Closed
Assignees
Labels
engagement enhancement New feature or request

Comments

@lucasmt
Copy link
Contributor

lucasmt commented Apr 24, 2023

The function _range_predicate in solc_to_k.py does not support array types. As a result, if we try to foundry-kompile a function such as

function testArray(address[] memory array) public {
	assert(true);
}

that has an array as argument, we get the message Unsupported ABI type for method TestContract.method_TestContract_testArray_address[], will not generate calldata sugar: address[], and no rule of the form

rule  ( TestContract . testArray ( ... ) => #abiCallData ( ... ) )

is added to foundry.k. This makes it so that the function cannot be evaluated during symbolic execution. If we try to run kevm foundry-prove on this function, the execution just starts branching on conditions like

lengthBytes ( TestContract . testArray ( VV0_array_114b9705:K : address[] ) ) <Int 4

without ever stepping into the function.

@ehildenb
Copy link
Member

ehildenb commented Jun 1, 2023

From slack discussion with @iFrostizz :

Currently, when we have a function signature with types, we generate a rule that simplifies that function signature to its abi encoding, while at teh same time using an ensures clause to make sure the symbolic variables present are in the correct range: https://github.com/runtimeverification/evm-semantics/blob/a68c97a2280b7ac9f1fc81f142464d0a23793b8d/tests/foundry/contracts.k.check.expected#L80

This is an example generated rule for the KEVM foundry test-suite at tests/foundry
Those predicates in the ensures clause are generated by the _range_predicate thing you have linked above.
Currently, the logic there is "if it's a type we don't recognize directly, then return None, and don't generate the corresponnding rule with syntactic sugar".
Which means we can't write property tests about that function.

Here: https://github.com/runtimeverification/evm-semantics/blob/a68c97a2280b7ac9f1fc81f142464d0a23793b8d/kevm-pyk/src/kevm_pyk/solc_to_k.py#L15

We call _range_predicate to get the predicate used to constrain the symbolic value in the type.
And if it gives back None, then we just give up, and don't generate the overall rule.

I think there are two things we can do here:

  • It's OK to still generate the rule itself, but leave the variable unconstrained, if the _range_predicate does not give back an appropriate predicate. This is less than ideal, because now you have an unconstrained variable, but,
  • We can then make _range_predicate stronger, and able to handle more cases basically.

@lucasmt
Copy link
Contributor Author

lucasmt commented Aug 10, 2023

By the way, a similar issue also happens when a function has a struct argument.

@iFrostizz
Copy link

Partly fixed, please see runtimeverification/evm-semantics#1883 (comment) for reference.

@palinatolmach
Copy link
Collaborator

A related PR introducing support for structs: runtimeverification/evm-semantics#2051.

@palinatolmach palinatolmach transferred this issue from runtimeverification/evm-semantics Sep 28, 2023
@spencerhaoxiao spencerhaoxiao self-assigned this Sep 29, 2023
@yale-vinson yale-vinson added the enhancement New feature or request label Oct 11, 2023
@anvacaru anvacaru self-assigned this Jan 22, 2024
@palinatolmach
Copy link
Collaborator

Closed by #321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engagement enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants