-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
In my thought, callData in mail subject is not user-friendly. How about the following implementation? I'd like to know what do you think Add public mapping for function that user wants to request
Add public mapping for param indexes that user wants to use with the above function
Add callFuntionName into arguments of configureRecovery function
Add callParamIndexes into arguments of configureRecovery function
Regarding accountIndex. At this time, I think accountIndex is always 0 it’s fine. Build callParams in processRecovery function
Build callData in processRecovery function
|
Summary of Technical Discussion PointsSome key discussion points, summarised in this PR for visibility. Originally scaffolded by chapgpt Indexing Templates by Account AddressContextAllow templates to be indexed by an account address (could also be indexed by module address), negating need for hardcoded subjects and making ZkEmailRecovery.sol generic. Relevant LinksResolution 11/06Decided against to keep Storing Templates in a RegistryContextSuggested by Rhinestone. An attestation flow could be used to maintain the subject templates. Storing them per module and not per smart account could make it easier for the user to opt-in Relevant LinksResolution 11/06Decided against to keep Adding Account Address to
|
should allow the removal of BytesLib. less code to be audited foo
@@ -33,9 +33,8 @@ interface IZkEmailRecovery { | |||
uint256 executeAfter; // the timestamp from which the recovery request can be executed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using uint48
here. would allow packing both executeAfter
and executeBefore
into one slot. since these are sloaded together
I quite like the new design of initializing |
}); | ||
} | ||
|
||
function allowValidatorRecovery( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good to add a set/remove function for the recovery allowedSelectors after installation as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree will add that
src/modules/EmailRecoveryModule.sol
Outdated
|
||
mapping(address validatorModule => mapping(address account => bytes4 allowedSelector)) internal | ||
allowedSelectors; | ||
mapping(address account => address validator) internal validators; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is just for PoC and in the final version we will support multiple validators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - just pushed an initial commit for this. It's a little messy with multiple mappings but wanted to push something as a POC.
Let me know if you can think of any cleaner ways of doing this
small improvements for readability and gas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor post-merge suggestions, didn't see anything major. Like the continued breakup of recovery flow into more standardized components 👍
|
||
contract DeploySafeRecoveryScript is Script { | ||
function run() public { | ||
bytes32 salt = bytes32(uint256(0)); | ||
|
||
address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998; | ||
address ecdsaOwnedDkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78; | ||
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78; |
There was a problem hiding this comment.
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
require(templateId == emailAuthMsg.templateId, "invalid template id"); | ||
require(emailAuthMsg.proof.isCodeExist == true, "isCodeExist is false"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason require
s are used in this file instead of error
s? Would be good to be consistent, and can use error param data to include expected vs actual to aid in debugging.
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
interface IEmailRecoverySubjectHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstrings/natspec on this would be helpful for implementers & for understanding implementations above ^
No description provided.