Skip to content

Commit

Permalink
UncommittedDB of PEVM shutdown when an invalid snapshot id found (jus…
Browse files Browse the repository at this point in the history
…t like the StateDB do)
  • Loading branch information
andyzhang2023 committed Oct 25, 2024
1 parent 92b2317 commit 938ac30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions core/state/pevm_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,6 @@ func (j *ujournal) append(st ustate) {
}

func (j *ujournal) revertTo(db *UncommittedDB, snapshot int) {
if snapshot < 0 || snapshot >= len(*j) {
return // invalid snapshot index
}
for i := len(*j) - 1; i >= snapshot; i-- {
(*j)[i].revert(db)
}
Expand Down
4 changes: 3 additions & 1 deletion core/state/pevm_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,10 @@ func (pst *UncommittedDB) AddSlotToAccessList(addr common.Address, slot common.H

// ===============================================
// Snapshot Methods
// (is it necessary to do snapshot and revert ?)
func (pst *UncommittedDB) RevertToSnapshot(id int) {
if id < 0 || id > len(pst.journal) {
panic(fmt.Sprintf("invalid snapshot index, out of range, snapshot:%d, len:%d", id, len(pst.journal)))
}
pst.journal.revertTo(pst, id)
}
func (pst *UncommittedDB) Snapshot() int {
Expand Down

0 comments on commit 938ac30

Please sign in to comment.