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

Place re-entrancy lock immediately after used storage slots #2308

Merged

Conversation

iamdefinitelyahuman
Copy link
Contributor

What I did

In storage, place re-entrancy locks immediately after the last used storage slot.

How I did it

Within parser/global_context.py, storage variables are stored in GlobalContext._globals. The storage slot for each storage variable is determined from len(self._globals) prior to adding the variable into the dict. Arrays, mappings, and other multiple-slot types are always assigned exactly one slot, but their actual location is calculated from a SHA3 operation (see #769 for more details).

Re-entrancy locks start at slot 0xFFFFFF and if more than this many storage variables are defined, a compile-time exception is raised.

This PR sets the initial re-entrancy lock to location len(self._globals) - immediately after the last used storage slot. This works because globals are defined while parsing the module scope, but re-entrancy locks are defined when parsing the local scope of each function. Thus, there is no overlap and by the time we get to the locks we know with certainy the exact size of storage.

How to verify it

Run tests.

Cute Animal Picture

image

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.

None yet

2 participants