Skip to content

Commit

Permalink
Fix incorrect accounting in nested contract calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
abizjak committed Aug 15, 2022
1 parent 5672885 commit ee0c7c5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions concordium-consensus/src/Concordium/Scheduler/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,16 +1043,13 @@ instance (MonadProtocolVersion m, StaticInformation m, AccountOperations m, Cont
Nothing -> return $ netDeposit - max oldLockedUp staked

{-# INLINE getCurrentContractAmount #-}
getCurrentContractAmount sv inst = do
let amnt = iiBalance inst
getCurrentContractAmount _ inst = do
let addr = _instanceAddress . iiParameters $ inst
case sv of
Wasm.SV0 -> use (changeSet . instanceV0Updates . at addr) >>= \case
Just (_, delta, _) -> return $! applyAmountDelta delta amnt
Nothing -> return amnt
Wasm.SV1 -> use (changeSet . instanceV1Updates . at addr) >>= \case
Just (_, delta, _) -> return $! applyAmountDelta delta amnt
Nothing -> return amnt
getCurrentContractInstance addr >>= \case
Nothing -> error "Precondition violation."
Just ist -> case ist of
InstanceInfoV0 ii -> return (iiBalance ii)
InstanceInfoV1 ii -> return (iiBalance ii)

{-# INLINE getEnergy #-}
getEnergy = do
Expand Down

0 comments on commit ee0c7c5

Please sign in to comment.