Skip to content

Commit

Permalink
Merge pull request #2085 from kadena-io/push-ustmvsuwzlkz
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble authored Jan 7, 2025
2 parents 73cc88d + 0b1fd32 commit eed8c8d
Show file tree
Hide file tree
Showing 31 changed files with 1,437 additions and 910 deletions.
28 changes: 15 additions & 13 deletions cabal.project.freeze
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ constraints: any.Cabal ==3.12.1.0,
aeson +ordered-keymap,
any.aeson-pretty ==0.8.10,
aeson-pretty -lib-only,
any.alex ==3.5.1.0,
any.alex ==3.5.2.0,
any.ansi-terminal ==1.1.2,
ansi-terminal -example,
any.ansi-terminal-types ==1.1,
Expand All @@ -41,7 +41,7 @@ constraints: any.Cabal ==3.12.1.0,
attoparsec -developer,
any.attoparsec-aeson ==2.2.2.0,
any.authenticate-oauth ==1.7,
any.auto-update ==0.2.5,
any.auto-update ==0.2.6,
any.barbies ==2.1.1.0,
any.base ==4.19.1.0,
any.base-compat ==0.14.1,
Expand Down Expand Up @@ -165,19 +165,21 @@ constraints: any.Cabal ==3.12.1.0,
any.easy-file ==0.2.5,
any.emojis ==0.1.4.1,
any.enclosed-exceptions ==1.0.3,
any.entropy ==0.4.1.10,
any.entropy ==0.4.1.11,
entropy -donotgetentropy,
any.erf ==2.0.0.0,
any.errors ==2.3.0,
any.ethereum ==0.1.0.2,
ethereum -ethhash -openssl-use-pkg-config,
any.exceptions ==0.10.7,
any.extra ==1.8,
any.fast-logger ==3.2.5,
any.file-embed ==0.0.16.0,
any.filepath ==1.4.200.1,
any.fingertree ==0.1.5.0,
any.finite-typelits ==0.2.1.0,
any.free ==5.2,
any.generic-arbitrary ==1.0.1,
any.generic-data ==1.1.0.2,
generic-data -enable-inspect,
any.generic-lens ==2.2.2.0,
Expand Down Expand Up @@ -225,7 +227,7 @@ constraints: any.Cabal ==3.12.1.0,
any.indexed-traversable-instances ==0.1.2,
any.integer-conversion ==0.1.1,
any.integer-gmp ==1.1,
any.integer-logarithms ==1.0.3.1,
any.integer-logarithms ==1.0.4,
integer-logarithms -check-bounds +integer-gmp,
any.invariant ==0.6.4,
any.iproute ==1.7.15,
Expand All @@ -234,7 +236,7 @@ constraints: any.Cabal ==3.12.1.0,
any.jira-wiki-markup ==1.5.1,
any.js-chart ==2.9.4.1,
any.kan-extensions ==5.2.6,
any.lens ==5.3.2,
any.lens ==5.3.3,
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,
Expand All @@ -244,9 +246,9 @@ constraints: any.Cabal ==3.12.1.0,
any.lifted-base ==0.2.3.12,
any.loglevel ==0.1.0.0,
any.lrucaching ==0.3.4,
any.lsp ==2.3.0.0,
any.lsp ==2.7.0.1,
lsp -demo,
any.lsp-types ==2.1.0.0,
any.lsp-types ==2.3.0.1,
lsp-types -force-ospath,
any.managed ==1.0.10,
any.massiv ==1.0.4.0,
Expand Down Expand Up @@ -295,7 +297,7 @@ constraints: any.Cabal ==3.12.1.0,
pact-time -with-time,
any.pact-tng ==5.0,
pact-tng +with-crypto +with-funcall-tracing +with-native-tracing,
any.pandoc ==3.6,
any.pandoc ==3.6.1,
pandoc -embed_data_files,
any.pandoc-types ==1.23.1,
any.parallel ==3.2.2.0,
Expand All @@ -321,7 +323,7 @@ constraints: any.Cabal ==3.12.1.0,
any.primitive-unlifted ==2.1.0.0,
any.process ==1.6.18.0,
any.profunctors ==5.6.2,
any.property-matchers ==0.2.0.0,
any.property-matchers ==0.4.0.0,
any.psqueues ==0.2.8.0,
any.pvar ==1.0.0.0,
any.quickcheck-instances ==0.3.32,
Expand Down Expand Up @@ -372,9 +374,9 @@ constraints: any.Cabal ==3.12.1.0,
any.simple-sendfile ==0.2.32,
simple-sendfile +allow-bsd -fallback,
any.singleton-bool ==0.1.8,
any.skylighting ==0.14.4,
any.skylighting ==0.14.5,
skylighting -executable,
any.skylighting-core ==0.14.4,
any.skylighting-core ==0.14.5,
skylighting-core -executable,
any.skylighting-format-ansi ==0.1,
any.skylighting-format-blaze-html ==0.1.1.3,
Expand Down Expand Up @@ -433,7 +435,7 @@ constraints: any.Cabal ==3.12.1.0,
any.th-reify-many ==0.1.10,
any.these ==1.2.1,
any.time ==1.12.2,
any.time-compat ==1.9.7,
any.time-compat ==1.9.8,
any.time-locale-compat ==0.1.1.5,
time-locale-compat +old-locale,
any.time-manager ==0.2.2,
Expand Down Expand Up @@ -517,4 +519,4 @@ constraints: any.Cabal ==3.12.1.0,
zip-archive -executable,
any.zlib ==0.7.1.0,
zlib -bundled-c-zlib +non-blocking-ffi +pkg-config
index-state: hackage.haskell.org 2024-12-19T19:57:30Z
index-state: hackage.haskell.org 2025-01-03T16:40:09Z
5 changes: 4 additions & 1 deletion chainweb.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ library
, rosetta >= 1.0
, safe-exceptions >= 0.1
, scheduler >= 1.4
, semialign >= 1.3.1
, semigroupoids >= 5.3.7
, servant >= 0.20.1
, servant-client >= 0.20
Expand Down Expand Up @@ -566,6 +567,7 @@ library chainweb-test-utils
, pact-time:numeric >=0.3.0.1
, pact-tng >=5.0
, pact-tng:pact-request-api >=5.0
, property-matchers ^>= 0.4
, quickcheck-instances >= 0.3
, random >= 1.2
, resourcet >= 1.3
Expand Down Expand Up @@ -730,7 +732,8 @@ test-suite chainweb-tests
, pact-tng:pact-request-api
, pact-tng:test-utils
, patience >= 0.3
, property-matchers ^>= 0.2
, prettyprinter
, property-matchers ^>= 0.4
, pretty-show
, quickcheck-instances >= 0.3
, random >= 1.2
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/Chainweb/ChainId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE DeriveTraversable #-}

