Skip to content

Commit

Permalink
use 0x as the salt value for AccountFactory proxy deployment
Browse files Browse the repository at this point in the history
there's no reason to use a random hex here, or to have the salt match our contract deployment salt
  • Loading branch information
mikec committed Dec 16, 2021
1 parent d4f6ef9 commit 71686cf
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion __snapshots__/Account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ exports['Account externalCall() gas cost 1'] = 28277

exports['Account delegateCall() gas cost 1'] = 28106

exports['Account metaDelegateCall() gas cost 1'] = 34784
exports['Account metaDelegateCall() gas cost 1'] = 34760

exports['Account metaDelegateCall_EIP1271() gas cost 1'] = 46884
2 changes: 1 addition & 1 deletion __snapshots__/DeployAndCall.test.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports['DeployAndCall deployAndCall() with callData that does not revert gas cost 1'] = 94181
exports['DeployAndCall deployAndCall() with callData that does not revert gas cost 1'] = 94193
4 changes: 2 additions & 2 deletions __snapshots__/deterministicAddresses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ exports['Account.sol deterministic address check 1'] = `
`

exports['AccountFactory.sol deterministic address check 1'] = `
0xbb1eee341ed905F1d6d1f9e34e9119f032aB8f0E
0x25b874bAee46AeA093692d54393D6648355B8Ac0
`

exports['DeployAndCall.sol deterministic address check 1'] = `
0x784D8a95fA3B841523494688D64F6588ef1f17bd
0xf9d7A4411ab64D256c677354FF069F4dD904ee14
`

exports['SaltedDeployer.sol deterministic address check 1'] = `
Expand Down
5 changes: 2 additions & 3 deletions constants.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module.exports = {
ACCOUNT: '0x0000F673CB919A0D37A55a20263B490614eed150',
ACCOUNT_FACTORY: '0xbb1eee341ed905F1d6d1f9e34e9119f032aB8f0E',
DEPLOY_AND_CALL: '0x784D8a95fA3B841523494688D64F6588ef1f17bd',
ACCOUNT_FACTORY: '0x25b874bAee46AeA093692d54393D6648355B8Ac0',
DEPLOY_AND_CALL: '0xf9d7A4411ab64D256c677354FF069F4dD904ee14',
CONTRACT_DEPLOY_SALT: '0x0000000000000000000000000000000000000000000000000000000000005dcd',
PROXY_DEPLOY_SALT: '0xa673c34e43742984a277506c967311f8de686653b0232a554cf57699fa5dc522',
SALTED_DEPLOYER: '0x06Dc2c9fB6f92f4242a17dbc80448a510fc52465',
SINGLETON_FACTORY: '0xce0042B868300000d44A59004Da54A005ffdcf9f'
}
5 changes: 1 addition & 4 deletions contracts/Account/AccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ pragma abicoder v1;
/// @title Brink account factory
/// @notice This is a factory contract used for deployment of Brink proxy accounts
contract AccountFactory {
/// @dev Salt used for salted deployment of Proxy accounts
bytes32 constant SALT = 0xa673c34e43742984a277506c967311f8de686653b0232a554cf57699fa5dc522;

/// @dev Deploys a Proxy account for the given owner
/// @param owner Owner of the Proxy account
/// @return account Address of the deployed Proxy account
Expand All @@ -22,7 +19,7 @@ contract AccountFactory {
owner
);
assembly {
account := create2(0, add(initCode, 0x20), mload(initCode), SALT)
account := create2(0, add(initCode, 0x20), mload(initCode), 0)
}
}
}
2 changes: 1 addition & 1 deletion contracts/Batched/DeployAndCall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "../Account/AccountFactory.sol";
/// @notice This contract contains a function to batch account deploy and call into one transaction
contract DeployAndCall {
/// @dev The AccountFactory to use for account deployments
AccountFactory constant ACCOUNT_FACTORY = AccountFactory(0xbb1eee341ed905F1d6d1f9e34e9119f032aB8f0E);
AccountFactory constant ACCOUNT_FACTORY = AccountFactory(0x25b874bAee46AeA093692d54393D6648355B8Ac0);

/// @dev Deploys an account for the given owner and executes callData on the account
/// @param owner Address of the account owner
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/deployProxyAccount.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { ethers } = require('hardhat')
const { ACCOUNT_FACTORY, PROXY_DEPLOY_SALT } = require('../../constants')
const { ACCOUNT_FACTORY } = require('../../constants')
const deployMasterAccount = require('./deployMasterAccount')
const deployAccountFactory = require('./deployAccountFactory')
const saltedDeployAddress = require('./saltedDeployAddress')
Expand All @@ -10,7 +10,7 @@ async function deployProxyAccount (ownerAddress) {
const accountFactory = await deployAccountFactory()

const { address: proxyAddress } = saltedDeployAddress(
ACCOUNT_FACTORY, PROXY_DEPLOY_SALT, await proxyBytecode(ownerAddress), [], []
ACCOUNT_FACTORY, '0x', await proxyBytecode(ownerAddress), [], []
)

if (await ethers.provider.getCode(proxyAddress) == '0x') {
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/proxyAccountFromOwner.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const saltedDeployAddress = require('./saltedDeployAddress')
const proxyBytecode = require('./proxyBytecode')
const { ACCOUNT_FACTORY, PROXY_DEPLOY_SALT } = require('../../constants')
const { ACCOUNT_FACTORY } = require('../../constants')

async function proxyAccountFromOwner (proxyOwnerAddress) {
const { address: proxyAccountAddress } = saltedDeployAddress(
ACCOUNT_FACTORY, PROXY_DEPLOY_SALT, await proxyBytecode(proxyOwnerAddress), [], []
ACCOUNT_FACTORY, '0x', await proxyBytecode(proxyOwnerAddress), [], []
)
return proxyAccountAddress
}
Expand Down

0 comments on commit 71686cf

Please sign in to comment.