Skip to content

Commit

Permalink
Merge pull request #13 from forumdaos/jamesmccomish/update-entrypoint
Browse files Browse the repository at this point in the history
Jamesmccomish/update entrypoint
  • Loading branch information
jamesmccomish authored May 19, 2023
2 parents e98d53b + 99a1bff commit ff6a7a0
Show file tree
Hide file tree
Showing 49 changed files with 3,265 additions and 3,012 deletions.
10 changes: 4 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[submodule "lib/forge-std"]
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.4.0
[submodule "lib/solbase"]
[submodule "lib/solbase"]
path = lib/solbase
url = https://github.com/Sol-DAO/solbase
[submodule "lib/zodiac"]
Expand All @@ -11,14 +11,12 @@
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
branch = 1b78ed2
branch = develop
commit = abff2ac
[submodule "lib/foundry-deployment-manager"]
path = lib/foundry-deployment-manager
url = https://github.com/jamesmccomish/foundry-deployment-manager
[submodule "lib/safe-contracts"]
path = lib/safe-contracts
url = https://github.com/safe-global/safe-contracts
branch = v1.3.0
[submodule "lib/aa-passkeys-wallet"]
path = lib/aa-passkeys-wallet
url = https://github.com/itsobvioustech/aa-passkeys-wallet
5 changes: 0 additions & 5 deletions .prettierignore

This file was deleted.

11 changes: 0 additions & 11 deletions .prettierrc

This file was deleted.

1 change: 1 addition & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
test/
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ Forum groups will be extendedable with additional functionality, such as Fundrai

