Item dependency graphs and yulgen salsafication #596
Merged
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.
Functions, contracts, and struct items now have dependency graphs. A function depends on the functions it calls and any types that are present in the function signature or body (and on anything in the dependency graphs of those items). A type depends on the types of its fields (but not its functions; those are only included if they're called).
A contract runtime object is built by traversing the dependency graph of its (as yet imaginary)
__call__
function, which is the union of the dependency graphs of the contract's public functions (implemented incontract_runtime_dependency_graph
).The constructor object is built by traversing the graph of the contract's
__init__
fn, which means we no longer have to include the entire world in the constructor object "just in case".The (directed) edges in the dependency graphs are labeled with
DepLocality::Local
or::External
. An "external" edge between items means that the items will exist at different addresses when the code is deployed; eg calls to external contract functions result in "external" edges. (Note that this is orthogonal to whether the items are in the same "ingot"). When compiling a contract, we include all items reachable by traversing only "local" edges. "External" edges will be used for future 'unused item' warnings.Inclusion of contract objects that are
create/create2
d is handled by checking theCallType
of every call by every function in the dependency graph. This should probably be reworked; maybe an explicit "creates" relationship should be modeled in the dependency graph, or in a separate graph.This is only a partial re-organisation of the yulgen code; some functions became salsa queries but others didn't, somewhat arbitrarily. More cleanup could be done, but not today.
closes #299
closes #305
To-Do