Skip to content

Commit

Permalink
txdag: add suicide checking logic;
Browse files Browse the repository at this point in the history
  • Loading branch information
galaio committed Sep 25, 2024
1 parent 542c9d6 commit 963c78d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion core/types/mvstates.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,24 @@ type RWEventItem struct {
Slot common.Hash
}

func (e RWEventItem) String() string {
switch e.Event {
case NewTxRWEvent:
return fmt.Sprintf("(%v)%v", e.Event, e.Index)
case ReadAccRWEvent:
return fmt.Sprintf("(%v)%v|%v", e.Event, e.Addr, e.State)
case WriteAccRWEvent:
return fmt.Sprintf("(%v)%v|%v", e.Event, e.Addr, e.State)
case ReadSlotRWEvent:
return fmt.Sprintf("(%v)%v|%v", e.Event, e.Addr, e.Slot)
case WriteSlotRWEvent:
return fmt.Sprintf("(%v)%v|%v", e.Event, e.Addr, e.Slot)
case CannotGasFeeDelayRWEvent:
return fmt.Sprintf("(%v)", e.Event)
}
return "Unknown"
}

type RWTxList struct {
list []int
}
Expand Down Expand Up @@ -914,13 +932,20 @@ func (s *MVStates) resolveDepsMapCacheByWrites(index int, reads []RWEventItem, w
}
}
}
// append AccountSelf event
s.finaliseAccRead(index, item.Addr, AccountSelf)
}
// Looking for read operations before write operations, e.g: read->read->read/write execution sequence,
// we need the write transaction to occur after the read transactions.
for _, item := range writes {
var depReads *RWTxList
if item.Event == WriteAccRWEvent {
depReads = s.queryAccReads(item.Addr, item.State)
// if here is AccountSuicide write, check AccountSelf read
state := item.State
if state == AccountSuicide {
state = AccountSelf
}
depReads = s.queryAccReads(item.Addr, state)
} else {
depReads = s.querySlotReads(item.Addr, item.Slot)
}
Expand Down

0 comments on commit 963c78d

Please sign in to comment.