Fix bugs of WorldVirtualState.Commit().
While it commits, it should wait for commitment of unrealized account,
because dependent transition will continue to access the account after
commitment of it.
@@ -364,13 +364,20 @@ func (wvs *worldVirtualState) Commit() {
return
}
- for _, las := range wvs.accountStates {
+ for id, las := range wvs.accountStates {
if las.lock == AccountWriteLock {
las.lock = AccountWriteUnlock
+ if las.depend != nil {
+ las.depend.WaitCommit()
+ las.state = las.depend.GetAccountROState([]byte(id))
+ las.base = las.state.GetSnapshot()
+ las.depend = nil
+ } else {
ass := las.state.GetSnapshot()
las.state = newAccountROState(ass)
}
}
+ }
if wvs.worldLock == AccountWriteLock {
wvs.worldLock = AccountWriteUnlock
