Skip to content

Replace the data dependency by a context sensitive analysis #1742

Open
@montyly

Description

@montyly

Right now the data dependency is context insensitive, which creates a large over approximation.

For example in

contract A{

	uint a;
	uint b;

	function f(uint x) internal returns(uint){
		return x;
	}

	function test1(uint paramA) public{
		a = f(paramA);
	}

	function test2(uint paramB) public{
		b = f(paramB);
	}

}

Slither will merge all the deps related to the call to f(x) when looking at the contract context. As a result, a dependency between a and paramB(or b and paramA) will be created, because the the analysis will merge all the callers of f :

$ slither test.sol --print data-dependency

Contract A
+----------+---------------------------+
| Variable |        Dependencies       |
+----------+---------------------------+
|    a     | ['paramA', 'paramB', 'x'] |
|    b     | ['paramA', 'paramB', 'x'] |
+----------+---------------------------+

Having a context-sensitive analysis will lead to bette results. This is also a recurring issues with top-level functions - which tend to be called from a lot of different contexts.

Moving toward a context sensitive analysis will have an impact on the performance. We could propose the two options (sensitive/insensitive), and allow the user to enable one or the other.

Additionally we should take the opportunity to refactor the data dependency to better support the switch between the context and the different source type:

# TODO refactor the data deps to be better suited for top level function object
# Right now we allow to pass a node to ease the API, but we need something
# better
# The deps propagation for top level elements is also not working as expected

If Node is provided as context, the context will be the broader context, either the contract or the function,
depending on if the node is in a top level function or not

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions