Skip to content

Commit

Permalink
first one didn't work, let's try this...
Browse files Browse the repository at this point in the history
  • Loading branch information
samalws-tob committed Sep 4, 2024
1 parent c4d807a commit 827d0e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzzing/coverage/coverage_maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ type CoverageMaps struct {
// maps represents a structure used to track every ContractCoverageMap by a given deployed address/lookup hash.
maps map[common.Hash]map[common.Address]*ContractCoverageMap

// TODO comment this
// The assumption here is that geth codehash matches if and only if codehash matches
gethCodeHashToCodeHash map[common.Hash]*common.Hash

// TODO comment this
// The assumption here is that geth codehash matches if and only if codehash matches
cachedGethCodeHash common.Hash
Expand Down
9 changes: 9 additions & 0 deletions fuzzing/coverage/coverage_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type CoverageTracer struct {

// nativeTracer is the underlying tracer used to capture EVM execution.
nativeTracer *chain.TestChainTracer

// TODO comment
gethCodeHashToCodeHash map[common.Hash]*common.Hash
}

// coverageTracerCallFrameState tracks state across call frames in the tracer.
Expand Down Expand Up @@ -167,9 +170,15 @@ func (t *CoverageTracer) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tr
if callFrameState.pendingCoverageMap.cachedGethCodeHash == gethCodeHash {
lookupHash := callFrameState.pendingCoverageMap.cachedCodeHash
callFrameState.lookupHash = &lookupHash
} else if t.gethCodeHashToCodeHash[gethCodeHash] != nil {
callFrameState.lookupHash = t.gethCodeHashToCodeHash[gethCodeHash]
} else if callFrameState.pendingCoverageMap.gethCodeHashToCodeHash[gethCodeHash] != nil {
callFrameState.lookupHash = t.gethCodeHashToCodeHash[gethCodeHash]
} else {
lookupHash := getContractCoverageMapHash(code, callFrameState.create)
callFrameState.lookupHash = &lookupHash
t.gethCodeHashToCodeHash[gethCodeHash] = &lookupHash
callFrameState.pendingCoverageMap.gethCodeHashToCodeHash[gethCodeHash] = &lookupHash
}
}

Expand Down

0 comments on commit 827d0e6

Please sign in to comment.