Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CDEC-505] Move Pos.Core.Ssc to Pos.Chain.Ssc #3601

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion chain/bench/block-bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import Pos.Chain.Block (Body, BodyProof, ConsensusData, ExtraBodyData,
_gbhBodyProof, _gbhConsensus, _gbhExtra, _mbDlgPayload,
_mbSscPayload, _mbTxPayload, _mbUpdatePayload)
import Pos.Chain.Delegation (DlgPayload)
import Pos.Chain.Ssc (SscPayload)
import Pos.Chain.Txp (TxPayload (..))
import Pos.Core.Ssc (SscPayload)
import Pos.Core.Update (UpdatePayload)
import Pos.Crypto (ProtocolMagic (..))

Expand Down
30 changes: 23 additions & 7 deletions chain/cardano-sl-chain.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,35 @@ library
Pos.Chain.Security.Util

Pos.Chain.Ssc.Base
Pos.Chain.Ssc.Behavior
Pos.Chain.Ssc.Commitment
Pos.Chain.Ssc.CommitmentAndOpening
Pos.Chain.Ssc.CommitmentsMap
Pos.Chain.Ssc.Configuration
Pos.Chain.Ssc.Error
Pos.Chain.Ssc.Error.Seed
Pos.Chain.Ssc.Error.Verify
Pos.Chain.Ssc.Types
Pos.Chain.Ssc.Message
Pos.Chain.Ssc.Mem
Pos.Chain.Ssc.Functions
Pos.Chain.Ssc.VssCertData
Pos.Chain.Ssc.Mem
Pos.Chain.Ssc.Message
Pos.Chain.Ssc.Opening
Pos.Chain.Ssc.OpeningsMap
Pos.Chain.Ssc.Payload
Pos.Chain.Ssc.Proof
Pos.Chain.Ssc.Seed
Pos.Chain.Ssc.Configuration
Pos.Chain.Ssc.Behavior
Pos.Chain.Ssc.Shares
Pos.Chain.Ssc.SharesDistribution
Pos.Chain.Ssc.SharesMap
Pos.Chain.Ssc.Toss
Pos.Chain.Ssc.Toss.Logic
Pos.Chain.Ssc.Toss.Pure
Pos.Chain.Ssc.Toss.Base
Pos.Chain.Ssc.Toss.Class
Pos.Chain.Ssc.Toss.Types
Pos.Chain.Ssc.Types
Pos.Chain.Ssc.VssCertData
Pos.Chain.Ssc.VssCertificate
Pos.Chain.Ssc.VssCertificatesMap

Pos.Chain.Update.BlockVersion
Pos.Chain.Update.Configuration
Expand Down Expand Up @@ -158,6 +169,7 @@ library
, ekg-core
, ether
, exceptions
, extra
, filepath
, fmt >= 0.4
, formatting
Expand Down Expand Up @@ -237,9 +249,12 @@ test-suite test
Test.Pos.Chain.Genesis.Gen
Test.Pos.Chain.Genesis.Json
Test.Pos.Chain.Lrc.FtsSpec
Test.Pos.Chain.Ssc.Arbitrary
Test.Pos.Chain.Ssc.Bi
Test.Pos.Chain.Ssc.CborSpec
Test.Pos.Chain.Ssc.Example
Test.Pos.Chain.Ssc.Gen
Test.Pos.Chain.Ssc.Json
Test.Pos.Chain.Ssc.Arbitrary
Test.Pos.Chain.Txp.Arbitrary
Test.Pos.Chain.Txp.Arbitrary.Unsafe
Test.Pos.Chain.Txp.Bi
Expand Down Expand Up @@ -273,6 +288,7 @@ test-suite test
, hspec
, lens
, mtl
, pvss
, QuickCheck
, random
, serokell-util
Expand Down
3 changes: 1 addition & 2 deletions chain/src/Pos/Chain/Block/BHelpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ import Pos.Chain.Block.Union (Block, BlockHeader (..),
mainBlockEBDataProof)
import Pos.Chain.Delegation (LightDlgIndices (..), checkDlgPayload)
import Pos.Chain.Genesis as Genesis (Config (..))
import Pos.Chain.Ssc (verifySscPayload)
import Pos.Chain.Ssc (checkSscPayload, verifySscPayload)
import Pos.Chain.Txp (checkTxPayload)
import Pos.Core.Slotting (SlotId (..))
import Pos.Core.Ssc (checkSscPayload)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ seems good that these are in the same place now.

import Pos.Core.Update (checkSoftwareVersion, checkUpdatePayload)
import Pos.Crypto (ProtocolMagic, ProxySignature (..), SignTag (..),
checkSig, hash, isSelfSignedPsk, proxyVerify)
Expand Down
3 changes: 2 additions & 1 deletion chain/src/Pos/Chain/Block/Main/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import qualified Formatting.Buildable as Buildable
import Pos.Binary.Class (Bi (..), Cons (..), Field (..),
deriveSimpleBi, encodeListLen, enforceSize)
import Pos.Chain.Delegation.Payload (DlgPayload)
import Pos.Chain.Ssc.Payload (SscPayload)
import Pos.Chain.Ssc.Proof (SscProof)
import Pos.Chain.Txp.TxPayload (TxPayload)
import Pos.Chain.Txp.TxProof (TxProof)
import Pos.Core.Attributes (Attributes, areAttributesKnown)
import Pos.Core.Ssc (SscPayload, SscProof)
import Pos.Core.Update (BlockVersion, SoftwareVersion, UpdatePayload,
UpdateProof)
import Pos.Crypto (Hash)
Expand Down
3 changes: 2 additions & 1 deletion chain/src/Pos/Chain/Block/Union/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ import Pos.Chain.Block.Main.Types (BlockBodyAttributes,
import Pos.Chain.Delegation.HeavyDlgIndex (ProxySigHeavy)
import Pos.Chain.Delegation.LightDlgIndices (ProxySigLight)
import Pos.Chain.Delegation.Payload (DlgPayload)
import Pos.Chain.Ssc.Payload (SscPayload)
import Pos.Chain.Ssc.Proof (mkSscProof)
import Pos.Chain.Txp.Tx (Tx)
import Pos.Chain.Txp.TxPayload (TxPayload, txpTxs, txpWitnesses)
import Pos.Chain.Txp.TxProof (mkTxProof)
import Pos.Chain.Txp.TxWitness (TxWitness)
import Pos.Core.Common (ChainDifficulty, HasDifficulty (..))
import Pos.Core.Slotting (EpochOrSlot (..), HasEpochIndex (..),
HasEpochOrSlot (..), SlotId (..), slotIdF)
import Pos.Core.Ssc (SscPayload, mkSscProof)
import Pos.Core.Update (BlockVersion, HasBlockVersion (..),
HasSoftwareVersion (..), SoftwareVersion, UpdatePayload,
mkUpdateProof)
Expand Down
2 changes: 1 addition & 1 deletion chain/src/Pos/Chain/Genesis/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ import Pos.Chain.Genesis.ProtocolConstants
genesisProtocolConstantsToProtocolConstants)
import Pos.Chain.Genesis.Spec (GenesisSpec (..))
import Pos.Chain.Genesis.WStakeholders (GenesisWStakeholders)
import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap)
import Pos.Core.Common (BlockCount, SharedSeed)
import Pos.Core.ProtocolConstants (ProtocolConstants (..),
pcBlkSecurityParam, pcChainQualityThreshold, pcEpochSlots,
pcSlotSecurityParam, vssMaxTTL, vssMinTTL)
import Pos.Core.Slotting (SlotCount, Timestamp)
import Pos.Core.Ssc (VssCertificatesMap)
import Pos.Core.Update (BlockVersionData)
import Pos.Crypto (ProtocolMagic)
import Pos.Crypto.Hashing (Hash, hashRaw, unsafeHash)
Expand Down
2 changes: 1 addition & 1 deletion chain/src/Pos/Chain/Genesis/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Control.Monad.Except (MonadError (..))
import Text.JSON.Canonical (FromJSON (..), ToJSON (..), fromJSField,
mkObject)

