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

[DO NOT MERGE] Temporary Multiasset parametrization PR #1803

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
65e056d
non-compiling param changes
polinavino Aug 3, 2020
db46e1d
adding project base
polinavino Aug 4, 2020
5a941f4
txdata compiles
polinavino Aug 5, 2020
0c5df44
working on Tx
polinavino Aug 5, 2020
6104969
working on EpochBoundary
polinavino Aug 5, 2020
aa444a3
change EpochBoundary
polinavino Aug 5, 2020
e07698d
Validation compiles with warnings
polinavino Aug 6, 2020
c687b0b
fix warnings
polinavino Aug 6, 2020
75ee5b4
1. replaced the map Value with a product type Value Coin (Map ...) 2.…
polinavino Aug 10, 2020
120b991
value fix
polinavino Aug 11, 2020
52c14af
builds
polinavino Aug 11, 2020
5961887
fix split for integer
polinavino Aug 11, 2020
45bbf64
fix split for integer
polinavino Aug 11, 2020
441d387
vsplit is ok, working on Examples
polinavino Aug 13, 2020
1e20685
Added libsodium to the nix/stack-shell.nix
TimSheard Aug 13, 2020
c2529c7
Merge branch 'polina-nonbreaking-ma' of github.com:input-output-hk/ca…
TimSheard Aug 13, 2020
b4af251
CHanges to help the test Exampe.hs to type check, needed to also fix …
TimSheard Aug 13, 2020
ea037d2
Got the parameterized types fixed in some test files.
TimSheard Aug 14, 2020
6845081
Fixed many more test files to be parameterized by Value.
TimSheard Aug 15, 2020
55542d8
tests build but fail
polinavino Aug 17, 2020
cf953ff
change Value to Coin in benchm tests
polinavino Aug 18, 2020
349de6f
parameters changed, Value seriazlied as coin
polinavino Aug 19, 2020
e93533c
no outputs at all
polinavino Aug 19, 2020
1f64be6
Constants from master
polinavino Aug 19, 2020
e6080b1
property tests pass
polinavino Aug 24, 2020
46df1b6
benchmarking compiles
polinavino Aug 24, 2020
642e0f9
Ran ormolize
TimSheard Aug 25, 2020
4977b95
Revoved redundant import f Data.Map.Strict.
TimSheard Aug 25, 2020
038ce44
just for rerunning tests
polinavino Aug 25, 2020
a63683e
fix min deposit calc
polinavino Aug 26, 2020
c814a18
fix deposit calc in Value
polinavino Aug 31, 2020
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
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
index-state: 2020-07-15T00:00:00Z

