fix: 🔧 account for storage reads on withdrawal (#407)

## Summary
ERC20 balances precompile `withdraw()` was failing to account for gas
costs associated with storage reads. In fact the function was calling
`usable_balance` without accounting for `record_db_read`.

## Changes
- Added `116 bytes` of storage read computed like this: `Blake2128(16) +
AccountId(20) + AccountInfo ((4 * 4) + AccountData(16 * 4))`, to cover
for `usable_balance`, following the same that `balance_of` does.
This commit is contained in:
Gonza Montiel 2026-01-21 16:25:57 -03:00 committed by GitHub
parent 41141124e7
commit fe2227ef53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -446,6 +446,9 @@ where
let account_amount: U256 = {
let owner: Runtime::AccountId =
Runtime::AddressMapping::into_account_id(handle.context().caller);
// frame_system::Account:
// Blake2128(16) + AccountId(20) + AccountInfo ((4 * 4) + AccountData(16 * 4))
handle.record_db_read::<Runtime>(116)?;
pallet_balances::Pallet::<Runtime, Instance>::usable_balance(&owner).into()
};