Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Revert to old ReentrancyGuard implementation + random cleanup #2101

Merged
merged 6 commits into from
Aug 27, 2019

Conversation

abandeali1
Copy link
Member

@abandeali1 abandeali1 commented Aug 26, 2019

Description

We originally switched to a new ReentrancyGuard implementation in 3.0 that currently is ~5000 gas cheaper because EIP-1283 was nixed (which would have saved close to 10K gas in the current implementation). It looks like EIP-2200, which is based off of 1283, is actually going to end up in Istanbul, which gives us the same 10K optimization if we revert to the old implementation.

Note that this new implementation makes testing the noThrow functions for reentrancy much harder. I had to overwrite fillOrderNoThrow with something that is almost identical to fillOrder in terms of functionality in order to get all tests to pass.

This PR also cleans up some variable names and revert reasons that I encountered while working on the 3.0 spec.

Testing instructions

Types of changes

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@coveralls
Copy link

coveralls commented Aug 26, 2019

Coverage Status

Coverage remained the same at 75.804% when pulling df8419c on feat/3.0/cleanup into 8ef0a59 on 3.0.

Copy link
Contributor

@moodlezoup moodlezoup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single nit, but otherwise looks good to me

/// @dev Calls a public function to check if it is reentrant.
/// Because this function uses the `nonReentrant` modifier, if
/// the function being called is also guarded by the `nonReentrant` modifier,
/// it will revert when it returns.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this comment up to isReentrant now that it has the nonReentrant modifier

Copy link
Contributor

@dorothy-zbornak dorothy-zbornak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

external
nonReentrant
/// @dev Overridden to revert on unsuccessful fillOrder call.
function fillOrderNoThrow(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This almost feels not worth testing since it's bascially rewriting fillOrderNoThrow. I guess it's fine for now until we can come up with some clever way of getting around it.

@abandeali1 abandeali1 changed the base branch from 3.0 to development August 26, 2019 22:02
@abandeali1 abandeali1 changed the base branch from development to 3.0 August 26, 2019 22:02
@abandeali1 abandeali1 merged commit b7397bb into 3.0 Aug 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants