Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txdag: add suicide checking logic; #185

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading