feat: add view function for mint precompile allowlist#67
Conversation
Summary of ChangesHello @johnletey, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new read-only function to the mint precompile, allowing users to query the allowlist status of any given address. This enhancement improves transparency by providing a direct way to verify whether an account is permitted to perform minting operations, without altering the blockchain state. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new view function, allowlist(address), to the mint precompile. This allows users to check if an account is on the minting allowlist. The changes include updating the Solidity interface in the documentation and implementing the corresponding logic in the Rust precompile. My review identifies a key issue where the new view function can potentially modify state, which violates EVM conventions. I've provided a detailed comment and a code suggestion to address this. The rest of the changes, including documentation, are correct and consistent.
| INativeToken::INativeTokenCalls::allowlist(call) => { | ||
| let is_allowed = Self::is_allowlisted(internals, call.account)?; | ||
| let result = is_allowed.abi_encode(); | ||
| Ok(PrecompileOutput::new(0, result.into())) | ||
| } |
There was a problem hiding this comment.
The allowlist function is declared as view in the Solidity interface, which implies it must not modify blockchain state. The current implementation calls Self::is_allowlisted, which in turn calls Self::ensure_account_created. This can cause a state modification by creating the precompile's account if it doesn't already exist. This side effect violates the read-only guarantee of a view function and can lead to inconsistent behavior across different EVM clients and tools.
To fix this, the read-only logic from is_allowlisted should be inlined here, avoiding the state-mutating call. For consistent logging, you should also duplicate the tracing::debug! call from is_allowlisted.
INativeToken::INativeTokenCalls::allowlist(call) => {
// This is a view function; avoid state modifications from `is_allowlisted`.
let key = Self::allowlist_key(call.account);
let value = internals
.sload(MINT_PRECOMPILE_ADDR, key)
.map_err(Self::map_internals_error)?;
let is_allowed = !value.is_zero();
let result = is_allowed.abi_encode();
Ok(PrecompileOutput::new(0, result.into()))
}
Description
Type of Change
Related Issues
Fixes #(issue)
Checklist
Testing
Additional Notes