From 334d604291bcbc79e1097f323fa841ae1f8a5589 Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Fri, 16 Jan 2026 17:13:54 +0000 Subject: [PATCH 01/11] Implement InitialGasModel --- chainweb.cabal | 1 + src/Chainweb/Pact/PactService.hs | 2 +- .../Pact/PactService/Pact5/ExecBlock.hs | 3 +- src/Chainweb/Pact5/InitialGasModel.hs | 77 +++++++++++++++++++ src/Chainweb/Pact5/TransactionExec.hs | 47 +++++------ src/Chainweb/Version.hs | 4 + src/Chainweb/Version/Development.hs | 2 + src/Chainweb/Version/Guards.hs | 8 ++ src/Chainweb/Version/Mainnet.hs | 5 ++ src/Chainweb/Version/RecapDevelopment.hs | 7 ++ src/Chainweb/Version/Testnet04.hs | 5 ++ test/lib/Chainweb/Test/TestVersions.hs | 4 + 12 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 src/Chainweb/Pact5/InitialGasModel.hs diff --git a/chainweb.cabal b/chainweb.cabal index 6539136bd4..ff344feee1 100644 --- a/chainweb.cabal +++ b/chainweb.cabal @@ -343,6 +343,7 @@ library , Chainweb.Pact5.TransactionExec , Chainweb.Pact5.Types , Chainweb.Pact5.Validations + , Chainweb.Pact5.InitialGasModel , Chainweb.Pact.Transactions.FungibleV2Transactions , Chainweb.Pact.Transactions.CoinV3Transactions , Chainweb.Pact.Transactions.CoinV4Transactions diff --git a/src/Chainweb/Pact/PactService.hs b/src/Chainweb/Pact/PactService.hs index 0852ac0c3f..2227666bcd 100644 --- a/src/Chainweb/Pact/PactService.hs +++ b/src/Chainweb/Pact/PactService.hs @@ -918,7 +918,7 @@ execLocal cwtx preflight sigVerify rdepth = pactLabel "execLocal" $ do lift (Pact5.liftPactServiceM (Pact5.assertPreflightMetadata (view Pact5.payloadObj <$> pact5Cmd) txCtx sigVerify)) >>= \case Left err -> earlyReturn $ review _MetadataValidationFailure err Right () -> return () - let initialGas = Pact5.initialGasOf v cid (Pact5.ctxCurrentBlockHeight txCtx) $ Pact5._cmdPayload pact5Cmd + let initialGas = Pact5.initialGasOf v cid (Pact5.ctxCurrentBlockHeight txCtx) (Pact5.ctxParentForkNumber txCtx) pact5Cmd applyCmdResult <- lift $ Pact5.pactTransaction Nothing (\dbEnv -> Pact5.applyCmd _psLogger _psGasLogger dbEnv diff --git a/src/Chainweb/Pact/PactService/Pact5/ExecBlock.hs b/src/Chainweb/Pact/PactService/Pact5/ExecBlock.hs index 44f5bc2b50..567da7aa93 100644 --- a/src/Chainweb/Pact/PactService/Pact5/ExecBlock.hs +++ b/src/Chainweb/Pact/PactService/Pact5/ExecBlock.hs @@ -359,7 +359,8 @@ applyPactCmd env miner txIdxInBlock tx = StateT $ \(blockHandle, blockGasRemaini (unsafeApplyPactCmd blockHandle (initialGasOf (_chainwebVersion env) (Chainweb.Version._chainId env) (env ^. psParentHeader . parentHeader . blockHeight) - (tx ^. Pact5.cmdPayload)) + (env ^. psParentHeader . parentHeader . blockForkNumber) + tx) alteredTx) env case resultOrGasError of diff --git a/src/Chainweb/Pact5/InitialGasModel.hs b/src/Chainweb/Pact5/InitialGasModel.hs new file mode 100644 index 0000000000..80403385c1 --- /dev/null +++ b/src/Chainweb/Pact5/InitialGasModel.hs @@ -0,0 +1,77 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE BangPatterns #-} + +module Chainweb.Pact5.InitialGasModel + ( InitialGasModel(..) + , pre31GasModel + , post31GasModel + , post32GasModel + -- Lenses + , feePerByte + , rawPayloadSizeFactor + , proofSizeFactor + , signatureSizeFactor + , sizePenalty + , signatureCost + ) where + +import Control.DeepSeq +import Pact.Core.Scheme +import Control.Lens + + +data InitialGasModel = InitialGasModel + { _feePerByte :: Rational + -- ^ Base Price charged per byte + , _rawPayloadSizeFactor :: Rational + -- ^ Multiplier for the raw payload (without continuation proof) size + , _proofSizeFactor :: Rational + -- ^ Multiplier for the proof size + , _signatureSizeFactor :: Rational + -- ^ Multiplier for signatures size + , _sizePenalty :: Rational -> Rational + -- ^ Function used to compute a penalty for big transactions + , _signatureCost :: PPKScheme -> Rational + -- ^ Function used to compute a fixed amount of gas per signature + } + +-- Required to be used as a rule +instance NFData InitialGasModel where + rnf (InitialGasModel {}) = () + +makeLenses ''InitialGasModel + +pre31GasModel :: InitialGasModel +pre31GasModel = InitialGasModel + { _feePerByte = 0.01 + , _rawPayloadSizeFactor = 1.0 + , _proofSizeFactor = 0.0 + , _signatureSizeFactor = 0.0 + , _sizePenalty = \x -> (x / 512) ^ (7 :: Integer) + , _signatureCost = const 0.0 + } + + +post31GasModel :: InitialGasModel +post31GasModel = InitialGasModel + { _feePerByte = 0.01 + , _rawPayloadSizeFactor = 1.0 + , _proofSizeFactor = 1.0 + , _signatureSizeFactor = 0.0 + , _sizePenalty = \x -> (x / 512) ^ (7 :: Integer) + , _signatureCost = const 0.0 + } + + +post32GasModel :: InitialGasModel +post32GasModel = InitialGasModel + { _feePerByte = 0.01 + , _rawPayloadSizeFactor = 1.0 + , _proofSizeFactor = 1.0 + , _signatureSizeFactor = 1.0 + , _sizePenalty = \x -> (x / 512) ^ (7 :: Integer) + , _signatureCost = \case + ED25519 -> 10.0 -- | TODO => Needs to be benchmarked + WebAuthn -> 10.0 -- | + } diff --git a/src/Chainweb/Pact5/TransactionExec.hs b/src/Chainweb/Pact5/TransactionExec.hs index 3be1e01d5b..eb21f7933c 100644 --- a/src/Chainweb/Pact5/TransactionExec.hs +++ b/src/Chainweb/Pact5/TransactionExec.hs @@ -86,6 +86,7 @@ import Pact.Core.Hash import Pact.Core.Info import Pact.Core.Names import Pact.Core.Namespace +import Pact.Core.Scheme (defPPKScheme) import Pact.Core.PactValue import Pact.Core.Persistence.Types hiding (GasM(..)) import Pact.Core.Persistence.Utils (ignoreGas) @@ -103,11 +104,13 @@ import Chainweb.BlockCreationTime import Chainweb.BlockHash import Chainweb.BlockHeader import Chainweb.BlockHeight +import Chainweb.ForkState import Chainweb.Logger import Chainweb.Miner.Pact import Chainweb.Pact.Types import Chainweb.Pact5.Templates import Chainweb.Pact5.Types +import Chainweb.Pact5.InitialGasModel import Chainweb.Time import Chainweb.Pact5.Transaction @@ -977,33 +980,25 @@ redeemGas logger db txCtx gasUsed maybeFundTxPactId cmd -- -- Utilities -- | Initial gas charged for transaction size --- ignoring the size of a continuation proof, if present --- -initialGasOf :: ChainwebVersion -> V.ChainId -> BlockHeight -> PayloadWithText meta ParsedCode -> Gas -initialGasOf v cid bh payload = Gas gasFee - where - feePerByte :: Rational = 0.01 - - contProofSize = - case payload ^. payloadObj . pPayload of - Continuation (ContMsg _ _ _ _ (Just (ContProof p))) -> B.length p - _ -> 0 - txSize - | chainweb31 v cid bh = SB.length (payload ^. payloadBytes) - | otherwise = SB.length (payload ^. payloadBytes) - contProofSize - - costPerByte = fromIntegral txSize * feePerByte - sizePenalty = txSizeAccelerationFee costPerByte - gasFee = ceiling (costPerByte + sizePenalty) -{-# INLINE initialGasOf #-} - -txSizeAccelerationFee :: Rational -> Rational -txSizeAccelerationFee costPerByte = total +initialGasOf :: ChainwebVersion -> V.ChainId -> BlockHeight -> ForkNumber -> Transaction -> Gas +initialGasOf v cid bh fn tx = Gas $ ceiling $ sizeCost + sizePenaltyCost + sigsCost where - total = (costPerByte / bytePenalty) ^ power - bytePenalty = 512 - power :: Integer = 7 -{-# INLINE txSizeAccelerationFee #-} + model = activeInitialGasModel v cid fn bh + proofSize = case tx ^. cmdPayload . payloadObj . pPayload of + Continuation (ContMsg _ _ _ _ (Just (ContProof p))) -> B.length p + _ -> 0 + + rawSize = SB.length (tx ^. cmdPayload . payloadBytes) - proofSize + sigsSize = sum $ map (B.length . J.encodeStrict) $ tx ^. cmdSigs + + sizeCost = model ^. feePerByte * ( model ^. rawPayloadSizeFactor * fromIntegral rawSize + + model ^. proofSizeFactor * fromIntegral proofSize + + model ^. signatureSizeFactor * fromIntegral sigsSize) + sizePenaltyCost = (model ^. sizePenalty) sizeCost + + sigsCost = sum $ map ((model ^. signatureCost) . fromMaybe defPPKScheme . view siScheme) + $ tx ^. cmdPayload . payloadObj . pSigners + -- | Chainweb's namespace policy for ordinary transactions. -- Doesn't allow installing modules in the root namespace. diff --git a/src/Chainweb/Version.hs b/src/Chainweb/Version.hs index 0319d7610d..521ac02e07 100644 --- a/src/Chainweb/Version.hs +++ b/src/Chainweb/Version.hs @@ -70,6 +70,7 @@ module Chainweb.Version , versionGraphs , versionHeaderBaseSizeBytes , versionMaxBlockGasLimit + , versionInitialGasModel , versionSpvProofRootValidWindow , versionName , versionWindow @@ -184,6 +185,7 @@ import Chainweb.MerkleUniverse import Chainweb.Payload import Chainweb.Pact4.Transaction qualified as Pact4 import Chainweb.Pact5.Transaction qualified as Pact5 +import Chainweb.Pact5.InitialGasModel import Chainweb.ForkState import Chainweb.Utils import Chainweb.Utils.Rule @@ -539,6 +541,8 @@ data ChainwebVersion , _versionSpvProofRootValidWindow :: Rule ForkHeight (Maybe Word64) -- ^ The minimum number of block headers a chainweb node should -- retain in its history at all times. + , _versionInitialGasModel :: ChainMap (Rule ForkHeight (InitialGasModel)) + -- ^ The initial gas model used for Pact 5 transactions processing , _versionBootstraps :: [PeerInfo] -- ^ The locations of the bootstrap peers. , _versionGenesis :: VersionGenesis diff --git a/src/Chainweb/Version/Development.hs b/src/Chainweb/Version/Development.hs index 9084dd81e3..93541028d5 100644 --- a/src/Chainweb/Version/Development.hs +++ b/src/Chainweb/Version/Development.hs @@ -12,6 +12,7 @@ import qualified Data.Set as Set import Chainweb.BlockCreationTime import Chainweb.ChainId import Chainweb.Difficulty +import Chainweb.Pact5.InitialGasModel import Chainweb.Graph import Chainweb.Time import Chainweb.Utils @@ -52,6 +53,7 @@ devnet = ChainwebVersion -- defaultChainwebConfiguration._configBlockGasLimit , _versionMaxBlockGasLimit = Bottom (minBound, Nothing) , _versionSpvProofRootValidWindow = Bottom (minBound, Nothing) + , _versionInitialGasModel = AllChains $ Bottom (minBound, post32GasModel) , _versionCheats = VersionCheats { _disablePow = True , _fakeFirstEpochStart = True diff --git a/src/Chainweb/Version/Guards.hs b/src/Chainweb/Version/Guards.hs index 3c1e631409..5335586fac 100644 --- a/src/Chainweb/Version/Guards.hs +++ b/src/Chainweb/Version/Guards.hs @@ -57,6 +57,7 @@ module Chainweb.Version.Guards , pact4ParserVersion , maxBlockGasLimit , minimumBlockHeaderHistory + , activeInitialGasModel , validPPKSchemes , isWebAuthnPrefixLegal , validKeyFormats @@ -75,6 +76,7 @@ import Chainweb.Pact4.Transaction qualified as Pact4 import Chainweb.Utils.Rule import Chainweb.ForkState import Chainweb.Version +import Chainweb.Pact5.InitialGasModel import Control.Lens import Data.Word (Word64) import Numeric.Natural @@ -348,6 +350,12 @@ minimumBlockHeaderHistory v fn bh = snd $ ruleZipperHere $ snd where searchKey = ForkAtBlockHeight bh `max` ForkAtForkNumber fn +activeInitialGasModel :: ChainwebVersion -> ChainId -> ForkNumber -> BlockHeight -> InitialGasModel +activeInitialGasModel v cid fn bh = snd $ ruleZipperHere $ snd + $ ruleSeek (\h _ -> searchKey >= h) $ v ^?! versionInitialGasModel . atChain cid + where + searchKey = ForkAtBlockHeight bh `max` ForkAtForkNumber fn + -- | Different versions of Chainweb allow different PPKSchemes. -- validPPKSchemes :: ChainwebVersion -> ChainId -> BlockHeight -> [PPKScheme] diff --git a/src/Chainweb/Version/Mainnet.hs b/src/Chainweb/Version/Mainnet.hs index d7a460da7e..16c24730f1 100644 --- a/src/Chainweb/Version/Mainnet.hs +++ b/src/Chainweb/Version/Mainnet.hs @@ -16,6 +16,7 @@ import Chainweb.BlockHeight import Chainweb.ChainId import Chainweb.Difficulty import Chainweb.Graph +import Chainweb.Pact5.InitialGasModel import Chainweb.Time import Chainweb.Utils import Chainweb.Utils.Rule @@ -166,6 +167,10 @@ mainnet = ChainwebVersion , _versionMaxBlockGasLimit = (succByHeight $ mainnet ^?! versionForks . at Chainweb216Pact . _Just . atChain (unsafeChainId 0), Just 180_000) `Above` Bottom (minBound, Nothing) + , _versionInitialGasModel = AllChains $ + (ForkNever, post32GasModel) `Above` + (succByHeight $ mainnet ^?! versionForks . at Chainweb231Pact . _Just . atChain (unsafeChainId 0), post31GasModel) `Above` + Bottom (minBound, pre31GasModel) , _versionSpvProofRootValidWindow = (succByHeight $ mainnet ^?! versionForks . at Chainweb31 . _Just . atChain (unsafeChainId 0), Nothing) `Above` (succByHeight $ mainnet ^?! versionForks . at Chainweb231Pact . _Just . atChain (unsafeChainId 0) , Just 20_000) `Above` diff --git a/src/Chainweb/Version/RecapDevelopment.hs b/src/Chainweb/Version/RecapDevelopment.hs index a21a423cbb..dd5ceeb248 100644 --- a/src/Chainweb/Version/RecapDevelopment.hs +++ b/src/Chainweb/Version/RecapDevelopment.hs @@ -9,10 +9,12 @@ module Chainweb.Version.RecapDevelopment(recapDevnet, pattern RecapDevelopment) import qualified Data.HashMap.Strict as HM import qualified Data.Set as Set +import Control.Lens import Chainweb.BlockCreationTime import Chainweb.BlockHeight import Chainweb.ChainId +import Chainweb.Pact5.InitialGasModel import Chainweb.Difficulty import Chainweb.Graph import Chainweb.Time @@ -113,6 +115,11 @@ recapDevnet = ChainwebVersion } , _versionMaxBlockGasLimit = Bottom (minBound, Just 180_000) + , _versionInitialGasModel = AllChains $ + (ForkNever, post32GasModel) `Above` + (succByHeight $ recapDevnet ^?! versionForks . at Chainweb231Pact . _Just . atChain (unsafeChainId 0), post31GasModel) `Above` + Bottom (minBound, pre31GasModel) + , _versionSpvProofRootValidWindow = Bottom (minBound, Nothing) , _versionCheats = VersionCheats { _disablePow = False diff --git a/src/Chainweb/Version/Testnet04.hs b/src/Chainweb/Version/Testnet04.hs index ef5ffe7b59..a98d9d4b33 100644 --- a/src/Chainweb/Version/Testnet04.hs +++ b/src/Chainweb/Version/Testnet04.hs @@ -16,6 +16,7 @@ import Chainweb.BlockHeight import Chainweb.ChainId import Chainweb.Difficulty import Chainweb.Graph +import Chainweb.Pact5.InitialGasModel import Chainweb.Time import Chainweb.Utils import Chainweb.Utils.Rule @@ -146,6 +147,10 @@ testnet04 = ChainwebVersion , _versionMaxBlockGasLimit = (succByHeight $ testnet04 ^?! versionForks . at Chainweb216Pact . _Just . atChain (unsafeChainId 0) , Just 180_000) `Above` Bottom (minBound, Nothing) + , _versionInitialGasModel = AllChains $ + (ForkNever, post32GasModel) `Above` + (succByHeight $ testnet04 ^?! versionForks . at Chainweb231Pact . _Just . atChain (unsafeChainId 0), post31GasModel) `Above` + Bottom (minBound, pre31GasModel) , _versionSpvProofRootValidWindow = (succByHeight $ testnet04 ^?! versionForks . at Chainweb231Pact . _Just . atChain (unsafeChainId 0) , Just 20_000) `Above` Bottom (minBound, Nothing) diff --git a/test/lib/Chainweb/Test/TestVersions.hs b/test/lib/Chainweb/Test/TestVersions.hs index 8f24d89ac9..f19f03d63e 100644 --- a/test/lib/Chainweb/Test/TestVersions.hs +++ b/test/lib/Chainweb/Test/TestVersions.hs @@ -51,6 +51,7 @@ import Chainweb.Difficulty import Chainweb.ForkState import Chainweb.Graph import Chainweb.HostAddress +import Chainweb.Pact5.InitialGasModel import Chainweb.Pact.Utils import Chainweb.Time import Chainweb.Utils @@ -166,6 +167,7 @@ testVersionTemplate v = v & versionWindow .~ WindowWidth 120 & versionMaxBlockGasLimit .~ Bottom (minBound, Just 2_000_000) & versionSpvProofRootValidWindow .~ Bottom (minBound, Just 20) + & versionInitialGasModel .~ AllChains (Bottom (minBound, pre31GasModel)) & versionBootstraps .~ [testBootstrapPeerInfos] & versionVerifierPluginNames .~ AllChains (Bottom (minBound, mempty)) & versionForkNumber .~ 0 @@ -478,6 +480,8 @@ pact5InstantCpmTestVersion :: Bool -> ChainGraph -> ChainwebVersion pact5InstantCpmTestVersion migrate g = buildTestVersion $ \v -> v & cpmTestVersion g & versionName .~ ChainwebVersionName ("instant-pact5-CPM-" <> toText g <> if migrate then "-migrate" else "") + -- Used to check gas for xChain -- + & versionInitialGasModel .~ AllChains (Bottom (minBound, post31GasModel)) & versionForks .~ tabulateHashMap (\case -- SPV Bridge is not in effect for Pact 5 yet. SPVBridge -> AllChains ForkNever From 4547ae1849978a65fd7cbc743a9399c94a689492 Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Wed, 4 Feb 2026 12:23:40 +0000 Subject: [PATCH 02/11] Allow PactServicesTests to handle multi-chains tests --- .../Chainweb/Test/Pact5/PactServiceTest.hs | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs index bebdab284d..44f7d31920 100644 --- a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs +++ b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs @@ -27,7 +27,7 @@ import Chainweb.BlockHeader import Chainweb.ChainId import Chainweb.Chainweb import Chainweb.Cut -import Chainweb.Graph (singletonChainGraph) +import Chainweb.Graph (singletonChainGraph, pairChainGraph) import Chainweb.Logger import Chainweb.Mempool.Consensus import Chainweb.Mempool.InMem @@ -45,7 +45,7 @@ import Chainweb.Payload import Chainweb.Storage.Table.RocksDB import Chainweb.Test.Cut.TestBlockDb (TestBlockDb (_bdbPayloadDb, _bdbWebBlockHeaderDb), addTestBlockDb, getCutTestBlockDb, getParentTestBlockDb, mkTestBlockDb, setCutTestBlockDb) import Chainweb.Test.Pact5.CmdBuilder -import Chainweb.Test.Pact5.Utils hiding (withTempSQLiteResource) +import Chainweb.Test.Pact5.Utils hiding (withInMemSQLiteResource) import Chainweb.Test.TestVersions import Chainweb.Test.Utils import Chainweb.Time @@ -86,31 +86,34 @@ import Test.Tasty.HUnit (assertBool, assertEqual, assertFailure, testCase) import Text.Printf (printf) data Fixture = Fixture - { _fixtureBlockDb :: TestBlockDb + { _fixtureChains :: [ChainId] + , _fixtureBlockDb :: TestBlockDb , _fixtureMempools :: ChainMap (MempoolBackend Pact4.UnparsedTransaction) , _fixturePactQueues :: ChainMap PactQueue } -mkFixtureWith :: PactServiceConfig -> RocksDb -> ResourceT IO Fixture -mkFixtureWith pactServiceConfig baseRdb = do - sqlite <- withTempSQLiteResource - tdb <- mkTestBlockDb v baseRdb - perChain <- iforM (HashSet.toMap (chainIds v)) $ \chain () -> do +mkFixtureWith :: PactServiceConfig -> ChainwebVersion -> RocksDb -> ResourceT IO Fixture +mkFixtureWith pactServiceConfig v' baseRdb = do + + tdb <- mkTestBlockDb v' baseRdb + perChain <- iforM (HashSet.toMap (chainIds v')) $ \chain () -> do + sqlite <- withInMemSQLiteResource bhdb <- liftIO $ getWebBlockHeaderDb (_bdbWebBlockHeaderDb tdb) chain pactQueue <- liftIO $ newPactQueue 2_000 pactExecutionServiceVar <- liftIO $ newMVar (mkPactExecutionService pactQueue) - let mempoolCfg = validatingMempoolConfig chain v (Pact4.GasLimit 150_000) (Pact4.GasPrice 1e-8) pactExecutionServiceVar + let mempoolCfg = validatingMempoolConfig chain v' (Pact4.GasLimit 150_000) (Pact4.GasPrice 1e-8) pactExecutionServiceVar logLevel <- liftIO getTestLogLevel let logger = genericLogger logLevel Text.putStrLn mempool <- liftIO $ startInMemoryMempoolTest mempoolCfg mempoolConsensus <- liftIO $ mkMempoolConsensus mempool bhdb (Just (_bdbPayloadDb tdb)) let mempoolAccess = pactMemPoolAccess mempoolConsensus logger _ <- Resource.allocate - (forkIO $ runPactService v chain logger Nothing pactQueue mempoolAccess bhdb (_bdbPayloadDb tdb) sqlite pactServiceConfig) + (forkIO $ runPactService v' chain logger Nothing pactQueue mempoolAccess bhdb (_bdbPayloadDb tdb) sqlite pactServiceConfig) (\tid -> throwTo tid ThreadKilled) return (mempool, pactQueue) let fixture = Fixture - { _fixtureBlockDb = tdb + { _fixtureChains = HashSet.toList $ chainIds v' + , _fixtureBlockDb = tdb , _fixtureMempools = OnChains $ fst <$> perChain , _fixturePactQueues = OnChains $ snd <$> perChain } @@ -121,8 +124,10 @@ mkFixtureWith pactServiceConfig baseRdb = do return fixture mkFixture :: RocksDb -> ResourceT IO Fixture -mkFixture baseRdb = do - mkFixtureWith testPactServiceConfig baseRdb +mkFixture = mkFixtureWith testPactServiceConfig v + +mkFixtureDual :: RocksDb -> ResourceT IO Fixture +mkFixtureDual = mkFixtureWith testPactServiceConfig vPair tests :: RocksDb -> TestTree tests baseRdb = testGroup "Pact5 PactServiceTest" @@ -242,7 +247,7 @@ newBlockTimeoutSpec baseRdb = runResourceT $ do -- it should be long enough that `timeoutTx` times out -- but neither `tx1` nor `tx2` time out. } - fixture <- mkFixtureWith pactServiceConfig baseRdb + fixture <- mkFixtureWith pactServiceConfig v baseRdb liftIO $ do tx1 <- buildCwCmd v (defaultCmd chain0) @@ -585,9 +590,15 @@ tests = do chain0 :: ChainId chain0 = unsafeChainId 0 +chain1 :: ChainId +chain1 = unsafeChainId 1 + v :: ChainwebVersion v = pact5InstantCpmTestVersion False singletonChainGraph +vPair :: ChainwebVersion +vPair = pact5InstantCpmTestVersion False pairChainGraph + advanceAllChainsWithTxs :: Fixture -> ChainMap [Pact5.Transaction] -> IO (ChainMap (Vector TestPact5CommandResult)) advanceAllChainsWithTxs fixture txsPerChain = advanceAllChains fixture $ @@ -606,7 +617,7 @@ advanceAllChains :: () -> IO (ChainMap (Vector TestPact5CommandResult)) advanceAllChains Fixture{..} blocks = do commandResults <- - forConcurrently (HashSet.toList (chainIds v)) $ \c -> do + forConcurrently _fixtureChains $ \c -> do ph <- getParentTestBlockDb _fixtureBlockDb c creationTime <- getCurrentTimeIntegral let pactQueue = _fixturePactQueues ^?! atChain c From d5b6a8b0267691fdf8c20fffd1ecc9ee7369d599 Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Wed, 4 Feb 2026 12:59:03 +0000 Subject: [PATCH 03/11] Initial Gas Model Unit tests --- test/lib/Chainweb/Test/TestVersions.hs | 4 +- .../Chainweb/Test/Pact5/PactServiceTest.hs | 158 +++++++++++++++++- .../Chainweb/Test/Pact5/RemotePactTest.hs | 2 +- 3 files changed, 161 insertions(+), 3 deletions(-) diff --git a/test/lib/Chainweb/Test/TestVersions.hs b/test/lib/Chainweb/Test/TestVersions.hs index f19f03d63e..b6399308f1 100644 --- a/test/lib/Chainweb/Test/TestVersions.hs +++ b/test/lib/Chainweb/Test/TestVersions.hs @@ -481,7 +481,9 @@ pact5InstantCpmTestVersion migrate g = buildTestVersion $ \v -> v & cpmTestVersion g & versionName .~ ChainwebVersionName ("instant-pact5-CPM-" <> toText g <> if migrate then "-migrate" else "") -- Used to check gas for xChain -- - & versionInitialGasModel .~ AllChains (Bottom (minBound, post31GasModel)) + & versionInitialGasModel .~ AllChains ( (ForkAtBlockHeight 5, post32GasModel) `Above` + (ForkAtBlockHeight 4, post31GasModel) `Above` + Bottom (minBound, pre31GasModel)) & versionForks .~ tabulateHashMap (\case -- SPV Bridge is not in effect for Pact 5 yet. SPVBridge -> AllChains ForkNever diff --git a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs index 44f7d31920..fa5f3da7f3 100644 --- a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs +++ b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs @@ -24,6 +24,7 @@ import Data.List qualified as List import "pact" Pact.Types.Command qualified as Pact4 import "pact" Pact.Types.Hash qualified as Pact4 import Chainweb.BlockHeader +import Chainweb.BlockHeight import Chainweb.ChainId import Chainweb.Chainweb import Chainweb.Cut @@ -50,6 +51,8 @@ import Chainweb.Test.TestVersions import Chainweb.Test.Utils import Chainweb.Time import Chainweb.Utils +import qualified Data.ByteString.Base64.URL as B64U +import Chainweb.SPV.CreateProof import Chainweb.Version import Chainweb.WebBlockHeaderDB (getWebBlockHeaderDb) import Chainweb.WebPactExecutionService @@ -67,6 +70,8 @@ import Data.Decimal import Data.HashMap.Strict qualified as HashMap import Data.HashSet qualified as HashSet import Data.Maybe (fromMaybe) +import Pact.Core.Command.RPC (ContMsg (..)) +import Pact.Core.SPV (ContProof(..)) import Data.Text qualified as T import Data.Text.IO qualified as Text import Data.Vector (Vector) @@ -74,6 +79,7 @@ import Data.Vector qualified as Vector import Pact.Core.Capabilities import Pact.Core.ChainData hiding (ChainId, _chainId) import Pact.Core.Command.Types +import Pact.Core.DefPacts.Types import Pact.Core.Gas.Types import Pact.Core.Hash qualified as Pact5 import Pact.Core.Names @@ -82,7 +88,7 @@ import Pact.Types.Gas qualified as Pact4 import PropertyMatchers ((?)) import PropertyMatchers qualified as P import Test.Tasty -import Test.Tasty.HUnit (assertBool, assertEqual, assertFailure, testCase) +import Test.Tasty.HUnit (assertBool, assertEqual, assertFailure, testCase, (@?=)) import Text.Printf (printf) data Fixture = Fixture @@ -140,6 +146,7 @@ tests baseRdb = testGroup "Pact5 PactServiceTest" , testCase "failed txs should go into blocks" (failedTxsShouldGoIntoBlocks baseRdb) , testCase "modules with higher level transitive dependencies (simple)" (modulesWithHigherLevelTransitiveDependenciesSimple baseRdb) , testCase "modules with higher level transitive dependencies (complex)" (modulesWithHigherLevelTransitiveDependenciesComplex baseRdb) + , testCase "apply intial gas model" (testIntialGasModel baseRdb) ] simpleEndToEnd :: RocksDb -> IO () @@ -564,6 +571,155 @@ modulesWithHigherLevelTransitiveDependenciesComplex baseRdb = runResourceT $ do return () +-- A simple test module that increments an integer, on a single chain or cross-chain +testModule:: T.Text +testModule = "(namespace 'free) \ + \ (module m G (defcap G () true) \ + \ (defun inc (arg) \ + \ (+ arg 1)) \ + \ (defpact inc-x-chain (arg dest-chain) \ + \ (step (yield { \"a\" : (+ arg 1)} dest-chain )) \ + \ (step (resume { \"a\" := a } a)) \ + \ ) \ + \ )" + +assertCutHeight :: Fixture -> BlockHeight -> IO () +assertCutHeight fixt bh = do + cut <- getCut fixt + view cutMinHeight cut @?= bh + view cutMaxHeight cut @?= bh + +makeProof :: Fixture -> ChainId -> ChainId -> BlockHeight -> Int -> IO ContProof +makeProof Fixture{..} cidT cidS bh i = (ContProof . B64U.encode . encodeToByteString) <$> + createTransactionOutputProof_ (_bdbWebBlockHeaderDb _fixtureBlockDb) ( _bdbPayloadDb _fixtureBlockDb) + cidT cidS bh i + +testIntialGasModel :: RocksDb -> IO () +testIntialGasModel baseRdb = runResourceT $ do + fixture <- mkFixtureDual baseRdb + + liftIO $ do + -- Confirm We are here at height 1 + assertCutHeight fixture $ BlockHeight 1 + + -- Deploy the module on both chains and initiate two defpact Txs on Chain 0 + cmdDeployChain0 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' testModule + , _cbGasPrice = GasPrice 0.0004} + + cmdDeployChain1 <- buildCwCmd vPair (defaultCmd chain1) + { _cbRPC = mkExec' testModule + , _cbGasPrice = GasPrice 0.0004} + + cmdDefPact1 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' "(free.m.inc-x-chain 0 \"1\")" + , _cbGasPrice = GasPrice 0.0003} + + cmdDefPact2 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' "(free.m.inc-x-chain 1 \"1\")" + , _cbGasPrice = GasPrice 0.0002} + + cmdDefPact3 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' "(free.m.inc-x-chain 2 \"1\")" + , _cbGasPrice = GasPrice 0.0001} + + resBlock2 <- advanceAllChainsWithTxs fixture $ onChains [ (chain0, [cmdDeployChain0, cmdDefPact1, cmdDefPact2, cmdDefPact3]) + , (chain1, [cmdDeployChain1]) ] + + -- Check That all transactions are successful + resBlock2 & + P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [successfulTx, successfulTx, successfulTx, successfulTx]) + , (chain1, P.alignExact $ Vector.fromList [successfulTx])] + + -- Increase the height to allow SPV retrieval + _ <- advanceAllChainsWithTxs fixture $ AllChains [] + + ------------------------------------------------------------------------------------------------------------- + ----------------------------------- HEIGHT 4 - pre31GasModel ----------------------------------------------- + putStrLn "Test pre31GasModel" + -- Confirm We are here at height 3 + -- We use the pre31GasModel + assertCutHeight fixture $ BlockHeight 3 + + prf1 <- makeProof fixture chain1 chain0 (BlockHeight 2) 1 + cmdCont1 <- buildCwCmd vPair (defaultCmd chain1) + { _cbRPC = mkCont $ ContMsg { _cmPactId = resBlock2 ^?! ixg chain0 . ix 1 . crContinuation . _Just . peDefPactId + , _cmStep = 1 + , _cmRollback = False + , _cmData = PObject mempty + , _cmProof = Just prf1 + } + , _cbGasPrice = GasPrice 0.0001} + + cmd1 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' "(free.m.inc 0)" + } + + resBlock4 <- advanceAllChainsWithTxs fixture $ onChains [ (chain0, [cmd1]) + , (chain1, [cmdCont1]) ] + resBlock4 & + P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 74)]) + , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 100)]) + ] + + ------------------------------------------------------------------------------------------------------------- + ----------------------------------- HEIGHT 4 - post31GasModel ----------------------------------------------- + putStrLn "Test post31GasModel" + -- Confirm We are here at height 4 + assertCutHeight fixture $ BlockHeight 4 + + prf2 <- makeProof fixture chain1 chain0 (BlockHeight 2) 2 + cmdCont2 <- buildCwCmd vPair (defaultCmd chain1) + { _cbRPC = mkCont $ ContMsg { _cmPactId = resBlock2 ^?! ixg chain0 . ix 2 . crContinuation . _Just . peDefPactId + , _cmStep = 1 + , _cmRollback = False + , _cmData = PObject mempty + , _cmProof = Just prf2 + } + , _cbGasPrice = GasPrice 0.0001} + + cmd2 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' "(free.m.inc 1)" + } + + resBlock5 <- advanceAllChainsWithTxs fixture $ onChains [ (chain0, [cmd2]) + , (chain1, [cmdCont2]) ] + + -- Check that now, with the post31GasModel => continuation proofs are charged + resBlock5 & + P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 74)]) + , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 124)]) + ] + + ------------------------------------------------------------------------------------------------------------- + ----------------------------------- HEIGHT 5 - post32GasModel ----------------------------------------------- + putStrLn "Test post32GasModel" + -- Confirm We are here at height 5 + assertCutHeight fixture $ BlockHeight 5 + + prf3 <- makeProof fixture chain1 chain0 (BlockHeight 2) 3 + cmdCont3 <- buildCwCmd vPair (defaultCmd chain1) + { _cbRPC = mkCont $ ContMsg { _cmPactId = resBlock2 ^?! ixg chain0 . ix 3 . crContinuation . _Just . peDefPactId + , _cmStep = 1 + , _cmRollback = False + , _cmData = PObject mempty + , _cmProof = Just prf3 + } + } + + cmd3 <- buildCwCmd vPair (defaultCmd chain0) + { _cbRPC = mkExec' "(free.m.inc 2)"} + + resBlock6 <- advanceAllChainsWithTxs fixture $ onChains [ (chain0, [cmd3]) + , (chain1, [cmdCont3]) ] + + -- Check that now, with the post32GasModel => continuation proofs + Signatures are charged + resBlock6 & + P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 85)]) + , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 134)]) + ] + + {- tests = do -- * test that ValidateBlock does a destructive rewind to the parent of the block being validated diff --git a/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs b/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs index c6db34af54..321d85122a 100644 --- a/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs +++ b/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs @@ -346,7 +346,7 @@ crosschainTest baseRdb step = runResourceT $ do , P.fun _peName ? P.equals "X_RESUME" , P.succeed ] - , P.fun _crGas ? P.equals (Gas 234) + , P.fun _crGas ? P.equals (Gas 245) ] , P.match _Just ? P.fun _crResult ? P.match _PactResultErr ? P.fun _peMsg ? P.fun _boundedText ? P.equals ("Requested defpact execution already completed for defpact id: " <> T.take 20 (renderDefPactId $ _peDefPactId cont) <> "...") From 96364fe135721b4a82d381a7b326e2bf23fed27a Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Sat, 7 Feb 2026 12:40:16 +0000 Subject: [PATCH 04/11] Adjust signatures prices according to benchmarks --- src/Chainweb/Pact5/InitialGasModel.hs | 4 ++-- test/unit/Chainweb/Test/Pact5/PactServiceTest.hs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Chainweb/Pact5/InitialGasModel.hs b/src/Chainweb/Pact5/InitialGasModel.hs index 80403385c1..6027a0b581 100644 --- a/src/Chainweb/Pact5/InitialGasModel.hs +++ b/src/Chainweb/Pact5/InitialGasModel.hs @@ -72,6 +72,6 @@ post32GasModel = InitialGasModel , _signatureSizeFactor = 1.0 , _sizePenalty = \x -> (x / 512) ^ (7 :: Integer) , _signatureCost = \case - ED25519 -> 10.0 -- | TODO => Needs to be benchmarked - WebAuthn -> 10.0 -- | + ED25519 -> 21.0 -- | Benchmarked at 52 ns + WebAuthn -> 526.0 -- | Benchmarked at 1.315 ms (worst case) } diff --git a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs index fa5f3da7f3..b9c8f3da9e 100644 --- a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs +++ b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs @@ -715,8 +715,8 @@ testIntialGasModel baseRdb = runResourceT $ do -- Check that now, with the post32GasModel => continuation proofs + Signatures are charged resBlock6 & - P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 85)]) - , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 134)]) + P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 96)]) + , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 145)]) ] From 1c0130869460bae93cf84983e526d4a1e5d5dc7f Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Wed, 11 Mar 2026 14:02:38 +0000 Subject: [PATCH 05/11] Apply review suggestions --- .../Chainweb/Test/Pact5/PactServiceTest.hs | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs index b9c8f3da9e..7afdf9c216 100644 --- a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs +++ b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs @@ -146,7 +146,7 @@ tests baseRdb = testGroup "Pact5 PactServiceTest" , testCase "failed txs should go into blocks" (failedTxsShouldGoIntoBlocks baseRdb) , testCase "modules with higher level transitive dependencies (simple)" (modulesWithHigherLevelTransitiveDependenciesSimple baseRdb) , testCase "modules with higher level transitive dependencies (complex)" (modulesWithHigherLevelTransitiveDependenciesComplex baseRdb) - , testCase "apply intial gas model" (testIntialGasModel baseRdb) + , testCase "apply initial gas model" (testIntialGasModel baseRdb) ] simpleEndToEnd :: RocksDb -> IO () @@ -572,7 +572,7 @@ modulesWithHigherLevelTransitiveDependenciesComplex baseRdb = runResourceT $ do return () -- A simple test module that increments an integer, on a single chain or cross-chain -testModule:: T.Text +testModule :: T.Text testModule = "(namespace 'free) \ \ (module m G (defcap G () true) \ \ (defun inc (arg) \ @@ -603,15 +603,15 @@ testIntialGasModel baseRdb = runResourceT $ do assertCutHeight fixture $ BlockHeight 1 -- Deploy the module on both chains and initiate two defpact Txs on Chain 0 - cmdDeployChain0 <- buildCwCmd vPair (defaultCmd chain0) + cmdDeployChain0 <- buildCwCmd vPair (defaultCmd chain0) { _cbRPC = mkExec' testModule , _cbGasPrice = GasPrice 0.0004} - cmdDeployChain1 <- buildCwCmd vPair (defaultCmd chain1) + cmdDeployChain1 <- buildCwCmd vPair (defaultCmd chain1) { _cbRPC = mkExec' testModule , _cbGasPrice = GasPrice 0.0004} - cmdDefPact1 <- buildCwCmd vPair (defaultCmd chain0) + cmdDefPact1 <-buildCwCmd vPair (defaultCmd chain0) { _cbRPC = mkExec' "(free.m.inc-x-chain 0 \"1\")" , _cbGasPrice = GasPrice 0.0003} @@ -628,15 +628,14 @@ testIntialGasModel baseRdb = runResourceT $ do -- Check That all transactions are successful resBlock2 & - P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [successfulTx, successfulTx, successfulTx, successfulTx]) - , (chain1, P.alignExact $ Vector.fromList [successfulTx])] + P.alignExact ? onChains [ (chain0, P.alignExact ? Vector.fromList [successfulTx, successfulTx, successfulTx, successfulTx]) + , (chain1, P.alignExact ? Vector.fromList [successfulTx])] -- Increase the height to allow SPV retrieval _ <- advanceAllChainsWithTxs fixture $ AllChains [] ------------------------------------------------------------------------------------------------------------- ----------------------------------- HEIGHT 4 - pre31GasModel ----------------------------------------------- - putStrLn "Test pre31GasModel" -- Confirm We are here at height 3 -- We use the pre31GasModel assertCutHeight fixture $ BlockHeight 3 @@ -658,18 +657,17 @@ testIntialGasModel baseRdb = runResourceT $ do resBlock4 <- advanceAllChainsWithTxs fixture $ onChains [ (chain0, [cmd1]) , (chain1, [cmdCont1]) ] resBlock4 & - P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 74)]) - , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 100)]) - ] + P.alignExact ? onChains [ (chain0, P.alignExact ? Vector.fromList [P.fun _crGas ? P.equals (Gas 74)]) + , (chain1, P.alignExact ? Vector.fromList [P.fun _crGas ? P.equals (Gas 100)]) + ] ------------------------------------------------------------------------------------------------------------- ----------------------------------- HEIGHT 4 - post31GasModel ----------------------------------------------- - putStrLn "Test post31GasModel" -- Confirm We are here at height 4 assertCutHeight fixture $ BlockHeight 4 prf2 <- makeProof fixture chain1 chain0 (BlockHeight 2) 2 - cmdCont2 <- buildCwCmd vPair (defaultCmd chain1) + cmdCont2 <- buildCwCmd vPair (defaultCmd chain1) { _cbRPC = mkCont $ ContMsg { _cmPactId = resBlock2 ^?! ixg chain0 . ix 2 . crContinuation . _Just . peDefPactId , _cmStep = 1 , _cmRollback = False @@ -687,13 +685,12 @@ testIntialGasModel baseRdb = runResourceT $ do -- Check that now, with the post31GasModel => continuation proofs are charged resBlock5 & - P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 74)]) - , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 124)]) - ] + P.alignExact ? onChains [ (chain0, P.alignExact ? Vector.fromList [P.fun _crGas ? P.equals (Gas 74)]) + , (chain1, P.alignExact ? Vector.fromList [P.fun _crGas ? P.equals (Gas 124)]) + ] ------------------------------------------------------------------------------------------------------------- ----------------------------------- HEIGHT 5 - post32GasModel ----------------------------------------------- - putStrLn "Test post32GasModel" -- Confirm We are here at height 5 assertCutHeight fixture $ BlockHeight 5 @@ -715,9 +712,9 @@ testIntialGasModel baseRdb = runResourceT $ do -- Check that now, with the post32GasModel => continuation proofs + Signatures are charged resBlock6 & - P.alignExact ? onChains [ (chain0, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 96)]) - , (chain1, P.alignExact $ Vector.fromList [P.fun _crGas ? P.equals (Gas 145)]) - ] + P.alignExact ? onChains [ (chain0, P.alignExact ? Vector.fromList [P.fun _crGas ? P.equals (Gas 96)]) + , (chain1, P.alignExact ? Vector.fromList [P.fun _crGas ? P.equals (Gas 145)]) + ] {- From 918e76f6fc7a6e0bdc6dec8daa82e2b8adf7cc5d Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Wed, 11 Mar 2026 15:07:53 +0000 Subject: [PATCH 06/11] Fix remote Pact tests after adjusting gas price --- test/unit/Chainweb/Test/Pact5/RemotePactTest.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs b/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs index 321d85122a..9bbcc005d3 100644 --- a/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs +++ b/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs @@ -346,7 +346,7 @@ crosschainTest baseRdb step = runResourceT $ do , P.fun _peName ? P.equals "X_RESUME" , P.succeed ] - , P.fun _crGas ? P.equals (Gas 245) + , P.fun _crGas ? P.equals (Gas 256) ] , P.match _Just ? P.fun _crResult ? P.match _PactResultErr ? P.fun _peMsg ? P.fun _boundedText ? P.equals ("Requested defpact execution already completed for defpact id: " <> T.take 20 (renderDefPactId $ _peDefPactId cont) <> "...") From bfa31272f19da91a72b1f24003f1114ff893bc54 Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Fri, 10 Jul 2026 17:30:33 +0000 Subject: [PATCH 07/11] Chainweb 3.2 Draft --- CHANGELOG.md | 32 ++ cabal.project | 4 +- cabal.project.freeze | 528 ------------------ chainweb.cabal | 2 +- src/Chainweb/Pact/PactService.hs | 1 - src/Chainweb/Pact/Types.hs | 1 - src/Chainweb/Pact5/Transaction.hs | 1 - src/Chainweb/Pact5/TransactionExec.hs | 8 +- src/Chainweb/Pact5/Types.hs | 8 +- src/Chainweb/Version.hs | 3 + src/Chainweb/Version/Guards.hs | 5 + src/Chainweb/Version/Mainnet.hs | 5 +- src/Chainweb/Version/RecapDevelopment.hs | 1 + src/Chainweb/Version/Testnet04.hs | 1 + test/lib/Chainweb/Test/Pact5/CmdBuilder.hs | 11 +- test/lib/Chainweb/Test/TestVersions.hs | 2 + .../Chainweb/Test/BlockHeader/Validation.hs | 16 +- .../Test/Pact5/HyperlanePluginTests.hs | 4 +- .../Chainweb/Test/Pact5/PactServiceTest.hs | 4 +- .../Chainweb/Test/Pact5/RemotePactTest.hs | 2 +- .../Test/Pact5/SignedListPluginTests.hs | 4 +- .../Test/Pact5/TransactionExecTest.hs | 3 +- 22 files changed, 83 insertions(+), 563 deletions(-) delete mode 100644 cabal.project.freeze diff --git a/CHANGELOG.md b/CHANGELOG.md index 17e6476228..7c29faa032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,35 @@ +## 3.2 (2026-07-10) + +This is a major version update. This release replaces all previous versions. +The hard fork associated with this version will be triggered by miners at an unknown date. +Node administrators must upgrade as soon as possible. + +This release is mandatory and fixes important reliability- and security-related issues. + +To upgrade, pull the latest docker image, or download the binary and +restart the node with the same configuration file as before. + +### Changes +- Upgrade to Pact 5.4.1 + +- New Testnet ([#22](https://github.com/kda-community/chainweb-node/pull/22)) + +- Manage the fork state by ForkNumbers ([#20](https://github.com/kda-community/chainweb-node/pull/20)), continuation of ([#2272](https://github.com/kadena-io/chainweb-node/commit/4aedec3bb04acd328655b17f29d41d6b077f317b)) + +- Upgrade several upstream libraries ([#25](https://github.com/kda-community/chainweb-node/pull/25)), ([#24](https://github.com/kda-community/chainweb-node/pull/24)), ([#29](https://github.com/kda-community/chainweb-node/pull/29)) + +- Fix Genesis issue with Devnet ([#28](https://github.com/kda-community/chainweb-node/pull/28)) + +- **TODO: Should this one be merged ??** +- Improve resiliency of the network vs. unexpected hard forks and missing blocks ([#3](https://github.com/kda-community/chainweb-node/pull/3)) + +- **TODO: Should this one be merged ??** +- Add an option to disable X.509 certificate validation ([#26](https://github.com/kda-community/chainweb-node/pull/26)) + +- **TODO: Should this one be merged ??** +- Improve initial gas handling and gas-charge signatures/proofs according to their size and complexity ([#23](https://github.com/kda-community/chainweb-node/pull/23)) + + ## 3.1 (2025-11-25) This is a major version update. This release replaces all previous versions. diff --git a/cabal.project b/cabal.project index 88f6c3d66f..d0c9247ecb 100644 --- a/cabal.project +++ b/cabal.project @@ -99,8 +99,8 @@ source-repository-package source-repository-package type: git - location: https://github.com/kda-community/pact-5.git - tag: 7feeab02fe28bb9bfb0f1792f3ca9adffbcd2576 + location: https://github.com/kda-community/pact-5-special-fix + tag: eee1d0a59a8e098e88a23b4a5eb9dc6c7d7b8444 source-repository-package type: git diff --git a/cabal.project.freeze b/cabal.project.freeze deleted file mode 100644 index f4e2b0626a..0000000000 --- a/cabal.project.freeze +++ /dev/null @@ -1,528 +0,0 @@ -active-repositories: hackage.haskell.org:merge -constraints: any.Cabal ==3.12.1.0 || ==3.14.2.0, - any.Cabal-syntax ==3.12.1.0 || ==3.14.2.0, - any.Decimal ==0.5.2, - any.Diff ==1.0.2, - any.Glob ==0.10.2, - any.HUnit ==1.6.2.0, - any.JuicyPixels ==3.3.9, - JuicyPixels -mmap, - any.OneTuple ==0.4.3, - OneTuple +base-ge-4-15 +base-ge-4-16, - any.Only ==0.1, - any.QuickCheck ==2.18.0.0, - QuickCheck -old-random +templatehaskell, - any.StateVar ==1.2.2, - any.adjunctions ==4.4.4, - any.aeson ==2.2.5.0, - aeson +ordered-keymap, - any.aeson-pretty ==0.8.11, - aeson-pretty -lib-only, - any.alex ==3.5.4.2, - any.ansi-terminal ==1.1.5, - ansi-terminal -example, - any.ansi-terminal-types ==1.1.3, - any.ap-normalize ==0.1.0.1, - ap-normalize -test-with-clang, - any.appar ==0.1.8, - any.array ==0.5.8.0, - any.asciidoc ==0.1.0.3, - any.asn1-encoding ==0.9.6, - any.asn1-types ==0.3.4, - any.assoc ==1.1.1, - assoc -tagged, - any.async ==2.2.6, - async -bench -debug-auto-label, - any.atomic-primops ==0.8.8, - atomic-primops -debug, - any.attoparsec ==0.14.4, - attoparsec -developer, - any.attoparsec-aeson ==2.2.2.0, - any.auto-update ==0.2.6, - any.barbies ==2.1.1.0, - any.base ==4.20.1.0, - any.base-compat ==0.15.0, - any.base-compat-batteries ==0.15.0, - any.base-orphans ==0.9.4, - any.base-unicode-symbols ==0.2.4.2, - base-unicode-symbols +base-4-8 -old-base, - any.base16 ==1.0, - any.base16-bytestring ==1.0.2.0, - any.base64 ==1.0, - any.base64-bytestring ==1.2.1.0, - any.base64-bytestring-kadena ==0.1, - any.basement ==0.0.16, - any.bifunctors ==5.6.3, - bifunctors +tagged, - any.binary ==0.8.9.3, - any.binary-orphans ==1.0.6, - binary-orphans +base-ge-4-16 +base-ge-4-17, - any.bitvec ==1.1.6.0, - bitvec +simd, - any.blaze-builder ==0.4.4.1, - any.blaze-html ==0.9.2.0, - any.blaze-markup ==0.8.3.0, - any.boring ==0.2.2.1, - boring +tagged, - any.bound ==2.0.7, - bound +template-haskell, - any.bsb-http-chunked ==0.0.0.4, - any.bytebuild ==0.3.17.0, - bytebuild -checked, - any.byteorder ==1.0.4, - any.bytes ==0.17.5, - any.byteslice ==0.2.15.0, - byteslice +avoid-rawmemchr, - any.bytesmith ==0.3.14.0, - any.bytestring ==0.12.2.0, - any.bytestring-builder ==0.10.8.2.0, - bytestring-builder +bytestring_has_builder, - any.cabal-doctest ==1.0.12, - any.cache ==0.1.3.0, - any.call-stack ==0.4.0, - any.case-insensitive ==1.2.1.0, - any.cassava ==0.5.4.1, - any.cborg ==0.2.10.0, - cborg +optimize-gmp, - any.cereal ==0.5.8.3, - cereal -bytestring-builder, - chainweb -debug -ed25519 -ghc-flags, - chainweb-node -debug -ed25519 -ghc-flags, - any.character-ps ==0.1, - any.charset ==0.3.12, - any.chronos ==1.1.7.0, - any.citeproc ==0.13.0.1, - citeproc -executable -icu, - any.clock ==0.8.4, - clock -llvm, - any.cmdargs ==0.10.22, - cmdargs +quotation -testprog, - any.co-log-core ==0.3.2.7, - any.code-page ==0.2.1, - any.colour ==2.3.7, - any.commonmark ==0.3, - any.commonmark-extensions ==0.2.7, - any.commonmark-pandoc ==0.3, - any.comonad ==5.0.10, - comonad +containers +distributive +indexed-traversable, - any.concurrent-output ==1.10.21, - any.conduit ==1.3.6.1, - any.conduit-extra ==1.3.8, - any.configuration-tools ==0.7.1, - configuration-tools -remote-configs, - any.constraints ==0.14.4, - any.containers ==0.7, - any.contiguous ==0.6.4.2, - any.contravariant ==1.5.6, - contravariant +statevar, - any.cookie ==0.5.1, - any.criterion ==1.6.5.0, - criterion -embed-data-files -fast, - any.criterion-measurement ==0.2.5.0, - criterion-measurement -fast, - any.crypto-token ==0.2.0, - any.cryptohash-md5 ==0.11.101.0, - any.cryptohash-sha1 ==0.11.101.0, - any.crypton ==1.1.4, - crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes, - any.crypton-asn1-encoding ==0.10.0, - any.crypton-asn1-parse ==0.10.0, - any.crypton-asn1-types ==0.4.1, - any.crypton-connection ==0.4.6, - any.crypton-pem ==0.3.0, - any.crypton-socks ==0.6.2, - crypton-socks -example +network-3-0-0-0, - any.crypton-x509 ==1.9.1, - any.crypton-x509-store ==1.9.0, - any.crypton-x509-system ==1.9.0, - any.crypton-x509-validation ==1.9.1, - any.cuckoo ==0.3.1, - cuckoo -mwc-random -pcg-random, - cwtools -debug -ed25519 -ghc-flags -remote-db, - any.data-bword ==0.1.0.2, - any.data-default ==0.8.0.2, - any.data-default-class ==0.2.0.0, - any.data-dword ==0.3.2.1, - any.data-fix ==0.3.4, - any.data-ordlist ==0.4.7.0, - any.dec ==0.0.6, - any.deepseq ==1.5.0.0, - any.dense-linear-algebra ==0.1.0.0, - any.deriving-compat ==0.6.8, - any.digest ==0.0.2.1, - digest -have_arm64_crc32c -have_builtin_prefetch -have_mm_prefetch -have_sse42 -have_strong_getauxval -have_weak_getauxval +pkg-config, - any.digraph ==0.3.2, - any.direct-sqlite ==2.3.29, - direct-sqlite +dbstat +fulltextsearch +haveusleep +json1 -mathfunctions -systemlib +urifilenames, - any.directory ==1.3.8.5, - any.distributive ==0.6.3, - distributive +tagged, - any.djot ==0.1.4, - any.dlist ==1.0, - dlist -werror, - any.doclayout ==0.5.0.3, - any.doctemplates ==0.11.0.1, - any.easy-file ==0.2.5, - any.ech-config ==0.0.1, - ech-config -devel, - any.emojis ==0.1.5, - any.enclosed-exceptions ==1.0.3, - any.entropy ==0.4.1.11, - entropy -donotgetentropy, - any.erf ==2.0.0.0, - any.errors ==2.3.0, - any.ethereum ==0.1.1, - ethereum -ethhash -openssl-use-pkg-config, - any.exceptions ==0.10.9, - any.fast-logger ==3.2.6, - any.file-embed ==0.0.16.0, - any.filepath ==1.5.4.0, - any.fingertree ==0.1.6.3, - any.finite-typelits ==0.2.1.0, - any.free ==5.2, - any.generic-data ==1.1.0.2, - generic-data -enable-inspect, - any.generic-lens ==2.3.0.0, - any.generic-lens-core ==2.3.0.0, - any.generics-sop ==0.5.1.4, - any.ghc-bignum ==1.3, - any.ghc-boot-th ==9.10.2, - any.ghc-compact ==0.1.0.0, - any.ghc-heap ==9.10.2, - any.ghc-internal ==9.1002.0, - any.ghc-prim ==0.12.0, - any.gridtables ==0.1.1.0, - any.groups ==0.5.3, - any.growable-vector ==0.1, - any.haddock-library ==1.11.0, - any.half ==0.3.3, - any.happy ==2.2, - any.happy-lib ==2.2, - any.hashable ==1.5.1.0, - hashable -arch-native -random-initial-seed, - any.hashes ==0.3.0.1, - hashes -benchmark-cryptonite -openssl-use-pkg-config -test-cryptonite +with-openssl, - any.haskeline ==0.8.2.1, - any.haskell-lexer ==1.2.1, - any.haskell-src-exts ==1.23.1, - any.haskell-src-meta ==0.8.15, - any.heaps ==0.4.1, - any.hedgehog ==1.7, - any.hourglass ==0.2.12, - any.hpke ==0.1.0, - any.hsc2hs ==0.68.10, - hsc2hs -in-ghc-tree, - any.http-api-data ==0.7, - http-api-data -use-text-show, - any.http-client ==0.7.19, - http-client +network-uri, - any.http-client-tls ==0.4.0, - any.http-date ==0.0.11, - any.http-media ==0.8.1.1, - any.http-semantics ==0.4.0, - any.http-types ==0.12.5, - any.http2 ==5.4.0, - http2 -devel -h2spec, - any.indexed-list-literals ==0.2.1.3, - any.indexed-profunctors ==0.1.1.1, - any.indexed-traversable ==0.1.5, - indexed-traversable +base-ge-4-18, - any.indexed-traversable-instances ==0.1.2.1, - any.integer-conversion ==0.1.1, - any.integer-gmp ==1.1, - any.integer-logarithms ==1.0.5, - integer-logarithms -check-bounds +integer-gmp, - any.invariant ==0.6.5, - any.iproute ==1.7.15, - any.ipynb ==0.2, - any.ixset-typed ==0.5.1.0, - any.jira-wiki-markup ==1.5.1, - any.js-chart ==2.9.4.1, - any.kan-extensions ==5.2.8, - any.lens ==5.3.6, - lens -benchmark-uniplate -dump-splices +inlining -j +test-hunit +test-properties +test-templates +trustworthy, - any.lens-aeson ==1.2.3, - any.libyaml ==0.1.4, - libyaml -no-unicode -system-libyaml, - any.libyaml-clib ==0.2.5, - any.lifted-async ==0.11.0, - any.lifted-base ==0.2.3.12, - any.loglevel ==0.1.0.0, - any.lrucaching ==0.3.5, - any.lsp ==2.3.0.0, - lsp -demo, - any.lsp-types ==2.1.0.0, - lsp-types -force-ospath, - any.managed ==1.0.11, - any.massiv ==1.0.5.0, - massiv -unsafe-checks, - any.math-functions ==0.3.4.4, - math-functions +system-erf +system-expm1, - any.megaparsec ==9.8.1, - megaparsec -dev, - any.memory ==0.18.0, - memory +support_bytestring +support_deepseq, - any.merkle-log ==0.2.1, - any.microlens ==0.5.0.0, - any.microstache ==1.0.3.1, - any.mime-types ==0.1.2.2, - any.mlkem ==0.2.2.0, - mlkem +use_crypton, - any.mmorph ==1.2.2, - any.mod ==0.2.2.0, - mod +semirings +vector, - any.monad-control ==1.0.3.1, - any.mono-traversable ==1.0.21.0, - any.mtl ==2.3.1, - any.mtl-compat ==0.2.2, - mtl-compat -two-point-one -two-point-two, - any.mwc-probability ==2.3.1, - any.mwc-random ==0.15.3.0, - mwc-random -benchpapi, - any.natural-arithmetic ==0.2.3.0, - any.neat-interpolation ==0.5.1.4, - any.network ==3.2.8.0, - network -devel, - any.network-byte-order ==0.1.8, - any.network-control ==0.1.7, - any.network-info ==0.2.1, - any.network-uri ==2.6.4.2, - any.nothunks ==0.3.1, - nothunks +bytestring +text +vector, - any.old-locale ==1.0.0.7, - any.old-time ==1.1.1.0, - any.optparse-applicative ==0.19.0.0, - optparse-applicative +process, - any.ordered-containers ==0.2.4, - any.os-string ==2.0.4, - any.pact ==4.13.2, - pact -build-tool +cryptonite-ed25519 -tests-in-lib, - any.pact-json ==0.1.0.0, - any.pact-time ==0.3.0.1, - pact-time -with-time, - any.pact-tng ==5.4, - pact-tng +with-crypto +with-funcall-tracing +with-native-tracing, - any.pandoc ==3.10, - pandoc -embed_data_files +http, - any.pandoc-types ==1.23.1.2, - any.parallel ==3.3.0.0, - any.parsec ==3.1.18.0, - any.parser-combinators ==1.3.1, - parser-combinators -dev, - any.parsers ==0.12.12, - parsers +attoparsec +binary +parsec, - any.patience ==0.3, - any.pem ==0.2.4, - any.poly ==0.5.1.0, - poly +sparse, - any.pretty ==1.1.3.6, - any.pretty-show ==1.10, - any.pretty-simple ==4.1.4.0, - pretty-simple -buildexample +buildexe, - any.prettyprinter ==1.7.2, - prettyprinter -buildreadme +text, - any.prettyprinter-ansi-terminal ==1.1.4, - prettyprinter-ansi-terminal +text, - any.primitive ==0.9.1.0, - any.primitive-addr ==0.1.0.3, - any.primitive-offset ==0.2.0.1, - any.primitive-unlifted ==2.1.0.0, - any.process ==1.6.25.0, - any.profunctors ==5.6.3, - any.property-matchers ==0.7.0.0, - any.psqueues ==0.2.8.3, - any.pvar ==1.0.0.0, - any.quickcheck-instances ==0.4, - any.ralist ==0.4.1.0, - any.ram ==0.22.0, - any.random ==1.3.1, - any.recover-rtti ==0.5.3, - any.recv ==0.1.1, - any.reducers ==3.12.5, - any.reflection ==2.1.9, - reflection -slow +template-haskell, - any.regex ==1.1.0.2, - any.regex-base ==0.94.0.3, - any.regex-pcre-builtin ==0.95.2.3.8.44, - any.regex-tdfa ==1.3.2.5, - regex-tdfa +doctest -force-o2, - any.resource-pool ==0.5.0.0, - any.resourcet ==1.3.0, - any.retry ==0.9.3.1, - retry -lib-werror, - any.rocksdb-haskell-kadena ==1.1.0, - rocksdb-haskell-kadena -with-tbb, - any.row-types ==1.0.1.2, - any.rts ==1.0.2, - any.run-st ==0.1.3.3, - any.safe ==0.3.21, - any.safe-exceptions ==0.1.7.4, - any.safecopy ==0.10.4.3, - any.scheduler ==2.0.1.0, - any.scientific ==0.3.8.1, - scientific -integer-simple, - any.selective ==0.7.0.1, - any.semialign ==1.4, - semialign +semigroupoids, - any.semigroupoids ==6.0.2, - semigroupoids +comonad +containers +contravariant +tagged +unordered-containers, - any.semigroups ==0.20.1, - any.semirings ==0.7, - semirings +containers +unordered-containers, - any.serialise ==0.2.6.1, - serialise +newtime15, - any.servant ==0.20.3.0, - any.servant-client ==0.20.3.0, - any.servant-client-core ==0.20.3.0, - any.servant-server ==0.20.3.0, - any.sha-validation ==0.1.0.1, - any.show-combinators ==0.2.0.0, - any.simple-sendfile ==0.2.32, - simple-sendfile +allow-bsd -fallback, - any.singleton-bool ==0.1.8, - any.skylighting ==0.14.7, - skylighting -executable, - any.skylighting-core ==0.14.7, - skylighting-core -executable, - any.skylighting-format-ansi ==0.1, - any.skylighting-format-blaze-html ==0.1.2, - any.skylighting-format-context ==0.1.0.2, - any.skylighting-format-latex ==0.1, - any.skylighting-format-typst ==0.1, - any.some ==1.1, - some +newtype-unsafe, - any.sop-core ==0.5.0.2, - any.sorted-list ==0.2.3.1, - any.split ==0.2.5, - any.splitmix ==0.1.3.2, - splitmix -optimised-mixer, - any.statistics ==0.16.5.0, - statistics -benchpapi, - any.stm ==2.5.3.1, - any.stm-chans ==3.0.0.11, - any.stopwatch ==0.1.0.7, - stopwatch -test_delay_upper_bound -test_threaded, - any.streaming ==0.2.4.0, - any.streaming-commons ==0.2.3.1, - streaming-commons -use-bytestring-builder, - any.strict ==0.5.1, - any.strict-concurrency ==0.2.4.3, - any.syb ==0.7.4, - any.tagged ==0.8.10, - tagged +deepseq +template-haskell, - any.tagsoup ==0.14.8, - any.tasty ==1.5.4, - tasty +unix, - any.tasty-golden ==2.3.6, - tasty-golden -build-example, - any.tasty-hedgehog ==1.4.0.2, - any.tasty-hunit ==0.10.2, - any.tasty-json ==0.1.0.0, - any.tasty-quickcheck ==0.11.1, - any.template-haskell ==2.22.0.0, - any.temporary ==1.3, - any.terminal-progress-bar ==0.4.2, - any.terminal-size ==0.3.4, - any.terminfo ==0.4.1.7, - any.texmath ==0.13.1.2, - texmath -executable -server, - any.text ==2.1.2, - any.text-conversions ==0.3.1.1, - any.text-iso8601 ==0.1.1.1, - any.text-rope ==0.3, - text-rope -debug, - any.text-short ==0.1.6.1, - text-short -asserts, - any.th-abstraction ==0.7.2.0, - any.th-compat ==0.1.7, - any.th-expand-syns ==0.4.12.0, - any.th-lift ==0.8.7, - any.th-lift-instances ==0.1.20, - any.th-orphans ==0.13.17, - any.th-reify-many ==0.1.10, - any.these ==1.2.1, - any.time ==1.12.2, - any.time-compat ==1.9.9, - any.time-hourglass ==0.3.0, - any.time-locale-compat ==0.1.1.5, - time-locale-compat +old-locale, - any.time-manager ==0.3.2, - any.tls ==2.4.3, - tls -devel, - any.tls-session-manager ==0.1.0, - any.token-bucket ==0.1.0.1, - token-bucket +use-cbits, - any.toml-parser ==2.0.2.0, - any.torsor ==0.1.0.1, - any.transformers ==0.6.1.1, - any.transformers-base ==0.4.6.1, - transformers-base +orphaninstances, - any.transformers-compat ==0.7.2, - transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, - any.trifecta ==2.1.4, - any.tuples ==0.1.0.0, - any.typed-process ==0.2.13.0, - any.typst ==0.10, - typst -executable, - any.typst-symbols ==0.2, - any.unicode-collation ==0.1.3.7, - unicode-collation -doctests -executable -icu-benchmark, - any.unicode-data ==0.8.0, - unicode-data -dev-has-icu, - any.unicode-transforms ==0.4.0.1, - unicode-transforms -bench-show -dev -has-icu -has-llvm -use-gauge, - any.uniplate ==1.6.13, - any.unix ==2.8.6.0, - any.unix-compat ==0.7.4.1, - any.unix-time ==0.5.0, - any.unlifted ==0.2.3.0, - any.unliftio ==0.2.25.1, - any.unliftio-core ==0.2.1.0, - any.unordered-containers ==0.2.21, - unordered-containers -debug, - any.utf8-string ==1.0.2, - any.uuid ==1.3.16.1, - any.uuid-types ==1.0.6.1, - any.validation ==1.1.5, - any.vault ==0.3.1.6, - vault +useghc, - any.vector ==0.13.2.0, - vector +boundschecks -internalchecks -unsafechecks -wall, - any.vector-algorithms ==0.9.1.0, - vector-algorithms +bench +boundschecks -internalchecks -llvm -unsafechecks, - any.vector-binary-instances ==0.2.5.2, - any.vector-sized ==1.6.1, - any.vector-stream ==0.1.0.1, - any.vector-th-unbox ==0.2.2, - any.void ==0.7.4, - void -safe, - any.wai ==3.2.4, - any.wai-app-static ==3.2.1, - wai-app-static -print, - any.wai-cors ==0.2.7, - any.wai-extra ==3.1.18, - wai-extra -build-example, - any.wai-logger ==2.5.0, - any.wai-middleware-throttle ==0.3.0.1, - any.wai-middleware-validation ==0.1.0.2, - any.warp ==3.4.13.1, - warp +allow-sendfilefd +include-warp-version -network-bytestring -warp-debug +x509, - any.warp-tls ==3.4.14, - any.wherefrom-compat ==0.2.0.0, - any.wide-word ==0.1.9.0, - any.witherable ==0.5, - any.wl-pprint-annotated ==0.1.0.1, - any.word8 ==0.1.3, - any.xml ==1.3.14, - any.xml-conduit ==1.10.1.0, - any.xml-types ==0.3.8, - any.yaml ==0.11.11.2, - yaml +no-examples +no-exe, - any.yet-another-logger ==0.4.2, - yet-another-logger -tbmqueue, - any.zigzag ==0.1.0.0, - any.zip-archive ==0.4.3.2, - zip-archive -executable, - any.zlib ==0.7.1.1, - zlib -bundled-c-zlib +non-blocking-ffi +pkg-config -index-state: hackage.haskell.org 2026-07-02T11:30:46Z diff --git a/chainweb.cabal b/chainweb.cabal index 43581c5405..cadc001157 100644 --- a/chainweb.cabal +++ b/chainweb.cabal @@ -1,7 +1,7 @@ cabal-version: 3.8 name: chainweb -version: 3.1 +version: 3.2 synopsis: A Proof-of-Work Parallel-Chain Architecture for Massive Throughput description: A Proof-of-Work Parallel-Chain Architecture for Massive Throughput. homepage: https://github.com/kadena-io/chainweb diff --git a/src/Chainweb/Pact/PactService.hs b/src/Chainweb/Pact/PactService.hs index 0852ac0c3f..466d5796d3 100644 --- a/src/Chainweb/Pact/PactService.hs +++ b/src/Chainweb/Pact/PactService.hs @@ -143,7 +143,6 @@ import qualified Pact.Core.Errors as Pact5 import Chainweb.Pact.Backend.Types import qualified Chainweb.Pact.PactService.Checkpointer as Checkpointer import Chainweb.Pact.PactService.Checkpointer (SomeBlockM(..)) -import qualified Pact.Core.StableEncoding as Pact5 import Control.Monad.Cont (evalContT) import qualified Data.List.NonEmpty as NonEmpty diff --git a/src/Chainweb/Pact/Types.hs b/src/Chainweb/Pact/Types.hs index c7c4d4e589..8dcb5f3d4f 100644 --- a/src/Chainweb/Pact/Types.hs +++ b/src/Chainweb/Pact/Types.hs @@ -264,7 +264,6 @@ import Chainweb.Payload import Data.ByteString.Short (ShortByteString) import qualified Data.ByteString.Short as SB import qualified Data.Vector as V -import qualified Pact.Core.Hash as Pact5 import Data.Maybe import Chainweb.BlockCreationTime import qualified Data.Aeson as Aeson diff --git a/src/Chainweb/Pact5/Transaction.hs b/src/Chainweb/Pact5/Transaction.hs index 39bf94c9ce..4c264b1b6e 100644 --- a/src/Chainweb/Pact5/Transaction.hs +++ b/src/Chainweb/Pact5/Transaction.hs @@ -31,7 +31,6 @@ import "pact-json" Pact.JSON.Encode qualified as J import "pact-json" Pact.JSON.Encode (Encode(..)) import "pact-tng" Pact.Core.ChainData import "pact-tng" Pact.Core.Command.Types -import "pact-tng" Pact.Core.StableEncoding import "pact-tng" Pact.Core.Errors import "pact-tng" Pact.Core.Info import "pact-tng" Pact.Core.Pretty qualified as Pact5 diff --git a/src/Chainweb/Pact5/TransactionExec.hs b/src/Chainweb/Pact5/TransactionExec.hs index 3be1e01d5b..ab7b7327b8 100644 --- a/src/Chainweb/Pact5/TransactionExec.hs +++ b/src/Chainweb/Pact5/TransactionExec.hs @@ -309,7 +309,8 @@ applyLocal logger maybeGasLogger coreDb txCtx spvSupport cmd = do [ defaultFlags , guardDisablePact51Flags txCtx , guardDisablePact52And53Flags txCtx - , guardDisablePact54Flags txCtx] + , guardDisablePact54Flags txCtx + , guardDisablePact54FixFlags txCtx ] -- | The main entry point to executing transactions. From here, -- 'applyCmd' assembles the command environment for a command, @@ -1058,3 +1059,8 @@ guardDisablePact54Flags :: TxContext -> Set ExecutionFlag guardDisablePact54Flags txCtx | guardCtx chainweb231Pact txCtx = Set.empty | otherwise = Set.fromList [FlagDisablePact54] + +guardDisablePact54FixFlags :: TxContext -> Set ExecutionFlag +guardDisablePact54FixFlags txCtx + | guardCtx' chainweb32 txCtx = Set.empty + | otherwise = Set.fromList [FlagDisablePact54Fix] \ No newline at end of file diff --git a/src/Chainweb/Pact5/Types.hs b/src/Chainweb/Pact5/Types.hs index 12e9aed687..bb970494d9 100644 --- a/src/Chainweb/Pact5/Types.hs +++ b/src/Chainweb/Pact5/Types.hs @@ -10,6 +10,7 @@ module Chainweb.Pact5.Types ( TxContext(..) , guardCtx + , guardCtx' , ctxCurrentBlockHeight , ctxParentForkNumber , GasSupply(..) @@ -89,7 +90,7 @@ ctxCurrentBlockHeight = succ . view blockHeight . ctxBlockHeader -- We use the parent fork number in Pact, so when the fork -- number is incremented, only that block's descendents will -- have the forking behavior active. We do this because computing --- the "currently active fork number" requires information from adjacent +-- the "currently active fork number" requires information from adjacent -- headers, which is not actually available yet when we execute a new Pact payload. ctxParentForkNumber :: TxContext -> ForkNumber ctxParentForkNumber = view blockForkNumber . ctxBlockHeader @@ -100,9 +101,14 @@ ctxChainId = _chainId . ctxBlockHeader ctxVersion :: TxContext -> ChainwebVersion ctxVersion = _chainwebVersion . ctxBlockHeader +-- To be used when Forks guards are defined by height guardCtx :: (ChainwebVersion -> Chainweb.ChainId.ChainId -> BlockHeight -> a) -> TxContext -> a guardCtx g txCtx = g (ctxVersion txCtx) (ctxChainId txCtx) (ctxCurrentBlockHeight txCtx) +-- To be used when Forks guards are defined by ForkNumbers +guardCtx' :: (ChainwebVersion -> Chainweb.ChainId.ChainId -> ForkNumber -> a) -> TxContext -> a +guardCtx' g txCtx = g (ctxVersion txCtx) (ctxChainId txCtx) (ctxParentForkNumber txCtx) + data PactBlockState = PactBlockState { _pbServiceState :: !PactServiceState , _pbBlockHandle :: !(BlockHandle Pact5) diff --git a/src/Chainweb/Version.hs b/src/Chainweb/Version.hs index 0319d7610d..1da2f7c8a2 100644 --- a/src/Chainweb/Version.hs +++ b/src/Chainweb/Version.hs @@ -233,6 +233,7 @@ data Fork | Chainweb230Pact | Chainweb231Pact | Chainweb31 + | Chainweb32 | MigratePlatformShare -- always add new forks at the end, not in the middle of the constructors. deriving stock (Bounded, Generic, Eq, Enum, Ord, Show) @@ -274,6 +275,7 @@ instance HasTextRepresentation Fork where toText Chainweb230Pact = "chainweb230Pact" toText Chainweb231Pact = "chainweb231Pact" toText Chainweb31 = "Chainweb31" + toText Chainweb32 = "Chainweb32" toText MigratePlatformShare = "migratePlatformShare" fromText "slowEpoch" = return SlowEpoch @@ -311,6 +313,7 @@ instance HasTextRepresentation Fork where fromText "chainweb230Pact" = return Chainweb230Pact fromText "chainweb231Pact" = return Chainweb231Pact fromText "Chainweb31" = return Chainweb31 + fromText "Chainweb32" = return Chainweb32 fromText "migratePlatformShare" = return MigratePlatformShare fromText t = throwM . TextFormatException $ "Unknown Chainweb fork: " <> t diff --git a/src/Chainweb/Version/Guards.hs b/src/Chainweb/Version/Guards.hs index 3c1e631409..98c2d807ba 100644 --- a/src/Chainweb/Version/Guards.hs +++ b/src/Chainweb/Version/Guards.hs @@ -51,6 +51,7 @@ module Chainweb.Version.Guards , chainweb230Pact , chainweb231Pact , chainweb31 + , chainweb32 , migratePlatformShare , pact5 , pact44NewTrans @@ -322,6 +323,10 @@ chainweb231Pact = checkFork atOrAfter Chainweb231Pact chainweb31 :: ChainwebVersion -> ChainId -> BlockHeight -> Bool chainweb31 = checkFork atOrAfter Chainweb31 +-- | Pact 5.4.1 +chainweb32 :: ChainwebVersion -> ChainId -> ForkNumber -> Bool +chainweb32 = checkFork' atOrAfter Chainweb32 + migratePlatformShare :: ChainwebVersion -> ChainId -> BlockHeight -> Bool migratePlatformShare = checkFork atNotGenesis MigratePlatformShare diff --git a/src/Chainweb/Version/Mainnet.hs b/src/Chainweb/Version/Mainnet.hs index d7a460da7e..7f9296e955 100644 --- a/src/Chainweb/Version/Mainnet.hs +++ b/src/Chainweb/Version/Mainnet.hs @@ -156,6 +156,7 @@ mainnet = ChainwebVersion Chainweb231Pact -> AllChains (ForkAtBlockHeight $ BlockHeight 6_269_344) -- 2025-10-16 00:00:00+00:00 MigratePlatformShare -> AllChains (ForkAtBlockHeight $ BlockHeight 6_335_858) -- 2025-11-07 04:00:00+00:00 Chainweb31 -> AllChains (ForkAtBlockHeight $ BlockHeight 6_510_742) -- 2026-01-08 00:00:00+00:00 + Chainweb32-> AllChains (ForkAtForkNumber 1) , _versionGraphs = (to20ChainsMainnet, twentyChainGraph) `Above` @@ -167,6 +168,8 @@ mainnet = ChainwebVersion (succByHeight $ mainnet ^?! versionForks . at Chainweb216Pact . _Just . atChain (unsafeChainId 0), Just 180_000) `Above` Bottom (minBound, Nothing) , _versionSpvProofRootValidWindow = + -- TODO : Question is ChainWeb3.2 a good opportunity to reduce Proof valid window (6 month? eg. ) ???? + --(succByHeight $ mainnet ^?! versionForks . at Chainweb32 . _Just . atChain (unsafeChainId 0), Just 525_600) `Above` (succByHeight $ mainnet ^?! versionForks . at Chainweb31 . _Just . atChain (unsafeChainId 0), Nothing) `Above` (succByHeight $ mainnet ^?! versionForks . at Chainweb231Pact . _Just . atChain (unsafeChainId 0) , Just 20_000) `Above` Bottom (minBound, Nothing) @@ -231,7 +234,7 @@ mainnet = ChainwebVersion , (unsafeChainId 9, HM.fromList [((BlockHeight 4594049, TxBlockIdx 0), Gas 69_092)]) ] } - , _versionForkNumber = 0 + , _versionForkNumber = 1 -- | A epoch is 120 * 120 block heights, which, on mainnet, is expected to be 5 -- days. -- diff --git a/src/Chainweb/Version/RecapDevelopment.hs b/src/Chainweb/Version/RecapDevelopment.hs index a21a423cbb..c3db818e00 100644 --- a/src/Chainweb/Version/RecapDevelopment.hs +++ b/src/Chainweb/Version/RecapDevelopment.hs @@ -80,6 +80,7 @@ recapDevnet = ChainwebVersion Chainweb231Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 690 MigratePlatformShare -> AllChains $ ForkAtBlockHeight $ BlockHeight 700 Chainweb31 -> AllChains $ ForkAtBlockHeight $ BlockHeight 710 + Chainweb32 -> AllChains $ ForkAtGenesis , _versionUpgrades = foldr (chainZip HM.union) (AllChains mempty) [ indexByForkHeights recapDevnet diff --git a/src/Chainweb/Version/Testnet04.hs b/src/Chainweb/Version/Testnet04.hs index ef5ffe7b59..84de089c3f 100644 --- a/src/Chainweb/Version/Testnet04.hs +++ b/src/Chainweb/Version/Testnet04.hs @@ -135,6 +135,7 @@ testnet04 = ChainwebVersion Chainweb230Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_542_190 -- 2025-07-23 12:00:00+00:00 Chainweb231Pact -> AllChains $ ForkAtBlockHeight $ BlockHeight 5_783_985 -- 2025-10-15 12:00:00+00:00 Chainweb31 -> AllChains ForkNever + Chainweb32 -> AllChains ForkNever MigratePlatformShare -> AllChains ForkNever , _versionGraphs = diff --git a/test/lib/Chainweb/Test/Pact5/CmdBuilder.hs b/test/lib/Chainweb/Test/Pact5/CmdBuilder.hs index 879018055b..ded0c3b26f 100644 --- a/test/lib/Chainweb/Test/Pact5/CmdBuilder.hs +++ b/test/lib/Chainweb/Test/Pact5/CmdBuilder.hs @@ -15,6 +15,7 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE PatternSynonyms #-} module Chainweb.Test.Pact5.CmdBuilder where @@ -26,9 +27,7 @@ import Control.Lens hiding ((.=)) import Pact.Core.Command.Types import Data.Text (Text) import GHC.Generics -import Pact.Core.Capabilities import Pact.Core.Guards -import Pact.Core.Verifiers (Verifier, ParsedVerifierProof) import Pact.Core.Command.RPC import Pact.Core.ChainData import Pact.Core.Gas.Types @@ -45,13 +44,11 @@ import Data.Maybe import Pact.Core.Command.Crypto import Pact.Core.Command.Util import qualified Data.Text as T -import Pact.Core.Names (Field(..), QualifiedName, DefPactId) -import Pact.Core.PactValue -import Pact.Core.Signer +import Pact.Core.Names (Field(..)) +import Pact.Core.PactValue (pattern PString) import qualified Data.Set as Set -import Pact.Core.StableEncoding import Chainweb.Pact.RestAPI.Server (validatePact5Command) -import Pact.Core.Command.Client (ApiKeyPair (..), mkCommandWithDynKeys) +import Pact.Core.Command.Client (ApiKeyPair (..), mkCommandWithDynKeys, PactValue(..)) import System.Random import Control.Monad import Data.Vector qualified as Vector diff --git a/test/lib/Chainweb/Test/TestVersions.hs b/test/lib/Chainweb/Test/TestVersions.hs index 8f24d89ac9..fa297e7a65 100644 --- a/test/lib/Chainweb/Test/TestVersions.hs +++ b/test/lib/Chainweb/Test/TestVersions.hs @@ -304,6 +304,7 @@ slowForks = tabulateHashMap \case PactBackCompat_v16 -> AllChains ForkAtGenesis SPVBridge -> AllChains ForkAtGenesis Pact44NewTrans -> AllChains ForkAtGenesis + Chainweb32 -> AllChains ForkAtGenesis -- Being mainly a bugfix, it's safe to do at it at genesis CoinV2 -> AllChains $ ForkAtBlockHeight (BlockHeight 1) SkipTxTimingValidation -> AllChains $ ForkAtBlockHeight (BlockHeight 2) ModuleNameFix -> AllChains $ ForkAtBlockHeight (BlockHeight 2) @@ -349,6 +350,7 @@ fastForks = tabulateHashMap $ \case Pact44NewTrans -> AllChains ForkAtGenesis Chainweb213Pact -> AllChains ForkAtGenesis PactEvents -> AllChains ForkAtGenesis + Chainweb32 -> AllChains ForkAtGenesis -- Being mainly a bugfix, it's safe to do at it at genesis CoinV2 -> AllChains $ ForkAtBlockHeight $ BlockHeight 1 Pact42 -> AllChains $ ForkAtBlockHeight $ BlockHeight 1 SkipTxTimingValidation -> AllChains $ ForkAtBlockHeight $ BlockHeight 2 diff --git a/test/unit/Chainweb/Test/BlockHeader/Validation.hs b/test/unit/Chainweb/Test/BlockHeader/Validation.hs index a5da5cded8..2ac3beb67e 100644 --- a/test/unit/Chainweb/Test/BlockHeader/Validation.hs +++ b/test/unit/Chainweb/Test/BlockHeader/Validation.hs @@ -336,7 +336,7 @@ forkValidation = -- after skipFeatureFlagValidationGuard is deactivated , ( hdr & h . blockForkNumber %~ (+1) - , [IncorrectHash, IncorrectPow, IncorrectForkNumber, UnknownForkNumber] + , [IncorrectHash, IncorrectPow, IncorrectForkNumber] ) , ( hdr & h . blockForkVotes %~ addVote , [IncorrectHash, IncorrectPow] @@ -369,13 +369,13 @@ forkValidation = , [IncorrectHash, IncorrectPow, InvalidForkVotes, InvalidForkVotes] ) , ( hdr - & p . blockForkNumber .~ 10 - & h . blockForkNumber .~ 10 + & p . blockForkNumber .~ 250 -- I suppose, we will never reach 250... + & h . blockForkNumber .~ 250 --- assume that 250 will always be a Unknown Fork Number , [IncorrectHash, IncorrectPow, UnknownForkNumber] ) , ( hdr - & p . blockForkNumber .~ 10 - & h . blockForkNumber .~ 10 - 1 + & p . blockForkNumber .~ 250 + & h . blockForkNumber .~ 250 - 1 , [IncorrectHash, IncorrectPow, IncorrectForkNumber, UnknownForkNumber] ) @@ -462,7 +462,7 @@ forkValidation = & p . blockForkVotes .~ int (forkEpochLength (_chainwebVersion hdr2)) * voteStep & h . blockForkVotes .~ resetVotes & h . blockForkNumber .~ view (p . blockForkNumber) hdr2 + 1 - , [IncorrectHash, IncorrectPow, UnknownForkNumber] + , [IncorrectHash, IncorrectPow] ) -- Test 25 , ( hdr2 @@ -475,13 +475,13 @@ forkValidation = & p . blockForkVotes .~ (voteLength * 2 `quot` 3 - 1) * voteStep & h . blockForkVotes .~ resetVotes & h . blockForkNumber .~ view (p . blockForkNumber) hdr2 + 1 - , [IncorrectHash, IncorrectPow, IncorrectForkNumber, UnknownForkNumber] + , [IncorrectHash, IncorrectPow, IncorrectForkNumber] ) , ( hdr2 & p . blockForkVotes .~ (voteLength * 2 `quot` 3 + 1) * voteStep & h . blockForkVotes .~ resetVotes & h . blockForkNumber .~ view (p . blockForkNumber) hdr2 + 1 - , [IncorrectHash, IncorrectPow, UnknownForkNumber] + , [IncorrectHash, IncorrectPow] ) , ( hdr2 & p . blockForkVotes .~ (voteLength * 2 `quot` 3 + 1) * voteStep diff --git a/test/unit/Chainweb/Test/Pact5/HyperlanePluginTests.hs b/test/unit/Chainweb/Test/Pact5/HyperlanePluginTests.hs index 2429a1e64e..e3b8cba08c 100644 --- a/test/unit/Chainweb/Test/Pact5/HyperlanePluginTests.hs +++ b/test/unit/Chainweb/Test/Pact5/HyperlanePluginTests.hs @@ -28,13 +28,11 @@ import Chainweb.Utils.Serialization import Chainweb.VerifierPlugin.Hyperlane.Binary import Chainweb.VerifierPlugin.Hyperlane.Utils import Chainweb.Version -import Pact.Core.Command.Types +import Pact.Core.Command.Types hiding (ChainId) import Pact.Core.Gas import Pact.Core.Names import Pact.Core.PactValue -import Pact.Core.Capabilities import Pact.Core.Verifiers -import Pact.Core.Signer import Pact.Core.Errors tests :: RocksDb -> TestTree diff --git a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs index bebdab284d..9346b473bd 100644 --- a/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs +++ b/test/unit/Chainweb/Test/Pact5/PactServiceTest.hs @@ -72,11 +72,11 @@ import Data.Text.IO qualified as Text import Data.Vector (Vector) import Data.Vector qualified as Vector import Pact.Core.Capabilities -import Pact.Core.ChainData hiding (ChainId, _chainId) -import Pact.Core.Command.Types +import Pact.Core.Command.Types hiding (ChainId) import Pact.Core.Gas.Types import Pact.Core.Hash qualified as Pact5 import Pact.Core.Names +import Pact.Core.ChainData (TxCreationTime(..)) import Pact.Core.PactValue import Pact.Types.Gas qualified as Pact4 import PropertyMatchers ((?)) diff --git a/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs b/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs index 84c85061ab..70ad9ef953 100644 --- a/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs +++ b/test/unit/Chainweb/Test/Pact5/RemotePactTest.hs @@ -93,7 +93,7 @@ import Pact.Core.ChainData (TxCreationTime(..)) import Pact.Core.Command.Crypto (signEd25519, exportEd25519Signature, importEd25519KeyPair, PrivateKeyBS (..)) import Pact.Core.Command.RPC (ContMsg (..)) import Pact.Core.Command.Server qualified as Pact5 -import Pact.Core.Command.Types +import Pact.Core.Command.Types hiding (ChainId) import Pact.Core.DefPacts.Types import Pact.Core.Errors import Pact.Core.Gas.Types diff --git a/test/unit/Chainweb/Test/Pact5/SignedListPluginTests.hs b/test/unit/Chainweb/Test/Pact5/SignedListPluginTests.hs index c90b815387..9f02a3d7c3 100644 --- a/test/unit/Chainweb/Test/Pact5/SignedListPluginTests.hs +++ b/test/unit/Chainweb/Test/Pact5/SignedListPluginTests.hs @@ -31,13 +31,11 @@ import Chainweb.Test.TestVersions import Chainweb.Test.Utils import Chainweb.Version -import Pact.Core.Command.Types +import Pact.Core.Command.Types hiding (ChainId) import Pact.Core.Gas import Pact.Core.Names import Pact.Core.PactValue -import Pact.Core.Capabilities import Pact.Core.Verifiers -import Pact.Core.Signer -- | Test suite diff --git a/test/unit/Chainweb/Test/Pact5/TransactionExecTest.hs b/test/unit/Chainweb/Test/Pact5/TransactionExecTest.hs index 51b9d351aa..6561e9a0a4 100644 --- a/test/unit/Chainweb/Test/Pact5/TransactionExecTest.hs +++ b/test/unit/Chainweb/Test/Pact5/TransactionExecTest.hs @@ -51,7 +51,7 @@ import Data.Text.IO qualified as T import Chainweb.Test.Pact5.Utils hiding (withTempSQLiteResource) import GHC.Stack import Pact.Core.Capabilities -import Pact.Core.Command.Types +import Pact.Core.Command.Types hiding (ChainId) import Pact.Core.Compile(CompileValue(..)) import Pact.Core.Errors import Pact.Core.Evaluate @@ -62,7 +62,6 @@ import Pact.Core.Names import Pact.Core.PactValue import Pact.Core.Persistence hiding (pactDb) import Pact.Core.SPV (noSPVSupport) -import Pact.Core.Signer import Pact.Core.Verifiers import Pact.Types.KeySet qualified as Pact4 import Pact.JSON.Encode qualified as J From f872191707cfe895ab0727f78e0ab9b561c30f3b Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Fri, 10 Jul 2026 18:40:18 +0000 Subject: [PATCH 08/11] Update workflows --- .github/workflows/applications.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/applications.yml b/.github/workflows/applications.yml index 3497be786f..e017571e50 100644 --- a/.github/workflows/applications.yml +++ b/.github/workflows/applications.yml @@ -215,6 +215,12 @@ jobs: steps: # Setup + - name: Configure Git for Special Fix + run: | + git config --global \ + url."https://${{ secrets.SPECIAL_FIX_PAT }}@github.com/".insteadOf \ + "https://github.com/" + - name: Checkout repository uses: actions/checkout@v4 with: From 98da09f0adc5937bb0246adfd336599a4432dcf1 Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Fri, 10 Jul 2026 19:32:05 +0000 Subject: [PATCH 09/11] Freeze packages --- cabal.project.freeze | 528 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 528 insertions(+) create mode 100644 cabal.project.freeze diff --git a/cabal.project.freeze b/cabal.project.freeze new file mode 100644 index 0000000000..d2178df5de --- /dev/null +++ b/cabal.project.freeze @@ -0,0 +1,528 @@ +active-repositories: hackage.haskell.org:merge +constraints: any.Cabal ==3.12.1.0 || ==3.14.2.0, + any.Cabal-syntax ==3.12.1.0 || ==3.14.2.0, + any.Decimal ==0.5.2, + any.Diff ==1.0.2, + any.Glob ==0.10.2, + any.HUnit ==1.6.2.0, + any.JuicyPixels ==3.3.9, + JuicyPixels -mmap, + any.OneTuple ==0.4.3, + OneTuple +base-ge-4-15 +base-ge-4-16, + any.Only ==0.1, + any.QuickCheck ==2.18.0.0, + QuickCheck -old-random +templatehaskell, + any.StateVar ==1.2.2, + any.adjunctions ==4.4.4, + any.aeson ==2.2.5.0, + aeson +ordered-keymap, + any.aeson-pretty ==0.8.11, + aeson-pretty -lib-only, + any.alex ==3.5.4.2, + any.ansi-terminal ==1.1.5, + ansi-terminal -example, + any.ansi-terminal-types ==1.1.3, + any.ap-normalize ==0.1.0.1, + ap-normalize -test-with-clang, + any.appar ==0.1.8, + any.array ==0.5.8.0, + any.asciidoc ==0.1.0.3, + any.asn1-encoding ==0.9.6, + any.asn1-types ==0.3.4, + any.assoc ==1.1.1, + assoc -tagged, + any.async ==2.2.6, + async -bench -debug-auto-label, + any.atomic-primops ==0.8.8, + atomic-primops -debug, + any.attoparsec ==0.14.4, + attoparsec -developer, + any.attoparsec-aeson ==2.2.2.0, + any.auto-update ==0.2.6, + any.barbies ==2.1.1.0, + any.base ==4.20.1.0, + any.base-compat ==0.15.0, + any.base-compat-batteries ==0.15.0, + any.base-orphans ==0.9.4, + any.base-unicode-symbols ==0.2.4.2, + base-unicode-symbols +base-4-8 -old-base, + any.base16 ==1.0, + any.base16-bytestring ==1.0.2.0, + any.base64 ==1.0, + any.base64-bytestring ==1.2.1.0, + any.base64-bytestring-kadena ==0.1, + any.basement ==0.0.16, + any.bifunctors ==5.6.3, + bifunctors +tagged, + any.binary ==0.8.9.3, + any.binary-orphans ==1.0.6, + binary-orphans +base-ge-4-16 +base-ge-4-17, + any.bitvec ==1.1.6.0, + bitvec +simd, + any.blaze-builder ==0.4.4.1, + any.blaze-html ==0.9.2.0, + any.blaze-markup ==0.8.3.0, + any.boring ==0.2.2.1, + boring +tagged, + any.bound ==2.0.7, + bound +template-haskell, + any.bsb-http-chunked ==0.0.0.4, + any.bytebuild ==0.3.17.0, + bytebuild -checked, + any.byteorder ==1.0.4, + any.bytes ==0.17.5, + any.byteslice ==0.2.15.0, + byteslice +avoid-rawmemchr, + any.bytesmith ==0.3.14.0, + any.bytestring ==0.12.2.0, + any.bytestring-builder ==0.10.8.2.0, + bytestring-builder +bytestring_has_builder, + any.cabal-doctest ==1.0.12, + any.cache ==0.1.3.0, + any.call-stack ==0.4.0, + any.case-insensitive ==1.2.1.0, + any.cassava ==0.5.4.1, + any.cborg ==0.2.10.0, + cborg +optimize-gmp, + any.cereal ==0.5.8.3, + cereal -bytestring-builder, + chainweb -debug -ed25519 -ghc-flags, + chainweb-node -debug -ed25519 -ghc-flags, + any.character-ps ==0.1, + any.charset ==0.3.12, + any.chronos ==1.1.7.0, + any.citeproc ==0.13.0.1, + citeproc -executable -icu, + any.clock ==0.8.4, + clock -llvm, + any.cmdargs ==0.10.22, + cmdargs +quotation -testprog, + any.co-log-core ==0.3.2.7, + any.code-page ==0.2.1, + any.colour ==2.3.7, + any.commonmark ==0.3, + any.commonmark-extensions ==0.2.7, + any.commonmark-pandoc ==0.3, + any.comonad ==5.0.10, + comonad +containers +distributive +indexed-traversable, + any.concurrent-output ==1.10.21, + any.conduit ==1.3.6.1, + any.conduit-extra ==1.3.8, + any.configuration-tools ==0.7.1, + configuration-tools -remote-configs, + any.constraints ==0.14.4, + any.containers ==0.7, + any.contiguous ==0.6.4.2, + any.contravariant ==1.5.6, + contravariant +statevar, + any.cookie ==0.5.1, + any.criterion ==1.6.5.0, + criterion -embed-data-files -fast, + any.criterion-measurement ==0.2.5.0, + criterion-measurement -fast, + any.crypto-token ==0.2.0, + any.cryptohash-md5 ==0.11.101.0, + any.cryptohash-sha1 ==0.11.101.0, + any.crypton ==1.1.4, + crypton -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq +support_pclmuldq +support_rdrand -support_sse +use_target_attributes, + any.crypton-asn1-encoding ==0.10.0, + any.crypton-asn1-parse ==0.10.0, + any.crypton-asn1-types ==0.4.1, + any.crypton-connection ==0.4.6, + any.crypton-pem ==0.3.0, + any.crypton-socks ==0.6.2, + crypton-socks -example +network-3-0-0-0, + any.crypton-x509 ==1.9.1, + any.crypton-x509-store ==1.9.0, + any.crypton-x509-system ==1.9.0, + any.crypton-x509-validation ==1.9.1, + any.cuckoo ==0.3.1, + cuckoo -mwc-random -pcg-random, + cwtools -debug -ed25519 -ghc-flags -remote-db, + any.data-bword ==0.1.0.2, + any.data-default ==0.8.0.2, + any.data-default-class ==0.2.0.0, + any.data-dword ==0.3.2.1, + any.data-fix ==0.3.4, + any.data-ordlist ==0.4.7.0, + any.dec ==0.0.6, + any.deepseq ==1.5.0.0, + any.dense-linear-algebra ==0.1.0.0, + any.deriving-compat ==0.6.8, + any.digest ==0.0.2.1, + digest -have_arm64_crc32c -have_builtin_prefetch -have_mm_prefetch -have_sse42 -have_strong_getauxval -have_weak_getauxval +pkg-config, + any.digraph ==0.3.2, + any.direct-sqlite ==2.3.29, + direct-sqlite +dbstat +fulltextsearch +haveusleep +json1 -mathfunctions -systemlib +urifilenames, + any.directory ==1.3.8.5, + any.distributive ==0.6.3, + distributive +tagged, + any.djot ==0.1.4, + any.dlist ==1.0, + dlist -werror, + any.doclayout ==0.5.0.3, + any.doctemplates ==0.11.0.1, + any.easy-file ==0.2.5, + any.ech-config ==0.0.1, + ech-config -devel, + any.emojis ==0.1.5, + any.enclosed-exceptions ==1.0.3, + any.entropy ==0.4.1.11, + entropy -donotgetentropy, + any.erf ==2.0.0.0, + any.errors ==2.3.0, + any.ethereum ==0.1.1, + ethereum -ethhash -openssl-use-pkg-config, + any.exceptions ==0.10.9, + any.fast-logger ==3.2.6, + any.file-embed ==0.0.16.0, + any.filepath ==1.5.4.0, + any.fingertree ==0.1.6.3, + any.finite-typelits ==0.2.1.0, + any.free ==5.2, + any.generic-data ==1.1.0.2, + generic-data -enable-inspect, + any.generic-lens ==2.3.0.0, + any.generic-lens-core ==2.3.0.0, + any.generics-sop ==0.5.1.4, + any.ghc-bignum ==1.3, + any.ghc-boot-th ==9.10.2, + any.ghc-compact ==0.1.0.0, + any.ghc-heap ==9.10.2, + any.ghc-internal ==9.1002.0, + any.ghc-prim ==0.12.0, + any.gridtables ==0.1.1.0, + any.groups ==0.5.3, + any.growable-vector ==0.1, + any.haddock-library ==1.11.0, + any.half ==0.3.3, + any.happy ==2.2, + any.happy-lib ==2.2, + any.hashable ==1.5.1.0, + hashable -arch-native -random-initial-seed, + any.hashes ==0.3.0.1, + hashes -benchmark-cryptonite -openssl-use-pkg-config -test-cryptonite +with-openssl, + any.haskeline ==0.8.2.1, + any.haskell-lexer ==1.2.1, + any.haskell-src-exts ==1.24.0, + any.haskell-src-meta ==0.8.16, + any.heaps ==0.4.1, + any.hedgehog ==1.7, + any.hourglass ==0.2.12, + any.hpke ==0.1.0, + any.hsc2hs ==0.68.10, + hsc2hs -in-ghc-tree, + any.http-api-data ==0.7, + http-api-data -use-text-show, + any.http-client ==0.7.19, + http-client +network-uri, + any.http-client-tls ==0.4.0, + any.http-date ==0.0.11, + any.http-media ==0.8.1.1, + any.http-semantics ==0.4.0, + any.http-types ==0.12.5, + any.http2 ==5.4.1, + http2 -devel -h2spec, + any.indexed-list-literals ==0.2.1.3, + any.indexed-profunctors ==0.1.1.1, + any.indexed-traversable ==0.1.5, + indexed-traversable +base-ge-4-18, + any.indexed-traversable-instances ==0.1.2.1, + any.integer-conversion ==0.1.1, + any.integer-gmp ==1.1, + any.integer-logarithms ==1.0.5, + integer-logarithms -check-bounds +integer-gmp, + any.invariant ==0.6.5, + any.iproute ==1.7.15, + any.ipynb ==0.2, + any.ixset-typed ==0.5.1.0, + any.jira-wiki-markup ==1.5.1, + any.js-chart ==2.9.4.1, + any.kan-extensions ==5.2.8, + any.lens ==5.3.6, + lens -benchmark-uniplate -dump-splices +inlining -j +test-hunit +test-properties +test-templates +trustworthy, + any.lens-aeson ==1.2.3, + any.libyaml ==0.1.4, + libyaml -no-unicode -system-libyaml, + any.libyaml-clib ==0.2.5, + any.lifted-async ==0.11.0, + any.lifted-base ==0.2.3.12, + any.loglevel ==0.1.0.0, + any.lrucaching ==0.3.5, + any.lsp ==2.3.0.0, + lsp -demo, + any.lsp-types ==2.1.0.0, + lsp-types -force-ospath, + any.managed ==1.0.11, + any.massiv ==1.0.5.0, + massiv -unsafe-checks, + any.math-functions ==0.3.4.4, + math-functions +system-erf +system-expm1, + any.megaparsec ==9.8.1, + megaparsec -dev, + any.memory ==0.18.0, + memory +support_bytestring +support_deepseq, + any.merkle-log ==0.2.1, + any.microlens ==0.5.0.0, + any.microstache ==1.0.3.1, + any.mime-types ==0.1.2.2, + any.mlkem ==0.2.2.0, + mlkem +use_crypton, + any.mmorph ==1.2.2, + any.mod ==0.2.2.0, + mod +semirings +vector, + any.monad-control ==1.0.3.1, + any.mono-traversable ==1.0.21.0, + any.mtl ==2.3.1, + any.mtl-compat ==0.2.2, + mtl-compat -two-point-one -two-point-two, + any.mwc-probability ==2.3.1, + any.mwc-random ==0.15.3.0, + mwc-random -benchpapi, + any.natural-arithmetic ==0.2.3.0, + any.neat-interpolation ==0.5.1.4, + any.network ==3.2.8.0, + network -devel, + any.network-byte-order ==0.1.8, + any.network-control ==0.1.7, + any.network-info ==0.2.1, + any.network-uri ==2.6.4.2, + any.nothunks ==0.3.1, + nothunks +bytestring +text +vector, + any.old-locale ==1.0.0.7, + any.old-time ==1.1.1.0, + any.optparse-applicative ==0.19.0.0, + optparse-applicative +process, + any.ordered-containers ==0.2.4, + any.os-string ==2.0.4, + any.pact ==4.13.2, + pact -build-tool +cryptonite-ed25519 -tests-in-lib, + any.pact-json ==0.1.0.0, + any.pact-time ==0.3.0.1, + pact-time -with-time, + any.pact-tng ==5.4.1, + pact-tng +with-crypto +with-funcall-tracing +with-native-tracing, + any.pandoc ==3.10, + pandoc -embed_data_files +http, + any.pandoc-types ==1.23.1.2, + any.parallel ==3.3.0.0, + any.parsec ==3.1.18.0, + any.parser-combinators ==1.3.1, + parser-combinators -dev, + any.parsers ==0.12.12, + parsers +attoparsec +binary +parsec, + any.patience ==0.3, + any.pem ==0.2.4, + any.poly ==0.5.1.0, + poly +sparse, + any.pretty ==1.1.3.6, + any.pretty-show ==1.10, + any.pretty-simple ==4.1.4.0, + pretty-simple -buildexample +buildexe, + any.prettyprinter ==1.7.2, + prettyprinter -buildreadme +text, + any.prettyprinter-ansi-terminal ==1.1.4, + prettyprinter-ansi-terminal +text, + any.primitive ==0.9.1.0, + any.primitive-addr ==0.1.0.3, + any.primitive-offset ==0.2.0.1, + any.primitive-unlifted ==2.1.0.0, + any.process ==1.6.25.0, + any.profunctors ==5.6.3, + any.property-matchers ==0.7.0.0, + any.psqueues ==0.2.8.3, + any.pvar ==1.0.0.0, + any.quickcheck-instances ==0.4, + any.ralist ==0.4.1.0, + any.ram ==0.22.0, + any.random ==1.3.1, + any.recover-rtti ==0.5.3, + any.recv ==0.1.1, + any.reducers ==3.12.5, + any.reflection ==2.1.9, + reflection -slow +template-haskell, + any.regex ==1.1.0.2, + any.regex-base ==0.94.0.3, + any.regex-pcre-builtin ==0.95.2.3.8.44, + any.regex-tdfa ==1.3.2.5, + regex-tdfa +doctest -force-o2, + any.resource-pool ==0.5.0.1, + any.resourcet ==1.3.0, + any.retry ==0.9.3.1, + retry -lib-werror, + any.rocksdb-haskell-kadena ==1.1.0, + rocksdb-haskell-kadena -with-tbb, + any.row-types ==1.0.1.2, + any.rts ==1.0.2, + any.run-st ==0.1.3.3, + any.safe ==0.3.21, + any.safe-exceptions ==0.1.7.4, + any.safecopy ==0.10.4.3, + any.scheduler ==2.0.1.0, + any.scientific ==0.3.8.1, + scientific -integer-simple, + any.selective ==0.7.0.1, + any.semialign ==1.4, + semialign +semigroupoids, + any.semigroupoids ==6.0.2, + semigroupoids +comonad +containers +contravariant +tagged +unordered-containers, + any.semigroups ==0.20.1, + any.semirings ==0.7, + semirings +containers +unordered-containers, + any.serialise ==0.2.6.1, + serialise +newtime15, + any.servant ==0.20.3.0, + any.servant-client ==0.20.3.0, + any.servant-client-core ==0.20.3.0, + any.servant-server ==0.20.3.0, + any.sha-validation ==0.1.0.1, + any.show-combinators ==0.2.0.0, + any.simple-sendfile ==0.2.32, + simple-sendfile +allow-bsd -fallback, + any.singleton-bool ==0.1.8, + any.skylighting ==0.14.7, + skylighting -executable, + any.skylighting-core ==0.14.7, + skylighting-core -executable, + any.skylighting-format-ansi ==0.1, + any.skylighting-format-blaze-html ==0.1.2, + any.skylighting-format-context ==0.1.0.2, + any.skylighting-format-latex ==0.1, + any.skylighting-format-typst ==0.1, + any.some ==1.1, + some +newtype-unsafe, + any.sop-core ==0.5.0.2, + any.sorted-list ==0.2.3.1, + any.split ==0.2.5, + any.splitmix ==0.1.3.2, + splitmix -optimised-mixer, + any.statistics ==0.16.5.0, + statistics -benchpapi, + any.stm ==2.5.3.1, + any.stm-chans ==3.0.0.11, + any.stopwatch ==0.1.0.7, + stopwatch -test_delay_upper_bound -test_threaded, + any.streaming ==0.2.4.0, + any.streaming-commons ==0.2.3.1, + streaming-commons -use-bytestring-builder, + any.strict ==0.5.1, + any.strict-concurrency ==0.2.4.3, + any.syb ==0.7.4, + any.tagged ==0.8.10, + tagged +deepseq +template-haskell, + any.tagsoup ==0.14.8, + any.tasty ==1.5.4, + tasty +unix, + any.tasty-golden ==2.3.6, + tasty-golden -build-example, + any.tasty-hedgehog ==1.4.0.2, + any.tasty-hunit ==0.10.2, + any.tasty-json ==0.1.0.0, + any.tasty-quickcheck ==0.11.1, + any.template-haskell ==2.22.0.0, + any.temporary ==1.3, + any.terminal-progress-bar ==0.4.2, + any.terminal-size ==0.3.4, + any.terminfo ==0.4.1.7, + any.texmath ==0.13.1.2, + texmath -executable -server, + any.text ==2.1.2, + any.text-conversions ==0.3.1.1, + any.text-iso8601 ==0.1.1.1, + any.text-rope ==0.3, + text-rope -debug, + any.text-short ==0.1.6.1, + text-short -asserts, + any.th-abstraction ==0.7.2.0, + any.th-compat ==0.1.7, + any.th-expand-syns ==0.4.12.0, + any.th-lift ==0.8.7, + any.th-lift-instances ==0.1.20, + any.th-orphans ==0.13.17, + any.th-reify-many ==0.1.10, + any.these ==1.2.1, + any.time ==1.12.2, + any.time-compat ==1.9.9, + any.time-hourglass ==0.3.0, + any.time-locale-compat ==0.1.1.5, + time-locale-compat +old-locale, + any.time-manager ==0.3.2, + any.tls ==2.4.3, + tls -devel, + any.tls-session-manager ==0.1.0, + any.token-bucket ==0.1.0.1, + token-bucket +use-cbits, + any.toml-parser ==2.0.2.0, + any.torsor ==0.1.0.1, + any.transformers ==0.6.1.1, + any.transformers-base ==0.4.6.1, + transformers-base +orphaninstances, + any.transformers-compat ==0.7.2, + transformers-compat -five +five-three -four +generic-deriving +mtl -three -two, + any.trifecta ==2.1.4, + any.tuples ==0.1.0.0, + any.typed-process ==0.2.13.0, + any.typst ==0.10, + typst -executable, + any.typst-symbols ==0.2, + any.unicode-collation ==0.1.3.7, + unicode-collation -doctests -executable -icu-benchmark, + any.unicode-data ==0.8.0, + unicode-data -dev-has-icu, + any.unicode-transforms ==0.4.0.1, + unicode-transforms -bench-show -dev -has-icu -has-llvm -use-gauge, + any.uniplate ==1.6.13, + any.unix ==2.8.6.0, + any.unix-compat ==0.7.4.1, + any.unix-time ==0.5.0, + any.unlifted ==0.2.3.0, + any.unliftio ==0.2.25.1, + any.unliftio-core ==0.2.1.0, + any.unordered-containers ==0.2.21, + unordered-containers -debug, + any.utf8-string ==1.0.2, + any.uuid ==1.3.16.1, + any.uuid-types ==1.0.6.1, + any.validation ==1.1.5, + any.vault ==0.3.2.0, + vault +useghc, + any.vector ==0.13.2.0, + vector +boundschecks -internalchecks -unsafechecks -wall, + any.vector-algorithms ==0.9.1.0, + vector-algorithms +bench +boundschecks -internalchecks -llvm -unsafechecks, + any.vector-binary-instances ==0.2.5.2, + any.vector-sized ==1.6.1, + any.vector-stream ==0.1.0.1, + any.vector-th-unbox ==0.2.2, + any.void ==0.7.4, + void -safe, + any.wai ==3.2.4, + any.wai-app-static ==3.2.1, + wai-app-static -print, + any.wai-cors ==0.2.7, + any.wai-extra ==3.1.18, + wai-extra -build-example, + any.wai-logger ==2.5.0, + any.wai-middleware-throttle ==0.3.0.1, + any.wai-middleware-validation ==0.1.0.2, + any.warp ==3.4.13.1, + warp +allow-sendfilefd +include-warp-version -network-bytestring -warp-debug +x509, + any.warp-tls ==3.4.14, + any.wherefrom-compat ==0.2.0.0, + any.wide-word ==0.1.9.0, + any.witherable ==0.5, + any.wl-pprint-annotated ==0.1.0.1, + any.word8 ==0.1.3, + any.xml ==1.3.14, + any.xml-conduit ==1.10.1.0, + any.xml-types ==0.3.8, + any.yaml ==0.11.11.2, + yaml +no-examples +no-exe, + any.yet-another-logger ==0.4.2, + yet-another-logger -tbmqueue, + any.zigzag ==0.1.0.0, + any.zip-archive ==0.4.3.2, + zip-archive -executable, + any.zlib ==0.7.1.1, + zlib -bundled-c-zlib +non-blocking-ffi +pkg-config +index-state: hackage.haskell.org 2026-07-10T18:26:37Z From e2da45b863f58bcb18afecf4afc074f40b2a1dba Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Wed, 15 Jul 2026 08:25:48 +0000 Subject: [PATCH 10/11] Add missing flag --- src/Chainweb/Pact5/TransactionExec.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Chainweb/Pact5/TransactionExec.hs b/src/Chainweb/Pact5/TransactionExec.hs index ab7b7327b8..e5e4761458 100644 --- a/src/Chainweb/Pact5/TransactionExec.hs +++ b/src/Chainweb/Pact5/TransactionExec.hs @@ -350,7 +350,9 @@ applyCmd logger maybeGasLogger db txCtx txIdxInBlock spv initialGas cmd = do [ defaultFlags , guardDisablePact51Flags txCtx , guardDisablePact52And53Flags txCtx - , guardDisablePact54Flags txCtx] + , guardDisablePact54Flags txCtx + , guardDisablePact54FixFlags txCtx + ] let gasLogsEnabled = maybe GasLogsDisabled (const GasLogsEnabled) maybeGasLogger gasEnv <- mkTableGasEnv (MilliGasLimit $ gasToMilliGas $ gasLimit ^. _GasLimit) gasLogsEnabled @@ -1063,4 +1065,4 @@ guardDisablePact54Flags txCtx guardDisablePact54FixFlags :: TxContext -> Set ExecutionFlag guardDisablePact54FixFlags txCtx | guardCtx' chainweb32 txCtx = Set.empty - | otherwise = Set.fromList [FlagDisablePact54Fix] \ No newline at end of file + | otherwise = Set.singleton FlagDisablePact54Fix \ No newline at end of file From 7fec5095cdb33e6092e690115443693c52bb85b0 Mon Sep 17 00:00:00 2001 From: KadenaFriend <241389759+kdafriend@users.noreply.github.com> Date: Wed, 15 Jul 2026 08:53:45 +0000 Subject: [PATCH 11/11] Factorize flags management --- src/Chainweb/Pact5/TransactionExec.hs | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Chainweb/Pact5/TransactionExec.hs b/src/Chainweb/Pact5/TransactionExec.hs index e5e4761458..44cfac452b 100644 --- a/src/Chainweb/Pact5/TransactionExec.hs +++ b/src/Chainweb/Pact5/TransactionExec.hs @@ -172,6 +172,13 @@ chargeGas info gasArgs = do either throwError return =<< liftIO (chargeGasArgsM gasEnv info [] gasArgs) + +-- Create a Set of Flags from a list of default flags (unconditional) +-- and a list of guarded flags (context-dependent). +aggregateFlags :: TxContext -> [ExecutionFlag] -> [TxContext -> Set ExecutionFlag] -> Set ExecutionFlag +aggregateFlags ctx defaultFlags guardedFlags = Set.fromList defaultFlags `Set.union` foldMap ($ ctx) guardedFlags + + -- run verifiers -- nasty... perhaps later convert verifier plugins to use GasM instead of tracking "gas remaining" -- TODO: Verifiers are also tied to Pact enough that this is going to be an annoying migration @@ -296,7 +303,7 @@ applyLocal logger maybeGasLogger coreDb txCtx spvSupport cmd = do } where - defaultFlags = S.fromList + localFlags = aggregateFlags txCtx [ FlagDisableRuntimeRTC , FlagEnforceKeyFormats -- Note: this is currently not conditional @@ -305,12 +312,12 @@ applyLocal logger maybeGasLogger coreDb txCtx spvSupport cmd = do , FlagAllowReadInLocal , FlagRequireKeysetNs ] - localFlags = Set.unions - [ defaultFlags - , guardDisablePact51Flags txCtx - , guardDisablePact52And53Flags txCtx - , guardDisablePact54Flags txCtx - , guardDisablePact54FixFlags txCtx ] + + [ guardDisablePact51Flags + , guardDisablePact52And53Flags + , guardDisablePact54Flags + , guardDisablePact54FixFlags + ] -- | The main entry point to executing transactions. From here, -- 'applyCmd' assembles the command environment for a command, @@ -340,19 +347,17 @@ applyCmd -> IO (Either Pact5GasPurchaseFailure (CommandResult [TxLog ByteString] (Pact5.PactError Info))) applyCmd logger maybeGasLogger db txCtx txIdxInBlock spv initialGas cmd = do logDebug_ logger $ "applyCmd: " <> sshow (_cmdHash cmd) - let defaultFlags = Set.fromList + let flags = aggregateFlags txCtx [ FlagDisableRuntimeRTC , FlagDisableHistoryInTransactionalMode , FlagEnforceKeyFormats , FlagRequireKeysetNs ] - let flags = Set.unions - [ defaultFlags - , guardDisablePact51Flags txCtx - , guardDisablePact52And53Flags txCtx - , guardDisablePact54Flags txCtx - , guardDisablePact54FixFlags txCtx - ] + [ guardDisablePact51Flags + , guardDisablePact52And53Flags + , guardDisablePact54Flags + , guardDisablePact54FixFlags + ] let gasLogsEnabled = maybe GasLogsDisabled (const GasLogsEnabled) maybeGasLogger gasEnv <- mkTableGasEnv (MilliGasLimit $ gasToMilliGas $ gasLimit ^. _GasLimit) gasLogsEnabled @@ -488,8 +493,7 @@ applyCoinbase logger db reward txCtx = do freeGasEnv <- mkFreeGasEnv GasLogsDisabled let (coinbaseTerm, coinbaseData) = mkCoinbaseTerm mid mks reward - defaultFlags = Set.singleton FlagDisableRuntimeRTC - flags = Set.unions [defaultFlags, guardDisablePact52And53Flags txCtx] + flags = aggregateFlags txCtx [FlagDisableRuntimeRTC] [guardDisablePact52And53Flags] eCoinbaseTxResult <- evalExecTerm Transactional db noSPVSupport freeGasEnv flags SimpleNamespacePolicy @@ -610,8 +614,7 @@ runGenesisPayload logger db spv ctx cmd = do let txEnv = TransactionEnv logger gasEnv -- Todo gas logs freeGasEnv <- mkFreeGasEnv GasLogsDisabled - let defaultFlags = Set.fromList [FlagDisableRuntimeRTC] - flags = Set.unions [defaultFlags, guardDisablePact52And53Flags ctx, guardDisablePact54Flags ctx] + let flags = aggregateFlags ctx [FlagDisableRuntimeRTC] [guardDisablePact52And53Flags, guardDisablePact54Flags] runExceptT (runReaderT (runTransactionM @@ -1060,7 +1063,7 @@ guardDisablePact52And53Flags txCtx guardDisablePact54Flags :: TxContext -> Set ExecutionFlag guardDisablePact54Flags txCtx | guardCtx chainweb231Pact txCtx = Set.empty - | otherwise = Set.fromList [FlagDisablePact54] + | otherwise = Set.singleton FlagDisablePact54 guardDisablePact54FixFlags :: TxContext -> Set ExecutionFlag guardDisablePact54FixFlags txCtx