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

Proxies: add checks for base being a contract #394

Merged
merged 5 commits into from
Aug 23, 2018
Merged

Proxies: add checks for base being a contract #394

merged 5 commits into from
Aug 23, 2018

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented Aug 22, 2018

Adds more contract checks to the proxies.

Bytecode change:

                    CODE DEPOSIT COST    DEPLOYED BYTES     INITIALIZATION BYTES
AppProxyPinned.json Same                 0                  -18
KernelProxy.json    Same                 0                  +126

@sohkai sohkai requested review from bingen and izqui August 22, 2018 16:34
@@ -21,7 +22,7 @@ contract AppProxyPinned is AppProxyBase {
public // solium-disable-line visibility-first
{
setPinnedCode(getAppBase(_appId));
require(pinnedCode() != address(0));
require(isContract(pinnedCode()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that strictly, this isn't necessary as our Kernel doesn't let an app be set unless it's a contract (https://github.com/aragon/aragonOS/blob/dev/contracts/kernel/Kernel.sol#L177), so this is really more of an assertion (should we make it one?).

This also complicates the tests quite a bit, as you'll see in 961a7d7

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think an assertion makes sense here, as a contract that follows the IKernel interface may not check whether a base is a contract. A require is fine IMO.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 99.068% when pulling 961a7d7 on check-contract into f4048ef on add-petrifiable-tests.

Copy link
Contributor

@izqui izqui left a comment

Choose a reason for hiding this comment

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

Not a huge fan of the increased test complexity but I cannot think of another way to do it. The complexity is well documented though!

@@ -21,7 +22,7 @@ contract AppProxyPinned is AppProxyBase {
public // solium-disable-line visibility-first
{
setPinnedCode(getAppBase(_appId));
require(pinnedCode() != address(0));
require(isContract(pinnedCode()));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think an assertion makes sense here, as a contract that follows the IKernel interface may not check whether a base is a contract. A require is fine IMO.

function KernelSetAppMock() Kernel(false) public {
}

function setApp(bytes32 _namespace, bytes32 _name, address _app) public returns (bytes32 id) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add a comment explaining that we are bypassing the isContract check

@sohkai sohkai force-pushed the add-petrifiable-tests branch from f4048ef to 5326557 Compare August 22, 2018 17:09
@sohkai
Copy link
Contributor Author

sohkai commented Aug 22, 2018

Yeah... there is a way right now, by overloading the isContract() base function... but that won't be an option if we turn it into a library (which we probably will after turning on the optimizer).

@sohkai sohkai changed the base branch from add-petrifiable-tests to dev August 22, 2018 18:41
@sohkai sohkai merged commit 5bec9d0 into dev Aug 23, 2018
@sohkai sohkai deleted the check-contract branch August 23, 2018 12:52
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.

3 participants