Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 30f6324

Browse files
committed
Fix broken SPV oracles
Change-Id: Id0000000fbd4c58b18ba9e4063c224da92b97b43
1 parent d517ea3 commit 30f6324

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/Chainweb/Pact/Backend/ChainwebPactDb.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ chainwebPactBlockDb env = ChainwebPactDb
261261
, consult = \(Parent hsh) -> do
262262
throwOnDbError (lookupBlockHash (_blockHandlerDb env) hsh) <&> \case
263263
Nothing -> False
264-
Just rootHeight -> rootHeight > currentHeight
264+
Just rootHeight -> rootHeight < currentHeight
265265
}
266266
let spv = pactSPV headerOracle
267267
r <- liftIO $ kont pactDb spv

src/Chainweb/Pact/PactService/Pact4/ExecBlock.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import Chainweb.Pact.Types (ServiceEnv(..), Transactions (..), bctxParentCreatio
5050
import Chainweb.Pact4.Backend.ChainwebPactDb
5151
import Chainweb.Pact4.ModuleCache
5252
import Chainweb.Pact4.NoCoinbase
53+
import Chainweb.Pact4.SPV qualified as Pact4
5354
import Chainweb.Pact4.Transaction qualified as Pact4
5455
import Chainweb.Pact4.TransactionExec qualified as Pact4
5556
import Chainweb.Pact4.Types
@@ -505,9 +506,7 @@ applyPactCmd logger serviceEnv blockEnv txIdxInBlock miner cmd = StateT $ \(T2 m
505506
if _bctxIsGenesis bCtx
506507
then liftIO $! Pact4.applyGenesisCmd logger pactDb Pact4.noSPVSupport bCtx gasLimitedCmd
507508
else do
508-
-- FIXME
509-
-- let bhdb = view psBlockHeaderDb serviceEnv
510-
-- let spv = Pact4.pactSPV bhdb (_parentHeader parent)
509+
let spv = Pact4.pactSPV (_cpHeaderOracle $ _benvDbEnv blockEnv) bCtx
511510
let
512511
txTimeout io = do
513512
logFunctionText logger Debug $ "txTimeLimit was not set - defaulting to a function of the block gas limit"
@@ -516,7 +515,7 @@ applyPactCmd logger serviceEnv blockEnv txIdxInBlock miner cmd = StateT $ \(T2 m
516515
liftIO $ txTimeout $
517516
Pact4.applyCmd logger
518517
-- FIXME spv
519-
blockEnv miner gasModel txIdxInBlock undefined gasLimitedCmd initialGas mcache
518+
blockEnv miner gasModel txIdxInBlock spv gasLimitedCmd initialGas mcache
520519
pure $ T2 r c
521520

522521
if _bctxIsGenesis bCtx

src/Chainweb/Pact4/Backend/ChainwebPactDb.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
{-# LANGUAGE DataKinds #-}
1111
{-# LANGUAGE TypeFamilies #-}
1212
{-# LANGUAGE ImportQualifiedPost #-}
13-
-- TODO pact5: fix the orphan PactDbFor instance
1413
{-# OPTIONS_GHC -Wno-orphans #-}
1514
{-# LANGUAGE ViewPatterns #-}
1615

@@ -918,6 +917,6 @@ headerOracleForBlock env = HeaderOracle
918917
{ consult = \(Parent blkHash) -> do
919918
lookupBlockHash (_blockHandlerDb env) blkHash <&> \case
920919
Nothing -> False
921-
Just rootHeight -> rootHeight > _blockHandlerBlockHeight env
920+
Just rootHeight -> rootHeight < _blockHandlerBlockHeight env
922921
, chain = _blockHandlerChainId env
923922
}

0 commit comments

Comments
 (0)