-
Notifications
You must be signed in to change notification settings - Fork 34
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
feat: add time range module #180
Conversation
ac6503a
to
ed7a64a
Compare
5da015e
to
4d83375
Compare
ed7a64a
to
d7b5b7f
Compare
|
||
import {BaseModule} from "../../modules/BaseModule.sol"; | ||
|
||
contract TimeRangeModule is IValidationHookModule, BaseModule { |
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.
Mind adding NatSpec documentation to our contracts?
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.
Added here: 5aeff4d
Lmk if anything's missing!
|
||
error TimeRangeNotValid(); | ||
|
||
function onInstall(bytes calldata data) external override { |
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.
Also @dev
comments in functions like these to describe how data should be encoded.
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.
Added!
Though I wonder if it would be preferable to put this info in an @param
instead?
4d83375
to
6273dfe
Compare
c278831
to
4265d1f
Compare
e54e9a1
to
4afc628
Compare
4265d1f
to
108d147
Compare
108d147
to
51d7377
Compare
Summary by OctaneNew Contracts
Updated ContractsNo contracts were updated in this PR. 🔗 Commit Hash: 51d7377 |
OverviewOctane AI analysis has finished. No vulnerabilities were found. Cheers! 🎉🎉🎉 🔗 Commit Hash: 51d7377 |
Contract sizes: | Contract | Size (B) | Margin (B) |
|------------------------------|----------|------------|
| AccountFactory | 4,169 | 20,407 |
| AllowlistModule | 5,817 | 18,759 |
| ERC20TokenLimitModule | 4,138 | 20,438 |
| ModularAccount | 25,983 | -1,407 |
| SemiModularAccount | 26,487 | -1,911 |
| SingleSignerValidationModule | 3,444 | 21,132 |
+| TimeRangeModule | 1,870 | 22,706 |
| TokenReceiverModule | 2,189 | 22,387 | Code coverage:
|
Motivation
We want the ability to limit validations by time range, for use in session keys and other modules.
Solution
Add a time range enforcing module. When used as a user op validation, this returns the time range in the 4337 validationData value. When used as a runtime validation, this checks
block.timestamp
and enforces that the validation is only used within this context.Also adds additional commands to
package.json
for viewing coverage and generating anlcov
report.Note: this currently doesn't enforce anything for signature validation. It is not clear to me whether or not it is safe to use
block.timestamp
in the signature checking logic, because if may be used within another account's 4337 validation phase. However, that entire workflow is not common due to the likely violation for associated storage.To discuss: should this hook check
block.timestamp
in the pre signature validation hook? Or should we just recommend users to disable signature validation from validation functions with this hook using the flag?