Skip to content

Commit

Permalink
notes during sync
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble committed Oct 15, 2024
1 parent 73ab089 commit bee3e8f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Chainweb/Pact/PactService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ import qualified Pact.Parse as Pact4
import qualified Control.Parallel.Strategies as Strategies
import qualified Chainweb.Pact5.Validations as Pact5
import qualified Pact.Core.Errors as Pact5
import qualified Data.Text as T

runPactService
:: Logger logger
Expand Down Expand Up @@ -746,6 +747,7 @@ execReadOnlyReplay lowerBound maybeUpperBound = pactLabel "execReadOnlyReplay" $
-- TODO: Make this transformation not so convoluted...

-- 1. Decode input bytes as a Pact4 Command
-- TODO: try to parse txBytes into a Pact 5 command directly
let cmd4 :: Pact4.Command Text
cmd4 = fromJuste $ decodeStrictOrThrow' txBytes

Expand Down Expand Up @@ -780,17 +782,19 @@ execReadOnlyReplay lowerBound maybeUpperBound = pactLabel "execReadOnlyReplay" $
{ _tcParentHeader = ParentHeader bhParent
, _tcMiner = miner
}
let spvSupport = Pact5.pactSPV bhdb bh
let spvSupport = Pact5.pactSPV bhdb bhParent
let initialGas = Pact5.initialGasOf (Pact5._cmdPayload cmd)

applyCmdResult <- try @_ @SomeException $ Pact5.applyCmd logger Nothing pact5Db txContext spvSupport initialGas (fmap (^. Pact5.payloadObj) cmd)
case applyCmdResult of
Left someException -> do
-- TODO: apparently an SPV exception?
-- these exceptions shouldn't happen, do something about it here
return ()
logError_ logger $ "Uncaught exception during replay: " <> T.pack (displayException someException)
Right (Left e) -> do
-- uhhhh what do we do here
return ()
-- TODO: write all of these out, they should be impossible
logError_ logger $ "Gas buy error during replay: " <> sshow e
Right (Right cmdResult5) -> do
let txMinerId = miner ^. minerId
let r4 = commandResultToDiffable txMinerId cmdResult
Expand Down
1 change: 1 addition & 0 deletions src/Chainweb/Pact/ReflectingDb.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ pact4ReflectingDb PactTables{..} pact4Db = do
read' dom k meth = do
Pact4._readRow pact4Db dom k meth >>= \case
Nothing -> do
-- TODO: record `Nothing` here in the tables too
pure Nothing
Just v -> do
writeToPactTables dom k v
Expand Down
1 change: 1 addition & 0 deletions src/Chainweb/Pact/Types/Parity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Text.Regex qualified as R

data CommandResultDiffable = CommandResultDiffable
{ -- _crdTxId :: Maybe Pact5.TxId -- TODO: Can't do txId for now
-- TODO: include txlogs, after converting them to the same format
_crdRequestKey :: Pact5.RequestKey
, _crdResult :: Pact5.PactResult ErrorDiffable
, _crdEvents :: OrderedEvents
Expand Down

0 comments on commit bee3e8f

Please sign in to comment.