Skip to content

Commit 22d87bb

Browse files
zhangchiqingjordanschalmtim-barry
authored
Apply suggestions from code review
Co-authored-by: Jordan Schalm <[email protected]> Co-authored-by: Tim Barry <[email protected]>
1 parent a33dfcc commit 22d87bb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

storage/epoch_protocol_state.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ type EpochProtocolStateEntries interface {
3434
//
3535
// CAUTION:
3636
// - The caller must acquire the lock [storage.LockInsertBlock] and hold it until the database write has been committed.
37-
// - The lock proof serves as a reminder that the CALLER is responsible to ensure that the operation.InsertHeader is
38-
// done ATOMICALLY with this write operation.
37+
// - OVERWRITES existing data (potential for data corruption):
38+
// The lock proof serves as a reminder that the CALLER is responsible to ensure that the DEDUPLICATION CHECK is done elsewhere
39+
// ATOMICALLY within this write operation. Currently it's done by operation.InsertHeader where it performs a check
40+
// to ensure the blockID is new, therefore any data indexed by this blockID is new as well.
3941
//
4042
// Expected errors during normal operations:
41-
// - [storage.ErrAlreadyExists] if a KV store for the given blockID has already been indexed
43+
// No expected errors during normal operations.
4244
BatchIndex(lctx lockctx.Proof, rw ReaderBatchWriter, blockID flow.Identifier, epochProtocolStateID flow.Identifier) error
4345

4446
// ByID returns the flow.RichEpochStateEntry by its ID.

storage/operation/execution_fork_evidence.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func RemoveExecutionForkEvidence(w storage.Writer) error {
3737
// No errors are expected during normal operations.
3838
func InsertExecutionForkEvidence(lctx lockctx.Proof, rw storage.ReaderBatchWriter, conflictingSeals []*flow.IncorporatedResultSeal) error {
3939
if !lctx.HoldsLock(storage.LockInsertExecutionForkEvidence) {
40-
return fmt.Errorf("InsertExecutionForkEvidence requires LockInsertBlock to be held")
40+
return fmt.Errorf("InsertExecutionForkEvidence requires LockInsertExecutionForkEvidence to be held")
4141
}
4242
key := MakePrefix(codeExecutionFork)
43-
exist, err := KeyExists(rw.GlobalReader(), MakePrefix(codeExecutionFork))
43+
exist, err := KeyExists(rw.GlobalReader(), key)
4444
if err != nil {
4545
return fmt.Errorf("failed to check if execution fork evidence exists: %w", err)
4646
}

0 commit comments

Comments
 (0)