-- |
-- Module: Chainweb.ChainId
Expand Down Expand Up @@ -77,7 +78,9 @@ import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HM
import Data.Kind
import Data.Proxy
import Data.Semialign
import qualified Data.Text as T
import Data.These
import Data.Word (Word32)

import GHC.Generics (Generic)
Expand Down Expand Up @@ -276,9 +279,17 @@ chainIdInt (ChainId cid) = int cid

-- | Values keyed by `ChainId`s, or a single value that applies for all chains.
data ChainMap a = AllChains a | OnChains (HashMap ChainId a)
deriving stock (Eq, Functor, Foldable, Generic, Ord, Show)
deriving stock (Eq, Functor, Foldable, Traversable, Generic, Ord, Show)
deriving anyclass (Hashable, NFData)

-- TODO: fix this. This is not a legal instance, because `align` can change the
-- shape from `AllChains` to `OnChains`. This breaks the "alignedness" law.
instance Semialign ChainMap where
align (OnChains l) (OnChains r) = OnChains $ align l r
align (OnChains l) (AllChains r) = OnChains $ fmap (`These` r) l
align (AllChains l) (OnChains r) = OnChains $ fmap (l `These`) r
align (AllChains l) (AllChains r) = AllChains $ These l r

-- | A smart constructor, @onChains = OnChains . HM.fromList@.
onChains :: [(ChainId, a)] -> ChainMap a
onChains = OnChains . HM.fromList
Expand Down
12 changes: 6 additions & 6 deletions src/Chainweb/Mempool/InMem.hs
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,10 @@ validateOne cfg badmap curTxIdx now t h =
ebool_ (InsertErrorOther msg) (f (txGasPrice txcfg t))
where
f (GasPrice (ParsedDecimal d)) = decimalPlaces d <= defaultMaxCoinDecimalPlaces
msg = mconcat
[ "This transaction's gas price: "
msg = T.unwords
[ "This transaction's gas price:"
, sshow (txGasPrice txcfg t)
, " is not correctly rounded."
, "is not correctly rounded."
, "It should be rounded to at most 12 decimal places."
]

Expand Down Expand Up @@ -498,9 +498,9 @@ insertInMem logger cfg lock runCheck txs0 = do
recordRecentTransactions maxRecent newHashes
where
insertCheck :: IO (Vector (T2 TransactionHash t))
insertCheck = if runCheck == CheckedInsert
then insertCheckInMem' cfg lock txs0
else return $! V.map (\tx -> T2 (hasher tx) tx) txs0
insertCheck = case runCheck of
CheckedInsert -> insertCheckInMem' cfg lock txs0
UncheckedInsert -> return $! V.map (\tx -> T2 (hasher tx) tx) txs0

txcfg = _inmemTxCfg cfg
encodeTx = codecEncode (txCodec txcfg)
Expand Down
2 changes: 2 additions & 0 deletions src/Chainweb/Mempool/Mempool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ data InsertError
| InsertErrorInvalidSigs
| InsertErrorTimedOut
| InsertErrorPactParseError Text
| InsertErrorWrongChain Text Text
deriving (Generic, Eq, NFData)

instance Show InsertError where
Expand All @@ -259,6 +260,7 @@ instance Show InsertError where
InsertErrorInvalidSigs -> "Invalid transaction sigs"
InsertErrorTimedOut -> "Transaction validation timed out"
InsertErrorPactParseError msg -> "Pact parse error: " <> T.unpack msg
InsertErrorWrongChain expected actual -> "Wrong chain, expected: " <> T.unpack expected <> ", actual: " <> T.unpack actual

instance Exception InsertError

Expand Down
4 changes: 4 additions & 0 deletions src/Chainweb/Pact/Backend/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module Chainweb.Pact.Backend.Types
, pendingTxLogMap
, SQLiteRowDelta(..)
, Historical(..)
, _Historical
, _NoHistory
, PactDbFor
) where

Expand Down Expand Up @@ -145,4 +147,6 @@ data Historical a
deriving stock (Eq, Foldable, Functor, Generic, Traversable, Show)
deriving anyclass NFData

makePrisms ''Historical

type family PactDbFor logger (pv :: PactVersion)
Loading

0 comments on commit eed8c8d

Please sign in to comment.