-
Notifications
You must be signed in to change notification settings - Fork 2
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
Nonce workarounds #39
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3251121
add relayer subwallets
efdbc20
bit more to test remove sub
b6bd2be
nit on test
38c81f5
nit on test 2
1a265e6
relayer signature-based verification
9357fc3
add signature used check mapping
276f02a
signature-based validation, mapping store
55301e7
get rid of subwallets
ef24f19
option 2: move mapping to state
b265c77
option 2: correct bug
20edf26
add basic signature skeleton
e4854ef
got signatures working
a90dea5
nonce-based replay protection (not sure this works)
6ce40ec
revert to explicit subwallets, address comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ contract ExpressRelayStorage { | |
struct State { | ||
// address of admin of express relay, handles setting fees and relayer role | ||
address admin; | ||
// address of relayer EOA uniquely permissioned to call ExpressRelay.multicall | ||
// address of primary relayer EOA, where relayer will ultimately receive fees | ||
address relayer; | ||
// store of relayer subwallets permissioned to call ExpressRelay.multicall | ||
address[] relayerSubwallets; | ||
// stores custom fee splits for protocol fee receivers | ||
mapping(address => uint256) feeConfig; | ||
// stores the flags for whether permission keys are currently allowed | ||
|
@@ -40,6 +42,23 @@ contract ExpressRelayState is IExpressRelay { | |
} | ||
|
||
modifier onlyRelayer() { | ||
if (msg.sender != state.relayer) { | ||
bool isSubwallet = false; | ||
for (uint i = 0; i < state.relayerSubwallets.length; i++) { | ||
if (state.relayerSubwallets[i] == msg.sender) { | ||
isSubwallet = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!isSubwallet) { | ||
revert Unauthorized(); | ||
} | ||
} | ||
_; | ||
} | ||
|
||
modifier onlyRelayerPrimary() { | ||
if (msg.sender != state.relayer) { | ||
revert Unauthorized(); | ||
} | ||
|
@@ -66,6 +85,7 @@ contract ExpressRelayState is IExpressRelay { | |
*/ | ||
function setRelayer(address relayer) public onlyAdmin { | ||
state.relayer = relayer; | ||
state.relayerSubwallets = new address[](0); | ||
} | ||
|
||
/** | ||
|
@@ -75,6 +95,50 @@ contract ExpressRelayState is IExpressRelay { | |
return state.relayer; | ||
} | ||
|
||
/** | ||
* @notice addRelayerSubwallet function - adds a relayer subwallet | ||
* | ||
* @param subwallet: address of the relayer subwallet to be added | ||
*/ | ||
function addRelayerSubwallet(address subwallet) public onlyRelayerPrimary { | ||
for (uint i = 0; i < state.relayerSubwallets.length; i++) { | ||
if (state.relayerSubwallets[i] == subwallet) { | ||
revert DuplicateRelayerSubwallet(); | ||
} | ||
} | ||
state.relayerSubwallets.push(subwallet); | ||
} | ||
|
||
/** | ||
* @notice removeRelayerSubwallet function - removes a relayer subwallet | ||
* | ||
* @param subwallet: address of the relayer subwallet to be removed | ||
*/ | ||
function removeRelayerSubwallet( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add docs for this function too |
||
address subwallet | ||
) public onlyRelayerPrimary { | ||
for (uint i = 0; i < state.relayerSubwallets.length; i++) { | ||
if (state.relayerSubwallets[i] == subwallet) { | ||
state.relayerSubwallets[i] = state.relayerSubwallets[ | ||
state.relayerSubwallets.length - 1 | ||
]; | ||
state.relayerSubwallets.pop(); | ||
break; | ||
} | ||
|
||
if (i == state.relayerSubwallets.length - 1) { | ||
revert RelayerSubwalletNotFound(); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @notice getRelayerSubwallets function - returns the relayer subwallets | ||
*/ | ||
function getRelayerSubwallets() public view returns (address[] memory) { | ||
return state.relayerSubwallets; | ||
} | ||
|
||
/** | ||
* @notice setFeeProtocolDefault function - sets the default fee split for the protocol | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please write some tests for this line of logic