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

Staticcalling a non-existent contract in constructor fails #648

Closed
hacker-DOM opened this issue Apr 29, 2021 · 4 comments
Closed

Staticcalling a non-existent contract in constructor fails #648

hacker-DOM opened this issue Apr 29, 2021 · 4 comments

Comments

@hacker-DOM
Copy link

I have a library

library MockConsole {
	address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
	function _sendLogPayload(bytes memory payload) private view {
		uint256 payloadLength = payload.length;
		address consoleAddress = CONSOLE_ADDRESS;
		assembly {
			let payloadStart := add(payload, 32)
			let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)
		}
	}
    function log(string memory p0, uint p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1));
	}
}

and inside of a constructor, I am calling like MockConsole.log("foo", 5). The CONSOLE_ADDRESS is an EOA in my context, so I would expect the staticcall to succeed. Instead, the deployment fails with:

echidna-test: Deploying the contract failed (revert, out-of-gas, sending ether to an non-payable constructor, etc.)

Note: When I uncomment the line with the staticcall, the deployment succeeds.

This looks like an hevm issues, any ideas?

@montyly
Copy link
Member

montyly commented Apr 29, 2021

Smaller example:

contract Test{
    constructor() public{
        address a = address(0xdeadbeef);
        a.call("");
    }
    bool public echidna_test = true;
}

@montyly
Copy link
Member

montyly commented Apr 29, 2021

A more problematic example:

contract Test{
    function f() public{
        address payable a = address(0xdeadbeef);
        a.call("");
        echidna_test = false;
    }
    bool public echidna_test = true;
}

@hacker-DOM
Copy link
Author

Quick workaround:
Set sender: ["0x00000000000000000000000000000000deadbeef"] in echidna config file.

@ggrieco-tob
Copy link
Member

Closing in favor of #653

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

No branches or pull requests

3 participants