| Contract | Address | Description |
| :-------------------- | :---------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------- |
| Forum Group | [0xd6839cdbd177012fd9766c274A92Fc27e30c80c4](https://polygonscan.com/address/0xd6839cdbd177012fd9766c274A92Fc27e30c80c4#code) | ERC4337 enabled safe with P-256 passkey members |
| Forum Group Factory | [0x4D5AbC4d534E6764a1BAe920e76037D2E89E970F](https://polygonscan.com/address/0x4D5AbC4d534E6764a1BAe920e76037D2E89E970F#code) | Factory for Forum Groups |
| Forum Account | [0x412e20CB39aaC4D3BB250599349b3d904BF27262](https://polygonscan.com/address/0x412e20CB39aaC4D3BB250599349b3d904BF27262#code) | ERC4337 enabled safe with P-256 passkey owner |
| Forum Account Factory | [0xcbAf5c43571d368117B7550b2f58c4864f3Ccb2d](https://polygonscan.com/address/0xcbAf5c43571d368117B7550b2f58c4864f3Ccb2d#code) | Factory for Forum Accounts |
| Forum Group | [0xAce948FC346A00Eead396c23eCCB2f83c7f35ef6](https://polygonscan.com/address/0xAce948FC346A00Eead396c23eCCB2f83c7f35ef6#code) | ERC4337 enabled safe with P-256 passkey members |
| Forum Group Factory | [0xCD9dC60Ad2ceC294bB384B7C8190e58c39595694](https://polygonscan.com/address/0xCD9dC60Ad2ceC294bB384B7C8190e58c39595694#code) | Factory for Forum Groups |
| Forum Account | [0x9dE434EE5d7604e0A95626614AD76464dd2d65E5](https://polygonscan.com/address/0x9dE434EE5d7604e0A95626614AD76464dd2d65E5#code) | ERC4337 enabled safe with P-256 passkey owner |
| Forum Account Factory | [0x7504c55f1b6E10364f4735Ff56888BB721F97578](https://polygonscan.com/address/0x7504c55f1b6E10364f4735Ff56888BB721F97578#code) | Factory for Forum Accounts |

<br>
<br>

Current seperation of development, staging, and production environments means that multiple factories addresses have been deployed.

| Chain | **Account Factory** | **Group Factory** |
| :-----: | :-------------------------------------------------: | :-------------------------------------------------: |
| Mumbai | Dev: 0x27305c89Cc26d77bcbA3ccf82EF0bB171319C37e | Dev: 0xa780c7627205c39E4BA956f7ff1cc4Dc629EC5DC |
| Polygon | Staging: 0xD243610b2d09255C73692f26A446c71843768819 | Staging: 0x3FAb616EAc9c4dB46B0273D8C3fBCdaA0fFf9254 |
12 changes: 6 additions & 6 deletions addresses/deployed/matic.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions addresses/deployed/maticmum.json

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ script='script'
broadcast='broadcast'
libs = ['lib', 'node_modules']
cache_path = 'forge-cache'
gas_reports = ["*"]
optimize = false # set to true to enable optimizer
via_ir = false # set to true to enable IR compiler
solc = '0.8.17'
fs_permissions = [{ access = "read-write", path = "./addresses/"}, { access ="read", path="./out/"}]
solc = '0.8.19'
gas_reports = ["*"]
ffi = true

[profile.prod]
optimize = true
optimizer_runs = 40000
via_ir = true
optimizer_runs = 20000

[rpc_endpoints]
fuji = "${FUJI_RPC_URL}"
Expand All @@ -25,3 +23,9 @@ mumbai = "${MUMBAI_RPC_URL}"
[etherscan]
fuji = { key = "${SNOWTRACE_API_KEY}" }
mumbai = { key = "${POLYSCAN_API_KEY}" }

[fmt]
line_length = 120
multiline_func_header = "params_first"
number_underscore="thousands"
# handle sorting of imports
1 change: 0 additions & 1 deletion lib/aa-passkeys-wallet
Submodule aa-passkeys-wallet deleted from 3607aa
2 changes: 1 addition & 1 deletion lib/account-abstraction
Submodule account-abstraction updated 63 files
+2 −1 .solcover.js
+ audits/EIP_4337_–_Ethereum_Account_Abstraction_Incremental_Audit_Feb_2023.pdf
+24 −13 contracts/core/BaseAccount.sol
+15 −4 contracts/core/EntryPoint.sol
+16 −0 contracts/core/Helpers.sol
+40 −0 contracts/core/NonceManager.sol
+8 −1 contracts/interfaces/IEntryPoint.sol
+27 −0 contracts/interfaces/INonceManager.sol
+23 −16 contracts/interfaces/UserOperation.sol
+1 −1 contracts/package.json
+2 −13 contracts/samples/SimpleAccount.sol
+47 −20 contracts/samples/VerifyingPaymaster.sol
+61 −0 contracts/samples/callback/TokenCallbackHandler.sol
+32 −1 contracts/samples/gnosis/EIP4337Fallback.sol
+28 −18 contracts/samples/gnosis/EIP4337Manager.sol
+3 −2 contracts/test/MaliciousAccount.sol
+6 −0 deploy/2_deploy_SimpleAccountFactory.ts
+1 −0 deployments/arbitrum/.chainId
+1,318 −0 deployments/arbitrum/EntryPoint.json
+68 −0 deployments/arbitrum/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+1 −0 deployments/gnosis/.chainId
+1,318 −0 deployments/gnosis/EntryPoint.json
+68 −0 deployments/gnosis/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+646 −427 deployments/goerli/EntryPoint.json
+0 −408 deployments/goerli/SimpleWallet.json
+0 −138 deployments/goerli/TestCounter.json
+0 −86 deployments/goerli/solcInputs/9255faacf3ae4e81db1326413027bfa0.json
+68 −0 deployments/goerli/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+0 −122 deployments/goerli/solcInputs/a58a7c922040a77213173e74ee727845.json
+0 −122 deployments/goerli/solcInputs/a9230f4fbd9f8bb927fc904125f37781.json
+0 −122 deployments/goerli/solcInputs/ca8360c2ec2d44ef9859dfd0bed61fc1.json
+0 −104 deployments/goerli/solcInputs/ff55e3c34716cae656c07df27230c239.json
+1 −0 deployments/mainnet/.chainId
+1,318 −0 deployments/mainnet/EntryPoint.json
+107 −0 deployments/mainnet/SimpleAccountFactory.json
+329 −0 deployments/mainnet/solcInputs/02113a2ed1850c3774563305ee607f11.json
+68 −0 deployments/mainnet/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+59 −0 deployments/mainnet/solcInputs/cfbebdf1101dd2bc0f310cb0b7d62cb7.json
+1 −0 deployments/matic/.chainId
+1,318 −0 deployments/matic/EntryPoint.json
+68 −0 deployments/matic/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+59 −0 deployments/matic/solcInputs/cfbebdf1101dd2bc0f310cb0b7d62cb7.json
+1 −0 deployments/mumbai/.chainId
+1,318 −0 deployments/mumbai/EntryPoint.json
+68 −0 deployments/mumbai/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+1 −0 deployments/optimism/.chainId
+1,318 −0 deployments/optimism/EntryPoint.json
+68 −0 deployments/optimism/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+1 −0 deployments/sepolia/.chainId
+1,318 −0 deployments/sepolia/EntryPoint.json
+68 −0 deployments/sepolia/solcInputs/a4c52f0671aad8941c53d6ead2063803.json
+34 −22 eip/EIPS/eip-4337.md
+35 −9 gascalc/GasChecker.ts
+2 −2 hardhat.config.ts
+4 −4 package.json
+20 −16 reports/gas-checker.txt
+26 −67 test/UserOp.ts
+90 −8 test/entrypoint.test.ts
+26 −9 test/gnosis.test.ts
+20 −15 test/simple-wallet.test.ts
+27 −8 test/verifying_paymaster.test.ts
+1 −2 test/y.bls.test.ts
+338 −435 yarn.lock
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
"test": "forge test FOUNDRY_PROFILE=test -vvvv ",
"gas": "yarn test --gas-report ",
"relay": "yarn ts-node services/oz-defender/autotasks/scripts/test/relay-user-op.ts",
"deploy": "func () forge script script/deploy/$1.s.sol:$1 --rpc-url $(grep $2'_RPC_URL' .env | cut -d '=' -f2) --chain-id $(grep $2'_CHAIN_ID' .env | cut -d '=' -f2) --private-key $(grep $2'_PRIVATE_KEY' .env | cut -d '=' -f2) --etherscan-api-key $(grep $2'_EXPLORER_API_KEY' .env | cut -d '=' -f2) --verify $(if [ $3 = 'b' ]; then echo '--broadcast'; fi); func"
"deploy": "func () forge script script/deploy/$1.s.sol:$1 --rpc-url $(grep $2'_RPC_URL' .env | cut -d '=' -f2) --chain-id $(grep $2'_CHAIN_ID' .env | cut -d '=' -f2) --private-key $(grep $2'_PRIVATE_KEY' .env | cut -d '=' -f2) --etherscan-api-key $(grep $2'_EXPLORER_API_KEY' .env | cut -d '=' -f2) $(if [ $3 = 'b' ]; then echo '--verify --broadcast'; fi); func"
}
}
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ forge-std/=lib/forge-std/src/
@solbase=lib/solbase/src/
@erc4337=lib/account-abstraction/contracts
@safe=lib/safe-contracts/contracts/
@aa-passkeys-wallet/=lib/aa-passkeys-wallet/src/

@openzeppelin/=node_modules/@openzeppelin/

Expand Down
43 changes: 43 additions & 0 deletions script/deploy/FclEllipticDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script2} from "../../lib/foundry-deployment-manager/src/utils/Script2.sol";

import {console} from "forge-std/console.sol";

contract FclEllipticDeployer is Script2 {
function run() public {
address localBroadcaster;
address contractAddress;
string memory chainName;

// TODO improve this
if (block.chainid == 137) {
chainName = "POLYGON";
} else if (block.chainid == 80001) {
chainName = "MUMBAI";
}

string memory pkEnvVar = string.concat(chainName, "_PRIVATE_KEY");
try vm.envUint(pkEnvVar) returns (uint256 key) {
localBroadcaster = vm.rememberKey(key);
} catch {
console.log("%s key not found or not parseable as uint", pkEnvVar);
}

vm.startBroadcast(localBroadcaster);

// No longer using external validator
bytes memory deploymentBytecode = vm.getCode("FCL_Elliptic_ZZ.sol:FCL_Elliptic_ZZ");

console.logBytes(deploymentBytecode);

assembly {
contractAddress := create2(0, add(deploymentBytecode, 0x20), mload(deploymentBytecode), 0)
}

vm.stopBroadcast();

console.log("Elliptic library deployed at %s", contractAddress);
}
}
37 changes: 19 additions & 18 deletions script/deploy/ForumAccountDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {ForumAccount} from '../../src/erc4337-account/ForumAccount.sol';
import {DeploymentSelector} from '../../lib/foundry-deployment-manager/src/DeploymentSelector.sol';
import {ForumAccount} from "../../src/erc4337-account/ForumAccount.sol";
import {DeploymentSelector} from "../../lib/foundry-deployment-manager/src/DeploymentSelector.sol";

/**
* @dev This contract is used to deploy the ForumAccount contract
* For now this must be run before the ERC4337FactoryDeployer
* Improvements to the deployment manager will allow this to be run in any order
*/
contract ForumAccountDeployer is DeploymentSelector {
ForumAccount internal account;
ForumAccount internal account;

function run() public {
innerRun();
outputDeployment();
}
// TODO improve the linking of this lib
address internal constant FCL_ELLIPTIC_ZZ = 0xbb93A0Ca0EDb4a726f37433993ED22376CD8387a;

function innerRun() public {
startBroadcast();
function run() public {
innerRun();
outputDeployment();
}

// No longer using external validator
bytes memory initData = new bytes(0);
function innerRun() public {
startBroadcast();

(address contractAddress, bytes memory deploymentBytecode) = SelectDeployment(
'ForumAccount',
initData
);
// No longer using external validator
bytes memory initData = abi.encode(FCL_ELLIPTIC_ZZ);

fork.set('ForumAccount', contractAddress, deploymentBytecode);
// ! ENSURE UPDATED VERSION IS SET ON CONTRACT
(address contractAddress, bytes memory deploymentBytecode) = SelectDeployment("ForumAccount", initData);

stopBroadcast();
}
fork.set("ForumAccount", contractAddress, deploymentBytecode);

stopBroadcast();
}
}
85 changes: 60 additions & 25 deletions script/deploy/ForumAccountFactoryDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -1,44 +1,79 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {ForumAccount} from '../../src/erc4337-account/ForumAccount.sol';
import {ForumAccountFactory} from '../../src/erc4337-account/ForumAccountFactory.sol';
import {ForumAccount} from "../../src/erc4337-account/ForumAccount.sol";
import {ForumAccountFactory} from "../../src/erc4337-account/ForumAccountFactory.sol";

import {DeploymentSelector} from '../../lib/foundry-deployment-manager/src/DeploymentSelector.sol';
import {DeploymentSelector} from "../../lib/foundry-deployment-manager/src/DeploymentSelector.sol";

/**
* @dev This contract is used to deploy the ForumAccountFactory contract
* For now this must be run after the ForumAccountDeployer
* Improvements to the deployment manager will allow this to be run in any order
*/
contract ForumAccountFactoryDeployer is DeploymentSelector {
address internal forumAccountSingleton;
address internal entryPoint = 0x0576a174D229E3cFA37253523E645A78A0C91B57;
address internal gnosisFallbackHandler = 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4;
// New singleton deployed in previous script
address internal forumAccountSingleton;

function run() public {
innerRun();
outputDeployment();
}
// ! ENSURE THIS IS THE CORRECT ADDRESS FOR LATEST VERSION
address internal entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // v6 entry point

function innerRun() public {
startBroadcast();
address internal gnosisFallbackHandler = 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4;

forumAccountSingleton = fork.get('ForumAccount');
function run() public {
innerRun(); //outputDeployment();
}

bytes memory initData = abi.encode(
forumAccountSingleton,
entryPoint,
gnosisFallbackHandler
);
function innerRun() public {
startBroadcast();

(address contractAddress, bytes memory deploymentBytecode) = SelectDeployment(
'ForumAccountFactory',
initData
);
// ! ENSURE UPDATED VERSION IS SET ON CONTRACT
forumAccountSingleton = fork.get("ForumAccount");

fork.set('ForumAccountFactory', contractAddress, deploymentBytecode);
address contractAddress;
bytes memory deploymentBytecode;
bytes memory initData;

stopBroadcast();
}
if (block.chainid == 137) {
// First deploy staging
initData = abi.encode(
forumAccountSingleton,
entryPoint,
gnosisFallbackHandler,
hex"03b6d35a71a78c74371a51a07459cb30b03a4cbea9885c8b656dd84e4175bce11d00000000",
'{"type":"webauthn.get","challenge":"',
'","origin":"https://staging.forumdaos.com"}'
);
(contractAddress, deploymentBytecode) = SelectDeployment("ForumAccountFactory", initData);

// Then deploy production
initData = abi.encode(
forumAccountSingleton,
entryPoint,
gnosisFallbackHandler,
hex"15fb388e36f88f11a3606dc4effb11f6a645d5c315366bdc62002118c776cea41d00000000",
'{"type":"webauthn.get","challenge":"',
'","origin":"https://forumdaos.com"}'
);

// Overwrite the staging address as we will take it from console for now, prod is more important to write
(contractAddress, deploymentBytecode) = SelectDeployment("ForumAccountFactory", initData);
} else {
// Deploy development
initData = abi.encode(
forumAccountSingleton,
entryPoint,
gnosisFallbackHandler,
hex"1584482fdf7a4d0b7eb9d45cf835288cb59e55b8249fff356e33be88ecc546d11d00000000",
'{"type":"webauthn.get","challenge":"',
'","origin":"https://development.forumdaos.com"}'
);

(contractAddress, deploymentBytecode) = SelectDeployment("ForumAccountFactory", initData);
}

fork.set("ForumAccountFactory", contractAddress, deploymentBytecode);

stopBroadcast();
}
}
41 changes: 21 additions & 20 deletions script/deploy/ForumGroupDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {ForumGroup} from '../../src/erc4337-group/ForumGroup.sol';
import {DeploymentSelector} from '../../lib/foundry-deployment-manager/src/DeploymentSelector.sol';
import {ForumGroup} from "../../src/erc4337-group/ForumGroup.sol";
import {DeploymentSelector} from "../../lib/foundry-deployment-manager/src/DeploymentSelector.sol";

/**
* @dev This contract is used to deploy the ForumGroup contract
* For now this must be run before the ForumGroupFactoryDeployer
* Improvements to the deployment manager will allow this to be run in any order
*/
contract ForumGroupDeployer is DeploymentSelector {
address internal forumAccountSingleton;
ForumGroup internal forumGroup;
address internal forumAccountSingleton;
ForumGroup internal forumGroup;

function run() public {
innerRun();
outputDeployment();
}
// TODO improve the linking of this lib
address internal constant FCL_ELLIPTIC_ZZ = 0xbb93A0Ca0EDb4a726f37433993ED22376CD8387a;

function innerRun() public {
startBroadcast();
function run() public {
innerRun();
outputDeployment();
}

forumAccountSingleton = fork.get('ForumAccount');
function innerRun() public {
startBroadcast();

// No longer using external validator
bytes memory initData = abi.encode(forumAccountSingleton);
// ! ENSURE UPDATED VERSION IS SET ON CONTRACT
forumAccountSingleton = fork.get("ForumAccount");

(address contractAddress, bytes memory deploymentBytecode) = SelectDeployment(
'ForumGroup',
initData
);
// No longer using external validator
bytes memory initData = abi.encode(forumAccountSingleton, FCL_ELLIPTIC_ZZ);

fork.set('ForumGroup', contractAddress, deploymentBytecode);
(address contractAddress, bytes memory deploymentBytecode) = SelectDeployment("ForumGroup", initData);

stopBroadcast();
}
fork.set("ForumGroup", contractAddress, deploymentBytecode);

stopBroadcast();
}
}
Loading

0 comments on commit ff6a7a0

Please sign in to comment.