Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pact Aeson2 #1242

Merged
merged 178 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 175 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
1ccffbe
toEncoding instances
larskuhtz Sep 14, 2022
0446ffa
misc and aeson-2
larskuhtz Sep 14, 2022
efcf637
fixes and JSON compat tests
larskuhtz Sep 16, 2022
53dd9a5
...
larskuhtz Sep 16, 2022
36dc283
...
larskuhtz Sep 16, 2022
f13cab2
...
larskuhtz Sep 16, 2022
6b6b1d4
fix JSONKey instance for FullyQualifiedName
larskuhtz Sep 16, 2022
26c5520
move arbitrary instances out of Term
larskuhtz Sep 17, 2022
d8fc054
split up Term module
larskuhtz Sep 17, 2022
cdf5eda
remove outdated CPP
larskuhtz Sep 17, 2022
cbf6474
fix hspec build without tools
larskuhtz Sep 17, 2022
ff9cb1e
less inlining
larskuhtz Sep 17, 2022
14b8e2b
add LegacyValue for JSON Value
larskuhtz Sep 19, 2022
72d356a
use LegacyValue for persisting Value
larskuhtz Sep 20, 2022
13772ad
Merge branch 'master' into lars/wip
larskuhtz Oct 3, 2022
3a8c741
fix some FIXMEs and tests
larskuhtz Oct 4, 2022
dceee4f
...
larskuhtz Oct 4, 2022
180cdf1
remove module comments
larskuhtz Oct 4, 2022
c8aaebd
address review comments
larskuhtz Oct 4, 2022
7fb0dd5
Merge branch 'master' into lars/wip
larskuhtz Oct 11, 2022
e7589db
Merge branch 'master' into lars/wip
larskuhtz Oct 11, 2022
81b2b46
Merge branch 'master' into lars/wip
larskuhtz Oct 25, 2022
a823e0b
fix some white spacing
larskuhtz Oct 25, 2022
597c7c0
misc aeson toEncoding fixes
larskuhtz Oct 15, 2022
f70ad13
readd requestKeyToB16Text and fixes to arbitrary instances
larskuhtz Oct 25, 2022
ce15ed8
remove redundant upper bound on entropy
larskuhtz Oct 15, 2022
d3369c5
aeson-2
larskuhtz Oct 19, 2022
c43f0b2
remove outdated code and macros
larskuhtz Oct 24, 2022
78f3e64
cleanup dependencies
larskuhtz Oct 24, 2022
23770a4
update outdated packages
larskuhtz Oct 25, 2022
39c197e
update ci build
larskuhtz Oct 25, 2022
6e9fb08
support ghc-9.2
larskuhtz Oct 25, 2022
9319126
ignore upper bounds on contrainted dependencies
larskuhtz Oct 25, 2022
c5ca7f9
relax bounds introduced by servant
larskuhtz Oct 26, 2022
4b7ea24
aeson-2 support for CapabilityGuard
larskuhtz Oct 26, 2022
e927dd5
build with +cryptonite-ed25519
larskuhtz Oct 26, 2022
6aaebbf
upgrade z3 version for ubuntu-22.04 ci builds
larskuhtz Oct 31, 2022
1a34527
Merge branch 'master' into lars/wip
larskuhtz Nov 4, 2022
b2ca93a
Merge branch 'master' into lars/wip
larskuhtz Nov 14, 2022
c8d35ab
Merge branch 'master' into lars/wip
larskuhtz Nov 17, 2022
5dbdfa7
fix legacy encoding for ModuleData
larskuhtz Nov 21, 2022
7829509
Constrain some arbitrary instances to support more roundtrip tests
larskuhtz Nov 21, 2022
4767f61
disambiugate sums in JSON parsers. Make 'info' and 'i' optional
larskuhtz Nov 21, 2022
05ea97a
allow nested LegacyValues
larskuhtz Nov 21, 2022
1846fc5
add JsonDecode benchmark
larskuhtz Nov 21, 2022
51fa9a0
fix json-decode bechmark
larskuhtz Dec 5, 2022
0406494
support megaparsec 9.3
larskuhtz Dec 5, 2022
c16791b
use LegacyValue in ExecMsg
larskuhtz Dec 5, 2022
594978f
Merge branch 'master' into lars/wip
larskuhtz Dec 13, 2022
00320c6
...
larskuhtz Dec 13, 2022
6309ac5
Merge branch 'master' into lars/wip
larskuhtz Dec 15, 2022
fd0a130
WIP internal json library
larskuhtz Dec 19, 2022
d474fa4
...
larskuhtz Dec 19, 2022
5f9c9bd
...
larskuhtz Dec 19, 2022
4a675c2
pact-json package
larskuhtz Dec 20, 2022
3d6751e
newtype
larskuhtz Dec 20, 2022
a996389
redundant language pragma
larskuhtz Dec 20, 2022
bf08388
[wip] monomorphic txlog
larskuhtz Dec 20, 2022
5513bac
Revert "[wip] monomorphic txlog"
larskuhtz Dec 21, 2022
785478a
...
larskuhtz Jan 18, 2023
ac0ab49
...
larskuhtz Jan 25, 2023
0d44d4b
...
larskuhtz Jan 25, 2023
f28f07e
...
larskuhtz Jan 26, 2023
cdcc53b
Tests passing
larskuhtz Jan 28, 2023
4b99a4f
fixes for chainweb tests
larskuhtz Jan 29, 2023
7867b69
...
larskuhtz Jan 29, 2023
dd4b288
fix mkCommand
larskuhtz Jan 30, 2023
f45fcc0
Revert "fix json-decode bechmark"
larskuhtz Jan 31, 2023
9910f0e
Revert "add JsonDecode benchmark"
larskuhtz Jan 31, 2023
1aa28f8
Merge branch 'master' into lars/wip
larskuhtz Jan 31, 2023
2d5da22
Merge branch 'master' into lars/wip
larskuhtz Feb 3, 2023
c2bd6b4
build with ghc 9.4
larskuhtz Feb 3, 2023
3d89dd2
fix module.blessed serialization
larskuhtz Feb 5, 2023
aa4772c
Merge branch 'master' into lars/wip
larskuhtz Feb 6, 2023
51852c6
Merge branch 'master' into lars/wip
larskuhtz Feb 7, 2023
b06e6ff
remove redundant upper bounds
larskuhtz Feb 9, 2023
9b07459
Encode instances for Paylaod and Signer
larskuhtz Feb 9, 2023
bceff83
fix encoding of module dependencies
larskuhtz Feb 9, 2023
6c9f26a
Merge branch 'master' into lars/wip
larskuhtz Feb 11, 2023
9eaf96b
Revert "remove redundant upper bounds"
larskuhtz Feb 11, 2023
33eb557
update compiler versions
larskuhtz Feb 11, 2023
c0437a5
build image with ghc-9.4.4
larskuhtz Feb 14, 2023
e03360c
tests for pairings
larskuhtz Mar 25, 2023
fc4418f
Merge branch 'master' into lars/wip
larskuhtz Mar 25, 2023
100d004
build with ghc-9.6 and remove unused SBV related definitions
larskuhtz Mar 27, 2023
8ce30a5
...
larskuhtz Mar 27, 2023
8651f00
fix pretty instance for Value
larskuhtz Mar 29, 2023
30f27ad
update build matrix
larskuhtz Mar 29, 2023
29dee0d
relax some bounds for ghc-9.6
larskuhtz Mar 29, 2023
f3c4333
update pact-json pin
larskuhtz Mar 30, 2023
efb4c35
use different order in encoding of dependencies
larskuhtz Mar 31, 2023
b25dbb3
...
larskuhtz Mar 31, 2023
67ac748
...
larskuhtz Mar 31, 2023
deb5c0a
make mkInfo strict in its argument
larskuhtz Mar 31, 2023
52f5d61
move musl float arithmetic into sub-library and fix it for ghc-9.6
larskuhtz Apr 2, 2023
3e4ec6c
build docker image for ghc-9.6.1
larskuhtz Apr 2, 2023
f75f089
update github actions
larskuhtz Apr 2, 2023
3ff918b
more github actions updates
larskuhtz Apr 2, 2023
fc605f9
use legacy order in traverseGraph
larskuhtz Apr 4, 2023
151a1d9
fix error message encoding
larskuhtz Apr 4, 2023
0f029cf
regenerate docs
larskuhtz Apr 4, 2023
140574f
fix time codec
larskuhtz Apr 4, 2023
a4cfc5d
fix type in PactRPC Encode instance
larskuhtz Apr 4, 2023
1a0ef89
fix mkTextInfo for unicode inputs
larskuhtz Apr 5, 2023
8f9844c
fix order in which constraints are resolved
larskuhtz Apr 5, 2023
ad693e3
fix mkInfo
larskuhtz Apr 5, 2023
aab0516
make ExpParser a bit more strict
larskuhtz Apr 7, 2023
bf2d455
fix delta parsing for attoparsec
larskuhtz Apr 8, 2023
7b578d2
Revert "move musl float arithmetic into sub-library and fix it for gh…
larskuhtz Apr 11, 2023
4047fb9
Merge branch 'master' into lars/wip
larskuhtz Apr 11, 2023
7266396
some linting
larskuhtz Apr 12, 2023
3e93eba
one more test
larskuhtz Apr 12, 2023
58ca210
remove redundant HasBytes instance
larskuhtz Apr 12, 2023
c72090b
Merge branch 'master' into lars/deltaparsing
larskuhtz Apr 14, 2023
0d898ec
use legacy parsing
larskuhtz Apr 17, 2023
9a55270
Merge branch 'master' into lars/deltaparsing
larskuhtz Apr 17, 2023
6bd2cea
use legacy parser
larskuhtz Apr 19, 2023
a609679
Merge branch 'master' into lars/deltaparsing
larskuhtz Apr 19, 2023
2a1ce93
Merge branch 'master' into lars/wip
larskuhtz Apr 20, 2023
d332325
Merge branch 'lars/deltaparsing' into lars/wip-deltaparsing
larskuhtz Apr 20, 2023
a626f89
deltaparsing tweaks (#1203)
imalsogreg Apr 20, 2023
2ec274f
Merge branch 'lars/deltaparsing' into lars/wip-deltaparsing
larskuhtz Apr 20, 2023
a50f750
...
larskuhtz Apr 20, 2023
145b474
work around buggy TokenParsing instance for StateT
larskuhtz Apr 21, 2023
5cfb065
fix parser tests
larskuhtz Apr 21, 2023
f7c5b5c
more test fixes
larskuhtz Apr 21, 2023
edcb736
fix legacy parser
larskuhtz Apr 21, 2023
5112979
Merge branch 'master' into lars/wip
larskuhtz Apr 26, 2023
52e72c1
fix parser tests
larskuhtz Apr 26, 2023
5612ab0
add missing strictness annotations
larskuhtz Apr 28, 2023
54ed02e
Merge branch 'master' into lars/wip
larskuhtz Apr 28, 2023
94c4fe9
more strictness
larskuhtz Apr 28, 2023
23fadd0
benchmark json encoding
larskuhtz Apr 28, 2023
0bf488d
Merge branch 'master' into lars/wip
larskuhtz Apr 28, 2023
665edfd
be strict consistently
larskuhtz Apr 29, 2023
3540437
fix roundtrip of time values
larskuhtz Apr 30, 2023
438abd7
add ghc-9.4 back to the build matrix
larskuhtz Apr 30, 2023
74bbf76
remove redundant imports
larskuhtz May 1, 2023
7cea5c8
Merge branch 'master' into lars/wip
larskuhtz May 1, 2023
9ce40d4
Merge branch 'master' into lars/wip
larskuhtz May 2, 2023
925fd78
drop support for old hashable and some CPP cleanup
larskuhtz May 7, 2023
44a3033
drop support for text <2
larskuhtz May 7, 2023
4273e29
Merge branch 'master' into lars/wip
larskuhtz May 9, 2023
7d6d593
Merge branch 'master' into lars/wip
larskuhtz May 10, 2023
59fed8a
Merge branch 'master' into lars/wip
larskuhtz May 12, 2023
ae88e0b
Merge branch 'master' into lars/wip
larskuhtz May 12, 2023
2a881d4
Merge branch 'master' into lars/wip
larskuhtz May 15, 2023
6c26ec3
remove redundant Orphan for Value
larskuhtz May 16, 2023
c079b97
replace aeson encode by pact json encode
larskuhtz May 16, 2023
6cfd4c1
Merge branch 'master' into lars/wip
larskuhtz May 16, 2023
c84dabe
fix incomplete pattern
larskuhtz May 16, 2023
99e726b
update pact-json
larskuhtz May 17, 2023
e8d2111
servant support for PactJson
larskuhtz May 17, 2023
1a36d19
yaml utils for GasModelSpec
larskuhtz May 17, 2023
a13526c
update pact-json pin
larskuhtz May 27, 2023
314a7e2
fix sorting of coverage report
larskuhtz May 27, 2023
4e7fef4
disable tojson warnings
larskuhtz May 27, 2023
ae29e8f
update pact-json pin
larskuhtz May 27, 2023
e43311a
fix gas mode spec tests
larskuhtz May 27, 2023
bca7b3e
encode instances for SQLiteConfig
larskuhtz May 27, 2023
6c608d8
encode instance for server config
larskuhtz May 27, 2023
c6bf401
Merge branch 'master' into lars/wip
larskuhtz May 30, 2023
a66e5c8
Make ToJSON instances conditional via CPP
larskuhtz Jun 1, 2023
8d05b33
json instance fixes
larskuhtz Jun 7, 2023
922b180
replace cryptonite by crypton
larskuhtz Jun 9, 2023
e2fab87
address some issues from code review
larskuhtz Jun 9, 2023
147d4f1
Merge branch 'lars/crypton' into lars/wip
larskuhtz Jun 10, 2023
c954c55
Merge branch 'master' into lars/wip
larskuhtz Jun 12, 2023
3502eb0
remove pact_tojson
Jun 19, 2023
29bda02
wip remove strictness anns
Jun 20, 2023
9ddffb3
compiling
Jun 22, 2023
5e17590
remove most strictness changes
Jul 6, 2023
a66ecfd
more strictness removals
Jul 6, 2023
6a40805
space
Jul 13, 2023
fe6a41b
PR comments
jmcardon Jul 17, 2023
ab7f639
last batch of changes
jmcardon Jul 18, 2023
6601360
remove outdated comment
jmcardon Jul 18, 2023
af4999f
remove enable_tojson
jmcardon Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/workflows/applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ['8.10.7']
cabal: ['3.8']
ghc: ['8.10.7', '9.2', '9.4.5', '9.6']
emilypi marked this conversation as resolved.
Show resolved Hide resolved
cabal: ['3.10']
os: ['ubuntu-20.04', 'ubuntu-22.04', 'macOS-latest']
cabalcache: ['true']
flags: ['+build-tool']
include:
- os: 'ubuntu-22.04'
ghc: '8.10.7'
cabal: '3.8'
ghc: '9.6'
cabal: '3.10'
cabalcache: 'true'
flags: '-build-tool'
- os: 'ubuntu-22.04'
ghc: '9.0.2'
cabal: '3.8'
cabal: '3.10'
cabalcache: 'true'
flags: '+build-tool'

Expand Down Expand Up @@ -98,14 +98,13 @@ jobs:
benchmarks: True
documentation: False
optimization: 1
flags: ${{ matrix.flags }}
flags: ${{ matrix.flags }} +cryptonite-ed25519
EOF
- name: Extend cabal.project.local for GHC-9.0.2
if: "startsWith(matrix.ghc, '9')"
shell: bash
run: |
cat >> cabal.project.local <<EOF
allow-newer: hashable:*
package pact
ghc-options: -Wwarn -Wunused-packages
EOF
Expand Down Expand Up @@ -207,7 +206,7 @@ jobs:
fail-fast: false
matrix:
include:
- ghc: "8.10.7"
- ghc: "9.6"
os: "ubuntu-20.04"
env:
OS: ${{ matrix.os }}
Expand Down
128 changes: 128 additions & 0 deletions bench/PactJson.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}