packages:
byron/chain/executable-spec
byron/ledger/executable-spec
Expand Down
2 changes: 1 addition & 1 deletion nix/stack-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ haskell.lib.buildStackProject {
buildInputs =
# Development libraries which may be necessary for the build.
# Add remove libraries as necessary
[ zlib gmp ncurses lzma openssl git systemd.dev ] ++
[ libsodium zlib gmp ncurses lzma openssl git systemd.dev ] ++
# MacOS-specific librararies which may be necessary for the build.
(lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Cocoa CoreServices libcxx libiconv ]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ library
Shelley.Spec.Ledger.Scripts
Shelley.Spec.Ledger.Serialization
Shelley.Spec.Ledger.Slot

Shelley.Spec.Ledger.Value

Shelley.Spec.Ledger.STS.Bbody
Shelley.Spec.Ledger.STS.Chain
Shelley.Spec.Ledger.STS.Deleg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ import Control.Monad.Except
import Control.Monad.Trans.Reader (runReader)
import Control.State.Transition.Extended (PredicateFailure, TRC (..), applySTS)
import Data.Sequence (Seq)
import Data.Typeable (Typeable)
import Shelley.Spec.Ledger.API.Validation
import Shelley.Spec.Ledger.BaseTypes (Globals)
import Shelley.Spec.Ledger.Crypto
import Shelley.Spec.Ledger.Keys
import qualified Shelley.Spec.Ledger.LedgerState as LedgerState
import Shelley.Spec.Ledger.STS.Ledgers (LEDGERS)
import qualified Shelley.Spec.Ledger.STS.Ledgers as Ledgers
import Shelley.Spec.Ledger.Slot (SlotNo)
import Shelley.Spec.Ledger.Tx (Tx)
import qualified Shelley.Spec.Ledger.Tx as Tx
import Shelley.Spec.Ledger.Value

type MempoolEnv = Ledgers.LedgersEnv

Expand All @@ -53,7 +52,7 @@ type MempoolState = LedgerState.LedgerState
-- included until a certain number of slots before the end of the epoch. A
-- protocol update proposal submitted after this is considered invalid.
mkMempoolEnv ::
ShelleyState crypto ->
ShelleyState crypto v ->
SlotNo ->
MempoolEnv
mkMempoolEnv
Expand All @@ -72,40 +71,40 @@ mkMempoolEnv
-- The given mempool state may then be evolved using 'applyTxs', but should be
-- regenerated when the ledger state gets updated (e.g. through application of
-- a new block).
mkMempoolState :: ShelleyState crypto -> MempoolState crypto
mkMempoolState :: ShelleyState crypto v -> MempoolState crypto v
mkMempoolState LedgerState.NewEpochState {LedgerState.nesEs} =
LedgerState.esLState nesEs

data ApplyTxError crypto = ApplyTxError [PredicateFailure (LEDGERS crypto)]
data ApplyTxError crypto v = ApplyTxError [PredicateFailure (LEDGERS crypto v)]
deriving (Eq, Show)

instance
(Typeable crypto, Crypto crypto) =>
ToCBOR (ApplyTxError crypto)
(CV crypto v) =>
ToCBOR (ApplyTxError crypto v)
where
toCBOR (ApplyTxError es) = toCBOR es

instance
(Crypto crypto) =>
FromCBOR (ApplyTxError crypto)
(CV crypto v) =>
FromCBOR (ApplyTxError crypto v)
where
fromCBOR = ApplyTxError <$> fromCBOR

applyTxs ::
forall crypto m.
( Crypto crypto,
MonadError (ApplyTxError crypto) m,
DSignable crypto (Hash crypto (Tx.TxBody crypto))
forall crypto m v.
( CV crypto v,
MonadError (ApplyTxError crypto v) m,
DSignable crypto (Hash crypto (Tx.TxBody crypto v))
) =>
Globals ->
MempoolEnv ->
Seq (Tx crypto) ->
MempoolState crypto ->
m (MempoolState crypto)
Seq (Tx crypto v) ->
MempoolState crypto v ->
m (MempoolState crypto v)
applyTxs globals env txs state =
let res =
flip runReader globals
. applySTS @(LEDGERS crypto)
. applySTS @(LEDGERS crypto v)
$ TRC (env, state, txs)
in liftEither
. left (ApplyTxError . join)
Expand All @@ -115,9 +114,9 @@ applyTxs globals env txs state =
-- state.
overShelleyState ::
Applicative f =>
(MempoolState c -> f (MempoolState c)) ->
ShelleyState c ->
f (ShelleyState c)
(MempoolState c v -> f (MempoolState c v)) ->
ShelleyState c v ->
f (ShelleyState c v)
overShelleyState f st = do
res <- f $ mkMempoolState st
pure $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import Shelley.Spec.Ledger.STS.Tick (TICK, TickEnv (..))
import qualified Shelley.Spec.Ledger.STS.Tickn as STS.Tickn
import Shelley.Spec.Ledger.Serialization (decodeRecordNamed)
import Shelley.Spec.Ledger.Slot (SlotNo)
import Shelley.Spec.Ledger.Value

-- | Data required by the Transitional Praos protocol from the Shelley ledger.
data LedgerView crypto = LedgerView
Expand Down Expand Up @@ -119,7 +120,7 @@ mkPrtclEnv
lvPoolDistr
lvGenDelegs

view :: ShelleyState crypto -> LedgerView crypto
view :: ShelleyState crypto v -> LedgerView crypto
view
NewEpochState
{ nesPd,
Expand All @@ -138,7 +139,7 @@ view
}

-- | Alias of 'view' for export
currentLedgerView :: ShelleyState crypto -> LedgerView crypto
currentLedgerView :: ShelleyState crypto v -> LedgerView crypto
currentLedgerView = view

-- $timetravel
Expand Down Expand Up @@ -169,8 +170,8 @@ currentLedgerView = view
-- A future ledger view (within the stability window) is equal to the
-- application of the TICK rule at the target slot to the curernt ledger state.

newtype FutureLedgerViewError crypto
= FutureLedgerViewError [PredicateFailure (TICK crypto)]
newtype FutureLedgerViewError crypto v
= FutureLedgerViewError [PredicateFailure (TICK crypto v)]
deriving (Eq, Show)

-- | Anachronistic ledger view
Expand All @@ -179,12 +180,12 @@ newtype FutureLedgerViewError crypto
-- slot corresponding to the passed-in 'ShelleyState'), return a 'LedgerView'
-- appropriate to that slot.
futureLedgerView ::
forall crypto m.
( Crypto crypto,
MonadError (FutureLedgerViewError crypto) m
forall crypto m v.
( CV crypto v,
MonadError (FutureLedgerViewError crypto v) m
) =>
Globals ->
ShelleyState crypto ->
ShelleyState crypto v ->
SlotNo ->
m (LedgerView crypto)
futureLedgerView globals ss slot =
Expand All @@ -195,7 +196,7 @@ futureLedgerView globals ss slot =
where
res =
flip runReader globals
. applySTS @(TICK crypto)
. applySTS @(TICK crypto v)
$ TRC (tickEnv, ss, slot)
tickEnv =
TickEnv
Expand Down Expand Up @@ -242,15 +243,15 @@ instance Crypto crypto => ToCBOR (ChainDepState crypto) where
toCBOR csLabNonce
]

newtype ChainTransitionError crypto
= ChainTransitionError [PredicateFailure (STS.Prtcl.PRTCL crypto)]
newtype ChainTransitionError crypto v
= ChainTransitionError [PredicateFailure (STS.Prtcl.PRTCL crypto v)]
deriving (Generic)

instance (Crypto crypto) => NoUnexpectedThunks (ChainTransitionError crypto)
instance (Crypto crypto) => NoUnexpectedThunks (ChainTransitionError crypto v)

deriving instance (Crypto crypto) => Eq (ChainTransitionError crypto)
deriving instance (Crypto crypto) => Eq (ChainTransitionError crypto v)

deriving instance (Crypto crypto) => Show (ChainTransitionError crypto)
deriving instance (Crypto crypto) => Show (ChainTransitionError crypto v)

-- | Tick the chain state to a new epoch.
tickChainDepState ::
Expand Down Expand Up @@ -284,22 +285,22 @@ tickChainDepState
--
-- This also updates the last applied block hash.
updateChainDepState ::
forall crypto m.
( Crypto crypto,
MonadError (ChainTransitionError crypto) m,
forall crypto m v.
( CV crypto v,
MonadError (ChainTransitionError crypto v) m,
Cardano.Crypto.DSIGN.Class.Signable
(DSIGN crypto)
(Shelley.Spec.Ledger.OCert.OCertSignable crypto),
Cardano.Crypto.KES.Class.Signable
(KES crypto)
(Shelley.Spec.Ledger.BlockChain.BHBody crypto),
(Shelley.Spec.Ledger.BlockChain.BHBody crypto v),
Cardano.Crypto.VRF.Class.Signable
(VRF crypto)
Shelley.Spec.Ledger.BaseTypes.Seed
) =>
Globals ->
LedgerView crypto ->
BHeader crypto ->
BHeader crypto v ->
ChainDepState crypto ->
m (ChainDepState crypto)
updateChainDepState
Expand All @@ -320,7 +321,7 @@ updateChainDepState
where
res =
flip runReader globals
. applySTS @(STS.Prtcl.PRTCL crypto)
. applySTS @(STS.Prtcl.PRTCL crypto v)
$ TRC
( mkPrtclEnv lv epochNonce,
csProtocol,
Expand Down
Loading