refactor(precompile): do not execute write functions on staticcall#3001
refactor(precompile): do not execute write functions on staticcall#3001
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request focus on the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Contract
participant EVM
User->>Contract: Call Run(evm, contract, readOnly)
alt readOnly is true
Contract->>Contract: Check operation type
alt Stake/Unstake/MoveStake
Contract-->>User: Error: Operation not allowed in read-only mode
else GetAllValidators/GetShares
Contract-->>User: Return data
end
else readOnly is false
Contract->>Contract: Execute operation
Contract-->>User: Return result
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- precompiles/staking/staking.go (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
precompiles/staking/staking.go (1)
Pattern
**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
🔇 Additional comments (1)
precompiles/staking/staking.go (1)
383-383: Ensure Interface Compliance When Modifying Method SignaturesThe
Runmethod is part of thePrecompiledContractinterface. By changing the parameter from_toreadOnlyand utilizing it within the method, ensure that this modification does not break the interface contract. Verify that all implementations of the interface and all calls to this method are updated accordingly.
aad0f0f to
715d729
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3001 +/- ##
===========================================
- Coverage 66.05% 66.02% -0.04%
===========================================
Files 397 397
Lines 22313 22337 +24
===========================================
+ Hits 14739 14747 +8
- Misses 6806 6816 +10
- Partials 768 774 +6
|
Description
Minor refactor, not associated to any issue or changelog. This is part of the preparation work before introducing the distribute functions.
The EVM marks
staticcallas a readOnly low-level call, with this PR we avoid running write methods through static calls.How Has This Been Tested?
Summary by CodeRabbit
New Features
Bug Fixes