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

Add generic validator recovery module and update zk email contracts to use it #2

Merged
merged 20 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6b6e31d
Add validator recovery module and update zk email contracts
JohnGuilding Jun 6, 2024
531a49a
subject calldata builder
JohnGuilding Jun 9, 2024
6aac792
Use recovery subject handlers
JohnGuilding Jun 11, 2024
71fe6c7
feat: use calldata slicing in module
zeroknots Jun 13, 2024
9c7bade
feat: readability
zeroknots Jun 13, 2024
8cc744b
fix: make email_recovery internal since there is an external getter f…
zeroknots Jun 13, 2024
72057f1
feat: minor coding best practice improvement
zeroknots Jun 13, 2024
4dd50b4
Merge pull request #4 from zeroknots/feature/zeroknots-suggestions
JohnGuilding Jun 13, 2024
03581ca
Move guardian logic to library
JohnGuilding Jun 13, 2024
87fbb7e
Restructure manager & cancelRecovery bytes param
JohnGuilding Jun 13, 2024
fa1f0e8
recovery module can support many validators per account POC
JohnGuilding Jun 13, 2024
b039f8a
Remove hex strings library and dynamically generate test subject
JohnGuilding Jun 13, 2024
a6eb46d
Update factory
JohnGuilding Jun 14, 2024
192cc7a
Move TemplateIndex check
JohnGuilding Jun 14, 2024
4668516
Add module installation check
JohnGuilding Jun 14, 2024
360a2a1
Separation of concerns between lower and higher level guardian libraries
JohnGuilding Jun 14, 2024
3626aef
Support new email auth & store module at initialization
JohnGuilding Jun 14, 2024
f0df1d8
Reorder mapping
JohnGuilding Jun 14, 2024
c035b84
Comment out tests to come back to in a later PR
JohnGuilding Jun 14, 2024
f13e93c
Update workflows
JohnGuilding Jun 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:

jobs:
build:
uses: "./.github/workflows/forge-build.yml"
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-build.yaml@main"

test:
needs: ["build"]
uses: "./.github/workflows/forge-test.yml"
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test"
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ It is strongly recommended that configureRecovery is called during the installat

```ts
function configureRecovery(
address recoveryModule,
address[] memory guardians,
uint256[] memory weights,
uint256 threshold,
Expand Down
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ ignored_warnings_from = [
]

[rpc_endpoints]
baseSepolia = "${BASE_SEPOLIA_RPC_URL}"
sepolia = "${BASE_SEPOLIA_RPC_URL}"

[etherscan]
baseSepolia = { key = "${BASE_SCAN_API_KEY}" }
sepolia = { key = "${BASE_SCAN_API_KEY}" }

[fmt]
bracket_spacing = true
Expand Down
14 changes: 11 additions & 3 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@
pragma solidity ^0.8.25;

import { Script } from "forge-std/Script.sol";
import { ZkEmailRecovery } from "src/ZkEmailRecovery.sol";
import { EmailRecoverySubjectHandler } from "src/handlers/EmailRecoverySubjectHandler.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol";

contract DeployScript is Script {
function run() public {
bytes32 salt = bytes32(uint256(0));

address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998;
address ecdsaOwnedDkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748;

vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

new ZkEmailRecovery{ salt: salt }(verifier, ecdsaOwnedDkimRegistry, emailAuthImpl);
EmailRecoverySubjectHandler emailRecoveryHandler = new EmailRecoverySubjectHandler();

EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager{ salt: salt }(
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
);

new EmailRecoveryModule(address(emailRecoveryManager));

vm.stopBroadcast();
}
Expand Down
17 changes: 11 additions & 6 deletions script/DeploySafeRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@
pragma solidity ^0.8.25;

import { Script } from "forge-std/Script.sol";
import { SafeZkEmailRecovery } from "src/SafeZkEmailRecovery.sol";
import { SafeRecoveryModule } from "src/modules/SafeRecoveryModule.sol";
import { SafeRecoverySubjectHandler } from "src/handlers/SafeRecoverySubjectHandler.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol";

contract DeploySafeRecoveryScript is Script {
function run() public {
bytes32 salt = bytes32(uint256(0));

address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998;
address ecdsaOwnedDkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;

Choose a reason for hiding this comment

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

For production/mainnet deploys, you may want to switch this to the user overrideable registry by default https://github.com/zkemail/zk-email-verify/blob/main/packages/contracts/UserOverrideableDKIMRegistry.sol

address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748;

vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

SafeZkEmailRecovery safeZkEmailRecovery =
new SafeZkEmailRecovery{ salt: salt }(verifier, ecdsaOwnedDkimRegistry, emailAuthImpl);
new SafeRecoveryModule(address(safeZkEmailRecovery));
SafeRecoverySubjectHandler emailRecoveryHandler = new SafeRecoverySubjectHandler();

EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager(
verifier, dkimRegistry, emailAuthImpl, address(emailRecoveryHandler)
);

new EmailRecoveryModule(address(emailRecoveryManager));

vm.stopBroadcast();
}
Expand Down
67 changes: 0 additions & 67 deletions src/EmailAccountRecoveryRouter.sol

This file was deleted.

29 changes: 29 additions & 0 deletions src/EmailRecoveryFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import { EmailRecoveryManager } from "./EmailRecoveryManager.sol";
import { EmailRecoveryModule } from "./modules/EmailRecoveryModule.sol";
import { EmailRecoverySubjectHandler } from "./handlers/EmailRecoverySubjectHandler.sol";

contract EmailRecoveryFactory {
function deployModuleAndManager(
address verifier,
address dkimRegistry,
address emailAuthImpl,
address emailRecoveryHandler
)
external
returns (address, address)
{
EmailRecoveryManager emailRecoveryManager =
new EmailRecoveryManager(verifier, dkimRegistry, emailAuthImpl, emailRecoveryHandler);
address manager = address(emailRecoveryManager);

EmailRecoveryModule emailRecoveryModule = new EmailRecoveryModule(manager);
address module = address(emailRecoveryModule);

emailRecoveryManager.initialize(module);

return (manager, module);
}
}
Loading