diff --git a/cardano-chain-gen/src/Cardano/Mock/Query.hs b/cardano-chain-gen/src/Cardano/Mock/Query.hs index ec8ff7ffc..a52013146 100644 --- a/cardano-chain-gen/src/Cardano/Mock/Query.hs +++ b/cardano-chain-gen/src/Cardano/Mock/Query.hs @@ -20,7 +20,7 @@ module Cardano.Mock.Query ( ) where import qualified Cardano.Db as Db -import Cardano.Prelude hiding (from, isNothing) +import Cardano.Prelude hiding (from, isNothing, on) import qualified Data.ByteString.Base16 as Base16 import Data.ByteString.Short (ShortByteString, toShort) import Database.Esqueleto.Experimental diff --git a/cardano-db-sync/src/Cardano/DbSync/Cache.hs b/cardano-db-sync/src/Cardano/DbSync/Cache.hs index 55f9ce9a7..4b618cb02 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Cache.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Cache.hs @@ -71,8 +71,8 @@ import Ouroboros.Consensus.Cardano.Block (StandardCrypto) -- a different id. -- NOTE: Other tables are not cleaned up since they are not rollbacked. rollbackCache :: MonadIO m => CacheStatus -> DB.BlockId -> ReaderT SqlBackend m () -rollbackCache UninitiatedCache _ = pure () -rollbackCache (Cache cache) blockId = do +rollbackCache NoCache _ = pure () +rollbackCache (ActiveCache cache) blockId = do liftIO $ do atomically $ writeTVar (cPrevBlock cache) Nothing atomically $ modifyTVar (cDatum cache) LRU.cleanup @@ -193,12 +193,11 @@ queryStakeAddrAux cacheUA mp sts nw cred = queryPoolKeyWithCache :: MonadIO m => - SyncEnv -> CacheStatus -> CacheUpdateAction -> PoolKeyHash -> ReaderT SqlBackend m (Either DB.LookupFail DB.PoolHashId) -queryPoolKeyWithCache syncEnv cache cacheUA hsh = +queryPoolKeyWithCache cache cacheUA hsh = case cache of NoCache -> do mPhId <- queryPoolHashId (Generic.unKeyHashRaw hsh) @@ -281,13 +280,13 @@ queryPoolKeyOrInsert :: PoolKeyHash -> ReaderT SqlBackend m DB.PoolHashId queryPoolKeyOrInsert txt syncEnv cache cacheUA logsWarning hsh = do - pk <- queryPoolKeyWithCache syncEnv cache cacheUA hsh + pk <- queryPoolKeyWithCache cache cacheUA hsh case pk of Right poolHashId -> pure poolHashId Left err -> do when logsWarning $ liftIO $ - logWarning trce $ + logWarning (getTrace syncEnv) $ mconcat [ "Failed with " , DB.textShow err @@ -301,7 +300,7 @@ queryPoolKeyOrInsert txt syncEnv cache cacheUA logsWarning hsh = do queryMAWithCache :: MonadIO m => - Cache -> + CacheStatus -> PolicyID StandardCrypto -> AssetName -> ReaderT SqlBackend m (Either (ByteString, ByteString) DB.MultiAssetId) diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Query.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Query.hs index 6b66a6d41..f654dbc42 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Query.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Query.hs @@ -8,7 +8,6 @@ module Cardano.DbSync.Era.Shelley.Query ( queryPoolHashId, queryStakeAddress, - queryMultipleStakeAddress, queryStakeRefPtr, resolveInputTxId, resolveInputTxOutId, @@ -30,7 +29,6 @@ import Database.Esqueleto.Experimental ( Value (..), desc, from, - in_, innerJoin, just, limit, @@ -39,7 +37,6 @@ import Database.Esqueleto.Experimental ( select, table, val, - valList, where_, (:&) ((:&)), (==.), @@ -67,17 +64,6 @@ queryStakeAddress addr = do pure (saddr ^. StakeAddressId) pure $ maybeToEither (DbLookupMessage $ "StakeAddress " <> renderByteArray addr) unValue (listToMaybe res) -queryMultipleStakeAddress :: - MonadIO m => - [ByteString] -> - ReaderT SqlBackend m (Either LookupFail [StakeAddressId]) -queryMultipleStakeAddress addrs = do - res <- select $ do - saddr <- from $ table @StakeAddress - where_ (saddr ^. StakeAddressHashRaw `in_` valList addrs) - pure (saddr ^. StakeAddressId) - pure $ Right $ map unValue res - resolveInputTxId :: MonadIO m => Generic.TxIn -> ReaderT SqlBackend m (Either LookupFail TxId) resolveInputTxId = queryTxId . Generic.txInHash diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Adjust.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Adjust.hs index 19dded7ac..33dc7e935 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Adjust.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Adjust.hs @@ -16,7 +16,7 @@ import Cardano.DbSync.Cache ( queryPoolKeyWithCache, queryStakeAddrWithCache, ) -import Cardano.DbSync.Cache.Types (CacheStatus, CacheUpdateAction (..)) +import Cardano.DbSync.Cache.Types (CacheUpdateAction (..)) import qualified Cardano.DbSync.Era.Shelley.Generic.Rewards as Generic import Cardano.DbSync.Types (StakeCred) import Cardano.Ledger.BaseTypes (Network) @@ -69,7 +69,7 @@ adjustEpochRewards syncEnv nw epochNo rwds creds = do ] forM_ eraIgnored $ \(cred, rewards) -> forM_ (Set.toList rewards) $ \rwd -> - deleteReward nw cache epochNo (cred, rwd) + deleteReward syncEnv nw epochNo (cred, rwd) crds <- rights <$> forM (Set.toList creds) (queryStakeAddrWithCache (envCache syncEnv) DoNotUpdateCache nw) deleteOrphanedRewards epochNo crds diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Block.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Block.hs index 72571d0f1..69382bfe9 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Block.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Block.hs @@ -18,7 +18,7 @@ import Cardano.DbSync.Api.Types (InsertOptions (..), SyncEnv (..), SyncOptions ( import Cardano.DbSync.Cache (insertBlockAndCache, queryPoolKeyWithCache, queryPrevBlockWithCache) import Cardano.DbSync.Cache.Epoch (writeEpochBlockDiffToCache) import Cardano.DbSync.Cache.Types (CacheStatus (..), CacheUpdateAction (..), EpochBlockDiff (..)) -import Cardano.DbSync.Config.Types (isShelleyEnabled) +import Cardano.DbSync.Config.Types (isShelleyModeActive) import qualified Cardano.DbSync.Era.Shelley.Generic as Generic import Cardano.DbSync.Era.Universal.Epoch import Cardano.DbSync.Era.Universal.Insert.Grouped @@ -63,12 +63,12 @@ insertBlockUniversal syncEnv shouldLog withinTwoMins withinHalfHour blk details pbid <- case Generic.blkPreviousHash blk of Nothing -> liftLookupFail (renderErrorMessage (Generic.blkEra blk)) DB.queryGenesis -- this is for networks that fork from Byron on epoch 0. Just pHash -> queryPrevBlockWithCache (renderErrorMessage (Generic.blkEra blk)) cache pHash - mPhid <- lift $ queryPoolKeyWithCache syncEnv UpdateCache $ coerceKeyRole $ Generic.blkSlotLeader blk + mPhid <- lift $ queryPoolKeyWithCache cache UpdateCache $ coerceKeyRole $ Generic.blkSlotLeader blk let epochNo = sdEpochNo details slid <- lift . DB.insertSlotLeader $ Generic.mkSlotLeader (isShelleyModeActive $ ioShelley iopts) (Generic.unKeyHashRaw $ Generic.blkSlotLeader blk) (eitherToMaybe mPhid) blkId <- - lift . insertBlockAndCache cacheStatus $ + lift . insertBlockAndCache cache $ DB.Block { DB.blockHash = Generic.blkHash blk , DB.blockEpochNo = Just $ unEpochNo epochNo @@ -99,7 +99,7 @@ insertBlockUniversal syncEnv shouldLog withinTwoMins withinHalfHour blk details when (soptEpochAndCacheEnabled $ envOptions syncEnv) . newExceptT $ writeEpochBlockDiffToCache - cacheStatus + cache EpochBlockDiff { ebdBlockId = blkId , ebdTime = sdSlotTime details @@ -176,5 +176,5 @@ insertBlockUniversal syncEnv shouldLog withinTwoMins withinHalfHour blk details tracer :: Trace IO Text tracer = getTrace syncEnv - cacheStatus :: CacheStatus - cacheStatus = envCache syncEnv + cache :: CacheStatus + cache = envCache syncEnv diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Epoch.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Epoch.hs index b1fb76a9a..6d0ddab75 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Epoch.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Epoch.hs @@ -28,7 +28,6 @@ import Cardano.DbSync.Api import Cardano.DbSync.Api.Types (InsertOptions (..), SyncEnv (..)) import Cardano.DbSync.Cache (queryOrInsertStakeAddress, queryPoolKeyOrInsert) import Cardano.DbSync.Cache.Types (CacheStatus, CacheUpdateAction (..)) -import Cardano.DbSync.Era.Conway.Insert.GovAction (insertCostModel, insertDrepDistr, updateEnacted) import Cardano.DbSync.Config.Types (isShelleyModeActive) import qualified Cardano.DbSync.Era.Shelley.Generic as Generic import Cardano.DbSync.Era.Universal.Insert.Certificate (insertPots) @@ -37,7 +36,7 @@ import Cardano.DbSync.Era.Universal.Insert.Other (toDouble) import Cardano.DbSync.Error import Cardano.DbSync.Ledger.Event import Cardano.DbSync.Types -import Cardano.DbSync.Util (whenStrictJust) +import Cardano.DbSync.Util (whenFalseEmpty, whenStrictJust) import Cardano.DbSync.Util.Constraint (constraintNameEpochStake, constraintNameReward) import Cardano.DbSync.Util.Whitelist (shelleyStakeAddrWhitelistCheck) import qualified Cardano.Ledger.Address as Ledger @@ -63,6 +62,7 @@ import Database.Persist.Sql (SqlBackend) -------------------------------------------------------------------------------------------- insertOnNewEpoch :: (MonadBaseControl IO m, MonadIO m) => + SyncEnv -> DB.BlockId -> SlotNo -> EpochNo -> @@ -78,12 +78,12 @@ insertOnNewEpoch syncEnv blkId slotNo epochNo newEpoch = do lift $ insertDrepDistr epochNo drepSnapshot updateRatified syncEnv epochNo (toList $ rsEnacted ratifyState) updateExpired syncEnv epochNo (toList $ rsExpired ratifyState) - whenStrictJust (Generic.neEnacted newEpoch) $ \enactedSt -> - when (ioGov iopts) $ - updateEnacted syncEnv epochNo enactedSt + whenStrictJust (Generic.neEnacted newEpoch) $ \enactedSt -> do + when (ioGov iopts) $ do + insertUpdateEnacted syncEnv blkId epochNo enactedSt where epochUpdate :: Generic.EpochUpdate - epochUpdate = Generic.neEpochUpdate newEpoc + epochUpdate = Generic.neEpochUpdate newEpoch tracer = getTrace syncEnv iopts = getInsertOptions syncEnv @@ -204,7 +204,7 @@ insertEpochStake :: [(StakeCred, (Shelley.Coin, PoolKeyHash))] -> ExceptT SyncNodeError (ReaderT SqlBackend m) () insertEpochStake syncEnv nw epochNo stakeChunk = do - let cacheStatus = envCache syncEnv + let cache = envCache syncEnv DB.ManualDbConstraints {..} <- liftIO $ readTVarIO $ envDbConstraints syncEnv dbStakes <- mapMaybeM (mkStake cache) stakeChunk let chunckDbStakes = splittRecordsEvery 100000 dbStakes @@ -217,22 +217,21 @@ insertEpochStake syncEnv nw epochNo stakeChunk = do (StakeCred, (Shelley.Coin, PoolKeyHash)) -> ExceptT SyncNodeError (ReaderT SqlBackend m) (Maybe DB.EpochStake) mkStake cache (saddr, (coin, pool)) = - -- Check if the stake address is in the shelley whitelist - if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount nw saddr - then - ( do - saId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache nw saddr - poolId <- lift $ queryPoolKeyOrInsert "insertEpochStake" syncEnv cache UpdateCache (isShelleyModeActive $ ioShelley iopts) pool - pure $ - Just $ - DB.EpochStake - { DB.epochStakeAddrId = saId - , DB.epochStakePoolId = poolId - , DB.epochStakeAmount = Generic.coinToDbLovelace coin - , DB.epochStakeEpochNo = unEpochNo epochNo -- The epoch where this delegation becomes valid. - } - ) - else pure Nothing + whenFalseEmpty + (shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount nw saddr) + Nothing + ( do + saId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache nw saddr + poolId <- lift $ queryPoolKeyOrInsert "insertEpochStake" syncEnv cache UpdateCache (isShelleyModeActive $ ioShelley iopts) pool + pure $ + Just $ + DB.EpochStake + { DB.epochStakeAddrId = saId + , DB.epochStakePoolId = poolId + , DB.epochStakeAmount = Generic.coinToDbLovelace coin + , DB.epochStakeEpochNo = unEpochNo epochNo -- The epoch where this delegation becomes valid. + } + ) iopts = getInsertOptions syncEnv insertRewards :: @@ -244,7 +243,7 @@ insertRewards :: CacheStatus -> [(StakeCred, Set Generic.Reward)] -> ExceptT SyncNodeError (ReaderT SqlBackend m) () -insertRewards syncEnv nw earnedEpoch spendableEpoch cacheStatus rewardsChunk = do +insertRewards syncEnv nw earnedEpoch spendableEpoch cache rewardsChunk = do DB.ManualDbConstraints {..} <- liftIO $ readTVarIO $ envDbConstraints syncEnv dbRewards <- concatMapM mkRewards rewardsChunk let chunckDbRewards = splittRecordsEvery 100000 dbRewards @@ -255,7 +254,7 @@ insertRewards syncEnv nw earnedEpoch spendableEpoch cacheStatus rewardsChunk = d (MonadBaseControl IO m, MonadIO m) => (StakeCred, Set Generic.Reward) -> ExceptT SyncNodeError (ReaderT SqlBackend m) [DB.Reward] - mkRewards (saddr, rset) = + mkRewards (saddr, rset) = do -- Check if the stake address is in the shelley whitelist if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount nw saddr then do @@ -308,7 +307,7 @@ insertRewardRests syncEnv nw earnedEpoch spendableEpoch cache rewardsChunk = do (MonadBaseControl IO m, MonadIO m) => (StakeCred, Set Generic.RewardRest) -> ExceptT SyncNodeError (ReaderT SqlBackend m) [DB.RewardRest] - mkRewards (saddr, rset) = + mkRewards (saddr, rset) = do -- Check if the stake address is in the shelley whitelist if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount nw saddr then do diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Genesis.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Genesis.hs index 6fdd66d3a..750bfe034 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Genesis.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Genesis.hs @@ -15,7 +15,7 @@ import Cardano.BM.Trace (Trace, logError, logInfo) import qualified Cardano.Db as DB import Cardano.DbSync.Api import Cardano.DbSync.Api.Types (SyncEnv (envBackend)) -import Cardano.DbSync.Cache.Types (CacheStatus (..), useNoCache) +import Cardano.DbSync.Cache.Types (useNoCache) import qualified Cardano.DbSync.Era.Shelley.Generic.Util as Generic import Cardano.DbSync.Era.Universal.Insert.Certificate ( insertDelegation, @@ -157,7 +157,7 @@ insertValidateGenesisDist syncEnv networkName cfg shelleyInitiation = do "Initial genesis distribution populated. Hash " <> renderByteArray (configGenesisHash cfg) when hasStakes $ - insertStaking syncEnv useNoCache bid cfg + insertStaking syncEnv bid cfg supply <- lift DB.queryTotalSupply liftIO $ logInfo tracer ("Total genesis supply of Ada: " <> DB.renderAda supply) @@ -297,7 +297,7 @@ insertStaking syncEnv blkId genesis = do forM_ stakes $ \(n, (keyStaking, keyPool)) -> do -- TODO: add initial deposits for genesis stake keys. insertStakeRegistration syncEnv (EpochNo 0) Nothing txId (2 * n) (Generic.annotateStakingCred network (KeyHashObj keyStaking)) - insertDelegation syncEnv UninitiatedCache network (EpochNo 0) 0 txId (2 * n + 1) Nothing (KeyHashObj keyStaking) keyPool + insertDelegation syncEnv useNoCache network (EpochNo 0) 0 txId (2 * n + 1) Nothing (KeyHashObj keyStaking) keyPool -- ----------------------------------------------------------------------------- diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Certificate.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Certificate.hs index 2a8b5fd46..18c1a6ec5 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Certificate.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Certificate.hs @@ -203,7 +203,7 @@ insertMirCert syncEnv network txId idx mcert = do insertMirReserves (cred, dcoin) = -- Check if the stake address is in the shelley whitelist when (shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount network cred) $ do - addrId <- lift $ queryOrInsertStakeAddress syncEnv (envCache syncEnv) CacheNew network cred + addrId <- lift $ queryOrInsertStakeAddress syncEnv (envCache syncEnv) UpdateCache network cred void . lift . DB.insertReserve $ DB.Reserve { DB.reserveAddrId = addrId @@ -219,7 +219,7 @@ insertMirCert syncEnv network txId idx mcert = do insertMirTreasury (cred, dcoin) = -- Check if the stake address is in the shelley whitelist when (shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount network cred) $ do - addrId <- lift $ queryOrInsertStakeAddress syncEnv (envCache syncEnv) CacheNew network cred + addrId <- lift $ queryOrInsertStakeAddress syncEnv (envCache syncEnv) UpdateCache network cred void . lift . DB.insertTreasury $ DB.Treasury { DB.treasuryAddrId = addrId @@ -339,7 +339,7 @@ insertStakeDeregistration :: insertStakeDeregistration syncEnv network epochNo txId idx mRedeemerId cred = do -- Check if the stake address is in the shelley whitelist when (shelleyCustomStakeWhitelistCheck syncEnv $ Ledger.RewardAccount network cred) $ do - scId <- lift $ queryOrInsertStakeAddress syncEnv (envCache syncEnv) EvictAndReturn network cred + scId <- lift $ queryOrInsertStakeAddress syncEnv (envCache syncEnv) EvictAndUpdateCache network cred void . lift . DB.insertStakeDeregistration $ DB.StakeDeregistration { DB.stakeDeregistrationAddrId = scId @@ -432,8 +432,8 @@ insertDelegation :: insertDelegation syncEnv cache network (EpochNo epoch) slotNo txId idx mRedeemerId cred poolkh = -- Check if the stake address is in the shelley whitelist when (shelleyCustomStakeWhitelistCheck syncEnv $ Ledger.RewardAccount network cred) $ do - addrId <- lift $ queryOrInsertStakeAddress syncEnv cache CacheNew network cred - poolHashId <- lift $ queryPoolKeyOrInsert "insertDelegation" syncEnv cache CacheNew True poolkh + addrId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache network cred + poolHashId <- lift $ queryPoolKeyOrInsert "insertDelegation" syncEnv cache UpdateCache True poolkh void . lift . DB.insertDelegation $ DB.Delegation { DB.delegationAddrId = addrId diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs index 87d3a828d..713a84127 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/GovAction.hs @@ -6,6 +6,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE NoImplicitPrelude #-} module Cardano.DbSync.Era.Universal.Insert.GovAction ( @@ -28,12 +29,14 @@ module Cardano.DbSync.Era.Universal.Insert.GovAction ( ) where +import Cardano.BM.Trace (logWarning) import qualified Cardano.Crypto as Crypto import Cardano.Db (DbWord64 (..)) import qualified Cardano.Db as DB +import Cardano.DbSync.Api (getTrace) import Cardano.DbSync.Api.Types (InsertOptions (..), SyncEnv (..), SyncOptions (..)) import Cardano.DbSync.Cache (queryOrInsertRewardAccount, queryPoolKeyOrInsert) -import Cardano.DbSync.Cache.Types (CacheStatus (..), CacheUpdateAction (..)) +import Cardano.DbSync.Cache.Types (CacheUpdateAction (..)) import Cardano.DbSync.Config.Types (ShelleyInsertConfig (..)) import qualified Cardano.DbSync.Era.Shelley.Generic as Generic import Cardano.DbSync.Era.Shelley.Generic.ParamProposal @@ -51,7 +54,7 @@ import Cardano.Ledger.CertState (DRep (..)) import Cardano.Ledger.Coin (Coin) import qualified Cardano.Ledger.Coin as Ledger import Cardano.Ledger.Compactible (Compactible (..)) -import Cardano.Ledger.Conway.Core (DRepVotingThresholds (..), PoolVotingThresholds (..)) +import Cardano.Ledger.Conway.Core (DRepVotingThresholds (..), Era (..), PoolVotingThresholds (..)) import Cardano.Ledger.Conway.Governance import qualified Cardano.Ledger.Credential as Ledger import Cardano.Ledger.DRep (DRepState (..)) @@ -84,7 +87,7 @@ insertGovActionProposal syncEnv blkId txId govExpiresAt mmCommittee (index, pp) -- check if shelley stake address is in the whitelist when (shelleyStakeAddrWhitelistCheck syncEnv $ pProcReturnAddr pp) $ do addrId <- lift $ queryOrInsertRewardAccount syncEnv cache UpdateCache $ pProcReturnAddr pp - votingAnchorId <- lift $ insertVotingAnchor txId DB.GovActionAnchor $ pProcAnchor pp + votingAnchorId <- lift $ insertVotingAnchor blkId DB.GovActionAnchor $ pProcAnchor pp mParamProposalId <- lift $ case pProcGovAction pp of ParameterChange _ pparams _ -> @@ -114,8 +117,8 @@ insertGovActionProposal syncEnv blkId txId govExpiresAt mmCommittee (index, pp) } case pProcGovAction pp of TreasuryWithdrawals mp _ -> lift $ mapM_ (insertTreasuryWithdrawal govActionProposalId) (Map.toList mp) - UpdateCommittee _ removed added q -> lift $ insertNewCommittee govActionProposalId removed added q - NewConstitution _ constitution -> lift $ insertConstitution txId govActionProposalId constitution + UpdateCommittee _ removed added q -> lift $ insertNewCommittee (Just govActionProposalId) removed added q + NewConstitution _ constitution -> void $ lift $ insertConstitution blkId (Just govActionProposalId) constitution _ -> pure () where cache = envCache syncEnv @@ -133,7 +136,7 @@ insertGovActionProposal syncEnv blkId txId govExpiresAt mmCommittee (index, pp) ReaderT SqlBackend m DB.TreasuryWithdrawalId insertTreasuryWithdrawal gaId (rwdAcc, coin) = do addrId <- - queryOrInsertRewardAccount cache UpdateCache rwdAcc + queryOrInsertRewardAccount syncEnv cache UpdateCache rwdAcc DB.insertTreasuryWithdrawal $ DB.TreasuryWithdrawal { DB.treasuryWithdrawalGovActionProposalId = gaId @@ -150,7 +153,6 @@ insertGovActionProposal syncEnv blkId txId govExpiresAt mmCommittee (index, pp) insertNewCommittee gapId removed added q = do void $ insertCommittee' gapId (updatedCommittee removed added q <$> mmCommittee) q - insertCommittee :: (MonadIO m, MonadBaseControl IO m) => Maybe DB.GovActionProposalId -> Committee StandardConway -> ReaderT SqlBackend m DB.CommitteeId insertCommittee mgapId committee = do insertCommittee' mgapId (Just committee) (committeeThreshold committee) @@ -290,29 +292,31 @@ insertConstitution blockId mgapId constitution = do insertVotingProcedures :: (MonadIO m, MonadBaseControl IO m) => SyncEnv -> + DB.BlockId -> DB.TxId -> [ProposalProcedure StandardConway] -> (Voter StandardCrypto, [(GovActionId StandardCrypto, VotingProcedure StandardConway)]) -> ExceptT SyncNodeError (ReaderT SqlBackend m) () -insertVotingProcedures syncEnv txId proposalPs (voter, actions) = +insertVotingProcedures syncEnv blkId txId proposalPs (voter, actions) = -- TODO: cmdv will actions & proposalPs always be the same length? - mapM_ (insertVotingProcedure syncEnv txId voter) (zip3 [0 ..] actions proposalPs) + mapM_ (insertVotingProcedure syncEnv blkId txId voter) (zip3 [0 ..] actions proposalPs) insertVotingProcedure :: (MonadIO m, MonadBaseControl IO m) => SyncEnv -> + DB.BlockId -> DB.TxId -> Voter StandardCrypto -> (Word16, (GovActionId StandardCrypto, VotingProcedure StandardConway), ProposalProcedure StandardConway) -> ExceptT SyncNodeError (ReaderT SqlBackend m) () -insertVotingProcedure syncEnv txId voter (index, (gaId, vp), proposalP) = do +insertVotingProcedure syncEnv blkId txId voter (index, (gaId, vp), proposalP) = do -- check if shelley stake address is in the whitelist when (shelleyStakeAddrWhitelistCheck syncEnv $ pProcReturnAddr proposalP) $ do maybeGovActionId <- resolveGovActionProposal syncEnv gaId case maybeGovActionId of Nothing -> pure () Just govActionId -> do - votingAnchorId <- whenMaybe (strictMaybeToMaybe $ vProcAnchor vp) $ lift . insertVotingAnchor txId DB.OtherAnchor + votingAnchorId <- whenMaybe (strictMaybeToMaybe $ vProcAnchor vp) $ lift . insertVotingAnchor blkId DB.OtherAnchor (mCommitteeVoterId, mDRepVoter, mStakePoolVoter) <- case voter of CommitteeVoter cred -> do khId <- lift $ insertCommitteeHash cred @@ -459,19 +463,19 @@ insertUpdateEnacted :: ExceptT SyncNodeError (ReaderT SqlBackend m) () insertUpdateEnacted syncEnv blkId epochNo enactedState = do whenJust (strictMaybeToMaybe (grPParamUpdate govIds)) $ \prevId -> do - maybeGaId <- resolveGovActionProposal syncEnv $ getPrevId prevId + maybeGaId <- resolveGovActionProposal syncEnv $ unGovPurposeId prevId case maybeGaId of Nothing -> pure () - Just gaId -> lift $ DB.updateGovActionEnacted gaId (unEpochNo epochNo) + Just gaId -> void $ lift $ DB.updateGovActionEnacted gaId (unEpochNo epochNo) whenJust (strictMaybeToMaybe (grHardFork govIds)) $ \prevId -> do - maybeGaId <- resolveGovActionProposal $ unGovPurposeId prevId + maybeGaId <- resolveGovActionProposal syncEnv $ unGovPurposeId prevId case maybeGaId of Nothing -> pure () Just gaId -> void $ lift $ DB.updateGovActionEnacted gaId (unEpochNo epochNo) - (mcommitteeId, mnoConfidenceGaId) <- handleCommittee syncEnv blkId + (mcommitteeId, mnoConfidenceGaId) <- handleCommittee syncEnv govIds epochNo enactedState - constitutionId <- handleConstitution syncEnv blkId + constitutionId <- handleConstitution syncEnv blkId govIds epochNo enactedState void $ lift $ @@ -485,7 +489,14 @@ insertUpdateEnacted syncEnv blkId epochNo enactedState = do where govIds = govStatePrevGovActionIds enactedState -handleCommittee syncEnv govIds blkId = do +handleCommittee :: + (EraCrypto era ~ StandardCrypto, MonadIO m, MonadBaseControl IO m) => + SyncEnv -> + GovRelation StrictMaybe era -> + EpochNo -> + ConwayGovState StandardConway -> + ExceptT SyncNodeError (ReaderT SqlBackend m) (Maybe DB.CommitteeId, Maybe DB.GovActionProposalId) +handleCommittee syncEnv govIds epochNo enactedState = do mCommitteeGaId <- case strictMaybeToMaybe (grCommittee govIds) of Nothing -> pure Nothing Just prevId -> do @@ -517,7 +528,7 @@ handleCommittee syncEnv govIds blkId = do -- This should never happen. Having a committee and an enacted action, means -- the committee came from a proposal which should be returned from the query. liftIO $ - logWarning trce $ + logWarning (getTrace syncEnv) $ mconcat [ "The impossible happened! Couldn't find the committee " , textShow committee @@ -528,7 +539,15 @@ handleCommittee syncEnv govIds blkId = do (committeeId : _rest) -> pure (Just committeeId, Nothing) -handleConstitution syncEnv govIds = do +handleConstitution :: + (EraCrypto era ~ StandardCrypto, MonadIO m, MonadBaseControl IO m) => + SyncEnv -> + DB.BlockId -> + GovRelation StrictMaybe era -> + EpochNo -> + ConwayGovState StandardConway -> + ExceptT SyncNodeError (ReaderT SqlBackend m) DB.ConstitutionId +handleConstitution syncEnv blkId govIds epochNo enactedState = do mConstitutionGaId <- case strictMaybeToMaybe (grConstitution govIds) of Nothing -> pure Nothing Just prevId -> do @@ -547,7 +566,7 @@ handleConstitution syncEnv govIds = do constitutionId : rest -> do unless (null rest) $ liftIO $ - logWarning trce $ + logWarning (getTrace syncEnv) $ mconcat [ "Found multiple constitutions for proposal " , textShow mConstitutionGaId @@ -555,16 +574,3 @@ handleConstitution syncEnv govIds = do , textShow constitutionIds ] pure constitutionId -======= - whenJust (strictMaybeToMaybe (grCommittee enactedState)) $ \prevId -> do - maybeGaId <- resolveGovActionProposal syncEnv $ unGovPurposeId prevId - case maybeGaId of - Nothing -> pure () - Just gaId -> lift $ DB.updateGovActionEnacted gaId (unEpochNo epochNo) - - whenJust (strictMaybeToMaybe (grConstitution enactedState)) $ \prevId -> do - maybeGaId <- resolveGovActionProposal syncEnv $ unGovPurposeId prevId - case maybeGaId of - Nothing -> pure () - Just gaId -> lift $ DB.updateGovActionEnacted gaId (unEpochNo epochNo) ->>>>>>> 328815aa (fix merge conflict errors) diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Other.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Other.hs index 1bc8369f4..eaeb158f6 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Other.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Other.hs @@ -14,6 +14,7 @@ module Cardano.DbSync.Era.Universal.Insert.Other ( insertRedeemerData, insertStakeAddressRefIfMissing, insertMultiAsset, + insertScriptWithWhitelist, insertScript, insertExtraKeyWitness, ) @@ -95,7 +96,7 @@ insertRedeemerData syncEnv txId txd = do case mRedeemerDataId of Just redeemerDataId -> pure redeemerDataId Nothing -> do - value <- safeDecodeToJson tracer "insertRedeemerData: Column 'value' in table 'datum' " $ Generic.txDataValue txd + value <- safeDecodeToJson syncEnv "insertRedeemerData: Column 'value' in table 'datum' " $ Generic.txDataValue txd lift . DB.insertRedeemerData $ DB.RedeemerData @@ -120,7 +121,7 @@ insertDatum syncEnv cache txId txd = do case mDatumId of Just datumId -> pure datumId Nothing -> do - value <- safeDecodeToJson tracer "insertDatum: Column 'value' in table 'redeemer' " $ Generic.txDataValue txd + value <- safeDecodeToJson syncEnv "insertDatum: Column 'value' in table 'redeemer' " $ Generic.txDataValue txd lift $ insertDatumAndCache cache (Generic.txDataHash txd) $ DB.Datum @@ -158,7 +159,7 @@ insertWithdrawals syncEnv cache txId redeemers txWdrl = do insertStakeAddressRefIfMissing :: (MonadBaseControl IO m, MonadIO m) => SyncEnv -> - Cache -> + CacheStatus -> Ledger.Addr StandardCrypto -> ReaderT SqlBackend m (Maybe DB.StakeAddressId) insertStakeAddressRefIfMissing syncEnv cache addr = @@ -168,17 +169,16 @@ insertStakeAddressRefIfMissing syncEnv cache addr = case sref of Ledger.StakeRefBase cred -> do -- Check if the stake address is in the shelley whitelist - if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount nw cred - then do - Just <$> queryOrInsertStakeAddress syncEnv cache DoNotUpdateCache nw cred - else pure Nothing + whenFalseEmpty + (shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount nw cred) + Nothing + (Just <$> queryOrInsertStakeAddress syncEnv cache DoNotUpdateCache nw cred) Ledger.StakeRefPtr ptr -> do queryStakeRefPtr ptr Ledger.StakeRefNull -> pure Nothing insertMultiAsset :: (MonadBaseControl IO m, MonadIO m) => - Trace IO Text -> CacheStatus -> Maybe (NonEmpty ShortByteString) -> PolicyID StandardCrypto -> @@ -205,36 +205,42 @@ insertMultiAsset cache mWhitelist policy aName = do , DB.multiAssetFingerprint = DB.unAssetFingerprint (DB.mkAssetFingerprint policyBs assetNameBs) } -insertScript :: +insertScriptWithWhitelist :: (MonadBaseControl IO m, MonadIO m) => SyncEnv -> DB.TxId -> Generic.TxScript -> ReaderT SqlBackend m (Maybe DB.ScriptId) -insertScript syncEnv txId script = +insertScriptWithWhitelist syncEnv txId script = do if isSimplePlutusScriptHashInWhitelist syncEnv $ Generic.txScriptHash script - then do - mScriptId <- DB.queryScript $ Generic.txScriptHash script - case mScriptId of - Just scriptId -> pure $ Just scriptId - Nothing -> do - json <- scriptConvert script - mInScript <- - DB.insertScript $ - DB.Script - { DB.scriptTxId = txId - , DB.scriptHash = Generic.txScriptHash script - , DB.scriptType = Generic.txScriptType script - , DB.scriptSerialisedSize = Generic.txScriptPlutusSize script - , DB.scriptJson = json - , DB.scriptBytes = Generic.txScriptCBOR script - } - pure $ Just mInScript + then insertScript syncEnv txId script <&> Just else pure Nothing + +insertScript :: + (MonadBaseControl IO m, MonadIO m) => + SyncEnv -> + DB.TxId -> + Generic.TxScript -> + ReaderT SqlBackend m DB.ScriptId +insertScript syncEnv txId script = do + mScriptId <- DB.queryScript $ Generic.txScriptHash script + case mScriptId of + Just scriptId -> pure scriptId + Nothing -> do + json <- scriptConvert script + DB.insertScript $ + DB.Script + { DB.scriptTxId = txId + , DB.scriptHash = Generic.txScriptHash script + , DB.scriptType = Generic.txScriptType script + , DB.scriptSerialisedSize = Generic.txScriptPlutusSize script + , DB.scriptJson = json + , DB.scriptBytes = Generic.txScriptCBOR script + } where scriptConvert :: (MonadIO m) => Generic.TxScript -> m (Maybe Text) scriptConvert s = - maybe (pure Nothing) (safeDecodeToJson tracer "insertScript: Column 'json' in table 'script' ") (Generic.txScriptJson s) + maybe (pure Nothing) (safeDecodeToJson syncEnv "insertScript: Column 'json' in table 'script' ") (Generic.txScriptJson s) insertExtraKeyWitness :: (MonadBaseControl IO m, MonadIO m) => diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Pool.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Pool.hs index 41e1ed831..773705254 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Pool.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Pool.hs @@ -5,6 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# OPTIONS_GHC -Wno-deprecations #-} module Cardano.DbSync.Era.Universal.Insert.Pool ( IsPoolMember, @@ -152,7 +153,7 @@ insertPoolOwner :: ExceptT SyncNodeError (ReaderT SqlBackend m) () insertPoolOwner syncEnv cache network poolUpdateId skh = -- Check if the stake address is in the shelley whitelist - when (shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAcnt network (Ledger.KeyHashObj skh)) $ do + when (shelleyStakeAddrWhitelistCheck syncEnv $ Ledger.RewardAccount network (Ledger.KeyHashObj skh)) $ do saId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache network (Ledger.KeyHashObj skh) void . lift . DB.insertPoolOwner $ DB.PoolOwner diff --git a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Tx.hs b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Tx.hs index acd5e79eb..b6a2edd21 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Tx.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Tx.hs @@ -36,6 +36,7 @@ import Cardano.DbSync.Era.Universal.Insert.Other ( insertMultiAsset, insertRedeemer, insertScript, + insertScriptWithWhitelist, insertStakeAddressRefIfMissing, insertWithdrawals, ) @@ -80,6 +81,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped let !outSum = fromIntegral $ unCoin $ Generic.txOutSum tx !withdrawalSum = fromIntegral $ unCoin $ Generic.txWithdrawalSum tx hasConsumed = getHasConsumedOrPruneTxOut syncEnv + disInOut <- liftIO $ getDisableInOutState syncEnv -- In some txs and with specific configuration we may be able to find necessary data within the tx body. -- In these cases we can avoid expensive queries. @@ -124,7 +126,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped if not (Generic.txValidContract tx) then do !txOutsGrouped <- do - if plutusMultiAssetWhitelistCheck syncEnv txMints txOuts + if isplutusMultiAssetInWhitelist then mapMaybeM (insertTxOut syncEnv cache iopts (txId, txHash)) txOuts else pure mempty @@ -136,7 +138,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped -- The following operations only happen if the script passes stage 2 validation (or the tx has -- no script). !txOutsGrouped <- do - if plutusMultiAssetWhitelistCheck syncEnv txMints txOuts + if isplutusMultiAssetInWhitelist then mapMaybeM (insertTxOut syncEnv cache iopts (txId, txHash)) txOuts else pure mempty @@ -150,9 +152,9 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped mapM_ (insertDatum syncEnv cache txId) (Generic.txData tx) mapM_ (insertCollateralTxIn tracer txId) (Generic.txCollateralInputs tx) mapM_ (insertReferenceTxIn tracer txId) (Generic.txReferenceInputs tx) - mapM_ (insertCollateralTxOut syncEnv cache (txId, txHash)) (Generic.txCollateralOutputs tx) - mapM_ (lift . insertScript syncEnv txId) $ Generic.txScripts tx mapM_ (insertExtraKeyWitness txId) $ Generic.txExtraKeyWitnesses tx + mapM_ (lift . insertScriptWithWhitelist syncEnv txId) $ Generic.txScripts tx + mapM_ (insertCollateralTxOut syncEnv cache (txId, txHash)) (Generic.txCollateralOutputs tx) txMetadata <- do case ioMetadata iopts of @@ -176,7 +178,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped when (ioGov iopts) $ do mapM_ (insertGovActionProposal syncEnv blkId txId (getGovExpiresAt applyResult epochNo) (apCommittee applyResult)) $ zip [0 ..] (Generic.txProposalProcedure tx) - mapM_ (insertVotingProcedures syncEnv txId (Generic.txProposalProcedure tx)) (Generic.txVotingProcedure tx) + mapM_ (insertVotingProcedures syncEnv blkId txId (Generic.txProposalProcedure tx)) (Generic.txVotingProcedure tx) let !txIns = map (prepareTxIn txId redeemers) resolvedInputs pure (grouped <> BlockGroupedData txIns txOutsGrouped txMetadata maTxMint resolvedFees outSum) @@ -187,6 +189,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped cache = envCache syncEnv iopts = getInsertOptions syncEnv mDeposits = maybeFromStrict $ apDeposits applyResult + isplutusMultiAssetInWhitelist = plutusMultiAssetWhitelistCheck syncEnv txMints txOuts -------------------------------------------------------------------------------------- -- INSERT TXOUT @@ -210,7 +213,7 @@ insertTxOut syncEnv cache iopts (txId, txHash) (Generic.TxOut index addr value m buildExtendedTxOutPart1 = do mDatumId <- Generic.whenInlineDatum dt $ insertDatum syncEnv cache txId mScriptId <- case mScript of - Just script -> lift $ insertScript syncEnv txId script + Just script -> lift $ Just <$> insertScript syncEnv txId script Nothing -> pure Nothing buildExtendedTxOutPart2 mDatumId mScriptId @@ -290,7 +293,7 @@ prepareTxMetadata syncEnv mWhitelist txId mmetadata = mkDbTxMetadata (key, md) = do let jsonbs = LBS.toStrict $ Aeson.encode (metadataValueToJsonNoSchema md) singleKeyCBORMetadata = serialiseTxMetadataToCbor $ Map.singleton key md - mjson <- safeDecodeToJson tracer "prepareTxMetadata: Column 'json' in table 'metadata' " jsonbs + mjson <- safeDecodeToJson syncEnv "prepareTxMetadata: Column 'json' in table 'metadata' " jsonbs pure $ DB.TxMetadata { DB.txMetadataKey = DbWord64 key @@ -304,7 +307,6 @@ prepareTxMetadata syncEnv mWhitelist txId mmetadata = -------------------------------------------------------------------------------------- insertMaTxMint :: (MonadBaseControl IO m, MonadIO m) => - Trace IO Text -> CacheStatus -> Maybe (NonEmpty ShortByteString) -> DB.TxId -> @@ -339,7 +341,6 @@ insertMaTxMint cache mWhitelist txId (MultiAsset mintMap) = insertMaTxOuts :: (MonadBaseControl IO m, MonadIO m) => - Trace IO Text -> CacheStatus -> Maybe (NonEmpty ShortByteString) -> Map (PolicyID StandardCrypto) (Map AssetName Integer) -> @@ -374,7 +375,6 @@ insertCollateralTxOut :: (MonadBaseControl IO m, MonadIO m) => SyncEnv -> CacheStatus -> - InsertOptions -> (DB.TxId, ByteString) -> Generic.TxOut -> ExceptT SyncNodeError (ReaderT SqlBackend m) () @@ -389,7 +389,7 @@ insertCollateralTxOut syncEnv cache (txId, _txHash) txout@(Generic.TxOut index a insertColTxOutPart1 = do mDatumId <- Generic.whenInlineDatum dt $ insertDatum syncEnv cache txId mScriptId <- case mScript of - Just script -> lift $ insertScript syncEnv txId script + Just script -> lift $ Just <$> insertScript syncEnv txId script Nothing -> pure Nothing insertColTxOutPart2 mDatumId mScriptId pure () diff --git a/cardano-db-sync/src/Cardano/DbSync/Util/Whitelist.hs b/cardano-db-sync/src/Cardano/DbSync/Util/Whitelist.hs index 0785a7dd2..aec4ec341 100644 --- a/cardano-db-sync/src/Cardano/DbSync/Util/Whitelist.hs +++ b/cardano-db-sync/src/Cardano/DbSync/Util/Whitelist.hs @@ -26,18 +26,16 @@ plutusMultiAssetWhitelistCheck :: plutusMultiAssetWhitelistCheck syncEnv txMints txOuts = isPlutusScriptHashesInWhitelist syncEnv txOuts || isMAPoliciesInWhitelist syncEnv txMints txOuts +-- | Check if any script hash or address is in the whitelist isPlutusScriptHashesInWhitelist :: SyncEnv -> [Generic.TxOut] -> Bool isPlutusScriptHashesInWhitelist syncEnv txOuts = do - -- first check the config option case ioPlutus iopts of PlutusEnable -> True PlutusDisable -> False - PlutusScripts plutusWhitelist -> plutuswhitelistCheck plutusWhitelist + PlutusScripts whitelist -> + any (\txOut -> isScriptHashWhitelisted whitelist txOut || isAddressWhitelisted whitelist txOut) txOuts where iopts = soptInsertOptions $ envOptions syncEnv - plutuswhitelistCheck :: NonEmpty ShortByteString -> Bool - plutuswhitelistCheck whitelist = - any (\txOut -> isScriptHashWhitelisted whitelist txOut || isAddressWhitelisted whitelist txOut) txOuts -- check if the script hash is in the whitelist isScriptHashWhitelisted :: NonEmpty ShortByteString -> Generic.TxOut -> Bool isScriptHashWhitelisted whitelist txOut = @@ -51,7 +49,7 @@ isSimplePlutusScriptHashInWhitelist :: SyncEnv -> ByteString -> Bool isSimplePlutusScriptHashInWhitelist syncEnv scriptHash = do case ioPlutus iopts of PlutusEnable -> True - PlutusDisable -> True + PlutusDisable -> False PlutusScripts plutusWhitelist -> toShort scriptHash `elem` plutusWhitelist where iopts = soptInsertOptions $ envOptions syncEnv