Skip to content

Commit

Permalink
fix ut issue
Browse files Browse the repository at this point in the history
fix the ut issue by avoid pollute the pst.cache when append journal
  • Loading branch information
sunny2022da committed Jan 9, 2025
1 parent e109b4e commit 7db8b0b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/state/pevm_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,25 +169,27 @@ func (pst *UncommittedDB) Prepare(rules params.Rules, sender, coinbase common.Ad
// 2. object

func (pst *UncommittedDB) SubBalance(addr common.Address, amount *uint256.Int) {
obj := pst.getOrNewObject(addr)
if amount.IsZero() {
obj := pst.getOrNewObject(addr)
if !obj.empty(pst) {
return
}
}
pst.journal.append(newJBalance(pst.cache[addr], addr))
obj := pst.getOrNewObject(addr)
newb := new(uint256.Int).Sub(obj.balance, amount)
pst.cache.setBalance(addr, newb)
}

func (pst *UncommittedDB) AddBalance(addr common.Address, amount *uint256.Int) {
obj := pst.getOrNewObject(addr)
if amount.IsZero() {
obj := pst.getOrNewObject(addr)
if !obj.empty(pst) {
return
}
}
pst.journal.append(newJBalance(pst.cache[addr], addr))
obj := pst.getOrNewObject(addr)
newb := new(uint256.Int).Add(obj.balance, amount)
pst.cache.setBalance(addr, newb)
}
Expand Down

0 comments on commit 7db8b0b

Please sign in to comment.