{-# OPTIONS_GHC -Wno-orphans #-}

-- |
-- Module: PactJson
-- Copyright: Copyright © 2023 Kadena LLC.
-- License: MIT
-- Maintainer: Lars Kuhtz <lars@kadena.io>
-- Stability: experimental
--
-- benchmarks for pact-json
--
module Main
( main
) where

import Bound

import Criterion
import Criterion.Main

import qualified Data.Aeson as A
import qualified Data.ByteString.Lazy as BL

import qualified Pact.JSON.Encode as J

import System.IO.Unsafe

import Test.QuickCheck

-- internal modules
import Pact.Types.Command
import Pact.Types.Names
import Pact.Types.RowData
import Pact.Types.SPV
import Pact.Types.Term
import Pact.Types.Term.Arbitrary ()


-- -------------------------------------------------------------------------- --
-- Main

main :: IO ()
main = defaultMain [benchmarks]

-- -------------------------------------------------------------------------- --
-- Benchmarks

benchmarks :: Benchmark
benchmarks = bgroup "JsonEncoding"
[ bgroup "pact"
[ group "module" pactModule
, group "RowData" rowData
, group "CommandResult" commandResult
, group "ContProof" contProof
]
]

group
:: J.Encode a
=> String
-> a
-> Benchmark
group l a = bgroup l
[ bench_encode a
]

-- -------------------------------------------------------------------------- --
-- Benchmark Functions

bench_encode :: J.Encode a => a -> Benchmark
bench_encode a = bench "bench_encode" $ nf run_encode a

run_encode :: J.Encode a => a -> BL.ByteString
run_encode = J.encode
{-# NOINLINE run_encode #-}

-- -------------------------------------------------------------------------- --
-- Orphans

deriving newtype instance A.ToJSON a => A.ToJSON (J.Aeson a)
deriving newtype instance A.FromJSON a => A.FromJSON (J.Aeson a)
deriving newtype instance Show a => Show (J.Aeson a)
deriving newtype instance Eq a => Eq (J.Aeson a)
deriving newtype instance Arbitrary a => Arbitrary (J.Aeson a)
deriving instance Functor J.Aeson
deriving instance Foldable J.Aeson
deriving instance Traversable J.Aeson

instance J.Encode [J.Aeson ()] where
build a = J.build $ J.Array a

instance J.Encode [Var Int [J.Aeson ()]] where
build a = J.build $ J.Array a

-- -------------------------------------------------------------------------- --
-- Benchmark Data
--

type A = J.Aeson

pactModule :: Module Name
pactModule = unsafeDupablePerformIO $ generate $ arbitrary
{-# NOINLINE pactModule #-}

rowData :: RowData
rowData = unsafeDupablePerformIO $ generate $ arbitrary
{-# NOINLINE rowData #-}

commandResult :: CommandResult (A ())
commandResult = unsafeDupablePerformIO $ generate $ arbitrary
{-# NOINLINE commandResult #-}

contProof :: ContProof
contProof = unsafeDupablePerformIO $ generate $ arbitrary
{-# NOINLINE contProof #-}

46 changes: 40 additions & 6 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,18 +1,52 @@
packages: .

allow-older: libBF:hashable

-- temporary upper bounds
constraints: sbv <10

-- these upper bounds are required in order to not break payload validation in chainweb
constraints: aeson <2
constraints: base16-bytestring <1
constraints: base64-bytestring <1.1
constraints: hashable <1.3.1
constraints: prettyprinter <1.6.1
constraints: unordered-containers <0.2.16
constraints: base64-bytestring <1.1

allow-newer: base64-bytestring:*
allow-newer: base16-bytestring:*
allow-newer: prettyprinter:*

-- test upper bounds
constraints: hspec-golden <0.2,

-- The following fork provides trifecta-2.`1.1.1 which is compatible with
-- hashable >=1.4 and prettyprinter <1.7
--
-- trifeta >=2.1.2 requires a prettyprinter >=1.7, which isn't supported by
-- pact (because it would break mainnet replays). trifecta ==2.1.1 does not
-- support hashable >=1.4.
--
source-repository-package
type: git
tag: f991ffb74a1a1ab86f14e751d7c4f4ba549785b3
location: https://github.com/hackage-package-forks/trifecta

source-repository-package
type: git
tag: e43073d0b8d89d9b300980913b842f4be339846d
location: https://github.com/kadena-io/pact-json

-- Required for GHC-9.6

allow-newer: *:template-haskell
allow-newer: *:base

-- Patch merged into master (upcoming verison 10.0). We are currently using 9.2
source-repository-package
type: git
tag: b66e3a04c20f753213fe7e5115a95b3fe34109f9
location: https://github.com/larskuhtz/sbv

-- Servant is notoriously forcing outdated upper bounds onto its users.
-- It is usually safe to just ignore those.
--
allow-newer: servant-server:*
allow-newer: servant-client-core:*
allow-newer: servant-client:*
allow-newer: servant:*
22 changes: 21 additions & 1 deletion executables/ReplGhcjs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@

module Main where

import Control.Monad.State.Strict

import Data.Aeson hiding ((.=),Object)

import GHCJS.Marshal
import GHCJS.Foreign.Callback
import GHCJS.Types

import Prelude hiding (log)

import Pact.Repl (evalString)
import qualified Pact.JSON.Encode as J
import Pact.Repl
import Pact.Repl.Types

foreign import javascript unsafe "evalCmd = $1"
evalCmd :: Callback (JSVal -> JSVal -> IO JSVal) -> IO ()
Expand All @@ -23,3 +30,16 @@ main = do
r <- evalString log' cmd'
toJSVal_aeson r
evalCmd callback

-- -------------------------------------------------------------------------- --
-- Utils

evalString :: Bool -> String -> IO Value
evalString showLog cmd = do
(er,s) <- initReplState StringEval Nothing >>= runStateT (evalRepl' cmd)
return $ J.object $ case (showLog,er) of
(False,Right v) -> [ "success" J..= v]
(True,Right _) -> ["success" J..= trim (_rOut s) ]
(False,Left e) -> ["failure" J..= e ]
(True,Left e) -> ["failure" J..= (_rOut s ++ e) ]

Loading
Loading