diff --git a/auxx/cardano-sl-auxx.cabal b/auxx/cardano-sl-auxx.cabal index 2c63c21428c..73c3cd2a399 100644 --- a/auxx/cardano-sl-auxx.cabal +++ b/auxx/cardano-sl-auxx.cabal @@ -49,6 +49,7 @@ library , canonical-json , cardano-sl , cardano-sl-chain + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -187,6 +188,7 @@ test-suite cardano-auxx-test build-depends: QuickCheck , cardano-sl-auxx + , cardano-sl-chain , cardano-sl-core , cardano-sl-crypto , hspec diff --git a/auxx/src/Command/Proc.hs b/auxx/src/Command/Proc.hs index 0c6220d7ff4..bcd3f2c45b6 100644 --- a/auxx/src/Command/Proc.hs +++ b/auxx/src/Command/Proc.hs @@ -20,14 +20,14 @@ import Pos.Chain.Genesis as Genesis (Config (..), configEpochSlots, configGeneratedSecretsThrow) import Pos.Chain.Genesis (gsSecretKeys) import Pos.Chain.Txp (TxOut (..), TxpConfiguration) -import Pos.Chain.Update (BlockVersionModifier (..)) +import Pos.Chain.Update (BlockVersionModifier (..), + SoftwareVersion (..)) import Pos.Client.KeyStorage (addSecretKey, getSecretKeysPlain) import Pos.Client.Txp.Balances (getBalance) import Pos.Core (AddrStakeDistribution (..), StakeholderId, addressHash, mkMultiKeyDistr, unsafeGetCoin) import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..), makeAddress) -import Pos.Core.Update (SoftwareVersion (..)) import Pos.Crypto (PublicKey, emptyPassphrase, encToPublic, fullPublicKeyF, hashHexF, noPassEncrypt, safeCreatePsk, unsafeCheatingHashCoerce, withSafeSigner) diff --git a/auxx/src/Command/Tx.hs b/auxx/src/Command/Tx.hs index 6276aa15f93..e4deafbdd3b 100644 --- a/auxx/src/Command/Tx.hs +++ b/auxx/src/Command/Tx.hs @@ -37,6 +37,7 @@ import Pos.Chain.Genesis as Genesis (Config (..), configBlockVersionData, configEpochSlots) import Pos.Chain.Txp (TxAux (..), TxIn (TxInUtxo), TxOut (..), TxOutAux (..), topsortTxAuxes, txaF) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Client.KeyStorage (getSecretKeysPlain) import Pos.Client.Txp.Balances (getOwnUtxoForPk) import Pos.Client.Txp.Network (prepareMTx, submitTxRaw) @@ -45,7 +46,6 @@ import Pos.Core (IsBootstrapEraAddr (..), Timestamp (..), deriveFirstHDAddress, makePubKeyAddress, mkCoin) import Pos.Core.Conc (concurrently, currentTime, delay, forConcurrently, modifySharedAtomic, newSharedAtomic) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (EncryptedSecretKey, SecretKey, emptyPassphrase, encToPublic, fakeSigner, hash, safeToPublic, toPublic, withSafeSigners) diff --git a/auxx/src/Command/TyProjection.hs b/auxx/src/Command/TyProjection.hs index feae5cd5dbf..ee2a7509558 100644 --- a/auxx/src/Command/TyProjection.hs +++ b/auxx/src/Command/TyProjection.hs @@ -37,12 +37,12 @@ import Data.Time.Units (Microsecond, TimeUnit, convertUnit, import Serokell.Data.Memory.Units (Byte, fromBytes) import Pos.Chain.Txp (TxOut (..)) -import Pos.Chain.Update (ApplicationName (..), - BlockVersionModifier (..), SystemTag (..)) +import Pos.Chain.Update (ApplicationName (..), BlockVersion, + BlockVersionModifier (..), SoftwareVersion, + SystemTag (..)) import Pos.Core (AddrStakeDistribution (..), Address, Coin, CoinPortion, EpochIndex, ScriptVersion, StakeholderId, mkCoin, unsafeCoinPortionFromDouble, unsafeGetCoin) -import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Crypto (AHash (..), Hash, PublicKey) import Lang.Argument (TyProjection (..), TypeName (..)) diff --git a/auxx/src/Lang/Lexer.hs b/auxx/src/Lang/Lexer.hs index 47129174a84..55445044dfa 100644 --- a/auxx/src/Lang/Lexer.hs +++ b/auxx/src/Lang/Lexer.hs @@ -53,14 +53,15 @@ import Text.Megaparsec.Char (anyChar, char, satisfy, spaceChar, import Text.Megaparsec.Char.Lexer (decimal, scientific, signed) import Lang.Name (Letter, Name (..), unsafeMkLetter) -import Pos.Core (Address, StakeholderId, decodeTextAddress) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), SoftwareVersion (..)) +import Pos.Core (Address, StakeholderId, decodeTextAddress) import Pos.Crypto (AHash (..), PublicKey, decodeAbstractHash, fullPublicKeyF, hashHexF, parseFullPublicKey, unsafeCheatingHashCoerce) import Pos.Util.Util (toParsecError) +import Test.Pos.Chain.Update.Arbitrary () import Test.Pos.Core.Arbitrary () data BracketSide = BracketSideOpening | BracketSideClosing diff --git a/auxx/src/Lang/Syntax.hs b/auxx/src/Lang/Syntax.hs index aae65af1de2..1bfd94a47b3 100644 --- a/auxx/src/Lang/Syntax.hs +++ b/auxx/src/Lang/Syntax.hs @@ -14,8 +14,8 @@ import Universum import Data.Scientific (Scientific) import Lang.Name (Name) +import Pos.Chain.Update (BlockVersion, SoftwareVersion) import Pos.Core (Address, StakeholderId) -import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Crypto (AHash, PublicKey) data Expr cmd diff --git a/auxx/src/Lang/Value.hs b/auxx/src/Lang/Value.hs index 825c43cd651..e91de222964 100644 --- a/auxx/src/Lang/Value.hs +++ b/auxx/src/Lang/Value.hs @@ -37,11 +37,10 @@ import Control.Lens (makePrisms) import Data.Scientific (Scientific) import Pos.Chain.Txp (TxOut) -import Pos.Chain.Update (BlockVersionData, BlockVersionModifier, - SystemTag) +import Pos.Chain.Update (BlockVersion, BlockVersionData, + BlockVersionModifier, SoftwareVersion, SystemTag) import Pos.Core (AddrStakeDistribution, Address, CoinPortion, StakeholderId) -import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Crypto (AHash, PublicKey) data AddrDistrPart = AddrDistrPart diff --git a/auxx/test/Test/Auxx/Lang/LexerSpec.hs b/auxx/test/Test/Auxx/Lang/LexerSpec.hs index 1ab6be5ddc8..19e5ebe06e1 100644 --- a/auxx/test/Test/Auxx/Lang/LexerSpec.hs +++ b/auxx/test/Test/Auxx/Lang/LexerSpec.hs @@ -8,9 +8,9 @@ import Test.Hspec (Expectation, Spec, describe, it, shouldBe) import Test.Hspec.QuickCheck (prop) import Test.QuickCheck (Property, property) -import Pos.Core (decodeTextAddress) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), SoftwareVersion (..)) +import Pos.Core (decodeTextAddress) import Pos.Crypto (decodeAbstractHash, parseFullPublicKey, unsafeCheatingHashCoerce) diff --git a/chain/bench/block-bench.hs b/chain/bench/block-bench.hs index f88c93c35ca..ab3817b48af 100644 --- a/chain/bench/block-bench.hs +++ b/chain/bench/block-bench.hs @@ -18,7 +18,7 @@ import Pos.Chain.Block (Body, BodyProof, ConsensusData, ExtraBodyData, import Pos.Chain.Delegation (DlgPayload) import Pos.Chain.Ssc (SscPayload) import Pos.Chain.Txp (TxPayload (..)) -import Pos.Core.Update (UpdatePayload) +import Pos.Chain.Update (UpdatePayload) import Pos.Crypto (ProtocolMagic (..)) import Test.Pos.Chain.Block.Arbitrary.Generate (generateMainBlock) diff --git a/chain/cardano-sl-chain.cabal b/chain/cardano-sl-chain.cabal index f32e8bce273..5b6641d0430 100644 --- a/chain/cardano-sl-chain.cabal +++ b/chain/cardano-sl-chain.cabal @@ -138,15 +138,25 @@ library Pos.Chain.Ssc.VssCertificate Pos.Chain.Ssc.VssCertificatesMap + Pos.Chain.Update.ApplicationName Pos.Chain.Update.BlockVersion + Pos.Chain.Update.BlockVersionData + Pos.Chain.Update.BlockVersionModifier Pos.Chain.Update.Configuration Pos.Chain.Update.Constants + Pos.Chain.Update.Data + Pos.Chain.Update.Params + Pos.Chain.Update.Payload Pos.Chain.Update.Poll Pos.Chain.Update.Poll.Class Pos.Chain.Update.Poll.Modifier Pos.Chain.Update.Poll.Types Pos.Chain.Update.Poll.Failure - Pos.Chain.Update.Params + Pos.Chain.Update.Proof + Pos.Chain.Update.SoftforkRule + Pos.Chain.Update.SoftwareVersion + Pos.Chain.Update.SystemTag + Pos.Chain.Update.Vote build-depends: Cabal , aeson @@ -264,7 +274,11 @@ test-suite test Test.Pos.Chain.Txp.Example Test.Pos.Chain.Txp.Toil.UtxoSpec Test.Pos.Chain.Update.Arbitrary - Test.Pos.Chain.Update.Arbitrary.Core + Test.Pos.Chain.Update.Bi + Test.Pos.Chain.Update.CborSpec + Test.Pos.Chain.Update.Example + Test.Pos.Chain.Update.Gen + Test.Pos.Chain.Update.Json build-depends: base , base16-bytestring @@ -293,6 +307,7 @@ test-suite test , random , serokell-util , formatting + , time-units , universum , unordered-containers , vector @@ -316,7 +331,6 @@ benchmark block-bench Test.Pos.Chain.Ssc.Arbitrary Test.Pos.Chain.Txp.Arbitrary Test.Pos.Chain.Update.Arbitrary - Test.Pos.Chain.Update.Arbitrary.Core ghc-options: -Wall -O2 build-depends: QuickCheck diff --git a/chain/src/Pos/Chain/Block/BHelpers.hs b/chain/src/Pos/Chain/Block/BHelpers.hs index f58b637cd5d..c2597932ddf 100644 --- a/chain/src/Pos/Chain/Block/BHelpers.hs +++ b/chain/src/Pos/Chain/Block/BHelpers.hs @@ -34,8 +34,8 @@ import Pos.Chain.Delegation (LightDlgIndices (..), checkDlgPayload) import Pos.Chain.Genesis as Genesis (Config (..)) import Pos.Chain.Ssc (checkSscPayload, verifySscPayload) import Pos.Chain.Txp (checkTxPayload) +import Pos.Chain.Update (checkSoftwareVersion, checkUpdatePayload) import Pos.Core.Slotting (SlotId (..)) -import Pos.Core.Update (checkSoftwareVersion, checkUpdatePayload) import Pos.Crypto (ProtocolMagic, ProxySignature (..), SignTag (..), checkSig, hash, isSelfSignedPsk, proxyVerify) import Pos.Util.Some (Some (Some)) diff --git a/chain/src/Pos/Chain/Block/Constructors.hs b/chain/src/Pos/Chain/Block/Constructors.hs index eb5c783cadf..59785884f82 100644 --- a/chain/src/Pos/Chain/Block/Constructors.hs +++ b/chain/src/Pos/Chain/Block/Constructors.hs @@ -25,11 +25,11 @@ import Pos.Chain.Block.Union (BlockHeader, BlockSignature (..), headerHash) import Pos.Chain.Delegation (ProxySKBlockInfo) import Pos.Chain.Genesis (GenesisHash (..)) +import Pos.Chain.Update (BlockVersion, SoftwareVersion) import Pos.Core.Attributes (mkAttributes) import Pos.Core.Common (ChainDifficulty, HasDifficulty (..), SlotLeaders) import Pos.Core.Slotting (EpochIndex, SlotId) -import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Crypto (ProtocolMagic, SecretKey, SignTag (..), hash, proxySign, sign, toPublic) diff --git a/chain/src/Pos/Chain/Block/Logic/Integrity.hs b/chain/src/Pos/Chain/Block/Logic/Integrity.hs index 1ea15480d0a..c309fdcd9b5 100644 --- a/chain/src/Pos/Chain/Block/Logic/Integrity.hs +++ b/chain/src/Pos/Chain/Block/Logic/Integrity.hs @@ -35,13 +35,13 @@ import Pos.Chain.Block.Union (Block, BlockHeader (..), getBlockHeader, headerSlotL, mainHeaderLeaderKey, mebAttributes, mehAttributes, prevBlockL) import Pos.Chain.Genesis as Genesis (Config (..)) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (ChainDifficulty, EpochOrSlot, HasDifficulty (..), HasEpochIndex (..), HasEpochOrSlot (..), SlotId (..), SlotLeaders, addressHash, getSlotIndex) import Pos.Core.Attributes (areAttributesKnown) import Pos.Core.Chrono (NewestFirst (..), OldestFirst) import Pos.Core.Slotting (EpochIndex) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (ProtocolMagic (..)) ---------------------------------------------------------------------------- diff --git a/chain/src/Pos/Chain/Block/Main/Instances.hs b/chain/src/Pos/Chain/Block/Main/Instances.hs index 705e9ec256e..092d29ac895 100644 --- a/chain/src/Pos/Chain/Block/Main/Instances.hs +++ b/chain/src/Pos/Chain/Block/Main/Instances.hs @@ -25,9 +25,10 @@ import Pos.Chain.Block.Union.Types (BlockHeader (..), mainHeaderLeaderKey, mainHeaderSlot, mainHeaderSoftwareVersion, mbTxs, mcdDifficulty, mehBlockVersion, mehSoftwareVersion) +import Pos.Chain.Update.BlockVersion (HasBlockVersion (..)) +import Pos.Chain.Update.SoftwareVersion (HasSoftwareVersion (..)) import Pos.Core.Common (HasDifficulty (..)) import Pos.Core.Slotting (HasEpochIndex (..), HasEpochOrSlot (..)) -import Pos.Core.Update (HasBlockVersion (..), HasSoftwareVersion (..)) instance NFData MainBlock diff --git a/chain/src/Pos/Chain/Block/Main/Types.hs b/chain/src/Pos/Chain/Block/Main/Types.hs index 1b97a8d5ef4..be7a0c57f4f 100644 --- a/chain/src/Pos/Chain/Block/Main/Types.hs +++ b/chain/src/Pos/Chain/Block/Main/Types.hs @@ -27,9 +27,11 @@ 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.Chain.Update.BlockVersion (BlockVersion) +import Pos.Chain.Update.Payload (UpdatePayload) +import Pos.Chain.Update.Proof (UpdateProof) +import Pos.Chain.Update.SoftwareVersion (SoftwareVersion) import Pos.Core.Attributes (Attributes, areAttributesKnown) -import Pos.Core.Update (BlockVersion, SoftwareVersion, UpdatePayload, - UpdateProof) import Pos.Crypto (Hash) -- | Proof of everything contained in the payload. diff --git a/chain/src/Pos/Chain/Block/Union/Types.hs b/chain/src/Pos/Chain/Block/Union/Types.hs index 38a43453d80..7a903e736db 100644 --- a/chain/src/Pos/Chain/Block/Union/Types.hs +++ b/chain/src/Pos/Chain/Block/Union/Types.hs @@ -137,12 +137,15 @@ 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.Chain.Update.BlockVersion (BlockVersion, + HasBlockVersion (..)) +import Pos.Chain.Update.Payload (UpdatePayload) +import Pos.Chain.Update.Proof (mkUpdateProof) +import Pos.Chain.Update.SoftwareVersion (HasSoftwareVersion (..), + SoftwareVersion) import Pos.Core.Common (ChainDifficulty, HasDifficulty (..)) import Pos.Core.Slotting (EpochOrSlot (..), HasEpochIndex (..), HasEpochOrSlot (..), SlotId (..), slotIdF) -import Pos.Core.Update (BlockVersion, HasBlockVersion (..), - HasSoftwareVersion (..), SoftwareVersion, UpdatePayload, - mkUpdateProof) import Pos.Crypto (Hash, ProtocolMagic, PublicKey, Signature, hash, hashHexF, unsafeHash) import Pos.Util.Some (Some, applySome, liftLensSome) diff --git a/chain/src/Pos/Chain/Genesis/Config.hs b/chain/src/Pos/Chain/Genesis/Config.hs index 5a5bb8a5ff3..377519cd592 100644 --- a/chain/src/Pos/Chain/Genesis/Config.hs +++ b/chain/src/Pos/Chain/Genesis/Config.hs @@ -64,12 +64,12 @@ import Pos.Chain.Genesis.ProtocolConstants import Pos.Chain.Genesis.Spec (GenesisSpec (..)) import Pos.Chain.Genesis.WStakeholders (GenesisWStakeholders) import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap) +import Pos.Chain.Update (BlockVersionData) 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.Update (BlockVersionData) import Pos.Crypto (ProtocolMagic) import Pos.Crypto.Hashing (Hash, hashRaw, unsafeHash) import Pos.Util.Json.Canonical (SchemaError) diff --git a/chain/src/Pos/Chain/Genesis/Data.hs b/chain/src/Pos/Chain/Genesis/Data.hs index a73b0f11310..169ad11fad7 100644 --- a/chain/src/Pos/Chain/Genesis/Data.hs +++ b/chain/src/Pos/Chain/Genesis/Data.hs @@ -11,9 +11,9 @@ import Text.JSON.Canonical (FromJSON (..), ToJSON (..), fromJSField, mkObject) import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap) +import Pos.Chain.Update (BlockVersionData) import Pos.Core.Common (SharedSeed) import Pos.Core.Slotting (Timestamp) -import Pos.Core.Update (BlockVersionData) import Pos.Chain.Genesis.AvvmBalances import Pos.Chain.Genesis.Delegation diff --git a/chain/src/Pos/Chain/Genesis/Spec.hs b/chain/src/Pos/Chain/Genesis/Spec.hs index 0b489112864..09504efdb4e 100644 --- a/chain/src/Pos/Chain/Genesis/Spec.hs +++ b/chain/src/Pos/Chain/Genesis/Spec.hs @@ -11,8 +11,8 @@ import Data.Aeson.TH (deriveJSON) import qualified Data.HashMap.Strict as HM import Serokell.Util (allDistinct) +import Pos.Chain.Update (BlockVersionData) import Pos.Core.Common (SharedSeed) -import Pos.Core.Update (BlockVersionData) import Pos.Chain.Genesis.AvvmBalances import Pos.Chain.Genesis.Delegation diff --git a/chain/src/Pos/Chain/Ssc/Toss/Base.hs b/chain/src/Pos/Chain/Ssc/Toss/Base.hs index 6876e4a4643..f5500c113ed 100644 --- a/chain/src/Pos/Chain/Ssc/Toss/Base.hs +++ b/chain/src/Pos/Chain/Ssc/Toss/Base.hs @@ -65,9 +65,9 @@ import Pos.Chain.Ssc.Toss.Class (MonadToss (..), MonadTossEnv (..), import Pos.Chain.Ssc.VssCertificate (vcSigningKey, vcVssKey) import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap (..), lookupVss, memberVss) +import Pos.Chain.Update (bvdMpcThd) import Pos.Core (CoinPortion, EpochIndex, StakeholderId, addressHash, coinPortionDenominator, getCoinPortion, unsafeGetCoin) -import Pos.Core.Update (bvdMpcThd) import Pos.Crypto (DecShare, verifyDecShare, verifyEncShares) import Pos.Util.Util (getKeys) import Pos.Util.Wlog (logWarning) diff --git a/chain/src/Pos/Chain/Ssc/Toss/Class.hs b/chain/src/Pos/Chain/Ssc/Toss/Class.hs index 00f8d266235..adcac37e2b2 100644 --- a/chain/src/Pos/Chain/Ssc/Toss/Class.hs +++ b/chain/src/Pos/Chain/Ssc/Toss/Class.hs @@ -22,8 +22,8 @@ import Pos.Chain.Ssc.OpeningsMap (OpeningsMap) import Pos.Chain.Ssc.SharesMap (InnerSharesMap, SharesMap) import Pos.Chain.Ssc.VssCertificate (VssCertificate) import Pos.Chain.Ssc.VssCertificatesMap (VssCertificatesMap) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (EpochIndex, EpochOrSlot, StakeholderId) -import Pos.Core.Update (BlockVersionData) import Pos.Util.Wlog (WithLogger) ---------------------------------------------------------------------------- diff --git a/chain/src/Pos/Chain/Ssc/Toss/Pure.hs b/chain/src/Pos/Chain/Ssc/Toss/Pure.hs index a525c6e268a..50ee8de89d1 100644 --- a/chain/src/Pos/Chain/Ssc/Toss/Pure.hs +++ b/chain/src/Pos/Chain/Ssc/Toss/Pure.hs @@ -26,8 +26,8 @@ import Pos.Chain.Ssc.Toss.Class (MonadToss (..), MonadTossEnv (..), import Pos.Chain.Ssc.Types (SscGlobalState, sgsCommitments, sgsOpenings, sgsShares, sgsVssCertificates) import qualified Pos.Chain.Ssc.VssCertData as VCD +import Pos.Chain.Update (BlockVersionData) import Pos.Core (EpochIndex) -import Pos.Core.Update (BlockVersionData) import Pos.Util.Wlog (CanLog, HasLoggerName (..), LogEvent, NamedPureLogger (..), WithLogger, dispatchEvents, runNamedPureLog) diff --git a/chain/src/Pos/Chain/Txp/Toil/Logic.hs b/chain/src/Pos/Chain/Txp/Toil/Logic.hs index d49e40a49dd..52c245feff6 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Logic.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Logic.hs @@ -37,13 +37,13 @@ import Pos.Chain.Txp.Tx (Tx (..), TxId, TxOut (..), txOutAddress) import Pos.Chain.Txp.TxAux (TxAux (..), checkTxAux) import Pos.Chain.Txp.TxOutAux (toaOut) import Pos.Chain.Txp.Undo (TxUndo, TxpUndo) +import Pos.Chain.Update (BlockVersionData (..), isBootstrapEraBVD) import Pos.Core (AddrAttributes (..), AddrStakeDistribution (..), Address, EpochIndex, addrAttributesUnwrapped, isRedeemAddress) import Pos.Core.Common (integerToCoin) import qualified Pos.Core.Common as Fee (TxFeePolicy (..), calculateTxSizeLinear) -import Pos.Core.Update (BlockVersionData (..), isBootstrapEraBVD) import Pos.Crypto (ProtocolMagic, WithHash (..), hash) import Pos.Util (liftEither) diff --git a/chain/src/Pos/Chain/Update.hs b/chain/src/Pos/Chain/Update.hs index 7512b9d0847..17b3c6793f8 100644 --- a/chain/src/Pos/Chain/Update.hs +++ b/chain/src/Pos/Chain/Update.hs @@ -1,23 +1,25 @@ --- | Update system reexports. (Except for "Pos.Chain.Update.DB".) - module Pos.Chain.Update - ( module Pos.Core.Update - , module Pos.Chain.Update.BlockVersion - , module Pos.Chain.Update.Configuration - , module Pos.Chain.Update.Constants - , module Pos.Chain.Update.Params - , module Pos.Chain.Update.Poll + ( module X , BlockVersionState (..) , PollModifier (..) ) where -import Pos.Chain.Update.BlockVersion -import Pos.Chain.Update.Configuration -import Pos.Chain.Update.Constants -import Pos.Chain.Update.Params -import Pos.Chain.Update.Poll -import Pos.Core.Update +import Pos.Chain.Update.ApplicationName as X +import Pos.Chain.Update.BlockVersion as X +import Pos.Chain.Update.BlockVersionData as X +import Pos.Chain.Update.BlockVersionModifier as X +import Pos.Chain.Update.Configuration as X +import Pos.Chain.Update.Constants as X +import Pos.Chain.Update.Data as X +import Pos.Chain.Update.Params as X +import Pos.Chain.Update.Payload as X +import Pos.Chain.Update.Poll as X +import Pos.Chain.Update.Proof as X +import Pos.Chain.Update.SoftforkRule as X +import Pos.Chain.Update.SoftwareVersion as X +import Pos.Chain.Update.SystemTag as X +import Pos.Chain.Update.Vote as X import Pos.Chain.Update.Poll.Modifier (PollModifier (..)) import Pos.Chain.Update.Poll.Types (BlockVersionState (..)) diff --git a/core/src/Pos/Core/Update/ApplicationName.hs b/chain/src/Pos/Chain/Update/ApplicationName.hs similarity index 97% rename from core/src/Pos/Core/Update/ApplicationName.hs rename to chain/src/Pos/Chain/Update/ApplicationName.hs index 298faf8a30b..1789503c3d6 100644 --- a/core/src/Pos/Core/Update/ApplicationName.hs +++ b/chain/src/Pos/Chain/Update/ApplicationName.hs @@ -1,4 +1,4 @@ -module Pos.Core.Update.ApplicationName +module Pos.Chain.Update.ApplicationName ( ApplicationName (..) , applicationNameMaxLength , checkApplicationName diff --git a/chain/src/Pos/Chain/Update/BlockVersion.hs b/chain/src/Pos/Chain/Update/BlockVersion.hs index e490082af7d..2f97b48cf14 100644 --- a/chain/src/Pos/Chain/Update/BlockVersion.hs +++ b/chain/src/Pos/Chain/Update/BlockVersion.hs @@ -1,33 +1,52 @@ {-# LANGUAGE RecordWildCards #-} --- | Update system-specific functionality related to 'BlockVersion', --- 'BlockVersionData', 'BlockVersionModifier'. - module Pos.Chain.Update.BlockVersion - ( applyBVM + ( BlockVersion (..) + , HasBlockVersion (..) ) where import Universum -import Pos.Core.Update (BlockVersionData (..), - BlockVersionModifier (..)) - --- | Apply 'BlockVersionModifier' to 'BlockVersionData'. -applyBVM :: BlockVersionModifier -> BlockVersionData -> BlockVersionData -applyBVM BlockVersionModifier {..} BlockVersionData {..} = - BlockVersionData - { bvdScriptVersion = fromMaybe bvdScriptVersion bvmScriptVersion - , bvdSlotDuration = fromMaybe bvdSlotDuration bvmSlotDuration - , bvdMaxBlockSize = fromMaybe bvdMaxBlockSize bvmMaxBlockSize - , bvdMaxHeaderSize = fromMaybe bvdMaxHeaderSize bvmMaxHeaderSize - , bvdMaxTxSize = fromMaybe bvdMaxTxSize bvmMaxTxSize - , bvdMaxProposalSize = fromMaybe bvdMaxProposalSize bvmMaxProposalSize - , bvdMpcThd = fromMaybe bvdMpcThd bvmMpcThd - , bvdHeavyDelThd = fromMaybe bvdHeavyDelThd bvmHeavyDelThd - , bvdUpdateVoteThd = fromMaybe bvdUpdateVoteThd bvmUpdateVoteThd - , bvdUpdateProposalThd = fromMaybe bvdUpdateProposalThd bvmUpdateProposalThd - , bvdUpdateImplicit = fromMaybe bvdUpdateImplicit bvmUpdateImplicit - , bvdSoftforkRule = fromMaybe bvdSoftforkRule bvmSoftforkRule - , bvdTxFeePolicy = fromMaybe bvdTxFeePolicy bvmTxFeePolicy - , bvdUnlockStakeEpoch = fromMaybe bvdUnlockStakeEpoch bvmUnlockStakeEpoch - } +import Data.Aeson.TH (defaultOptions, deriveJSON) +import Data.SafeCopy (base, deriveSafeCopySimple) +import Formatting (bprint, shown) +import qualified Formatting.Buildable as Buildable +import qualified Prelude + +import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) +import Pos.Util.Some (Some, liftLensSome) + +-- | Communication protocol version. +data BlockVersion = BlockVersion + { bvMajor :: !Word16 + , bvMinor :: !Word16 + , bvAlt :: !Word8 + } deriving (Eq, Generic, Ord, Typeable) + +instance Show BlockVersion where + show BlockVersion {..} = + intercalate "." [show bvMajor, show bvMinor, show bvAlt] + +instance Buildable BlockVersion where + build = bprint shown + +instance Hashable BlockVersion + +instance NFData BlockVersion + +class HasBlockVersion a where + blockVersionL :: Lens' a BlockVersion + +instance HasBlockVersion (Some HasBlockVersion) where + blockVersionL = liftLensSome blockVersionL + +deriveJSON defaultOptions ''BlockVersion + +deriveSimpleBi ''BlockVersion [ + Cons 'BlockVersion [ + Field [| bvMajor :: Word16 |], + Field [| bvMinor :: Word16 |], + Field [| bvAlt :: Word8 |] + ]] + +deriveSafeCopySimple 0 'base ''BlockVersion diff --git a/core/src/Pos/Core/Update/BlockVersionData.hs b/chain/src/Pos/Chain/Update/BlockVersionData.hs similarity index 93% rename from core/src/Pos/Core/Update/BlockVersionData.hs rename to chain/src/Pos/Chain/Update/BlockVersionData.hs index e1e80f84855..c2baa9bc55c 100644 --- a/core/src/Pos/Core/Update/BlockVersionData.hs +++ b/chain/src/Pos/Chain/Update/BlockVersionData.hs @@ -1,12 +1,13 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.BlockVersionData +module Pos.Chain.Update.BlockVersionData ( BlockVersionData (..) , isBootstrapEraBVD ) where import Universum +import Control.Monad.Except (MonadError) import qualified Data.Aeson.Options as S (defaultOptions) import Data.Aeson.TH (deriveJSON) import Data.SafeCopy (base, deriveSafeCopySimple) @@ -14,15 +15,15 @@ import Data.Time.Units (Millisecond) import Formatting (bprint, build, int, (%)) import qualified Formatting.Buildable as Buildable import Serokell.Data.Memory.Units (Byte, memory) -import Text.JSON.Canonical (FromJSON (..), ReportSchemaErrors, - ToJSON (..), fromJSField, mkObject) +import Text.JSON.Canonical (FromJSON (..), ToJSON (..), fromJSField, + mkObject) import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) +import Pos.Chain.Update.SoftforkRule import Pos.Core.Binary () import Pos.Core.Common (CoinPortion, ScriptVersion, TxFeePolicy) import Pos.Core.Slotting (EpochIndex, FlatSlotId, isBootstrapEra) -import Pos.Core.Update.SoftforkRule -import Pos.Util.Json.Canonical () +import Pos.Util.Json.Canonical (SchemaError) import Pos.Util.Orphans () -- | Data which is associated with 'BlockVersion'. @@ -96,7 +97,7 @@ instance Monad m => ToJSON m BlockVersionData where , ("unlockStakeEpoch", toJSON unlockStakeEpoch) ] -instance ReportSchemaErrors m => FromJSON m BlockVersionData where +instance MonadError SchemaError m => FromJSON m BlockVersionData where fromJSON obj = do bvdScriptVersion <- fromJSField obj "scriptVersion" bvdSlotDuration <- fromJSField obj "slotDuration" diff --git a/core/src/Pos/Core/Update/BlockVersionModifier.hs b/chain/src/Pos/Chain/Update/BlockVersionModifier.hs similarity index 78% rename from core/src/Pos/Core/Update/BlockVersionModifier.hs rename to chain/src/Pos/Chain/Update/BlockVersionModifier.hs index 4d0818c8c7d..4f5019fe83a 100644 --- a/core/src/Pos/Core/Update/BlockVersionModifier.hs +++ b/chain/src/Pos/Chain/Update/BlockVersionModifier.hs @@ -1,8 +1,9 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.BlockVersionModifier +module Pos.Chain.Update.BlockVersionModifier ( BlockVersionModifier (..) , checkBlockVersionModifier + , applyBVM ) where import Universum @@ -23,7 +24,8 @@ import Pos.Core.Common (CoinPortion, ScriptVersion, TxFeePolicy, import Pos.Core.Slotting (EpochIndex, FlatSlotId) import Pos.Util.Orphans () -import Pos.Core.Update.SoftforkRule +import Pos.Chain.Update.BlockVersionData (BlockVersionData (..)) +import Pos.Chain.Update.SoftforkRule -- | Data which represents modifications of block (aka protocol) version. data BlockVersionModifier = BlockVersionModifier @@ -110,6 +112,26 @@ checkBlockVersionModifier BlockVersionModifier {..} = do whenJust bvmUpdateProposalThd checkCoinPortion whenJust bvmSoftforkRule checkSoftforkRule +-- | Apply 'BlockVersionModifier' to 'BlockVersionData'. +applyBVM :: BlockVersionModifier -> BlockVersionData -> BlockVersionData +applyBVM BlockVersionModifier {..} BlockVersionData {..} = + BlockVersionData + { bvdScriptVersion = fromMaybe bvdScriptVersion bvmScriptVersion + , bvdSlotDuration = fromMaybe bvdSlotDuration bvmSlotDuration + , bvdMaxBlockSize = fromMaybe bvdMaxBlockSize bvmMaxBlockSize + , bvdMaxHeaderSize = fromMaybe bvdMaxHeaderSize bvmMaxHeaderSize + , bvdMaxTxSize = fromMaybe bvdMaxTxSize bvmMaxTxSize + , bvdMaxProposalSize = fromMaybe bvdMaxProposalSize bvmMaxProposalSize + , bvdMpcThd = fromMaybe bvdMpcThd bvmMpcThd + , bvdHeavyDelThd = fromMaybe bvdHeavyDelThd bvmHeavyDelThd + , bvdUpdateVoteThd = fromMaybe bvdUpdateVoteThd bvmUpdateVoteThd + , bvdUpdateProposalThd = fromMaybe bvdUpdateProposalThd bvmUpdateProposalThd + , bvdUpdateImplicit = fromMaybe bvdUpdateImplicit bvmUpdateImplicit + , bvdSoftforkRule = fromMaybe bvdSoftforkRule bvmSoftforkRule + , bvdTxFeePolicy = fromMaybe bvdTxFeePolicy bvmTxFeePolicy + , bvdUnlockStakeEpoch = fromMaybe bvdUnlockStakeEpoch bvmUnlockStakeEpoch + } + deriveSimpleBi ''BlockVersionModifier [ Cons 'BlockVersionModifier [ Field [| bvmScriptVersion :: Maybe ScriptVersion |], diff --git a/chain/src/Pos/Chain/Update/Configuration.hs b/chain/src/Pos/Chain/Update/Configuration.hs index 4513c86dcab..1bb52da6bab 100644 --- a/chain/src/Pos/Chain/Update/Configuration.hs +++ b/chain/src/Pos/Chain/Update/Configuration.hs @@ -26,8 +26,10 @@ import Data.Maybe (fromMaybe) import Data.Reflection (Given (..), give) import Distribution.System (buildArch, buildOS) -import Pos.Core.Update (ApplicationName, BlockVersion (..), - SoftwareVersion (..), SystemTag (..), archHelper, +import Pos.Chain.Update.ApplicationName (ApplicationName) +import Pos.Chain.Update.BlockVersion (BlockVersion (..)) +import Pos.Chain.Update.SoftwareVersion (SoftwareVersion (..)) +import Pos.Chain.Update.SystemTag (SystemTag (..), archHelper, osHelper) ---------------------------------------------------------------------------- diff --git a/chain/src/Pos/Chain/Update/Constants.hs b/chain/src/Pos/Chain/Update/Constants.hs index 3281f5b56a2..fabd80374b4 100644 --- a/chain/src/Pos/Chain/Update/Constants.hs +++ b/chain/src/Pos/Chain/Update/Constants.hs @@ -7,8 +7,9 @@ module Pos.Chain.Update.Constants import Universum -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), - SoftwareVersion (..)) +import Pos.Chain.Update.ApplicationName (ApplicationName (..)) +import Pos.Chain.Update.BlockVersion (BlockVersion (..)) +import Pos.Chain.Update.SoftwareVersion (SoftwareVersion (..)) ---------------------------------------------------------------------------- -- Genesis constants diff --git a/core/src/Pos/Core/Update/Data.hs b/chain/src/Pos/Chain/Update/Data.hs similarity index 98% rename from core/src/Pos/Core/Update/Data.hs rename to chain/src/Pos/Chain/Update/Data.hs index aa90e0641c4..47edc970d8e 100644 --- a/core/src/Pos/Core/Update/Data.hs +++ b/chain/src/Pos/Chain/Update/Data.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.Data +module Pos.Chain.Update.Data ( UpdateData (..) ) where diff --git a/core/src/Pos/Core/Update/Payload.hs b/chain/src/Pos/Chain/Update/Payload.hs similarity index 96% rename from core/src/Pos/Core/Update/Payload.hs rename to chain/src/Pos/Chain/Update/Payload.hs index f913915d936..01df3256454 100644 --- a/core/src/Pos/Core/Update/Payload.hs +++ b/chain/src/Pos/Chain/Update/Payload.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.Payload +module Pos.Chain.Update.Payload ( UpdatePayload (..) , checkUpdatePayload ) where @@ -17,7 +17,7 @@ import Serokell.Util.Text (listJson) import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) import Pos.Crypto (ProtocolMagic) -import Pos.Core.Update.Vote +import Pos.Chain.Update.Vote -- | Update System payload. 'BodyProof MainBlockchain' contains -- 'UpdateProof' = @Hash UpdatePayload@. diff --git a/chain/src/Pos/Chain/Update/Poll/Class.hs b/chain/src/Pos/Chain/Update/Poll/Class.hs index 117ce9af9eb..117fbd954bc 100644 --- a/chain/src/Pos/Chain/Update/Poll/Class.hs +++ b/chain/src/Pos/Chain/Update/Poll/Class.hs @@ -30,7 +30,10 @@ import qualified Data.HashSet as HS import qualified Data.List as List (find) import qualified Ether -import Pos.Chain.Update.BlockVersion (applyBVM) +import Pos.Chain.Update.ApplicationName (ApplicationName) +import Pos.Chain.Update.BlockVersion (BlockVersion) +import Pos.Chain.Update.BlockVersionData (BlockVersionData) +import Pos.Chain.Update.BlockVersionModifier (applyBVM) import Pos.Chain.Update.Poll.Modifier (PollModifier (..), pmActivePropsL, pmAdoptedBVFullL, pmBVsL, pmConfirmedL, pmConfirmedPropsL, pmEpochProposersL, pmSlottingDataL) @@ -41,12 +44,12 @@ import Pos.Chain.Update.Poll.Types (BlockVersionState, cpsSoftwareVersion, maybeToPrev, psProposal, unChangedBVL, unChangedConfPropsL, unChangedPropsL, unChangedSVL, unLastAdoptedBVL, unPrevProposersL, unSlottingDataL) +import Pos.Chain.Update.SoftwareVersion (NumSoftwareVersion, + SoftwareVersion (..)) +import Pos.Chain.Update.Vote (UpId, UpdateProposal (..)) import Pos.Core (ChainDifficulty, Coin, EpochIndex, SlotId, StakeholderId, addressHash) import Pos.Core.Slotting (SlottingData) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionData, NumSoftwareVersion, - SoftwareVersion (..), UpId, UpdateProposal (..)) import Pos.Crypto (hash) import qualified Pos.Util.Modifier as MM import Pos.Util.Util (ether) diff --git a/chain/src/Pos/Chain/Update/Poll/Failure.hs b/chain/src/Pos/Chain/Update/Poll/Failure.hs index 9876f8a1266..bb237c839e0 100644 --- a/chain/src/Pos/Chain/Update/Poll/Failure.hs +++ b/chain/src/Pos/Chain/Update/Poll/Failure.hs @@ -12,12 +12,15 @@ import qualified Formatting.Buildable import Serokell.Data.Memory.Units (Byte, memory) import Pos.Chain.Block.Union (HeaderHash) +import Pos.Chain.Update.ApplicationName (ApplicationName) +import Pos.Chain.Update.BlockVersion (BlockVersion) +import Pos.Chain.Update.BlockVersionData (BlockVersionData) +import Pos.Chain.Update.BlockVersionModifier (BlockVersionModifier) +import Pos.Chain.Update.SoftwareVersion (NumSoftwareVersion) +import Pos.Chain.Update.Vote (UpAttributes, UpId) import Pos.Core (Coin, EpochIndex, ScriptVersion, StakeholderId, coinF) import Pos.Core.Reporting (MonadReporting, reportError) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionData, BlockVersionModifier, - NumSoftwareVersion, UpAttributes, UpId) import Pos.Crypto (shortHashF) -- | PollVerFailure represents all possible errors which can diff --git a/chain/src/Pos/Chain/Update/Poll/Modifier.hs b/chain/src/Pos/Chain/Update/Poll/Modifier.hs index 81c454239fd..a62f1e9787d 100644 --- a/chain/src/Pos/Chain/Update/Poll/Modifier.hs +++ b/chain/src/Pos/Chain/Update/Poll/Modifier.hs @@ -22,13 +22,16 @@ import Control.Lens (makeLensesFor) import Data.Default (Default (def)) import Data.Semigroup (Semigroup) +import Pos.Chain.Update.ApplicationName (ApplicationName) +import Pos.Chain.Update.BlockVersion (BlockVersion) +import Pos.Chain.Update.BlockVersionData (BlockVersionData) import Pos.Chain.Update.Poll.Types (BlockVersionState, ConfirmedProposalState, ProposalState) +import Pos.Chain.Update.SoftwareVersion (NumSoftwareVersion, + SoftwareVersion) +import Pos.Chain.Update.Vote (UpId) import Pos.Core.Common (StakeholderId) import Pos.Core.Slotting (SlottingData) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionData, NumSoftwareVersion, SoftwareVersion, - UpId) import Pos.Util.Modifier (MapModifier) -- | PollModifier is used in verification. It represents operation which diff --git a/chain/src/Pos/Chain/Update/Poll/Types.hs b/chain/src/Pos/Chain/Update/Poll/Types.hs index c026fb09b96..d68a7fc0a94 100644 --- a/chain/src/Pos/Chain/Update/Poll/Types.hs +++ b/chain/src/Pos/Chain/Update/Poll/Types.hs @@ -59,12 +59,16 @@ import Pos.Binary.Class (Bi (..), Cons (..), Field (..), decodeListLenCanonical, deriveIndexedBi, deriveSimpleBi, encodeListLen) import Pos.Chain.Block.Union (HeaderHash) +import Pos.Chain.Update.ApplicationName (ApplicationName) +import Pos.Chain.Update.BlockVersion (BlockVersion) +import Pos.Chain.Update.BlockVersionModifier + (BlockVersionModifier (..)) +import Pos.Chain.Update.SoftwareVersion (NumSoftwareVersion, + SoftwareVersion) +import Pos.Chain.Update.Vote (UpId, UpdateProposal (..), UpdateVote) import Pos.Core (ChainDifficulty, Coin, ScriptVersion, StakeholderId, mkCoin) import Pos.Core.Slotting (EpochIndex, SlotId, SlottingData) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionModifier (..), NumSoftwareVersion, - SoftwareVersion, UpId, UpdateProposal (..), UpdateVote) import Pos.Crypto (PublicKey) import Pos.Util.Util (cborError) diff --git a/core/src/Pos/Core/Update/Proof.hs b/chain/src/Pos/Chain/Update/Proof.hs similarity index 79% rename from core/src/Pos/Core/Update/Proof.hs rename to chain/src/Pos/Chain/Update/Proof.hs index bb9a786fa13..afe357b614a 100644 --- a/core/src/Pos/Core/Update/Proof.hs +++ b/chain/src/Pos/Chain/Update/Proof.hs @@ -1,11 +1,11 @@ -module Pos.Core.Update.Proof +module Pos.Chain.Update.Proof ( UpdateProof , mkUpdateProof ) where import Pos.Crypto (Hash, hash) -import Pos.Core.Update.Payload +import Pos.Chain.Update.Payload -- | Proof that body of update message contains 'UpdatePayload'. type UpdateProof = Hash UpdatePayload diff --git a/core/src/Pos/Core/Update/SoftforkRule.hs b/chain/src/Pos/Chain/Update/SoftforkRule.hs similarity index 91% rename from core/src/Pos/Core/Update/SoftforkRule.hs rename to chain/src/Pos/Chain/Update/SoftforkRule.hs index 879c448763b..0fca1808d2f 100644 --- a/core/src/Pos/Core/Update/SoftforkRule.hs +++ b/chain/src/Pos/Chain/Update/SoftforkRule.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.SoftforkRule +module Pos.Chain.Update.SoftforkRule ( SoftforkRule (..) , softforkRuleF , checkSoftforkRule @@ -14,12 +14,12 @@ import Data.Aeson.TH (deriveJSON) import Data.SafeCopy (base, deriveSafeCopySimple) import Formatting (Format, bprint, build, (%)) import qualified Formatting.Buildable as Buildable -import Text.JSON.Canonical (FromJSON (..), ReportSchemaErrors, - ToJSON (..), fromJSField, mkObject) +import Text.JSON.Canonical (FromJSON (..), ToJSON (..), fromJSField, + mkObject) import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) import Pos.Core.Common (CoinPortion, checkCoinPortion) -import Pos.Util.Json.Canonical () +import Pos.Util.Json.Canonical (SchemaError) -- | Values defining softfork resolution rule. -- If a proposal is confirmed at the 's'-th epoch, softfork resolution threshold @@ -55,7 +55,7 @@ instance Monad m => ToJSON m SoftforkRule where , ("thdDecrement", toJSON srThdDecrement) ] -instance ReportSchemaErrors m => FromJSON m SoftforkRule where +instance MonadError SchemaError m => FromJSON m SoftforkRule where fromJSON obj = do srInitThd <- fromJSField obj "initThd" srMinThd <- fromJSField obj "minThd" diff --git a/core/src/Pos/Core/Update/SoftwareVersion.hs b/chain/src/Pos/Chain/Update/SoftwareVersion.hs similarity index 95% rename from core/src/Pos/Core/Update/SoftwareVersion.hs rename to chain/src/Pos/Chain/Update/SoftwareVersion.hs index 17a45eca512..2862969ef13 100644 --- a/core/src/Pos/Core/Update/SoftwareVersion.hs +++ b/chain/src/Pos/Chain/Update/SoftwareVersion.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.SoftwareVersion +module Pos.Chain.Update.SoftwareVersion ( SoftwareVersion (..) , HasSoftwareVersion (..) , NumSoftwareVersion @@ -19,7 +19,7 @@ import qualified Prelude import Pos.Util.Some (Some, liftLensSome) import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) -import Pos.Core.Update.ApplicationName +import Pos.Chain.Update.ApplicationName -- | Numeric software version associated with ApplicationName. type NumSoftwareVersion = Word32 diff --git a/core/src/Pos/Core/Update/SystemTag.hs b/chain/src/Pos/Chain/Update/SystemTag.hs similarity index 96% rename from core/src/Pos/Core/Update/SystemTag.hs rename to chain/src/Pos/Chain/Update/SystemTag.hs index 9a779797a4e..7a0e486a4bb 100644 --- a/core/src/Pos/Core/Update/SystemTag.hs +++ b/chain/src/Pos/Chain/Update/SystemTag.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DeriveLift #-} -module Pos.Core.Update.SystemTag +module Pos.Chain.Update.SystemTag ( SystemTag (..) , checkSystemTag , systemTagMaxLength @@ -20,7 +20,7 @@ import Data.SafeCopy (base, deriveSafeCopySimple) import qualified Data.Text as T import Distribution.System (Arch (..), OS (..)) import Distribution.Text (display) -import Instances.TH.Lift () +--import Instances.TH.Lift () import Language.Haskell.TH.Syntax (Lift) import Pos.Binary.Class (Bi (..)) diff --git a/core/src/Pos/Core/Update/Util.hs b/chain/src/Pos/Chain/Update/Util.hs similarity index 97% rename from core/src/Pos/Core/Update/Util.hs rename to chain/src/Pos/Chain/Update/Util.hs index 858ba706486..1bfb2b03cb2 100644 --- a/core/src/Pos/Core/Update/Util.hs +++ b/chain/src/Pos/Chain/Update/Util.hs @@ -2,7 +2,7 @@ -- | Utility functions related to core update system types. -module Pos.Core.Update.Util +module Pos.Chain.Update.Util ( -- * Checkers/validators. checkUpdatePayload @@ -35,14 +35,14 @@ import Formatting (Format, build) import Instances.TH.Lift () import Pos.Binary.Crypto () -import Pos.Core.Common.Types (checkCoinPortion) -import Pos.Core.Slotting (EpochIndex, isBootstrapEra) -import Pos.Core.Update.Types (BlockVersion, BlockVersionData (..), +import Pos.Chain.Update.Types (BlockVersion, BlockVersionData (..), BlockVersionModifier (..), SoftforkRule (..), SoftwareVersion, SystemTag, UpAttributes, UpdateData, UpdatePayload (..), UpdateProposal (..), UpdateProposalToSign (..), UpdateVote (..), VoteId, checkSoftwareVersion, checkSystemTag) +import Pos.Core.Common.Types (checkCoinPortion) +import Pos.Core.Slotting (EpochIndex, isBootstrapEra) import Pos.Crypto (ProtocolMagic, SafeSigner, SignTag (SignUSProposal, SignUSVote), checkSig, safeSign, safeToPublic) diff --git a/core/src/Pos/Core/Update/Vote.hs b/chain/src/Pos/Chain/Update/Vote.hs similarity index 97% rename from core/src/Pos/Core/Update/Vote.hs rename to chain/src/Pos/Chain/Update/Vote.hs index 6b9e277e0ae..4cb1d10fa3a 100644 --- a/core/src/Pos/Core/Update/Vote.hs +++ b/chain/src/Pos/Chain/Update/Vote.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Update.Vote +module Pos.Chain.Update.Vote ( -- Software update proposal UpdateProposal (..) @@ -42,11 +42,11 @@ import Pos.Crypto (Hash, ProtocolMagic, PublicKey, SafeSigner, Signature, checkSig, hash, safeSign, safeToPublic, shortHashF, sign, toPublic) -import Pos.Core.Update.BlockVersion -import Pos.Core.Update.BlockVersionModifier -import Pos.Core.Update.Data -import Pos.Core.Update.SoftwareVersion -import Pos.Core.Update.SystemTag +import Pos.Chain.Update.BlockVersion +import Pos.Chain.Update.BlockVersionModifier +import Pos.Chain.Update.Data +import Pos.Chain.Update.SoftwareVersion +import Pos.Chain.Update.SystemTag ---------------------------------------------------------------------------- -- Software Update Proposal diff --git a/chain/test/Test/Pos/Chain/Block/Bi.hs b/chain/test/Test/Pos/Chain/Block/Bi.hs index 51fc335f5a8..9acbda8b376 100644 --- a/chain/test/Test/Pos/Chain/Block/Bi.hs +++ b/chain/test/Test/Pos/Chain/Block/Bi.hs @@ -32,12 +32,13 @@ import Test.Pos.Chain.Delegation.Example (exampleLightDlgIndices, staticHeavyDlgIndexes, staticProxySKHeavys) import Test.Pos.Chain.Ssc.Example (exampleSscPayload, exampleSscProof) import Test.Pos.Chain.Txp.Example (exampleTxPayload, exampleTxProof) -import Test.Pos.Core.ExampleHelpers (exampleBlockVersion, - exampleChainDifficulty, exampleEpochIndex, - examplePublicKey, exampleSecretKey, exampleSecretKeys, - exampleSlotId, exampleSlotLeaders, exampleSoftwareVersion, - exampleUpdatePayload, exampleUpdateProof, feedPM, - feedPMEpochSlots) +import Test.Pos.Chain.Update.Example (exampleBlockVersion, + exampleSoftwareVersion, exampleUpdatePayload, + exampleUpdateProof) +import Test.Pos.Core.ExampleHelpers (exampleChainDifficulty, + exampleEpochIndex, examplePublicKey, exampleSecretKey, + exampleSecretKeys, exampleSlotId, exampleSlotLeaders, + feedPM, feedPMEpochSlots) import Test.Pos.Util.Golden (discoverGolden, eachOf) import Test.Pos.Util.Tripping (discoverRoundTrip) diff --git a/chain/test/Test/Pos/Chain/Block/Gen.hs b/chain/test/Test/Pos/Chain/Block/Gen.hs index 2f1277f7f73..3dfbdf6f627 100644 --- a/chain/test/Test/Pos/Chain/Block/Gen.hs +++ b/chain/test/Test/Pos/Chain/Block/Gen.hs @@ -40,10 +40,10 @@ import Test.Pos.Chain.Delegation.Gen (genDlgPayload, genHeavyDlgIndex, genLightDlgIndices) import Test.Pos.Chain.Ssc.Gen (genSscPayload, genSscProof) import Test.Pos.Chain.Txp.Gen (genTxPayload, genTxProof) -import Test.Pos.Core.Gen (genBlockVersion, genChainDifficulty, - genEpochIndex, genSlotId, genSlotLeaders, - genSoftwareVersion, genTextHash, genUpdatePayload, - genUpdateProof) +import Test.Pos.Chain.Update.Gen (genBlockVersion, genSoftwareVersion, + genUpdatePayload, genUpdateProof) +import Test.Pos.Core.Gen (genChainDifficulty, genEpochIndex, + genSlotId, genSlotLeaders, genTextHash) import Test.Pos.Crypto.Gen (genAbstractHash, genProxySignature, genPublicKey, genSecretKey, genSignature) diff --git a/chain/test/Test/Pos/Chain/Genesis/Arbitrary.hs b/chain/test/Test/Pos/Chain/Genesis/Arbitrary.hs index 5c61ca8d962..b947060955f 100644 --- a/chain/test/Test/Pos/Chain/Genesis/Arbitrary.hs +++ b/chain/test/Test/Pos/Chain/Genesis/Arbitrary.hs @@ -18,14 +18,15 @@ import Test.QuickCheck (Arbitrary (..), choose, sized, suchThat) import Pos.Chain.Delegation (HeavyDlgIndex (..)) import Pos.Chain.Genesis import Pos.Chain.Ssc (mkVssCertificatesMapLossy) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (Timestamp (..), TxFeePolicy (..), maxCoinVal) import Pos.Core.ProtocolConstants (ProtocolConstants (..), VssMaxTTL (..), VssMinTTL (..)) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (createPsk, toPublic) import Pos.Util.Util (leftToPanic) import Test.Pos.Chain.Ssc.Arbitrary () +import Test.Pos.Chain.Update.Arbitrary () import Test.Pos.Core.Arbitrary () import Test.Pos.Crypto.Dummy (dummyProtocolMagic) import Test.Pos.Util.QuickCheck.Arbitrary (nonrepeating) diff --git a/chain/test/Test/Pos/Chain/Genesis/Dummy.hs b/chain/test/Test/Pos/Chain/Genesis/Dummy.hs index c365944917e..b4d5d75acd6 100644 --- a/chain/test/Test/Pos/Chain/Genesis/Dummy.hs +++ b/chain/test/Test/Pos/Chain/Genesis/Dummy.hs @@ -34,13 +34,13 @@ import Pos.Chain.Genesis (Config (..), FakeAvvmOptions (..), genesisProtocolConstantsFromProtocolConstants, gsSecretKeys, gsSecretKeysPoor, gsSecretKeysRich, mkConfig, noGenesisDelegation) +import Pos.Chain.Update (BlockVersionData (..), SoftforkRule (..)) import Pos.Core (BlockCount, Coeff (..), EpochIndex (..), ProtocolConstants (..), SharedSeed (..), SlotCount, Timestamp, TxFeePolicy (..), TxSizeLinear (..), VssMaxTTL (..), VssMinTTL (..), kEpochSlots, kSlotSecurityParam, pcBlkSecurityParam, unsafeCoinPortionFromDouble) -import Pos.Core.Update (BlockVersionData (..), SoftforkRule (..)) import Pos.Crypto (SecretKey) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) diff --git a/chain/test/Test/Pos/Chain/Genesis/Example.hs b/chain/test/Test/Pos/Chain/Genesis/Example.hs index 5e91a7a71bc..1f7435c0183 100644 --- a/chain/test/Test/Pos/Chain/Genesis/Example.hs +++ b/chain/test/Test/Pos/Chain/Genesis/Example.hs @@ -28,8 +28,8 @@ import Pos.Crypto (ProtocolMagic (..), ProxyCert (..), redeemDeterministicKeyGen) import Pos.Crypto.Signing (PublicKey (..)) -import Test.Pos.Core.ExampleHelpers (exampleBlockVersionData, - exampleSharedSeed) +import Test.Pos.Chain.Update.Example (exampleBlockVersionData) +import Test.Pos.Core.ExampleHelpers (exampleSharedSeed) import Test.Pos.Crypto.Bi (getBytes) diff --git a/chain/test/Test/Pos/Chain/Genesis/Gen.hs b/chain/test/Test/Pos/Chain/Genesis/Gen.hs index cd154910bf1..eaf77a31d9b 100644 --- a/chain/test/Test/Pos/Chain/Genesis/Gen.hs +++ b/chain/test/Test/Pos/Chain/Genesis/Gen.hs @@ -28,9 +28,9 @@ import Pos.Chain.Genesis (FakeAvvmOptions (..), import Pos.Crypto (ProtocolMagic) import Test.Pos.Chain.Delegation.Gen (genProxySKHeavy) -import Test.Pos.Core.Gen (genBlockVersionData, genCoin, - genCoinPortion, genHashRaw, genSharedSeed, genTextHash, - genVssMaxTTL, genVssMinTTL) +import Test.Pos.Chain.Update.Gen (genBlockVersionData) +import Test.Pos.Core.Gen (genCoin, genCoinPortion, genHashRaw, + genSharedSeed, genTextHash, genVssMaxTTL, genVssMinTTL) import Test.Pos.Crypto.Gen (genProtocolMagic, genRedeemPublicKey) genGenesisHash :: Gen GenesisHash diff --git a/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs b/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs index 67f6228d9b5..78a4e20e56a 100644 --- a/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs +++ b/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs @@ -21,9 +21,9 @@ import Test.QuickCheck (Arbitrary (..), Gen, choose, vector) import Test.QuickCheck.Arbitrary.Generic (genericShrink) import Pos.Chain.Lrc (RichmenStakes) +import Pos.Chain.Update (BlockVersionData (bvdMpcThd)) import Pos.Core.Common (Coin, CoinPortion, coinPortionToDouble, mkCoin, unsafeAddCoin, unsafeGetCoin, unsafeSubCoin) -import Pos.Core.Update (BlockVersionData (bvdMpcThd)) import Test.Pos.Chain.Genesis.Dummy (dummyBlockVersionData) import Test.Pos.Core.Arbitrary () diff --git a/chain/test/Test/Pos/Chain/Update/Arbitrary.hs b/chain/test/Test/Pos/Chain/Update/Arbitrary.hs index 91dc1b0be1e..b90d1f3862c 100644 --- a/chain/test/Test/Pos/Chain/Update/Arbitrary.hs +++ b/chain/test/Test/Pos/Chain/Update/Arbitrary.hs @@ -1,9 +1,124 @@ -{-# OPTIONS_GHC -Wno-unused-imports #-} -{-# OPTIONS_GHC -Wno-dodgy-exports #-} --- | Arbitrary instances for Update System types. +{-# OPTIONS_GHC -fno-warn-orphans #-} module Test.Pos.Chain.Update.Arbitrary - ( module Test.Pos.Chain.Update.Arbitrary.Core + ( genUpdatePayload + , genUpdateVote + , genUpdateProposal ) where -import Test.Pos.Chain.Update.Arbitrary.Core +import Universum + +import qualified Data.HashMap.Strict as HM +import Data.List ((!!)) +import Test.QuickCheck (Arbitrary (..), Gen, frequency, listOf, + listOf1, oneof) +import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, + genericShrink) + +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), + BlockVersionData (..), BlockVersionModifier, + SoftforkRule (..), SoftwareVersion (..), SystemTag (..), + UpdateData (..), UpdatePayload (..), UpdateProposal, + UpdateProposalToSign (..), UpdateVote (..), + VoteState (..), applicationNameMaxLength, + mkUpdateProposalWSign, mkUpdateVote) +import Pos.Core.Attributes (mkAttributes) +import Pos.Crypto (ProtocolMagic, fakeSigner) + +import Test.Pos.Core.Arbitrary () +import Test.Pos.Core.Arbitrary.Slotting () +import Test.Pos.Crypto.Arbitrary () +import Test.Pos.Crypto.Dummy (dummyProtocolMagic) + + +instance Arbitrary SoftforkRule where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary BlockVersionData where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary ApplicationName where + arbitrary = + ApplicationName . + toText . map selectAlpha . take applicationNameMaxLength <$> + arbitrary + where + selectAlpha n = alphabet !! (n `mod` length alphabet) + alphabet = "-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + +instance Arbitrary BlockVersion where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary SoftwareVersion where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary BlockVersionModifier where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary SystemTag where + arbitrary = + oneof . map (pure . SystemTag) $ + [os <> arch | os <- ["win", "linux", "mac"], arch <- ["32", "64"]] + shrink = genericShrink + +genUpdateVote :: ProtocolMagic -> Gen UpdateVote +genUpdateVote pm = mkUpdateVote pm <$> arbitrary <*> arbitrary <*> arbitrary + +instance Arbitrary UpdateVote where + arbitrary = genUpdateVote dummyProtocolMagic + shrink = genericShrink + +genUpdateProposal :: ProtocolMagic -> Gen UpdateProposal +genUpdateProposal pm = do + upBlockVersion <- arbitrary + upBlockVersionMod <- arbitrary + upSoftwareVersion <- arbitrary + upData <- HM.fromList <$> listOf1 arbitrary + let upAttributes = mkAttributes () + ss <- fakeSigner <$> arbitrary + pure $ + mkUpdateProposalWSign + pm + upBlockVersion + upBlockVersionMod + upSoftwareVersion + upData + upAttributes + ss + +instance Arbitrary UpdateProposal where + arbitrary = genUpdateProposal dummyProtocolMagic + shrink = genericShrink + +instance Arbitrary UpdateProposalToSign where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary VoteState where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary UpdateData where + arbitrary = genericArbitrary + shrink = genericShrink + +genUpdatePayload :: ProtocolMagic -> Gen UpdatePayload +genUpdatePayload pm = + UpdatePayload + <$> genMaybeUpdateProposal + <*> listOf (genUpdateVote pm) + where + -- Arbitrary1 instance for Maybe uses these frequencies. + genMaybeUpdateProposal = frequency + [ (1, return Nothing) + , (3, Just <$> genUpdateProposal pm) + ] + +instance Arbitrary UpdatePayload where + arbitrary = genUpdatePayload dummyProtocolMagic + shrink = genericShrink diff --git a/chain/test/Test/Pos/Chain/Update/Arbitrary/Core.hs b/chain/test/Test/Pos/Chain/Update/Arbitrary/Core.hs deleted file mode 100644 index 048e9102cc2..00000000000 --- a/chain/test/Test/Pos/Chain/Update/Arbitrary/Core.hs +++ /dev/null @@ -1,100 +0,0 @@ -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE OverloadedStrings #-} - -{-# OPTIONS_GHC -fno-warn-orphans #-} - --- | Arbitrary instances for Update System core types. - -module Test.Pos.Chain.Update.Arbitrary.Core - ( genUpdatePayload - , genUpdateVote - , genUpdateProposal - ) where - -import Universum - -import qualified Data.HashMap.Strict as HM -import Test.QuickCheck (Arbitrary (..), Gen, frequency, listOf, - listOf1, oneof) -import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, - genericShrink) - -import Pos.Chain.Update (VoteState (..)) -import Pos.Core.Attributes (mkAttributes) -import Pos.Core.Update (BlockVersionModifier, SystemTag (..), - UpdateData (..), UpdatePayload (..), UpdateProposal, - UpdateProposalToSign (..), UpdateVote (..), - mkUpdateProposalWSign, mkUpdateVote) -import Pos.Crypto (ProtocolMagic, fakeSigner) - -import Test.Pos.Core.Arbitrary () -import Test.Pos.Core.Arbitrary.Slotting () -import Test.Pos.Crypto.Arbitrary () -import Test.Pos.Crypto.Dummy (dummyProtocolMagic) - -instance Arbitrary BlockVersionModifier where - arbitrary = genericArbitrary - shrink = genericShrink - -instance Arbitrary SystemTag where - arbitrary = - oneof . map (pure . SystemTag) $ - [os <> arch | os <- ["win", "linux", "mac"], arch <- ["32", "64"]] - shrink = genericShrink - -genUpdateVote :: ProtocolMagic -> Gen UpdateVote -genUpdateVote pm = mkUpdateVote pm <$> arbitrary <*> arbitrary <*> arbitrary - -instance Arbitrary UpdateVote where - arbitrary = genUpdateVote dummyProtocolMagic - shrink = genericShrink - -genUpdateProposal :: ProtocolMagic -> Gen UpdateProposal -genUpdateProposal pm = do - upBlockVersion <- arbitrary - upBlockVersionMod <- arbitrary - upSoftwareVersion <- arbitrary - upData <- HM.fromList <$> listOf1 arbitrary - let upAttributes = mkAttributes () - ss <- fakeSigner <$> arbitrary - pure $ - mkUpdateProposalWSign - pm - upBlockVersion - upBlockVersionMod - upSoftwareVersion - upData - upAttributes - ss - -instance Arbitrary UpdateProposal where - arbitrary = genUpdateProposal dummyProtocolMagic - shrink = genericShrink - -instance Arbitrary UpdateProposalToSign where - arbitrary = genericArbitrary - shrink = genericShrink - -instance Arbitrary VoteState where - arbitrary = genericArbitrary - shrink = genericShrink - -instance Arbitrary UpdateData where - arbitrary = genericArbitrary - shrink = genericShrink - -genUpdatePayload :: ProtocolMagic -> Gen UpdatePayload -genUpdatePayload pm = - UpdatePayload - <$> genMaybeUpdateProposal - <*> listOf (genUpdateVote pm) - where - -- Arbitrary1 instance for Maybe uses these frequencies. - genMaybeUpdateProposal = frequency - [ (1, return Nothing) - , (3, Just <$> genUpdateProposal pm) - ] - -instance Arbitrary UpdatePayload where - arbitrary = genUpdatePayload dummyProtocolMagic - shrink = genericShrink diff --git a/chain/test/Test/Pos/Chain/Update/Bi.hs b/chain/test/Test/Pos/Chain/Update/Bi.hs new file mode 100644 index 00000000000..c4883983927 --- /dev/null +++ b/chain/test/Test/Pos/Chain/Update/Bi.hs @@ -0,0 +1,241 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Test.Pos.Chain.Update.Bi + ( tests + ) where + +import Universum + +import qualified Data.HashMap.Strict as HM +import Hedgehog (Property) +import qualified Hedgehog as H + +import Pos.Binary.Class (Raw (..)) +import Pos.Chain.Update (ApplicationName (..), SoftforkRule (..)) +import Pos.Core (CoinPortion (..)) +import Pos.Crypto (Hash, abstractHash) + +import Test.Pos.Binary.Helpers.GoldenRoundTrip (goldenTestBi, + roundTripsBiBuildable, roundTripsBiShow) +import Test.Pos.Chain.Update.Example (exampleBlockVersion, + exampleBlockVersionData, exampleBlockVersionModifier, + exampleSoftwareVersion, exampleSystemTag, + exampleUpAttributes, exampleUpId, exampleUpdateData, + exampleUpdatePayload, exampleUpdateProof, + exampleUpdateProposal, exampleUpdateProposalToSign, + exampleUpdateVote, exampleVoteId) +import Test.Pos.Chain.Update.Gen (genApplicationName, genBlockVersion, + genBlockVersionData, genBlockVersionModifier, + genSoftforkRule, genSoftwareVersion, genSystemTag, + genUpAttributes, genUpId, genUpdateData, genUpdatePayload, + genUpdateProof, genUpdateProposal, + genUpdateProposalToSign, genUpdateProposals, + genUpdateVote, genUpsData, genVoteId) +import Test.Pos.Core.ExampleHelpers (feedPM) +import Test.Pos.Core.Gen (genHashRaw) +import Test.Pos.Util.Golden (discoverGolden, eachOf) +import Test.Pos.Util.Tripping (discoverRoundTrip) + +-------------------------------------------------------------------------------- +-- ApplicationName +-------------------------------------------------------------------------------- + +golden_ApplicationName :: Property +golden_ApplicationName = goldenTestBi aN "test/golden/ApplicationName" + where aN = ApplicationName "Golden" + +roundTripApplicationName :: Property +roundTripApplicationName = eachOf 50 genApplicationName roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- BlockVersion +-------------------------------------------------------------------------------- + +golden_BlockVersion :: Property +golden_BlockVersion = goldenTestBi exampleBlockVersion "test/golden/BlockVersion" + +roundTripBlockVersion :: Property +roundTripBlockVersion = eachOf 50 genBlockVersion roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- BlockVersionData +-------------------------------------------------------------------------------- + +golden_BlockVersionData :: Property +golden_BlockVersionData = goldenTestBi bVerDat "test/golden/BlockVersionData" + where bVerDat = exampleBlockVersionData + +roundTripBlockVersionData :: Property +roundTripBlockVersionData = eachOf 50 genBlockVersionData roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- BlockVersionModifier +-------------------------------------------------------------------------------- + +golden_BlockVersionModifier :: Property +golden_BlockVersionModifier = goldenTestBi bVerMod "test/golden/BlockVersionModifier" + where bVerMod = exampleBlockVersionModifier + +roundTripBlockVersionModifier :: Property +roundTripBlockVersionModifier = eachOf 50 genBlockVersionModifier roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- HashRaw +-------------------------------------------------------------------------------- + +golden_BlockHashRaw :: Property +golden_BlockHashRaw = goldenTestBi hRaw "test/golden/HashRaw" + where hRaw = (abstractHash $ Raw ("9" ) :: Hash Raw) + +roundTripHashRaw :: Property +roundTripHashRaw = eachOf 50 genHashRaw roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- SoftforkRule +-------------------------------------------------------------------------------- + +golden_SoftforkRule :: Property +golden_SoftforkRule = goldenTestBi sfR "test/golden/SoftforkRule" + where sfR = SoftforkRule (CoinPortion 99) (CoinPortion 99) (CoinPortion 99) + +roundTripSoftforkRule :: Property +roundTripSoftforkRule = eachOf 10 genSoftforkRule roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- SoftwareVersion +-------------------------------------------------------------------------------- + +golden_SoftwareVersion :: Property +golden_SoftwareVersion = goldenTestBi exampleSoftwareVersion "test/golden/SoftwareVersion" + +roundTripSoftwareVersion :: Property +roundTripSoftwareVersion = eachOf 10 genSoftwareVersion roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- SystemTag +-------------------------------------------------------------------------------- + +golden_SystemTag :: Property +golden_SystemTag = goldenTestBi exampleSystemTag "test/golden/SystemTag" + +roundTripSystemTag :: Property +roundTripSystemTag = eachOf 10 genSystemTag roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpAttributes +-------------------------------------------------------------------------------- + +golden_UpAttributes :: Property +golden_UpAttributes = goldenTestBi exampleUpAttributes "test/golden/UpAttributes" + +roundTripUpAttributes :: Property +roundTripUpAttributes = eachOf 20 genUpAttributes roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpdateData +-------------------------------------------------------------------------------- + +golden_UpdateData :: Property +golden_UpdateData = goldenTestBi exampleUpdateData "test/golden/UpdateData" + +roundTripUpdateData :: Property +roundTripUpdateData = eachOf 20 genUpdateData roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpdatePayload +-------------------------------------------------------------------------------- + +golden_UpdatePayload :: Property +golden_UpdatePayload = goldenTestBi exampleUpdatePayload "test/golden/UpdatePayload" + +roundTripUpdatePayload :: Property +roundTripUpdatePayload = eachOf 20 (feedPM genUpdatePayload) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpdateProof +-------------------------------------------------------------------------------- + +golden_UpdateProof :: Property +golden_UpdateProof = goldenTestBi exampleUpdateProof "test/golden/UpdateProof" + +roundTripUpdateProof :: Property +roundTripUpdateProof = eachOf 20 (feedPM genUpdateProof) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpdateProposal +-------------------------------------------------------------------------------- + +golden_UpdateProposal :: Property +golden_UpdateProposal = goldenTestBi exampleUpdateProposal "test/golden/UpdateProposal" + +roundTripUpdateProposal :: Property +roundTripUpdateProposal = eachOf 20 (feedPM genUpdateProposal) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpdateProposals +-------------------------------------------------------------------------------- + +golden_UpdateProposals :: Property +golden_UpdateProposals = goldenTestBi ups "test/golden/UpdateProposals" + where + -- Need to revisit this. + ups = HM.fromList [(exampleUpId, exampleUpdateProposal)] + +roundTripUpdateProposals :: Property +roundTripUpdateProposals = eachOf 20 (feedPM genUpdateProposals) roundTripsBiShow + +-------------------------------------------------------------------------------- +-- UpdateProposalToSign +-------------------------------------------------------------------------------- + +golden_UpdateProposalToSign :: Property +golden_UpdateProposalToSign = + goldenTestBi exampleUpdateProposalToSign "test/golden/UpdateProposalToSign" + +roundTripUpdateProposalToSign :: Property +roundTripUpdateProposalToSign = eachOf 20 genUpdateProposalToSign roundTripsBiShow + +-------------------------------------------------------------------------------- +-- UpdateVote +-------------------------------------------------------------------------------- + +golden_UpdateVote :: Property +golden_UpdateVote = goldenTestBi exampleUpdateVote "test/golden/UpdateVote" + +roundTripUpdateVote :: Property +roundTripUpdateVote = eachOf 20 (feedPM genUpdateVote) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpId +-------------------------------------------------------------------------------- + +golden_UpId :: Property +golden_UpId = goldenTestBi exampleUpId "test/golden/UpId" + +roundTripUpId :: Property +roundTripUpId = eachOf 20 (feedPM genUpId) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- UpsData NB: UpsData is not a type it is a record accessor of `UpdateProposalToSign` +-------------------------------------------------------------------------------- + +roundTripUpsData :: Property +roundTripUpsData = eachOf 20 genUpsData roundTripsBiShow + +-------------------------------------------------------------------------------- +-- VoteId +-------------------------------------------------------------------------------- + +golden_VoteId :: Property +golden_VoteId = goldenTestBi exampleVoteId "test/golden/VoteId" + +roundTripVoteId :: Property +roundTripVoteId = eachOf 20 (feedPM genVoteId) roundTripsBiBuildable + +----------------------------------------------------------------------- +-- Main test export +----------------------------------------------------------------------- + +tests :: IO Bool +tests = and <$> sequence + [H.checkSequential $$discoverGolden, H.checkParallel $$discoverRoundTrip] diff --git a/chain/test/Test/Pos/Chain/Update/CborSpec.hs b/chain/test/Test/Pos/Chain/Update/CborSpec.hs new file mode 100644 index 00000000000..195db609ece --- /dev/null +++ b/chain/test/Test/Pos/Chain/Update/CborSpec.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE TypeApplications #-} + +module Test.Pos.Chain.Update.CborSpec + ( spec + ) where + +import Universum + +import Test.Hspec (Spec, describe) + +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), + BlockVersionData (..), SoftforkRule (..), + SoftwareVersion (..)) + +import Test.Pos.Binary.Helpers (binaryTest) +import Test.Pos.Chain.Update.Arbitrary () + +spec :: Spec +spec = describe "Cbor Bi instances" $ do + binaryTest @ApplicationName + binaryTest @BlockVersion + binaryTest @BlockVersionData + binaryTest @SoftforkRule + binaryTest @SoftwareVersion diff --git a/chain/test/Test/Pos/Chain/Update/Example.hs b/chain/test/Test/Pos/Chain/Update/Example.hs new file mode 100644 index 00000000000..153ba09829e --- /dev/null +++ b/chain/test/Test/Pos/Chain/Update/Example.hs @@ -0,0 +1,150 @@ +module Test.Pos.Chain.Update.Example + ( exampleBlockVersion + , exampleBlockVersionData + , exampleBlockVersionModifier + , exampleSoftwareVersion + , exampleSystemTag + , exampleUpdateData + , exampleUpdatePayload + , exampleUpdateProof + , exampleUpdateProposal + , exampleUpdateProposalToSign + , exampleUpdateVote + , exampleUpAttributes + , exampleUpId + , exampleVoteId + ) where + +import Universum + +import Data.Fixed (Fixed (..)) +import qualified Data.HashMap.Strict as HM +import Data.List ((!!)) +import Data.Time.Units (Millisecond) +import Serokell.Data.Memory.Units (Byte) + +import Pos.Binary.Class (Raw (..)) +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), + BlockVersionData (..), BlockVersionModifier (..), + SoftforkRule (..), SoftwareVersion (..), SystemTag (..), + UpAttributes, UpId, UpdateData (..), UpdatePayload (..), + UpdateProof, UpdateProposal, UpdateProposalToSign (..), + UpdateVote (..), VoteId, mkUpdateProof, + mkUpdateProposalWSign, mkUpdateVoteSafe) +import Pos.Core (Coeff (..), CoinPortion (..), EpochIndex (..), + FlatSlotId, ScriptVersion, TxFeePolicy (..), + TxSizeLinear (..)) +import Pos.Crypto (ProtocolMagic (..), hash) + +import Test.Pos.Core.ExampleHelpers (exampleAttributes, + examplePublicKey, exampleSafeSigner, getText) +import Test.Pos.Crypto.Bi (getBytes) + +exampleBlockVersion :: BlockVersion +exampleBlockVersion = BlockVersion 1 1 1 + +exampleBlockVersionData :: BlockVersionData +exampleBlockVersionData = BlockVersionData + (999 :: ScriptVersion) + (999 :: Millisecond) + (999 :: Byte) + (999 :: Byte) + (999 :: Byte) + (999 :: Byte) + (CoinPortion 99) + (CoinPortion 99) + (CoinPortion 99) + (CoinPortion 99) + (99 :: FlatSlotId) + sfrule + (TxFeePolicyTxSizeLinear tslin) + (EpochIndex 99) + where + tslin = TxSizeLinear c1' c2' + c1' = Coeff (MkFixed 999) + c2' = Coeff (MkFixed 77) + sfrule = (SoftforkRule (CoinPortion 99) (CoinPortion 99) (CoinPortion 99)) + +exampleBlockVersionModifier :: BlockVersionModifier +exampleBlockVersionModifier = BlockVersionModifier + (Just (999 :: ScriptVersion)) + (Just (999 :: Millisecond)) + (Just (999 :: Byte)) + (Just (999 :: Byte)) + (Just (999 :: Byte)) + (Just (999 :: Byte)) + (Just $ CoinPortion 99) + (Just $ CoinPortion 99) + (Just $ CoinPortion 99) + (Just $ CoinPortion 99) + (Just (99 :: FlatSlotId)) + (Just sfrule') + (Just $ TxFeePolicyTxSizeLinear tslin') + (Just $ EpochIndex 99) + where + tslin' = TxSizeLinear co1 co2 + co1 = Coeff (MkFixed 999) + co2 = Coeff (MkFixed 77) + sfrule' = (SoftforkRule (CoinPortion 99) (CoinPortion 99) (CoinPortion 99)) + +exampleSystemTag :: SystemTag +exampleSystemTag = (exampleSystemTags 0 1) !! 0 + +exampleSystemTags :: Int -> Int -> [SystemTag] +exampleSystemTags offset count = map (toSystemTag . (*offset)) [0..count-1] + where + toSystemTag start = SystemTag (getText start 16) + +exampleUpAttributes :: UpAttributes +exampleUpAttributes = exampleAttributes + +exampleUpdateData :: UpdateData +exampleUpdateData = (exampleUpdateDatas 10 2) !! 1 + +exampleUpdateDatas :: Int -> Int -> [UpdateData] +exampleUpdateDatas offset count = map (toUpdateData . (*offset)) [0..count-1] + where + toUpdateData start = + let h = hash $ Raw (getBytes start 128) + in UpdateData h h h h + +exampleUpId :: UpId +exampleUpId = hash exampleUpdateProposal + +exampleUpdatePayload :: UpdatePayload +exampleUpdatePayload = UpdatePayload up uv + where + up = Just exampleUpdateProposal + uv = [exampleUpdateVote] + +exampleUpdateProof :: UpdateProof +exampleUpdateProof = mkUpdateProof exampleUpdatePayload + +exampleUpdateProposal :: UpdateProposal +exampleUpdateProposalToSign :: UpdateProposalToSign +(exampleUpdateProposal, exampleUpdateProposalToSign) = + ( mkUpdateProposalWSign pm bv bvm sv hm ua ss + , UpdateProposalToSign bv bvm sv hm ua ) + where + pm = ProtocolMagic 0 + bv = exampleBlockVersion + bvm = exampleBlockVersionModifier + sv = exampleSoftwareVersion + hm = HM.fromList $ zip (exampleSystemTags 10 5) (exampleUpdateDatas 10 5) + ua = exampleUpAttributes + ss = exampleSafeSigner 0 + +exampleUpdateVote :: UpdateVote +exampleUpdateVote = mkUpdateVoteSafe pm ss ui ar + where + pm = ProtocolMagic 0 + ss = exampleSafeSigner 0 + ui = exampleUpId + ar = True + +-- | ```type VoteId = (UpId, PublicKey, Bool)``` +exampleVoteId :: VoteId +exampleVoteId = (exampleUpId, examplePublicKey, False) + +exampleSoftwareVersion :: SoftwareVersion +exampleSoftwareVersion = SoftwareVersion (ApplicationName "Golden") 99 diff --git a/chain/test/Test/Pos/Chain/Update/Gen.hs b/chain/test/Test/Pos/Chain/Update/Gen.hs new file mode 100644 index 00000000000..88459787cb6 --- /dev/null +++ b/chain/test/Test/Pos/Chain/Update/Gen.hs @@ -0,0 +1,169 @@ +module Test.Pos.Chain.Update.Gen + ( genApplicationName + , genBlockVersion + , genBlockVersionData + , genBlockVersionModifier + , genHashRaw + , genSoftforkRule + , genSoftwareVersion + , genSystemTag + , genUpAttributes + , genUpdateData + , genUpdatePayload + , genUpdateProof + , genUpdateProposal + , genUpdateProposals + , genUpdateProposalToSign + , genUpdateVote + , genUpId + , genUpsData + , genVoteId + ) where + +import Universum + +import qualified Data.HashMap.Strict as HM +import Hedgehog +import qualified Hedgehog.Gen as Gen +import qualified Hedgehog.Range as Range + +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), + BlockVersionData (..), BlockVersionModifier (..), + SoftforkRule (..), SoftwareVersion (..), SystemTag (..), + UpAttributes, UpId, UpdateData (..), UpdatePayload (..), + UpdateProof, UpdateProposal (..), + UpdateProposalToSign (..), UpdateProposals, + UpdateVote (..), VoteId, mkUpdateVote) +import Pos.Core.Attributes (mkAttributes) +import Pos.Crypto (ProtocolMagic) + +import Test.Pos.Core.Gen (genByte, genCoinPortion, genCustomHashMap, + genEpochIndex, genFlatSlotId, genHashRaw, genMillisecond, + genScriptVersion, genTxFeePolicy) +import Test.Pos.Crypto.Gen (genAbstractHash, genPublicKey, + genSecretKey, genSignature) + + +genApplicationName :: Gen ApplicationName +genApplicationName = + ApplicationName <$> Gen.text (Range.constant 0 10) Gen.alphaNum + +genBlockVersion :: Gen BlockVersion +genBlockVersion = + BlockVersion + <$> Gen.word16 Range.constantBounded + <*> Gen.word16 Range.constantBounded + <*> Gen.word8 Range.constantBounded + +genBlockVersionData :: Gen BlockVersionData +genBlockVersionData = + BlockVersionData + <$> genScriptVersion + <*> genMillisecond + <*> genByte + <*> genByte + <*> genByte + <*> genByte + <*> genCoinPortion + <*> genCoinPortion + <*> genCoinPortion + <*> genCoinPortion + <*> genFlatSlotId + <*> genSoftforkRule + <*> genTxFeePolicy + <*> genEpochIndex + +genBlockVersionModifier :: Gen BlockVersionModifier +genBlockVersionModifier = + BlockVersionModifier + <$> Gen.maybe genScriptVersion + <*> Gen.maybe genMillisecond + <*> Gen.maybe genByte + <*> Gen.maybe genByte + <*> Gen.maybe genByte + <*> Gen.maybe genByte + <*> Gen.maybe genCoinPortion + <*> Gen.maybe genCoinPortion + <*> Gen.maybe genCoinPortion + <*> Gen.maybe genCoinPortion + <*> Gen.maybe genFlatSlotId + <*> Gen.maybe genSoftforkRule + <*> Gen.maybe genTxFeePolicy + <*> Gen.maybe genEpochIndex + +genSoftforkRule :: Gen SoftforkRule +genSoftforkRule = + SoftforkRule <$> genCoinPortion <*> genCoinPortion <*> genCoinPortion + +genSoftwareVersion :: Gen SoftwareVersion +genSoftwareVersion = + SoftwareVersion + <$> genApplicationName + <*> Gen.word32 Range.constantBounded + +genSystemTag :: Gen SystemTag +genSystemTag = SystemTag <$> Gen.text (Range.constant 0 10) Gen.alphaNum + +genUpAttributes :: Gen UpAttributes +genUpAttributes = pure $ mkAttributes () + +genUpdateData :: Gen UpdateData +genUpdateData = + UpdateData + <$> genHashRaw + <*> genHashRaw + <*> genHashRaw + <*> genHashRaw + +genUpdatePayload :: ProtocolMagic -> Gen UpdatePayload +genUpdatePayload pm = + UpdatePayload + <$> Gen.maybe (genUpdateProposal pm) + <*> Gen.list (Range.linear 0 10) (genUpdateVote pm) + +genUpdateProof :: ProtocolMagic -> Gen UpdateProof +genUpdateProof pm = genAbstractHash (genUpdatePayload pm) + +genUpdateProposal :: ProtocolMagic -> Gen UpdateProposal +genUpdateProposal pm = do + UnsafeUpdateProposal + <$> genBlockVersion + <*> genBlockVersionModifier + <*> genSoftwareVersion + <*> genUpsData + <*> genUpAttributes + <*> genPublicKey + <*> genSignature pm genUpdateProposalToSign + +genUpdateProposals :: ProtocolMagic -> Gen UpdateProposals +genUpdateProposals pm = genCustomHashMap (genUpId pm) (genUpdateProposal pm) + +genUpdateProposalToSign :: Gen UpdateProposalToSign +genUpdateProposalToSign = + UpdateProposalToSign + <$> genBlockVersion + <*> genBlockVersionModifier + <*> genSoftwareVersion + <*> genUpsData + <*> genUpAttributes + +genUpId :: ProtocolMagic -> Gen UpId +genUpId pm = genAbstractHash (genUpdateProposal pm) + +genUpsData :: Gen (HM.HashMap SystemTag UpdateData) +genUpsData = do + hMapSize <- Gen.int (Range.linear 0 20) + sysTagList <- Gen.list (Range.singleton hMapSize) genSystemTag + upDataList <- Gen.list (Range.singleton hMapSize) genUpdateData + pure $ HM.fromList $ zip sysTagList upDataList + +genUpdateVote :: ProtocolMagic -> Gen UpdateVote +genUpdateVote pm = mkUpdateVote pm <$> genSecretKey <*> genUpId pm <*> Gen.bool + -- <$> genSecretKey + -- <*> genUpId + -- <*> Gen.bool + -- <*> genSignature ((,) <$> genUpId <*> Gen.bool) +-- genUpdateVote pm = mkUpdateVote pm <$> arbitrary <*> arbitrary <*> arbitrary + +genVoteId :: ProtocolMagic -> Gen VoteId +genVoteId pm = (,,) <$> genUpId pm <*> genPublicKey <*> Gen.bool diff --git a/chain/test/Test/Pos/Chain/Update/Json.hs b/chain/test/Test/Pos/Chain/Update/Json.hs new file mode 100644 index 00000000000..a1ec88e29da --- /dev/null +++ b/chain/test/Test/Pos/Chain/Update/Json.hs @@ -0,0 +1,38 @@ +{-# LANGUAGE TemplateHaskell #-} + +module Test.Pos.Chain.Update.Json + ( tests + ) where + +import Universum + +import Hedgehog (Property) +import qualified Hedgehog as H + +import Test.Pos.Chain.Update.Gen (genBlockVersionData, + genSoftforkRule) +import Test.Pos.Util.Golden (eachOf) +import Test.Pos.Util.Tripping (discoverRoundTrip, + roundTripsAesonBuildable) + +-------------------------------------------------------------------------------- +-- BlockVersionData +-------------------------------------------------------------------------------- + +roundTripBlockVersionData :: Property +roundTripBlockVersionData = + eachOf 1000 genBlockVersionData roundTripsAesonBuildable + +-------------------------------------------------------------------------------- +-- SoftforkRule +-------------------------------------------------------------------------------- + +roundTripSoftforkRule :: Property +roundTripSoftforkRule = eachOf 1000 genSoftforkRule roundTripsAesonBuildable + +-------------------------------------------------------------------------------- +-- Main Testing Function +-------------------------------------------------------------------------------- + +tests :: IO Bool +tests = H.checkParallel $$discoverRoundTrip diff --git a/chain/test/cardano-sl-chain-test.cabal b/chain/test/cardano-sl-chain-test.cabal index 10a074dd59d..7442c8d4d76 100644 --- a/chain/test/cardano-sl-chain-test.cabal +++ b/chain/test/cardano-sl-chain-test.cabal @@ -32,8 +32,8 @@ library Test.Pos.Chain.Txp.Example Test.Pos.Chain.Txp.Gen Test.Pos.Chain.Update.Arbitrary - - other-modules: Test.Pos.Chain.Update.Arbitrary.Core + Test.Pos.Chain.Update.Example + Test.Pos.Chain.Update.Gen build-depends: base , base16-bytestring @@ -57,6 +57,7 @@ library , QuickCheck , random , reflection + , serokell-util , time-units , universum , unordered-containers diff --git a/core/test/golden/ApplicationName b/chain/test/golden/ApplicationName similarity index 100% rename from core/test/golden/ApplicationName rename to chain/test/golden/ApplicationName diff --git a/core/test/golden/BlockVersion b/chain/test/golden/BlockVersion similarity index 100% rename from core/test/golden/BlockVersion rename to chain/test/golden/BlockVersion diff --git a/core/test/golden/BlockVersionData b/chain/test/golden/BlockVersionData similarity index 100% rename from core/test/golden/BlockVersionData rename to chain/test/golden/BlockVersionData diff --git a/core/test/golden/BlockVersionModifier b/chain/test/golden/BlockVersionModifier similarity index 100% rename from core/test/golden/BlockVersionModifier rename to chain/test/golden/BlockVersionModifier diff --git a/core/test/golden/HashRaw b/chain/test/golden/HashRaw similarity index 100% rename from core/test/golden/HashRaw rename to chain/test/golden/HashRaw diff --git a/core/test/golden/SoftforkRule b/chain/test/golden/SoftforkRule similarity index 100% rename from core/test/golden/SoftforkRule rename to chain/test/golden/SoftforkRule diff --git a/core/test/golden/SoftwareVersion b/chain/test/golden/SoftwareVersion similarity index 100% rename from core/test/golden/SoftwareVersion rename to chain/test/golden/SoftwareVersion diff --git a/core/test/golden/SystemTag b/chain/test/golden/SystemTag similarity index 100% rename from core/test/golden/SystemTag rename to chain/test/golden/SystemTag diff --git a/core/test/golden/UpAttributes b/chain/test/golden/UpAttributes similarity index 100% rename from core/test/golden/UpAttributes rename to chain/test/golden/UpAttributes diff --git a/core/test/golden/UpId b/chain/test/golden/UpId similarity index 100% rename from core/test/golden/UpId rename to chain/test/golden/UpId diff --git a/core/test/golden/UpdateData b/chain/test/golden/UpdateData similarity index 100% rename from core/test/golden/UpdateData rename to chain/test/golden/UpdateData diff --git a/core/test/golden/UpdatePayload b/chain/test/golden/UpdatePayload similarity index 100% rename from core/test/golden/UpdatePayload rename to chain/test/golden/UpdatePayload diff --git a/core/test/golden/UpdateProof b/chain/test/golden/UpdateProof similarity index 100% rename from core/test/golden/UpdateProof rename to chain/test/golden/UpdateProof diff --git a/core/test/golden/UpdateProposal b/chain/test/golden/UpdateProposal similarity index 100% rename from core/test/golden/UpdateProposal rename to chain/test/golden/UpdateProposal diff --git a/core/test/golden/UpdateProposalToSign b/chain/test/golden/UpdateProposalToSign similarity index 100% rename from core/test/golden/UpdateProposalToSign rename to chain/test/golden/UpdateProposalToSign diff --git a/core/test/golden/UpdateProposals b/chain/test/golden/UpdateProposals similarity index 100% rename from core/test/golden/UpdateProposals rename to chain/test/golden/UpdateProposals diff --git a/core/test/golden/UpdateVote b/chain/test/golden/UpdateVote similarity index 100% rename from core/test/golden/UpdateVote rename to chain/test/golden/UpdateVote diff --git a/core/test/golden/VoteId b/chain/test/golden/VoteId similarity index 100% rename from core/test/golden/VoteId rename to chain/test/golden/VoteId diff --git a/chain/test/test.hs b/chain/test/test.hs index 3f93d2c0ba5..f6370978ae0 100644 --- a/chain/test/test.hs +++ b/chain/test/test.hs @@ -11,6 +11,8 @@ import qualified Test.Pos.Chain.Ssc.Bi import qualified Test.Pos.Chain.Ssc.Json import qualified Test.Pos.Chain.Txp.Bi import qualified Test.Pos.Chain.Txp.Json +import qualified Test.Pos.Chain.Update.Bi +import qualified Test.Pos.Chain.Update.Json import Test.Pos.Util.Tripping (runTests) main :: IO () @@ -24,4 +26,6 @@ main = do , Test.Pos.Chain.Ssc.Json.tests , Test.Pos.Chain.Txp.Bi.tests , Test.Pos.Chain.Txp.Json.tests + , Test.Pos.Chain.Update.Bi.tests + , Test.Pos.Chain.Update.Json.tests ] diff --git a/client/src/Pos/Client/Txp/Util.hs b/client/src/Pos/Client/Txp/Util.hs index 3c468929a9b..d16ef020cba 100644 --- a/client/src/Pos/Client/Txp/Util.hs +++ b/client/src/Pos/Client/Txp/Util.hs @@ -70,6 +70,7 @@ import Pos.Chain.Script.Examples (multisigRedeemer, multisigValidator) import Pos.Chain.Txp (Tx (..), TxAux (..), TxFee (..), TxIn (..), TxInWitness (..), TxOut (..), TxOutAux (..), TxSigData (..), Utxo) +import Pos.Chain.Update (bvdTxFeePolicy) import Pos.Client.Txp.Addresses (MonadAddresses (..)) import Pos.Core (Address, Coin, SlotCount, StakeholderId, TxFeePolicy (..), TxSizeLinear (..), @@ -77,7 +78,6 @@ import Pos.Core (Address, Coin, SlotCount, StakeholderId, isRedeemAddress, mkCoin, sumCoins, txSizeLinearMinValue, unsafeIntegerToCoin, unsafeSubCoin) import Pos.Core.Attributes (mkAttributes) -import Pos.Core.Update (bvdTxFeePolicy) import Pos.Crypto (ProtocolMagic, RedeemSecretKey, SafeSigner, SignTag (SignRedeemTx, SignTx), deterministicKeyGen, fakeSigner, hash, redeemSign, redeemToPublic, safeSign, diff --git a/client/test/Test/Pos/Client/Txp/Mode.hs b/client/test/Test/Pos/Client/Txp/Mode.hs index aa46a941a7c..639e8fe2da0 100644 --- a/client/test/Test/Pos/Client/Txp/Mode.hs +++ b/client/test/Test/Pos/Client/Txp/Mode.hs @@ -16,9 +16,9 @@ import qualified Data.ByteString as BS import Test.QuickCheck (Testable (..), ioProperty) import Test.QuickCheck.Monadic (PropertyM, monadic) +import Pos.Chain.Update (BlockVersionData) import Pos.Client.Txp.Addresses (MonadAddresses (..)) import Pos.Core (Address, makePubKeyAddressBoot) -import Pos.Core.Update (BlockVersionData) import Pos.Crypto (deterministicKeyGen) import Pos.DB (MonadGState (..)) diff --git a/client/test/Test/Pos/Client/Txp/UtilSpec.hs b/client/test/Test/Pos/Client/Txp/UtilSpec.hs index 790140b313a..9c547026c39 100644 --- a/client/test/Test/Pos/Client/Txp/UtilSpec.hs +++ b/client/test/Test/Pos/Client/Txp/UtilSpec.hs @@ -23,6 +23,7 @@ import Test.QuickCheck.Monadic (forAllM, stop) import Pos.Chain.Txp (Tx (..), TxAux (..), TxId, TxIn (..), TxOut (..), TxOutAux (..), Utxo) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Client.Txp.Addresses (MonadAddresses (..)) import Pos.Client.Txp.Util (InputSelectionPolicy (..), TxError (..), TxOutputs, TxWithSpendings, createMTx, createRedemptionTx, @@ -30,7 +31,6 @@ import Pos.Client.Txp.Util (InputSelectionPolicy (..), TxError (..), import Pos.Core (Address, Coeff (..), TxFeePolicy (..), TxSizeLinear (..), makePubKeyAddressBoot, makeRedeemAddress, unsafeIntegerToCoin) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (RedeemSecretKey, SafeSigner, SecretKey, decodeHash, fakeSigner, redeemToPublic, toPublic) import Pos.DB (gsAdoptedBVData) diff --git a/core/cardano-sl-core.cabal b/core/cardano-sl-core.cabal index ca2348d0c99..4aa98eaa8e3 100644 --- a/core/cardano-sl-core.cabal +++ b/core/cardano-sl-core.cabal @@ -51,7 +51,6 @@ library Pos.Core.Script Pos.Core.Slotting - Pos.Core.Update Pos.Core.Util.LogSafe Pos.Core.Util.TimeLimit @@ -109,19 +108,6 @@ library Pos.Core.Reporting.Methods Pos.Core.Reporting.Metrics - -- Update - Pos.Core.Update.ApplicationName - Pos.Core.Update.BlockVersion - Pos.Core.Update.BlockVersionData - Pos.Core.Update.BlockVersionModifier - Pos.Core.Update.Data - Pos.Core.Update.Payload - Pos.Core.Update.Proof - Pos.Core.Update.SoftforkRule - Pos.Core.Update.SoftwareVersion - Pos.Core.Update.SystemTag - Pos.Core.Update.Vote - build-depends: aeson , aeson-options , ansi-terminal diff --git a/core/src/Pos/Core/Update.hs b/core/src/Pos/Core/Update.hs deleted file mode 100644 index 6a16e84ef43..00000000000 --- a/core/src/Pos/Core/Update.hs +++ /dev/null @@ -1,25 +0,0 @@ -module Pos.Core.Update - ( module Pos.Core.Update.ApplicationName - , module Pos.Core.Update.BlockVersion - , module Pos.Core.Update.BlockVersionData - , module Pos.Core.Update.BlockVersionModifier - , module Pos.Core.Update.Data - , module Pos.Core.Update.Payload - , module Pos.Core.Update.Proof - , module Pos.Core.Update.SoftforkRule - , module Pos.Core.Update.SoftwareVersion - , module Pos.Core.Update.SystemTag - , module Pos.Core.Update.Vote - ) where - -import Pos.Core.Update.ApplicationName -import Pos.Core.Update.BlockVersion -import Pos.Core.Update.BlockVersionData -import Pos.Core.Update.BlockVersionModifier -import Pos.Core.Update.Data -import Pos.Core.Update.Payload -import Pos.Core.Update.Proof -import Pos.Core.Update.SoftforkRule -import Pos.Core.Update.SoftwareVersion -import Pos.Core.Update.SystemTag -import Pos.Core.Update.Vote diff --git a/core/src/Pos/Core/Update/BlockVersion.hs b/core/src/Pos/Core/Update/BlockVersion.hs deleted file mode 100644 index e51f180ea62..00000000000 --- a/core/src/Pos/Core/Update/BlockVersion.hs +++ /dev/null @@ -1,52 +0,0 @@ -{-# LANGUAGE RecordWildCards #-} - -module Pos.Core.Update.BlockVersion - ( BlockVersion (..) - , HasBlockVersion (..) - ) where - -import Universum - -import Data.Aeson.TH (defaultOptions, deriveJSON) -import Data.SafeCopy (base, deriveSafeCopySimple) -import Formatting (bprint, shown) -import qualified Formatting.Buildable as Buildable -import qualified Prelude - -import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) -import Pos.Util.Some (Some, liftLensSome) - --- | Communication protocol version. -data BlockVersion = BlockVersion - { bvMajor :: !Word16 - , bvMinor :: !Word16 - , bvAlt :: !Word8 - } deriving (Eq, Generic, Ord, Typeable) - -instance Show BlockVersion where - show BlockVersion {..} = - intercalate "." [show bvMajor, show bvMinor, show bvAlt] - -instance Buildable BlockVersion where - build = bprint shown - -instance Hashable BlockVersion - -instance NFData BlockVersion - -class HasBlockVersion a where - blockVersionL :: Lens' a BlockVersion - -instance HasBlockVersion (Some HasBlockVersion) where - blockVersionL = liftLensSome blockVersionL - -deriveJSON defaultOptions ''BlockVersion - -deriveSimpleBi ''BlockVersion [ - Cons 'BlockVersion [ - Field [| bvMajor :: Word16 |], - Field [| bvMinor :: Word16 |], - Field [| bvAlt :: Word8 |] - ]] - -deriveSafeCopySimple 0 'base ''BlockVersion diff --git a/core/src/Pos/Core/Update/Types.hs b/core/src/Pos/Core/Update/Types.hs deleted file mode 100644 index 71cb4ffaeeb..00000000000 --- a/core/src/Pos/Core/Update/Types.hs +++ /dev/null @@ -1,638 +0,0 @@ -{-# LANGUAGE DeriveLift #-} -{-# LANGUAGE RecordWildCards #-} - --- | Core types related to update system. - -module Pos.Core.Update.Types - ( - -- * Version - ApplicationName (..) - , applicationNameMaxLength - , checkApplicationName - , BlockVersion (..) - , NumSoftwareVersion - , SoftwareVersion (..) - , checkSoftwareVersion - - -- * Data associated with block version - , SoftforkRule (..) - , BlockVersionData (..) - , BlockVersionModifier (..) - - -- * UpdateProposal and related - , UpdateProposal (..) - , UpdateProposals - , UpId - , UpAttributes - , UpdateData (..) - , UpdateProposalToSign (..) - , SystemTag (..) - , checkSystemTag - , systemTagMaxLength - - -- * UpdateVote and related - , UpdateVote (..) - , mkUpdateVote - , mkUpdateVoteSafe - , VoteId - , formatVoteShort - , shortVoteF - - -- * Payload and proof - , UpdatePayload (..) - , UpdateProof - , mkUpdateProof - ) where - -import Universum - -import Control.Monad.Except (MonadError (throwError)) -import Data.Char (isAscii) -import Data.Default (Default (..)) -import Data.Hashable (Hashable) -import qualified Data.HashMap.Strict as HM -import qualified Data.Text as T -import Data.Text.Lazy.Builder (Builder) -import Data.Time.Units (Millisecond) -import Formatting (Format, bprint, build, builder, int, later, shown, - stext, (%)) -import qualified Formatting.Buildable as Buildable -import Instances.TH.Lift () -import Language.Haskell.TH.Syntax (Lift) -import qualified Prelude -import Serokell.Data.Memory.Units (Byte, memory) -import Serokell.Util.Text (listJson) - -import Pos.Binary.Class (Bi (..), Cons (..), Field (..), Raw, - deriveSimpleBi, encodeListLen, enforceSize) -import Pos.Core.Attributes (Attributes, areAttributesKnown) -import Pos.Core.Common (CoinPortion, ScriptVersion, TxFeePolicy, - addressHash) -import Pos.Core.Slotting.Types (EpochIndex, FlatSlotId) -import Pos.Crypto (Hash, ProtocolMagic, PublicKey, SafeSigner, - SecretKey, SignTag (SignUSVote), Signature, hash, - safeSign, safeToPublic, shortHashF, sign, toPublic) -import Pos.Util.Orphans () - ----------------------------------------------------------------------------- --- Version ----------------------------------------------------------------------------- - --- | Communication protocol version. -data BlockVersion = BlockVersion - { bvMajor :: !Word16 - , bvMinor :: !Word16 - , bvAlt :: !Word8 - } deriving (Eq, Generic, Ord, Typeable) - -newtype ApplicationName = ApplicationName - { getApplicationName :: Text - } deriving (Eq, Ord, Show, Generic, Typeable, ToString, Hashable, Buildable, NFData) - -instance Bi ApplicationName where - encode appName = encode (getApplicationName appName) - decode = ApplicationName <$> decode - --- | Smart constructor of 'ApplicationName'. -checkApplicationName :: MonadError Text m => ApplicationName -> m () -checkApplicationName (ApplicationName appName) - | length appName > applicationNameMaxLength = - throwError "ApplicationName: too long string passed" - | T.any (not . isAscii) appName = - throwError "ApplicationName: not ascii string passed" - | otherwise = pure () - -applicationNameMaxLength :: Integral i => i -applicationNameMaxLength = 12 - --- | Numeric software version associated with ApplicationName. -type NumSoftwareVersion = Word32 - --- | Software version. -data SoftwareVersion = SoftwareVersion - { svAppName :: !ApplicationName - , svNumber :: !NumSoftwareVersion - } deriving (Eq, Generic, Ord, Typeable) - -instance Buildable SoftwareVersion where - build SoftwareVersion {..} = - bprint (stext % ":" % int) (getApplicationName svAppName) svNumber - -instance Show SoftwareVersion where - show = toString . pretty - -instance Show BlockVersion where - show BlockVersion {..} = - intercalate "." [show bvMajor, show bvMinor, show bvAlt] - -instance Buildable BlockVersion where - build = bprint shown - -instance Hashable SoftwareVersion -instance Hashable BlockVersion - -instance NFData BlockVersion -instance NFData SoftwareVersion - --- | A software version is valid iff its application name is valid. -checkSoftwareVersion :: MonadError Text m => SoftwareVersion -> m () -checkSoftwareVersion sv = checkApplicationName (svAppName sv) - ----------------------------------------------------------------------------- --- Values updatable by update system ----------------------------------------------------------------------------- - --- | Values defining softfork resolution rule. --- If a proposal is confirmed at the 's'-th epoch, softfork resolution threshold --- at the 't'-th epoch will be --- 'max spMinThd (spInitThd - (t - s) * spThdDecrement)'. --- --- Softfork resolution threshold is the portion of total stake such --- that if total stake of issuers of blocks with some block version is --- greater than this portion, this block version becomes adopted. -data SoftforkRule = SoftforkRule - { srInitThd :: !CoinPortion - -- ^ Initial threshold (right after proposal is confirmed). - , srMinThd :: !CoinPortion - -- ^ Minimal threshold (i. e. threshold can't become less than - -- this one). - , srThdDecrement :: !CoinPortion - -- ^ Theshold will be decreased by this value after each epoch. - } deriving (Show, Eq, Ord, Generic) - -instance Hashable SoftforkRule -instance NFData SoftforkRule - -instance Buildable SoftforkRule where - build SoftforkRule {..} = - bprint ("(init = "%build%", min = "%build%", decrement = "%build%")") - srInitThd srMinThd srThdDecrement - --- | Data which is associated with 'BlockVersion'. -data BlockVersionData = BlockVersionData - { bvdScriptVersion :: !ScriptVersion - , bvdSlotDuration :: !Millisecond - , bvdMaxBlockSize :: !Byte - , bvdMaxHeaderSize :: !Byte - , bvdMaxTxSize :: !Byte - , bvdMaxProposalSize :: !Byte - , bvdMpcThd :: !CoinPortion - , bvdHeavyDelThd :: !CoinPortion - , bvdUpdateVoteThd :: !CoinPortion - , bvdUpdateProposalThd :: !CoinPortion - , bvdUpdateImplicit :: !FlatSlotId - , bvdSoftforkRule :: !SoftforkRule - , bvdTxFeePolicy :: !TxFeePolicy - , bvdUnlockStakeEpoch :: !EpochIndex - } deriving (Show, Eq, Ord, Generic, Typeable) - -instance NFData BlockVersionData where - -instance Buildable BlockVersionData where - build BlockVersionData {..} = - bprint ("{ script version: "%build% - ", slot duration: "%int%" mcs"% - ", block size limit: "%memory% - ", header size limit: "%memory% - ", tx size limit: "%memory% - ", proposal size limit: "%memory% - ", mpc threshold: "%build% - ", heavyweight delegation threshold: "%build% - ", update vote threshold: "%build% - ", update proposal threshold: "%build% - ", update implicit period: "%int%" slots"% - ", softfork rule: "%build% - ", tx fee policy: "%build% - ", unlock stake epoch: "%build% - " }") - bvdScriptVersion - bvdSlotDuration - bvdMaxBlockSize - bvdMaxHeaderSize - bvdMaxTxSize - bvdMaxProposalSize - bvdMpcThd - bvdHeavyDelThd - bvdUpdateVoteThd - bvdUpdateProposalThd - bvdUpdateImplicit - bvdSoftforkRule - bvdTxFeePolicy - bvdUnlockStakeEpoch - --- | Data which represents modifications of block (aka protocol) version. -data BlockVersionModifier = BlockVersionModifier - { bvmScriptVersion :: !(Maybe ScriptVersion) - , bvmSlotDuration :: !(Maybe Millisecond) - , bvmMaxBlockSize :: !(Maybe Byte) - , bvmMaxHeaderSize :: !(Maybe Byte) - , bvmMaxTxSize :: !(Maybe Byte) - , bvmMaxProposalSize :: !(Maybe Byte) - , bvmMpcThd :: !(Maybe CoinPortion) - , bvmHeavyDelThd :: !(Maybe CoinPortion) - , bvmUpdateVoteThd :: !(Maybe CoinPortion) - , bvmUpdateProposalThd :: !(Maybe CoinPortion) - , bvmUpdateImplicit :: !(Maybe FlatSlotId) - , bvmSoftforkRule :: !(Maybe SoftforkRule) - , bvmTxFeePolicy :: !(Maybe TxFeePolicy) - , bvmUnlockStakeEpoch :: !(Maybe EpochIndex) - } deriving (Show, Eq, Ord, Generic, Typeable) - -instance NFData BlockVersionModifier -instance Hashable BlockVersionModifier - -instance Default BlockVersionModifier where - def = BlockVersionModifier - { bvmScriptVersion = Nothing - , bvmSlotDuration = Nothing - , bvmMaxBlockSize = Nothing - , bvmMaxHeaderSize = Nothing - , bvmMaxTxSize = Nothing - , bvmMaxProposalSize = Nothing - , bvmMpcThd = Nothing - , bvmHeavyDelThd = Nothing - , bvmUpdateVoteThd = Nothing - , bvmUpdateProposalThd = Nothing - , bvmUpdateImplicit = Nothing - , bvmSoftforkRule = Nothing - , bvmTxFeePolicy = Nothing - , bvmUnlockStakeEpoch = Nothing - } - -instance Buildable BlockVersionModifier where - build BlockVersionModifier {..} = - bprint ("{ script version: "%bmodifier build% - ", slot duration (mcs): "%bmodifier int% - ", block size limit: "%bmodifier memory% - ", header size limit: "%bmodifier memory% - ", tx size limit: "%bmodifier memory% - ", proposal size limit: "%bmodifier memory% - ", mpc threshold: "%bmodifier build% - ", heavyweight delegation threshold: "%bmodifier build% - ", update vote threshold: "%bmodifier build% - ", update proposal threshold: "%bmodifier build% - ", update implicit period (slots): "%bmodifier int% - ", softfork rule: "%bmodifier build% - ", tx fee policy: "%bmodifier build% - ", unlock stake epoch: "%bmodifier build% - " }") - bvmScriptVersion - bvmSlotDuration - bvmMaxBlockSize - bvmMaxHeaderSize - bvmMaxTxSize - bvmMaxProposalSize - bvmMpcThd - bvmHeavyDelThd - bvmUpdateVoteThd - bvmUpdateProposalThd - bvmUpdateImplicit - bvmSoftforkRule - bvmTxFeePolicy - bvmUnlockStakeEpoch - where - bmodifier :: Format Builder (a -> Builder) -> Format r (Maybe a -> r) - bmodifier b = later $ maybe "no change" (bprint b) - ----------------------------------------------------------------------------- --- UpdateProposal and related ----------------------------------------------------------------------------- - --- | Tag of system for which update data is purposed, e.g. win64, mac32 -newtype SystemTag = SystemTag { getSystemTag :: Text } - deriving (Eq, Ord, Show, Generic, Buildable, Hashable, Lift, Typeable) - -instance Bi SystemTag where - encode = encode . getSystemTag - decode = SystemTag <$> decode - -systemTagMaxLength :: Integral i => i -systemTagMaxLength = 10 - -checkSystemTag :: MonadError Text m => SystemTag -> m () -checkSystemTag (SystemTag tag) - | T.length tag > systemTagMaxLength - = throwError "SystemTag: too long string passed" - | T.any (not . isAscii) tag - = throwError "SystemTag: not ascii string passed" - | otherwise - = pure () - --- | ID of software update proposal -type UpId = Hash UpdateProposal - -type UpAttributes = Attributes () - -data UpdateProposalToSign - = UpdateProposalToSign - { upsBV :: !BlockVersion - , upsBVM :: !BlockVersionModifier - , upsSV :: !SoftwareVersion - , upsData :: !(HM.HashMap SystemTag UpdateData) - , upsAttr :: !UpAttributes - } deriving (Eq, Show, Generic) - --- | Proposal for software update -data UpdateProposal = UnsafeUpdateProposal - { upBlockVersion :: !BlockVersion - , upBlockVersionMod :: !BlockVersionModifier - , upSoftwareVersion :: !SoftwareVersion - , upData :: !(HM.HashMap SystemTag UpdateData) - -- ^ UpdateData for each system which this update affects. - -- It must be non-empty. - , upAttributes :: !UpAttributes - -- ^ Attributes which are currently empty, but provide - -- extensibility. - , upFrom :: !PublicKey - -- ^ Who proposed this UP. - , upSignature :: !(Signature UpdateProposalToSign) - } deriving (Eq, Show, Generic, Typeable) - -type UpdateProposals = HashMap UpId UpdateProposal - -instance Hashable UpdateProposal - -instance Bi UpdateProposal where - encode up = encodeListLen 7 - <> encode (upBlockVersion up) - <> encode (upBlockVersionMod up) - <> encode (upSoftwareVersion up) - <> encode (upData up) - <> encode (upAttributes up) - <> encode (upFrom up) - <> encode (upSignature up) - decode = do - enforceSize "UpdateProposal" 7 - UnsafeUpdateProposal <$> decode - <*> decode - <*> decode - <*> decode - <*> decode - <*> decode - <*> decode - -instance Buildable (UpdateProposal, [UpdateVote]) where - build (up, votes) = - bprint - (build % " with votes: " %listJson) - up - (map formatVoteShort votes) - -instance Buildable UpdateProposal where - build up@UnsafeUpdateProposal {..} = - bprint (build% - " { block v"%build% - ", UpId: "%build% - ", "%build% - ", tags: "%listJson% - ", "%builder% - " }") - upSoftwareVersion - upBlockVersion - (hash up) - upBlockVersionMod - (HM.keys upData) - attrsBuilder - where - attrs = upAttributes - attrsBuilder - | areAttributesKnown upAttributes = "no attributes" - | otherwise = bprint ("attributes: " %build) attrs - --- | Data which describes update. It is specific for each system. -data UpdateData = UpdateData - { udAppDiffHash :: !(Hash Raw) - -- ^ Hash of binary diff between two applications. This diff can - -- be passed to updater to create new application. - , udPkgHash :: !(Hash Raw) - -- ^ Hash of package to install new application. This package can - -- be used to install new application from scratch instead of - -- updating existing application. - , udUpdaterHash :: !(Hash Raw) - -- ^ Hash if update application which can be used to install this - -- update (relevant only when updater is used, not package). - , udMetadataHash :: !(Hash Raw) - -- ^ Hash of metadata relevant to this update. It is raw hash, - -- because metadata can include image or something - -- (maybe). Anyway, we can always use `unsafeHash`. - } deriving (Eq, Show, Generic, Typeable) - - -instance NFData SystemTag -instance NFData UpdateProposal --- Proper NFData Millisecond instance should be defined in --- time-units. I'm sorry for this. volhovm. -instance NFData UpdateData - -instance Hashable UpdateData - -instance Buildable UpdateData where - build UpdateData {..} = - bprint ("{ appDiff: "%build% - ", pkg: "%build% - ", updater: "%build% - ", metadata: "%build% - " }") - udAppDiffHash - udPkgHash - udUpdaterHash - udMetadataHash - ----------------------------------------------------------------------------- --- UpdateVote and related ----------------------------------------------------------------------------- - -type VoteId = (UpId, PublicKey, Bool) - --- | Vote for update proposal. --- --- Invariants: --- * The signature is valid. -data UpdateVote = UnsafeUpdateVote - { -- | Public key of stakeholder, who votes - uvKey :: !PublicKey - , -- | Proposal to which this vote applies - uvProposalId :: !UpId - , -- | Approval/rejection bit - uvDecision :: !Bool - , -- | Signature of (Update proposal, Approval/rejection bit) - -- by stakeholder - uvSignature :: !(Signature (UpId, Bool)) - } deriving (Eq, Show, Generic, Typeable) - -instance NFData UpdateVote - -instance Buildable UpdateVote where - build UnsafeUpdateVote {..} = - bprint ("Update Vote { voter: "%build%", proposal id: "%build%", voter's decision: "%build%" }") - (addressHash uvKey) uvProposalId uvDecision - -instance Bi UpdateVote where - encode uv = encodeListLen 4 - <> encode (uvKey uv) - <> encode (uvProposalId uv) - <> encode (uvDecision uv) - <> encode (uvSignature uv) - decode = do - enforceSize "UpdateVote" 4 - uvKey <- decode - uvProposalId <- decode - uvDecision <- decode - uvSignature <- decode - pure UnsafeUpdateVote{..} - -instance Buildable VoteId where - build (upId, pk, dec) = - bprint ("Vote Id { voter: "%build%", proposal id: "%build%", voter's decision: "%build%" }") - pk upId dec - --- | A safe constructor for 'UnsafeVote'. -mkUpdateVote - :: ProtocolMagic - -> SecretKey -- ^ The voter - -> UpId -- ^ Proposal which is voted for - -> Bool -- ^ Approval/rejection bit - -> UpdateVote -mkUpdateVote pm sk uvProposalId uvDecision = - let uvSignature = sign pm SignUSVote sk (uvProposalId, uvDecision) - uvKey = toPublic sk - in UnsafeUpdateVote{..} - --- | Same as 'mkUpdateVote', but uses 'SafeSigner'. -mkUpdateVoteSafe - :: ProtocolMagic - -> SafeSigner -- ^ The voter - -> UpId -- ^ Proposal which is voted for - -> Bool -- ^ Approval/rejection bit - -> UpdateVote -mkUpdateVoteSafe pm sk uvProposalId uvDecision = - let uvSignature = safeSign pm SignUSVote sk (uvProposalId, uvDecision) - uvKey = safeToPublic sk - in UnsafeUpdateVote{..} - --- | Format 'UpdateVote' compactly. -formatVoteShort :: UpdateVote -> Builder -formatVoteShort UnsafeUpdateVote {..} = - bprint ("("%shortHashF%" "%builder%" "%shortHashF%")") - (addressHash uvKey) - (bool "against" "for" uvDecision) - uvProposalId - --- | Formatter for 'UpdateVote' which displays it compactly. -shortVoteF :: Format r (UpdateVote -> r) -shortVoteF = later formatVoteShort - ----------------------------------------------------------------------------- --- Payload and proof ----------------------------------------------------------------------------- - --- | Update System payload. 'BodyProof MainBlockchain' contains --- 'UpdateProof' = @Hash UpdatePayload@. -data UpdatePayload = UpdatePayload - { upProposal :: !(Maybe UpdateProposal) - , upVotes :: ![UpdateVote] - } deriving (Eq, Show, Generic, Typeable) - -instance NFData UpdatePayload - -instance Buildable UpdatePayload where - build UpdatePayload {..} - | null upVotes = formatMaybeProposal upProposal <> ", no votes" - | otherwise = - formatMaybeProposal upProposal <> - bprint - ("\n votes: "%listJson) - (map formatVoteShort upVotes) - -formatMaybeProposal :: Maybe UpdateProposal -> Builder -formatMaybeProposal = maybe "no proposal" Buildable.build - -instance Default UpdatePayload where - def = UpdatePayload Nothing [] - --- | Proof that body of update message contains 'UpdatePayload'. -type UpdateProof = Hash UpdatePayload - -mkUpdateProof - :: Bi UpdatePayload - => UpdatePayload -> UpdateProof -mkUpdateProof = hash - -deriveSimpleBi ''BlockVersion [ - Cons 'BlockVersion [ - Field [| bvMajor :: Word16 |], - Field [| bvMinor :: Word16 |], - Field [| bvAlt :: Word8 |] - ]] - -deriveSimpleBi ''SoftwareVersion [ - Cons 'SoftwareVersion [ - Field [| svAppName :: ApplicationName |], - Field [| svNumber :: NumSoftwareVersion |] - ]] - -deriveSimpleBi ''SoftforkRule [ - Cons 'SoftforkRule [ - Field [| srInitThd :: CoinPortion |], - Field [| srMinThd :: CoinPortion |], - Field [| srThdDecrement :: CoinPortion |] - ]] - -deriveSimpleBi ''BlockVersionData [ - Cons 'BlockVersionData [ - Field [| bvdScriptVersion :: ScriptVersion |], - Field [| bvdSlotDuration :: Millisecond |], - Field [| bvdMaxBlockSize :: Byte |], - Field [| bvdMaxHeaderSize :: Byte |], - Field [| bvdMaxTxSize :: Byte |], - Field [| bvdMaxProposalSize :: Byte |], - Field [| bvdMpcThd :: CoinPortion |], - Field [| bvdHeavyDelThd :: CoinPortion |], - Field [| bvdUpdateVoteThd :: CoinPortion |], - Field [| bvdUpdateProposalThd :: CoinPortion |], - Field [| bvdUpdateImplicit :: FlatSlotId |], - Field [| bvdSoftforkRule :: SoftforkRule |], - Field [| bvdTxFeePolicy :: TxFeePolicy |], - Field [| bvdUnlockStakeEpoch :: EpochIndex |] - ]] - -deriveSimpleBi ''BlockVersionModifier [ - Cons 'BlockVersionModifier [ - Field [| bvmScriptVersion :: Maybe ScriptVersion |], - Field [| bvmSlotDuration :: Maybe Millisecond |], - Field [| bvmMaxBlockSize :: Maybe Byte |], - Field [| bvmMaxHeaderSize :: Maybe Byte |], - Field [| bvmMaxTxSize :: Maybe Byte |], - Field [| bvmMaxProposalSize :: Maybe Byte |], - Field [| bvmMpcThd :: Maybe CoinPortion |], - Field [| bvmHeavyDelThd :: Maybe CoinPortion |], - Field [| bvmUpdateVoteThd :: Maybe CoinPortion |], - Field [| bvmUpdateProposalThd :: Maybe CoinPortion |], - Field [| bvmUpdateImplicit :: Maybe FlatSlotId |], - Field [| bvmSoftforkRule :: Maybe SoftforkRule |], - Field [| bvmTxFeePolicy :: Maybe TxFeePolicy |], - Field [| bvmUnlockStakeEpoch :: Maybe EpochIndex |] - ]] - -deriveSimpleBi ''UpdateData [ - Cons 'UpdateData [ - Field [| udAppDiffHash :: Hash Raw |], - Field [| udPkgHash :: Hash Raw |], - Field [| udUpdaterHash :: Hash Raw |], - Field [| udMetadataHash :: Hash Raw |] - ]] - -deriveSimpleBi ''UpdateProposalToSign [ - Cons 'UpdateProposalToSign [ - Field [| upsBV :: BlockVersion |], - Field [| upsBVM :: BlockVersionModifier |], - Field [| upsSV :: SoftwareVersion |], - Field [| upsData :: HashMap SystemTag UpdateData |], - Field [| upsAttr :: UpAttributes |] - ]] - -deriveSimpleBi ''UpdatePayload [ - Cons 'UpdatePayload [ - Field [| upProposal :: Maybe UpdateProposal |], - Field [| upVotes :: [UpdateVote] |] - ]] diff --git a/core/test/Test/Pos/Core/Arbitrary.hs b/core/test/Test/Pos/Core/Arbitrary.hs index ec3921890ba..1260060063c 100644 --- a/core/test/Test/Pos/Core/Arbitrary.hs +++ b/core/test/Test/Pos/Core/Arbitrary.hs @@ -26,7 +26,6 @@ module Test.Pos.Core.Arbitrary import Universum import qualified Data.ByteString as BS (pack) -import Data.List ((!!)) import qualified Data.Map as M import Data.Time.Units (TimeUnit (..)) import System.Random (Random) @@ -53,9 +52,6 @@ import Pos.Core.Attributes (Attributes (..), UnparsedFields (..)) import Pos.Core.Constants (sharedSeedLength) import Pos.Core.Merkle (MerkleTree, mkMerkleTree) import Pos.Core.ProtocolConstants (pcEpochSlots) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), - BlockVersionData (..), SoftforkRule (..), - SoftwareVersion (..), applicationNameMaxLength) import Pos.Util.Util (leftToPanic) import Test.Pos.Core.Dummy (dummyProtocolConstants) @@ -439,35 +435,6 @@ instance Arbitrary SharedSeed where bs <- replicateM sharedSeedLength (choose (0, 255)) return $ SharedSeed $ BS.pack bs -instance Arbitrary SoftforkRule where - arbitrary = genericArbitrary - shrink = genericShrink - -instance Arbitrary BlockVersionData where - arbitrary = genericArbitrary - shrink = genericShrink - ----------------------------------------------------------------------------- --- Arbitrary types from MainExtra[header/body]data ----------------------------------------------------------------------------- - -instance Arbitrary ApplicationName where - arbitrary = - ApplicationName . - toText . map selectAlpha . take applicationNameMaxLength <$> - arbitrary - where - selectAlpha n = alphabet !! (n `mod` length alphabet) - alphabet = "-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - -instance Arbitrary BlockVersion where - arbitrary = genericArbitrary - shrink = genericShrink - -instance Arbitrary SoftwareVersion where - arbitrary = genericArbitrary - shrink = genericShrink - ---------------------------------------------------------------------------- -- Arbitrary types from 'Pos.Core.Fee' ---------------------------------------------------------------------------- diff --git a/core/test/Test/Pos/Core/Bi.hs b/core/test/Test/Pos/Core/Bi.hs index 0b978982be9..721acd79858 100644 --- a/core/test/Test/Pos/Core/Bi.hs +++ b/core/test/Test/Pos/Core/Bi.hs @@ -29,7 +29,6 @@ import Pos.Core.Merkle (mkMerkleTree, mtRoot) import Pos.Core.Slotting (EpochIndex (..), EpochOrSlot (..), FlatSlotId, LocalSlotIndex (..), SlotCount (..), TimeDiff (..), Timestamp (..)) -import Pos.Core.Update (ApplicationName (..), SoftforkRule (..)) import Pos.Crypto (AbstractHash (..), Hash, PublicKey (..), abstractHash, redeemDeterministicKeyGen) @@ -39,15 +38,10 @@ import Test.Pos.Binary.Helpers.GoldenRoundTrip (goldenTestBi, roundTripsBiBuildable, roundTripsBiShow) import Test.Pos.Core.ExampleHelpers (exampleAddrSpendingData_PubKey, exampleAddress, exampleAddress1, exampleAddress2, - exampleAddress3, exampleAddress4, exampleBlockVersion, - exampleBlockVersionData, exampleBlockVersionModifier, - exampleEpochIndex, examplePublicKey, exampleScript, - exampleSlotId, exampleSlotLeaders, exampleSoftwareVersion, - exampleStakeholderId, exampleStakesList, exampleSystemTag, - exampleUpAttributes, exampleUpId, exampleUpdateData, - exampleUpdatePayload, exampleUpdateProof, - exampleUpdateProposal, exampleUpdateProposalToSign, - exampleUpdateVote, exampleVoteId, feedEpochSlots, feedPM) + exampleAddress3, exampleAddress4, exampleEpochIndex, + examplePublicKey, exampleScript, exampleSlotId, + exampleSlotLeaders, exampleStakeholderId, + exampleStakesList, feedEpochSlots) import Test.Pos.Core.Gen import Test.Pos.Crypto.Bi (getBytes) import Test.Pos.Util.Golden (discoverGolden, eachOf) @@ -366,17 +360,6 @@ golden_TimeDiff = goldenTestBi td "test/golden/TimeDiff" roundTripTimeDiffBi :: Property roundTripTimeDiffBi = eachOf 1000 genTimeDiff roundTripsBiBuildable --------------------------------------------------------------------------------- --- ApplicationName --------------------------------------------------------------------------------- - -golden_ApplicationName :: Property -golden_ApplicationName = goldenTestBi aN "test/golden/ApplicationName" - where aN = ApplicationName "Golden" - -roundTripApplicationName :: Property -roundTripApplicationName = eachOf 50 genApplicationName roundTripsBiBuildable - -------------------------------------------------------------------------------- -- Attributes -------------------------------------------------------------------------------- @@ -388,49 +371,6 @@ golden_Attributes = goldenTestBi attrib "test/golden/Attributes" roundTripAttributes :: Property roundTripAttributes = eachOf 50 (genAttributes (pure ())) roundTripsBiShow --------------------------------------------------------------------------------- --- BlockVersion --------------------------------------------------------------------------------- - -golden_BlockVersion :: Property -golden_BlockVersion = goldenTestBi exampleBlockVersion "test/golden/BlockVersion" - -roundTripBlockVersion :: Property -roundTripBlockVersion = eachOf 50 genBlockVersion roundTripsBiBuildable - --------------------------------------------------------------------------------- --- BlockVersionData --------------------------------------------------------------------------------- - -golden_BlockVersionData :: Property -golden_BlockVersionData = goldenTestBi bVerDat "test/golden/BlockVersionData" - where bVerDat = exampleBlockVersionData - -roundTripBlockVersionData :: Property -roundTripBlockVersionData = eachOf 50 genBlockVersionData roundTripsBiBuildable - --------------------------------------------------------------------------------- --- BlockVersionModifier --------------------------------------------------------------------------------- - -golden_BlockVersionModifier :: Property -golden_BlockVersionModifier = goldenTestBi bVerMod "test/golden/BlockVersionModifier" - where bVerMod = exampleBlockVersionModifier - -roundTripBlockVersionModifier :: Property -roundTripBlockVersionModifier = eachOf 50 genBlockVersionModifier roundTripsBiBuildable - --------------------------------------------------------------------------------- --- HashRaw --------------------------------------------------------------------------------- - -golden_BlockHashRaw :: Property -golden_BlockHashRaw = goldenTestBi hRaw "test/golden/HashRaw" - where hRaw = (abstractHash $ Raw ("9" ) :: Hash Raw) - -roundTripHashRaw :: Property -roundTripHashRaw = eachOf 50 genHashRaw roundTripsBiBuildable - -------------------------------------------------------------------------------- -- MerkleTree -------------------------------------------------------------------------------- @@ -454,37 +394,6 @@ golden_MerkleRoot = goldenTestBi mTree "test/golden/MerkleRoot" roundTripMerkleRoot :: Property roundTripMerkleRoot = eachOf 10 (genMerkleRoot genHashRaw) roundTripsBiBuildable --------------------------------------------------------------------------------- --- SoftforkRule --------------------------------------------------------------------------------- - -golden_SoftforkRule :: Property -golden_SoftforkRule = goldenTestBi sfR "test/golden/SoftforkRule" - where sfR = SoftforkRule (CoinPortion 99) (CoinPortion 99) (CoinPortion 99) - -roundTripSoftforkRule :: Property -roundTripSoftforkRule = eachOf 10 genSoftforkRule roundTripsBiBuildable - --------------------------------------------------------------------------------- --- SoftwareVersion --------------------------------------------------------------------------------- - -golden_SoftwareVersion :: Property -golden_SoftwareVersion = goldenTestBi exampleSoftwareVersion "test/golden/SoftwareVersion" - -roundTripSoftwareVersion :: Property -roundTripSoftwareVersion = eachOf 10 genSoftwareVersion roundTripsBiBuildable - --------------------------------------------------------------------------------- --- SystemTag --------------------------------------------------------------------------------- - -golden_SystemTag :: Property -golden_SystemTag = goldenTestBi exampleSystemTag "test/golden/SystemTag" - -roundTripSystemTag :: Property -roundTripSystemTag = eachOf 10 genSystemTag roundTripsBiBuildable - -------------------------------------------------------------------------------- -- TimeStamp -------------------------------------------------------------------------------- @@ -497,117 +406,6 @@ golden_Timestamp = goldenTestBi timeStamp "test/golden/TimeStamp" roundTripTimestamp :: Property roundTripTimestamp = eachOf 50 genTimestamp roundTripsBiBuildable --------------------------------------------------------------------------------- --- UpAttributes --------------------------------------------------------------------------------- - -golden_UpAttributes :: Property -golden_UpAttributes = goldenTestBi exampleUpAttributes "test/golden/UpAttributes" - -roundTripUpAttributes :: Property -roundTripUpAttributes = eachOf 20 genUpAttributes roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpdateData --------------------------------------------------------------------------------- - -golden_UpdateData :: Property -golden_UpdateData = goldenTestBi exampleUpdateData "test/golden/UpdateData" - -roundTripUpdateData :: Property -roundTripUpdateData = eachOf 20 genUpdateData roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpdatePayload --------------------------------------------------------------------------------- - -golden_UpdatePayload :: Property -golden_UpdatePayload = goldenTestBi exampleUpdatePayload "test/golden/UpdatePayload" - -roundTripUpdatePayload :: Property -roundTripUpdatePayload = eachOf 20 (feedPM genUpdatePayload) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpdateProof --------------------------------------------------------------------------------- - -golden_UpdateProof :: Property -golden_UpdateProof = goldenTestBi exampleUpdateProof "test/golden/UpdateProof" - -roundTripUpdateProof :: Property -roundTripUpdateProof = eachOf 20 (feedPM genUpdateProof) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpdateProposal --------------------------------------------------------------------------------- - -golden_UpdateProposal :: Property -golden_UpdateProposal = goldenTestBi exampleUpdateProposal "test/golden/UpdateProposal" - -roundTripUpdateProposal :: Property -roundTripUpdateProposal = eachOf 20 (feedPM genUpdateProposal) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpdateProposals --------------------------------------------------------------------------------- - -golden_UpdateProposals :: Property -golden_UpdateProposals = goldenTestBi ups "test/golden/UpdateProposals" - where - -- Need to revisit this. - ups = HM.fromList [(exampleUpId, exampleUpdateProposal)] - -roundTripUpdateProposals :: Property -roundTripUpdateProposals = eachOf 20 (feedPM genUpdateProposals) roundTripsBiShow - --------------------------------------------------------------------------------- --- UpdateProposalToSign --------------------------------------------------------------------------------- - -golden_UpdateProposalToSign :: Property -golden_UpdateProposalToSign = - goldenTestBi exampleUpdateProposalToSign "test/golden/UpdateProposalToSign" - -roundTripUpdateProposalToSign :: Property -roundTripUpdateProposalToSign = eachOf 20 genUpdateProposalToSign roundTripsBiShow - --------------------------------------------------------------------------------- --- UpdateVote --------------------------------------------------------------------------------- - -golden_UpdateVote :: Property -golden_UpdateVote = goldenTestBi exampleUpdateVote "test/golden/UpdateVote" - -roundTripUpdateVote :: Property -roundTripUpdateVote = eachOf 20 (feedPM genUpdateVote) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpId --------------------------------------------------------------------------------- - -golden_UpId :: Property -golden_UpId = goldenTestBi exampleUpId "test/golden/UpId" - -roundTripUpId :: Property -roundTripUpId = eachOf 20 (feedPM genUpId) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- UpsData NB: UpsData is not a type it is a record accessor of `UpdateProposalToSign` --------------------------------------------------------------------------------- - -roundTripUpsData :: Property -roundTripUpsData = eachOf 20 genUpsData roundTripsBiShow - --------------------------------------------------------------------------------- --- VoteId --------------------------------------------------------------------------------- - -golden_VoteId :: Property -golden_VoteId = goldenTestBi exampleVoteId "test/golden/VoteId" - -roundTripVoteId :: Property -roundTripVoteId = eachOf 20 (feedPM genVoteId) roundTripsBiBuildable - sizeEstimates :: H.Group sizeEstimates = let check :: forall a. (Show a, Bi a) => Gen a -> Property diff --git a/core/test/Test/Pos/Core/CborSpec.hs b/core/test/Test/Pos/Core/CborSpec.hs index 6101e26110c..197353b2642 100644 --- a/core/test/Test/Pos/Core/CborSpec.hs +++ b/core/test/Test/Pos/Core/CborSpec.hs @@ -21,9 +21,6 @@ import Pos.Binary.Class (Bi (..), Cons (..), Field (..), deriveSimpleBi, serialize, unsafeDeserialize) import Pos.Core import Pos.Core.Common (ScriptVersion) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), - BlockVersionData (..), SoftforkRule (..), - SoftwareVersion (..)) import Pos.Core.Attributes (Attributes (..), decodeAttributes, encodeAttributes) @@ -100,8 +97,6 @@ spec = describe "Cbor Bi instances" $ do binaryTest @EpochOrSlot binaryTest @SharedSeed binaryTest @ChainDifficulty - binaryTest @SoftforkRule - binaryTest @BlockVersionData binaryTest @(Attributes ()) binaryTest @(Attributes AddrAttributes) describe "Core.Fee" $ do @@ -110,9 +105,5 @@ spec = describe "Cbor Bi instances" $ do binaryTest @TxFeePolicy describe "Core.Script" $ do binaryTest @Script - describe "Core.Version" $ do - binaryTest @ApplicationName - binaryTest @SoftwareVersion - binaryTest @BlockVersion describe "Merkle" $ do binaryTest @(MerkleTree Int32) diff --git a/core/test/Test/Pos/Core/ExampleHelpers.hs b/core/test/Test/Pos/Core/ExampleHelpers.hs index f1640017869..270c1c0969f 100644 --- a/core/test/Test/Pos/Core/ExampleHelpers.hs +++ b/core/test/Test/Pos/Core/ExampleHelpers.hs @@ -7,34 +7,22 @@ module Test.Pos.Core.ExampleHelpers , exampleAddress2 , exampleAddress3 , exampleAddress4 - , exampleBlockVersion - , exampleBlockVersionData - , exampleBlockVersionModifier + , exampleAttributes , exampleChainDifficulty , exampleEpochIndex , examplePublicKey , examplePublicKeys , exampleRedeemPublicKey + , exampleSafeSigner , exampleScript , exampleSecretKey , exampleSecretKeys , exampleSharedSeed , exampleSlotId , exampleSlotLeaders - , exampleSoftwareVersion , exampleStakeholderId , exampleStakeholderIds , exampleStakesList - , exampleSystemTag - , exampleUpdateData - , exampleUpdatePayload - , exampleUpdateProof - , exampleUpdateProposal - , exampleUpdateProposalToSign - , exampleUpdateVote - , exampleUpAttributes - , exampleUpId - , exampleVoteId , exampleVssPublicKeys , staticSafeSigners @@ -44,45 +32,33 @@ module Test.Pos.Core.ExampleHelpers , feedPMC , feedEpochSlots , feedPMEpochSlots + , getText ) where import Universum -import Data.Fixed (Fixed (..)) -import qualified Data.HashMap.Strict as HM import Data.List ((!!)) import Data.List.NonEmpty (fromList) import qualified Data.Map as M import Data.Maybe (fromJust) import qualified Data.Text as T -import Data.Time.Units (Millisecond) import qualified Hedgehog as H -import Serokell.Data.Memory.Units (Byte) import qualified Cardano.Crypto.Wallet as CC -import Pos.Binary.Class (Raw (..)) import Pos.Core.Attributes (Attributes, mkAttributes) import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..), AddrStakeDistribution (..), Address (..), BlockCount (..), - ChainDifficulty (..), Coeff (..), Coin (..), - CoinPortion (..), Script (..), ScriptVersion, - SharedSeed (..), SlotLeaders, StakeholderId, StakesList, - TxFeePolicy (..), TxSizeLinear (..), - coinPortionDenominator, makeAddress, mkMultiKeyDistr) + ChainDifficulty (..), Coin (..), CoinPortion (..), + Script (..), SharedSeed (..), SlotLeaders, StakeholderId, + StakesList, coinPortionDenominator, makeAddress, + mkMultiKeyDistr) import Pos.Core.ProtocolConstants (ProtocolConstants, pcEpochSlots) -import Pos.Core.Slotting (EpochIndex (..), FlatSlotId, - LocalSlotIndex (..), SlotCount, SlotId (..)) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), - BlockVersionData (..), BlockVersionModifier (..), - SoftforkRule (..), SoftwareVersion (..), SystemTag (..), - UpAttributes, UpId, UpdateData (..), UpdatePayload (..), - UpdateProof, UpdateProposal, UpdateProposalToSign (..), - UpdateVote (..), VoteId, mkUpdateProof, - mkUpdateProposalWSign, mkUpdateVoteSafe) +import Pos.Core.Slotting (EpochIndex (..), LocalSlotIndex (..), + SlotCount, SlotId (..)) import Pos.Crypto (HDAddressPayload (..), ProtocolMagic (..), RedeemPublicKey, SafeSigner (..), SecretKey (..), VssPublicKey (..), abstractHash, deterministicVssKeyGen, - hash, redeemDeterministicKeyGen, toVssPublicKey) + redeemDeterministicKeyGen, toVssPublicKey) import Pos.Crypto.Signing (PublicKey (..)) import Test.Pos.Core.Gen (genProtocolConstants) @@ -121,31 +97,6 @@ feedPMEpochSlots genA = do exampleAttributes :: Attributes () exampleAttributes = mkAttributes () -exampleBlockVersion :: BlockVersion -exampleBlockVersion = BlockVersion 1 1 1 - -exampleBlockVersionData :: BlockVersionData -exampleBlockVersionData = BlockVersionData - (999 :: ScriptVersion) - (999 :: Millisecond) - (999 :: Byte) - (999 :: Byte) - (999 :: Byte) - (999 :: Byte) - (CoinPortion 99) - (CoinPortion 99) - (CoinPortion 99) - (CoinPortion 99) - (99 :: FlatSlotId) - sfrule - (TxFeePolicyTxSizeLinear tslin) - (EpochIndex 99) - where - tslin = TxSizeLinear c1' c2' - c1' = Coeff (MkFixed 999) - c2' = Coeff (MkFixed 77) - sfrule = (SoftforkRule (CoinPortion 99) (CoinPortion 99) (CoinPortion 99)) - exampleChainDifficulty :: ChainDifficulty exampleChainDifficulty = ChainDifficulty (BlockCount 9999) @@ -166,28 +117,6 @@ exampleVssPublicKeys offset count = map (toKey . (*offset)) [0..count] where toKey start = toVssPublicKey . deterministicVssKeyGen $ (getBytes start 32) -exampleBlockVersionModifier :: BlockVersionModifier -exampleBlockVersionModifier = BlockVersionModifier - (Just (999 :: ScriptVersion)) - (Just (999 :: Millisecond)) - (Just (999 :: Byte)) - (Just (999 :: Byte)) - (Just (999 :: Byte)) - (Just (999 :: Byte)) - (Just $ CoinPortion 99) - (Just $ CoinPortion 99) - (Just $ CoinPortion 99) - (Just $ CoinPortion 99) - (Just (99 :: FlatSlotId)) - (Just sfrule') - (Just $ TxFeePolicyTxSizeLinear tslin') - (Just $ EpochIndex 99) - where - tslin' = TxSizeLinear co1 co2 - co1 = Coeff (MkFixed 999) - co2 = Coeff (MkFixed 77) - sfrule' = (SoftforkRule (CoinPortion 99) (CoinPortion 99) (CoinPortion 99)) - exampleSlotId :: SlotId exampleSlotId = SlotId (EpochIndex 11) (UnsafeLocalSlotIndex 47) @@ -230,65 +159,6 @@ exampleStakesList = zip sis coins exampleSlotLeaders :: SlotLeaders exampleSlotLeaders = map abstractHash (fromList (examplePublicKeys 16 3)) -exampleSystemTag :: SystemTag -exampleSystemTag = (exampleSystemTags 0 1) !! 0 - -exampleSystemTags :: Int -> Int -> [SystemTag] -exampleSystemTags offset count = map (toSystemTag . (*offset)) [0..count-1] - where - toSystemTag start = SystemTag (getText start 16) - -exampleUpAttributes :: UpAttributes -exampleUpAttributes = exampleAttributes - -exampleUpdateData :: UpdateData -exampleUpdateData = (exampleUpdateDatas 10 2) !! 1 - -exampleUpdateDatas :: Int -> Int -> [UpdateData] -exampleUpdateDatas offset count = map (toUpdateData . (*offset)) [0..count-1] - where - toUpdateData start = - let h = hash $ Raw (getBytes start 128) - in UpdateData h h h h - -exampleUpId :: UpId -exampleUpId = hash exampleUpdateProposal - -exampleUpdatePayload :: UpdatePayload -exampleUpdatePayload = UpdatePayload up uv - where - up = Just exampleUpdateProposal - uv = [exampleUpdateVote] - -exampleUpdateProof :: UpdateProof -exampleUpdateProof = mkUpdateProof exampleUpdatePayload - -exampleUpdateProposal :: UpdateProposal -exampleUpdateProposalToSign :: UpdateProposalToSign -(exampleUpdateProposal, exampleUpdateProposalToSign) = - ( mkUpdateProposalWSign pm bv bvm sv hm ua ss - , UpdateProposalToSign bv bvm sv hm ua ) - where - pm = ProtocolMagic 0 - bv = exampleBlockVersion - bvm = exampleBlockVersionModifier - sv = exampleSoftwareVersion - hm = HM.fromList $ zip (exampleSystemTags 10 5) (exampleUpdateDatas 10 5) - ua = exampleUpAttributes - ss = exampleSafeSigner 0 - -exampleUpdateVote :: UpdateVote -exampleUpdateVote = mkUpdateVoteSafe pm ss ui ar - where - pm = ProtocolMagic 0 - ss = exampleSafeSigner 0 - ui = exampleUpId - ar = True - --- | ```type VoteId = (UpId, PublicKey, Bool)``` -exampleVoteId :: VoteId -exampleVoteId = (exampleUpId, examplePublicKey, False) - staticSafeSigners :: [SafeSigner] staticSafeSigners = map FakeSigner (exampleSecretKeys 1 6) @@ -306,9 +176,6 @@ staticText getText :: Int -> Int -> Text getText offset len = T.take len $ T.drop offset staticText -exampleSoftwareVersion :: SoftwareVersion -exampleSoftwareVersion = SoftwareVersion (ApplicationName "Golden") 99 - exampleAddress :: Address exampleAddress = makeAddress exampleAddrSpendingData_PubKey attrs where diff --git a/core/test/Test/Pos/Core/Gen.hs b/core/test/Test/Pos/Core/Gen.hs index 2947874f36c..6fa44b3a973 100644 --- a/core/test/Test/Pos/Core/Gen.hs +++ b/core/test/Test/Pos/Core/Gen.hs @@ -39,33 +39,13 @@ module Test.Pos.Core.Gen , genTimeDiff , genTimestamp - -- Pos.Core.Update Generators - , genApplicationName - , genBlockVersion - , genBlockVersionData - , genBlockVersionModifier - , genHashRaw - , genSoftforkRule - , genSoftwareVersion - , genSystemTag - , genUpAttributes - , genUpdateData - , genUpdatePayload - , genUpdateProof - , genUpdateProposal - , genUpdateProposals - , genUpdateProposalToSign - , genUpdateVote - , genUpId - , genUpsData - , genVoteId - -- Pos.Core.Attributes Generators , genAttributes -- Pos.Merkle Generators , genMerkleRoot , genMerkleTree + , genHashRaw -- Helpers , genCustomHashMap @@ -76,6 +56,7 @@ module Test.Pos.Core.Gen , genWord16 , genWord32 , gen32Bytes + , genMillisecond ) where import Universum @@ -107,20 +88,12 @@ import Pos.Core.Slotting (EpochIndex (..), EpochOrSlot (..), FlatSlotId, LocalSlotIndex (..), SlotCount (..), SlotId (..), TimeDiff (..), Timestamp (..), localSlotIndexMaxBound, localSlotIndexMinBound) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), - BlockVersionData (..), BlockVersionModifier (..), - SoftforkRule (..), SoftwareVersion (..), SystemTag (..), - UpAttributes, UpId, UpdateData (..), UpdatePayload (..), - UpdateProof, UpdateProposal (..), - UpdateProposalToSign (..), UpdateProposals, - UpdateVote (..), VoteId, mkUpdateVote) -import Pos.Crypto (Hash, ProtocolMagic, hash) +import Pos.Crypto (Hash, hash) import Pos.Util.Util (leftToPanic) import Serokell.Data.Memory.Units (Byte) import Test.Pos.Crypto.Gen (genAbstractHash, genHDAddressPayload, - genPublicKey, genRedeemPublicKey, genSecretKey, - genSignature) + genPublicKey, genRedeemPublicKey) ---------------------------------------------------------------------------- -- Pos.Core.Common Generators @@ -334,138 +307,6 @@ genTimeDiff = TimeDiff <$> genMicrosecond genTimestamp :: Gen Timestamp genTimestamp = Timestamp <$> genMicrosecond ----------------------------------------------------------------------------- --- Pos.Core.Update Generators ----------------------------------------------------------------------------- - -genApplicationName :: Gen ApplicationName -genApplicationName = - ApplicationName <$> Gen.text (Range.constant 0 10) Gen.alphaNum - -genBlockVersion :: Gen BlockVersion -genBlockVersion = - BlockVersion - <$> Gen.word16 Range.constantBounded - <*> Gen.word16 Range.constantBounded - <*> Gen.word8 Range.constantBounded - -genBlockVersionData :: Gen BlockVersionData -genBlockVersionData = - BlockVersionData - <$> genScriptVersion - <*> genMillisecond - <*> genByte - <*> genByte - <*> genByte - <*> genByte - <*> genCoinPortion - <*> genCoinPortion - <*> genCoinPortion - <*> genCoinPortion - <*> genFlatSlotId - <*> genSoftforkRule - <*> genTxFeePolicy - <*> genEpochIndex - - -genBlockVersionModifier :: Gen BlockVersionModifier -genBlockVersionModifier = - BlockVersionModifier - <$> Gen.maybe genScriptVersion - <*> Gen.maybe genMillisecond - <*> Gen.maybe genByte - <*> Gen.maybe genByte - <*> Gen.maybe genByte - <*> Gen.maybe genByte - <*> Gen.maybe genCoinPortion - <*> Gen.maybe genCoinPortion - <*> Gen.maybe genCoinPortion - <*> Gen.maybe genCoinPortion - <*> Gen.maybe genFlatSlotId - <*> Gen.maybe genSoftforkRule - <*> Gen.maybe genTxFeePolicy - <*> Gen.maybe genEpochIndex - -genHashRaw :: Gen (Hash Raw) -genHashRaw = genAbstractHash $ Raw <$> gen32Bytes - -genSoftforkRule :: Gen SoftforkRule -genSoftforkRule = - SoftforkRule <$> genCoinPortion <*> genCoinPortion <*> genCoinPortion - -genSoftwareVersion :: Gen SoftwareVersion -genSoftwareVersion = - SoftwareVersion - <$> genApplicationName - <*> Gen.word32 Range.constantBounded - -genSystemTag :: Gen SystemTag -genSystemTag = SystemTag <$> Gen.text (Range.constant 0 10) Gen.alphaNum - -genUpAttributes :: Gen UpAttributes -genUpAttributes = pure $ mkAttributes () - -genUpdateData :: Gen UpdateData -genUpdateData = - UpdateData - <$> genHashRaw - <*> genHashRaw - <*> genHashRaw - <*> genHashRaw - -genUpdatePayload :: ProtocolMagic -> Gen UpdatePayload -genUpdatePayload pm = - UpdatePayload - <$> Gen.maybe (genUpdateProposal pm) - <*> Gen.list (Range.linear 0 10) (genUpdateVote pm) - -genUpdateProof :: ProtocolMagic -> Gen UpdateProof -genUpdateProof pm = genAbstractHash (genUpdatePayload pm) - -genUpdateProposal :: ProtocolMagic -> Gen UpdateProposal -genUpdateProposal pm = do - UnsafeUpdateProposal - <$> genBlockVersion - <*> genBlockVersionModifier - <*> genSoftwareVersion - <*> genUpsData - <*> genUpAttributes - <*> genPublicKey - <*> genSignature pm genUpdateProposalToSign - -genUpdateProposals :: ProtocolMagic -> Gen UpdateProposals -genUpdateProposals pm = genCustomHashMap (genUpId pm) (genUpdateProposal pm) - -genUpdateProposalToSign :: Gen UpdateProposalToSign -genUpdateProposalToSign = - UpdateProposalToSign - <$> genBlockVersion - <*> genBlockVersionModifier - <*> genSoftwareVersion - <*> genUpsData - <*> genUpAttributes - -genUpId :: ProtocolMagic -> Gen UpId -genUpId pm = genAbstractHash (genUpdateProposal pm) - -genUpsData :: Gen (HM.HashMap SystemTag UpdateData) -genUpsData = do - hMapSize <- Gen.int (Range.linear 0 20) - sysTagList <- Gen.list (Range.singleton hMapSize) genSystemTag - upDataList <- Gen.list (Range.singleton hMapSize) genUpdateData - pure $ HM.fromList $ zip sysTagList upDataList - -genUpdateVote :: ProtocolMagic -> Gen UpdateVote -genUpdateVote pm = mkUpdateVote pm <$> genSecretKey <*> genUpId pm <*> Gen.bool - -- <$> genSecretKey - -- <*> genUpId - -- <*> Gen.bool - -- <*> genSignature ((,) <$> genUpId <*> Gen.bool) --- genUpdateVote pm = mkUpdateVote pm <$> arbitrary <*> arbitrary <*> arbitrary - -genVoteId :: ProtocolMagic -> Gen VoteId -genVoteId pm = (,,) <$> genUpId pm <*> genPublicKey <*> Gen.bool - ---------------------------------------------------------------------------- -- Pos.Core.Attributes Generators ---------------------------------------------------------------------------- @@ -477,6 +318,9 @@ genAttributes genA = mkAttributes <$> genA -- Pos.Merkle Generators ---------------------------------------------------------------------------- +genHashRaw :: Gen (Hash Raw) +genHashRaw = genAbstractHash $ Raw <$> gen32Bytes + -- slow genMerkleTree :: Bi a => Gen a -> Gen (MerkleTree a) genMerkleTree genA = mkMerkleTree <$> Gen.list (Range.linear 0 10) genA diff --git a/core/test/Test/Pos/Core/Json.hs b/core/test/Test/Pos/Core/Json.hs index 543ed132052..966daa5a8b5 100644 --- a/core/test/Test/Pos/Core/Json.hs +++ b/core/test/Test/Pos/Core/Json.hs @@ -7,10 +7,9 @@ import Pos.Core.JsonLog.LogEvents (InvReqDataFlowLog (..)) import Test.Pos.Core.ExampleHelpers (exampleAddress, exampleAddress1, exampleAddress2, exampleAddress3, exampleAddress4) -import Test.Pos.Core.Gen (genAddress, genBlockVersionData, genByte, - genCoin, genCoinPortion, genEpochIndex, genFlatSlotId, - genInvReqDataFlowLog, genSharedSeed, genSoftforkRule, - genTxFeePolicy) +import Test.Pos.Core.Gen (genAddress, genByte, genCoin, + genCoinPortion, genEpochIndex, genFlatSlotId, + genInvReqDataFlowLog, genSharedSeed, genTxFeePolicy) import Test.Pos.Crypto.Gen (genRedeemPublicKey) import Test.Pos.Util.Gen (genMillisecond) import Test.Pos.Util.Golden (discoverGolden, eachOf, goldenTestJSON) @@ -81,14 +80,6 @@ roundTripCoin = eachOf 1000 genCoin roundTripsAesonBuildable roundTripSharedSeed :: Property roundTripSharedSeed = eachOf 1000 genSharedSeed roundTripsAesonBuildable --------------------------------------------------------------------------------- --- BlockVersionData --------------------------------------------------------------------------------- - -roundTripBlockVersionData :: Property -roundTripBlockVersionData = - eachOf 1000 genBlockVersionData roundTripsAesonBuildable - -------------------------------------------------------------------------------- -- Millisecond -------------------------------------------------------------------------------- @@ -117,13 +108,6 @@ roundTripCoinPortion = eachOf 1000 genCoinPortion roundTripsAesonBuildable roundTripFlatSlotId :: Property roundTripFlatSlotId = eachOf 1000 genFlatSlotId roundTripsAesonShow --------------------------------------------------------------------------------- --- SoftforkRule --------------------------------------------------------------------------------- - -roundTripSoftforkRule :: Property -roundTripSoftforkRule = eachOf 1000 genSoftforkRule roundTripsAesonBuildable - -------------------------------------------------------------------------------- -- TxFeePolicy -------------------------------------------------------------------------------- diff --git a/db/src/Pos/DB/Block/Logic/Creation.hs b/db/src/Pos/DB/Block/Logic/Creation.hs index d3f87c4bcb8..562e617aaa0 100644 --- a/db/src/Pos/DB/Block/Logic/Creation.hs +++ b/db/src/Pos/DB/Block/Logic/Creation.hs @@ -36,8 +36,8 @@ import Pos.Chain.Ssc (MonadSscMem, SscPayload, defaultSscPayload, stripSscPayload) import Pos.Chain.Txp (TxAux (..), TxpConfiguration, emptyTxPayload, mkTxPayload) -import Pos.Chain.Update (HasUpdateConfiguration, curSoftwareVersion, - lastKnownBlockVersion) +import Pos.Chain.Update (HasUpdateConfiguration, UpdatePayload (..), + curSoftwareVersion, lastKnownBlockVersion) import Pos.Core (BlockCount, EpochIndex, EpochOrSlot (..), SlotId (..), epochIndexL, flattenSlotId, getEpochOrSlot, kChainQualityThreshold, kEpochSlots, @@ -48,7 +48,6 @@ import Pos.Core.JsonLog (CanJsonLog (..)) import Pos.Core.JsonLog.LogEvents (MemPoolModifyReason (..)) import Pos.Core.Reporting (HasMisbehaviorMetrics, reportError) import Pos.Core.Slotting (MonadSlots (getCurrentSlot)) -import Pos.Core.Update (UpdatePayload (..)) import Pos.Core.Util.LogSafe (logInfoS) import Pos.Crypto (SecretKey) import Pos.DB.Block.Logic.Internal (MonadBlockApply, diff --git a/db/src/Pos/DB/Block/Logic/Header.hs b/db/src/Pos/DB/Block/Logic/Header.hs index 08572d734eb..2522290e8a6 100644 --- a/db/src/Pos/DB/Block/Logic/Header.hs +++ b/db/src/Pos/DB/Block/Logic/Header.hs @@ -32,11 +32,11 @@ import Pos.Chain.Block (BlockHeader (..), HeaderHash, headerSlotL, prevBlockL, verifyHeader) import Pos.Chain.Genesis as Genesis (Config (..), configBlkSecurityParam, configEpochSlots) +import Pos.Chain.Update (bvdMaxHeaderSize) import Pos.Core (difficultyL, epochIndexL, getEpochOrSlot) import Pos.Core.Chrono (NE, NewestFirst, OldestFirst (..), toNewestFirst, toOldestFirst, _NewestFirst, _OldestFirst) import Pos.Core.Slotting (MonadSlots (getCurrentSlot)) -import Pos.Core.Update (bvdMaxHeaderSize) import Pos.DB (MonadDBRead) import qualified Pos.DB.Block.GState.BlockExtra as GS import Pos.DB.Block.Load (loadHeadersByDepth) diff --git a/db/src/Pos/DB/Block/Logic/Types.hs b/db/src/Pos/DB/Block/Logic/Types.hs index a4c721e6143..db5f84929d9 100644 --- a/db/src/Pos/DB/Block/Logic/Types.hs +++ b/db/src/Pos/DB/Block/Logic/Types.hs @@ -8,9 +8,9 @@ module Pos.DB.Block.Logic.Types import Universum +import Pos.Chain.Update (BlockVersion, BlockVersionData) import Pos.Core.Slotting (MonadSlots (getCurrentSlot), SlotCount, SlotId) -import Pos.Core.Update (BlockVersion, BlockVersionData) import Pos.DB.Class (MonadDBRead) import Pos.DB.Update (getAdoptedBVFull) diff --git a/db/src/Pos/DB/Block/Slog/Logic.hs b/db/src/Pos/DB/Block/Slog/Logic.hs index 572ba27bc4d..3d04c0ec19b 100644 --- a/db/src/Pos/DB/Block/Slog/Logic.hs +++ b/db/src/Pos/DB/Block/Slog/Logic.hs @@ -36,7 +36,7 @@ import Pos.Chain.Block (Block, Blund, HasSlogGState, SlogUndo (..), mainBlockSlot, prevBlockL, verifyBlocks) import Pos.Chain.Genesis as Genesis (Config (..), configEpochSlots, configK) -import Pos.Chain.Update (HasUpdateConfiguration, +import Pos.Chain.Update (BlockVersion (..), HasUpdateConfiguration, lastKnownBlockVersion) import Pos.Core (BlockCount, FlatSlotId, ProtocolConstants, difficultyL, epochIndexL, flattenSlotId, kEpochSlots, @@ -45,7 +45,6 @@ import Pos.Core.Chrono (NE, NewestFirst (getNewestFirst), OldestFirst (..), toOldestFirst, _OldestFirst) import Pos.Core.Exception (assertionFailed, reportFatalError) import Pos.Core.Slotting (MonadSlots, SlotId) -import Pos.Core.Update (BlockVersion (..)) import Pos.DB (SomeBatchOp (..)) import Pos.DB.Block.BListener (MonadBListener (..)) import qualified Pos.DB.Block.GState.BlockExtra as GS diff --git a/db/src/Pos/DB/Class.hs b/db/src/Pos/DB/Class.hs index b6abd77189a..9b0f384723e 100644 --- a/db/src/Pos/DB/Class.hs +++ b/db/src/Pos/DB/Class.hs @@ -60,8 +60,8 @@ import Serokell.Data.Memory.Units (Byte) import Pos.Binary.Class (Bi, decodeFull') import Pos.Chain.Block (Block, BlockHeader, HeaderHash) import Pos.Chain.Genesis (GenesisHash) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (EpochIndex, isBootstrapEra) -import Pos.Core.Update (BlockVersionData (..)) import Pos.DB.Error (DBError (DBMalformed)) import Pos.Util.Util (eitherToThrow) diff --git a/db/src/Pos/DB/Delegation/Logic/Mempool.hs b/db/src/Pos/DB/Delegation/Logic/Mempool.hs index 3f11710b559..876cc6529f2 100644 --- a/db/src/Pos/DB/Delegation/Logic/Mempool.hs +++ b/db/src/Pos/DB/Delegation/Logic/Mempool.hs @@ -32,9 +32,9 @@ import Pos.Chain.Delegation (DlgMemPool, DlgPayload (..), isRevokePsk, pskToDlgEdgeAction) import Pos.Chain.Genesis as Genesis (Config (..), configBlockVersionData) +import Pos.Chain.Update (bvdMaxBlockSize) import Pos.Core (addressHash, epochIndexL) import Pos.Core.Conc (currentTime) -import Pos.Core.Update (bvdMaxBlockSize) import Pos.Crypto (ProxySecretKey (..), PublicKey) import Pos.DB (MonadDBRead, MonadGState) import qualified Pos.DB as DB diff --git a/db/src/Pos/DB/Delegation/Logic/VAR.hs b/db/src/Pos/DB/Delegation/Logic/VAR.hs index dd5d60d790b..8b707bd4d1f 100644 --- a/db/src/Pos/DB/Delegation/Logic/VAR.hs +++ b/db/src/Pos/DB/Delegation/Logic/VAR.hs @@ -37,10 +37,10 @@ import Pos.Chain.Delegation (CedeModifier (..), DlgBlund, import Pos.Chain.Genesis as Genesis (Config (..), configBlockVersionData) import Pos.Chain.Lrc (RichmenSet) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (EpochIndex (..), StakeholderId, addressHash, epochIndexL, siEpoch) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) -import Pos.Core.Update (BlockVersionData) import Pos.Crypto (ProxySecretKey (..), shortHashF) import Pos.DB (DBError (DBMalformed), MonadDBRead, SomeBatchOp (..)) import qualified Pos.DB as DB diff --git a/db/src/Pos/DB/Lrc/Consumer.hs b/db/src/Pos/DB/Lrc/Consumer.hs index 142f741c764..1e452109d4d 100644 --- a/db/src/Pos/DB/Lrc/Consumer.hs +++ b/db/src/Pos/DB/Lrc/Consumer.hs @@ -12,8 +12,8 @@ import Universum import Pos.Binary.Class (Bi) import Pos.Chain.Lrc (RichmenComponent (..), RichmenStakes) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (Coin, CoinPortion, EpochIndex, applyCoinPortionUp) -import Pos.Core.Update (BlockVersionData) import Pos.DB.Class (MonadDB, MonadGState, gsAdoptedBVData) import Pos.DB.Lrc.RichmenBase (getRichmen, putRichmen) diff --git a/db/src/Pos/DB/Lrc/Consumer/Delegation.hs b/db/src/Pos/DB/Lrc/Consumer/Delegation.hs index e4473259687..fddf76f7b51 100644 --- a/db/src/Pos/DB/Lrc/Consumer/Delegation.hs +++ b/db/src/Pos/DB/Lrc/Consumer/Delegation.hs @@ -18,8 +18,8 @@ module Pos.DB.Lrc.Consumer.Delegation import Universum import Pos.Chain.Lrc (RichmenComponent (..), RichmenSet) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (EpochIndex) -import Pos.Core.Update (BlockVersionData (..)) import Pos.DB (MonadDB, MonadDBRead, MonadGState) import Pos.DB.Lrc.Consumer (LrcConsumer, lrcConsumerFromComponentSimple) diff --git a/db/src/Pos/DB/Lrc/Consumer/Ssc.hs b/db/src/Pos/DB/Lrc/Consumer/Ssc.hs index 467a4090e1d..6886398f569 100644 --- a/db/src/Pos/DB/Lrc/Consumer/Ssc.hs +++ b/db/src/Pos/DB/Lrc/Consumer/Ssc.hs @@ -18,8 +18,8 @@ module Pos.DB.Lrc.Consumer.Ssc import Universum import Pos.Chain.Lrc (RichmenComponent (..), RichmenStakes) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (EpochIndex) -import Pos.Core.Update (BlockVersionData (..)) import Pos.DB (MonadDB, MonadDBRead, MonadGState) import Pos.DB.Lrc.Consumer (LrcConsumer, lrcConsumerFromComponentSimple) diff --git a/db/src/Pos/DB/Lrc/Consumer/Update.hs b/db/src/Pos/DB/Lrc/Consumer/Update.hs index 5da8763d161..0c7bea85c59 100644 --- a/db/src/Pos/DB/Lrc/Consumer/Update.hs +++ b/db/src/Pos/DB/Lrc/Consumer/Update.hs @@ -18,8 +18,8 @@ module Pos.DB.Lrc.Consumer.Update import Universum import Pos.Chain.Lrc (FullRichmenData, RichmenComponent (..)) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (EpochIndex) -import Pos.Core.Update (BlockVersionData (..)) import Pos.DB (MonadDB, MonadDBRead, MonadGState) import Pos.DB.Lrc.Consumer (LrcConsumer, lrcConsumerFromComponentSimple) diff --git a/db/src/Pos/DB/Lrc/Consumers.hs b/db/src/Pos/DB/Lrc/Consumers.hs index aaf796a11fc..21d805e4443 100644 --- a/db/src/Pos/DB/Lrc/Consumers.hs +++ b/db/src/Pos/DB/Lrc/Consumers.hs @@ -7,7 +7,7 @@ module Pos.DB.Lrc.Consumers import Universum -import Pos.Core.Update (BlockVersionData) +import Pos.Chain.Update (BlockVersionData) import Pos.DB.Lrc.Consumer (LrcConsumer) import Pos.DB.Lrc.Consumer.Delegation (dlgLrcConsumer) import Pos.DB.Lrc.Consumer.Ssc (sscLrcConsumer) diff --git a/db/src/Pos/DB/Ssc/Logic/Global.hs b/db/src/Pos/DB/Ssc/Logic/Global.hs index 469f00d5f8b..16cbbbccbca 100644 --- a/db/src/Pos/DB/Ssc/Logic/Global.hs +++ b/db/src/Pos/DB/Ssc/Logic/Global.hs @@ -16,8 +16,8 @@ import Pos.Chain.Ssc (MonadSscMem, SscGlobalQuery, SscSeedError, sgsOpenings, sgsShares, sgsVssCertificates, sscRunGlobalQuery, vcVssKey) import qualified Pos.Chain.Ssc as Ssc +import Pos.Chain.Update (BlockVersionData) import Pos.Core (EpochIndex (..), SharedSeed) -import Pos.Core.Update (BlockVersionData) import Pos.DB (MonadDBRead) import Pos.DB.Lrc (HasLrcContext, getSscRichmen) diff --git a/db/src/Pos/DB/Ssc/Logic/Local.hs b/db/src/Pos/DB/Ssc/Logic/Local.hs index 88a11393978..0fcb640174f 100644 --- a/db/src/Pos/DB/Ssc/Logic/Local.hs +++ b/db/src/Pos/DB/Ssc/Logic/Local.hs @@ -46,10 +46,10 @@ import Pos.Chain.Ssc (HasSscConfiguration, InnerSharesMap, supplyPureTossEnv, syncingStateWith, tmCertificates, tmCommitments, tmOpenings, tmShares, verifyAndApplySscPayload) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (BlockCount, EpochIndex, SlotId (..), StakeholderId, epochIndexL, kEpochSlots) import Pos.Core.Slotting (MonadSlots (getCurrentSlot)) -import Pos.Core.Update (BlockVersionData (..)) import Pos.DB (MonadBlockDBRead, MonadDBRead, MonadGState (gsAdoptedBVData)) import Pos.DB.BlockIndex (getTipHeader) diff --git a/db/src/Pos/DB/Ssc/Logic/VAR.hs b/db/src/Pos/DB/Ssc/Logic/VAR.hs index ec8d8969db3..718d7d8d4d4 100644 --- a/db/src/Pos/DB/Ssc/Logic/VAR.hs +++ b/db/src/Pos/DB/Ssc/Logic/VAR.hs @@ -29,11 +29,11 @@ import Pos.Chain.Ssc (HasSscConfiguration, MonadSscMem, rollbackSsc, runPureTossWithLogger, sscGlobal, sscIsCriticalVerifyError, sscRunGlobalUpdate, supplyPureTossEnv, verifyAndApplySscPayload) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (SlotCount, epochIndexL, epochOrSlotG) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) import Pos.Core.Exception (assertionFailed) import Pos.Core.Reporting (MonadReporting, reportError) -import Pos.Core.Update (BlockVersionData) import Pos.DB (MonadDBRead, MonadGState, SomeBatchOp (..), gsAdoptedBVData) import Pos.DB.Lrc (HasLrcContext, getSscRichmen) diff --git a/db/src/Pos/DB/Txp/Logic/Local.hs b/db/src/Pos/DB/Txp/Logic/Local.hs index 84a2a9d7af2..9cda9f833d6 100644 --- a/db/src/Pos/DB/Txp/Logic/Local.hs +++ b/db/src/Pos/DB/Txp/Logic/Local.hs @@ -33,12 +33,12 @@ import Pos.Chain.Txp (ExtendedLocalToilM, LocalToilState (..), TxpConfiguration (..), UndoMap, Utxo, UtxoLookup, UtxoModifier, extendLocalToilM, mpLocalTxs, normalizeToil, processTx, topsortTxs, utxoToLookup) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (EpochIndex, SlotCount, siEpoch) import Pos.Core.JsonLog (CanJsonLog (..)) import Pos.Core.JsonLog.LogEvents (MemPoolModifyReason (..)) import Pos.Core.Reporting (reportError) import Pos.Core.Slotting (MonadSlots (..)) -import Pos.Core.Update (BlockVersionData) import Pos.Crypto (WithHash (..)) import Pos.DB.Class (MonadGState (..)) import qualified Pos.DB.GState.Common as GS diff --git a/db/src/Pos/DB/Update/GState.hs b/db/src/Pos/DB/Update/GState.hs index 2ecc9ab5622..37e20b438d4 100644 --- a/db/src/Pos/DB/Update/GState.hs +++ b/db/src/Pos/DB/Update/GState.hs @@ -52,21 +52,20 @@ import UnliftIO (MonadUnliftIO) import Pos.Binary.Class (serialize') import Pos.Chain.Genesis as Genesis (Config (..), configBlockVersionData, configEpochSlots) -import Pos.Chain.Update (BlockVersionState (..), +import Pos.Chain.Update (ApplicationName, BlockVersion, + BlockVersionData (..), BlockVersionState (..), ConfirmedProposalState (..), DecidedProposalState (dpsDifficulty), - HasUpdateConfiguration, ProposalState (..), - UndecidedProposalState (upsSlot), bvsIsConfirmed, - cpsSoftwareVersion, genesisBlockVersion, - genesisSoftwareVersions, ourAppName, ourSystemTag, - psProposal) + HasUpdateConfiguration, NumSoftwareVersion, + ProposalState (..), SoftwareVersion (..), + UndecidedProposalState (upsSlot), UpId, + UpdateProposal (..), bvsIsConfirmed, cpsSoftwareVersion, + genesisBlockVersion, genesisSoftwareVersions, ourAppName, + ourSystemTag, psProposal) import Pos.Core (ChainDifficulty, SlotId, StakeholderId, TimeDiff (..)) import Pos.Core.Slotting (EpochSlottingData (..), SlottingData, createInitSlottingData) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionData (..), NumSoftwareVersion, - SoftwareVersion (..), UpId, UpdateProposal (..)) import Pos.Crypto (hash) import Pos.DB (DBIteratorClass (..), DBTag (..), IterType, MonadDB, MonadDBRead (..), RocksBatchOp (..), encodeWithKeyPrefix) diff --git a/db/src/Pos/DB/Update/Logic/Global.hs b/db/src/Pos/DB/Update/Logic/Global.hs index b7e94218d70..e6bf4765e63 100644 --- a/db/src/Pos/DB/Update/Logic/Global.hs +++ b/db/src/Pos/DB/Update/Logic/Global.hs @@ -20,9 +20,12 @@ import UnliftIO (MonadUnliftIO) import Pos.Chain.Block (ComponentBlock (..), headerHashG, headerLeaderKeyL, headerSlotL) import Pos.Chain.Genesis as Genesis (Config, configBlkSecurityParam) -import Pos.Chain.Update (BlockVersionState, ConfirmedProposalState, - HasUpdateConfiguration, MonadPoll, PollModifier (..), - PollT, PollVerFailure, ProposalState, USUndo, execPollT, +import Pos.Chain.Update (ApplicationName, BlockVersion, + BlockVersionData, BlockVersionState, + ConfirmedProposalState, HasUpdateConfiguration, MonadPoll, + NumSoftwareVersion, PollModifier (..), PollT, + PollVerFailure, ProposalState, SoftwareVersion (..), + USUndo, UpId, UpdatePayload, blockVersionL, execPollT, execRollT, getAdoptedBV, lastKnownBlockVersion, reportUnexpectedError, runPollT) import Pos.Core (StakeholderId, addressHash, epochIndexL) @@ -30,9 +33,6 @@ import Pos.Core.Chrono (NE, NewestFirst, OldestFirst) import Pos.Core.Exception (reportFatalError) import Pos.Core.Reporting (MonadReporting) import Pos.Core.Slotting (MonadSlotsData, SlottingData, slottingVar) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionData, NumSoftwareVersion, - SoftwareVersion (..), UpId, UpdatePayload, blockVersionL) import qualified Pos.DB.BatchOp as DB import qualified Pos.DB.Class as DB import Pos.DB.Lrc (HasLrcContext) diff --git a/db/src/Pos/DB/Update/Logic/Local.hs b/db/src/Pos/DB/Update/Logic/Local.hs index da042a47fbb..719cf900592 100644 --- a/db/src/Pos/DB/Update/Logic/Local.hs +++ b/db/src/Pos/DB/Update/Logic/Local.hs @@ -36,16 +36,15 @@ import UnliftIO (MonadUnliftIO) import Pos.Binary.Class (biSize) import Pos.Chain.Block (HeaderHash) import Pos.Chain.Genesis as Genesis (Config, configBlockVersionData) -import Pos.Chain.Update (HasUpdateConfiguration, - MonadPoll (deactivateProposal), +import Pos.Chain.Update (BlockVersionData (..), + HasUpdateConfiguration, MonadPoll (deactivateProposal), MonadPollRead (getProposal), PollModifier, - PollVerFailure (..), canCombineVotes, evalPollT, - execPollT, getAdoptedBV, modifyPollModifier, psVotes, - reportUnexpectedError, runPollT) + PollVerFailure (..), UpId, UpdatePayload (..), + UpdateProposal, UpdateVote (..), canCombineVotes, + evalPollT, execPollT, getAdoptedBV, modifyPollModifier, + psVotes, reportUnexpectedError, runPollT) import Pos.Core (SlotId (..), slotIdF) import Pos.Core.Reporting (MonadReporting) -import Pos.Core.Update (BlockVersionData (..), UpId, - UpdatePayload (..), UpdateProposal, UpdateVote (..)) import Pos.Crypto (PublicKey, shortHashF) import Pos.DB.Class (MonadDBRead) import qualified Pos.DB.GState.Common as DB diff --git a/db/src/Pos/DB/Update/MemState/Functions.hs b/db/src/Pos/DB/Update/MemState/Functions.hs index d81537c414c..7b0cca75eb0 100644 --- a/db/src/Pos/DB/Update/MemState/Functions.hs +++ b/db/src/Pos/DB/Update/MemState/Functions.hs @@ -12,8 +12,8 @@ import Universum import qualified Data.HashMap.Strict as HM import Pos.Binary.Class (biSize) -import Pos.Chain.Update (LocalVotes) -import Pos.Core.Update (UpdatePayload (..), UpdateVote (..)) +import Pos.Chain.Update (LocalVotes, UpdatePayload (..), + UpdateVote (..)) import Pos.Crypto (PublicKey, hash) import Pos.DB.GState.Lock (Priority (..), StateLock, withStateLockNoMetrics) diff --git a/db/src/Pos/DB/Update/MemState/Types.hs b/db/src/Pos/DB/Update/MemState/Types.hs index d176e3b4a02..ff004673b79 100644 --- a/db/src/Pos/DB/Update/MemState/Types.hs +++ b/db/src/Pos/DB/Update/MemState/Types.hs @@ -18,10 +18,9 @@ import Data.Default (Default (def)) import Serokell.Data.Memory.Units (Byte) import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Update (LocalVotes, PollModifier) +import Pos.Chain.Update (LocalVotes, PollModifier, UpdateProposals) import Pos.Core (SlotCount, SlotId (..), localSlotIndexMinBound) import Pos.Core.Slotting (MonadSlots (getCurrentSlot)) -import Pos.Core.Update (UpdateProposals) import Pos.DB.Class (MonadDBRead) import Pos.DB.GState.Common (getTip) diff --git a/db/src/Pos/DB/Update/Poll/Logic/Apply.hs b/db/src/Pos/DB/Update/Poll/Logic/Apply.hs index 5fe64a68059..7f5304d11cd 100644 --- a/db/src/Pos/DB/Update/Poll/Logic/Apply.hs +++ b/db/src/Pos/DB/Update/Poll/Logic/Apply.hs @@ -22,20 +22,19 @@ import Pos.Chain.Block (HeaderHash, IsMainHeader (..), headerHashG, import Pos.Chain.Genesis as Genesis (Config (..), configBlkSecurityParam, configBlockVersionData, configEpochSlots) -import Pos.Chain.Update (ConfirmedProposalState (..), - DecidedProposalState (..), DpsExtra (..), MonadPoll (..), - MonadPollRead (..), PollVerFailure (..), - ProposalState (..), UndecidedProposalState (..), - UpsExtra (..), psProposal) +import Pos.Chain.Update (BlockVersion, BlockVersionData (..), + ConfirmedProposalState (..), DecidedProposalState (..), + DpsExtra (..), MonadPoll (..), MonadPollRead (..), + PollVerFailure (..), ProposalState (..), + SoftwareVersion (..), UndecidedProposalState (..), UpId, + UpdatePayload (..), UpdateProposal (..), UpdateVote (..), + UpsExtra (..), blockVersionL, bvdUpdateProposalThd, + checkUpdatePayload, psProposal) import Pos.Core (BlockCount, ChainDifficulty (..), Coin, EpochIndex, SlotCount, SlotId (..), addressHash, applyCoinPortionUp, coinToInteger, difficultyL, epochIndexL, flattenSlotId, sumCoins, unflattenSlotId, unsafeIntegerToCoin) import Pos.Core.Attributes (areAttributesKnown) -import Pos.Core.Update (BlockVersion, BlockVersionData (..), - SoftwareVersion (..), UpId, UpdatePayload (..), - UpdateProposal (..), UpdateVote (..), blockVersionL, - bvdUpdateProposalThd, checkUpdatePayload) import Pos.Crypto (hash, shortHashF) import Pos.DB.Update.Poll.Logic.Base (canBeAdoptedBV, canCreateBlockBV, confirmBlockVersion, isDecided, diff --git a/db/src/Pos/DB/Update/Poll/Logic/Base.hs b/db/src/Pos/DB/Update/Poll/Logic/Base.hs index 9c858eb5bdf..efe90c75c7d 100644 --- a/db/src/Pos/DB/Update/Poll/Logic/Base.hs +++ b/db/src/Pos/DB/Update/Poll/Logic/Base.hs @@ -39,11 +39,13 @@ import Data.Time.Units (convertUnit) import Formatting (build, int, sformat, (%)) import Pos.Chain.Block (HeaderHash, IsMainHeader (..), headerHashG) -import Pos.Chain.Update (BlockVersionState (..), +import Pos.Chain.Update (BlockVersion (..), BlockVersionData (..), + BlockVersionModifier (..), BlockVersionState (..), ConfirmedProposalState (..), DecidedProposalState (..), DpsExtra (..), MonadPoll (..), MonadPollRead (..), PollVerFailure (..), ProposalState (..), - UndecidedProposalState (..), UpsExtra (..), + SoftforkRule (..), UndecidedProposalState (..), UpId, + UpdateProposal (..), UpdateVote (..), UpsExtra (..), bvsIsConfirmed, combineVotes, cpsBlockVersion, isPositiveVote, newVoteState) import Pos.Core (Coin, CoinPortion (..), EpochIndex, SlotCount, @@ -54,9 +56,6 @@ import Pos.Core (Coin, CoinPortion (..), EpochIndex, SlotCount, import Pos.Core.Slotting (EpochSlottingData (..), SlottingData, addEpochSlottingData, getCurrentEpochIndex, getNextEpochSlottingData) -import Pos.Core.Update (BlockVersion (..), BlockVersionData (..), - BlockVersionModifier (..), SoftforkRule (..), UpId, - UpdateProposal (..), UpdateVote (..)) import Pos.Crypto (PublicKey, hash, shortHashF) import Pos.Util.Wlog (WithLogger, logDebug, logNotice) diff --git a/db/src/Pos/DB/Update/Poll/Logic/Normalize.hs b/db/src/Pos/DB/Update/Poll/Logic/Normalize.hs index f261d763919..27212836c86 100644 --- a/db/src/Pos/DB/Update/Poll/Logic/Normalize.hs +++ b/db/src/Pos/DB/Update/Poll/Logic/Normalize.hs @@ -16,13 +16,13 @@ import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HS import Formatting (build, sformat, (%)) -import Pos.Chain.Update (DecidedProposalState (..), LocalVotes, - MonadPoll (..), MonadPollRead (..), PollVerFailure (..), - ProposalState (..), UndecidedProposalState (..)) +import Pos.Chain.Update (BlockVersionData (..), + DecidedProposalState (..), LocalVotes, MonadPoll (..), + MonadPollRead (..), PollVerFailure (..), + ProposalState (..), UndecidedProposalState (..), UpId, + UpdateProposal, UpdateProposals, UpdateVote (..)) import Pos.Core (Coin, EpochIndex, SlotId (siEpoch), addressHash, applyCoinPortionUp, mkCoin, unsafeAddCoin) -import Pos.Core.Update (BlockVersionData (..), UpId, UpdateProposal, - UpdateProposals, UpdateVote (..)) import Pos.Crypto (PublicKey, hash) import Pos.DB.Update.Poll.Logic.Apply (verifyAndApplyProposal, verifyAndApplyVoteDo) diff --git a/db/src/Pos/DB/Update/Poll/Logic/Rollback.hs b/db/src/Pos/DB/Update/Poll/Logic/Rollback.hs index 101aecfe811..a5229e44793 100644 --- a/db/src/Pos/DB/Update/Poll/Logic/Rollback.hs +++ b/db/src/Pos/DB/Update/Poll/Logic/Rollback.hs @@ -9,11 +9,10 @@ module Pos.DB.Update.Poll.Logic.Rollback import qualified Data.HashMap.Strict as HM import Universum -import Pos.Chain.Update (BlockVersionState, ConfirmedProposalState, - MonadPoll (..), PrevValue (..), ProposalState (..), - USUndo (..)) -import Pos.Core.Update (ApplicationName, BlockVersion, - NumSoftwareVersion, SoftwareVersion (..), UpId) +import Pos.Chain.Update (ApplicationName, BlockVersion, + BlockVersionState, ConfirmedProposalState, MonadPoll (..), + NumSoftwareVersion, PrevValue (..), ProposalState (..), + SoftwareVersion (..), USUndo (..), UpId) -- | Rollback application of UpdatePayload in MonadPoll using payload -- itself and undo data. diff --git a/db/src/Pos/DB/Update/Poll/Logic/Softfork.hs b/db/src/Pos/DB/Update/Poll/Logic/Softfork.hs index bd5bce54c27..f5c7ad514bc 100644 --- a/db/src/Pos/DB/Update/Poll/Logic/Softfork.hs +++ b/db/src/Pos/DB/Update/Poll/Logic/Softfork.hs @@ -20,12 +20,12 @@ import Serokell.Util.Text (listJson) import Pos.Chain.Block (HeaderHash) import Pos.Chain.Genesis as Genesis (Config (..), configBlockVersionData, configEpochSlots) -import Pos.Chain.Update (BlockVersionState (..), MonadPoll (..), - MonadPollRead (..), PollVerFailure (..)) +import Pos.Chain.Update (BlockVersion, BlockVersionData (..), + BlockVersionState (..), MonadPoll (..), + MonadPollRead (..), PollVerFailure (..), + SoftforkRule (..)) import Pos.Core (BlockCount, Coin, EpochIndex, SlotId (..), StakeholderId, crucialSlot, sumCoins, unsafeIntegerToCoin) -import Pos.Core.Update (BlockVersion, BlockVersionData (..), - SoftforkRule (..)) import Pos.DB.Update.Poll.Logic.Base (ConfirmedEpoch, CurEpoch, adoptBlockVersion, calcSoftforkThreshold, canBeAdoptedBV, updateSlottingData) diff --git a/db/src/Pos/DB/Update/Poll/Logic/Version.hs b/db/src/Pos/DB/Update/Poll/Logic/Version.hs index b90a075e6ea..4552ce83386 100644 --- a/db/src/Pos/DB/Update/Poll/Logic/Version.hs +++ b/db/src/Pos/DB/Update/Poll/Logic/Version.hs @@ -16,12 +16,11 @@ module Pos.DB.Update.Poll.Logic.Version import Control.Monad.Except (MonadError, throwError) import Universum -import Pos.Chain.Update (BlockVersionState (..), MonadPoll (..), - MonadPollRead (..), PollVerFailure (..)) +import Pos.Chain.Update (BlockVersionData (..), + BlockVersionModifier (..), BlockVersionState (..), + MonadPoll (..), MonadPollRead (..), PollVerFailure (..), + SoftwareVersion (..), UpId, UpdateProposal (..)) import Pos.Core (EpochIndex) -import Pos.Core.Update (BlockVersionData (..), - BlockVersionModifier (..), SoftwareVersion (..), UpId, - UpdateProposal (..)) import Pos.DB.Update.Poll.Logic.Base (canBeProposedBV, verifyNextBVMod) diff --git a/db/src/Pos/DB/Update/Poll/PollState.hs b/db/src/Pos/DB/Update/Poll/PollState.hs index 2ae2018d362..d9801e27188 100644 --- a/db/src/Pos/DB/Update/Poll/PollState.hs +++ b/db/src/Pos/DB/Update/Poll/PollState.hs @@ -31,13 +31,13 @@ import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HS import Pos.Chain.Lrc (FullRichmenData) -import Pos.Chain.Update (BlockVersionState, ConfirmedProposalState, - PollModifier (..), ProposalState, psProposal) +import Pos.Chain.Update (ApplicationName, BlockVersion, + BlockVersionData, BlockVersionState, + ConfirmedProposalState, NumSoftwareVersion, + PollModifier (..), ProposalState, SoftwareVersion (..), + UpId, UpdateProposal (..), psProposal) import Pos.Core.Common (StakeholderId) import Pos.Core.Slotting (EpochIndex, SlottingData) -import Pos.Core.Update (ApplicationName, BlockVersion, - BlockVersionData, NumSoftwareVersion, - SoftwareVersion (..), UpId, UpdateProposal (..)) import Pos.DB.Lrc (IssuersStakes) import Pos.Util.Modifier (foldlMapModWKey', modifyHashMap) diff --git a/db/src/Pos/DB/Update/Poll/Pure.hs b/db/src/Pos/DB/Update/Poll/Pure.hs index 38bc73a27dd..b13637c5383 100644 --- a/db/src/Pos/DB/Update/Poll/Pure.hs +++ b/db/src/Pos/DB/Update/Poll/Pure.hs @@ -17,9 +17,10 @@ import qualified Data.HashSet as HS import Pos.Chain.Update (BlockVersionState (..), DecidedProposalState (..), MonadPoll (..), - MonadPollRead (..), UndecidedProposalState (..), applyBVM, - cpsSoftwareVersion, propStateToEither, psProposal) -import Pos.Core.Update (SoftwareVersion (..), UpdateProposal (..)) + MonadPollRead (..), SoftwareVersion (..), + UndecidedProposalState (..), UpdateProposal (..), + applyBVM, cpsSoftwareVersion, propStateToEither, + psProposal) import Pos.Crypto (hash) import qualified Pos.DB.Update.Poll.PollState as Poll import Pos.Util.Wlog (CanLog, HasLoggerName (..), LogEvent, diff --git a/db/test/Test/Pos/DB/Functions.hs b/db/test/Test/Pos/DB/Functions.hs index fdbbb82f3c2..c0b7b0293a6 100644 --- a/db/test/Test/Pos/DB/Functions.hs +++ b/db/test/Test/Pos/DB/Functions.hs @@ -15,7 +15,7 @@ import Pos.Binary.Class (Bi) import Pos.DB (DBTag (..), dbGetBi, dbPutBi) import Test.Pos.Chain.Ssc.Example (exampleSscPayload) -import Test.Pos.Core.ExampleHelpers (exampleBlockVersionData) +import Test.Pos.Chain.Update.Example (exampleBlockVersionData) import Test.Pos.DB.Mode (runTestMode) diff --git a/docs/block-processing/us.md b/docs/block-processing/us.md index dc08b037dc6..5fc8a37cba2 100644 --- a/docs/block-processing/us.md +++ b/docs/block-processing/us.md @@ -74,19 +74,19 @@ data UpdatePayload = UpdatePayload } ``` -Update proposal is represented by type `UpdateProposal` (see [code](https://github.com/input-output-hk/cardano-sl/blob/560c71afa420a707d244cc2a18c00914cb758d61/core/Pos/Core/Update/Types.hs#L314)) and contains folowing data: +Update proposal is represented by type `UpdateProposal` (see [code](https://github.com/input-output-hk/cardano-sl/blob/560c71afa420a707d244cc2a18c00914cb758d61/core/Pos.Chain.Update/Types.hs#L314)) and contains folowing data: * [Block version](#block-version) * Protocol constants modifier (see [Protocol constants](#protocol-constants)) * [Software version](#software-version) * Update data - * For each supported system (identified by system tag, e.g. win64 or linux32) we keep number of hashe used to indetify binary files associated with update, see [code](https://github.com/input-output-hk/cardano-sl/blob/560c71afa420a707d244cc2a18c00914cb758d61/core/Pos/Core/Update/Types.hs#L363) for details) + * For each supported system (identified by system tag, e.g. win64 or linux32) we keep number of hashe used to indetify binary files associated with update, see [code](https://github.com/input-output-hk/cardano-sl/blob/560c71afa420a707d244cc2a18c00914cb758d61/core/Pos.Chain.Update/Types.hs#L363) for details) * Proposal attributes Attributes map, used for future extension of proposal contents with new fields (via softfork). * Protocol issuer (identified by his stake public key) * Signature of proposal by signature -Vote is represented by type `UpdateVote` (see [code](https://github.com/input-output-hk/cardano-sl/blob/560c71afa420a707d244cc2a18c00914cb758d61/core/Pos/Core/Update/Types.hs#L408)) and contains following fields: +Vote is represented by type `UpdateVote` (see [code](https://github.com/input-output-hk/cardano-sl/blob/560c71afa420a707d244cc2a18c00914cb758d61/core/Pos.Chain.Update/Types.hs#L408)) and contains following fields: * Stake public key of voter * Id of update proposal diff --git a/explorer/src/Pos/Explorer/TestUtil.hs b/explorer/src/Pos/Explorer/TestUtil.hs index 321a877f8fb..2cdd95e9c19 100644 --- a/explorer/src/Pos/Explorer/TestUtil.hs +++ b/explorer/src/Pos/Explorer/TestUtil.hs @@ -38,13 +38,12 @@ import Pos.Chain.Delegation (DlgPayload, DlgUndo (..), ProxySKBlockInfo) import Pos.Chain.Ssc (SscPayload, defaultSscPayload) import Pos.Chain.Txp (TxAux) -import Pos.Chain.Update (HasUpdateConfiguration) +import Pos.Chain.Update (HasUpdateConfiguration, UpdatePayload (..)) import qualified Pos.Communication () import Pos.Core (Address, BlockCount (..), ChainDifficulty (..), EpochIndex (..), LocalSlotIndex (..), SlotId (..), SlotLeaders, StakeholderId, difficultyL, makePubKeyAddressBoot) -import Pos.Core.Update (UpdatePayload (..)) import Pos.Crypto (SecretKey, toPublic) import Pos.DB.Block (RawPayload (..), createMainBlockPure) import Pos.Explorer.BListener (createPagedHeaderHashesPair) diff --git a/explorer/src/Pos/Explorer/Txp/Local.hs b/explorer/src/Pos/Explorer/Txp/Local.hs index 141dee55eaf..cda72767474 100644 --- a/explorer/src/Pos/Explorer/Txp/Local.hs +++ b/explorer/src/Pos/Explorer/Txp/Local.hs @@ -15,9 +15,9 @@ import qualified Data.HashMap.Strict as HM import Pos.Chain.Genesis as Genesis (Config (..), configEpochSlots) import Pos.Chain.Txp (ToilVerFailure (..), TxAux (..), TxId, TxpConfiguration, Utxo) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (EpochIndex, Timestamp) import Pos.Core.JsonLog (CanJsonLog (..)) -import Pos.Core.Update (BlockVersionData) import Pos.DB.Txp.Logic (txNormalizeAbstract, txProcessTransactionAbstract) import Pos.DB.Txp.MemState (MempoolExt, TxpLocalWorkMode, getTxpExtra, diff --git a/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs b/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs index a65f1356077..9e82f16085d 100644 --- a/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs +++ b/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs @@ -25,10 +25,10 @@ import Pos.Chain.Txp (ToilVerFailure (..), Tx (..), TxAux (..), TxId, TxOut (..), TxOutAux (..), TxUndo, TxpConfiguration, extendGlobalToilM, extendLocalToilM, topsortTxs, _TxOut) import qualified Pos.Chain.Txp as Txp +import Pos.Chain.Update (BlockVersionData) import Pos.Core (Address, Coin, EpochIndex, Timestamp, mkCoin, sumCoins, unsafeAddCoin, unsafeSubCoin) import Pos.Core.Chrono (NewestFirst (..)) -import Pos.Core.Update (BlockVersionData) import Pos.Crypto (ProtocolMagic, WithHash (..), hash) import Pos.Explorer.Core (AddrHistory, TxExtra (..)) import Pos.Explorer.Txp.Toil.Monad (EGlobalToilM, ELocalToilM, diff --git a/generator/bench/Bench/Pos/Criterion/Block/Logic.hs b/generator/bench/Bench/Pos/Criterion/Block/Logic.hs index 58335dba083..abc351542ae 100644 --- a/generator/bench/Bench/Pos/Criterion/Block/Logic.hs +++ b/generator/bench/Bench/Pos/Criterion/Block/Logic.hs @@ -22,11 +22,11 @@ import Pos.Chain.Genesis as Genesis (Config (..), TestnetBalanceOptions (..), configBlockVersionData, configBootStakeholders, configEpochSlots, configGeneratedSecretsThrow, gsSecretKeys) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core.Chrono (NE, OldestFirst (..), nonEmptyNewestFirst) import Pos.Core.Common (BlockCount (..), unsafeCoinPortionFromDouble) import Pos.Core.Slotting (EpochOrSlot (..), SlotId, Timestamp (..), epochIndexL, getEpochOrSlot) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (SecretKey) import Pos.DB (getTipHeader) import Pos.DB.Block (rollbackBlocks, verifyAndApplyBlocks, diff --git a/generator/src/Test/Pos/Block/Logic/Mode.hs b/generator/src/Test/Pos/Block/Logic/Mode.hs index e3ca3b5220d..f8a821f7dd7 100644 --- a/generator/src/Test/Pos/Block/Logic/Mode.hs +++ b/generator/src/Test/Pos/Block/Logic/Mode.hs @@ -67,12 +67,12 @@ import Pos.Chain.Genesis as Genesis (Config (..), gsSecretKeys, mkConfig) import Pos.Chain.Ssc (SscMemTag, SscState) import Pos.Chain.Txp (TxpConfiguration (..)) +import Pos.Chain.Update (BlockVersionData) import Pos.Core (SlotId, Timestamp (..)) import Pos.Core.Conc (currentTime) import Pos.Core.Reporting (HasMisbehaviorMetrics (..), MonadReporting (..)) import Pos.Core.Slotting (MonadSlotsData) -import Pos.Core.Update (BlockVersionData) import Pos.DB (DBPure, MonadDB (..), MonadDBRead (..), MonadGState (..)) import qualified Pos.DB as DB diff --git a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs index acc4d828d96..a4c3ec9f29e 100644 --- a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs +++ b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs @@ -22,11 +22,11 @@ import Pos.Chain.Delegation (DlgPayload, ProxySKBlockInfo) import Pos.Chain.Ssc (SscPayload (..), defaultSscPayload, mkVssCertificatesMapLossy) import Pos.Chain.Txp (TxAux) -import Pos.Chain.Update (HasUpdateConfiguration) +import Pos.Chain.Update (BlockVersionData (..), + HasUpdateConfiguration, UpdatePayload (..)) import qualified Pos.Communication () import Pos.Core (SlotId (..), localSlotIndexMinBound, unsafeMkLocalSlotIndex) -import Pos.Core.Update (BlockVersionData (..), UpdatePayload (..)) import Pos.Crypto (SecretKey) import Pos.DB.Block (RawPayload (..), createMainBlockPure) diff --git a/infra/src/Pos/Infra/Communication/Types/Protocol.hs b/infra/src/Pos/Infra/Communication/Types/Protocol.hs index 411c1365dd9..26f362745b3 100644 --- a/infra/src/Pos/Infra/Communication/Types/Protocol.hs +++ b/infra/src/Pos/Infra/Communication/Types/Protocol.hs @@ -70,7 +70,7 @@ import Pos.Binary.Class (Bi (..), Cons (..), Field (..), deriveSimpleBi, encodeKnownCborDataItem, encodeListLen, encodeUnknownCborDataItem, enforceSize) import Pos.Binary.Limit (Limit (..)) -import Pos.Core.Update (BlockVersion) +import Pos.Chain.Update (BlockVersion) import Pos.Infra.Communication.BiP (BiP) import Pos.Infra.Network.Types (MsgType (..), NodeId (..), NodeType (..), Origin (..)) diff --git a/infra/src/Pos/Infra/Communication/Types/Relay.hs b/infra/src/Pos/Infra/Communication/Types/Relay.hs index 886caa7e622..efba18dd700 100644 --- a/infra/src/Pos/Infra/Communication/Types/Relay.hs +++ b/infra/src/Pos/Infra/Communication/Types/Relay.hs @@ -30,8 +30,8 @@ import Pos.Chain.Delegation (ProxySKHeavy) import Pos.Chain.Ssc (MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..)) import Pos.Chain.Txp (TxMsgContents (..)) +import Pos.Chain.Update (UpdateProposal, UpdateVote, uvProposalId) import Pos.Core (StakeholderId) -import Pos.Core.Update (UpdateProposal, UpdateVote, uvProposalId) import Pos.Crypto (hash) import Pos.Util.Util (cborError) diff --git a/infra/src/Pos/Infra/Diffusion/Types.hs b/infra/src/Pos/Infra/Diffusion/Types.hs index e2b5fc48b35..f8207603591 100644 --- a/infra/src/Pos/Infra/Diffusion/Types.hs +++ b/infra/src/Pos/Infra/Diffusion/Types.hs @@ -22,8 +22,8 @@ import Pos.Chain.Delegation (ProxySKHeavy) import Pos.Chain.Ssc (InnerSharesMap, Opening, SignedCommitment, VssCertificate) import Pos.Chain.Txp (TxAux) +import Pos.Chain.Update (UpId, UpdateProposal, UpdateVote) import Pos.Core.Chrono (OldestFirst (..)) -import Pos.Core.Update (UpId, UpdateProposal, UpdateVote) import Pos.Infra.Communication.Types.Protocol (NodeId) import Pos.Infra.Diffusion.Subscription.Status (SubscriptionStates, emptySubscriptionStates) diff --git a/infra/test/Test/Pos/Infra/Arbitrary.hs b/infra/test/Test/Pos/Infra/Arbitrary.hs index 30c83711eb5..05e7b6ee66c 100644 --- a/infra/test/Test/Pos/Infra/Arbitrary.hs +++ b/infra/test/Test/Pos/Infra/Arbitrary.hs @@ -25,6 +25,7 @@ import Pos.Infra.Communication.Types.Relay (DataMsg (..), InvMsg (..), import Pos.Infra.DHT (DHTData (..), DHTKey (..)) import Test.Pos.Chain.Delegation.Arbitrary () +import Test.Pos.Chain.Update.Arbitrary () deriving instance Arbitrary DHTData diff --git a/infra/test/Test/Pos/Infra/Arbitrary/Update.hs b/infra/test/Test/Pos/Infra/Arbitrary/Update.hs index e7c967a314b..18521d9071b 100644 --- a/infra/test/Test/Pos/Infra/Arbitrary/Update.hs +++ b/infra/test/Test/Pos/Infra/Arbitrary/Update.hs @@ -13,7 +13,7 @@ import Universum hiding (id) import Test.QuickCheck (Arbitrary (..), listOf) -import Pos.Core.Update (UpdateProposal (..), UpdateVote (..), +import Pos.Chain.Update (UpdateProposal (..), UpdateVote (..), mkUpdateVote) import Pos.Crypto (hash) import Pos.Infra.Communication.Relay (DataMsg (..)) diff --git a/lib/bench/Bench/Pos/Diffusion/BlockDownload.hs b/lib/bench/Bench/Pos/Diffusion/BlockDownload.hs index 9ee9efab54d..0b14cc348bd 100644 --- a/lib/bench/Bench/Pos/Diffusion/BlockDownload.hs +++ b/lib/bench/Bench/Pos/Diffusion/BlockDownload.hs @@ -33,9 +33,9 @@ import qualified Node import Pos.Binary (serialize, serialize') import Pos.Chain.Block (Block, BlockHeader, HeaderHash) import qualified Pos.Chain.Block as Block (getBlockHeader) +import Pos.Chain.Update (BlockVersion (..)) import Pos.Core.Chrono (NewestFirst (..), OldestFirst (..)) import Pos.Core.ProtocolConstants (ProtocolConstants (..)) -import Pos.Core.Update (BlockVersion (..)) import Pos.Crypto (ProtocolMagic (..)) import Pos.Crypto.Hashing (Hash, unsafeMkAbstractHash) import Pos.DB.Class (Serialized (..), SerializedBlock) diff --git a/lib/src/Pos/Communication/Limits.hs b/lib/src/Pos/Communication/Limits.hs index 59d8a08d4ab..14a1a385d04 100644 --- a/lib/src/Pos/Communication/Limits.hs +++ b/lib/src/Pos/Communication/Limits.hs @@ -68,10 +68,10 @@ import Pos.Chain.Ssc (Commitment (..), InnerSharesMap, MCVssCertificate (..), Opening (..), SignedCommitment, VssCertificate) import Pos.Chain.Txp (TxAux, TxMsgContents (..)) +import Pos.Chain.Update (BlockVersionData (..), UpId, + UpdateProposal (..), UpdateVote (..)) import Pos.Core (BlockCount, EpochIndex, StakeholderId, coinPortionToDouble) -import Pos.Core.Update (BlockVersionData (..), UpId, - UpdateProposal (..), UpdateVote (..)) import Pos.Crypto (ProxyCert (..), ProxySecretKey (..), SecretProof (..)) import Pos.Network.Block.Types (MsgBlock (..), MsgGetBlocks (..), diff --git a/lib/src/Pos/DB/DB.hs b/lib/src/Pos/DB/DB.hs index 0c01efa7d02..d75a28f9e11 100644 --- a/lib/src/Pos/DB/DB.hs +++ b/lib/src/Pos/DB/DB.hs @@ -10,7 +10,7 @@ import Universum import Pos.Chain.Block (genesisBlock0, headerHash) import Pos.Chain.Genesis as Genesis (Config (..)) import Pos.Chain.Lrc (genesisLeaders) -import Pos.Core.Update (BlockVersionData) +import Pos.Chain.Update (BlockVersionData) import Pos.DB.Block (prepareBlockDB) import Pos.DB.Class (MonadDB, MonadDBRead (..)) import Pos.DB.Lrc (prepareLrcDB) diff --git a/lib/src/Pos/Diffusion/Full.hs b/lib/src/Pos/Diffusion/Full.hs index d01536e5589..6837687740f 100644 --- a/lib/src/Pos/Diffusion/Full.hs +++ b/lib/src/Pos/Diffusion/Full.hs @@ -39,6 +39,8 @@ import Pos.Chain.Ssc (InnerSharesMap, MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..), Opening, SignedCommitment, VssCertificate) import Pos.Chain.Txp (TxAux) +import Pos.Chain.Update (BlockVersion, BlockVersionData (..), UpId, + UpdateProposal, UpdateVote) import Pos.Communication (EnqueueMsg, HandlerSpecs, InSpecs (..), InvOrDataTK, Listener, MkListeners (..), Msg, MsgSubscribe, MsgSubscribe1, NodeId, OutSpecs (..), @@ -48,8 +50,6 @@ import Pos.Communication (EnqueueMsg, HandlerSpecs, InSpecs (..), import Pos.Core (ProtocolConstants (..), StakeholderId) import Pos.Core.Chrono (OldestFirst) import Pos.Core.Metrics.Constants (withCardanoNamespace) -import Pos.Core.Update (BlockVersion, BlockVersionData (..), UpId, - UpdateProposal, UpdateVote) import Pos.Crypto.Configuration (ProtocolMagic (..)) import qualified Pos.Diffusion.Full.Block as Diffusion.Block import qualified Pos.Diffusion.Full.Delegation as Diffusion.Delegation diff --git a/lib/src/Pos/Diffusion/Full/Block.hs b/lib/src/Pos/Diffusion/Full/Block.hs index 41472c14da7..d38a90bd59b 100644 --- a/lib/src/Pos/Diffusion/Full/Block.hs +++ b/lib/src/Pos/Diffusion/Full/Block.hs @@ -36,6 +36,7 @@ import Pos.Binary.Communication (serializeMsgSerializedBlock, serializeMsgStreamBlock) import Pos.Chain.Block (Block, BlockHeader (..), HeaderHash, MainBlockHeader, blockHeader, headerHash, prevBlockL) +import Pos.Chain.Update (BlockVersionData, bvdSlotDuration) import Pos.Communication.Limits (mlMsgBlock, mlMsgGetBlocks, mlMsgGetHeaders, mlMsgHeaders, mlMsgStream, mlMsgStreamBlock) @@ -45,7 +46,6 @@ import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..), import Pos.Core.Exception (cardanoExceptionFromException, cardanoExceptionToException) import Pos.Core.NetworkAddress (NetworkAddress) -import Pos.Core.Update (BlockVersionData, bvdSlotDuration) import Pos.Crypto (shortHashF) import Pos.DB (DBError (DBMalformed)) import Pos.Infra.Communication.Listener (listenerConv) diff --git a/lib/src/Pos/Diffusion/Full/Update.hs b/lib/src/Pos/Diffusion/Full/Update.hs index ae2c0e346e0..f84e4af94c7 100644 --- a/lib/src/Pos/Diffusion/Full/Update.hs +++ b/lib/src/Pos/Diffusion/Full/Update.hs @@ -13,10 +13,9 @@ import Universum import qualified Network.Broadcast.OutboundQueue as OQ -import Pos.Chain.Update () +import Pos.Chain.Update (UpId, UpdateProposal, UpdateVote, mkVoteId) import Pos.Communication.Limits (mlUpdateProposalAndVotes, mlUpdateVote) -import Pos.Core.Update (UpId, UpdateProposal, UpdateVote, mkVoteId) import Pos.Infra.Communication.Protocol (EnqueueMsg, MkListeners, MsgType (..), NodeId, Origin (..), OutSpecs) import Pos.Infra.Communication.Relay (InvReqDataParams (..), diff --git a/lib/src/Pos/Listener/Update.hs b/lib/src/Pos/Listener/Update.hs index 0fdb2293794..9fae8c85e08 100644 --- a/lib/src/Pos/Listener/Update.hs +++ b/lib/src/Pos/Listener/Update.hs @@ -16,8 +16,8 @@ import Formatting (build, sformat, (%)) import UnliftIO (MonadUnliftIO) import Pos.Chain.Genesis as Genesis (Config) -import Pos.Chain.Update (HasUpdateConfiguration, UpdateParams) -import Pos.Core.Update (UpdateProposal (..), UpdateVote (..)) +import Pos.Chain.Update (HasUpdateConfiguration, UpdateParams, + UpdateProposal (..), UpdateVote (..)) import Pos.DB.Class (MonadDB, MonadGState) import Pos.DB.Lrc (HasLrcContext) import Pos.DB.Update (UpdateContext, processProposal, processVote) diff --git a/lib/src/Pos/Logic/Full.hs b/lib/src/Pos/Logic/Full.hs index 44a78190a0d..744f1223bd6 100644 --- a/lib/src/Pos/Logic/Full.hs +++ b/lib/src/Pos/Logic/Full.hs @@ -27,11 +27,11 @@ import Pos.Chain.Ssc (MCCommitment (..), MCOpening (..), tmCommitments, tmOpenings, tmShares) import Pos.Chain.Txp (MemPool (..), TxAux (..), TxMsgContents (..), TxpConfiguration) +import Pos.Chain.Update (BlockVersionData, UpdateProposal (..), + UpdateVote (..)) import Pos.Communication (NodeId) import Pos.Core (StakeholderId, addressHash) import Pos.Core.Chrono (NE, NewestFirst, OldestFirst) -import Pos.Core.Update (BlockVersionData, UpdateProposal (..), - UpdateVote (..)) import Pos.Crypto (hash) import qualified Pos.DB.Block as Block import qualified Pos.DB.Block as DB (getTipBlock) diff --git a/lib/src/Pos/Logic/Pure.hs b/lib/src/Pos/Logic/Pure.hs index 716aaea2380..5538c0c45ce 100644 --- a/lib/src/Pos/Logic/Pure.hs +++ b/lib/src/Pos/Logic/Pure.hs @@ -23,6 +23,9 @@ import Pos.Chain.Delegation (DlgPayload (..)) import Pos.Chain.Ssc (SscPayload (..), SscProof (..), VssCertificatesMap (..)) import Pos.Chain.Txp (TxProof (..), emptyTxPayload) +import Pos.Chain.Update (ApplicationName (..), BlockVersion (..), + BlockVersionData (..), SoftforkRule (..), + SoftwareVersion (..), UpdatePayload (..), UpdateProof) import Pos.Core (StakeholderId, TxFeePolicy (..), unsafeCoinPortionFromDouble) import Pos.Core.Attributes (Attributes (..), UnparsedFields (..)) @@ -31,9 +34,6 @@ import Pos.Core.Common (BlockCount (..), ChainDifficulty (..)) import Pos.Core.Merkle (MerkleRoot (..)) import Pos.Core.Slotting (EpochIndex (..), LocalSlotIndex (..), SlotId (..)) -import Pos.Core.Update (ApplicationName (..), BlockVersion (..), - BlockVersionData (..), SoftforkRule (..), - SoftwareVersion (..), UpdatePayload (..), UpdateProof) import Pos.Crypto.Configuration (ProtocolMagic (..)) import Pos.Crypto.Hashing (Hash, unsafeMkAbstractHash) import Pos.Crypto.Signing (PublicKey (..), SecretKey (..), diff --git a/lib/src/Pos/Logic/Types.hs b/lib/src/Pos/Logic/Types.hs index ae069f1a6f0..7abd9c9c765 100644 --- a/lib/src/Pos/Logic/Types.hs +++ b/lib/src/Pos/Logic/Types.hs @@ -22,11 +22,11 @@ import Pos.Chain.Security (SecurityParams (..)) import Pos.Chain.Ssc (MCCommitment, MCOpening, MCShares, MCVssCertificate) import Pos.Chain.Txp (TxId, TxMsgContents) +import Pos.Chain.Update (BlockVersionData, UpId, UpdateProposal, + UpdateVote, VoteId) import Pos.Communication (NodeId) import Pos.Core (StakeholderId) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) -import Pos.Core.Update (BlockVersionData, UpId, UpdateProposal, - UpdateVote, VoteId) import Pos.DB.Block (GetHashesRangeError, GetHeadersFromManyToError) import Pos.DB.Class (SerializedBlock) diff --git a/lib/src/Pos/Network/Update/Download.hs b/lib/src/Pos/Network/Update/Download.hs index 41e2eb656b2..c1a4824ca74 100644 --- a/lib/src/Pos/Network/Update/Download.hs +++ b/lib/src/Pos/Network/Update/Download.hs @@ -28,10 +28,9 @@ import System.Directory (doesFileExist) import Pos.Binary.Class (Raw) import Pos.Chain.Update (ConfirmedProposalState (..), - UpdateParams (..), curSoftwareVersion, ourSystemTag) + SoftwareVersion (..), UpdateData (..), UpdateParams (..), + UpdateProposal (..), curSoftwareVersion, ourSystemTag) import Pos.Core.Exception (reportFatalError) -import Pos.Core.Update (SoftwareVersion (..), UpdateData (..), - UpdateProposal (..)) import Pos.Crypto (Hash, castHash, hash) import Pos.DB.Update (UpdateContext (..), isUpdateInstalled) import Pos.Infra.Reporting (reportOrLogW) diff --git a/lib/src/Pos/Worker/Block.hs b/lib/src/Pos/Worker/Block.hs index c07da67be7f..497d432227a 100644 --- a/lib/src/Pos/Worker/Block.hs +++ b/lib/src/Pos/Worker/Block.hs @@ -32,6 +32,7 @@ import Pos.Chain.Genesis as Genesis (Config (..), configBlkSecurityParam, configEpochSlots, configSlotSecurityParam) import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (BlockCount, ChainDifficulty, FlatSlotId, SlotCount, SlotId (..), Timestamp (Timestamp), addressHash, difficultyL, epochOrSlotToSlot, flattenSlotId, @@ -44,7 +45,6 @@ import Pos.Core.Conc (delay) import Pos.Core.JsonLog (CanJsonLog (..)) import Pos.Core.Reporting (HasMisbehaviorMetrics, MetricMonitor (..), MetricMonitorState, noReportMonitor, recordValue) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (ProxySecretKey (pskDelegatePk)) import Pos.DB (gsIsBootstrapEra) import Pos.DB.Block (calcChainQualityFixedTime, calcChainQualityM, diff --git a/lib/src/Pos/Worker/Ssc.hs b/lib/src/Pos/Worker/Ssc.hs index d59cac6f4d5..98fa9de09cd 100644 --- a/lib/src/Pos/Worker/Ssc.hs +++ b/lib/src/Pos/Worker/Ssc.hs @@ -38,6 +38,7 @@ import Pos.Chain.Ssc (HasSscConfiguration, HasSscContext (..), mkSignedCommitment, mkVssCertificate, mpcSendInterval, randCommitmentAndOpening, scBehavior, scParticipateSsc, scVssKeyPair, sgsCommitments, vssThreshold) +import Pos.Chain.Update (BlockVersionData (..)) import Pos.Core (BlockCount, EpochIndex, HasPrimaryKey, SlotId (..), StakeholderId, Timestamp (..), getOurSecretKey, getOurStakeholderId, getSlotIndex, kEpochSlots, @@ -46,7 +47,6 @@ import Pos.Core.Conc (currentTime, delay) import Pos.Core.JsonLog (CanJsonLog) import Pos.Core.Reporting (HasMisbehaviorMetrics (..), MisbehaviorMetrics (..), MonadReporting) -import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (SecretKey, VssKeyPair, VssPublicKey, randomNumber, randomNumberInRange, runSecureRandom, vssKeyGen) import Pos.Crypto.SecretSharing (toVssPublicKey) diff --git a/lib/src/Pos/Worker/Update.hs b/lib/src/Pos/Worker/Update.hs index 72db03b389d..10a2ade406e 100644 --- a/lib/src/Pos/Worker/Update.hs +++ b/lib/src/Pos/Worker/Update.hs @@ -15,8 +15,8 @@ import Pos.Chain.Genesis as Genesis (Config (..), configBlkSecurityParam, configBlockVersionData, configEpochSlots) import Pos.Chain.Update (ConfirmedProposalState (..), + SoftwareVersion (..), UpdateProposal (..), curSoftwareVersion) -import Pos.Core.Update (SoftwareVersion (..), UpdateProposal (..)) import Pos.DB.Update (UpdateContext (..), getConfirmedProposals, processNewSlot) import Pos.Infra.Diffusion.Types (Diffusion) diff --git a/lib/src/Test/Pos/Configuration.hs b/lib/src/Test/Pos/Configuration.hs index 700889da635..ac5341bbec4 100644 --- a/lib/src/Test/Pos/Configuration.hs +++ b/lib/src/Test/Pos/Configuration.hs @@ -34,10 +34,9 @@ import Pos.Chain.Genesis as Genesis (Config, GenesisSpec (..), StaticConfig (..), mkConfig) import Pos.Chain.Ssc (HasSscConfiguration, withSscConfiguration) import Pos.Chain.Txp (TxpConfiguration (..)) -import Pos.Chain.Update (HasUpdateConfiguration, +import Pos.Chain.Update (BlockVersionData, HasUpdateConfiguration, withUpdateConfiguration) import Pos.Configuration (HasNodeConfiguration, withNodeConfiguration) -import Pos.Core.Update (BlockVersionData) import Pos.Launcher.Configuration (Configuration (..), HasConfigurations) import Pos.Util.Config (embedYamlConfigCT) diff --git a/lib/test/Test/Pos/ConstantsSpec.hs b/lib/test/Test/Pos/ConstantsSpec.hs index c73b58b7e22..6e8b92b6801 100644 --- a/lib/test/Test/Pos/ConstantsSpec.hs +++ b/lib/test/Test/Pos/ConstantsSpec.hs @@ -6,8 +6,8 @@ module Test.Pos.ConstantsSpec import Universum -import Pos.Chain.Update (HasUpdateConfiguration, ourSystemTag) -import Pos.Core.Update (SystemTag (..)) +import Pos.Chain.Update (HasUpdateConfiguration, SystemTag (..), + ourSystemTag) import Test.Hspec (Expectation, Spec, describe, it, shouldSatisfy) import Test.Pos.Configuration (withDefUpdateConfiguration) diff --git a/lib/test/Test/Pos/Diffusion/BlockSpec.hs b/lib/test/Test/Pos/Diffusion/BlockSpec.hs index 77c64dd1360..79a13aaf688 100644 --- a/lib/test/Test/Pos/Diffusion/BlockSpec.hs +++ b/lib/test/Test/Pos/Diffusion/BlockSpec.hs @@ -29,9 +29,9 @@ import Pos.Binary.Class (serialize') import Pos.Chain.Block (Block, BlockHeader, HeaderHash, blockHeaderHash) import qualified Pos.Chain.Block as Block (getBlockHeader) +import Pos.Chain.Update (BlockVersion (..)) import Pos.Core.Chrono (NewestFirst (..), OldestFirst (..)) import Pos.Core.ProtocolConstants (ProtocolConstants (..)) -import Pos.Core.Update (BlockVersion (..)) import Pos.Crypto (ProtocolMagic (..)) import Pos.Crypto.Hashing (Hash, unsafeMkAbstractHash) import Pos.DB.Class (Serialized (..), SerializedBlock) diff --git a/lib/test/Test/Pos/Update/MemStateSpec.hs b/lib/test/Test/Pos/Update/MemStateSpec.hs index c24d4dcadcb..35ea43f4e58 100644 --- a/lib/test/Test/Pos/Update/MemStateSpec.hs +++ b/lib/test/Test/Pos/Update/MemStateSpec.hs @@ -10,7 +10,7 @@ import Universum import qualified Data.HashMap.Strict as HM -import qualified Pos.Core.Update as Upd +import qualified Pos.Chain.Update as Upd import Pos.Crypto (PublicKey, hash) import qualified Pos.DB.Update as Upd diff --git a/lib/test/Test/Pos/Update/PollSpec.hs b/lib/test/Test/Pos/Update/PollSpec.hs index 44a1efb6e5a..203888f097f 100644 --- a/lib/test/Test/Pos/Update/PollSpec.hs +++ b/lib/test/Test/Pos/Update/PollSpec.hs @@ -17,12 +17,11 @@ import Test.QuickCheck (Arbitrary (..), Gen, Property, conjoin, import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, genericShrink) -import Pos.Chain.Update (applyBVM) +import Pos.Chain.Update (ApplicationName, BlockVersion (..), + BlockVersionData (..), SoftwareVersion (..), UpId, + UpdateProposal (..), applyBVM) import qualified Pos.Chain.Update as Poll import Pos.Core (StakeholderId, addressHash) -import Pos.Core.Update (ApplicationName, BlockVersion (..), - BlockVersionData (..), SoftwareVersion (..), UpId, - UpdateProposal (..)) import Pos.Crypto (hash) import qualified Pos.DB.Update as Poll import Pos.Infra.Slotting.Types (SlottingData) diff --git a/networking/src/Node/Message/Class.hs b/networking/src/Node/Message/Class.hs index 0f9d8071a68..7592a5d7e08 100644 --- a/networking/src/Node/Message/Class.hs +++ b/networking/src/Node/Message/Class.hs @@ -37,7 +37,7 @@ import Node.Message.Decoder (Decoder, hoistDecoder) import Pos.Chain.Ssc (MCCommitment, MCOpening, MCShares, MCVssCertificate) import Pos.Chain.Txp (TxMsgContents) -import Pos.Core.Update (UpdateProposal, UpdateVote) +import Pos.Chain.Update (UpdateProposal, UpdateVote) -- * Message name diff --git a/pkgs/default.nix b/pkgs/default.nix index d3ebd4d2a89..d92d0646ead 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -14946,6 +14946,7 @@ license = stdenv.lib.licenses.mit; , canonical-json , cardano-sl , cardano-sl-chain +, cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -15016,6 +15017,7 @@ bytestring canonical-json cardano-sl cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -15080,6 +15082,7 @@ executableToolDepends = [ cpphs ]; testHaskellDepends = [ +cardano-sl-chain cardano-sl-core cardano-sl-crypto hspec @@ -15430,6 +15433,7 @@ pvss QuickCheck random serokell-util +time-units universum unordered-containers vector @@ -15485,6 +15489,7 @@ license = stdenv.lib.licenses.mit; , QuickCheck , random , reflection +, serokell-util , stdenv , time-units , universum @@ -15525,6 +15530,7 @@ pvss QuickCheck random reflection +serokell-util time-units universum unordered-containers diff --git a/wallet-new/cardano-sl-wallet-new.cabal b/wallet-new/cardano-sl-wallet-new.cabal index 25be1e3d6d4..c46badef2cc 100755 --- a/wallet-new/cardano-sl-wallet-new.cabal +++ b/wallet-new/cardano-sl-wallet-new.cabal @@ -181,6 +181,7 @@ library , cardano-sl , cardano-sl-binary , cardano-sl-chain + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -326,6 +327,7 @@ executable cardano-generate-swagger-file , bytestring , aeson , cardano-sl-util + , cardano-sl-chain , cardano-sl-core , cardano-sl-wallet-new , optparse-applicative diff --git a/wallet-new/generate-swagger-file/Main.hs b/wallet-new/generate-swagger-file/Main.hs index efc53926d0b..c387a2b3d2e 100644 --- a/wallet-new/generate-swagger-file/Main.hs +++ b/wallet-new/generate-swagger-file/Main.hs @@ -9,7 +9,7 @@ import Options.Applicative import Servant ((:<|>)) import Cardano.Wallet.API (InternalAPI, V1API, v0API) -import Pos.Core.Update (ApplicationName (..), SoftwareVersion (..)) +import Pos.Chain.Update (ApplicationName (..), SoftwareVersion (..)) import Pos.Util.CompileInfo (CompileTimeInfo (CompileTimeInfo), gitRev) diff --git a/wallet-new/src/Cardano/Wallet/API/Internal.hs b/wallet-new/src/Cardano/Wallet/API/Internal.hs index 7fa93273d4a..e44bd19b8e4 100644 --- a/wallet-new/src/Cardano/Wallet/API/Internal.hs +++ b/wallet-new/src/Cardano/Wallet/API/Internal.hs @@ -3,7 +3,7 @@ -- Daedalus client, and aren't useful for wallets, exchanges, and other users. module Cardano.Wallet.API.Internal where -import Pos.Core.Update (SoftwareVersion) +import Pos.Chain.Update (SoftwareVersion) import Servant diff --git a/wallet-new/src/Cardano/Wallet/API/Internal/Handlers.hs b/wallet-new/src/Cardano/Wallet/API/Internal/Handlers.hs index a4a8b028861..10a63cdaaa1 100644 --- a/wallet-new/src/Cardano/Wallet/API/Internal/Handlers.hs +++ b/wallet-new/src/Cardano/Wallet/API/Internal/Handlers.hs @@ -4,7 +4,7 @@ import Universum import Servant -import Pos.Core.Update (SoftwareVersion) +import Pos.Chain.Update (SoftwareVersion) import qualified Cardano.Wallet.API.Internal as Internal import Cardano.Wallet.API.Response (WalletResponse, single) diff --git a/wallet-new/src/Cardano/Wallet/API/Internal/LegacyHandlers.hs b/wallet-new/src/Cardano/Wallet/API/Internal/LegacyHandlers.hs index 37fd46b451b..fa45a9d4eae 100644 --- a/wallet-new/src/Cardano/Wallet/API/Internal/LegacyHandlers.hs +++ b/wallet-new/src/Cardano/Wallet/API/Internal/LegacyHandlers.hs @@ -15,8 +15,8 @@ import Servant import UnliftIO (MonadUnliftIO) import Pos.Chain.Genesis as Genesis (Config) +import Pos.Chain.Update (SoftwareVersion) import qualified Pos.Client.KeyStorage as V0 -import Pos.Core.Update (SoftwareVersion) import Pos.Crypto (emptyPassphrase) import Pos.Util (HasLens (..)) import qualified Pos.Wallet.WalletMode as V0 diff --git a/wallet-new/src/Cardano/Wallet/API/V1/Swagger.hs b/wallet-new/src/Cardano/Wallet/API/V1/Swagger.hs index b6c12a773b9..f1cf005e493 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Swagger.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Swagger.hs @@ -25,7 +25,7 @@ import Cardano.Wallet.API.V1.Swagger.Example import Cardano.Wallet.API.V1.Types import Cardano.Wallet.TypeLits (KnownSymbols (..)) -import Pos.Core.Update (SoftwareVersion) +import Pos.Chain.Update (SoftwareVersion) import Pos.Util.CompileInfo (CompileTimeInfo, ctiGitRevision) import Pos.Util.Servant (CustomQueryFlag, LoggingApi) import Pos.Wallet.Web.Swagger.Instances.Schema () diff --git a/wallet-new/src/Cardano/Wallet/API/V1/Types.hs b/wallet-new/src/Cardano/Wallet/API/V1/Types.hs index a65c4f6f1ea..4613f080ca2 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Types.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Types.hs @@ -187,10 +187,10 @@ import Cardano.Wallet.Util (showApiUtcTime) import qualified Pos.Binary.Class as Bi import qualified Pos.Chain.Txp as Txp +import qualified Pos.Chain.Update as Core import qualified Pos.Client.Txp.Util as Core import Pos.Core (addressF) import qualified Pos.Core as Core -import qualified Pos.Core.Update as Core import Pos.Crypto (Hash, PublicKey (..), decodeHash, hashHexF) import qualified Pos.Crypto.Signing as Core import Pos.Infra.Communication.Types.Protocol () diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs index 68def0a632f..5bdabff3b93 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs @@ -58,8 +58,8 @@ import qualified Formatting.Buildable import Test.QuickCheck (Arbitrary (..), oneof) import Pos.Chain.Txp (TxAux, TxId, Utxo) +import Pos.Chain.Update (SoftwareVersion) import Pos.Core.Chrono (OldestFirst (..)) -import Pos.Core.Update (SoftwareVersion) import Cardano.Wallet.Kernel.DB.BlockContext import Cardano.Wallet.Kernel.DB.HdWallet @@ -408,7 +408,7 @@ switchToFork k n blocks = runUpdateDiscardSnapshot $ zoom dbHdWallets $ -> OldestFirst [] PrefilteredBlock mkPBS = OldestFirst . map (\(bc, mPB) -> fromMaybe (emptyPrefilteredBlock bc) mPB) - . sortBy (comparing (view bcSlotId . fst)) + . sortOn (view bcSlotId . fst) -- | Observable rollback, used for tests only -- diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs index 032972ab51f..b328fa46e59 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs @@ -29,9 +29,9 @@ import qualified Pos.Chain.Block as Core import qualified Pos.Chain.Delegation as Core import qualified Pos.Chain.Ssc as Ssc import qualified Pos.Chain.Txp as Txp +import qualified Pos.Chain.Update as Core import qualified Pos.Core as Core import qualified Pos.Core.Attributes as Core -import qualified Pos.Core.Update as Core import qualified Pos.Crypto as Core import qualified Cardano.Crypto.Wallet as CCW diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/Updates.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/Updates.hs index d0794c4162d..b7557e35634 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/Updates.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/Updates.hs @@ -13,8 +13,8 @@ import Control.Lens (iso, makeLenses, (%=), _Wrapped) import Data.Coerce (coerce) import Data.SafeCopy (base, deriveSafeCopy) +import Pos.Chain.Update (SoftwareVersion (..)) import Pos.Core.Chrono -import Pos.Core.Update (SoftwareVersion (..)) import Cardano.Wallet.Kernel.DB.InDb import Cardano.Wallet.Kernel.DB.Util.AcidState diff --git a/wallet-new/src/Cardano/Wallet/Orphans/Arbitrary.hs b/wallet-new/src/Cardano/Wallet/Orphans/Arbitrary.hs index 6e3a07afbcf..b18be75849f 100644 --- a/wallet-new/src/Cardano/Wallet/Orphans/Arbitrary.hs +++ b/wallet-new/src/Cardano/Wallet/Orphans/Arbitrary.hs @@ -15,6 +15,7 @@ import Pos.Wallet.Web.ClientTypes.Types import Pos.Wallet.Web.Methods.Misc (WalletStateSnapshot (..)) import Pos.Wallet.Web.State.Storage (WalletStorage (..)) +import Test.Pos.Chain.Update.Arbitrary () import Test.Pos.Core.Arbitrary () instance Arbitrary NoContent where diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer.hs b/wallet-new/src/Cardano/Wallet/WalletLayer.hs index 093f6829d61..2260c1f934d 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer.hs @@ -33,10 +33,9 @@ import Test.QuickCheck (Arbitrary (..), oneof) import Pos.Chain.Block (Blund) import Pos.Chain.Txp (Tx, TxId, Utxo) -import Pos.Chain.Update (ConfirmedProposalState) +import Pos.Chain.Update (ConfirmedProposalState, SoftwareVersion) import Pos.Core (Coin, Timestamp) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) -import Pos.Core.Update (SoftwareVersion) import Pos.Crypto (EncryptedSecretKey, PassPhrase) import Cardano.Wallet.API.Request (RequestParams (..)) diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Internal.hs b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Internal.hs index b9e73d64732..32d927f95f3 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Internal.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Internal.hs @@ -15,8 +15,7 @@ import Control.Concurrent.MVar (modifyMVar_) import Data.Acid.Advanced (update') import System.IO.Error (isDoesNotExistError) -import Pos.Chain.Update (ConfirmedProposalState) -import Pos.Core.Update (SoftwareVersion) +import Pos.Chain.Update (ConfirmedProposalState, SoftwareVersion) import Cardano.Wallet.API.V1.Types (V1 (..), Wallet, WalletImport (..)) @@ -124,4 +123,3 @@ importWallet pw WalletImport{..} = liftIO $ do return $ case res of Left e -> Left (ImportWalletCreationFailed e) Right importedWallet -> Right importedWallet - diff --git a/wallet-new/test/MarshallingSpec.hs b/wallet-new/test/MarshallingSpec.hs index 43cbd744c5f..e9f6f5d4bc7 100644 --- a/wallet-new/test/MarshallingSpec.hs +++ b/wallet-new/test/MarshallingSpec.hs @@ -30,9 +30,9 @@ import qualified Pos.Chain.Block as Core import qualified Pos.Chain.Delegation as Core import qualified Pos.Chain.Ssc as Ssc import qualified Pos.Chain.Txp as Txp +import qualified Pos.Chain.Update as Core import qualified Pos.Core as Core import qualified Pos.Core.Attributes as Core -import qualified Pos.Core.Update as Core import qualified Pos.Crypto as Core import Test.Pos.Chain.Block.Arbitrary () diff --git a/wallet-new/test/unit/UTxO/Verify.hs b/wallet-new/test/unit/UTxO/Verify.hs index 50b5e0a6be8..b702a80b59a 100644 --- a/wallet-new/test/unit/UTxO/Verify.hs +++ b/wallet-new/test/unit/UTxO/Verify.hs @@ -32,7 +32,6 @@ import Pos.Chain.Txp import Pos.Chain.Update import Pos.Core import Pos.Core.Chrono -import Pos.Core.Update (BlockVersionData) import Pos.DB.Block (toTxpBlock) import Pos.DB.Class (MonadGState (..)) import Pos.DB.Txp (TxpBlock) diff --git a/wallet/src/Pos/Wallet/Web/Api.hs b/wallet/src/Pos/Wallet/Web/Api.hs index 71a419a549c..dae03c3d00a 100644 --- a/wallet/src/Pos/Wallet/Web/Api.hs +++ b/wallet/src/Pos/Wallet/Web/Api.hs @@ -59,9 +59,9 @@ import Servant.API.ContentTypes (NoContent, OctetStream) import Servant.Generic ((:-), AsApi, ToServant) import Servant.Swagger.UI (SwaggerSchemaUI) +import Pos.Chain.Update (SoftwareVersion) import Pos.Client.Txp.Util (InputSelectionPolicy) import Pos.Core (Coin) -import Pos.Core.Update (SoftwareVersion) import Pos.Util.Servant (ApiLoggingConfig (..), CCapture, CQueryParam, CReqBody, DCQueryParam, DReqBody, LoggingApi, ModifiesApiRes (..), ReportDecodeError (..), VerbMod, diff --git a/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs b/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs index b24005ffa85..85edcb688db 100644 --- a/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs +++ b/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs @@ -18,14 +18,13 @@ import Data.Text (Text) import Formatting (build, sformat) import Pos.Chain.Txp (Tx (..), TxOut (..), txOutAddress, txOutValue) -import Pos.Chain.Update (ConfirmedProposalState (..), - StakeholderVotes, isPositiveVote) +import Pos.Chain.Update (BlockVersionData (..), + BlockVersionModifier (..), ConfirmedProposalState (..), + StakeholderVotes, UpdateProposal (..), isPositiveVote) import Pos.Client.Txp.History (TxHistoryEntry (..)) import Pos.Core (Address, ChainDifficulty, decodeTextAddress, makePubKeyAddressBoot, sumCoins, unsafeAddCoin, unsafeIntegerToCoin) -import Pos.Core.Update (BlockVersionData (..), - BlockVersionModifier (..), UpdateProposal (..)) import Pos.Crypto (EncryptedSecretKey, encToPublic) import Pos.Util.Servant import Pos.Wallet.Web.ClientTypes.Instances () diff --git a/wallet/src/Pos/Wallet/Web/ClientTypes/Types.hs b/wallet/src/Pos/Wallet/Web/ClientTypes/Types.hs index fadc6cae7d6..b1ee3af546c 100644 --- a/wallet/src/Pos/Wallet/Web/ClientTypes/Types.hs +++ b/wallet/src/Pos/Wallet/Web/ClientTypes/Types.hs @@ -76,9 +76,9 @@ import Data.Time.Clock.POSIX (POSIXTime) import Data.Typeable (Typeable) import Data.Version (Version) import Formatting (bprint, build, builder, later, shown, (%)) +import Pos.Chain.Update (BlockVersion, SoftwareVersion) import Pos.Client.Txp.Util (InputSelectionPolicy) import Pos.Core (ChainDifficulty, Coin, ScriptVersion, unsafeGetCoin) -import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Infra.Util.LogSafe (BuildableSafeGen (..), SecureLog (..), buildUnsecure, deriveSafeBuildable, secretOnlyF, secureListF) diff --git a/wallet/src/Pos/Wallet/Web/Methods/Misc.hs b/wallet/src/Pos/Wallet/Web/Methods/Misc.hs index 8bb43aca575..8d5b5885307 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Misc.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Misc.hs @@ -45,12 +45,12 @@ import UnliftIO (MonadUnliftIO) import Ntp.Client (NtpStatus (..)) import Pos.Chain.Txp (TxId, TxIn, TxOut) -import Pos.Chain.Update (HasUpdateConfiguration, curSoftwareVersion) +import Pos.Chain.Update (HasUpdateConfiguration, SoftwareVersion (..), + curSoftwareVersion) import Pos.Client.KeyStorage (MonadKeys (..), deleteAllSecretKeys) import Pos.Configuration (HasNodeConfiguration) import Pos.Core (ProtocolConstants, SlotId, pcEpochSlots) import Pos.Core.Conc (async, delay) -import Pos.Core.Update (SoftwareVersion (..)) import Pos.Crypto (hashHexF) import Pos.Infra.Shutdown (HasShutdownContext, triggerShutdown) import Pos.Infra.Slotting (MonadSlots, getCurrentSlotBlocking) diff --git a/wallet/src/Pos/Wallet/Web/Swagger/Instances/Schema.hs b/wallet/src/Pos/Wallet/Web/Swagger/Instances/Schema.hs index 26b285930b3..d99d0eb5421 100644 --- a/wallet/src/Pos/Wallet/Web/Swagger/Instances/Schema.hs +++ b/wallet/src/Pos/Wallet/Web/Swagger/Instances/Schema.hs @@ -26,11 +26,11 @@ import Data.Version (Version) import Servant.Multipart (FileData (..)) +import Pos.Chain.Update (ApplicationName, BlockVersion, + SoftwareVersion) import Pos.Client.Txp.Util (InputSelectionPolicy (..)) import Pos.Core (BlockCount (..), ChainDifficulty, Coin, SlotCount (..), mkCoin) -import Pos.Core.Update (ApplicationName, BlockVersion, - SoftwareVersion) import Pos.Util.Mnemonic (Mnemonic) import qualified Pos.Wallet.Web.ClientTypes as CT diff --git a/wallet/test/Test/Pos/Wallet/MigrationSpec.hs b/wallet/test/Test/Pos/Wallet/MigrationSpec.hs index eb75f3dd025..406b4f09650 100644 --- a/wallet/test/Test/Pos/Wallet/MigrationSpec.hs +++ b/wallet/test/Test/Pos/Wallet/MigrationSpec.hs @@ -32,6 +32,7 @@ import Pos.Wallet.Web.State.State (askWalletSnapshot) import Pos.Wallet.Web.State.Storage import Test.Pos.Chain.Txp.Arbitrary () +import Test.Pos.Chain.Update.Arbitrary () import Test.Pos.Core.Arbitrary () -------------------------------------------------------------------------------- diff --git a/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs b/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs index 738d9be3b86..c220f5b4c77 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs @@ -24,11 +24,11 @@ import Test.QuickCheck.Monadic (pick) import Pos.Chain.Txp (Tx (..), TxAux (..), TxFee (..), TxpConfiguration, _TxOut) +import Pos.Chain.Update (bvdTxFeePolicy) import Pos.Client.Txp.Balances (getBalance) import Pos.Client.Txp.Util (InputSelectionPolicy (..), txToLinearFee) import Pos.Core (Address, Coin, TxFeePolicy (..), mkCoin, sumCoins, unsafeGetCoin, unsafeSubCoin) -import Pos.Core.Update (bvdTxFeePolicy) import Pos.Crypto (PassPhrase) import Pos.DB.Class (MonadGState (..)) import Pos.Launcher (HasConfigurations)