Skip to content

Commit

Permalink
Fix decommitment on out-of-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed Aug 27, 2024
1 parent d2405bc commit aebf23c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/decommit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ impl WorldDiff {
decommit: UnpaidDecommit,
gas: &mut u32,
) -> Option<Program> {
// We intentionally record a decommitment event even if actual decommitment never happens because of an out-of-gas error.
// This is how the old VM behaves.
self.decommitted_hashes.insert(decommit.code_key, ());

if decommit.cost > *gas {
// Unlike all other gas costs, this one is not paid if low on gas.
return None;
}
*gas -= decommit.cost;
self.decommitted_hashes.insert(decommit.code_key, ());
Some(world.decommit(decommit.code_key))
}
}
Expand Down

0 comments on commit aebf23c

Please sign in to comment.