From 81efd632699ebe240924fb8c5f874c25fd1fea96 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 17 Sep 2024 10:53:04 -0700 Subject: [PATCH] Quit early when read conflict is detected --- core/state/statedb.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 34230f6d06..c8a1317213 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -329,10 +329,13 @@ func MVRead[T any](s *StateDB, k blockstm.Key, defaultV T, readStorage func(s *S return defaultV } - // TODO: I assume we don't want to overwrite an existing read because this could - for example - change a storage - // read to map if the same value is read multiple times. - if _, ok := s.readMap[k]; !ok { + if prevRd, ok := s.readMap[k]; !ok { s.readMap[k] = rd + } else { + if prevRd.Kind != rd.Kind || prevRd.V.TxnIndex != rd.V.TxnIndex || prevRd.V.Incarnation != rd.V.Incarnation { + s.dep = rd.V.TxnIndex + panic("Read conflict detected") + } } return