diff --git a/auxx/src/Command/Proc.hs b/auxx/src/Command/Proc.hs index c266924e2f3..5c424575316 100644 --- a/auxx/src/Command/Proc.hs +++ b/auxx/src/Command/Proc.hs @@ -16,7 +16,7 @@ import System.Wlog (CanLog, HasLoggerName, logError, logInfo, logWarning) import qualified Text.JSON.Canonical as CanonicalJSON -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxOut (..), TxpConfiguration) import Pos.Chain.Update (BlockVersionModifier (..)) import Pos.Client.KeyStorage (addSecretKey, getSecretKeysPlain) import Pos.Client.Txp.Balances (getBalance) @@ -26,7 +26,6 @@ import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..), makeAddress) import Pos.Core.Configuration (genesisSecretKeys) import Pos.Core.Delegation (HeavyDlgIndex (..)) -import Pos.Core.Txp (TxOut (..)) import Pos.Core.Update (SoftwareVersion (..)) import Pos.Crypto (ProtocolMagic, PublicKey, emptyPassphrase, encToPublic, fullPublicKeyF, hashHexF, noPassEncrypt, diff --git a/auxx/src/Command/Rollback.hs b/auxx/src/Command/Rollback.hs index 10f0bc5ef0a..928bbcc0e01 100644 --- a/auxx/src/Command/Rollback.hs +++ b/auxx/src/Command/Rollback.hs @@ -14,10 +14,9 @@ import Formatting (build, int, sformat, string, (%)) import System.Wlog (logInfo) import Pos.Chain.Block (Blund, mainBlockTxPayload) -import Pos.Chain.Txp (flattenTxPayload) +import Pos.Chain.Txp (TxAux, flattenTxPayload) import Pos.Core (difficultyL, epochIndexL) import Pos.Core.Chrono (NewestFirst, _NewestFirst) -import Pos.Core.Txp (TxAux) import Pos.Crypto (ProtocolMagic) import Pos.DB.Block (BypassSecurityCheck (..), ShouldCallBListener (..), rollbackBlocksUnsafe) diff --git a/auxx/src/Command/Tx.hs b/auxx/src/Command/Tx.hs index c890e29b7e3..19fa361dea8 100644 --- a/auxx/src/Command/Tx.hs +++ b/auxx/src/Command/Tx.hs @@ -34,7 +34,8 @@ import System.IO (BufferMode (LineBuffering), hClose, hSetBuffering) import System.Wlog (logError, logInfo) import UnliftIO (MonadUnliftIO) -import Pos.Chain.Txp (topsortTxAuxes) +import Pos.Chain.Txp (TxAux (..), TxIn (TxInUtxo), TxOut (..), + TxOutAux (..), topsortTxAuxes, txaF) import Pos.Client.KeyStorage (getSecretKeysPlain) import Pos.Client.Txp.Balances (getOwnUtxoForPk) import Pos.Client.Txp.Network (prepareMTx, submitTxRaw) @@ -45,8 +46,6 @@ import Pos.Core.Conc (concurrently, currentTime, delay, forConcurrently, modifySharedAtomic, newSharedAtomic) import Pos.Core.Configuration (genesisBlockVersionData, genesisSecretKeys) -import Pos.Core.Txp (TxAux (..), TxIn (TxInUtxo), TxOut (..), - TxOutAux (..), txaF) import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (EncryptedSecretKey, ProtocolMagic, emptyPassphrase, encToPublic, fakeSigner, hash, safeToPublic, toPublic, diff --git a/auxx/src/Command/TyProjection.hs b/auxx/src/Command/TyProjection.hs index e151c807bc2..feae5cd5dbf 100644 --- a/auxx/src/Command/TyProjection.hs +++ b/auxx/src/Command/TyProjection.hs @@ -36,12 +36,12 @@ import Data.Time.Units (Microsecond, TimeUnit, convertUnit, fromMicroseconds) import Serokell.Data.Memory.Units (Byte, fromBytes) +import Pos.Chain.Txp (TxOut (..)) import Pos.Chain.Update (ApplicationName (..), BlockVersionModifier (..), SystemTag (..)) import Pos.Core (AddrStakeDistribution (..), Address, Coin, CoinPortion, EpochIndex, ScriptVersion, StakeholderId, mkCoin, unsafeCoinPortionFromDouble, unsafeGetCoin) -import Pos.Core.Txp (TxOut (..)) import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Crypto (AHash (..), Hash, PublicKey) diff --git a/auxx/src/Lang/Value.hs b/auxx/src/Lang/Value.hs index b5611791a5c..825c43cd651 100644 --- a/auxx/src/Lang/Value.hs +++ b/auxx/src/Lang/Value.hs @@ -36,11 +36,11 @@ import Universum import Control.Lens (makePrisms) import Data.Scientific (Scientific) +import Pos.Chain.Txp (TxOut) import Pos.Chain.Update (BlockVersionData, BlockVersionModifier, SystemTag) import Pos.Core (AddrStakeDistribution, Address, CoinPortion, StakeholderId) -import Pos.Core.Txp (TxOut) import Pos.Core.Update (BlockVersion, SoftwareVersion) import Pos.Crypto (AHash, PublicKey) diff --git a/chain/bench/block-bench.hs b/chain/bench/block-bench.hs index 1a64b7351ed..631ebb8cb6b 100644 --- a/chain/bench/block-bench.hs +++ b/chain/bench/block-bench.hs @@ -15,10 +15,10 @@ import Pos.Chain.Block (Body, BodyProof, ConsensusData, ExtraBodyData, MainBlockchain, _gbBody, _gbExtra, _gbHeader, _gbhBodyProof, _gbhConsensus, _gbhExtra, _mbDlgPayload, _mbSscPayload, _mbTxPayload, _mbUpdatePayload) +import Pos.Chain.Txp (TxPayload (..)) import Pos.Core.Delegation (DlgPayload) import Pos.Core.ProtocolConstants (ProtocolConstants (..)) import Pos.Core.Ssc (SscPayload) -import Pos.Core.Txp (TxPayload (..)) import Pos.Core.Update (UpdatePayload) import Pos.Crypto (ProtocolMagic (..)) diff --git a/chain/cardano-sl-chain.cabal b/chain/cardano-sl-chain.cabal index 7ca71375b18..17c6ff85f71 100644 --- a/chain/cardano-sl-chain.cabal +++ b/chain/cardano-sl-chain.cabal @@ -70,6 +70,14 @@ library Pos.Chain.Txp.Toil.Utxo Pos.Chain.Txp.Toil.Utxo.Functions Pos.Chain.Txp.Toil.Utxo.Util + Pos.Chain.Txp.Tx + Pos.Chain.Txp.TxAux + Pos.Chain.Txp.TxMsg + Pos.Chain.Txp.TxOutAux + Pos.Chain.Txp.TxPayload + Pos.Chain.Txp.TxProof + Pos.Chain.Txp.TxWitness + Pos.Chain.Txp.Undo Pos.Chain.Lrc.Fts Pos.Chain.Lrc.Types @@ -207,14 +215,19 @@ test-suite test Test.Pos.Chain.Ssc.Gen Test.Pos.Chain.Ssc.Json Test.Pos.Chain.Ssc.Arbitrary + Test.Pos.Chain.Txp.Arbitrary + Test.Pos.Chain.Txp.Arbitrary.Unsafe + Test.Pos.Chain.Txp.Bi Test.Pos.Chain.Txp.CoreSpec Test.Pos.Chain.Txp.Gen Test.Pos.Chain.Txp.Json + Test.Pos.Chain.Txp.Example Test.Pos.Chain.Txp.Toil.UtxoSpec Test.Pos.Chain.Update.Arbitrary Test.Pos.Chain.Update.Arbitrary.Core build-depends: base + , base16-bytestring , bytestring , cardano-crypto , cardano-sl-binary @@ -227,6 +240,7 @@ test-suite test , cardano-sl-util , cardano-sl-util-test , containers + , data-default , fmt , formatting , generic-arbitrary @@ -242,29 +256,8 @@ test-suite test , unordered-containers , vector default-language: Haskell2010 - default-extensions: DeriveDataTypeable - DeriveGeneric - GeneralizedNewtypeDeriving - StandaloneDeriving - FlexibleContexts - FlexibleInstances - MultiParamTypeClasses - FunctionalDependencies - DefaultSignatures - NoImplicitPrelude + default-extensions: NoImplicitPrelude OverloadedStrings - RecordWildCards - TypeApplications - TupleSections - ViewPatterns - LambdaCase - MultiWayIf - ConstraintKinds - UndecidableInstances - BangPatterns - TemplateHaskell - ScopedTypeVariables - MonadFailDesugaring benchmark block-bench main-is: block-bench.hs @@ -277,6 +270,7 @@ benchmark block-bench Test.Pos.Chain.Block.Arbitrary.Generate Test.Pos.Chain.Delegation.Arbitrary Test.Pos.Chain.Ssc.Arbitrary + Test.Pos.Chain.Txp.Arbitrary Test.Pos.Chain.Update.Arbitrary Test.Pos.Chain.Update.Arbitrary.Core @@ -292,6 +286,7 @@ benchmark block-bench , cardano-sl-core-test , cardano-sl-crypto-test , cardano-sl-util-test + , data-default , deepseq , formatting , generic-arbitrary @@ -299,3 +294,6 @@ benchmark block-bench , text , universum , unordered-containers + , vector + default-extensions: NoImplicitPrelude + OverloadedStrings diff --git a/chain/src/Pos/Chain/Block/BHelpers.hs b/chain/src/Pos/Chain/Block/BHelpers.hs index 2750b5d881f..1932e19fe83 100644 --- a/chain/src/Pos/Chain/Block/BHelpers.hs +++ b/chain/src/Pos/Chain/Block/BHelpers.hs @@ -30,11 +30,11 @@ import Pos.Chain.Block.Union (Block, BlockHeader (..), MainConsensusData (..), MainToSign (..), mainBlockEBDataProof) import Pos.Chain.Ssc (verifySscPayload) +import Pos.Chain.Txp (checkTxPayload) import Pos.Core.Configuration (HasProtocolConstants) import Pos.Core.Delegation (LightDlgIndices (..), checkDlgPayload) import Pos.Core.Slotting (SlotId (..)) import Pos.Core.Ssc (checkSscPayload) -import Pos.Core.Txp (checkTxPayload) import Pos.Core.Update (checkSoftwareVersion, checkUpdatePayload) import Pos.Crypto (ProtocolMagic, ProxySignature (..), SignTag (..), checkSig, hash, isSelfSignedPsk, proxyVerify) diff --git a/chain/src/Pos/Chain/Block/JsonLog.hs b/chain/src/Pos/Chain/Block/JsonLog.hs index b84863459b8..6251eb5b901 100644 --- a/chain/src/Pos/Chain/Block/JsonLog.hs +++ b/chain/src/Pos/Chain/Block/JsonLog.hs @@ -11,10 +11,10 @@ import Pos.Chain.Block.Blockchain (gbHeader, gbhPrevBlock) import Pos.Chain.Block.Genesis (genBlockEpoch) import Pos.Chain.Block.Union (Block, HeaderHash, headerHash, headerHashF, mainBlockSlot, mainBlockTxPayload) +import Pos.Chain.Txp (txpTxs) import Pos.Core (HasConfiguration, SlotId (..), getEpochIndex, getSlotIndex, mkLocalSlotIndex) import Pos.Core.JsonLog.LogEvents (JLBlock (..), JLEvent (..)) -import Pos.Core.Txp (txpTxs) import Pos.Crypto (hash, hashHexF) -- | Return event of created block. diff --git a/chain/src/Pos/Chain/Block/Main/Types.hs b/chain/src/Pos/Chain/Block/Main/Types.hs index ecad7b2783b..9e1191ab01c 100644 --- a/chain/src/Pos/Chain/Block/Main/Types.hs +++ b/chain/src/Pos/Chain/Block/Main/Types.hs @@ -20,10 +20,11 @@ import qualified Formatting.Buildable as Buildable import Pos.Binary.Class (Bi (..), Cons (..), Field (..), deriveSimpleBi, encodeListLen, enforceSize) +import Pos.Chain.Txp.TxPayload (TxPayload) +import Pos.Chain.Txp.TxProof (TxProof) import Pos.Core.Attributes (Attributes, areAttributesKnown) import Pos.Core.Delegation (DlgPayload) import Pos.Core.Ssc (SscPayload, SscProof) -import Pos.Core.Txp (TxPayload, TxProof) import Pos.Core.Update (BlockVersion, SoftwareVersion, UpdatePayload, UpdateProof) import Pos.Crypto (Hash) diff --git a/chain/src/Pos/Chain/Block/Types.hs b/chain/src/Pos/Chain/Block/Types.hs index a72718489e8..feee88fa89a 100644 --- a/chain/src/Pos/Chain/Block/Types.hs +++ b/chain/src/Pos/Chain/Block/Types.hs @@ -20,9 +20,9 @@ import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) import Pos.Chain.Block.Slog.Types (SlogUndo (..)) import Pos.Chain.Block.Union (Block, BlockHeader, HasHeaderHash (..)) import Pos.Chain.Delegation (DlgUndo) +import Pos.Chain.Txp (TxpUndo) import Pos.Chain.Update (USUndo) import Pos.Core (HasConfiguration, HasDifficulty (..)) -import Pos.Core.Txp (TxpUndo) import Pos.Util.Util (HasLens (..)) -- | Structure for undo block during rollback diff --git a/chain/src/Pos/Chain/Block/Union/Types.hs b/chain/src/Pos/Chain/Block/Union/Types.hs index 1dd1dfc3f09..19be23c1b5a 100644 --- a/chain/src/Pos/Chain/Block/Union/Types.hs +++ b/chain/src/Pos/Chain/Block/Union/Types.hs @@ -127,13 +127,15 @@ import Pos.Chain.Block.Genesis.Types (GenesisBody (..), import Pos.Chain.Block.Main.Types (BlockBodyAttributes, BlockHeaderAttributes, MainBody (..), MainExtraBodyData, MainExtraHeaderData, MainProof (..)) +import Pos.Chain.Txp.Tx (Tx) +import Pos.Chain.Txp.TxPayload (TxPayload, txpTxs, txpWitnesses) +import Pos.Chain.Txp.TxProof (mkTxProof) +import Pos.Chain.Txp.TxWitness (TxWitness) import Pos.Core.Common (ChainDifficulty, HasDifficulty (..)) import Pos.Core.Delegation (DlgPayload, ProxySigHeavy, ProxySigLight) import Pos.Core.Slotting (EpochOrSlot (..), HasEpochIndex (..), HasEpochOrSlot (..), SlotId (..), slotIdF) import Pos.Core.Ssc (SscPayload, mkSscProof) -import Pos.Core.Txp (Tx, TxPayload, TxWitness, mkTxProof, txpTxs, - txpWitnesses) import Pos.Core.Update (BlockVersion, HasBlockVersion (..), HasSoftwareVersion (..), SoftwareVersion, UpdatePayload, mkUpdateProof) diff --git a/chain/src/Pos/Chain/Script.hs b/chain/src/Pos/Chain/Script.hs index c8f3e31063f..c8f36fc2a38 100644 --- a/chain/src/Pos/Chain/Script.hs +++ b/chain/src/Pos/Chain/Script.hs @@ -38,10 +38,10 @@ import System.IO.Unsafe (unsafePerformIO) import qualified Utils.Names as PL import qualified Pos.Binary.Class as Bi +import Pos.Chain.Txp.TxWitness (TxSigData (..)) import Pos.Core.Binary () import Pos.Core.Common (Script (..), ScriptVersion) import Pos.Core.Script () -import Pos.Core.Txp (TxSigData (..)) {- NOTE diff --git a/chain/src/Pos/Chain/Script/Examples.hs b/chain/src/Pos/Chain/Script/Examples.hs index b40f9e7c38b..812eef273d9 100644 --- a/chain/src/Pos/Chain/Script/Examples.hs +++ b/chain/src/Pos/Chain/Script/Examples.hs @@ -36,8 +36,8 @@ import Serokell.Util.Base16 (base16F) import Universum import Pos.Chain.Script (Script, parseRedeemer, parseValidator) +import Pos.Chain.Txp (TxSigData) import Pos.Core (StakeholderId) -import Pos.Core.Txp (TxSigData) import Pos.Crypto (SafeSigner, SignTag (SignTx), deterministicKeyGen, fullPublicKeyHexF, fullSignatureHexF, hashHexF, safeSign, safeToPublic, signRaw, signTag) diff --git a/chain/src/Pos/Chain/Txp.hs b/chain/src/Pos/Chain/Txp.hs index 3d8eb6f3193..6082c865205 100644 --- a/chain/src/Pos/Chain/Txp.hs +++ b/chain/src/Pos/Chain/Txp.hs @@ -1,19 +1,20 @@ -- | Txp system reexports. module Pos.Chain.Txp - ( module Pos.Core.Txp - , module Pos.Chain.Txp.Base - , module Pos.Chain.Txp.Configuration - , module Pos.Chain.Txp.Error - , module Pos.Chain.Txp.Toil - , module Pos.Chain.Txp.Topsort - , module Pos.Chain.Txp.GenesisUtxo + ( module X ) where -import Pos.Chain.Txp.Base -import Pos.Chain.Txp.Configuration -import Pos.Chain.Txp.Error -import Pos.Chain.Txp.GenesisUtxo -import Pos.Chain.Txp.Toil -import Pos.Chain.Txp.Topsort -import Pos.Core.Txp +import Pos.Chain.Txp.Base as X +import Pos.Chain.Txp.Configuration as X +import Pos.Chain.Txp.Error as X +import Pos.Chain.Txp.GenesisUtxo as X +import Pos.Chain.Txp.Toil as X +import Pos.Chain.Txp.Topsort as X +import Pos.Chain.Txp.Tx as X +import Pos.Chain.Txp.TxAux as X +import Pos.Chain.Txp.TxMsg as X +import Pos.Chain.Txp.TxOutAux as X +import Pos.Chain.Txp.TxPayload as X +import Pos.Chain.Txp.TxProof as X +import Pos.Chain.Txp.TxWitness as X +import Pos.Chain.Txp.Undo as X diff --git a/chain/src/Pos/Chain/Txp/Base.hs b/chain/src/Pos/Chain/Txp/Base.hs index ddfc6fd818d..8193ddf08d9 100644 --- a/chain/src/Pos/Chain/Txp/Base.hs +++ b/chain/src/Pos/Chain/Txp/Base.hs @@ -17,14 +17,16 @@ import qualified Data.HashSet as HS import Data.List (zipWith) import qualified Data.Map.Strict as M +import Pos.Chain.Txp.Tx (TxOut (..)) +import Pos.Chain.Txp.TxAux (TxAux (..)) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) +import Pos.Chain.Txp.TxPayload (TxPayload (..), mkTxPayload) import Pos.Core (AddrStakeDistribution (..), Address (..), Coin, CoinPortion, StakeholderId, StakesList, aaStakeDistribution, addrAttributesUnwrapped, applyCoinPortionDown, coinToInteger, mkCoin, sumCoins, unsafeAddCoin, unsafeGetCoin, unsafeIntegerToCoin) import Pos.Core.Genesis (GenesisWStakeholders (..)) -import Pos.Core.Txp (TxAux (..), TxOut (..), TxOutAux (..), - TxPayload (..), mkTxPayload) import Pos.Crypto (hash) import Pos.Crypto.Random (deterministic, randomNumber) diff --git a/chain/src/Pos/Chain/Txp/GenesisUtxo.hs b/chain/src/Pos/Chain/Txp/GenesisUtxo.hs index bc9388dee2e..be89c2f9d30 100644 --- a/chain/src/Pos/Chain/Txp/GenesisUtxo.hs +++ b/chain/src/Pos/Chain/Txp/GenesisUtxo.hs @@ -13,11 +13,12 @@ import qualified Data.HashMap.Strict as HM import qualified Data.Map.Strict as Map import Pos.Chain.Txp.Toil (GenesisUtxo (..), utxoToStakes) +import Pos.Chain.Txp.Tx (TxIn (..), TxOut (..)) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) import Pos.Core (Address, Coin, HasGenesisData, StakesMap, genesisData, makeRedeemAddress) import Pos.Core.Genesis (GenesisData (..), getGenesisAvvmBalances, getGenesisNonAvvmBalances) -import Pos.Core.Txp (TxIn (..), TxOut (..), TxOutAux (..)) import Pos.Crypto (unsafeHash) diff --git a/chain/src/Pos/Chain/Txp/Toil/Failure.hs b/chain/src/Pos/Chain/Txp/Toil/Failure.hs index f2df068bffd..ba6da419762 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Failure.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Failure.hs @@ -20,10 +20,11 @@ import Serokell.Util (listJson) import Pos.Chain.Block.Union (HeaderHash) import Pos.Chain.Script (PlutusError) import Pos.Chain.Txp.Toil.Types (TxFee) +import Pos.Chain.Txp.Tx (TxIn, TxOut (..)) +import Pos.Chain.Txp.TxWitness (TxInWitness) import Pos.Core (Address, ScriptVersion, TxFeePolicy, addressDetailedF, addressF) import Pos.Core.Attributes (UnparsedFields) -import Pos.Core.Txp (TxIn, TxInWitness, TxOut (..)) import Pos.Util (DisallowException) ---------------------------------------------------------------------------- diff --git a/chain/src/Pos/Chain/Txp/Toil/Logic.hs b/chain/src/Pos/Chain/Txp/Toil/Logic.hs index 9851c395735..565b19dd776 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Logic.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Logic.hs @@ -31,14 +31,16 @@ import Pos.Chain.Txp.Toil.Types (TxFee (..)) import Pos.Chain.Txp.Toil.Utxo (VerifyTxUtxoRes (..)) import qualified Pos.Chain.Txp.Toil.Utxo as Utxo import Pos.Chain.Txp.Topsort (topsortTxs) +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.Core (AddrAttributes (..), AddrStakeDistribution (..), Address, EpochIndex, HasGenesisData, addrAttributesUnwrapped, isRedeemAddress) import Pos.Core.Common (integerToCoin) import qualified Pos.Core.Common as Fee (TxFeePolicy (..), calculateTxSizeLinear) -import Pos.Core.Txp (Tx (..), TxAux (..), TxId, TxOut (..), TxUndo, - TxpUndo, checkTxAux, toaOut, txOutAddress) import Pos.Core.Update (BlockVersionData (..), isBootstrapEraBVD) import Pos.Crypto (ProtocolMagic, WithHash (..), hash) import Pos.Util (liftEither) diff --git a/chain/src/Pos/Chain/Txp/Toil/Monad.hs b/chain/src/Pos/Chain/Txp/Toil/Monad.hs index cc7ccff3600..fbc99ab9f96 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Monad.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Monad.hs @@ -62,8 +62,11 @@ import System.Wlog (NamedPureLogger, WithLogger, launchNamedPureLog) import Pos.Chain.Txp.Toil.Types (MemPool, StakesView, UndoMap, UtxoLookup, UtxoModifier, mpLocalTxs, mpSize, svStakes, svTotal) +import Pos.Chain.Txp.Tx (TxId, TxIn) +import Pos.Chain.Txp.TxAux (TxAux) +import Pos.Chain.Txp.TxOutAux (TxOutAux) +import Pos.Chain.Txp.Undo (TxUndo) import Pos.Core.Common (Coin, StakeholderId) -import Pos.Core.Txp (TxAux, TxId, TxIn, TxOutAux, TxUndo) import Pos.Util (type (~>)) import qualified Pos.Util.Modifier as MM diff --git a/chain/src/Pos/Chain/Txp/Toil/Stakes.hs b/chain/src/Pos/Chain/Txp/Toil/Stakes.hs index 5d1c3857396..2f3f3259e41 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Stakes.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Stakes.hs @@ -19,10 +19,13 @@ import System.Wlog (logDebug) import Pos.Chain.Txp.Base (txOutStake) import Pos.Chain.Txp.Toil.Monad (GlobalToilM, getStake, getTotalStake, setStake, setTotalStake) +import Pos.Chain.Txp.Tx (Tx (..)) +import Pos.Chain.Txp.TxAux (TxAux (..)) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) +import Pos.Chain.Txp.Undo (TxUndo) import Pos.Core (HasGenesisData, StakesList, coinToInteger, genesisData, mkCoin, sumCoins, unsafeIntegerToCoin) import Pos.Core.Genesis (GenesisData (..)) -import Pos.Core.Txp (Tx (..), TxAux (..), TxOutAux (..), TxUndo) -- | Apply transactions to stakes. applyTxsToStakes :: HasGenesisData => [(TxAux, TxUndo)] -> GlobalToilM () diff --git a/chain/src/Pos/Chain/Txp/Toil/Types.hs b/chain/src/Pos/Chain/Txp/Toil/Types.hs index 33169b0767c..d64861140a4 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Types.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Types.hs @@ -37,9 +37,12 @@ import Data.Text.Lazy.Builder (Builder) import Formatting (Format, later) import Serokell.Util.Text (mapBuilderJson) +import Pos.Chain.Txp.Tx (TxId, TxIn, _TxOut) +import Pos.Chain.Txp.TxAux (TxAux) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) +import Pos.Chain.Txp.Undo (TxUndo) import Pos.Core (Address, Coin, StakeholderId, unsafeAddCoin, unsafeSubCoin) -import Pos.Core.Txp (TxAux, TxId, TxIn, TxOutAux (..), TxUndo, _TxOut) import qualified Pos.Util.Modifier as MM ---------------------------------------------------------------------------- diff --git a/chain/src/Pos/Chain/Txp/Toil/Utxo/Functions.hs b/chain/src/Pos/Chain/Txp/Toil/Utxo/Functions.hs index 27c3f56e3bb..7a85a184084 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Utxo/Functions.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Utxo/Functions.hs @@ -24,15 +24,19 @@ import Pos.Chain.Txp.Toil.Failure (ToilVerFailure (..), TxOutVerFailure (..), WitnessVerFailure (..)) import Pos.Chain.Txp.Toil.Monad (UtxoM, utxoDel, utxoGet, utxoPut) import Pos.Chain.Txp.Toil.Types (TxFee (..)) +import Pos.Chain.Txp.Tx (Tx (..), TxAttributes, TxIn (..), TxOut (..), + isTxInUnknown) +import Pos.Chain.Txp.TxAux (TxAux (..)) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) +import Pos.Chain.Txp.TxWitness (TxInWitness (..), TxSigData (..), + TxWitness) +import Pos.Chain.Txp.Undo (TxUndo) import Pos.Core (AddrType (..), Address (..), integerToCoin, isRedeemAddress, isUnknownAddressType, sumCoins) import Pos.Core.Attributes (Attributes (attrRemain), areAttributesKnown) import Pos.Core.Common (checkPubKeyAddress, checkRedeemAddress, checkScriptAddress) -import Pos.Core.Txp (Tx (..), TxAttributes, TxAux (..), TxIn (..), - TxInWitness (..), TxOut (..), TxOutAux (..), - TxSigData (..), TxUndo, TxWitness, isTxInUnknown) import Pos.Crypto (SignTag (SignRedeemTx, SignTx), WithHash (..), checkSig, hash, redeemCheckSig) import Pos.Crypto.Configuration (ProtocolMagic) diff --git a/chain/src/Pos/Chain/Txp/Toil/Utxo/Util.hs b/chain/src/Pos/Chain/Txp/Toil/Utxo/Util.hs index 141b5560211..45e856c423c 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Utxo/Util.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Utxo/Util.hs @@ -18,10 +18,11 @@ import qualified Data.Map.Strict as M import Pos.Chain.Txp.Base (addrBelongsTo, addrBelongsToSet, txOutStake) import Pos.Chain.Txp.Toil.Types (Utxo) +import Pos.Chain.Txp.Tx (TxOut (txOutValue), _TxOut) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) import Pos.Core (Address, Coin, HasGenesisData, StakesMap, genesisData, sumCoins, unsafeAddCoin, unsafeIntegerToCoin) import Pos.Core.Genesis (GenesisData (..)) -import Pos.Core.Txp (TxOut (txOutValue), TxOutAux (..), _TxOut) -- | Select only TxOuts for given address filterUtxoByAddr :: Address -> Utxo -> Utxo diff --git a/chain/src/Pos/Chain/Txp/Topsort.hs b/chain/src/Pos/Chain/Txp/Topsort.hs index 668246bd5b3..52d20dd6fec 100644 --- a/chain/src/Pos/Chain/Txp/Topsort.hs +++ b/chain/src/Pos/Chain/Txp/Topsort.hs @@ -12,7 +12,8 @@ import qualified Data.HashMap.Strict as HM import qualified Data.HashSet as HS import Data.List (nub, tail, uncons) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), txInputs) +import Pos.Chain.Txp.Tx (Tx (..), TxIn (..), txInputs) +import Pos.Chain.Txp.TxAux (TxAux (..)) import Pos.Crypto (Hash, WithHash (..), withHash) ---------------------------------------------------------------------------- diff --git a/core/src/Pos/Core/Txp/Tx.hs b/chain/src/Pos/Chain/Txp/Tx.hs similarity index 98% rename from core/src/Pos/Core/Txp/Tx.hs rename to chain/src/Pos/Chain/Txp/Tx.hs index e98f9447dcb..c9c1c1b0521 100644 --- a/core/src/Pos/Core/Txp/Tx.hs +++ b/chain/src/Pos/Chain/Txp/Tx.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.Tx +module Pos.Chain.Txp.Tx ( Tx (..) , checkTx , txInputs @@ -43,6 +43,7 @@ import Pos.Binary.Class (Bi (..), Case (..), Cons (..), Field (..), import Pos.Core.Attributes (Attributes, areAttributesKnown) import Pos.Core.Common (Address (..), Coin (..), checkCoin, coinF, coinToInteger, decodeTextAddress, integerToCoin) +import Pos.Core.Util.LogSafe (SecureLog (..)) import Pos.Crypto (Hash, decodeAbstractHash, hash, hashHexF, shortHashF) import Pos.Util.Util (toAesonError) @@ -126,6 +127,9 @@ checkTx it = -- | Represents transaction identifier as 'Hash' of 'Tx'. type TxId = Hash Tx +instance Buildable (SecureLog TxId) where + build _ = "" + -------------------------------------------------------------------------------- -- TxAttributes -------------------------------------------------------------------------------- diff --git a/core/src/Pos/Core/Txp/TxAux.hs b/chain/src/Pos/Chain/Txp/TxAux.hs similarity index 92% rename from core/src/Pos/Core/Txp/TxAux.hs rename to chain/src/Pos/Chain/Txp/TxAux.hs index ee658a7d6a3..5d26767f52e 100644 --- a/core/src/Pos/Core/Txp/TxAux.hs +++ b/chain/src/Pos/Chain/Txp/TxAux.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.TxAux +module Pos.Chain.Txp.TxAux ( TxAux (..) , txaF , checkTxAux @@ -14,8 +14,8 @@ import Serokell.Util.Text (listJsonIndent) import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) -import Pos.Core.Txp.Tx -import Pos.Core.Txp.TxWitness +import Pos.Chain.Txp.Tx +import Pos.Chain.Txp.TxWitness -- | Transaction + auxiliary data data TxAux = TxAux diff --git a/core/src/Pos/Core/Txp/TxMsg.hs b/chain/src/Pos/Chain/Txp/TxMsg.hs similarity index 86% rename from core/src/Pos/Core/Txp/TxMsg.hs rename to chain/src/Pos/Chain/Txp/TxMsg.hs index 5f828295c3a..43ad7a3cff0 100644 --- a/core/src/Pos/Core/Txp/TxMsg.hs +++ b/chain/src/Pos/Chain/Txp/TxMsg.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.TxMsg +module Pos.Chain.Txp.TxMsg ( TxMsgContents (..) ) where @@ -7,7 +7,7 @@ import Universum import Formatting (bprint, (%)) import Formatting.Buildable (Buildable (..)) -import Pos.Core.Txp.TxAux (TxAux (..), txaF) +import Pos.Chain.Txp.TxAux (TxAux (..), txaF) -- | Data message. Can be used to send one transaction per message. -- Transaction is sent with auxilary data. diff --git a/core/src/Pos/Core/Txp/TxOutAux.hs b/chain/src/Pos/Chain/Txp/TxOutAux.hs similarity index 92% rename from core/src/Pos/Core/Txp/TxOutAux.hs rename to chain/src/Pos/Chain/Txp/TxOutAux.hs index 86729d8e886..fbfa23d9839 100644 --- a/core/src/Pos/Core/Txp/TxOutAux.hs +++ b/chain/src/Pos/Chain/Txp/TxOutAux.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.TxOutAux +module Pos.Chain.Txp.TxOutAux ( TxOutAux (..) ) where @@ -10,7 +10,7 @@ import Formatting (bprint, build, (%)) import qualified Formatting.Buildable as Buildable import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) -import Pos.Core.Txp.Tx (TxOut) +import Pos.Chain.Txp.Tx (TxOut) -- | Transaction output and auxilary data corresponding to it. -- [CSL-366] Add more data. diff --git a/core/src/Pos/Core/Txp/TxPayload.hs b/chain/src/Pos/Chain/Txp/TxPayload.hs similarity index 92% rename from core/src/Pos/Core/Txp/TxPayload.hs rename to chain/src/Pos/Chain/Txp/TxPayload.hs index c3842e88d8d..83e44800542 100644 --- a/core/src/Pos/Core/Txp/TxPayload.hs +++ b/chain/src/Pos/Chain/Txp/TxPayload.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.TxPayload +module Pos.Chain.Txp.TxPayload ( TxPayload (..) , mkTxPayload , checkTxPayload @@ -13,9 +13,9 @@ import Control.Monad.Except (MonadError) import Data.SafeCopy (base, deriveSafeCopySimple) import Pos.Binary.Class (Bi (..)) -import Pos.Core.Txp.Tx -import Pos.Core.Txp.TxAux -import Pos.Core.Txp.TxWitness +import Pos.Chain.Txp.Tx +import Pos.Chain.Txp.TxAux +import Pos.Chain.Txp.TxWitness -- | Payload of Txp component which is part of main block. Constructor -- is unsafe, because it lets one create invalid payload, for example diff --git a/core/src/Pos/Core/Txp/TxProof.hs b/chain/src/Pos/Chain/Txp/TxProof.hs similarity index 88% rename from core/src/Pos/Core/Txp/TxProof.hs rename to chain/src/Pos/Chain/Txp/TxProof.hs index 74aba82f2d7..63c3122636d 100644 --- a/core/src/Pos/Core/Txp/TxProof.hs +++ b/chain/src/Pos/Chain/Txp/TxProof.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.TxProof +module Pos.Chain.Txp.TxProof ( TxProof (..) , mkTxProof ) where @@ -13,9 +13,9 @@ import Pos.Binary.Class (Bi (..), encodeListLen, enforceSize) import Pos.Core.Merkle (MerkleRoot, mkMerkleTree, mtRoot) import Pos.Crypto (Hash, hash) -import Pos.Core.Txp.Tx -import Pos.Core.Txp.TxPayload -import Pos.Core.Txp.TxWitness +import Pos.Chain.Txp.Tx +import Pos.Chain.Txp.TxPayload +import Pos.Chain.Txp.TxWitness data TxProof = TxProof { txpNumber :: !Word32 @@ -42,7 +42,7 @@ instance NFData TxProof -- | Construct 'TxProof' which proves given 'TxPayload'. -- This will construct a merkle tree, which can be very expensive. Use with -- care. Bi constraints arise because we need to hash these things. -mkTxProof :: Bi TxInWitness => TxPayload -> TxProof +mkTxProof :: TxPayload -> TxProof mkTxProof UnsafeTxPayload {..} = TxProof { txpNumber = fromIntegral (length _txpTxs) diff --git a/core/src/Pos/Core/Txp/TxWitness.hs b/chain/src/Pos/Chain/Txp/TxWitness.hs similarity index 98% rename from core/src/Pos/Core/Txp/TxWitness.hs rename to chain/src/Pos/Chain/Txp/TxWitness.hs index c931920d101..ab211c1ea05 100644 --- a/core/src/Pos/Core/Txp/TxWitness.hs +++ b/chain/src/Pos/Chain/Txp/TxWitness.hs @@ -1,4 +1,4 @@ -module Pos.Core.Txp.TxWitness +module Pos.Chain.Txp.TxWitness ( TxWitness , TxInWitness (..) , TxSigData (..) @@ -27,7 +27,7 @@ import Pos.Crypto (Hash, PublicKey, RedeemPublicKey, RedeemSignature, Signature, hash, shortHashF) import Pos.Util.Util (aesonError) -import Pos.Core.Txp.Tx (Tx) +import Pos.Chain.Txp.Tx (Tx) -- | A witness is a proof that a transaction is allowed to spend the funds it -- spends (by providing signatures, redeeming scripts, etc). A separate proof diff --git a/core/src/Pos/Core/Txp/Undo.hs b/chain/src/Pos/Chain/Txp/Undo.hs similarity index 81% rename from core/src/Pos/Core/Txp/Undo.hs rename to chain/src/Pos/Chain/Txp/Undo.hs index 5374f875395..5d58fb312b1 100644 --- a/core/src/Pos/Core/Txp/Undo.hs +++ b/chain/src/Pos/Chain/Txp/Undo.hs @@ -1,11 +1,11 @@ -module Pos.Core.Txp.Undo +module Pos.Chain.Txp.Undo ( TxpUndo , TxUndo ) where import Universum -import Pos.Core.Txp.TxOutAux +import Pos.Chain.Txp.TxOutAux type TxpUndo = [TxUndo] diff --git a/chain/test/Test/Pos/Chain/Block/Arbitrary.hs b/chain/test/Test/Pos/Chain/Block/Arbitrary.hs index 151d226e316..7e7192cd1f5 100644 --- a/chain/test/Test/Pos/Chain/Block/Arbitrary.hs +++ b/chain/test/Test/Pos/Chain/Block/Arbitrary.hs @@ -43,9 +43,9 @@ import Pos.Crypto (ProtocolMagic, PublicKey, SecretKey, createPsk, import Test.Pos.Chain.Delegation.Arbitrary (genDlgPayload) import Test.Pos.Chain.Ssc.Arbitrary (SscPayloadDependsOnSlot (..), genSscPayload, genSscPayloadForSlot) +import Test.Pos.Chain.Txp.Arbitrary (genTxPayload) import Test.Pos.Chain.Update.Arbitrary (genUpdatePayload) import Test.Pos.Core.Arbitrary (genSlotId) -import Test.Pos.Core.Arbitrary.Txp (genTxPayload) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) newtype BodyDependsOnSlot b = BodyDependsOnSlot diff --git a/chain/test/Test/Pos/Chain/Block/Bi.hs b/chain/test/Test/Pos/Chain/Block/Bi.hs index 1ee501e4f9d..d6e8e33b94c 100644 --- a/chain/test/Test/Pos/Chain/Block/Bi.hs +++ b/chain/test/Test/Pos/Chain/Block/Bi.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE TemplateHaskell #-} + module Test.Pos.Chain.Block.Bi ( tests ) where @@ -26,15 +28,15 @@ import Pos.Crypto (Hash, SignTag (..), abstractHash, createPsk, hash, import Test.Pos.Binary.Helpers.GoldenRoundTrip (goldenTestBi, roundTripsBiBuildable, roundTripsBiShow) import Test.Pos.Chain.Block.Gen +import Test.Pos.Chain.Txp.Example (exampleTxPayload, exampleTxProof) import Test.Pos.Core.ExampleHelpers (exampleBlockVersion, exampleChainDifficulty, exampleEpochIndex, exampleLightDlgIndices, examplePublicKey, exampleSecretKey, exampleSecretKeys, exampleSlotId, exampleSlotLeaders, exampleSoftwareVersion, - exampleSscPayload, exampleSscProof, exampleTxPayload, - exampleTxProof, exampleUpdatePayload, exampleUpdateProof, - feedPM, feedPMC, staticHeavyDlgIndexes, - staticProxySKHeavys) + exampleSscPayload, exampleSscProof, exampleUpdatePayload, + exampleUpdateProof, feedPM, feedPMC, + staticHeavyDlgIndexes, staticProxySKHeavys) 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 9ae52263a2d..ebb424f14c3 100644 --- a/chain/test/Test/Pos/Chain/Block/Gen.hs +++ b/chain/test/Test/Pos/Chain/Block/Gen.hs @@ -35,12 +35,12 @@ import Pos.Chain.Block (BlockBodyAttributes, BlockHeader (..), import Pos.Core (ProtocolConstants, ProtocolMagic) import Pos.Core.Attributes (mkAttributes) +import Test.Pos.Chain.Txp.Gen (genTxPayload, genTxProof) import Test.Pos.Core.Gen (genBlockVersion, genChainDifficulty, genDlgPayload, genEpochIndex, genHeavyDlgIndex, genLightDlgIndices, genSlotId, genSlotLeaders, genSoftwareVersion, genSscPayload, genSscProof, - genTextHash, genTxPayload, genTxProof, genUpdatePayload, - genUpdateProof) + genTextHash, genUpdatePayload, genUpdateProof) import Test.Pos.Crypto.Gen (genAbstractHash, genProxySignature, genPublicKey, genSecretKey, genSignature) diff --git a/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs b/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs index 93e45aa1db6..f518bd955ff 100644 --- a/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs +++ b/chain/test/Test/Pos/Chain/Lrc/Arbitrary.hs @@ -1,3 +1,10 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE UndecidableInstances #-} + -- | Arbitrary instances for Lrc types. module Test.Pos.Chain.Lrc.Arbitrary diff --git a/chain/test/Test/Pos/Chain/Lrc/FtsSpec.hs b/chain/test/Test/Pos/Chain/Lrc/FtsSpec.hs index c8a66ce2dac..399397e303f 100644 --- a/chain/test/Test/Pos/Chain/Lrc/FtsSpec.hs +++ b/chain/test/Test/Pos/Chain/Lrc/FtsSpec.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ViewPatterns #-} + -- | Specification of Pos.Chain.LrcPure (which is basically a pure -- version of 'Pos.Chain.Lrc'). diff --git a/chain/test/Test/Pos/Chain/Txp/Arbitrary.hs b/chain/test/Test/Pos/Chain/Txp/Arbitrary.hs new file mode 100644 index 00000000000..2b3c4c0333c --- /dev/null +++ b/chain/test/Test/Pos/Chain/Txp/Arbitrary.hs @@ -0,0 +1,242 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} + +{-# OPTIONS_GHC -fno-warn-orphans #-} + +-- | `Arbitrary` instances for Txp types + +module Test.Pos.Chain.Txp.Arbitrary + ( BadSigsTx (..) + , DoubleInputTx (..) + , GoodTx (..) + , goodTxToTxAux + + -- | Standalone generators. + , genTx + , genTxAux + , genTxIn + , genTxInWitness + , genTxOutDist + , genTxPayload + ) where + +import Universum + +import Data.Default (Default (def)) +import Data.List.NonEmpty ((<|)) +import qualified Data.List.NonEmpty as NE +import qualified Data.Vector as V +import Test.QuickCheck (Arbitrary (..), Gen, choose, listOf, oneof, + scale) +import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, + genericShrink) + +import Pos.Binary.Class (Raw) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxIn (..), + TxInWitness (..), TxOut (..), TxOutAux (..), + TxPayload (..), TxProof (..), TxSigData (..), mkTxPayload) +import Pos.Core.Attributes (mkAttributes) +import Pos.Core.Common (Coin, IsBootstrapEraAddr (..), + makePubKeyAddress) +import Pos.Core.Merkle (MerkleNode (..), MerkleRoot (..)) +import Pos.Crypto (Hash, ProtocolMagic, SecretKey, SignTag (SignTx), + hash, sign, toPublic) + +import Test.Pos.Core.Arbitrary () +import Test.Pos.Crypto.Arbitrary (genRedeemSignature, genSignature) +import Test.Pos.Crypto.Dummy (dummyProtocolMagic) + +---------------------------------------------------------------------------- +-- Arbitrary txp types +---------------------------------------------------------------------------- + +instance Arbitrary TxOut where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary TxOutAux where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary TxSigData where + arbitrary = genericArbitrary + shrink = genericShrink + +-- | Generator for a 'TxInWitness'. 'ProtocolMagic' is needed because it +-- contains signatures. +genTxInWitness :: ProtocolMagic -> Gen TxInWitness +genTxInWitness pm = oneof + [ PkWitness <$> arbitrary <*> genSignature pm arbitrary + -- this can generate a redeemer script where a validator script is + -- needed and vice-versa, but it doesn't matter + , ScriptWitness <$> arbitrary <*> arbitrary + , RedeemWitness <$> arbitrary <*> genRedeemSignature pm arbitrary + , UnknownWitnessType <$> choose (3, 255) <*> scale (min 150) arbitrary + ] + +instance Arbitrary TxInWitness where + arbitrary = genTxInWitness dummyProtocolMagic + shrink = \case + UnknownWitnessType n a -> UnknownWitnessType n <$> shrink a + ScriptWitness a b -> uncurry ScriptWitness <$> shrink (a, b) + _ -> [] + +genTxIn :: Gen TxIn +genTxIn = oneof + [ TxInUtxo <$> arbitrary <*> arbitrary + , TxInUnknown <$> choose (1, 255) <*> scale (min 150) arbitrary + ] + +instance Arbitrary TxIn where + arbitrary = genTxIn + shrink = genericShrink + +genTx :: Gen Tx +genTx = UnsafeTx <$> arbitrary <*> arbitrary <*> pure (mkAttributes ()) + +-- | Arbitrary transactions generated from this instance will only be valid +-- with regards to 'mxTx' +instance Arbitrary Tx where + arbitrary = genTx + shrink = genericShrink + +-- | Type used to generate valid ('verifyTx') +-- transactions and accompanying input information. +-- It's not entirely general because it only generates transactions whose +-- outputs are in the same number as its inputs in a one-to-one correspondence. +-- +-- The GoodTx type is a nonempty list of quadruples. It contains +-- previous transaction input came from, the input itself, output and +-- witness for the input. Number of inputs is equal to number of outputs. +-- +-- The OverflowTx type is the same as GoodTx, except its values, both for +-- inputs as well as outputs, are very close to maxBound :: Coin so as to cause +-- overflow in the Coin type if they are summed. +-- +-- The BadSigTx type is also the same as GoodTx, with the difference that all +-- signatures in the transaction's inputs have been replaced with a bogus one. + +buildProperTx + :: ( ) + => ProtocolMagic + -> NonEmpty (Tx, SecretKey, SecretKey, Coin) + -> (Coin -> Coin, Coin -> Coin) + -> NonEmpty (Tx, TxIn, TxOutAux, TxInWitness) +buildProperTx pm inputList (inCoin, outCoin) = + txList <&> \(tx, txIn, fromSk, txOutput) -> + ( tx + , txIn + , TxOutAux txOutput + , mkWitness fromSk + ) + where + fun (UnsafeTx txIn txOut _, fromSk, toSk, c) = + let inC = inCoin c + outC = outCoin c + txToBeSpent = + UnsafeTx + txIn + ((makeTxOutput fromSk inC) <| txOut) + (mkAttributes ()) + in ( txToBeSpent + , TxInUtxo (hash txToBeSpent) 0 + , fromSk + , makeTxOutput toSk outC ) + -- why is it called txList? I've no idea what's going on here (@neongreen) + txList = fmap fun inputList + newTx = UnsafeTx ins outs def + newTxHash = hash newTx + ins = fmap (view _2) txList + outs = fmap (view _4) txList + mkWitness fromSk = + PkWitness (toPublic fromSk) (sign pm SignTx fromSk $ TxSigData newTxHash) + makeTxOutput s c = + TxOut (makePubKeyAddress (IsBootstrapEraAddr True) $ toPublic s) c + +-- | Well-formed transaction 'Tx'. +-- +-- TODO: this type is hard to use and should be rewritten as a record +newtype GoodTx = GoodTx + { getGoodTx :: NonEmpty (Tx, TxIn, TxOutAux, TxInWitness) + } deriving (Generic, Show) + +goodTxToTxAux :: GoodTx -> TxAux +goodTxToTxAux (GoodTx l) = TxAux tx witness + where + tx = UnsafeTx (map (view _2) l) (map (toaOut . view _3) l) def + witness = V.fromList $ NE.toList $ map (view _4) l + +instance Arbitrary GoodTx where + arbitrary = + GoodTx <$> (buildProperTx dummyProtocolMagic <$> arbitrary <*> pure (identity, identity)) + shrink = const [] -- used to be “genericShrink”, but shrinking is broken + -- because naive shrinking may turn a good transaction + -- into a bad one (by setting one of outputs to 0, for + -- instance) + +-- | Ill-formed 'Tx' with bad signatures. +newtype BadSigsTx = BadSigsTx + { getBadSigsTx :: NonEmpty (Tx, TxIn, TxOutAux, TxInWitness) + } deriving (Generic, Show) + +-- | Ill-formed 'Tx' that spends an input twice. +newtype DoubleInputTx = DoubleInputTx + { getDoubleInputTx :: NonEmpty (Tx, TxIn, TxOutAux, TxInWitness) + } deriving (Generic, Show) + +instance Arbitrary BadSigsTx where + arbitrary = BadSigsTx <$> do + goodTxList <- getGoodTx <$> arbitrary + badSig <- arbitrary + return $ map (set _4 badSig) goodTxList + shrink = genericShrink + +instance Arbitrary DoubleInputTx where + arbitrary = DoubleInputTx <$> do + inputs <- arbitrary + pure $ buildProperTx dummyProtocolMagic + (NE.cons (NE.head inputs) inputs) + (identity, identity) + shrink = const [] + +instance Arbitrary (MerkleRoot Tx) where + arbitrary = MerkleRoot <$> (arbitrary @(Hash Raw)) + shrink = genericShrink + +instance Arbitrary (MerkleNode Tx) where + arbitrary = genericArbitrary + shrink = genericShrink + +instance Arbitrary TxProof where + arbitrary = genericArbitrary + shrink = genericShrink + +genTxAux :: ProtocolMagic -> Gen TxAux +genTxAux pm = TxAux <$> genTx <*> (V.fromList <$> listOf (genTxInWitness pm)) + +instance Arbitrary TxAux where + arbitrary = genTxAux dummyProtocolMagic + shrink = genericShrink + +---------------------------------------------------------------------------- +-- Utilities used in 'Pos.Block.Arbitrary' +---------------------------------------------------------------------------- + +genTxOutDist :: ProtocolMagic -> Gen [TxAux] +genTxOutDist pm = + listOf $ do + txInW <- V.fromList <$> listOf (genTxInWitness pm) + txIns <- arbitrary + txOuts <- arbitrary + let tx = UnsafeTx txIns txOuts (mkAttributes ()) + return $ TxAux tx txInW + +genTxPayload :: ProtocolMagic -> Gen TxPayload +genTxPayload pm = mkTxPayload <$> genTxOutDist pm + +instance Arbitrary TxPayload where + arbitrary = genTxPayload dummyProtocolMagic + shrink = genericShrink diff --git a/core/test/Test/Pos/Core/Arbitrary/Txp/Unsafe.hs b/chain/test/Test/Pos/Chain/Txp/Arbitrary/Unsafe.hs similarity index 79% rename from core/test/Test/Pos/Core/Arbitrary/Txp/Unsafe.hs rename to chain/test/Test/Pos/Chain/Txp/Arbitrary/Unsafe.hs index 4047d88474e..1bb54cc2609 100644 --- a/core/test/Test/Pos/Core/Arbitrary/Txp/Unsafe.hs +++ b/chain/test/Test/Pos/Chain/Txp/Arbitrary/Unsafe.hs @@ -2,11 +2,11 @@ -- | 'Arbitrary' unsafe instances for some types from Txp types -module Test.Pos.Core.Arbitrary.Txp.Unsafe () where +module Test.Pos.Chain.Txp.Arbitrary.Unsafe () where import Universum -import Pos.Core.Txp (TxOut (..)) +import Pos.Chain.Txp (TxOut (..)) import Test.Pos.Core.Arbitrary.Unsafe () import Test.Pos.Util.QuickCheck.Arbitrary (ArbitraryUnsafe (..)) diff --git a/chain/test/Test/Pos/Chain/Txp/Bi.hs b/chain/test/Test/Pos/Chain/Txp/Bi.hs new file mode 100644 index 00000000000..cd868977add --- /dev/null +++ b/chain/test/Test/Pos/Chain/Txp/Bi.hs @@ -0,0 +1,301 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeApplications #-} + +module Test.Pos.Chain.Txp.Bi + ( tests + ) where + +import Universum + +import qualified Data.Map as M +import Data.Typeable (typeRep) +import Hedgehog (Gen, Property) +import qualified Hedgehog as H +import qualified Hedgehog.Gen as Gen + +import Pos.Binary.Class (Bi, Case (..), LengthOf, SizeOverride (..), + szCases) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxIn (..), + TxInWitness (..), TxOut (..), TxOutAux (..), + TxSigData (..)) +import Pos.Core.Attributes (Attributes (..), mkAttributes) +import Pos.Core.Common (AddrAttributes (..), Script (..)) +import Pos.Crypto (ProtocolMagic (..), SignTag (..), Signature, sign) + +import Test.Pos.Binary.Helpers (SizeTestConfig (..), scfg, sizeTest) +import Test.Pos.Binary.Helpers.GoldenRoundTrip (goldenTestBi, + roundTripsBiBuildable, roundTripsBiShow) +import Test.Pos.Chain.Txp.Example (exampleHashTx, + exampleRedeemSignature, exampleTxId, exampleTxInList, + exampleTxInUnknown, exampleTxInUtxo, exampleTxOut, + exampleTxOutList, exampleTxProof, exampleTxSig, + exampleTxSigData, exampleTxWitness) +import Test.Pos.Chain.Txp.Gen (genTx, genTxAttributes, genTxAux, + genTxHash, genTxId, genTxIn, genTxInList, genTxInWitness, + genTxOut, genTxOutAux, genTxOutList, genTxPayload, + genTxProof, genTxSig, genTxSigData, genTxWitness) +import Test.Pos.Core.ExampleHelpers (examplePublicKey, + exampleRedeemPublicKey, exampleSecretKey, feedPM) +import Test.Pos.Util.Golden (discoverGolden, eachOf) +import Test.Pos.Util.Tripping (discoverRoundTrip) + +-------------------------------------------------------------------------------- +-- Tx +-------------------------------------------------------------------------------- + +golden_Tx :: Property +golden_Tx = goldenTestBi tx "test/golden/Tx" + where + tx = UnsafeTx exampleTxInList exampleTxOutList (mkAttributes ()) + +roundTripTx :: Property +roundTripTx = eachOf 50 genTx roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxAttributes +-------------------------------------------------------------------------------- + +golden_TxAttributes :: Property +golden_TxAttributes = goldenTestBi txA "test/golden/TxAttributes" + where + txA = mkAttributes () + + +roundTripTxAttributes :: Property +roundTripTxAttributes = eachOf 10 genTxAttributes roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxAux +-------------------------------------------------------------------------------- + +roundTripTxAux :: Property +roundTripTxAux = eachOf 100 (feedPM genTxAux) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- Tx Hash +-------------------------------------------------------------------------------- + +golden_HashTx :: Property +golden_HashTx = goldenTestBi exampleHashTx "test/golden/HashTx" + +roundTripHashTx :: Property +roundTripHashTx = eachOf 50 genTxHash roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxIn +-------------------------------------------------------------------------------- + + +golden_TxInUtxo :: Property +golden_TxInUtxo = goldenTestBi exampleTxInUtxo "test/golden/TxIn_Utxo" + +golden_TxInUnknown :: Property +golden_TxInUnknown = goldenTestBi exampleTxInUnknown "test/golden/TxIn_Unknown" + +roundTripTxIn :: Property +roundTripTxIn = eachOf 100 genTxIn roundTripsBiBuildable + + +-------------------------------------------------------------------------------- +-- TxId +-------------------------------------------------------------------------------- + +golden_TxId :: Property +golden_TxId = goldenTestBi exampleTxId "test/golden/TxId" + +roundTripTxId :: Property +roundTripTxId = eachOf 50 genTxId roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxInList +-------------------------------------------------------------------------------- + +golden_TxInList :: Property +golden_TxInList = goldenTestBi exampleTxInList "test/golden/TxInList" + +roundTripTxInList :: Property +roundTripTxInList = eachOf 50 genTxInList roundTripsBiShow + +-------------------------------------------------------------------------------- +-- TxInWitness +-------------------------------------------------------------------------------- + +golden_PkWitness :: Property +golden_PkWitness = goldenTestBi pkWitness "test/golden/TxInWitness_PkWitness" + where + pkWitness = PkWitness examplePublicKey exampleTxSig + +golden_ScriptWitness :: Property +golden_ScriptWitness = goldenTestBi scriptWitness "test/golden/TxInWitness_ScriptWitness" + where + scriptWitness = ScriptWitness validatorScript redeemerScript + validatorScript = Script 47 "serialized script" + redeemerScript = Script 47 "serialized script" + +golden_RedeemWitness :: Property +golden_RedeemWitness = goldenTestBi redeemWitness "test/golden/TxInWitness_RedeemWitness" + where + redeemWitness = RedeemWitness exampleRedeemPublicKey exampleRedeemSignature + +golden_UnknownWitnessType :: Property +golden_UnknownWitnessType = goldenTestBi unkWitType "test/golden/TxInWitness_UnknownWitnessType" + where + unkWitType = UnknownWitnessType 47 "forty seven" + +roundTripTxInWitness :: Property +roundTripTxInWitness = eachOf 50 (feedPM genTxInWitness) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxOutList +-------------------------------------------------------------------------------- + +golden_TxOutList :: Property +golden_TxOutList = goldenTestBi exampleTxOutList "test/golden/TxOutList" + +roundTripTxOutList :: Property +roundTripTxOutList = eachOf 50 genTxOutList roundTripsBiShow + +-------------------------------------------------------------------------------- +-- TxOut +-------------------------------------------------------------------------------- + +golden_TxOut :: Property +golden_TxOut = goldenTestBi exampleTxOut "test/golden/TxOut" + +roundTripTxOut :: Property +roundTripTxOut = eachOf 50 genTxOut roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxOutAux +-------------------------------------------------------------------------------- + +golden_TxOutAux :: Property +golden_TxOutAux = goldenTestBi txOutAux "test/golden/TxOutAux" + where + txOutAux = TxOutAux exampleTxOut + +roundTripTxOutAux :: Property +roundTripTxOutAux = eachOf 50 genTxOutAux roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxPayload +-------------------------------------------------------------------------------- + +roundTripTxPayload :: Property +roundTripTxPayload = eachOf 50 (feedPM genTxPayload) roundTripsBiShow + +-------------------------------------------------------------------------------- +-- TxProof +-------------------------------------------------------------------------------- + +golden_TxProof :: Property +golden_TxProof = goldenTestBi exampleTxProof "test/golden/TxProof" + +roundTripTxProof :: Property +roundTripTxProof = eachOf 50 (feedPM genTxProof) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxSig +-------------------------------------------------------------------------------- + +golden_TxSig :: Property +golden_TxSig = goldenTestBi txSigGold "test/golden/TxSig" + where + txSigGold = sign (ProtocolMagic 0) SignForTestingOnly + exampleSecretKey exampleTxSigData + +roundTripTxSig :: Property +roundTripTxSig = eachOf 50 (feedPM genTxSig) roundTripsBiBuildable + +-------------------------------------------------------------------------------- +-- TxSigData +-------------------------------------------------------------------------------- + +golden_TxSigData :: Property +golden_TxSigData = goldenTestBi exampleTxSigData "test/golden/TxSigData" + +roundTripTxSigData :: Property +roundTripTxSigData = eachOf 50 genTxSigData roundTripsBiShow + +-------------------------------------------------------------------------------- +-- TxWitness +-------------------------------------------------------------------------------- + +golden_TxWitness :: Property +golden_TxWitness = goldenTestBi exampleTxWitness "test/golden/TxWitness" + +roundTripTxWitness :: Property +roundTripTxWitness = eachOf 20 (feedPM genTxWitness) roundTripsBiShow + +sizeEstimates :: H.Group +sizeEstimates = + let check :: (Show a, Bi a) => Gen a -> Property + check g = sizeTest $ scfg { gen = g } + pm = ProtocolMagic 0 + knownTxIn (TxInUnknown _ _) = False + knownTxIn _ = True + + -- Explicit bounds for types, based on the generators from Gen. + attrUnitSize = (typeRep (Proxy @(Attributes ())) + , SizeConstant 1) + attrAddrSize = (typeRep (Proxy @(Attributes AddrAttributes)), + SizeConstant (szCases [ Case "min" 1, Case "max" 1024 ])) + txSigSize = (typeRep (Proxy @(Signature TxSigData)) + , SizeConstant 66) + scriptSize = (typeRep (Proxy @Script), + SizeConstant $ szCases [ Case "loScript" 1 + , Case "hiScript" 255 ]) + + in H.Group "Encoded size bounds for core types." + [ ("TxId" , check genTxId) + , ("Tx" , sizeTest $ scfg + { gen = genTx + , addlCtx = M.fromList [ attrUnitSize, attrAddrSize ] + , computedCtx = \tx -> M.fromList + [ (typeRep (Proxy @(LengthOf [TxIn])), + SizeConstant (fromIntegral $ length $ _txInputs tx)) + , (typeRep (Proxy @(LengthOf [TxOut])), + SizeConstant (fromIntegral $ length $ _txOutputs tx)) + ] + }) + , ("TxIn" , check (Gen.filter knownTxIn genTxIn)) + , ("TxOut" , sizeTest $ scfg + { gen = genTxOut + , addlCtx = M.fromList [ attrAddrSize ] + }) + , ("TxAux" , sizeTest $ scfg + { gen = genTxAux pm + , addlCtx = M.fromList [ attrUnitSize + , attrAddrSize + , scriptSize + , txSigSize ] + , computedCtx = \(TxAux tx witness) -> M.fromList + [ (typeRep (Proxy @(LengthOf [TxIn])), + SizeConstant (fromIntegral $ length $ _txInputs tx)) + , (typeRep (Proxy @(LengthOf (Vector TxInWitness))), + SizeConstant (fromIntegral $ length witness)) + , (typeRep (Proxy @(LengthOf [TxOut])), + SizeConstant (fromIntegral $ length $ _txOutputs tx)) + ] + }) + , ("TxInWitness" , sizeTest $ scfg + { gen = genTxInWitness pm + , addlCtx = M.fromList [ txSigSize, scriptSize ] + }) + , ("TxSigData" , check genTxSigData) + , ("Signature TxSigData" , sizeTest $ scfg + { gen = genTxSig pm + , addlCtx = M.fromList [ txSigSize ] + }) + ] + +----------------------------------------------------------------------- +-- Main test export +----------------------------------------------------------------------- + +tests :: IO Bool +tests = and <$> sequence + [ H.checkSequential $$discoverGolden + , H.checkParallel $$discoverRoundTrip + , H.checkParallel sizeEstimates + ] diff --git a/chain/test/Test/Pos/Chain/Txp/CoreSpec.hs b/chain/test/Test/Pos/Chain/Txp/CoreSpec.hs index 1c3db615004..90445c6c478 100644 --- a/chain/test/Test/Pos/Chain/Txp/CoreSpec.hs +++ b/chain/test/Test/Pos/Chain/Txp/CoreSpec.hs @@ -1,3 +1,6 @@ +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} + -- | Specification for transaction-related core functions -- (Pos.Chain.Txp.Core). @@ -18,14 +21,14 @@ import Test.QuickCheck (NonNegative (..), Positive (..), Property, (===)) import Test.QuickCheck.Gen (Gen) -import Pos.Chain.Txp (topsortTxs) +import Pos.Chain.Txp (Tx (..), TxIn (..), TxOut (..), checkTx, + topsortTxs) import Pos.Core (mkCoin) import Pos.Core.Attributes (mkAttributes) -import Pos.Core.Txp (Tx (..), TxIn (..), TxOut (..), checkTx) import Pos.Crypto (hash, whData, withHash) import Pos.Util (_neHead) -import Test.Pos.Core.Arbitrary.Txp () +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Util.QuickCheck.Arbitrary (sublistN) spec :: Spec diff --git a/chain/test/Test/Pos/Chain/Txp/Example.hs b/chain/test/Test/Pos/Chain/Txp/Example.hs new file mode 100644 index 00000000000..a1d06dd365d --- /dev/null +++ b/chain/test/Test/Pos/Chain/Txp/Example.hs @@ -0,0 +1,90 @@ +module Test.Pos.Chain.Txp.Example + ( exampleTxId + , exampleTxInList + , exampleTxInUnknown + , exampleTxInUtxo + , exampleTxPayload + , exampleTxProof + , exampleTxOut + , exampleTxOutList + , exampleTxSig + , exampleTxSigData + , exampleTxWitness + , exampleRedeemSignature + , exampleHashTx + ) where + +import Universum + +import Data.Coerce (coerce) +import Data.List.NonEmpty (fromList) +import Data.Maybe (fromJust) +import qualified Data.Vector as V + +import qualified Cardano.Crypto.Wallet as CC +import Pos.Chain.Txp (Tx (..), TxAux (..), TxId, TxIn (..), + TxInWitness (..), TxOut (..), TxPayload (..), + TxProof (..), TxSig, TxSigData (..), TxWitness, + mkTxPayload) +import Pos.Core.Attributes (mkAttributes) +import Pos.Core.Common (Coin (..), IsBootstrapEraAddr (..), + makePubKeyAddress) +import Pos.Core.Merkle (mkMerkleTree, mtRoot) +import Pos.Crypto (AbstractHash (..), Hash, ProtocolMagic (..), + PublicKey (..), RedeemSignature, SignTag (..), hash, + redeemDeterministicKeyGen, redeemSign, sign) + +import Test.Pos.Core.ExampleHelpers (examplePublicKey, + exampleSecretKey) +import Test.Pos.Crypto.Bi (getBytes) + +exampleTxAux :: TxAux +exampleTxAux = TxAux tx exampleTxWitness + where + tx = UnsafeTx exampleTxInList exampleTxOutList (mkAttributes ()) + +exampleTxId :: TxId +exampleTxId = exampleHashTx + +exampleTxInList :: (NonEmpty TxIn) +exampleTxInList = fromList [exampleTxInUtxo] + +exampleTxInUnknown :: TxIn +exampleTxInUnknown = TxInUnknown 47 ("forty seven" :: ByteString) + +exampleTxInUtxo :: TxIn +exampleTxInUtxo = TxInUtxo exampleHashTx 47 -- TODO: loop here + +exampleTxOut :: TxOut +exampleTxOut = TxOut (makePubKeyAddress (IsBootstrapEraAddr True) pkey) (Coin 47) + where + Right pkey = PublicKey <$> CC.xpub (getBytes 0 64) + +exampleTxOutList :: (NonEmpty TxOut) +exampleTxOutList = fromList [exampleTxOut] + +exampleTxPayload :: TxPayload +exampleTxPayload = mkTxPayload [exampleTxAux] + +exampleTxProof :: TxProof +exampleTxProof = TxProof 32 mroot hashWit + where + mroot = mtRoot $ mkMerkleTree [(UnsafeTx exampleTxInList exampleTxOutList (mkAttributes ()))] + hashWit = hash $ [(V.fromList [(PkWitness examplePublicKey exampleTxSig)])] + +exampleTxSig :: TxSig +exampleTxSig = sign (ProtocolMagic 0) SignForTestingOnly exampleSecretKey exampleTxSigData + +exampleTxSigData :: TxSigData +exampleTxSigData = TxSigData exampleHashTx + +exampleTxWitness :: TxWitness +exampleTxWitness = V.fromList [(PkWitness examplePublicKey exampleTxSig)] + +exampleRedeemSignature :: RedeemSignature TxSigData +exampleRedeemSignature = redeemSign (ProtocolMagic 0) SignForTestingOnly rsk exampleTxSigData + where + rsk = fromJust (snd <$> redeemDeterministicKeyGen (getBytes 0 32)) + +exampleHashTx :: Hash Tx +exampleHashTx = coerce (hash "golden" :: Hash Text) diff --git a/chain/test/Test/Pos/Chain/Txp/Gen.hs b/chain/test/Test/Pos/Chain/Txp/Gen.hs index c1434eb206a..b7dc8111aa8 100644 --- a/chain/test/Test/Pos/Chain/Txp/Gen.hs +++ b/chain/test/Test/Pos/Chain/Txp/Gen.hs @@ -1,21 +1,141 @@ +{-# LANGUAGE TypeApplications #-} + module Test.Pos.Chain.Txp.Gen ( genTxpConfiguration + , genPkWitness + , genRedeemWitness + , genScriptWitness + , genTx + , genTxAttributes + , genTxAux + , genTxHash + , genTxId + , genTxIn + , genTxInList + , genTxInWitness + , genTxOut + , genTxOutAux + , genTxOutList + , genTxPayload + , genTxProof + , genTxSig + , genTxSigData + , genTxWitness + , genUnknownWitnessType ) where import Universum +import Data.ByteString.Base16 as B16 +import Data.Coerce (coerce) import qualified Data.Set as S +import qualified Data.Vector as V import Hedgehog import qualified Hedgehog.Gen as Gen import qualified Hedgehog.Range as Range -import Pos.Chain.Txp (TxpConfiguration (..)) - -import Test.Pos.Core.Gen (genAddress) +import Pos.Chain.Txp (Tx (..), TxAttributes, TxAux (..), TxId, + TxIn (..), TxInWitness (..), TxOut (..), TxOutAux (..), + TxPayload, TxProof (..), TxSig, TxSigData (..), TxWitness, + TxpConfiguration (..), mkTxPayload) +import Pos.Core.Attributes (mkAttributes) +import Pos.Crypto (Hash, ProtocolMagic, decodeHash, sign) +import Test.Pos.Core.Gen (gen32Bytes, genAddress, genBytes, genCoin, + genMerkleRoot, genScript, genTextHash, genWord32) +import Test.Pos.Crypto.Gen (genAbstractHash, genPublicKey, + genRedeemPublicKey, genRedeemSignature, genSecretKey, + genSignTag) genTxpConfiguration :: Gen TxpConfiguration genTxpConfiguration = do limit <- Gen.int (Range.constant 0 200) addrs <- Gen.list (Range.linear 0 50) genAddress return (TxpConfiguration limit (S.fromList addrs)) + +genPkWitness :: ProtocolMagic -> Gen TxInWitness +genPkWitness pm = PkWitness <$> genPublicKey <*> genTxSig pm + +genRedeemWitness :: ProtocolMagic -> Gen TxInWitness +genRedeemWitness pm = + RedeemWitness <$> genRedeemPublicKey <*> genRedeemSignature pm genTxSigData + +genScriptWitness :: Gen TxInWitness +genScriptWitness = ScriptWitness <$> genScript <*> genScript + +genTx :: Gen Tx +genTx = UnsafeTx <$> genTxInList <*> genTxOutList <*> genTxAttributes + +genTxAttributes :: Gen TxAttributes +genTxAttributes = pure $ mkAttributes () + +genTxAux :: ProtocolMagic -> Gen TxAux +genTxAux pm = TxAux <$> genTx <*> (genTxWitness pm) + +genTxHash :: Gen (Hash Tx) +genTxHash = coerce <$> genTextHash + +genTxId :: Gen TxId +genTxId = genBase16Text >>= pure . decodeHash >>= either error pure + where + genBase16Text = decodeUtf8 @Text @ByteString <$> genBase16Bs + +genBase16Bs :: Gen ByteString +genBase16Bs = B16.encode <$> genBytes 32 + +--genTxId :: Gen TxId +--genTxId = coerce <$> genTxHash + +genTxIn :: Gen TxIn +genTxIn = Gen.choice gens + where + gens = [ TxInUtxo <$> genTxId <*> genWord32 + -- 0 is reserved for TxInUtxo tag ----------+ + , TxInUnknown <$> Gen.word8 (Range.constant 1 255) + <*> gen32Bytes + ] + +genTxInList :: Gen (NonEmpty TxIn) +genTxInList = Gen.nonEmpty (Range.linear 1 20) genTxIn + +genTxOut :: Gen TxOut +genTxOut = TxOut <$> genAddress <*> genCoin + +genTxOutAux :: Gen TxOutAux +genTxOutAux = TxOutAux <$> genTxOut + +genTxOutList :: Gen (NonEmpty TxOut) +genTxOutList = Gen.nonEmpty (Range.linear 1 100) genTxOut + +genTxPayload :: ProtocolMagic -> Gen TxPayload +genTxPayload pm = mkTxPayload <$> (Gen.list (Range.linear 0 10) (genTxAux pm)) + +genTxProof :: ProtocolMagic -> Gen TxProof +genTxProof pm = + TxProof + <$> genWord32 + <*> genMerkleRoot genTx + <*> genAbstractHash (Gen.list (Range.linear 1 5) (genTxWitness pm)) + +genTxSig :: ProtocolMagic -> Gen TxSig +genTxSig pm = + sign pm <$> genSignTag <*> genSecretKey <*> genTxSigData + +genTxSigData :: Gen TxSigData +genTxSigData = TxSigData <$> genTxHash + +genTxInWitness :: ProtocolMagic -> Gen TxInWitness +genTxInWitness pm = Gen.choice gens + where + gens = [ genPkWitness pm + , genRedeemWitness pm + , genScriptWitness + , genUnknownWitnessType + ] + +genTxWitness :: ProtocolMagic -> Gen TxWitness +genTxWitness pm = V.fromList <$> Gen.list (Range.linear 1 10) (genTxInWitness pm) + +genUnknownWitnessType :: Gen TxInWitness +genUnknownWitnessType = + UnknownWitnessType <$> Gen.word8 (Range.constant 3 maxBound) <*> gen32Bytes diff --git a/chain/test/Test/Pos/Chain/Txp/Toil/UtxoSpec.hs b/chain/test/Test/Pos/Chain/Txp/Toil/UtxoSpec.hs index d697b6c0fc1..0f4d39b7919 100644 --- a/chain/test/Test/Pos/Chain/Txp/Toil/UtxoSpec.hs +++ b/chain/test/Test/Pos/Chain/Txp/Toil/UtxoSpec.hs @@ -1,3 +1,9 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ViewPatterns #-} + -- | Specification of Pos.Chain.Txp.Utxo module Test.Pos.Chain.Txp.Toil.UtxoSpec @@ -25,21 +31,21 @@ import Pos.Chain.Script.Examples (alwaysSuccessValidator, goodStdlibRedeemer, idValidator, intValidator, intValidatorWithBlah, multisigRedeemer, multisigValidator, shaStressRedeemer, sigStressRedeemer, stdlibValidator) -import Pos.Chain.Txp (ToilVerFailure (..), Utxo, VTxContext (..), +import Pos.Chain.Txp (ToilVerFailure (..), Tx (..), TxAux (..), + TxIn (..), TxInWitness (..), TxOut (..), TxOutAux (..), + TxSigData (..), TxWitness, Utxo, VTxContext (..), VerifyTxUtxoRes, WitnessVerFailure (..), applyTxToUtxo, - evalUtxoM, execUtxoM, utxoGet, utxoToLookup, verifyTxUtxo) -import Pos.Core (HasConfiguration, addressHash, checkPubKeyAddress, + evalUtxoM, execUtxoM, isTxInUnknown, utxoGet, + utxoToLookup, verifyTxUtxo) +import Pos.Core (addressHash, checkPubKeyAddress, defaultCoreConfiguration, makePubKeyAddressBoot, makeScriptAddress, mkCoin, sumCoins, withGenesisSpec) import Pos.Core.Attributes (mkAttributes) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxInWitness (..), - TxOut (..), TxOutAux (..), TxSigData (..), TxWitness, - isTxInUnknown) import Pos.Crypto (ProtocolMagic, SignTag (SignTx), checkSig, fakeSigner, hash, toPublic, unsafeHash, withHash) import qualified Pos.Util.Modifier as MM -import Test.Pos.Core.Arbitrary.Txp (BadSigsTx (..), +import Test.Pos.Chain.Txp.Arbitrary (BadSigsTx (..), DoubleInputTx (..), GoodTx (..)) import Test.Pos.Util.QuickCheck.Arbitrary (SmallGenerator (..), nonrepeating, runGen) diff --git a/chain/test/cardano-sl-chain-test.cabal b/chain/test/cardano-sl-chain-test.cabal index 0fe9c669730..80d422aa538 100644 --- a/chain/test/cardano-sl-chain-test.cabal +++ b/chain/test/cardano-sl-chain-test.cabal @@ -21,13 +21,17 @@ library Test.Pos.Chain.Ssc.Arbitrary Test.Pos.Chain.Ssc.Gen Test.Pos.Chain.Ssc.Json + Test.Pos.Chain.Txp.Arbitrary + Test.Pos.Chain.Txp.Arbitrary.Unsafe + Test.Pos.Chain.Txp.Bi + Test.Pos.Chain.Txp.Example Test.Pos.Chain.Txp.Gen - Test.Pos.Chain.Txp.Json Test.Pos.Chain.Update.Arbitrary other-modules: Test.Pos.Chain.Update.Arbitrary.Core build-depends: base + , base16-bytestring , bytestring , cardano-crypto , cardano-sl-binary-test @@ -39,6 +43,7 @@ library , cardano-sl-crypto-test , cardano-sl-util-test , containers + , data-default , formatting , generic-arbitrary , hedgehog @@ -47,32 +52,12 @@ library , reflection , universum , unordered-containers + , vector default-language: Haskell2010 - default-extensions: DeriveDataTypeable - DeriveGeneric - GeneralizedNewtypeDeriving - StandaloneDeriving - FlexibleContexts - FlexibleInstances - MultiParamTypeClasses - FunctionalDependencies - DefaultSignatures - NoImplicitPrelude + default-extensions: NoImplicitPrelude OverloadedStrings - RecordWildCards - TypeApplications - TupleSections - ViewPatterns - LambdaCase - MultiWayIf - ConstraintKinds - UndecidableInstances - BangPatterns - TemplateHaskell - ScopedTypeVariables - MonadFailDesugaring ghc-options: -Wall -O2 diff --git a/core/test/golden/HashTx b/chain/test/golden/HashTx similarity index 100% rename from core/test/golden/HashTx rename to chain/test/golden/HashTx diff --git a/core/test/golden/Tx b/chain/test/golden/Tx similarity index 100% rename from core/test/golden/Tx rename to chain/test/golden/Tx diff --git a/core/test/golden/TxAttributes b/chain/test/golden/TxAttributes similarity index 100% rename from core/test/golden/TxAttributes rename to chain/test/golden/TxAttributes diff --git a/core/test/golden/TxId b/chain/test/golden/TxId similarity index 100% rename from core/test/golden/TxId rename to chain/test/golden/TxId diff --git a/core/test/golden/TxInList b/chain/test/golden/TxInList similarity index 100% rename from core/test/golden/TxInList rename to chain/test/golden/TxInList diff --git a/core/test/golden/TxInWitness_PkWitness b/chain/test/golden/TxInWitness_PkWitness similarity index 100% rename from core/test/golden/TxInWitness_PkWitness rename to chain/test/golden/TxInWitness_PkWitness diff --git a/core/test/golden/TxInWitness_RedeemWitness b/chain/test/golden/TxInWitness_RedeemWitness similarity index 100% rename from core/test/golden/TxInWitness_RedeemWitness rename to chain/test/golden/TxInWitness_RedeemWitness diff --git a/core/test/golden/TxInWitness_ScriptWitness b/chain/test/golden/TxInWitness_ScriptWitness similarity index 100% rename from core/test/golden/TxInWitness_ScriptWitness rename to chain/test/golden/TxInWitness_ScriptWitness diff --git a/core/test/golden/TxInWitness_UnknownWitnessType b/chain/test/golden/TxInWitness_UnknownWitnessType similarity index 100% rename from core/test/golden/TxInWitness_UnknownWitnessType rename to chain/test/golden/TxInWitness_UnknownWitnessType diff --git a/core/test/golden/TxIn_Unknown b/chain/test/golden/TxIn_Unknown similarity index 100% rename from core/test/golden/TxIn_Unknown rename to chain/test/golden/TxIn_Unknown diff --git a/core/test/golden/TxIn_Utxo b/chain/test/golden/TxIn_Utxo similarity index 100% rename from core/test/golden/TxIn_Utxo rename to chain/test/golden/TxIn_Utxo diff --git a/core/test/golden/TxOut b/chain/test/golden/TxOut similarity index 100% rename from core/test/golden/TxOut rename to chain/test/golden/TxOut diff --git a/core/test/golden/TxOutAux b/chain/test/golden/TxOutAux similarity index 100% rename from core/test/golden/TxOutAux rename to chain/test/golden/TxOutAux diff --git a/core/test/golden/TxOutList b/chain/test/golden/TxOutList similarity index 100% rename from core/test/golden/TxOutList rename to chain/test/golden/TxOutList diff --git a/core/test/golden/TxProof b/chain/test/golden/TxProof similarity index 100% rename from core/test/golden/TxProof rename to chain/test/golden/TxProof diff --git a/core/test/golden/TxSig b/chain/test/golden/TxSig similarity index 100% rename from core/test/golden/TxSig rename to chain/test/golden/TxSig diff --git a/core/test/golden/TxSigData b/chain/test/golden/TxSigData similarity index 100% rename from core/test/golden/TxSigData rename to chain/test/golden/TxSigData diff --git a/core/test/golden/TxWitness b/chain/test/golden/TxWitness similarity index 100% rename from core/test/golden/TxWitness rename to chain/test/golden/TxWitness diff --git a/chain/test/test.hs b/chain/test/test.hs index 9252be9c6ee..1be60eccc55 100644 --- a/chain/test/test.hs +++ b/chain/test/test.hs @@ -7,6 +7,7 @@ import Spec (spec) import Test.Pos.Binary.Helpers (runTests) import qualified Test.Pos.Chain.Block.Bi import qualified Test.Pos.Chain.Ssc.Json +import qualified Test.Pos.Chain.Txp.Bi main :: IO () main = do @@ -14,4 +15,5 @@ main = do runTests [ Test.Pos.Chain.Block.Bi.tests , Test.Pos.Chain.Ssc.Json.tests + , Test.Pos.Chain.Txp.Bi.tests ] diff --git a/client/src/Pos/Client/Txp/Network.hs b/client/src/Pos/Client/Txp/Network.hs index d45fa2c95d7..82bd5cfb070 100644 --- a/client/src/Pos/Client/Txp/Network.hs +++ b/client/src/Pos/Client/Txp/Network.hs @@ -17,6 +17,8 @@ import Universum import Formatting (build, sformat, (%)) import System.Wlog (logInfo) +import Pos.Chain.Txp (Tx, TxAux (..), TxId, TxMsgContents (..), + TxOut (..), TxOutAux (..), txaF) import Pos.Client.Txp.Addresses (MonadAddresses (..)) import Pos.Client.Txp.Balances (MonadBalances (..), getOwnUtxo) import Pos.Client.Txp.History (MonadTxHistory (..)) @@ -26,8 +28,6 @@ import Pos.Client.Txp.Util (InputSelectionPolicy, import Pos.Communication.Types (InvOrDataTK) import Pos.Core (Address, Coin, makeRedeemAddress, mkCoin, unsafeAddCoin) -import Pos.Core.Txp (Tx, TxAux (..), TxId, TxMsgContents (..), - TxOut (..), TxOutAux (..), txaF) import Pos.Crypto (ProtocolMagic, RedeemSecretKey, SafeSigner, hash, redeemToPublic) import Pos.Infra.Communication.Protocol (OutSpecs) diff --git a/client/test/Test/Pos/Client/Txp/UtilSpec.hs b/client/test/Test/Pos/Client/Txp/UtilSpec.hs index 5359b272162..4ac5392bb9b 100644 --- a/client/test/Test/Pos/Client/Txp/UtilSpec.hs +++ b/client/test/Test/Pos/Client/Txp/UtilSpec.hs @@ -20,7 +20,8 @@ import Test.QuickCheck (Discard (..), Gen, Testable, arbitrary, choose) import Test.QuickCheck.Monadic (forAllM, stop) -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxId, TxIn (..), + TxOut (..), TxOutAux (..), Utxo) import Pos.Client.Txp.Addresses (MonadAddresses (..)) import Pos.Client.Txp.Util (InputSelectionPolicy (..), TxError (..), TxOutputs, TxWithSpendings, createMTx, createRedemptionTx, @@ -28,8 +29,6 @@ import Pos.Client.Txp.Util (InputSelectionPolicy (..), TxError (..), import Pos.Core (Address, Coeff (..), TxFeePolicy (..), TxSizeLinear (..), makePubKeyAddressBoot, makeRedeemAddress, unsafeIntegerToCoin) -import Pos.Core.Txp (Tx (..), TxAux (..), TxId, TxIn (..), TxOut (..), - TxOutAux (..)) import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (RedeemSecretKey, SafeSigner, SecretKey, decodeHash, fakeSigner, redeemToPublic, toPublic) diff --git a/core/cardano-sl-core.cabal b/core/cardano-sl-core.cabal index 4d8c6697a5c..7dc47e07326 100644 --- a/core/cardano-sl-core.cabal +++ b/core/cardano-sl-core.cabal @@ -55,7 +55,6 @@ library Pos.Core.Script Pos.Core.Slotting Pos.Core.Ssc - Pos.Core.Txp Pos.Core.Update Pos.Core.Util.LogSafe @@ -154,16 +153,6 @@ library Pos.Core.Ssc.VssCertificate Pos.Core.Ssc.VssCertificatesMap - -- Txp - Pos.Core.Txp.Tx - Pos.Core.Txp.TxAux - Pos.Core.Txp.TxMsg - Pos.Core.Txp.TxOutAux - Pos.Core.Txp.TxPayload - Pos.Core.Txp.TxProof - Pos.Core.Txp.TxWitness - Pos.Core.Txp.Undo - -- Update Pos.Core.Update.ApplicationName Pos.Core.Update.BlockVersion diff --git a/core/src/Pos/Core/Txp.hs b/core/src/Pos/Core/Txp.hs deleted file mode 100644 index 0daf521c373..00000000000 --- a/core/src/Pos/Core/Txp.hs +++ /dev/null @@ -1,19 +0,0 @@ -module Pos.Core.Txp - ( module Pos.Core.Txp.Tx - , module Pos.Core.Txp.TxAux - , module Pos.Core.Txp.TxMsg - , module Pos.Core.Txp.TxOutAux - , module Pos.Core.Txp.TxPayload - , module Pos.Core.Txp.TxProof - , module Pos.Core.Txp.TxWitness - , module Pos.Core.Txp.Undo - ) where - -import Pos.Core.Txp.Tx -import Pos.Core.Txp.TxAux -import Pos.Core.Txp.TxMsg -import Pos.Core.Txp.TxOutAux -import Pos.Core.Txp.TxPayload -import Pos.Core.Txp.TxProof -import Pos.Core.Txp.TxWitness -import Pos.Core.Txp.Undo diff --git a/core/src/Pos/Core/Util/LogSafe.hs b/core/src/Pos/Core/Util/LogSafe.hs index 88c350994c4..6bdfde1a52f 100644 --- a/core/src/Pos/Core/Util/LogSafe.hs +++ b/core/src/Pos/Core/Util/LogSafe.hs @@ -86,7 +86,6 @@ import System.Wlog.LogHandler (LogHandlerTag (HandlerFilelike)) import Pos.Core (Timestamp) import Pos.Core.Common (Address, Coin) -import Pos.Core.Txp (TxId) import Pos.Crypto (PassPhrase) ---------------------------------------------------------------------------- @@ -350,8 +349,5 @@ instance Buildable (SecureLog Address) where instance Buildable (SecureLog Word32) where build _ = "" -instance Buildable (SecureLog TxId) where - build _ = "" - instance Buildable (SecureLog Timestamp) where build _ = "" diff --git a/core/test/Test/Pos/Core/Arbitrary/Txp.hs b/core/test/Test/Pos/Core/Arbitrary/Txp.hs index e7779f461d0..b4f045fed9e 100644 --- a/core/test/Test/Pos/Core/Arbitrary/Txp.hs +++ b/core/test/Test/Pos/Core/Arbitrary/Txp.hs @@ -1,10 +1,11 @@ +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | `Arbitrary` instances for Txp types -module Test.Pos.Core.Arbitrary.Txp +module Test.Pos.Chain.Txp.Arbitrary ( BadSigsTx (..) , DoubleInputTx (..) , GoodTx (..) @@ -31,13 +32,13 @@ import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, genericShrink) import Pos.Binary.Class (Raw) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxIn (..), + TxInWitness (..), TxOut (..), TxOutAux (..), + TxPayload (..), TxProof (..), TxSigData (..), mkTxPayload) import Pos.Core.Attributes (mkAttributes) import Pos.Core.Common (Coin, IsBootstrapEraAddr (..), makePubKeyAddress) import Pos.Core.Merkle (MerkleNode (..), MerkleRoot (..)) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxInWitness (..), - TxOut (..), TxOutAux (..), TxPayload (..), TxProof (..), - TxSigData (..), mkTxPayload) import Pos.Crypto (Hash, ProtocolMagic, SecretKey, SignTag (SignTx), hash, sign, toPublic) diff --git a/core/test/Test/Pos/Core/Bi.hs b/core/test/Test/Pos/Core/Bi.hs index 00c3318f5e3..08ed4f175fb 100644 --- a/core/test/Test/Pos/Core/Bi.hs +++ b/core/test/Test/Pos/Core/Bi.hs @@ -17,13 +17,13 @@ import qualified Hedgehog as H import qualified Hedgehog.Gen as Gen import Cardano.Crypto.Wallet (xpub) -import Pos.Binary.Class (Bi, Case (..), LengthOf, Raw (..), - SizeOverride (..), szCases) +import Pos.Binary.Class (Bi, Case (..), Raw (..), SizeOverride (..), + szCases) import Pos.Core.Attributes (Attributes, mkAttributes) import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..), AddrStakeDistribution (..), AddrType (..), BlockCount (..), ChainDifficulty (..), Coeff (..), - Coin (..), CoinPortion (..), Script (..), ScriptVersion, + Coin (..), CoinPortion (..), ScriptVersion, SharedSeed (..), StakeholderId, TxFeePolicy (..), TxSizeLinear (..)) import Pos.Core.Delegation (DlgPayload (..), ProxySKBlockInfo) @@ -32,12 +32,9 @@ import Pos.Core.Slotting (EpochIndex (..), EpochOrSlot (..), FlatSlotId, LocalSlotIndex (..), SlotCount (..), TimeDiff (..), Timestamp (..)) import Pos.Core.Ssc (SscPayload (..), SscProof (..)) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxInWitness (..), - TxOut (..), TxOutAux (..), TxSigData (..)) import Pos.Core.Update (ApplicationName (..), SoftforkRule (..)) -import Pos.Crypto (AbstractHash (..), Hash, ProtocolMagic (..), - PublicKey (..), SignTag (..), Signature, abstractHash, - hash, redeemDeterministicKeyGen, sign) +import Pos.Crypto (AbstractHash (..), Hash, PublicKey (..), + abstractHash, hash, redeemDeterministicKeyGen) import Test.Pos.Binary.Helpers (SizeTestConfig (..), scfg, sizeTest) @@ -48,23 +45,18 @@ import Test.Pos.Core.ExampleHelpers (exampleAddrSpendingData_PubKey, exampleAddress3, exampleAddress4, exampleBlockVersion, exampleBlockVersionData, exampleBlockVersionModifier, exampleCommitment, exampleCommitmentSignature, - exampleCommitmentsMap, exampleEpochIndex, exampleHashTx, + exampleCommitmentsMap, exampleEpochIndex, exampleInnerSharesMap, exampleLightDlgIndices, exampleOpening, exampleOpeningsMap, - exampleProxySKBlockInfo, examplePublicKey, - exampleRedeemPublicKey, exampleRedeemSignature, - exampleScript, exampleSecretKey, + exampleProxySKBlockInfo, examplePublicKey, exampleScript, exampleSharesDistribution, exampleSignedCommitment, exampleSlotId, exampleSlotLeaders, exampleSoftwareVersion, exampleSscPayload, exampleSscProof, exampleStakeholderId, - exampleStakesList, exampleSystemTag, exampleTxId, - exampleTxInList, exampleTxInUnknown, exampleTxInUtxo, - exampleTxOut, exampleTxOutList, exampleTxProof, - exampleTxSig, exampleTxSigData, exampleTxWitness, - exampleUpAttributes, exampleUpId, exampleUpdateData, - exampleUpdatePayload, exampleUpdateProof, - exampleUpdateProposal, exampleUpdateProposalToSign, - exampleUpdateVote, exampleVoteId, exampleVssCertificate, + exampleStakesList, exampleSystemTag, exampleUpAttributes, + exampleUpId, exampleUpdateData, exampleUpdatePayload, + exampleUpdateProof, exampleUpdateProposal, + exampleUpdateProposalToSign, exampleUpdateVote, + exampleVoteId, exampleVssCertificate, exampleVssCertificatesHash, exampleVssCertificatesMap, feedPC, feedPM, staticHeavyDlgIndexes, staticProxySKHeavys) @@ -732,197 +724,6 @@ golden_Timestamp = goldenTestBi timeStamp "test/golden/TimeStamp" roundTripTimestamp :: Property roundTripTimestamp = eachOf 50 genTimestamp roundTripsBiBuildable --------------------------------------------------------------------------------- --- Tx --------------------------------------------------------------------------------- - -golden_Tx :: Property -golden_Tx = goldenTestBi tx "test/golden/Tx" - where - tx = UnsafeTx exampleTxInList exampleTxOutList (mkAttributes ()) - -roundTripTx :: Property -roundTripTx = eachOf 50 genTx roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxAttributes --------------------------------------------------------------------------------- - -golden_TxAttributes :: Property -golden_TxAttributes = goldenTestBi txA "test/golden/TxAttributes" - where - txA = mkAttributes () - - -roundTripTxAttributes :: Property -roundTripTxAttributes = eachOf 10 genTxAttributes roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxAux --------------------------------------------------------------------------------- - -roundTripTxAux :: Property -roundTripTxAux = eachOf 100 (feedPM genTxAux) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- Tx Hash --------------------------------------------------------------------------------- - -golden_HashTx :: Property -golden_HashTx = goldenTestBi exampleHashTx "test/golden/HashTx" - -roundTripHashTx :: Property -roundTripHashTx = eachOf 50 genTxHash roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxIn --------------------------------------------------------------------------------- - - -golden_TxInUtxo :: Property -golden_TxInUtxo = goldenTestBi exampleTxInUtxo "test/golden/TxIn_Utxo" - -golden_TxInUnknown :: Property -golden_TxInUnknown = goldenTestBi exampleTxInUnknown "test/golden/TxIn_Unknown" - -roundTripTxIn :: Property -roundTripTxIn = eachOf 100 genTxIn roundTripsBiBuildable - - --------------------------------------------------------------------------------- --- TxId --------------------------------------------------------------------------------- - -golden_TxId :: Property -golden_TxId = goldenTestBi exampleTxId "test/golden/TxId" - -roundTripTxId :: Property -roundTripTxId = eachOf 50 genTxId roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxInList --------------------------------------------------------------------------------- - -golden_TxInList :: Property -golden_TxInList = goldenTestBi exampleTxInList "test/golden/TxInList" - -roundTripTxInList :: Property -roundTripTxInList = eachOf 50 genTxInList roundTripsBiShow - --------------------------------------------------------------------------------- --- TxInWitness --------------------------------------------------------------------------------- - -golden_PkWitness :: Property -golden_PkWitness = goldenTestBi pkWitness "test/golden/TxInWitness_PkWitness" - where - pkWitness = PkWitness examplePublicKey exampleTxSig - -golden_ScriptWitness :: Property -golden_ScriptWitness = goldenTestBi scriptWitness "test/golden/TxInWitness_ScriptWitness" - where - scriptWitness = ScriptWitness validatorScript redeemerScript - validatorScript = Script 47 "serialized script" - redeemerScript = Script 47 "serialized script" - - -golden_RedeemWitness :: Property -golden_RedeemWitness = goldenTestBi redeemWitness "test/golden/TxInWitness_RedeemWitness" - where - redeemWitness = RedeemWitness exampleRedeemPublicKey exampleRedeemSignature - -golden_UnknownWitnessType :: Property -golden_UnknownWitnessType = goldenTestBi unkWitType "test/golden/TxInWitness_UnknownWitnessType" - where - unkWitType = UnknownWitnessType 47 "forty seven" - --- 4000 because this should generate 1000 for each constructor - -roundTripTxInWitness :: Property -roundTripTxInWitness = eachOf 50 (feedPM genTxInWitness) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxOutList --------------------------------------------------------------------------------- - -golden_TxOutList :: Property -golden_TxOutList = goldenTestBi exampleTxOutList "test/golden/TxOutList" - -roundTripTxOutList :: Property -roundTripTxOutList = eachOf 50 genTxOutList roundTripsBiShow - --------------------------------------------------------------------------------- --- TxOut --------------------------------------------------------------------------------- - -golden_TxOut :: Property -golden_TxOut = goldenTestBi exampleTxOut "test/golden/TxOut" - -roundTripTxOut :: Property -roundTripTxOut = eachOf 50 genTxOut roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxOutAux --------------------------------------------------------------------------------- - -golden_TxOutAux :: Property -golden_TxOutAux = goldenTestBi txOutAux "test/golden/TxOutAux" - where - txOutAux = TxOutAux exampleTxOut - -roundTripTxOutAux :: Property -roundTripTxOutAux = eachOf 50 genTxOutAux roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxPayload --------------------------------------------------------------------------------- - -roundTripTxPayload :: Property -roundTripTxPayload = eachOf 50 (feedPM genTxPayload) roundTripsBiShow - --------------------------------------------------------------------------------- --- TxProof --------------------------------------------------------------------------------- - -golden_TxProof :: Property -golden_TxProof = goldenTestBi exampleTxProof "test/golden/TxProof" - -roundTripTxProof :: Property -roundTripTxProof = eachOf 50 (feedPM genTxProof) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxSig --------------------------------------------------------------------------------- - -golden_TxSig :: Property -golden_TxSig = goldenTestBi txSigGold "test/golden/TxSig" - where - txSigGold = sign (ProtocolMagic 0) SignForTestingOnly - exampleSecretKey exampleTxSigData - -roundTripTxSig :: Property -roundTripTxSig = eachOf 50 (feedPM genTxSig) roundTripsBiBuildable - --------------------------------------------------------------------------------- --- TxSigData --------------------------------------------------------------------------------- - -golden_TxSigData :: Property -golden_TxSigData = goldenTestBi exampleTxSigData "test/golden/TxSigData" - -roundTripTxSigData :: Property -roundTripTxSigData = eachOf 50 genTxSigData roundTripsBiShow - --------------------------------------------------------------------------------- --- TxWitness --------------------------------------------------------------------------------- - -golden_TxWitness :: Property -golden_TxWitness = goldenTestBi exampleTxWitness "test/golden/TxWitness" - -roundTripTxWitness :: Property -roundTripTxWitness = eachOf 20 (feedPM genTxWitness) roundTripsBiShow - -------------------------------------------------------------------------------- -- UpAttributes -------------------------------------------------------------------------------- @@ -1068,9 +869,6 @@ sizeEstimates :: H.Group sizeEstimates = let check :: forall a. (Show a, Bi a) => Gen a -> Property check g = sizeTest $ scfg { gen = g } - pm = ProtocolMagic 0 - knownTxIn (TxInUnknown _ _) = False - knownTxIn _ = True pkOrRedeem (PubKeyASD _) = True pkOrRedeem (RedeemASD _) = True pkOrRedeem _ = False @@ -1082,16 +880,10 @@ sizeEstimates = SizeConstant (szCases [ Case "min" 1, Case "max" 1024 ])) portionSize = (typeRep (Proxy @(Map (AbstractHash Blake2b_224 PublicKey) CoinPortion)), SizeConstant (szCases [ Case "min" 1, Case "max" 1024 ])) - txSigSize = (typeRep (Proxy @(Signature TxSigData)) - , SizeConstant 66) - scriptSize = (typeRep (Proxy @Script), - SizeConstant $ szCases [ Case "loScript" 1 - , Case "hiScript" 255 ]) in H.Group "Encoded size bounds for core types." [ ("Coin" , check genCoin) , ("BlockCount" , check genBlockCount) - , ("TxId" , check genTxId) , ("Attributes ()" , sizeTest $ scfg { gen = genAttributes (pure ()) , addlCtx = M.fromList [ attrUnitSize ] @@ -1115,45 +907,6 @@ sizeEstimates = SelectCases ["PubKeyASD", "RedeemASD"]) ] }) , ("AddrType" , check genAddrType) - , ("Tx" , sizeTest $ scfg - { gen = genTx - , addlCtx = M.fromList [ attrUnitSize, attrAddrSize ] - , computedCtx = \tx -> M.fromList - [ (typeRep (Proxy @(LengthOf [TxIn])), - SizeConstant (fromIntegral $ length $ _txInputs tx)) - , (typeRep (Proxy @(LengthOf [TxOut])), - SizeConstant (fromIntegral $ length $ _txOutputs tx)) - ] - }) - , ("TxIn" , check (Gen.filter knownTxIn genTxIn)) - , ("TxOut" , sizeTest $ scfg - { gen = genTxOut - , addlCtx = M.fromList [ attrAddrSize ] - }) - , ("TxAux" , sizeTest $ scfg - { gen = genTxAux pm - , addlCtx = M.fromList [ attrUnitSize - , attrAddrSize - , scriptSize - , txSigSize ] - , computedCtx = \(TxAux tx witness) -> M.fromList - [ (typeRep (Proxy @(LengthOf [TxIn])), - SizeConstant (fromIntegral $ length $ _txInputs tx)) - , (typeRep (Proxy @(LengthOf (Vector TxInWitness))), - SizeConstant (fromIntegral $ length witness)) - , (typeRep (Proxy @(LengthOf [TxOut])), - SizeConstant (fromIntegral $ length $ _txOutputs tx)) - ] - }) - , ("TxInWitness" , sizeTest $ scfg - { gen = genTxInWitness pm - , addlCtx = M.fromList [ txSigSize, scriptSize ] - }) - , ("TxSigData" , check genTxSigData) - , ("Signature TxSigData" , sizeTest $ scfg - { gen = genTxSig pm - , addlCtx = M.fromList [ txSigSize ] - }) ] ----------------------------------------------------------------------- diff --git a/core/test/Test/Pos/Core/ExampleHelpers.hs b/core/test/Test/Pos/Core/ExampleHelpers.hs index 945595a3848..ea4d1a272e1 100644 --- a/core/test/Test/Pos/Core/ExampleHelpers.hs +++ b/core/test/Test/Pos/Core/ExampleHelpers.hs @@ -20,7 +20,6 @@ module Test.Pos.Core.ExampleHelpers , exampleGenesisConfiguration_GCSrc , exampleGenesisDelegation , exampleGenesisInitializer - , exampleHashTx , exampleInnerSharesMap , exampleLightDlgIndices , exampleOpening @@ -29,7 +28,6 @@ module Test.Pos.Core.ExampleHelpers , exampleProxySKBlockInfo , examplePublicKey , exampleRedeemPublicKey - , exampleRedeemSignature , exampleScript , exampleSecretKey , exampleSecretKeys @@ -45,17 +43,6 @@ module Test.Pos.Core.ExampleHelpers , exampleStakeholderIds , exampleStakesList , exampleSystemTag - , exampleTxId - , exampleTxInList - , exampleTxInUnknown - , exampleTxInUtxo - , exampleTxPayload - , exampleTxProof - , exampleTxOut - , exampleTxOutList - , exampleTxSig - , exampleTxSigData - , exampleTxWitness , exampleUpdateData , exampleUpdatePayload , exampleUpdateProof @@ -91,7 +78,6 @@ import qualified Data.Map as M import Data.Maybe (fromJust) import qualified Data.Text as T import Data.Time.Units (Millisecond) -import qualified Data.Vector as V import qualified Hedgehog as H import Serokell.Data.Memory.Units (Byte) import qualified Serokell.Util.Base16 as B16 @@ -102,11 +88,10 @@ import Pos.Core.Attributes (Attributes, mkAttributes) import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..), AddrStakeDistribution (..), Address (..), BlockCount (..), ChainDifficulty (..), Coeff (..), Coin (..), - CoinPortion (..), IsBootstrapEraAddr (..), Script (..), - ScriptVersion, SharedSeed (..), SlotLeaders, - StakeholderId, StakesList, TxFeePolicy (..), - TxSizeLinear (..), addressHash, coinPortionDenominator, - makeAddress, makePubKeyAddress, mkMultiKeyDistr) + CoinPortion (..), Script (..), ScriptVersion, + SharedSeed (..), SlotLeaders, StakeholderId, StakesList, + TxFeePolicy (..), TxSizeLinear (..), addressHash, + coinPortionDenominator, makeAddress, mkMultiKeyDistr) import Pos.Core.Configuration import Pos.Core.Delegation (HeavyDlgIndex (..), LightDlgIndices (..), ProxySKBlockInfo, ProxySKHeavy) @@ -114,7 +99,6 @@ import Pos.Core.Genesis (FakeAvvmOptions (..), GenesisAvvmBalances (..), GenesisDelegation (..), GenesisInitializer (..), GenesisProtocolConstants (..), GenesisSpec (..), TestnetBalanceOptions (..)) -import Pos.Core.Merkle (mkMerkleTree, mtRoot) import Pos.Core.ProtocolConstants (ProtocolConstants, VssMaxTTL (..), VssMinTTL (..)) import Pos.Core.Slotting (EpochIndex (..), FlatSlotId, @@ -126,10 +110,6 @@ import Pos.Core.Ssc (Commitment, CommitmentSignature, CommitmentsMap, VssCertificatesMap (..), mkCommitmentsMap, mkVssCertificate, mkVssCertificatesMap, randCommitmentAndOpening) -import Pos.Core.Txp (Tx (..), TxAux (..), TxId, TxIn (..), - TxInWitness (..), TxOut (..), TxPayload (..), - TxProof (..), TxSig, TxSigData (..), TxWitness, - mkTxPayload) import Pos.Core.Update (ApplicationName (..), BlockVersion (..), BlockVersionData (..), BlockVersionModifier (..), SoftforkRule (..), SoftwareVersion (..), SystemTag (..), @@ -137,14 +117,13 @@ import Pos.Core.Update (ApplicationName (..), BlockVersion (..), UpdateProof, UpdateProposal, UpdateProposalToSign (..), UpdateVote (..), VoteId, mkUpdateProof, mkUpdateProposalWSign, mkUpdateVoteSafe) -import Pos.Crypto (AbstractHash (..), EncShare (..), - HDAddressPayload (..), Hash, ProtocolMagic (..), - RedeemPublicKey, RedeemSignature, SafeSigner (..), +import Pos.Crypto (EncShare (..), HDAddressPayload (..), + ProtocolMagic (..), RedeemPublicKey, SafeSigner (..), Secret (..), SecretKey (..), SecretProof (..), SignTag (..), VssKeyPair, VssPublicKey (..), abstractHash, decryptShare, deterministic, deterministicVssKeyGen, hash, - redeemDeterministicKeyGen, redeemSign, safeCreatePsk, - sign, toVssPublicKey) + redeemDeterministicKeyGen, safeCreatePsk, sign, + toVssPublicKey) import Pos.Crypto.Signing (ProxyCert (..), ProxySecretKey (..), PublicKey (..), RedeemPublicKey (..)) @@ -319,11 +298,6 @@ examplePublicKeys offset count = map (toKey . (*offset)) [0..count-1] exampleRedeemPublicKey :: RedeemPublicKey exampleRedeemPublicKey = fromJust (fst <$> redeemDeterministicKeyGen (getBytes 0 32)) -exampleRedeemSignature :: RedeemSignature TxSigData -exampleRedeemSignature = redeemSign (ProtocolMagic 0) SignForTestingOnly rsk exampleTxSigData - where - rsk = fromJust (snd <$> redeemDeterministicKeyGen (getBytes 0 32)) - -- In order to get the key starting at byte 10, we generate two with offsets of 10 -- between them and take the second. exampleSecretKey :: SecretKey @@ -394,46 +368,6 @@ exampleSystemTags offset count = map (toSystemTag . (*offset)) [0..count-1] where toSystemTag start = SystemTag (getText start 16) -exampleTxAux :: TxAux -exampleTxAux = TxAux tx exampleTxWitness - where - tx = UnsafeTx exampleTxInList exampleTxOutList (mkAttributes ()) - -exampleTxId :: TxId -exampleTxId = exampleHashTx - -exampleTxInList :: (NonEmpty TxIn) -exampleTxInList = fromList [exampleTxInUtxo] - -exampleTxInUnknown :: TxIn -exampleTxInUnknown = TxInUnknown 47 ("forty seven" :: ByteString) - -exampleTxInUtxo :: TxIn -exampleTxInUtxo = TxInUtxo exampleHashTx 47 -- TODO: loop here - -exampleTxOut :: TxOut -exampleTxOut = TxOut (makePubKeyAddress (IsBootstrapEraAddr True) pkey) (Coin 47) - where - Right pkey = PublicKey <$> CC.xpub (getBytes 0 64) - -exampleTxOutList :: (NonEmpty TxOut) -exampleTxOutList = fromList [exampleTxOut] - -exampleTxProof :: TxProof -exampleTxProof = TxProof 32 mroot hashWit - where - mroot = mtRoot $ mkMerkleTree [(UnsafeTx exampleTxInList exampleTxOutList (mkAttributes ()))] - hashWit = hash $ [(V.fromList [(PkWitness examplePublicKey exampleTxSig)])] - -exampleTxSig :: TxSig -exampleTxSig = sign (ProtocolMagic 0) SignForTestingOnly exampleSecretKey exampleTxSigData - -exampleTxSigData :: TxSigData -exampleTxSigData = TxSigData exampleHashTx - -exampleTxWitness :: TxWitness -exampleTxWitness = V.fromList [(PkWitness examplePublicKey exampleTxSig)] - exampleUpAttributes :: UpAttributes exampleUpAttributes = exampleAttributes @@ -540,15 +474,9 @@ staticText getText :: Int -> Int -> Text getText offset len = T.take len $ T.drop offset staticText -exampleTxPayload :: TxPayload -exampleTxPayload = mkTxPayload [exampleTxAux] - exampleSoftwareVersion :: SoftwareVersion exampleSoftwareVersion = SoftwareVersion (ApplicationName "Golden") 99 -exampleHashTx :: Hash Tx -exampleHashTx = coerce (hash "golden" :: Hash Text) - exampleSscProof :: SscProof exampleSscProof = CommitmentsProof (hash exampleCommitmentsMap) (exampleVssCertificatesHash 10 4) diff --git a/core/test/Test/Pos/Core/Gen.hs b/core/test/Test/Pos/Core/Gen.hs index 95ccefd93e2..fcfd9c16461 100644 --- a/core/test/Test/Pos/Core/Gen.hs +++ b/core/test/Test/Pos/Core/Gen.hs @@ -76,28 +76,6 @@ module Test.Pos.Core.Gen , genVssCertificatesHash , genVssCertificatesMap - -- Pos.Core.Txp Generators - , genPkWitness - , genRedeemWitness - , genScriptWitness - , genTx - , genTxAttributes - , genTxAux - , genTxHash - , genTxId - , genTxIn - , genTxInList - , genTxInWitness - , genTxOut - , genTxOutAux - , genTxOutList - , genTxPayload - , genTxProof - , genTxSig - , genTxSigData - , genTxWitness - , genUnknownWitnessType - -- Pos.Core.Update Generators , genApplicationName , genBlockVersion @@ -129,14 +107,15 @@ module Test.Pos.Core.Gen -- Helpers , genTextHash , genByte + , genBytes , genUTF8Byte , genWord16 + , genWord32 , gen32Bytes ) where import Universum -import Data.ByteString.Base16 as B16 import Data.Coerce (coerce) import Data.Either (either) import Data.Fixed (Fixed (..)) @@ -145,7 +124,6 @@ import Data.List.NonEmpty (fromList) import qualified Data.Map as M import Data.Maybe import Data.Time.Units (Microsecond, Millisecond, fromMicroseconds) -import qualified Data.Vector as V import Hedgehog import qualified Hedgehog.Gen as Gen import qualified Hedgehog.Range as Range @@ -184,10 +162,6 @@ import Pos.Core.Ssc (Commitment, CommitmentSignature, CommitmentsMap, VssCertificatesMap (..), mkCommitmentsMap, mkSscProof, mkVssCertificate, mkVssCertificatesMap, randCommitmentAndOpening) -import Pos.Core.Txp (Tx (..), TxAttributes, TxAux (..), TxId, - TxIn (..), TxInWitness (..), TxOut (..), TxOutAux (..), - TxPayload (..), TxProof (..), TxSig, TxSigData (..), - TxWitness, mkTxPayload) import Pos.Core.Update (ApplicationName (..), BlockVersion (..), BlockVersionData (..), BlockVersionModifier (..), SoftforkRule (..), SoftwareVersion (..), SystemTag (..), @@ -195,15 +169,15 @@ import Pos.Core.Update (ApplicationName (..), BlockVersion (..), UpdateProof, UpdateProposal (..), UpdateProposalToSign (..), UpdateProposals, UpdateVote (..), VoteId, mkUpdateVote) -import Pos.Crypto (Hash, ProtocolMagic, decodeHash, deterministic, - hash, safeCreatePsk, sign) +import Pos.Crypto (Hash, ProtocolMagic, deterministic, hash, + safeCreatePsk) import Pos.Util.Util (leftToPanic) import Serokell.Data.Memory.Units (Byte) import Test.Pos.Crypto.Gen (genAbstractHash, genDecShare, genHDAddressPayload, genProtocolMagic, genPublicKey, - genRedeemPublicKey, genRedeemSignature, genSafeSigner, - genSecretKey, genSignTag, genSignature, genVssPublicKey) + genRedeemPublicKey, genSafeSigner, genSecretKey, + genSignature, genVssPublicKey) genGenesisHash :: Gen GenesisHash genGenesisHash = do @@ -610,99 +584,6 @@ genVssCertificatesMap :: ProtocolMagic -> Gen VssCertificatesMap genVssCertificatesMap pm = mkVssCertificatesMap <$> Gen.list (Range.linear 0 5) (genVssCertificate pm) ----------------------------------------------------------------------------- --- Pos.Core.Txp Generators ----------------------------------------------------------------------------- - -genPkWitness :: ProtocolMagic -> Gen TxInWitness -genPkWitness pm = PkWitness <$> genPublicKey <*> genTxSig pm - -genRedeemWitness :: ProtocolMagic -> Gen TxInWitness -genRedeemWitness pm = - RedeemWitness <$> genRedeemPublicKey <*> genRedeemSignature pm genTxSigData - -genScriptWitness :: Gen TxInWitness -genScriptWitness = ScriptWitness <$> genScript <*> genScript - -genTx :: Gen Tx -genTx = UnsafeTx <$> genTxInList <*> genTxOutList <*> genTxAttributes - -genTxAttributes :: Gen TxAttributes -genTxAttributes = pure $ mkAttributes () - -genTxAux :: ProtocolMagic -> Gen TxAux -genTxAux pm = TxAux <$> genTx <*> (genTxWitness pm) - -genTxHash :: Gen (Hash Tx) -genTxHash = coerce <$> genTextHash - -genTextHash :: Gen (Hash Text) -genTextHash = do - sampleText <- Gen.text (Range.linear 0 10) Gen.alphaNum - pure (hash sampleText :: Hash Text) - -genTxId :: Gen TxId -genTxId = genBase16Text >>= pure . decodeHash >>= either error pure - where - genBase16Text = decodeUtf8 @Text @ByteString <$> genBase16Bs - ---genTxId :: Gen TxId ---genTxId = coerce <$> genTxHash - -genTxIn :: Gen TxIn -genTxIn = Gen.choice gens - where - gens = [ TxInUtxo <$> genTxId <*> genWord32 - -- 0 is reserved for TxInUtxo tag ----------+ - , TxInUnknown <$> Gen.word8 (Range.constant 1 255) - <*> gen32Bytes - ] - -genTxInList :: Gen (NonEmpty TxIn) -genTxInList = Gen.nonEmpty (Range.linear 1 20) genTxIn - -genTxOut :: Gen TxOut -genTxOut = TxOut <$> genAddress <*> genCoin - -genTxOutAux :: Gen TxOutAux -genTxOutAux = TxOutAux <$> genTxOut - -genTxOutList :: Gen (NonEmpty TxOut) -genTxOutList = Gen.nonEmpty (Range.linear 1 100) genTxOut - -genTxPayload :: ProtocolMagic -> Gen TxPayload -genTxPayload pm = mkTxPayload <$> (Gen.list (Range.linear 0 10) (genTxAux pm)) - -genTxProof :: ProtocolMagic -> Gen TxProof -genTxProof pm = - TxProof - <$> genWord32 - <*> genMerkleRoot genTx - <*> genAbstractHash (Gen.list (Range.linear 1 5) (genTxWitness pm)) - -genTxSig :: ProtocolMagic -> Gen TxSig -genTxSig pm = - sign pm <$> genSignTag <*> genSecretKey <*> genTxSigData - -genTxSigData :: Gen TxSigData -genTxSigData = TxSigData <$> genTxHash - -genTxInWitness :: ProtocolMagic -> Gen TxInWitness -genTxInWitness pm = Gen.choice gens - where - gens = [ genPkWitness pm - , genRedeemWitness pm - , genScriptWitness - , genUnknownWitnessType - ] - -genTxWitness :: ProtocolMagic -> Gen TxWitness -genTxWitness pm = V.fromList <$> Gen.list (Range.linear 1 10) (genTxInWitness pm) - -genUnknownWitnessType :: Gen TxInWitness -genUnknownWitnessType = - UnknownWitnessType <$> Gen.word8 (Range.constant 3 maxBound) <*> gen32Bytes - ---------------------------------------------------------------------------- -- Pos.Core.Update Generators ---------------------------------------------------------------------------- @@ -865,9 +746,6 @@ customHashMapGen keyGen valGen = HM.fromList <$> (Gen.list (Range.linear 1 10) $ (,) <$> keyGen <*> valGen) -genBase16Bs :: Gen ByteString -genBase16Bs = B16.encode <$> genBytes 32 - genBytes :: Int -> Gen ByteString genBytes n = Gen.bytes (Range.singleton n) @@ -902,3 +780,8 @@ genWord8 = Gen.word8 Range.constantBounded genWord16 :: Gen Word16 genWord16 = Gen.word16 Range.constantBounded + +genTextHash :: Gen (Hash Text) +genTextHash = do + sampleText <- Gen.text (Range.linear 0 10) Gen.alphaNum + pure (hash sampleText :: Hash Text) diff --git a/core/test/cardano-sl-core-test.cabal b/core/test/cardano-sl-core-test.cabal index 9ba1cd90d1c..394fc641dac 100644 --- a/core/test/cardano-sl-core-test.cabal +++ b/core/test/cardano-sl-core-test.cabal @@ -21,8 +21,6 @@ library Test.Pos.Core.Arbitrary Test.Pos.Core.Arbitrary.Unsafe Test.Pos.Core.Arbitrary.Slotting - Test.Pos.Core.Arbitrary.Txp - Test.Pos.Core.Arbitrary.Txp.Unsafe Test.Pos.Core.Json build-depends: QuickCheck @@ -88,4 +86,3 @@ library ghc-options: -O2 -Wall - diff --git a/db/src/Pos/DB/Block/Logic/Creation.hs b/db/src/Pos/DB/Block/Logic/Creation.hs index a1405dbfdd3..19f8fe7b40c 100644 --- a/db/src/Pos/DB/Block/Logic/Creation.hs +++ b/db/src/Pos/DB/Block/Logic/Creation.hs @@ -31,7 +31,8 @@ import qualified Pos.Chain.Block as BC import Pos.Chain.Delegation (DelegationVar, DlgPayload (..), ProxySKBlockInfo) import Pos.Chain.Ssc (MonadSscMem, defaultSscPayload, stripSscPayload) -import Pos.Chain.Txp (TxpConfiguration, emptyTxPayload) +import Pos.Chain.Txp (TxAux (..), TxpConfiguration, emptyTxPayload, + mkTxPayload) import Pos.Chain.Update (HasUpdateConfiguration, curSoftwareVersion, lastKnownBlockVersion) import Pos.Core (EpochIndex, EpochOrSlot (..), HasProtocolConstants, @@ -43,7 +44,6 @@ import Pos.Core.JsonLog (CanJsonLog (..)) import Pos.Core.JsonLog.LogEvents (MemPoolModifyReason (..)) import Pos.Core.Reporting (HasMisbehaviorMetrics, reportError) import Pos.Core.Ssc (SscPayload) -import Pos.Core.Txp (TxAux (..), mkTxPayload) import Pos.Core.Update (UpdatePayload (..)) import Pos.Core.Util.LogSafe (logInfoS) import Pos.Crypto (ProtocolMagic, SecretKey) diff --git a/db/src/Pos/DB/Txp/Logic/Common.hs b/db/src/Pos/DB/Txp/Logic/Common.hs index 32d6e2df161..835e3e7a4ae 100644 --- a/db/src/Pos/DB/Txp/Logic/Common.hs +++ b/db/src/Pos/DB/Txp/Logic/Common.hs @@ -9,8 +9,8 @@ import Universum import qualified Data.Map as M (fromList) -import Pos.Chain.Txp (Utxo, UtxoModifier) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxOutAux) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxIn (..), TxOutAux, Utxo, + UtxoModifier) import Pos.Crypto (hash) import Pos.DB.Class (MonadDBRead) import Pos.DB.Txp.Utxo (getTxOut) diff --git a/db/src/Pos/DB/Txp/Logic/Global.hs b/db/src/Pos/DB/Txp/Logic/Global.hs index b19f48c3e78..63cafc6792b 100644 --- a/db/src/Pos/DB/Txp/Logic/Global.hs +++ b/db/src/Pos/DB/Txp/Logic/Global.hs @@ -25,15 +25,15 @@ import Formatting (build, sformat, (%)) import Pos.Chain.Block (ComponentBlock (..)) import Pos.Chain.Txp (ExtendedGlobalToilM, GlobalToilEnv (..), GlobalToilM, GlobalToilState (..), StakesView (..), - ToilVerFailure, TxpConfiguration (..), Utxo, UtxoM, - UtxoModifier, applyToil, defGlobalToilState, - flattenTxPayload, gtsUtxoModifier, rollbackToil, - runGlobalToilMBase, runUtxoM, utxoToLookup, verifyToil) + ToilVerFailure, TxAux, TxUndo, TxpConfiguration (..), + TxpUndo, Utxo, UtxoM, UtxoModifier, applyToil, + defGlobalToilState, flattenTxPayload, gtsUtxoModifier, + rollbackToil, runGlobalToilMBase, runUtxoM, utxoToLookup, + verifyToil) import Pos.Core (HasCoreConfiguration, HasGenesisData, ProtocolMagic, epochIndexL) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) import Pos.Core.Exception (assertionFailed) -import Pos.Core.Txp (TxAux, TxUndo, TxpUndo) import Pos.DB (SomeBatchOp (..)) import Pos.DB.Class (gsAdoptedBVData) import Pos.DB.GState.Stakes (getRealStake, getRealTotalStake) diff --git a/db/src/Pos/DB/Txp/Logic/Local.hs b/db/src/Pos/DB/Txp/Logic/Local.hs index 13f88988725..7aff283fe49 100644 --- a/db/src/Pos/DB/Txp/Logic/Local.hs +++ b/db/src/Pos/DB/Txp/Logic/Local.hs @@ -29,16 +29,15 @@ import System.Wlog (NamedPureLogger, WithLogger, launchNamedPureLog, import Pos.Chain.Block (HeaderHash) import Pos.Chain.Txp (ExtendedLocalToilM, LocalToilState (..), - MemPool, ToilVerFailure (..), TxpConfiguration (..), - UndoMap, Utxo, UtxoLookup, UtxoModifier, extendLocalToilM, - mpLocalTxs, normalizeToil, processTx, topsortTxs, - utxoToLookup) + MemPool, ToilVerFailure (..), TxAux (..), TxId, TxUndo, + TxpConfiguration (..), UndoMap, Utxo, UtxoLookup, + UtxoModifier, extendLocalToilM, mpLocalTxs, normalizeToil, + processTx, topsortTxs, utxoToLookup) import Pos.Core (EpochIndex, ProtocolMagic, 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.Txp (TxAux (..), TxId, TxUndo) import Pos.Core.Update (BlockVersionData) import Pos.Crypto (WithHash (..)) import Pos.DB.Class (MonadGState (..)) diff --git a/db/src/Pos/DB/Txp/MemState/Class.hs b/db/src/Pos/DB/Txp/MemState/Class.hs index f728425bc86..b80691354a4 100644 --- a/db/src/Pos/DB/Txp/MemState/Class.hs +++ b/db/src/Pos/DB/Txp/MemState/Class.hs @@ -30,11 +30,10 @@ import Data.Default (Default (..)) import qualified Data.HashMap.Strict as HM import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Txp (MemPool (..), ToilVerFailure, TxpConfiguration, - UndoMap, UtxoModifier) +import Pos.Chain.Txp (MemPool (..), ToilVerFailure, TxAux, TxId, + TxpConfiguration, UndoMap, UtxoModifier) import Pos.Core.Reporting (MonadReporting) import Pos.Core.Slotting (MonadSlots (..)) -import Pos.Core.Txp (TxAux, TxId) import Pos.Crypto (ProtocolMagic) import Pos.DB.Class (MonadDBRead, MonadGState (..)) import Pos.DB.Txp.MemState.Types (GenericTxpLocalData (..)) diff --git a/db/src/Pos/DB/Txp/Settings.hs b/db/src/Pos/DB/Txp/Settings.hs index 494fcccaa33..874287de4b2 100644 --- a/db/src/Pos/DB/Txp/Settings.hs +++ b/db/src/Pos/DB/Txp/Settings.hs @@ -19,10 +19,9 @@ import Universum import System.Wlog (WithLogger) import Pos.Chain.Block (ComponentBlock) -import Pos.Chain.Txp (ToilVerFailure) +import Pos.Chain.Txp (ToilVerFailure, TxPayload, TxpUndo) import Pos.Core.Chrono (NE, NewestFirst, OldestFirst) import Pos.Core.Slotting (MonadSlots) -import Pos.Core.Txp (TxPayload, TxpUndo) import Pos.DB (MonadDBRead, MonadGState, SomeBatchOp) type TxpCommonMode m = diff --git a/db/src/Pos/DB/Txp/Utxo.hs b/db/src/Pos/DB/Txp/Utxo.hs index 953cb91d8cf..b527de84660 100644 --- a/db/src/Pos/DB/Txp/Utxo.hs +++ b/db/src/Pos/DB/Txp/Utxo.hs @@ -42,13 +42,12 @@ import Serokell.Util (Color (Red), colorize) import System.Wlog (WithLogger, logError) import UnliftIO (MonadUnliftIO) -import Pos.Chain.Txp (GenesisUtxo (..), Utxo, addrBelongsToSet, - txOutStake) +import Pos.Chain.Txp (GenesisUtxo (..), TxIn (..), TxOutAux (toaOut), + Utxo, addrBelongsToSet, txOutStake) import Pos.Core (Address, Coin, HasCoreConfiguration, coinF, genesisData, mkCoin, sumCoins, unsafeAddCoin, unsafeIntegerToCoin) import Pos.Core.Genesis (GenesisData (..)) -import Pos.Core.Txp (TxIn (..), TxOutAux (toaOut)) import Pos.DB (DBError (..), DBIteratorClass (..), DBTag (GStateDB), IterType, MonadDB, MonadDBRead, RocksBatchOp (..), dbIterSource, dbSerializeValue, encodeWithKeyPrefix) diff --git a/db/test/Test/Pos/DB/Block/Arbitrary.hs b/db/test/Test/Pos/DB/Block/Arbitrary.hs index c7dbf6a45f2..2ec3ccf5b56 100644 --- a/db/test/Test/Pos/DB/Block/Arbitrary.hs +++ b/db/test/Test/Pos/DB/Block/Arbitrary.hs @@ -12,8 +12,8 @@ import Pos.Chain.Block (SlogUndo, Undo (..)) import Pos.Core (HasProtocolConstants) import Test.Pos.Chain.Delegation.Arbitrary () +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Core.Arbitrary () -import Test.Pos.Core.Arbitrary.Txp () import Test.Pos.DB.Update.Arbitrary () instance Arbitrary SlogUndo where diff --git a/explorer/bench/Bench/Pos/Explorer/ServerBench.hs b/explorer/bench/Bench/Pos/Explorer/ServerBench.hs index 98f5c93cb71..d3d0d936110 100644 --- a/explorer/bench/Bench/Pos/Explorer/ServerBench.hs +++ b/explorer/bench/Bench/Pos/Explorer/ServerBench.hs @@ -20,8 +20,8 @@ import Pos.Explorer.TestUtil (BlockNumber, SlotsPerEpoch, import Pos.Explorer.Web.ClientTypes (CBlockEntry) import Pos.Explorer.Web.Server (getBlocksPage, getBlocksTotal) +import Test.Pos.Chain.Txp.Arbitrary.Unsafe () import Test.Pos.Configuration (withDefConfigurations) -import Test.Pos.Core.Arbitrary.Txp.Unsafe () ---------------------------------------------------------------- -- Mocked functions diff --git a/explorer/cardano-sl-explorer.cabal b/explorer/cardano-sl-explorer.cabal index 2a380121ed7..ddad49cfe0f 100644 --- a/explorer/cardano-sl-explorer.cabal +++ b/explorer/cardano-sl-explorer.cabal @@ -404,6 +404,7 @@ benchmark cardano-explorer-bench build-depends: QuickCheck , base , cardano-sl + , cardano-sl-chain-test , cardano-sl-core-test , cardano-sl-explorer , criterion diff --git a/explorer/src/Pos/Explorer/BListener.hs b/explorer/src/Pos/Explorer/BListener.hs index 74592de3b1e..7310bcf7b24 100644 --- a/explorer/src/Pos/Explorer/BListener.hs +++ b/explorer/src/Pos/Explorer/BListener.hs @@ -31,12 +31,11 @@ import UnliftIO (MonadUnliftIO) import Pos.Chain.Block (Block, Blund, HeaderHash, MainBlock, headerHash, mainBlockSlot, mainBlockTxPayload) -import Pos.Chain.Txp (topsortTxs) +import Pos.Chain.Txp (Tx, topsortTxs, txpTxs) import Pos.Core (HasConfiguration, LocalSlotIndex (..), SlotId (..), difficultyL, epochIndexL, getChainDifficulty) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..), toNewestFirst) -import Pos.Core.Txp (Tx, txpTxs) import Pos.Crypto (withHash) import Pos.DB.BatchOp (SomeBatchOp (..)) import Pos.DB.Block (MonadBListener (..)) diff --git a/explorer/src/Pos/Explorer/Core/Types.hs b/explorer/src/Pos/Explorer/Core/Types.hs index 8c272092971..ed421b113f3 100644 --- a/explorer/src/Pos/Explorer/Core/Types.hs +++ b/explorer/src/Pos/Explorer/Core/Types.hs @@ -9,9 +9,9 @@ import Universum import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) import Pos.Chain.Block (HeaderHash) +import Pos.Chain.Txp (TxId, TxUndo) import Pos.Core (Timestamp) import Pos.Core.Chrono (NewestFirst) -import Pos.Core.Txp (TxId, TxUndo) type AddrHistory = NewestFirst [] TxId diff --git a/explorer/src/Pos/Explorer/DB.hs b/explorer/src/Pos/Explorer/DB.hs index 7d4c1a415b3..bccce5e8760 100644 --- a/explorer/src/Pos/Explorer/DB.hs +++ b/explorer/src/Pos/Explorer/DB.hs @@ -43,12 +43,11 @@ import UnliftIO (MonadUnliftIO) import Pos.Binary.Class (serialize') import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Txp (GenesisUtxo (..), genesisUtxo, utxoF, - utxoToAddressCoinPairs) +import Pos.Chain.Txp (GenesisUtxo (..), Tx, TxId, TxOut (..), + TxOutAux (..), genesisUtxo, utxoF, utxoToAddressCoinPairs) import Pos.Core (Address, Coin, EpochIndex (..), HasConfiguration, SlotCount, coinToInteger, unsafeAddCoin) import Pos.Core.Chrono (NewestFirst (..)) -import Pos.Core.Txp (Tx, TxId, TxOut (..), TxOutAux (..)) import Pos.Crypto (ProtocolMagic) import Pos.DB (DBError (..), DBIteratorClass (..), DBTag (GStateDB), MonadDB, MonadDBRead (dbGet), RocksBatchOp (..), diff --git a/explorer/src/Pos/Explorer/Socket/Methods.hs b/explorer/src/Pos/Explorer/Socket/Methods.hs index f35a5e32735..5cbea83d7ac 100644 --- a/explorer/src/Pos/Explorer/Socket/Methods.hs +++ b/explorer/src/Pos/Explorer/Socket/Methods.hs @@ -64,10 +64,10 @@ import Formatting (sformat, shown, stext, (%)) import Network.EngineIO (SocketId) import Network.SocketIO (Socket, socketId) import Pos.Chain.Block (Block, Blund, HeaderHash, mainBlockTxPayload) +import Pos.Chain.Txp (Tx (..), TxOut (..), TxOutAux (..), + txOutAddress, txpTxs) import Pos.Core (Address) import Pos.Core.Chrono (getOldestFirst) -import Pos.Core.Txp (Tx (..), TxOut (..), TxOutAux (..), txOutAddress, - txpTxs) import Pos.Crypto (hash, withHash) import Pos.DB.Block (getBlund) import qualified Pos.DB.Block as DB diff --git a/explorer/src/Pos/Explorer/TestUtil.hs b/explorer/src/Pos/Explorer/TestUtil.hs index 0db6d44a564..8e742e5f1da 100644 --- a/explorer/src/Pos/Explorer/TestUtil.hs +++ b/explorer/src/Pos/Explorer/TestUtil.hs @@ -37,6 +37,7 @@ import Pos.Chain.Block (Block, BlockHeader, Blund, GenesisBlock, import Pos.Chain.Delegation (DlgPayload, DlgUndo (..), ProxySKBlockInfo) import Pos.Chain.Ssc (defaultSscPayload) +import Pos.Chain.Txp (TxAux) import Pos.Chain.Update (HasUpdateConfiguration) import qualified Pos.Communication () import Pos.Core (Address, BlockCount (..), ChainDifficulty (..), @@ -45,7 +46,6 @@ import Pos.Core (Address, BlockCount (..), ChainDifficulty (..), StakeholderId, difficultyL, genesisHash, makePubKeyAddressBoot) import Pos.Core.Ssc (SscPayload) -import Pos.Core.Txp (TxAux) import Pos.Core.Update (UpdatePayload (..)) import Pos.Crypto (ProtocolMagic, SecretKey, toPublic) import Pos.DB.Block (RawPayload (..), createMainBlockPure) diff --git a/explorer/src/Pos/Explorer/Txp/Common.hs b/explorer/src/Pos/Explorer/Txp/Common.hs index f11cf374bf3..7845628b965 100644 --- a/explorer/src/Pos/Explorer/Txp/Common.hs +++ b/explorer/src/Pos/Explorer/Txp/Common.hs @@ -10,10 +10,9 @@ import Universum hiding (keys) import Control.Lens (at, non) import qualified Data.HashMap.Strict as HM -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (Tx (..), TxAux (..), Utxo, toaOut, txOutAddress) import Pos.Core (Address, Coin) import Pos.Core.Chrono (NewestFirst (..)) -import Pos.Core.Txp (Tx (..), TxAux (..), toaOut, txOutAddress) import Pos.DB.Class (MonadDBRead) import qualified Pos.Explorer.DB as ExDB diff --git a/explorer/src/Pos/Explorer/Txp/Global.hs b/explorer/src/Pos/Explorer/Txp/Global.hs index 2f9f91f556e..0a26735382c 100644 --- a/explorer/src/Pos/Explorer/Txp/Global.hs +++ b/explorer/src/Pos/Explorer/Txp/Global.hs @@ -10,10 +10,9 @@ import qualified Data.HashMap.Strict as HM import Pos.Chain.Block (ComponentBlock (..), HeaderHash, headerHash, headerSlotL) -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux, TxUndo, TxpConfiguration) import Pos.Core (HasConfiguration, SlotId (..), epochIndexL) import Pos.Core.Chrono (NewestFirst (..)) -import Pos.Core.Txp (TxAux, TxUndo) import Pos.Crypto (ProtocolMagic) import Pos.DB (SomeBatchOp (..)) import Pos.DB.Txp (ProcessBlundsSettings (..), TxpBlund, diff --git a/explorer/src/Pos/Explorer/Txp/Local.hs b/explorer/src/Pos/Explorer/Txp/Local.hs index 30a25d7aeca..1c673156e7b 100644 --- a/explorer/src/Pos/Explorer/Txp/Local.hs +++ b/explorer/src/Pos/Explorer/Txp/Local.hs @@ -12,10 +12,10 @@ import Universum import qualified Data.HashMap.Strict as HM -import Pos.Chain.Txp (ToilVerFailure (..), TxpConfiguration, Utxo) +import Pos.Chain.Txp (ToilVerFailure (..), TxAux (..), TxId, + TxpConfiguration, Utxo) import Pos.Core (EpochIndex, Timestamp) import Pos.Core.JsonLog (CanJsonLog (..)) -import Pos.Core.Txp (TxAux (..), TxId) import Pos.Core.Update (BlockVersionData) import Pos.Crypto (ProtocolMagic) import Pos.DB.Txp.Logic (txNormalizeAbstract, diff --git a/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs b/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs index 827bdb5f300..554585cbafe 100644 --- a/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs +++ b/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs @@ -20,14 +20,13 @@ import Formatting (build, sformat, (%)) import System.Wlog (logError) import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Txp (ToilVerFailure (..), TxpConfiguration, - extendGlobalToilM, extendLocalToilM, topsortTxs) +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.Core (Address, Coin, EpochIndex, HasConfiguration, Timestamp, mkCoin, sumCoins, unsafeAddCoin, unsafeSubCoin) import Pos.Core.Chrono (NewestFirst (..)) -import Pos.Core.Txp (Tx (..), TxAux (..), TxId, TxOut (..), - TxOutAux (..), TxUndo, _TxOut) import Pos.Core.Update (BlockVersionData) import Pos.Crypto (ProtocolMagic, WithHash (..), hash) import Pos.Explorer.Core (AddrHistory, TxExtra (..)) diff --git a/explorer/src/Pos/Explorer/Txp/Toil/Monad.hs b/explorer/src/Pos/Explorer/Txp/Toil/Monad.hs index 95cdc7dbb1a..e013c481fc7 100644 --- a/explorer/src/Pos/Explorer/Txp/Toil/Monad.hs +++ b/explorer/src/Pos/Explorer/Txp/Toil/Monad.hs @@ -36,9 +36,8 @@ import Control.Monad.State.Strict (mapStateT) import System.Wlog (NamedPureLogger) import Pos.Chain.Txp (ExtendedGlobalToilM, ExtendedLocalToilM, - StakesLookupF) + StakesLookupF, TxId) import Pos.Core (Address, Coin) -import Pos.Core.Txp (TxId) import Pos.Explorer.Core (AddrHistory, TxExtra) import Pos.Explorer.Txp.Toil.Types (ExplorerExtraLookup (..), ExplorerExtraModifier, eemAddrBalances, eemAddrHistories, diff --git a/explorer/src/Pos/Explorer/Txp/Toil/Types.hs b/explorer/src/Pos/Explorer/Txp/Toil/Types.hs index 975bf73985a..ba1e052c9c7 100644 --- a/explorer/src/Pos/Explorer/Txp/Toil/Types.hs +++ b/explorer/src/Pos/Explorer/Txp/Toil/Types.hs @@ -14,8 +14,8 @@ import Universum import Control.Lens (makeLenses) import Data.Default (Default, def) +import Pos.Chain.Txp (TxId) import Pos.Core (Address, Coin) -import Pos.Core.Txp (TxId) import Pos.Explorer.Core (AddrHistory, TxExtra) import qualified Pos.Util.Modifier as MM diff --git a/explorer/src/Pos/Explorer/Web/ClientTypes.hs b/explorer/src/Pos/Explorer/Web/ClientTypes.hs index 679b676d1d9..7818c66abe1 100644 --- a/explorer/src/Pos/Explorer/Web/ClientTypes.hs +++ b/explorer/src/Pos/Explorer/Web/ClientTypes.hs @@ -72,6 +72,8 @@ import Pos.Binary (biSize) import Pos.Chain.Block (MainBlock, Undo (..), gbHeader, gbhConsensus, headerHash, mainBlockSlot, mainBlockTxPayload, mcdSlot, prevBlockL) +import Pos.Chain.Txp (Tx (..), TxId, TxOut (..), TxOutAux (..), + TxUndo, txpTxs, _txOutputs) import Pos.Core (Address, Coin, EpochIndex, LocalSlotIndex, SlotId (..), StakeholderId, Timestamp, addressF, coinToInteger, decodeTextAddress, getEpochIndex, @@ -79,8 +81,6 @@ import Pos.Core (Address, Coin, EpochIndex, LocalSlotIndex, unsafeAddCoin, unsafeGetCoin, unsafeIntegerToCoin, unsafeSubCoin) import Pos.Core.Merkle (getMerkleRoot, mkMerkleTree, mtRoot) -import Pos.Core.Txp (Tx (..), TxId, TxOut (..), TxOutAux (..), TxUndo, - txpTxs, _txOutputs) import Pos.Crypto (AbstractHash, Hash, HashAlgorithm, hash) import qualified Pos.DB.Lrc as LrcDB (getLeader) import qualified Pos.GState as GS diff --git a/explorer/src/Pos/Explorer/Web/Server.hs b/explorer/src/Pos/Explorer/Web/Server.hs index 703a1ad2a65..57615d83941 100644 --- a/explorer/src/Pos/Explorer/Web/Server.hs +++ b/explorer/src/Pos/Explorer/Web/Server.hs @@ -59,15 +59,15 @@ import Pos.Binary.Class (biSize) import Pos.Chain.Block (Block, Blund, HeaderHash, MainBlock, Undo, gbHeader, gbhConsensus, mainBlockSlot, mainBlockTxPayload, mcdSlot) -import Pos.Chain.Txp (TxMap, mpLocalTxs, topsortTxs) +import Pos.Chain.Txp (Tx (..), TxAux, TxId, TxIn (..), TxMap, + TxOutAux (..), mpLocalTxs, taTx, topsortTxs, txOutAddress, + txOutValue, txpTxs, _txOutputs) import Pos.Core (AddrType (..), Address (..), Coin, EpochIndex, Timestamp, coinToInteger, difficultyL, getChainDifficulty, isUnknownAddressType, makeRedeemAddress, siEpoch, siSlot, sumCoins, timestampToPosix, unsafeAddCoin, unsafeIntegerToCoin, unsafeSubCoin) import Pos.Core.Chrono (NewestFirst (..)) -import Pos.Core.Txp (Tx (..), TxAux, TxId, TxIn (..), TxOutAux (..), - taTx, txOutAddress, txOutValue, txpTxs, _txOutputs) import Pos.DB.Txp (MonadTxpMem, getFilteredUtxo, getLocalTxs, getMemPool, withTxpLocalData) import Pos.Infra.Slotting (MonadSlots (..), getSlotStart) diff --git a/explorer/test/Test/Pos/Explorer/Arbitrary.hs b/explorer/test/Test/Pos/Explorer/Arbitrary.hs index 2f15d11cf10..289cf152b21 100644 --- a/explorer/test/Test/Pos/Explorer/Arbitrary.hs +++ b/explorer/test/Test/Pos/Explorer/Arbitrary.hs @@ -10,8 +10,8 @@ import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, import Pos.Explorer.Core (TxExtra (..)) +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Core.Arbitrary () -import Test.Pos.Core.Arbitrary.Txp () instance Arbitrary TxExtra where arbitrary = genericArbitrary diff --git a/explorer/test/Test/Pos/Explorer/MockFactory.hs b/explorer/test/Test/Pos/Explorer/MockFactory.hs index d281f62f5a8..a6b6704646d 100644 --- a/explorer/test/Test/Pos/Explorer/MockFactory.hs +++ b/explorer/test/Test/Pos/Explorer/MockFactory.hs @@ -12,8 +12,8 @@ import Universum import System.Wlog (LoggerName) +import Pos.Chain.Txp (TxOut (..)) import Pos.Core (Address, unsafeIntegerToCoin) -import Pos.Core.Txp (TxOut (..)) -- | Factory to create `TxOut` -- | It is mostly taken from `makeTxOutAux` in `Test.Pos.Client.Txp.UtilSpec` diff --git a/generator/src/Pos/Generator/Block/Payload.hs b/generator/src/Pos/Generator/Block/Payload.hs index 9e9c0677bb5..c4d248812db 100644 --- a/generator/src/Pos/Generator/Block/Payload.hs +++ b/generator/src/Pos/Generator/Block/Payload.hs @@ -23,15 +23,15 @@ import System.Random (RandomGen (..)) import Pos.AllSecrets (asSecretKeys, asSpendingData, unInvAddrSpendingData, unInvSecretsMap) -import Pos.Chain.Txp (TxpConfiguration, Utxo, execUtxoM, utxoToLookup) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxIn (..), TxOut (..), + TxOutAux (..), TxpConfiguration, Utxo, execUtxoM, + utxoToLookup) import qualified Pos.Chain.Txp as Utxo import Pos.Client.Txp.Util (InputSelectionPolicy (..), TxError (..), createGenericTx, makeMPubKeyTxAddrs) import Pos.Core (AddrSpendingData (..), Address (..), Coin, SlotId (..), addressHash, coinToInteger, makePubKeyAddressBoot, unsafeIntegerToCoin) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxOut (..), - TxOutAux (..)) import Pos.Crypto (ProtocolMagic, SecretKey, WithHash (..), fakeSigner, hash, toPublic) import Pos.DB.Txp (MonadTxpLocal (..), getAllPotentiallyHugeUtxo) diff --git a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs index 6480f0c6aa7..317fe3a73f3 100644 --- a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs +++ b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs @@ -20,13 +20,13 @@ import Pos.Binary.Class (biSize) import Pos.Chain.Block (BlockHeader, MainBlock) import Pos.Chain.Delegation (DlgPayload, ProxySKBlockInfo) import Pos.Chain.Ssc (defaultSscPayload) +import Pos.Chain.Txp (TxAux) import Pos.Chain.Update (HasUpdateConfiguration) import qualified Pos.Communication () import Pos.Core (HasConfiguration, SlotId (..), blkSecurityParam, genesisBlockVersionData, pcEpochSlots, protocolConstants, unsafeMkLocalSlotIndexExplicit) import Pos.Core.Ssc (SscPayload (..), mkVssCertificatesMapLossy) -import Pos.Core.Txp (TxAux) import Pos.Core.Update (BlockVersionData (..), UpdatePayload (..)) import Pos.Crypto (SecretKey) import Pos.DB.Block (RawPayload (..), createMainBlockPure) @@ -35,9 +35,9 @@ import Test.Pos.Chain.Block.Arbitrary () import Test.Pos.Chain.Delegation.Arbitrary (genDlgPayload) import Test.Pos.Chain.Ssc.Arbitrary (commitmentMapEpochGen, vssCertificateEpochGen) +import Test.Pos.Chain.Txp.Arbitrary (GoodTx, goodTxToTxAux) import Test.Pos.Configuration (withDefConfiguration, withDefUpdateConfiguration) -import Test.Pos.Core.Arbitrary.Txp (GoodTx, goodTxToTxAux) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) import Test.Pos.Util.QuickCheck (SmallGenerator (..), makeSmall) diff --git a/generator/test/Test/Pos/Generator/Block/LrcSpec.hs b/generator/test/Test/Pos/Generator/Block/LrcSpec.hs index c8629eeb0a8..cbef3bdd151 100644 --- a/generator/test/Test/Pos/Generator/Block/LrcSpec.hs +++ b/generator/test/Test/Pos/Generator/Block/LrcSpec.hs @@ -24,13 +24,12 @@ import Test.QuickCheck.Monadic (pick, run) import Pos.Binary.Class (serialize') import Pos.Chain.Block (mainBlockTxPayload) import qualified Pos.Chain.Lrc as Lrc -import Pos.Chain.Txp (TxpConfiguration (..)) +import Pos.Chain.Txp (TxAux, TxpConfiguration (..), mkTxPayload) import Pos.Core (Coin, EpochIndex, StakeholderId, addressHash, blkSecurityParam, coinF, epochSlots, genesisData, genesisSecretKeysPoor, genesisSecretKeysRich) import Pos.Core.Genesis (GenesisData (..), GenesisInitializer (..), TestnetBalanceOptions (..)) -import Pos.Core.Txp (TxAux, mkTxPayload) import Pos.Crypto (SecretKey, toPublic) import Pos.DB.Block (ShouldCallBListener (..), applyBlocksUnsafe) import qualified Pos.DB.Block as Lrc diff --git a/infra/src/Pos/Infra/Communication/Types/Relay.hs b/infra/src/Pos/Infra/Communication/Types/Relay.hs index 6bea0c006dc..d5b4b4cb5c6 100644 --- a/infra/src/Pos/Infra/Communication/Types/Relay.hs +++ b/infra/src/Pos/Infra/Communication/Types/Relay.hs @@ -27,9 +27,9 @@ import Node.Message.Class (Message (..)) import Pos.Binary.Class (Bi (..), encodeListLen, enforceSize) import Pos.Chain.Ssc (MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..)) +import Pos.Chain.Txp (TxMsgContents (..)) import Pos.Core (StakeholderId) import Pos.Core.Delegation (ProxySKHeavy) -import Pos.Core.Txp (TxMsgContents (..)) 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 f56082b16cb..93c1126590a 100644 --- a/infra/src/Pos/Infra/Diffusion/Types.hs +++ b/infra/src/Pos/Infra/Diffusion/Types.hs @@ -17,11 +17,11 @@ import System.Metrics.Gauge (Gauge) import Pos.Chain.Block (Block, BlockHeader, HeaderHash, MainBlockHeader) +import Pos.Chain.Txp (TxAux) import Pos.Core.Chrono (OldestFirst (..)) import Pos.Core.Delegation (ProxySKHeavy) import Pos.Core.Ssc (InnerSharesMap, Opening, SignedCommitment, VssCertificate) -import Pos.Core.Txp (TxAux) import Pos.Core.Update (UpId, UpdateProposal, UpdateVote) import Pos.Infra.Communication.Types.Protocol (NodeId) import Pos.Infra.Diffusion.Subscription.Status (SubscriptionStates, diff --git a/infra/test/Test/Pos/Infra/Arbitrary/Communication.hs b/infra/test/Test/Pos/Infra/Arbitrary/Communication.hs index aa1db8e8e09..b4131a5a153 100644 --- a/infra/test/Test/Pos/Infra/Arbitrary/Communication.hs +++ b/infra/test/Test/Pos/Infra/Arbitrary/Communication.hs @@ -12,7 +12,7 @@ import Universum import Test.QuickCheck (Arbitrary (..)) import Test.QuickCheck.Arbitrary.Generic (genericShrink) -import Pos.Core.Txp (TxMsgContents (..)) +import Pos.Chain.Txp (TxMsgContents (..)) import Pos.Infra.Communication.Types.Relay (DataMsg (..)) import Test.Pos.Infra.Arbitrary.Txp () diff --git a/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs b/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs index b2274688a27..367d4ce99fb 100644 --- a/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs +++ b/infra/test/Test/Pos/Infra/Arbitrary/Txp.hs @@ -10,9 +10,9 @@ import Test.QuickCheck (Arbitrary (..)) import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, genericShrink) -import Pos.Core.Txp (TxMsgContents (..)) +import Pos.Chain.Txp (TxMsgContents (..)) -import Test.Pos.Core.Arbitrary.Txp () +import Test.Pos.Chain.Txp.Arbitrary () instance Arbitrary TxMsgContents where arbitrary = genericArbitrary diff --git a/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs b/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs index 584ac72385b..b410cb1ab82 100644 --- a/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs +++ b/lib/bench/Bench/Pos/Criterion/TxSigningBench.hs @@ -12,7 +12,7 @@ import Pos.Chain.Ssc () import Pos.Chain.Txp (TxId, TxSig, TxSigData (..)) import Pos.Crypto (SecretKey, SignTag (SignTx), sign) -import Test.Pos.Core.Arbitrary.Txp.Unsafe () +import Test.Pos.Chain.Txp.Arbitrary.Unsafe () import Test.Pos.Util.QuickCheck.Arbitrary (arbitraryUnsafe) import Bench.Configuration (benchProtocolMagic) diff --git a/lib/src/Pos/Communication/Limits.hs b/lib/src/Pos/Communication/Limits.hs index 6484d030c1a..0ee8cc41301 100644 --- a/lib/src/Pos/Communication/Limits.hs +++ b/lib/src/Pos/Communication/Limits.hs @@ -64,12 +64,12 @@ import Pos.Chain.Block (Block, BlockHeader (..), GenesisBlock, GenesisBlockHeader, MainBlock, MainBlockHeader) import Pos.Chain.Ssc (MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..)) +import Pos.Chain.Txp (TxAux, TxMsgContents (..)) import Pos.Core (BlockCount, EpochIndex, StakeholderId, coinPortionToDouble) import Pos.Core.Delegation (HeavyDlgIndex (..), LightDlgIndices (..)) import Pos.Core.Ssc (Commitment (..), InnerSharesMap, Opening (..), SignedCommitment, VssCertificate) -import Pos.Core.Txp (TxAux, TxMsgContents (..)) import Pos.Core.Update (BlockVersionData (..), UpId, UpdateProposal (..), UpdateVote (..)) import Pos.Crypto (ProxyCert (..), ProxySecretKey (..), diff --git a/lib/src/Pos/Crypto/HDDiscovery.hs b/lib/src/Pos/Crypto/HDDiscovery.hs index 93e83e9bbaa..315e784ff06 100644 --- a/lib/src/Pos/Crypto/HDDiscovery.hs +++ b/lib/src/Pos/Crypto/HDDiscovery.hs @@ -12,9 +12,9 @@ import Data.Conduit (mapOutput, runConduitRes, (.|)) import qualified Data.Conduit.List as CL import UnliftIO (MonadUnliftIO) +import Pos.Chain.Txp (toaOut, txOutAddress) import Pos.Core (AddrAttributes (..), Address (..), addrAttributesUnwrapped) -import Pos.Core.Txp (toaOut, txOutAddress) import Pos.Crypto.HD (HDAddressPayload, HDPassphrase, unpackHDAddressAttr) import Pos.DB.Class (DBTag (GStateDB), MonadDBRead, dbIterSource) diff --git a/lib/src/Pos/Diffusion/Full.hs b/lib/src/Pos/Diffusion/Full.hs index fe3b1f5aea5..d4662b6e1f0 100644 --- a/lib/src/Pos/Diffusion/Full.hs +++ b/lib/src/Pos/Diffusion/Full.hs @@ -36,6 +36,7 @@ import Pos.Chain.Block (Block, BlockHeader, HeaderHash, MainBlockHeader) import Pos.Chain.Ssc (MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..)) +import Pos.Chain.Txp (TxAux) import Pos.Communication (EnqueueMsg, HandlerSpecs, InSpecs (..), InvOrDataTK, Listener, MkListeners (..), Msg, MsgSubscribe, MsgSubscribe1, NodeId, OutSpecs (..), @@ -48,7 +49,6 @@ import Pos.Core.Delegation (ProxySKHeavy) import Pos.Core.Metrics.Constants (withCardanoNamespace) import Pos.Core.Ssc (InnerSharesMap, Opening, SignedCommitment, VssCertificate) -import Pos.Core.Txp (TxAux) import Pos.Core.Update (BlockVersion, BlockVersionData (..), UpId, UpdateProposal, UpdateVote) import Pos.Crypto.Configuration (ProtocolMagic (..)) diff --git a/lib/src/Pos/Diffusion/Full/Txp.hs b/lib/src/Pos/Diffusion/Full/Txp.hs index a6288c096a3..8ceb2bb5799 100644 --- a/lib/src/Pos/Diffusion/Full/Txp.hs +++ b/lib/src/Pos/Diffusion/Full/Txp.hs @@ -12,8 +12,8 @@ import qualified Network.Broadcast.OutboundQueue as OQ import Universum import Pos.Binary.Communication () +import Pos.Chain.Txp (TxAux (..), TxId, TxMsgContents (..)) import Pos.Communication.Limits (mlTxMsgContents) -import Pos.Core.Txp (TxAux (..), TxId, TxMsgContents (..)) import Pos.Crypto (hash) import Pos.Infra.Communication.Protocol (EnqueueMsg, MkListeners, MsgType (..), NodeId, Origin (..), OutSpecs) diff --git a/lib/src/Pos/Listener/Txp.hs b/lib/src/Pos/Listener/Txp.hs index c7ead9e941f..b6f98900d0a 100644 --- a/lib/src/Pos/Listener/Txp.hs +++ b/lib/src/Pos/Listener/Txp.hs @@ -18,8 +18,8 @@ import Node.Message.Class (Message) import System.Wlog (WithLogger, logInfo) import Universum -import Pos.Chain.Txp (TxpConfiguration) -import Pos.Core.Txp (TxAux (..), TxId, TxMsgContents (..)) +import Pos.Chain.Txp (TxAux (..), TxId, TxMsgContents (..), + TxpConfiguration) import Pos.Crypto (ProtocolMagic, hash) import Pos.DB.Txp.MemState (MempoolExt, MonadTxpLocal, MonadTxpMem, txpProcessTx) diff --git a/lib/src/Pos/Logic/Full.hs b/lib/src/Pos/Logic/Full.hs index 33e074fb0d2..8a041fc6cbd 100644 --- a/lib/src/Pos/Logic/Full.hs +++ b/lib/src/Pos/Logic/Full.hs @@ -22,13 +22,13 @@ import Pos.Chain.Ssc (MCCommitment (..), MCOpening (..), MCShares (..), MCVssCertificate (..), SscTag (..), TossModifier, ldModifier, sscRunLocalQuery, tmCertificates, tmCommitments, tmOpenings, tmShares) -import Pos.Chain.Txp (MemPool (..), TxpConfiguration) +import Pos.Chain.Txp (MemPool (..), TxAux (..), TxMsgContents (..), + TxpConfiguration) import Pos.Communication (NodeId) import Pos.Core (HasConfiguration, StakeholderId, addressHash) import Pos.Core.Chrono (NE, NewestFirst, OldestFirst) import Pos.Core.Delegation (ProxySKHeavy) import Pos.Core.Ssc (getCertId, getCommitmentsMap, lookupVss) -import Pos.Core.Txp (TxAux (..), TxMsgContents (..)) import Pos.Core.Update (BlockVersionData, UpdateProposal (..), UpdateVote (..)) import Pos.Crypto (ProtocolMagic, hash) diff --git a/lib/src/Pos/Logic/Pure.hs b/lib/src/Pos/Logic/Pure.hs index ca0419701b4..a037a3f8c59 100644 --- a/lib/src/Pos/Logic/Pure.hs +++ b/lib/src/Pos/Logic/Pure.hs @@ -19,7 +19,7 @@ import Pos.Chain.Block (Block, BlockHeader (..), MainBlockHeader, MainBlockchain, MainBody (..), MainConsensusData (..), MainExtraBodyData (..), MainExtraHeaderData (..), MainProof (..)) -import Pos.Chain.Txp (emptyTxPayload) +import Pos.Chain.Txp (TxProof (..), emptyTxPayload) import Pos.Core (StakeholderId, TxFeePolicy (..), unsafeCoinPortionFromDouble) import Pos.Core.Attributes (Attributes (..), UnparsedFields (..)) @@ -31,7 +31,6 @@ import Pos.Core.Slotting (EpochIndex (..), LocalSlotIndex (..), SlotId (..)) import Pos.Core.Ssc (SscPayload (..), SscProof (..), VssCertificatesMap (..)) -import Pos.Core.Txp (TxProof (..)) import Pos.Core.Update (ApplicationName (..), BlockVersion (..), BlockVersionData (..), SoftforkRule (..), SoftwareVersion (..), UpdatePayload (..), UpdateProof) diff --git a/lib/src/Pos/Logic/Types.hs b/lib/src/Pos/Logic/Types.hs index 3d05dbb2cf4..0cbfdc750f9 100644 --- a/lib/src/Pos/Logic/Types.hs +++ b/lib/src/Pos/Logic/Types.hs @@ -20,11 +20,11 @@ import Pos.Chain.Block (Block, BlockHeader, HeaderHash) import Pos.Chain.Security (SecurityParams (..)) import Pos.Chain.Ssc (MCCommitment, MCOpening, MCShares, MCVssCertificate) +import Pos.Chain.Txp (TxId, TxMsgContents) import Pos.Communication (NodeId) import Pos.Core (StakeholderId) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) import Pos.Core.Delegation (ProxySKHeavy) -import Pos.Core.Txp (TxId, TxMsgContents) import Pos.Core.Update (BlockVersionData, UpId, UpdateProposal, UpdateVote, VoteId) import Pos.DB.Block (GetHashesRangeError, GetHeadersFromManyToError) diff --git a/lib/src/Pos/Web/Api.hs b/lib/src/Pos/Web/Api.hs index 58c78842d0b..5f516609e49 100644 --- a/lib/src/Pos/Web/Api.hs +++ b/lib/src/Pos/Web/Api.hs @@ -17,8 +17,8 @@ import Servant.API ((:<|>), (:>), Capture, Get, JSON, PlainText, Post, QueryParam) import Pos.Chain.Block (HeaderHash) +import Pos.Chain.Txp (TxOut) import Pos.Core (EpochIndex, SlotLeaders) -import Pos.Core.Txp (TxOut) import Pos.Crypto (PublicKey) import Pos.Web.Types (CConfirmedProposalState) diff --git a/lib/test/Test/Pos/Cbor/CborSpec.hs b/lib/test/Test/Pos/Cbor/CborSpec.hs index 76c886aaf4b..1b912ff5af7 100644 --- a/lib/test/Test/Pos/Cbor/CborSpec.hs +++ b/lib/test/Test/Pos/Cbor/CborSpec.hs @@ -24,6 +24,7 @@ import Test.QuickCheck (Arbitrary (..)) import Pos.Binary.Communication () import Pos.Chain.Delegation (DlgPayload, DlgUndo) import qualified Pos.Chain.Ssc as Ssc +import Pos.Chain.Txp (TxMsgContents (..)) import qualified Pos.Chain.Txp as T import qualified Pos.Chain.Update as U import qualified Pos.Communication as C @@ -33,7 +34,6 @@ import Pos.Core (StakeholderId) import Pos.Core.Delegation (ProxySKHeavy) import Pos.Core.Ssc (VssCertificate) import qualified Pos.Core.Ssc as Ssc -import Pos.Core.Txp (TxMsgContents (..)) import Pos.Crypto.Signing (EncryptedSecretKey) import Pos.Infra.Communication.Limits.Instances (mlDataMsg, mlInvMsg, mlMempoolMsg, mlReqMsg) diff --git a/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs b/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs index d62a489efe3..5939ffb6ada 100644 --- a/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs +++ b/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs @@ -8,13 +8,13 @@ import Universum import Test.Hspec (Spec, describe) +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core import qualified Pos.Core.Ssc as Ssc -import qualified Pos.Core.Txp as Txp import Test.Pos.Binary.Helpers (safeCopyTest) +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Configuration (withDefConfiguration) -import Test.Pos.Core.Arbitrary.Txp () import Test.Pos.Infra.Arbitrary.Txp () spec :: Spec diff --git a/networking/src/Node/Message/Class.hs b/networking/src/Node/Message/Class.hs index 092f2d11d8c..01e5cdb48be 100644 --- a/networking/src/Node/Message/Class.hs +++ b/networking/src/Node/Message/Class.hs @@ -35,7 +35,7 @@ import qualified Formatting as F import Node.Message.Decoder (Decoder, hoistDecoder) import Pos.Chain.Ssc (MCCommitment, MCOpening, MCShares, MCVssCertificate) -import Pos.Core.Txp (TxMsgContents) +import Pos.Chain.Txp (TxMsgContents) import Pos.Core.Update (UpdateProposal, UpdateVote) -- * Message name diff --git a/pkgs/default.nix b/pkgs/default.nix index 905610e34e6..8caa921983a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -15335,6 +15335,7 @@ license = stdenv.lib.licenses.mit; , aeson-options , array , base +, base16-bytestring , bytestring , Cabal , cardano-crypto @@ -15453,6 +15454,7 @@ cpphs ]; testHaskellDepends = [ base +base16-bytestring bytestring cardano-crypto cardano-sl-binary @@ -15464,6 +15466,7 @@ cardano-sl-crypto-test cardano-sl-util cardano-sl-util-test containers +data-default fmt formatting generic-arbitrary @@ -15488,6 +15491,7 @@ cardano-sl-crypto cardano-sl-crypto-test cardano-sl-util-test criterion +data-default deepseq formatting generic-arbitrary @@ -15496,6 +15500,7 @@ random text universum unordered-containers +vector ]; doHaddock = false; description = "Cardano SL - transaction processing"; @@ -15506,6 +15511,7 @@ license = stdenv.lib.licenses.mit; ({ mkDerivation , base +, base16-bytestring , bytestring , cardano-crypto , cardano-sl-binary @@ -15517,6 +15523,7 @@ license = stdenv.lib.licenses.mit; , cardano-sl-crypto-test , cardano-sl-util-test , containers +, data-default , formatting , generic-arbitrary , hedgehog @@ -15526,6 +15533,7 @@ license = stdenv.lib.licenses.mit; , stdenv , universum , unordered-containers +, vector }: mkDerivation { @@ -15539,6 +15547,7 @@ configureFlags = [ ]; libraryHaskellDepends = [ base +base16-bytestring bytestring cardano-crypto cardano-sl-binary @@ -15550,6 +15559,7 @@ cardano-sl-crypto cardano-sl-crypto-test cardano-sl-util-test containers +data-default formatting generic-arbitrary hedgehog @@ -15558,6 +15568,7 @@ random reflection universum unordered-containers +vector ]; doHaddock = false; description = "Cardano SL - arbitrary instances for cardano-sl-chain"; @@ -16445,6 +16456,7 @@ cpphs benchmarkHaskellDepends = [ base cardano-sl +cardano-sl-chain-test cardano-sl-core-test criterion QuickCheck @@ -17153,6 +17165,7 @@ license = stdenv.lib.licenses.mit; , cardano-sl-binary , cardano-sl-binary-test , cardano-sl-chain +, cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -17230,6 +17243,7 @@ base bytestring cardano-sl cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -17274,6 +17288,7 @@ cardano-report-server cardano-sl cardano-sl-binary cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -17567,6 +17582,7 @@ license = stdenv.lib.licenses.mit; , cardano-crypto , cardano-sl , cardano-sl-chain +, cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -17714,6 +17730,7 @@ bytestring cardano-crypto cardano-sl cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -17771,6 +17788,7 @@ license = stdenv.lib.licenses.mit; , cardano-sl-binary , cardano-sl-binary-test , cardano-sl-chain +, cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -17884,6 +17902,7 @@ cardano-crypto cardano-sl cardano-sl-binary cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -18001,6 +18020,7 @@ cardano-sl cardano-sl-binary cardano-sl-binary-test cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test diff --git a/tools/cardano-sl-tools.cabal b/tools/cardano-sl-tools.cabal index 8223b3ef2a7..1f084cb2386 100644 --- a/tools/cardano-sl-tools.cabal +++ b/tools/cardano-sl-tools.cabal @@ -36,6 +36,7 @@ executable dbgen build-depends: base >= 4.7 && < 5 , acid-state-exts , cardano-sl + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -554,6 +555,7 @@ library , ansi-terminal , bytestring , cardano-sl + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test diff --git a/tools/src/Pos/Tools/Dbgen/Lib.hs b/tools/src/Pos/Tools/Dbgen/Lib.hs index adcaba048ff..84628a1c96d 100644 --- a/tools/src/Pos/Tools/Dbgen/Lib.hs +++ b/tools/src/Pos/Tools/Dbgen/Lib.hs @@ -56,7 +56,7 @@ import Pos.Tools.Dbgen.CLI (CLI (..)) import Pos.Tools.Dbgen.Rendering (green, renderAccountId, say) import Pos.Tools.Dbgen.Types (UberMonad) -import Test.Pos.Core.Arbitrary.Txp () +import Test.Pos.Chain.Txp.Arbitrary () -- -- Types diff --git a/tools/src/blockchain-analyser/Rendering.hs b/tools/src/blockchain-analyser/Rendering.hs index ad27408a2c2..34a4dc606b5 100644 --- a/tools/src/blockchain-analyser/Rendering.hs +++ b/tools/src/blockchain-analyser/Rendering.hs @@ -14,9 +14,9 @@ import Pos.Binary.Class (biSize) import Pos.Chain.Block (Block, BlockHeader (..), Undo, blockHeaderHash, getBlockHeader, mbTxs, _gbBody, _gbhConsensus, _mcdLeaderKey) +import Pos.Chain.Txp (Tx) import Pos.Core (EpochIndex, EpochOrSlot (..), LocalSlotIndex (..), SlotId (..), getEpochIndex, getEpochOrSlot) -import Pos.Core.Txp (Tx) import Pos.Crypto (PublicKey) import Serokell.Data.Memory.Units (Byte, fromBytes, memory, toBytes) import Text.Tabl (Alignment (..), Decoration (..), diff --git a/wallet-new/cardano-sl-wallet-new.cabal b/wallet-new/cardano-sl-wallet-new.cabal index 40172459a1c..d5695d9fc3d 100755 --- a/wallet-new/cardano-sl-wallet-new.cabal +++ b/wallet-new/cardano-sl-wallet-new.cabal @@ -155,6 +155,7 @@ library , cardano-sl , cardano-sl-binary , cardano-sl-chain + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -476,6 +477,7 @@ test-suite wallet-unit-tests , cardano-sl , cardano-sl-binary , cardano-sl-chain + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test diff --git a/wallet-new/src/Cardano/Wallet/API/Indices.hs b/wallet-new/src/Cardano/Wallet/API/Indices.hs index f3a0cd0ba43..60669427e5d 100644 --- a/wallet-new/src/Cardano/Wallet/API/Indices.hs +++ b/wallet-new/src/Cardano/Wallet/API/Indices.hs @@ -14,8 +14,8 @@ import Universum import Cardano.Wallet.API.V1.Types import qualified Data.Text as T import GHC.TypeLits +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp import Pos.Crypto (decodeHash) import Data.IxSet.Typed (Indexable (..), IsIndexOf, IxSet, ixFun, diff --git a/wallet-new/src/Cardano/Wallet/API/V1/Handlers/Transactions.hs b/wallet-new/src/Cardano/Wallet/API/V1/Handlers/Transactions.hs index 97feb1f3662..5a7204fcc4b 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Handlers/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Handlers/Transactions.hs @@ -14,10 +14,10 @@ import Servant import Data.Coerce (coerce) +import Pos.Chain.Txp (Tx (..), TxOut (..)) import Pos.Client.Txp.Util (InputSelectionPolicy (..), defaultInputSelectionPolicy) import Pos.Core (Address) -import Pos.Core.Txp (Tx (..), TxOut (..)) import Pos.Crypto (hash) import Cardano.Wallet.API.Request diff --git a/wallet-new/src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs b/wallet-new/src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs index 1192e974ed7..71ba9417f42 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs @@ -6,11 +6,10 @@ import qualified Data.IxSet.Typed as IxSet import qualified Data.List.NonEmpty as NE import Servant -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux, TxpConfiguration) import Pos.Client.Txp.Util (defaultInputSelectionPolicy) import qualified Pos.Client.Txp.Util as V0 import qualified Pos.Core as Core -import Pos.Core.Txp (TxAux) import Pos.Crypto (ProtocolMagic) import qualified Pos.Util.Servant as V0 import qualified Pos.Wallet.WalletMode as V0 diff --git a/wallet-new/src/Cardano/Wallet/API/V1/Migration/Types.hs b/wallet-new/src/Cardano/Wallet/API/V1/Migration/Types.hs index ea7dd2c0efc..a22e3ed6ea4 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Migration/Types.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Migration/Types.hs @@ -22,11 +22,11 @@ import Cardano.Wallet.API.V1.Errors as Errors import Cardano.Wallet.API.V1.Types (V1 (..)) import qualified Cardano.Wallet.API.V1.Types as V1 import qualified Pos.Chain.Txp as V0 +import qualified Pos.Chain.Txp as Txp import qualified Pos.Client.Txp.Util as V0 import Pos.Core (addressF) import qualified Pos.Core.Common as Core import qualified Pos.Core.Slotting as Core -import qualified Pos.Core.Txp as Txp import Pos.Crypto (decodeHash) import Pos.Util.Mnemonic (Mnemonic) import qualified Pos.Util.Servant as V0 diff --git a/wallet-new/src/Cardano/Wallet/API/V1/Transactions.hs b/wallet-new/src/Cardano/Wallet/API/V1/Transactions.hs index 8cbb54186fd..9cf8fcb6cd4 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Transactions.hs @@ -5,8 +5,8 @@ import Cardano.Wallet.API.Response import Cardano.Wallet.API.Types import Cardano.Wallet.API.V1.Parameters import Cardano.Wallet.API.V1.Types +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp import Servant diff --git a/wallet-new/src/Cardano/Wallet/API/V1/Types.hs b/wallet-new/src/Cardano/Wallet/API/V1/Types.hs index c9ba2f60410..6ab020cea35 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Types.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Types.hs @@ -139,10 +139,10 @@ import Cardano.Wallet.Util (showApiUtcTime) import qualified Data.ByteArray as ByteArray import qualified Data.ByteString as BS import qualified Data.Map.Strict as Map +import qualified Pos.Chain.Txp as Txp import qualified Pos.Client.Txp.Util as Core import Pos.Core (addressF) import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp import qualified Pos.Core.Update as Core import Pos.Crypto (decodeHash, hashHexF) import qualified Pos.Crypto.Signing as Core diff --git a/wallet-new/src/Cardano/Wallet/Kernel.hs b/wallet-new/src/Cardano/Wallet/Kernel.hs index 6ae668dab57..f16dcee0878 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel.hs @@ -27,8 +27,8 @@ import Data.Acid.Memory (openMemoryState) import qualified Data.Map.Strict as Map import System.Wlog (Severity (..)) +import Pos.Chain.Txp (TxAux (..)) import Pos.Core (ProtocolMagic) -import Pos.Core.Txp (TxAux (..)) import Cardano.Wallet.Kernel.DB.AcidState (DB, defDB) import Cardano.Wallet.Kernel.DB.TxMeta diff --git a/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs b/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs index f2910c52f84..8200701adbd 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs @@ -36,13 +36,13 @@ import Data.Typeable (TypeRep, typeRep) import Pos.Binary.Class (LengthOf, Range (..), SizeOverride (..), encode, szSimplify, szWithCtx, toLazyByteString) +import Pos.Chain.Txp (TxAux, TxIn, TxInWitness, TxOut, TxSigData) import qualified Pos.Chain.Txp as Core import qualified Pos.Client.Txp.Util as Core import Pos.Core (AddrAttributes, Coin (..), TxSizeLinear, calculateTxSizeLinear) import qualified Pos.Core as Core import Pos.Core.Attributes (Attributes) -import Pos.Core.Txp (TxAux, TxIn, TxInWitness, TxOut, TxSigData) import Pos.Crypto (Signature) import qualified Pos.Crypto as Core import Serokell.Data.Memory.Units (Byte, toBytes) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs index cc8993354b9..f748e9051c9 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs @@ -47,10 +47,10 @@ import Formatting (bprint, build, (%)) import qualified Formatting.Buildable import Test.QuickCheck (Arbitrary (..), oneof) -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (TxAux, TxId, Utxo) +import qualified Pos.Chain.Txp as Txp import Pos.Core (SlotId) import Pos.Core.Chrono (OldestFirst (..)) -import Pos.Core.Txp (TxAux, TxId) import Cardano.Wallet.Kernel.DB.HdWallet import qualified Cardano.Wallet.Kernel.DB.HdWallet.Create as HD diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs index 5ea830f43de..5de4b5ffc77 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs @@ -30,8 +30,8 @@ import Formatting (bprint, build, (%)) import qualified Formatting.Buildable import Serokell.Util (mapJson) +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp import Cardano.Wallet.Kernel.DB.InDb diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/Spec/Update.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/Spec/Update.hs index 1888a96fa84..aee9b15d24b 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/Spec/Update.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/Spec/Update.hs @@ -29,10 +29,10 @@ import Serokell.Util (listJsonIndent) import Test.QuickCheck (Arbitrary (..)) import Pos.Chain.Txp (Utxo) +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core import Pos.Core.Chrono (NewestFirst (..), OldestFirst (..)) import Pos.Core.Slotting (SlotId) -import qualified Pos.Core.Txp as Txp import Cardano.Wallet.Kernel.DB.BlockMeta import Cardano.Wallet.Kernel.DB.InDb diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs index 01f0d195a55..e3e62bd962c 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs @@ -70,8 +70,8 @@ import Cardano.Wallet.Kernel.DB.TxMeta.Types (AccountFops (..), import qualified Cardano.Wallet.Kernel.DB.TxMeta.Types as Kernel -- execution time should move out of WalletLayer so that we don`t depend on it. import Cardano.Wallet.WalletLayer.ExecutionTimeLimit +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp import Pos.Crypto.Hashing (decodeAbstractHash, hashHexF) {-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-} @@ -615,9 +615,8 @@ getTxMetas conn (Offset offset) (Limit limit) accountFops mbAddress fopTxId fopT pure $ _outputTableTxId out -- union removes txId duplicates. txid <- SQL.union_ input output - meta <- SQL.join_ (_mDbMeta metaDB) - (\ mt -> ((TxIdPrimKey $ _txMetaTableId mt) ==. txid)) - pure meta + SQL.join_ (_mDbMeta metaDB) + (\ mt -> ((TxIdPrimKey $ _txMetaTableId mt) ==. txid)) metaQueryWithAddr addr = do meta <- case mbSorting of diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs index 971182ea445..0c93a7cd1f2 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs @@ -57,8 +57,8 @@ import Serokell.Util.Text (listBuilderJSON, listJsonIndent, mapBuilder) import Test.QuickCheck (Arbitrary (..), Gen, suchThat) +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp import Test.Pos.Core.Arbitrary () diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Diffusion.hs b/wallet-new/src/Cardano/Wallet/Kernel/Diffusion.hs index 996fe65177e..95e3d62c5f2 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Diffusion.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Diffusion.hs @@ -6,8 +6,8 @@ module Cardano.Wallet.Kernel.Diffusion ( import Universum +import Pos.Chain.Txp (TxAux) import Pos.Core () -import Pos.Core.Txp (TxAux) import Pos.Infra.Diffusion.Types -- | Wallet diffusion layer diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs b/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs index 65685115eb1..478aeed96ed 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs @@ -14,7 +14,7 @@ import Control.Concurrent.MVar (modifyMVar_) import Data.Acid.Advanced (update') -import Pos.Core.Txp (Tx (..), TxAux (..), TxOut (..)) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxOut (..)) import Pos.Crypto (EncryptedSecretKey) import Cardano.Wallet.Kernel.DB.AcidState (CancelPending (..), diff --git a/wallet-new/src/Cardano/Wallet/Kernel/PrefilterTx.hs b/wallet-new/src/Cardano/Wallet/Kernel/PrefilterTx.hs index 4dd1aef4660..2f1de5e4dec 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/PrefilterTx.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/PrefilterTx.hs @@ -24,9 +24,9 @@ import Serokell.Util (listJson, mapJson) import Data.SafeCopy (base, deriveSafeCopy) -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (TxId, TxIn (..), TxOut (..), TxOutAux (..), + Utxo) import Pos.Core (Address (..), SlotId) -import Pos.Core.Txp (TxId, TxIn (..), TxOut (..), TxOutAux (..)) import Pos.Crypto (EncryptedSecretKey) import Pos.Wallet.Web.State.Storage (WAddressMeta (..)) import Pos.Wallet.Web.Tracking.Decrypt (WalletDecrCredentials, diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs b/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs index 29fe44b9d7c..bcd34e3dfa3 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs @@ -71,7 +71,7 @@ import Test.QuickCheck import Cardano.Wallet.Kernel.DB.HdWallet (HdAccountId) import Cardano.Wallet.Kernel.DB.Spec.Pending (Pending) import qualified Cardano.Wallet.Kernel.DB.Spec.Pending as Pending -import qualified Pos.Core.Txp as Txp +import qualified Pos.Chain.Txp as Txp -- | Wallet Submission Layer -- diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Transactions.hs b/wallet-new/src/Cardano/Wallet/Kernel/Transactions.hs index 256834396ba..09048eb1e43 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Transactions.hs @@ -29,11 +29,10 @@ import Test.QuickCheck (Arbitrary (..)) import Formatting (bprint, build, sformat, (%)) import qualified Formatting.Buildable -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxId, TxIn (..), + TxOut (..), TxOutAux (..), Utxo) import Pos.Core (Address, Coin, unsafeSubCoin) import qualified Pos.Core as Core -import Pos.Core.Txp (Tx (..), TxAux (..), TxId, TxIn (..), TxOut (..), - TxOutAux (..)) import Pos.Crypto (EncryptedSecretKey, PassPhrase, SafeSigner (..), ShouldCheckPassphrase (..), hash) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Types.hs b/wallet-new/src/Cardano/Wallet/Kernel/Types.hs index 27c862692e1..4608b50110f 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Types.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Types.hs @@ -25,7 +25,7 @@ import Formatting.Buildable (Buildable (..)) import Pos.Chain.Block (MainBlock, gbBody, mainBlockSlot, mbTxs, mbWitnesses) -import Pos.Core.Txp (Tx, TxAux (..), TxIn (..), txInputs) +import Pos.Chain.Txp (Tx, TxAux (..), TxIn (..), txInputs) import Formatting (bprint, (%)) import qualified Formatting as F diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer.hs b/wallet-new/src/Cardano/Wallet/WalletLayer.hs index 0d78c5e6b34..3542f76c9b6 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer.hs @@ -52,9 +52,9 @@ import qualified Prelude import Test.QuickCheck (Arbitrary (..), oneof) import Pos.Chain.Block (Blund) +import Pos.Chain.Txp (Tx) import Pos.Core (Coin) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) -import Pos.Core.Txp (Tx) import Pos.Crypto (PassPhrase) import Cardano.Wallet.API.Request (RequestParams (..)) diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Active.hs b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Active.hs index f7d51213af5..cf672ec578c 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Active.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Active.hs @@ -8,8 +8,8 @@ import Universum import Data.Time.Units (Second) +import Pos.Chain.Txp (Tx) import Pos.Core (Address, Coin) -import Pos.Core.Txp (Tx) import Pos.Crypto (PassPhrase) import Cardano.Wallet.API.V1.Types (unV1) diff --git a/wallet-new/test/unit/Test/Spec/NewPayment.hs b/wallet-new/test/unit/Test/Spec/NewPayment.hs index eb5c504c3d6..7d9dfd9238b 100644 --- a/wallet-new/test/unit/Test/Spec/NewPayment.hs +++ b/wallet-new/test/unit/Test/Spec/NewPayment.hs @@ -22,9 +22,9 @@ import qualified Data.Map.Strict as M import Data.Acid (update) import Formatting (build, formatToString, sformat) +import Pos.Chain.Txp (TxOut (..), TxOutAux (..)) import Pos.Core (Address, Coin (..), IsBootstrapEraAddr (..), deriveLvl2KeyPair, mkCoin) -import Pos.Core.Txp (TxOut (..), TxOutAux (..)) import Pos.Crypto (EncryptedSecretKey, ShouldCheckPassphrase (..), safeDeterministicKeyGen) diff --git a/wallet-new/test/unit/Test/Spec/Submission.hs b/wallet-new/test/unit/Test/Spec/Submission.hs index 26161882429..00e2e46f0a4 100644 --- a/wallet-new/test/unit/Test/Spec/Submission.hs +++ b/wallet-new/test/unit/Test/Spec/Submission.hs @@ -25,13 +25,13 @@ import qualified Data.Vector as V import Formatting (bprint, (%)) import qualified Formatting as F import Formatting.Buildable (build) +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core import Pos.Core.Attributes (Attributes (..), UnparsedFields (..)) -import qualified Pos.Core.Txp as Txp import Pos.Crypto.Hashing (hash) import Pos.Crypto.Signing.Safe (safeDeterministicKeyGen) import Serokell.Util.Text (listJsonIndent) -import qualified Test.Pos.Core.Arbitrary.Txp as Txp +import qualified Test.Pos.Chain.Txp.Arbitrary as Txp import Cardano.Wallet.Kernel.Util (disjoint) import Test.QuickCheck (Gen, Property, arbitrary, choose, conjoin, @@ -51,8 +51,7 @@ genPending :: Core.ProtocolMagic -> Gen Pending genPending pMagic = do elems <- listOf (do tx <- Txp.genTx wit <- (V.fromList <$> listOf (Txp.genTxInWitness pMagic)) - aux <- Txp.TxAux <$> pure tx <*> pure wit - pure aux + Txp.TxAux <$> pure tx <*> pure wit ) return $ Pending.fromTransactions elems diff --git a/wallet-new/test/unit/TxMetaStorageSpecs.hs b/wallet-new/test/unit/TxMetaStorageSpecs.hs index 0bd29be67c7..2325c683ca7 100644 --- a/wallet-new/test/unit/TxMetaStorageSpecs.hs +++ b/wallet-new/test/unit/TxMetaStorageSpecs.hs @@ -18,8 +18,8 @@ import qualified Data.Set as Set import Formatting.Buildable (build) import qualified Prelude +import Pos.Chain.Txp (TxId) import qualified Pos.Core as Core -import Pos.Core.Txp (TxId) import Formatting (bprint) import Serokell.Util.Text (listJsonIndent, pairF) diff --git a/wallet-new/test/unit/UTxO/Crypto.hs b/wallet-new/test/unit/UTxO/Crypto.hs index f991e00ff90..470e43bd904 100644 --- a/wallet-new/test/unit/UTxO/Crypto.hs +++ b/wallet-new/test/unit/UTxO/Crypto.hs @@ -20,9 +20,9 @@ import Formatting (bprint, build, (%)) import qualified Formatting.Buildable import Universum +import Pos.Chain.Txp (TxIn) import Pos.Core import Pos.Core.Delegation (ProxySKHeavy) -import Pos.Core.Txp (TxIn) import Pos.Crypto {------------------------------------------------------------------------------- diff --git a/wallet-new/test/unit/UTxO/Interpreter.hs b/wallet-new/test/unit/UTxO/Interpreter.hs index 4946389bf6c..e5643c8bd48 100644 --- a/wallet-new/test/unit/UTxO/Interpreter.hs +++ b/wallet-new/test/unit/UTxO/Interpreter.hs @@ -51,7 +51,8 @@ import Pos.Chain.Block (Block, BlockHeader (..), GenesisBlock, MainBlock, gbHeader, genBlockLeaders, mkGenesisBlock) import Pos.Chain.Lrc (followTheSatoshi) import Pos.Chain.Ssc (defaultSscPayload) -import Pos.Chain.Txp (Utxo, txOutStake) +import Pos.Chain.Txp (TxAux (..), TxId, TxIn (..), TxOut (..), + TxOutAux (..), Utxo, txOutStake) import Pos.Chain.Update import Pos.Client.Txp import Pos.Core @@ -60,8 +61,6 @@ import Pos.Core.Delegation (DlgPayload (..)) import Pos.Core.Genesis (GenesisWStakeholders, gdBootStakeholders, gdProtocolConsts, genesisProtocolConstantsToProtocolConstants) -import Pos.Core.Txp (TxAux (..), TxId, TxIn (..), TxOut (..), - TxOutAux (..)) import Pos.Crypto import Pos.DB.Block (RawPayload (..), createMainBlockPure) diff --git a/wallet/cardano-sl-wallet.cabal b/wallet/cardano-sl-wallet.cabal index 8e4c4af08e1..ec41a705b00 100644 --- a/wallet/cardano-sl-wallet.cabal +++ b/wallet/cardano-sl-wallet.cabal @@ -243,6 +243,7 @@ test-suite cardano-wallet-test , cardano-crypto , cardano-sl , cardano-sl-chain + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test diff --git a/wallet/src/Pos/Wallet/Redirect.hs b/wallet/src/Pos/Wallet/Redirect.hs index 5f4fc91aeb4..e27c1229dda 100644 --- a/wallet/src/Pos/Wallet/Redirect.hs +++ b/wallet/src/Pos/Wallet/Redirect.hs @@ -28,12 +28,12 @@ import System.Wlog (WithLogger, logWarning) import Pos.Chain.Block (BlockHeader, LastKnownHeaderTag, MonadLastKnownHeader) -import Pos.Chain.Txp (ToilVerFailure, TxpConfiguration) +import Pos.Chain.Txp (ToilVerFailure, Tx, TxAux (..), TxId, TxUndo, + TxpConfiguration) import Pos.Chain.Update (ConfirmedProposalState) import qualified Pos.Context as PC import Pos.Core (ChainDifficulty, HasConfiguration, Timestamp, difficultyL, getCurrentTimestamp) -import Pos.Core.Txp (Tx, TxAux (..), TxId, TxUndo) import Pos.Crypto (ProtocolMagic, WithHash (..)) import qualified Pos.DB.BlockIndex as DB import Pos.DB.Class (MonadDBRead) diff --git a/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs b/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs index c6eae0722ef..b24005ffa85 100644 --- a/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs +++ b/wallet/src/Pos/Wallet/Web/ClientTypes/Functions.hs @@ -17,13 +17,13 @@ import qualified Data.List.NonEmpty as NE 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.Client.Txp.History (TxHistoryEntry (..)) import Pos.Core (Address, ChainDifficulty, decodeTextAddress, makePubKeyAddressBoot, sumCoins, unsafeAddCoin, unsafeIntegerToCoin) -import Pos.Core.Txp (Tx (..), TxOut (..), txOutAddress, txOutValue) import Pos.Core.Update (BlockVersionData (..), BlockVersionModifier (..), UpdateProposal (..)) import Pos.Crypto (EncryptedSecretKey, encToPublic) diff --git a/wallet/src/Pos/Wallet/Web/ClientTypes/Instances.hs b/wallet/src/Pos/Wallet/Web/ClientTypes/Instances.hs index 9a72f84e207..e5321724f4b 100644 --- a/wallet/src/Pos/Wallet/Web/ClientTypes/Instances.hs +++ b/wallet/src/Pos/Wallet/Web/ClientTypes/Instances.hs @@ -19,9 +19,9 @@ import Servant.API (FromHttpApiData (..), ToHttpApiData (..)) import Servant.Multipart (FromMultipart (..), Mem, lookupFile, lookupInput) +import Pos.Chain.Txp (TxId) import Pos.Core (Address, Coin (..), checkCoin, coinToInteger, decodeTextAddress, mkCoin, unsafeGetCoin) -import Pos.Core.Txp (TxId) import Pos.Crypto (PassPhrase, decodeHash, hashHexF, passphraseLength) import Pos.Util.Servant (FromCType (..), HasTruncateLogPolicy (..), OriginType, ToCType (..), WithTruncatedLog (..)) diff --git a/wallet/src/Pos/Wallet/Web/Methods/History.hs b/wallet/src/Pos/Wallet/Web/Methods/History.hs index c3d98f95dfa..5867389c3c3 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/History.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/History.hs @@ -24,10 +24,10 @@ import Formatting (sformat, stext, (%)) import Serokell.Util (listChunkedJson, listJsonIndent) import System.Wlog (WithLogger, logDebug) +import Pos.Chain.Txp (TxId) import Pos.Client.Txp.History (MonadTxHistory, TxHistoryEntry (..), txHistoryListToMap) import Pos.Core (Address, ChainDifficulty, timestampToPosix) -import Pos.Core.Txp (TxId) import Pos.Infra.Util.LogSafe (logInfoSP, secureListF) import Pos.Util.Servant (encodeCType) import Pos.Util.Util (eitherToThrow) diff --git a/wallet/src/Pos/Wallet/Web/Methods/Payment.hs b/wallet/src/Pos/Wallet/Web/Methods/Payment.hs index 14353ad7be9..49b2cbb38d2 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Payment.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Payment.hs @@ -21,7 +21,8 @@ import Servant.Server (err403, err405, errReasonPhrase) import System.Wlog (logDebug) import UnliftIO (MonadUnliftIO) -import Pos.Chain.Txp (TxFee (..), TxpConfiguration, Utxo) +import Pos.Chain.Txp (TxAux (..), TxFee (..), TxOut (..), + TxpConfiguration, Utxo, _txOutputs) import Pos.Client.KeyStorage (getSecretKeys) import Pos.Client.Txp.Addresses (MonadAddresses) import Pos.Client.Txp.Balances (MonadBalances (..)) @@ -32,7 +33,6 @@ import Pos.Client.Txp.Util (InputSelectionPolicy (..), computeTxFee, import Pos.Configuration (walletTxCreationDisabled) import Pos.Core (Address, Coin, HasConfiguration, getCurrentTimestamp) import Pos.Core.Conc (concurrently, delay) -import Pos.Core.Txp (TxAux (..), TxOut (..), _txOutputs) import Pos.Crypto (PassPhrase, ProtocolMagic, SafeSigner, ShouldCheckPassphrase (..), checkPassMatches, hash, withSafeSignerUnsafe) diff --git a/wallet/src/Pos/Wallet/Web/Methods/Redeem.hs b/wallet/src/Pos/Wallet/Web/Methods/Redeem.hs index 39652f50800..f3270608f47 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Redeem.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Redeem.hs @@ -12,11 +12,10 @@ import Universum import Data.ByteString.Base58 (bitcoinAlphabet, decodeBase58) import qualified Serokell.Util.Base64 as B64 -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux (..), TxOut (..), TxpConfiguration) import Pos.Client.Txp.History (TxHistoryEntry (..)) import Pos.Client.Txp.Network (prepareRedemptionTx) import Pos.Core (getCurrentTimestamp) -import Pos.Core.Txp (TxAux (..), TxOut (..)) import Pos.Crypto (PassPhrase, ProtocolMagic, aesDecrypt, hash, redeemDeterministicKeyGen) import Pos.Util (maybeThrow) diff --git a/wallet/src/Pos/Wallet/Web/Methods/Txp.hs b/wallet/src/Pos/Wallet/Web/Methods/Txp.hs index c0e0a655e52..9fa5ee13986 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Txp.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Txp.hs @@ -18,14 +18,14 @@ import Universum import qualified Data.List.NonEmpty as NE import Formatting (build, sformat, stext, (%)) -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxOut (..), TxOutAux (..), + TxpConfiguration) import Pos.Client.KeyStorage (MonadKeys) import Pos.Client.Txp.Addresses (MonadAddresses (..)) import Pos.Client.Txp.Util (InputSelectionPolicy (..), PendingAddresses (..), isCheckedTxError) import Pos.Core.Chrono (getNewestFirst, toNewestFirst) import Pos.Core.Common (Coin) -import Pos.Core.Txp (Tx (..), TxAux (..), TxOut (..), TxOutAux (..)) import Pos.Crypto (PassPhrase, ProtocolMagic, hash) import Pos.Util.Servant (encodeCType) import Pos.Wallet.Web.ClientTypes (AccountId, Addr, CId) diff --git a/wallet/src/Pos/Wallet/Web/Pending/Functions.hs b/wallet/src/Pos/Wallet/Web/Pending/Functions.hs index 509b0766fa2..06638bd66ff 100644 --- a/wallet/src/Pos/Wallet/Web/Pending/Functions.hs +++ b/wallet/src/Pos/Wallet/Web/Pending/Functions.hs @@ -16,10 +16,9 @@ import Universum import Formatting (build, sformat, (%)) -import Pos.Chain.Txp (ToilVerFailure (..)) +import Pos.Chain.Txp (ToilVerFailure (..), TxAux (..), TxId) import Pos.Client.Txp.History (SaveTxException (..), TxHistoryEntry) import Pos.Core (HasConfiguration, protocolConstants) -import Pos.Core.Txp (TxAux (..), TxId) import Pos.Infra.Slotting.Class (MonadSlots (..)) import Pos.Util.Util (maybeThrow) import Pos.Wallet.Web.ClientTypes (CId, Wal) diff --git a/wallet/src/Pos/Wallet/Web/Pending/Submission.hs b/wallet/src/Pos/Wallet/Web/Pending/Submission.hs index 44a658b9706..2cc47f18508 100644 --- a/wallet/src/Pos/Wallet/Web/Pending/Submission.hs +++ b/wallet/src/Pos/Wallet/Web/Pending/Submission.hs @@ -20,12 +20,11 @@ import Data.Time.Units (fromMicroseconds) import Formatting (build, sformat, shown, stext, (%)) import System.Wlog (WithLogger, logDebug, logInfo) -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux, TxpConfiguration) import Pos.Client.Txp.History (saveTx, thTimestamp) import Pos.Client.Txp.Network (TxMode) import Pos.Configuration (walletTxCreationDisabled) import Pos.Core (diffTimestamp, getCurrentTimestamp) -import Pos.Core.Txp (TxAux) import Pos.Crypto (ProtocolMagic) import Pos.Infra.Util.LogSafe (buildSafe, logInfoSP, logWarningSP, secretOnlyF) diff --git a/wallet/src/Pos/Wallet/Web/Pending/Types.hs b/wallet/src/Pos/Wallet/Web/Pending/Types.hs index 1ce8a4e78b3..245e7627554 100644 --- a/wallet/src/Pos/Wallet/Web/Pending/Types.hs +++ b/wallet/src/Pos/Wallet/Web/Pending/Types.hs @@ -33,10 +33,10 @@ import Data.Text.Lazy.Builder (Builder) import Formatting (bprint, build, (%)) import qualified Formatting.Buildable +import Pos.Chain.Txp (TxAux, TxId) import Pos.Client.Txp.History (TxHistoryEntry) import Pos.Core.Common (ChainDifficulty) import Pos.Core.Slotting (FlatSlotId, SlotId) -import Pos.Core.Txp (TxAux, TxId) import Pos.Infra.Util.LogSafe (LogSecurityLevel, SecureLog, getSecureLog, secure, unsecure) import Pos.Wallet.Web.ClientTypes.Types (CId, Wal) diff --git a/wallet/src/Pos/Wallet/Web/Pending/Worker.hs b/wallet/src/Pos/Wallet/Web/Pending/Worker.hs index cc1437dc5f3..441349aa559 100644 --- a/wallet/src/Pos/Wallet/Web/Pending/Worker.hs +++ b/wallet/src/Pos/Wallet/Web/Pending/Worker.hs @@ -16,7 +16,7 @@ import Formatting (build, sformat, (%)) import Serokell.Util (enumerate, listJson) import System.Wlog (logDebug, logInfo, modifyLoggerName) -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux, TxpConfiguration) import Pos.Client.Txp.Addresses (MonadAddresses) import Pos.Client.Txp.Network (TxMode) import Pos.Configuration (HasNodeConfiguration, @@ -25,7 +25,6 @@ import Pos.Core (ChainDifficulty (..), SlotId (..), difficultyL) import Pos.Core.Chrono (getOldestFirst) import Pos.Core.Conc (delay, forConcurrently) import Pos.Core.Configuration (HasConfiguration) -import Pos.Core.Txp (TxAux) import Pos.Crypto (ProtocolMagic) import qualified Pos.DB.BlockIndex as DB import Pos.DB.Class (MonadDBRead) diff --git a/wallet/src/Pos/Wallet/Web/Server/Handlers.hs b/wallet/src/Pos/Wallet/Web/Server/Handlers.hs index 00137c13052..67331ac40fa 100644 --- a/wallet/src/Pos/Wallet/Web/Server/Handlers.hs +++ b/wallet/src/Pos/Wallet/Web/Server/Handlers.hs @@ -19,9 +19,8 @@ import Servant.Generic (AsServerT, GenericProduct, ToServant, import Servant.Server (Handler, Server, ServerT, hoistServer) import Servant.Swagger.UI (swaggerSchemaUIServer) -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux, TxpConfiguration) import Pos.Chain.Update (curSoftwareVersion) -import Pos.Core.Txp (TxAux) import Pos.Crypto (ProtocolMagic) import Pos.Util.CompileInfo (HasCompileInfo) diff --git a/wallet/src/Pos/Wallet/Web/State/Storage.hs b/wallet/src/Pos/Wallet/Web/State/Storage.hs index 26e4a33cde3..886817b5533 100644 --- a/wallet/src/Pos/Wallet/Web/State/Storage.hs +++ b/wallet/src/Pos/Wallet/Web/State/Storage.hs @@ -123,13 +123,12 @@ import Formatting ((%)) import qualified Formatting as F import qualified Formatting.Buildable import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Txp (AddrCoinMap, Utxo, UtxoModifier, +import Pos.Chain.Txp (AddrCoinMap, TxAux, TxId, Utxo, UtxoModifier, applyUtxoModToAddrCoinMap, utxoToAddressCoinMap) import Pos.Client.Txp.History (TxHistoryEntry, txHistoryListToMap) import Pos.Core (Address, BlockCount (..), ChainDifficulty (..), ProtocolConstants (..), SlotId, Timestamp, VssMaxTTL (..), VssMinTTL (..)) -import Pos.Core.Txp (TxAux, TxId) import qualified Pos.Util.Modifier as MM import qualified Pos.Wallet.Web.ClientTypes as WebTypes import Pos.Wallet.Web.Pending.Types (PendingTx (..), PtxCondition, diff --git a/wallet/src/Pos/Wallet/Web/Tracking/BListener.hs b/wallet/src/Pos/Wallet/Web/Tracking/BListener.hs index f8acef4dd16..0a342a91aa7 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/BListener.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/BListener.hs @@ -22,10 +22,9 @@ import System.Wlog (HasLoggerName (modifyLoggerName), WithLogger) import Pos.Chain.Block (BlockHeader (..), Blund, HeaderHash, blockHeader, getBlockHeader, headerSlotL, mainBlockTxPayload, prevBlockL, undoTx) -import Pos.Chain.Txp (flattenTxPayload) +import Pos.Chain.Txp (TxAux (..), TxUndo, flattenTxPayload) import Pos.Core (Timestamp, difficultyL) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) -import Pos.Core.Txp (TxAux (..), TxUndo) import Pos.DB.BatchOp (SomeBatchOp) import Pos.DB.Block (MonadBListener (..)) import Pos.DB.Class (MonadDBRead) diff --git a/wallet/src/Pos/Wallet/Web/Tracking/Decrypt.hs b/wallet/src/Pos/Wallet/Web/Tracking/Decrypt.hs index 2636b737b25..4364f7dad95 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Decrypt.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Decrypt.hs @@ -19,12 +19,12 @@ import Data.List ((!!)) import qualified Data.List.NonEmpty as NE import Serokell.Util (enumerate) +import Pos.Chain.Txp (Tx (..), TxIn (..), TxOut, TxOutAux (..), + TxUndo, toaOut, txOutAddress) import Pos.Client.Txp.History (TxHistoryEntry (..)) import Pos.Core (Address (..), ChainDifficulty, Timestamp, aaPkDerivationPath, addrAttributesUnwrapped, makeRootPubKeyAddress) -import Pos.Core.Txp (Tx (..), TxIn (..), TxOut, TxOutAux (..), TxUndo, - toaOut, txOutAddress) import Pos.Crypto (EncryptedSecretKey, HDPassphrase, WithHash (..), deriveHDPassphrase, encToPublic, unpackHDAddressAttr) import Pos.Util.Servant (encodeCType) diff --git a/wallet/src/Pos/Wallet/Web/Tracking/Modifier.hs b/wallet/src/Pos/Wallet/Web/Tracking/Modifier.hs index 5f5b702d9e3..ab14cd7d3e7 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Modifier.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Modifier.hs @@ -27,10 +27,9 @@ import Formatting (bprint, build, (%)) import Serokell.Util (listJson, listJsonIndent) import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Txp (UtxoModifier) +import Pos.Chain.Txp (TxId, UtxoModifier) import Pos.Client.Txp.History (TxHistoryEntry (..)) import Pos.Core (Address) -import Pos.Core.Txp (TxId) import Pos.Infra.Util.LogSafe (BuildableSafeGen (..), deriveSafeBuildable, secretOnlyF, secureListF) import Pos.Util.Modifier (MapModifier) diff --git a/wallet/src/Pos/Wallet/Web/Tracking/Restore.hs b/wallet/src/Pos/Wallet/Web/Tracking/Restore.hs index 8f4ee15f3c8..c66bbd080b8 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Restore.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Restore.hs @@ -8,9 +8,9 @@ import qualified Data.Map as M import System.Wlog (WithLogger, logInfo, modifyLoggerName) import Pos.Chain.Block (headerHash) -import Pos.Chain.Txp (genesisUtxo, unGenesisUtxo, utxoToModifier) +import Pos.Chain.Txp (TxIn, TxOut (..), TxOutAux (..), genesisUtxo, + unGenesisUtxo, utxoToModifier) import Pos.Core (Address, HasConfiguration, HasDifficulty (..)) -import Pos.Core.Txp (TxIn, TxOut (..), TxOutAux (..)) import qualified Pos.DB.BlockIndex as DB import Pos.DB.Class (MonadDBRead (..)) import Pos.DB.Txp.Utxo (filterUtxo) diff --git a/wallet/src/Pos/Wallet/Web/Tracking/Sync.hs b/wallet/src/Pos/Wallet/Web/Tracking/Sync.hs index a07f8d0c8e5..3cea386ab3c 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Sync.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Sync.hs @@ -56,15 +56,14 @@ import Formatting (build, float, sformat, shown, (%)) import Pos.Chain.Block (BlockHeader (..), Blund, HeaderHash, MainBlock, getBlockHeader, headerHash, headerSlotL, mainBlockTxPayload, undoTx) -import Pos.Chain.Txp (UndoMap, flattenTxPayload, topsortTxs, - _txOutputs) +import Pos.Chain.Txp (TxAux (..), TxId, TxUndo, UndoMap, + flattenTxPayload, topsortTxs, _txOutputs) import Pos.Client.Txp.History (TxHistoryEntry (..), txHistoryListToMap) import Pos.Core (Address, BlockCount (..), ChainDifficulty (..), HasDifficulty (..), HasProtocolConstants, Timestamp (..), blkSecurityParam, genesisHash, timestampToPosix) import Pos.Core.Chrono (getNewestFirst) -import Pos.Core.Txp (TxAux (..), TxId, TxUndo) import Pos.Crypto (WithHash (..), shortHashF, withHash) import Pos.DB.Block (getBlund, resolveForwardLink) import qualified Pos.DB.Block as GS diff --git a/wallet/test/Test/Pos/Wallet/MigrationSpec.hs b/wallet/test/Test/Pos/Wallet/MigrationSpec.hs index a36c7349d40..eb75f3dd025 100644 --- a/wallet/test/Test/Pos/Wallet/MigrationSpec.hs +++ b/wallet/test/Test/Pos/Wallet/MigrationSpec.hs @@ -31,8 +31,8 @@ import Pos.Wallet.Web.State.Acidic (openState) import Pos.Wallet.Web.State.State (askWalletSnapshot) import Pos.Wallet.Web.State.Storage +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Core.Arbitrary () -import Test.Pos.Core.Arbitrary.Txp () -------------------------------------------------------------------------------- -- Reverse migrations diff --git a/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs b/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs index 00378785ec4..18d81989ac0 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Methods/PaymentSpec.hs @@ -22,12 +22,12 @@ import Test.Hspec.QuickCheck (modifyMaxSuccess) import Test.QuickCheck (arbitrary, choose, generate) import Test.QuickCheck.Monadic (pick) -import Pos.Chain.Txp (TxFee (..), TxpConfiguration) +import Pos.Chain.Txp (Tx (..), TxAux (..), TxFee (..), + TxpConfiguration, _TxOut) 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.Txp (Tx (..), TxAux (..), _TxOut) import Pos.Core.Update (bvdTxFeePolicy) import Pos.Crypto (PassPhrase) import Pos.DB.Class (MonadGState (..)) diff --git a/wallet/test/Test/Pos/Wallet/Web/Mode.hs b/wallet/test/Test/Pos/Wallet/Web/Mode.hs index bbbbbbf3280..66b37eadcba 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Mode.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Mode.hs @@ -48,6 +48,7 @@ import Pos.Chain.Block (HasSlogGState (..), LastKnownHeader, LastKnownHeaderTag) import Pos.Chain.Delegation (DelegationVar, HasDlgConfiguration) import Pos.Chain.Ssc (SscMemTag, SscState) +import Pos.Chain.Txp (TxAux) import Pos.Client.KeyStorage (MonadKeys (..), MonadKeysRead (..), getPublicDefault, getSecretDefault, modifyPublicPureDefault, modifySecretPureDefault) @@ -60,7 +61,6 @@ import Pos.Context (ConnectedPeers (..)) import Pos.Core (HasConfiguration, Timestamp (..), largestHDAddressBoot) import Pos.Core.JsonLog (CanJsonLog (..)) -import Pos.Core.Txp (TxAux) import Pos.Crypto (PassPhrase) import Pos.DB (MonadDB (..), MonadDBRead (..), MonadGState (..)) import qualified Pos.DB as DB diff --git a/wallet/test/Test/Pos/Wallet/Web/Util.hs b/wallet/test/Test/Pos/Wallet/Web/Util.hs index ebd74f0b669..67a1b330fed 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Util.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Util.hs @@ -38,7 +38,8 @@ import Test.QuickCheck.Monadic (assert, pick) import Pos.Chain.Block (Blund, LastKnownHeaderTag, blockHeader, headerHashG) -import Pos.Chain.Txp (TxpConfiguration, Utxo) +import Pos.Chain.Txp (TxIn, TxOut (..), TxOutAux (..), + TxpConfiguration, Utxo) import Pos.Client.KeyStorage (getSecretKeysPlain) import Pos.Client.Txp.Balances (getBalance) import Pos.Core (Address, BlockCount, Coin, HasConfiguration, @@ -46,7 +47,6 @@ import Pos.Core (Address, BlockCount, Coin, HasConfiguration, import Pos.Core.Chrono (OldestFirst (..)) import Pos.Core.Common (IsBootstrapEraAddr (..), deriveLvl2KeyPair) import Pos.Core.Genesis (poorSecretToEncKey) -import Pos.Core.Txp (TxIn, TxOut (..), TxOutAux (..)) import Pos.Crypto (EncryptedSecretKey, PassPhrase, ProtocolMagic, ShouldCheckPassphrase (..), emptyPassphrase, firstHardened) @@ -64,7 +64,7 @@ import Pos.Infra.Util.JsonLog.Events (MemPoolModifyReason (ApplyBlock)) import Test.Pos.Block.Logic.Util (EnableTxPayload, InplaceDB, genBlockGenParams) -import Test.Pos.Core.Arbitrary.Txp () +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Util.QuickCheck.Property (assertProperty, maybeStopProperty) import Test.Pos.Wallet.Web.Mode (WalletProperty)