diff --git a/plutus-benchmark/uplc-evaluator/Main.hs b/plutus-benchmark/uplc-evaluator/Main.hs index e9c397eb17f..1f65af98b07 100644 --- a/plutus-benchmark/uplc-evaluator/Main.hs +++ b/plutus-benchmark/uplc-evaluator/Main.hs @@ -35,7 +35,7 @@ import PlutusCore.Quote (runQuoteT) import PlutusPrelude (void) import System.Directory import System.Exit (exitFailure) -import System.FilePath (takeBaseName, takeExtension, ()) +import System.FilePath (takeBaseName, takeExtension, takeFileName, ()) import System.IO (BufferMode (LineBuffering), hPutStrLn, hSetBuffering, stderr) import System.Mem (performGC, performMinorGC) import UntypedPlutusCore qualified as UPLC @@ -136,22 +136,9 @@ parseJobId filename = else baseName in UUID.fromString jobIdStr -{-| Check if file is a valid UPLC program file. -Supports two extensions: -- @.uplc.txt@ - Textual UPLC syntax (currently supported) -- @.uplc.flat@ - Flat-encoded binary UPLC (future: requires different parsing path) - -TODO [Flat Encoding Support]: -Flat-encoded UPLC files (.uplc.flat) require binary deserialization rather than -text parsing. Flat is a bit-oriented format that's ~35% smaller than CBOR. -Implementation would require: - 1. Detect flat vs text format (by extension or magic bytes) - 2. Use "Flat" package with UPLC.UnrestrictedProgram decoder - 3. Skip the "(program" prefix validation for binary files -Currently, flat files fail with syntax_error (expected MVP behavior). -} +-- | Check if file is a valid UPLC program file (textual @.uplc.txt@ format only). isUplcFile :: FilePath -> Bool -isUplcFile path = - ".uplc.txt" `isSuffixOf` path || ".uplc.flat" `isSuffixOf` path +isUplcFile path = ".uplc.txt" `isSuffixOf` path {-| Parse a UPLC program from textual syntax. Returns either a descriptive error message or the parsed program with unit annotations. -} @@ -320,9 +307,6 @@ processProgram Config {..} inputPath = do hPutStrLn stderr $ "Processing job: " ++ UUID.toString jobId -- Read the file content as Text - -- TODO [Flat Encoding Support]: For .uplc.flat files, read as ByteString - -- and use binary deserialization instead of text parsing. - -- See Note [Flat Encoding Support] at isUplcFile. readResult <- try @SomeException $ TIO.readFile inputPath case readResult of @@ -483,9 +467,7 @@ evaluationLoop config@Config {..} processedFiles = do -- Continue loop evaluationLoop config newProcessed --- | Utility function to extract filename from path -takeFileName :: FilePath -> FilePath -takeFileName = reverse . takeWhile (/= '/') . reverse + -- | Main entry point main :: IO ()