Skip to content

Commit 1cac52e

Browse files
author
megakabi
committed
fix checkpoint bug
1 parent a406862 commit 1cac52e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

crates/context/interface/src/journaled_state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ pub struct JournalCheckpoint {
252252
pub log_i: usize,
253253
/// Checkpoint to where on revert we will go back to and revert other journal entries.
254254
pub journal_i: usize,
255+
/// Refund value at the time of checkpoint creation.
256+
pub refund: i64,
255257
}
256258

257259
/// State load information that contains the data and if the account or storage is cold loaded

crates/context/src/journal/inner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ impl<ENTRY: JournalEntryTr> JournalInner<ENTRY> {
461461
let checkpoint = JournalCheckpoint {
462462
log_i: self.logs.len(),
463463
journal_i: self.journal.len(),
464+
refund: self.refund,
464465
};
465466
self.depth += 1;
466467
checkpoint
@@ -481,6 +482,9 @@ impl<ENTRY: JournalEntryTr> JournalInner<ENTRY> {
481482
self.depth -= 1;
482483
self.logs.truncate(checkpoint.log_i);
483484

485+
// Restore refund to checkpoint value
486+
self.refund = checkpoint.refund;
487+
484488
// iterate over last N journals sets and revert our global state
485489
self.journal
486490
.drain(checkpoint.journal_i..)

0 commit comments

Comments
 (0)