diff --git a/contracts/zero-ex/contracts/src/ZeroEx.sol b/contracts/zero-ex/contracts/src/ZeroEx.sol index 25fa11ac65..4ea386f445 100644 --- a/contracts/zero-ex/contracts/src/ZeroEx.sol +++ b/contracts/zero-ex/contracts/src/ZeroEx.sol @@ -39,11 +39,10 @@ contract ZeroEx { /// @dev Construct this contract and set the bootstrap migration contract. /// After constructing this contract, `bootstrap()` should be called /// to seed the initial feature set. - /// @param bootstrapper The bootstrap migration contract. - constructor(address bootstrapper) public { + constructor() public { // Temporarily create and register the bootstrap feature. // It will deregister itself after `bootstrap()` has been called. - Bootstrap bootstrap = new Bootstrap(msg.sender, bootstrapper); + Bootstrap bootstrap = new Bootstrap(msg.sender); LibProxyStorage.getStorage().impls[bootstrap.bootstrap.selector] = address(bootstrap); } diff --git a/contracts/zero-ex/contracts/src/features/Bootstrap.sol b/contracts/zero-ex/contracts/src/features/Bootstrap.sol index 0dd60eba66..e54f85b0d5 100644 --- a/contracts/zero-ex/contracts/src/features/Bootstrap.sol +++ b/contracts/zero-ex/contracts/src/features/Bootstrap.sol @@ -40,28 +40,24 @@ contract Bootstrap is /// @dev The deployer. /// This has to be immutable to persist across delegatecalls. address immutable private _bootstrapCaller; - /// @dev The bootstrap migrator. - /// This has to be immutable to persist across delegatecalls. - address immutable private _bootstrapper; // solhint-enable state-visibility,indent /// @dev Construct this contract and set the bootstrap migration contract. /// After constructing this contract, `bootstrap()` should be called /// to seed the initial feature set. /// @param bootstrapCaller The allowed caller of `bootstrap()`. - /// @param bootstrapper The bootstrap migration contract. - constructor(address bootstrapCaller, address bootstrapper) public { + constructor(address bootstrapCaller) public { _deployer = msg.sender; _implementation = address(this); _bootstrapCaller = bootstrapCaller; - _bootstrapper = bootstrapper; } /// @dev Bootstrap the initial feature set of this contract by delegatecalling /// into `_bootstrapper`. Before exiting the `bootstrap()` function will /// deregister itself from the proxy to prevent being called again. + /// @param target The bootstrapper contract address. /// @param callData The call data to execute on `_bootstrapper`. - function bootstrap(bytes calldata callData) external override { + function bootstrap(address target, bytes calldata callData) external override { // Only the bootstrap caller can call this function. if (msg.sender != _bootstrapCaller) { _rrevert(LibProxyRichErrors.InvalidBootstrapCallerError( @@ -69,7 +65,7 @@ contract Bootstrap is _bootstrapCaller )); } - LibBootstrap.delegatecallBootstrapFunction(_bootstrapper, callData); + LibBootstrap.delegatecallBootstrapFunction(target, callData); // Deregister. LibProxyStorage.getStorage().impls[this.bootstrap.selector] = address(0); // Self-destruct. @@ -77,7 +73,7 @@ contract Bootstrap is } /// @dev Self-destructs this contract. - /// Can only be called by the ZeroEx contract. + /// Can only be called by the deployer. function die() external { if (msg.sender != _deployer) { _rrevert(LibProxyRichErrors.InvalidDieCallerError(msg.sender, _deployer)); diff --git a/contracts/zero-ex/contracts/src/features/IBootstrap.sol b/contracts/zero-ex/contracts/src/features/IBootstrap.sol index 87bc766700..24541da95e 100644 --- a/contracts/zero-ex/contracts/src/features/IBootstrap.sol +++ b/contracts/zero-ex/contracts/src/features/IBootstrap.sol @@ -26,6 +26,7 @@ interface IBootstrap { /// @dev Bootstrap the initial feature set of this contract by delegatecalling /// into `_bootstrapper`. Before exiting the `bootstrap()` function will /// deregister itself from the proxy to prevent being called again. + /// @param target The bootstrapper contract address. /// @param callData The call data to execute on `_bootstrapper`. - function bootstrap(bytes calldata callData) external; + function bootstrap(address target, bytes calldata callData) external; } diff --git a/contracts/zero-ex/contracts/src/migrations/InitialMigration.sol b/contracts/zero-ex/contracts/src/migrations/InitialMigration.sol index 1281a246ca..02c0e04130 100644 --- a/contracts/zero-ex/contracts/src/migrations/InitialMigration.sol +++ b/contracts/zero-ex/contracts/src/migrations/InitialMigration.sol @@ -41,13 +41,13 @@ contract InitialMigration { require(address(_zeroEx) == address(0), "InitialMigration/ALREADY_DEPLOYED"); // Deploy the ZeroEx contract, setting ourselves as the bootstrapper. - zeroEx = _zeroEx = new ZeroEx(address(this)); + zeroEx = _zeroEx = new ZeroEx(); // Bootstrap the initial feature set. - IBootstrap(address(zeroEx)).bootstrap(abi.encodeWithSelector( - this.bootstrap.selector, - owner - )); + IBootstrap(address(zeroEx)).bootstrap( + address(this), + abi.encodeWithSelector(this.bootstrap.selector, owner) + ); } /// @dev Sets up the initial state of the `ZeroEx` contract. diff --git a/contracts/zero-ex/contracts/test/TestInitialMigration.sol b/contracts/zero-ex/contracts/test/TestInitialMigration.sol index e3d60eb50b..135e2cb246 100644 --- a/contracts/zero-ex/contracts/test/TestInitialMigration.sol +++ b/contracts/zero-ex/contracts/test/TestInitialMigration.sol @@ -30,7 +30,7 @@ contract TestInitialMigration is address public bootstrapFeature; function callBootstrap(ZeroEx zeroEx) external { - IBootstrap(address(zeroEx)).bootstrap(new bytes(0)); + IBootstrap(address(zeroEx)).bootstrap(address(this), new bytes(0)); } function getCodeSizeOf(address target) external view returns (uint256 codeSize) {