Skip to content

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

Merged
iamdefinitelyahuman merged 1 commit into
vyperlang:masterfrom
iamdefinitelyahuman:feat-reentrant
Feb 16, 2021
Merged

Place re-entrancy lock immediately after used storage slots#2308
iamdefinitelyahuman merged 1 commit into
vyperlang:masterfrom
iamdefinitelyahuman:feat-reentrant

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
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.

2 participants