Skip to content

Commit a720ca4

Browse files
committed
revert to unjammed simulated storage
1 parent 363194e commit a720ca4

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

app/Commands/Dev/Nockma/Run/BuiltinEvaluator.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runCommand opts = do
2222
t@(TermCell {}) -> do
2323
let formula = anomaCallTuple parsedArgs
2424
storageJammedTerms = map Encoding.atomToByteString' . mapMaybe getAtom $ maybe [] unfoldList parsedStorage
25-
storage = foldr insertJammedStorage emptyStorage storageJammedTerms
25+
storage <- runAppError @SimpleError $ foldrM insertJammedStorage emptyStorage storageJammedTerms
2626
(counts, res) <-
2727
runOpCounts
2828
. runReader defaultEvalOptions

src/Juvix/Compiler/Nockma/Evaluator.hs

+4-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ evalProfile inistack initerm =
259259
TermAtom a -> do
260260
r <- Encoding.cueEither a
261261
either (throwDecodingFailed args') return r
262-
TermCell {} -> throwDecodingFailed args' DecodingErrorExpectedAtom
262+
TermCell {} ->
263+
-- In the simulated storage, we allow already decoded cells
264+
-- for efficiency. Decoding these should then be a no-op.
265+
return args'
263266
StdlibVerifyDetached -> case args' of
264267
TCell (TermAtom sig) (TCell (TermAtom message) (TermAtom pubKey)) -> goVerifyDetached sig message pubKey
265268
_ -> error "expected a term of the form [signature (atom) message (encoded term) public_key (atom)]"

src/Juvix/Compiler/Nockma/Evaluator/Storage.hs

+4-7
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,11 @@ mkModuleStorage mtab =
9090
fromJust (md' ^. moduleInfoTable . infoCode)
9191
)
9292

93-
insertJammedStorage :: ByteString -> Storage Natural -> Storage Natural
94-
insertJammedStorage jammedTerm storage =
95-
over storageKeyValueData (HashMap.insert (StorageKey sha256) jammedAtom) storage
93+
insertJammedStorage :: (Member (Error SimpleError) r) => ByteString -> Storage Natural -> Sem r (Storage Natural)
94+
insertJammedStorage jammedTerm storage = do
95+
term <- decodeCue jammedTerm
96+
return $ over storageKeyValueData (HashMap.insert (StorageKey sha256) term) storage
9697
where
97-
jammedAtom =
98-
TermAtom
99-
. byteStringToAtom'
100-
$ jammedTerm
10198
sha256 =
10299
TermAtom
103100
. byteStringToAtom'

0 commit comments

Comments
 (0)