Skip to content

Commit

Permalink
cannon: Fix path used when verifying a downloaded state (#11813)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored Sep 9, 2024
1 parent 4428d10 commit a0d3195
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion op-challenger/game/fault/trace/prestates/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (m *MultiPrestateProvider) fetchPrestate(hash common.Hash, fileType string,
return fmt.Errorf("failed to close file %v: %w", dest, err)
}
// Verify the prestate actually matches the expected hash before moving it into the final destination
proof, _, _, err := m.stateConverter.ConvertStateToProof(dest)
proof, _, _, err := m.stateConverter.ConvertStateToProof(tmpFile)
if err != nil || proof.ClaimValue != hash {
// Treat invalid prestates as unavailable. Often servers return a 404 page with 200 status code
_ = os.Remove(tmpFile) // Best effort attempt to clean up the temporary file
Expand Down
4 changes: 4 additions & 0 deletions op-challenger/game/fault/trace/prestates/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,9 @@ type stubStateConverter struct {
}

func (s *stubStateConverter) ConvertStateToProof(path string) (*utils.ProofData, uint64, bool, error) {
// Return an error if we're given the wrong path
if _, err := os.Stat(path); err != nil {
return nil, 0, false, err
}
return &utils.ProofData{ClaimValue: s.hash}, 0, false, s.err
}

0 comments on commit a0d3195

Please sign in to comment.