feat(precompiles): storage delta helpers#5605
Conversation
497d547 to
4f5da22
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
4f5da22 to
92759de
Compare
📊 Tempo Precompiles CoverageprecompilesCoverage: 5820/9099 lines (63.96%) File details
contractsCoverage: 1/168 lines (0.60%) File details
Total: 5821/9267 lines (62.81%) |
92759de to
918cf68
Compare
918cf68 to
b9a6ddf
Compare
👁️ Cyclops Security Review
🧭 Audit failed · mode=
Findings
⚙️ Controls
📜 24 events🔍 |
| let collected_fees = self.collected_fees.at_mut(&validator).at_mut(&token); | ||
| let slot = collected_fees.slot(); | ||
| collected_fees.sinc(slot, amount)?; |
There was a problem hiding this comment.
can we maybe have a helper on Slot<U256> for this? i do like the collected_fees[validator][token] API
| let balance = self.balances.at_mut(&account); | ||
| let slot = balance.slot(); | ||
| balance.sinc(slot, amount).map_err(|err| { | ||
| if err == TempoPrecompileError::under_overflow() { | ||
| TIP20Error::supply_cap_exceeded().into() | ||
| } else { | ||
| err | ||
| } | ||
| }) |
legion2002
left a comment
There was a problem hiding this comment.
👁️ Cyclops Review
Manual consolidation for the failed Cyclops workflows on PR #5605. I only reposted the latest verified finding that still applies to current head b9a6ddf; no older 4f5da225 findings were reposted.
| .ok_or(TempoPrecompileError::under_overflow())?; | ||
|
|
||
| self.set_balance(from, new_from_balance)?; | ||
| self.decrement_balance(from, amount)?; |
There was a problem hiding this comment.
_transfer balance pre-check removal lets rewards accounting turn insufficient balance into a Panic
The PR removes the up-front from balance check and now relies on decrement_balance to map storage underflow back into TIP20Error::insufficient_balance. That mapping happens only here, after handle_rewards_on_transfer(from, to.target, amount) has already run. For an opted-in sender that transfers more than its balance to a non-opted-in recipient, rewards accounting can subtract amount from opted_in_supply first; when amount exceeds the opted-in supply, that path returns TempoPrecompileError::under_overflow(), which is encoded as Solidity Panic(0x11) and treated as a system error instead of the expected TIP20 insufficient-balance error.
Recommended Fix:
Restore an explicit balance check before handle_rewards_on_transfer, or make handle_rewards_on_transfer receive the already-validated sender balance / post-debit amount so insufficient-balance transfers fail with TIP20Error::insufficient_balance before reward accounting can underflow.
Adds semantic
sinc/sdecstorage helpers and uses them for TIP-20 balance deltas and fee-manager accruals. The helpers intentionally return no post-delta value so callers cannot branch on intermediate delta results.They will be used for parallel execution in builder prewarming that outputs storage actions which can then be applied in serial builder loop.