Skip to content

Commit

Permalink
[hardening] fix bug on conservation checks recovery path
Browse files Browse the repository at this point in the history
As the comment indicated, we need to dump the writes before attempting to recover and re-charge for gas. Failing to do this was tripping an assertion in `charge_gas`.
  • Loading branch information
sblackshear committed Apr 10, 2023
1 parent 8ac8606 commit 3c6aa51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/sui-adapter/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ fn execute_transaction<
// conservation violated. try to avoid panic by dumping all writes, charging for gas, re-checking
// conservation, and surfacing an aborted transaction with an invariant violation if all of that works
result = Err(conservation_err);
temporary_store.reset(gas, &mut gas_status);
temporary_store.charge_gas(gas_object_id, &mut gas_status, &mut result, gas);
// check conservation once more more. if we still fail, it's a problem with gas
// charging that happens even in the "aborted" case--no other option but panic.
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/temporary_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl<S> TemporaryStore<S> {

/// Resets any mutations, deletions, and events recorded in the store, as well as any storage costs and
/// rebates, then Re-runs gas smashing. Effects on store are now as if we were about to begin execution
fn reset(&mut self, gas: &[ObjectRef], gas_status: &mut SuiGasStatus<'_>) {
pub fn reset(&mut self, gas: &[ObjectRef], gas_status: &mut SuiGasStatus<'_>) {
self.drop_writes();
gas_status.reset_storage_cost_and_rebate();

Expand Down

0 comments on commit 3c6aa51

Please sign in to comment.