import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap)
import Pos.Core.Common (SharedSeed)
import Pos.Core.Slotting (Timestamp)
import Pos.Core.Ssc (VssCertificatesMap)
import Pos.Core.Update (BlockVersionData)

import Pos.Chain.Genesis.AvvmBalances
Expand Down
5 changes: 3 additions & 2 deletions chain/src/Pos/Chain/Genesis/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ import Serokell.Util.Verify (VerificationRes (..), formatAllErrors,

import Pos.Binary.Class (asBinary, serialize')
import Pos.Chain.Delegation (HeavyDlgIndex (..), ProxySKHeavy)
import Pos.Chain.Ssc.VssCertificate (VssCertificate, mkVssCertificate)
import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap,
mkVssCertificatesMap)
import Pos.Core.Common (Address, Coin, IsBootstrapEraAddr (..),
StakeholderId, addressHash, applyCoinPortionDown,
coinToInteger, deriveFirstHDAddress,
makePubKeyAddressBoot, mkCoin, sumCoins,
unsafeIntegerToCoin)
import Pos.Core.ProtocolConstants (ProtocolConstants, vssMaxTTL,
vssMinTTL)
import Pos.Core.Ssc (VssCertificate, VssCertificatesMap,
mkVssCertificate, mkVssCertificatesMap)
import Pos.Crypto (EncryptedSecretKey, ProtocolMagic, RedeemPublicKey,
SecretKey, VssKeyPair, createPsk, deterministic,
emptyPassphrase, encToSecret, keyGen, noPassEncrypt,
Expand Down
11 changes: 11 additions & 0 deletions chain/src/Pos/Chain/Ssc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ module Pos.Chain.Ssc

import Pos.Chain.Ssc.Base as X
import Pos.Chain.Ssc.Behavior as X
import Pos.Chain.Ssc.Commitment as X
import Pos.Chain.Ssc.CommitmentAndOpening as X
import Pos.Chain.Ssc.CommitmentsMap as X
import Pos.Chain.Ssc.Configuration as X
import Pos.Chain.Ssc.Error as X
import Pos.Chain.Ssc.Functions as X
import Pos.Chain.Ssc.Mem as X
import Pos.Chain.Ssc.Message as X
import Pos.Chain.Ssc.Opening as X
import Pos.Chain.Ssc.OpeningsMap as X
import Pos.Chain.Ssc.Payload as X
import Pos.Chain.Ssc.Proof as X
import Pos.Chain.Ssc.Seed as X
import Pos.Chain.Ssc.Shares as X (getOurShares)
import Pos.Chain.Ssc.SharesDistribution as X
import Pos.Chain.Ssc.SharesMap as X
import Pos.Chain.Ssc.Toss as X
import Pos.Chain.Ssc.Types as X
import Pos.Chain.Ssc.VssCertData as X
import Pos.Chain.Ssc.VssCertificate as X
import Pos.Chain.Ssc.VssCertificatesMap as X
13 changes: 8 additions & 5 deletions chain/src/Pos/Chain/Ssc/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ import Serokell.Data.Memory.Units (Byte)
import Serokell.Util (VerificationRes, verifyGeneric)

import Pos.Binary.Class (biSize, fromBinary)
import Pos.Chain.Ssc.Commitment (Commitment (..), SignedCommitment)
import Pos.Chain.Ssc.CommitmentsMap
(CommitmentsMap (getCommitmentsMap),
mkCommitmentsMapUnsafe)
import Pos.Chain.Ssc.Opening (Opening (..))
import Pos.Chain.Ssc.Payload (SscPayload (..))
import Pos.Chain.Ssc.VssCertificate (VssCertificate (vcExpiryEpoch))
import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap (..))
import Pos.Core (BlockCount, EpochIndex (..), LocalSlotIndex,
SharedSeed (..), SlotCount, SlotId (..), StakeholderId,
addressHash, unsafeMkLocalSlotIndex)
import Pos.Core.Limits (stripHashMap)
import Pos.Core.ProtocolConstants (ProtocolConstants (..),
kEpochSlots, kSlotSecurityParam, vssMaxTTL, vssMinTTL)
import Pos.Core.Ssc (Commitment (..),
CommitmentsMap (getCommitmentsMap), Opening (..),
SignedCommitment, SscPayload (..),
VssCertificate (vcExpiryEpoch), VssCertificatesMap (..),
mkCommitmentsMapUnsafe)
import Pos.Crypto (ProtocolMagic, Secret, SecretKey,
SignTag (SignCommitment), Threshold, checkSig,
getDhSecret, secretToDhSecret, sign, toPublic,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE RecordWildCards #-}

module Pos.Core.Ssc.Commitment
module Pos.Chain.Ssc.Commitment
( Commitment (..)
, CommitmentSignature
, SignedCommitment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Pos.Core.Ssc.CommitmentAndOpening
module Pos.Chain.Ssc.CommitmentAndOpening
( randCommitmentAndOpening
) where

Expand All @@ -10,8 +10,8 @@ import qualified Data.List.NonEmpty as NE
import Formatting (build, sformat, (%))

import Pos.Binary.Class (asBinary)
import Pos.Core.Ssc.Commitment (Commitment (..))
import Pos.Core.Ssc.Opening (Opening (..))
import Pos.Chain.Ssc.Commitment (Commitment (..))
import Pos.Chain.Ssc.Opening (Opening (..))
import Pos.Crypto (Threshold, VssPublicKey, genSharedSecret)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module Pos.Core.Ssc.CommitmentsMap
{-# LANGUAGE TypeFamilies #-}

module Pos.Chain.Ssc.CommitmentsMap
( CommitmentsMap (getCommitmentsMap)
, mkCommitmentsMap
, mkCommitmentsMapUnsafe
Expand All @@ -12,8 +14,8 @@ import Data.SafeCopy (base, deriveSafeCopySimple)
import Serokell.Util (allDistinct)

import Pos.Binary.Class (Bi (..), Decoder, Encoding)
import Pos.Chain.Ssc.Commitment (SignedCommitment)
import Pos.Core.Common (StakeholderId, addressHash)
import Pos.Core.Ssc.Commitment (SignedCommitment)
import Pos.Crypto (PublicKey)
import Pos.Util.Util (cborError)

Expand Down
2 changes: 1 addition & 1 deletion chain/src/Pos/Chain/Ssc/Error/Verify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Formatting (bprint, build, ords, stext, (%))
import qualified Formatting.Buildable
import Serokell.Util (listJson)

import Pos.Chain.Ssc.VssCertificate (VssCertificate)
import Pos.Core (EpochIndex, SlotId, StakeholderId)
import Pos.Core.Ssc (VssCertificate)

type NEStIds = NonEmpty StakeholderId

Expand Down
5 changes: 3 additions & 2 deletions chain/src/Pos/Chain/Ssc/Functions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ import Pos.Chain.Genesis as Genesis (Config (..),
configBlkSecurityParam, configVssCerts)
import Pos.Chain.Ssc.Base (checkCertTTL, isCommitmentId, isOpeningId,
isSharesId, verifySignedCommitment, vssThreshold)
import Pos.Chain.Ssc.CommitmentsMap (CommitmentsMap (..))
import Pos.Chain.Ssc.Error (SscVerifyError (..))
import Pos.Chain.Ssc.Payload (SscPayload (..))
import Pos.Chain.Ssc.Toss.Base (verifyEntriesGuardM)
import Pos.Chain.Ssc.Types (SscGlobalState (..))
import qualified Pos.Chain.Ssc.VssCertData as VCD
import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap)
import Pos.Core (EpochIndex (..), SlotId (..), StakeholderId,
pcBlkSecurityParam)
import Pos.Core.Slotting (crucialSlot)
import Pos.Core.Ssc (CommitmentsMap (..), SscPayload (..),
VssCertificatesMap)
import Pos.Util.Some (Some)

----------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions chain/src/Pos/Chain/Ssc/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import Control.Lens (makePrisms)
import Formatting (bprint, build, (%))
import qualified Formatting.Buildable as Buildable

import Pos.Chain.Ssc.Commitment (SignedCommitment)
import Pos.Chain.Ssc.Opening (Opening)
import Pos.Chain.Ssc.SharesMap (InnerSharesMap)
import Pos.Chain.Ssc.Toss.Types (SscTag (..))
import Pos.Chain.Ssc.VssCertificate (VssCertificate, getCertId)
import Pos.Core (StakeholderId, addressHash)
import Pos.Core.Ssc (InnerSharesMap, Opening, SignedCommitment,
VssCertificate, getCertId)

class HasSscTag a where
toSscTag :: a -> SscTag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Pos.Core.Ssc.Opening
module Pos.Chain.Ssc.Opening
( Opening (..)
) where

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Pos.Core.Ssc.OpeningsMap
module Pos.Chain.Ssc.OpeningsMap
( OpeningsMap
) where

import Universum

import Pos.Core.Common (StakeholderId)

import Pos.Core.Ssc.Opening
import Pos.Chain.Ssc.Opening

type OpeningsMap = HashMap StakeholderId Opening
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Pos.Core.Ssc.Payload
module Pos.Chain.Ssc.Payload
( SscPayload (..)
, checkSscPayload
, spVss
Expand All @@ -17,11 +17,11 @@ import Serokell.Util (listJson)
import Pos.Crypto (ProtocolMagic, shortHashF)

import Pos.Binary.Class (Cons (..), Field (..), deriveIndexedBi)
import Pos.Core.Ssc.CommitmentsMap
import Pos.Core.Ssc.OpeningsMap
import Pos.Core.Ssc.SharesMap
import Pos.Core.Ssc.VssCertificate (VssCertificate (vcExpiryEpoch))
import Pos.Core.Ssc.VssCertificatesMap
import Pos.Chain.Ssc.CommitmentsMap
import Pos.Chain.Ssc.OpeningsMap
import Pos.Chain.Ssc.SharesMap
import Pos.Chain.Ssc.VssCertificate (VssCertificate (vcExpiryEpoch))
import Pos.Chain.Ssc.VssCertificatesMap
import Pos.Util.Util (cborError)

-- | Payload included into blocks.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Pos.Core.Ssc.Proof
module Pos.Chain.Ssc.Proof
( SscProof (..)
, mkSscProof
, VssCertificatesHash
Expand All @@ -10,17 +10,16 @@ import Data.SafeCopy (base, deriveSafeCopySimple)
import Fmt (genericF)
import qualified Formatting.Buildable as Buildable

import Pos.Binary.Class (Bi, Cons (..), Field (..), deriveIndexedBi)
import Pos.Binary.Class (Cons (..), Field (..), deriveIndexedBi)
import Pos.Core.Common (StakeholderId)
import Pos.Crypto (Hash, hash)

import Pos.Core.Ssc.CommitmentsMap
import Pos.Core.Ssc.Opening
import Pos.Core.Ssc.OpeningsMap
import Pos.Core.Ssc.Payload
import Pos.Core.Ssc.SharesMap
import Pos.Core.Ssc.VssCertificate
import Pos.Core.Ssc.VssCertificatesMap
import Pos.Chain.Ssc.CommitmentsMap
import Pos.Chain.Ssc.OpeningsMap
import Pos.Chain.Ssc.Payload
import Pos.Chain.Ssc.SharesMap
import Pos.Chain.Ssc.VssCertificate
import Pos.Chain.Ssc.VssCertificatesMap
import Pos.Util.Util (cborError)

-- Note: we can't use 'VssCertificatesMap', because we serialize it as
Expand Down Expand Up @@ -53,10 +52,7 @@ instance Buildable SscProof where
instance NFData SscProof

-- | Create proof (for inclusion into block header) from 'SscPayload'.
mkSscProof
:: ( Bi Opening
, Bi VssCertificate
) => SscPayload -> SscProof
mkSscProof :: SscPayload -> SscProof
mkSscProof payload =
case payload of
CommitmentsPayload comms certs ->
Expand Down
Loading