Commit a0d31953 authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

cannon: Fix path used when verifying a downloaded state (#11813)

parent 4428d107
...@@ -91,7 +91,7 @@ func (m *MultiPrestateProvider) fetchPrestate(hash common.Hash, fileType string, ...@@ -91,7 +91,7 @@ func (m *MultiPrestateProvider) fetchPrestate(hash common.Hash, fileType string,
return fmt.Errorf("failed to close file %v: %w", dest, err) 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 // 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 { if err != nil || proof.ClaimValue != hash {
// Treat invalid prestates as unavailable. Often servers return a 404 page with 200 status code // 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 _ = os.Remove(tmpFile) // Best effort attempt to clean up the temporary file
......
...@@ -167,5 +167,9 @@ type stubStateConverter struct { ...@@ -167,5 +167,9 @@ type stubStateConverter struct {
} }
func (s *stubStateConverter) ConvertStateToProof(path string) (*utils.ProofData, uint64, bool, error) { 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 return &utils.ProofData{ClaimValue: s.hash}, 0, false, s.err
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment