-
Notifications
You must be signed in to change notification settings - Fork 59
feat: add Precompiles trait #689
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files
|
/// Precompile primitives. | ||
pub mod primitives { | ||
/// The ecrecover precompile primitives. | ||
/// | ||
/// This module provides the cryptographic primitives needed for the | ||
/// `ecrecover` precompile, which recovers the signer address from an | ||
/// ECDSA signature and message hash. | ||
/// | ||
/// Re-exports selected ECDSA types and constants specifically relevant | ||
/// to the ecrecover operation. | ||
pub mod ecrecover { | ||
pub use crate::utils::cryptography::ecdsa::{ | ||
ECDSAInvalidSignature, ECDSAInvalidSignatureS, EcRecoverData, | ||
Error, ECRECOVER_ADDR, SIGNATURE_S_UPPER_BOUND, | ||
}; | ||
} | ||
} |
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.
Didn't remove utils::cryptography::ecdsa
for two reasons:
- The original crate can be expanded to include additional ECDSA-related operations, which have nothing to do with ecrecover precompile; the crate would be useful to devs as a standalone.
- Backward compatibility.
The mod primitives
module is used to make it clear to devs where to find relevant precompile-related types, constants, enums etc.
In this specific case, the reason for this reexport is that it should be easier for the average Stylus developer to understand that the relevant ecrecover primitives are in the same module, i.e. precompiles::primitives::ecrecover
, than that they should actually import them from a completely different module utils::cryptography::ecdsa
.
CI should be fixed by #690 |
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 like the idea, but my main concern is that we are not able to build common interface (trait
) for all the precompiles. IMHO each precompile is specific, and I do not see a way how we can handle it.
The idea is that each new precompile has its own function within Can you think of any precompile that would not work with this approach? |
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 think I may like the solution but please provide a refactor to our contracts too with the new precompile (Erc20Permit).
Co-authored-by: Daniel Bigos <[email protected]>
That's already done:
@bidzyyys if both you and @qalisander support this approach, I'll update CHANGELOG and docs |
Proposal for unifying all precompiles in a single extension trait that can be more ergonomically invoked on contracts.
PR Checklist