diff --git a/auxx/src/Command/Proc.hs b/auxx/src/Command/Proc.hs index aa30bded176..c39e9d06609 100644 --- a/auxx/src/Command/Proc.hs +++ b/auxx/src/Command/Proc.hs @@ -15,7 +15,7 @@ import qualified Data.Map as Map import Formatting (build, int, sformat, stext, (%)) 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) @@ -27,7 +27,6 @@ import Pos.Core.Common (AddrAttributes (..), AddrSpendingData (..), makeAddress) import Pos.Core.Delegation (HeavyDlgIndex (..)) import Pos.Core.Genesis (gsSecretKeys) -import Pos.Core.Txp (TxOut (..)) import Pos.Core.Update (SoftwareVersion (..)) import Pos.Crypto (PublicKey, emptyPassphrase, encToPublic, fullPublicKeyF, hashHexF, noPassEncrypt, safeCreatePsk, diff --git a/auxx/src/Command/Rollback.hs b/auxx/src/Command/Rollback.hs index 85817af071d..11b780425bf 100644 --- a/auxx/src/Command/Rollback.hs +++ b/auxx/src/Command/Rollback.hs @@ -13,10 +13,9 @@ import Data.List (genericTake) import Formatting (build, int, sformat, string, (%)) import Pos.Chain.Block (Blund, mainBlockTxPayload) -import Pos.Chain.Txp (flattenTxPayload) +import Pos.Chain.Txp (TxAux, flattenTxPayload) import Pos.Core as Core (Config (..), difficultyL, epochIndexL) import Pos.Core.Chrono (NewestFirst, _NewestFirst) -import Pos.Core.Txp (TxAux) import Pos.DB.Block (BypassSecurityCheck (..), ShouldCallBListener (..), rollbackBlocksUnsafe) import qualified Pos.DB.Block as DB diff --git a/auxx/src/Command/Tx.hs b/auxx/src/Command/Tx.hs index cc3c92a997c..1796b0667f4 100644 --- a/auxx/src/Command/Tx.hs +++ b/auxx/src/Command/Tx.hs @@ -33,7 +33,8 @@ import System.Environment (lookupEnv) import System.IO (BufferMode (LineBuffering), hClose, hSetBuffering) 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) @@ -43,8 +44,6 @@ import Pos.Core as Core (Config (..), IsBootstrapEraAddr (..), deriveFirstHDAddress, makePubKeyAddress, mkCoin) import Pos.Core.Conc (concurrently, currentTime, delay, forConcurrently, modifySharedAtomic, newSharedAtomic) -import Pos.Core.Txp (TxAux (..), TxIn (TxInUtxo), TxOut (..), - TxOutAux (..), txaF) import Pos.Core.Update (BlockVersionData (..)) import Pos.Crypto (EncryptedSecretKey, SecretKey, 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 6bfdeebf790..9d3eaa8078b 100644 --- a/chain/bench/block-bench.hs +++ b/chain/bench/block-bench.hs @@ -15,9 +15,9 @@ 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.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 fc90558597c..6bbb04c3003 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 @@ -205,14 +213,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 @@ -225,6 +238,7 @@ test-suite test , cardano-sl-util , cardano-sl-util-test , containers + , data-default , fmt , formatting , generic-arbitrary @@ -240,28 +254,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 - TypeApplications - TupleSections - ViewPatterns - LambdaCase - MultiWayIf - ConstraintKinds - UndecidableInstances - BangPatterns - TemplateHaskell - ScopedTypeVariables - MonadFailDesugaring ghc-options: -Wall @@ -276,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 @@ -291,6 +286,7 @@ benchmark block-bench , cardano-sl-core-test , cardano-sl-crypto-test , cardano-sl-util-test + , data-default , deepseq , formatting , generic-arbitrary @@ -298,5 +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 f6d550c7b84..de32bd34e94 100644 --- a/chain/src/Pos/Chain/Block/BHelpers.hs +++ b/chain/src/Pos/Chain/Block/BHelpers.hs @@ -31,11 +31,11 @@ import Pos.Chain.Block.Union (Block, BlockHeader (..), MainConsensusData (..), MainToSign (..), mainBlockEBDataProof) import Pos.Chain.Ssc (verifySscPayload) +import Pos.Chain.Txp (checkTxPayload) import Pos.Core as Core (Config (..)) 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 e7afef69269..f4d2d993394 100644 --- a/chain/src/Pos/Chain/Block/JsonLog.hs +++ b/chain/src/Pos/Chain/Block/JsonLog.hs @@ -13,10 +13,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 (SlotCount, 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 f8484cfea93..34279d42cef 100644 --- a/chain/src/Pos/Chain/Block/Main/Types.hs +++ b/chain/src/Pos/Chain/Block/Main/Types.hs @@ -22,10 +22,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 3e353b04e6e..2d27122b931 100644 --- a/chain/src/Pos/Chain/Block/Types.hs +++ b/chain/src/Pos/Chain/Block/Types.hs @@ -22,9 +22,9 @@ import Pos.Binary.Class (Cons (..), Field (..), deriveSimpleBi) import Pos.Chain.Block.Slog.Types (SlogUndo (..), buildSlogUndo) 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 (HasDifficulty (..), SlotCount) -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 d0d6fdad89c..97d25fa61c8 100644 --- a/chain/src/Pos/Chain/Block/Union/Types.hs +++ b/chain/src/Pos/Chain/Block/Union/Types.hs @@ -128,13 +128,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 22cc1700245..d621514d833 100644 --- a/chain/src/Pos/Chain/Script.hs +++ b/chain/src/Pos/Chain/Script.hs @@ -39,10 +39,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 1f53b8f5f61..a3f4e2dc181 100644 --- a/chain/src/Pos/Chain/Txp/Base.hs +++ b/chain/src/Pos/Chain/Txp/Base.hs @@ -19,14 +19,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 92ec8b1a1aa..81b7cc0f7ce 100644 --- a/chain/src/Pos/Chain/Txp/GenesisUtxo.hs +++ b/chain/src/Pos/Chain/Txp/GenesisUtxo.hs @@ -11,10 +11,11 @@ import qualified Data.HashMap.Strict as HM import qualified Data.Map.Strict as Map import Pos.Chain.Txp.Toil (Utxo, utxoToStakes) +import Pos.Chain.Txp.Tx (TxIn (..), TxOut (..)) +import Pos.Chain.Txp.TxOutAux (TxOutAux (..)) import Pos.Core (Address, Coin, StakesMap, 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 72f43ba0521..9b932119744 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Failure.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Failure.hs @@ -21,10 +21,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 0667580a6c0..185f71fa3bc 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Logic.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Logic.hs @@ -32,6 +32,10 @@ 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, addrAttributesUnwrapped, isRedeemAddress) @@ -39,8 +43,6 @@ import Pos.Core.Common (integerToCoin) import qualified Pos.Core.Common as Fee (TxFeePolicy (..), calculateTxSizeLinear) import Pos.Core.Genesis (GenesisWStakeholders) -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 d104fb524e2..15154a1b122 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Monad.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Monad.hs @@ -61,8 +61,11 @@ import Fmt ((+|), (|+)) 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 import Pos.Util.Wlog (NamedPureLogger, WithLogger, launchNamedPureLog) diff --git a/chain/src/Pos/Chain/Txp/Toil/Stakes.hs b/chain/src/Pos/Chain/Txp/Toil/Stakes.hs index c9e3c440c5e..4cc13c61567 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Stakes.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Stakes.hs @@ -19,10 +19,13 @@ import Serokell.Util.Text (listJson) 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 (StakesList, coinToInteger, mkCoin, sumCoins, unsafeIntegerToCoin) import Pos.Core.Genesis (GenesisWStakeholders) -import Pos.Core.Txp (Tx (..), TxAux (..), TxOutAux (..), TxUndo) import Pos.Util.Wlog (logDebug) -- | Apply transactions to stakes. diff --git a/chain/src/Pos/Chain/Txp/Toil/Types.hs b/chain/src/Pos/Chain/Txp/Toil/Types.hs index 10410fee97b..7ea5539da6a 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Types.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Types.hs @@ -35,9 +35,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 b379afb1fb4..5184b4f9256 100644 --- a/chain/src/Pos/Chain/Txp/Toil/Utxo/Functions.hs +++ b/chain/src/Pos/Chain/Txp/Toil/Utxo/Functions.hs @@ -26,15 +26,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 7a2bb6d906e..bdefed3aa59 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, StakesMap, sumCoins, unsafeAddCoin, unsafeIntegerToCoin) import Pos.Core.Genesis (GenesisWStakeholders) -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 b93af9e2e1a..f7cef24da1a 100644 --- a/chain/src/Pos/Chain/Txp/Topsort.hs +++ b/chain/src/Pos/Chain/Txp/Topsort.hs @@ -14,7 +14,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 3fc0aeac60a..8ff86bd0ecf 100644 --- a/core/src/Pos/Core/Txp/Tx.hs +++ b/chain/src/Pos/Chain/Txp/Tx.hs @@ -1,7 +1,6 @@ - {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Txp.Tx +module Pos.Chain.Txp.Tx ( Tx (..) , checkTx , txInputs @@ -46,6 +45,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) @@ -129,6 +129,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 66a94555dfe..a70e8d7c979 100644 --- a/core/src/Pos/Core/Txp/TxAux.hs +++ b/chain/src/Pos/Chain/Txp/TxAux.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Txp.TxAux +module Pos.Chain.Txp.TxAux ( TxAux (..) , txaF , checkTxAux @@ -16,8 +16,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 81ec8b9394c..8e81d9c3fff 100644 --- a/core/src/Pos/Core/Txp/TxPayload.hs +++ b/chain/src/Pos/Chain/Txp/TxPayload.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Txp.TxPayload +module Pos.Chain.Txp.TxPayload ( TxPayload (..) , mkTxPayload , checkTxPayload @@ -15,9 +15,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 6cd747038ca..ec903392bdb 100644 --- a/core/src/Pos/Core/Txp/TxProof.hs +++ b/chain/src/Pos/Chain/Txp/TxProof.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Txp.TxProof +module Pos.Chain.Txp.TxProof ( TxProof (..) , mkTxProof ) where @@ -15,9 +15,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 @@ -44,7 +44,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 1d84b266d6c..a026a259aaf 100644 --- a/core/src/Pos/Core/Txp/TxWitness.hs +++ b/chain/src/Pos/Chain/Txp/TxWitness.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RecordWildCards #-} -module Pos.Core.Txp.TxWitness +module Pos.Chain.Txp.TxWitness ( TxWitness , TxInWitness (..) , TxSigData (..) @@ -29,7 +29,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 599efa2e546..b892795b86b 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.Core.Dummy (dummyEpochSlots, dummyGenesisHash) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) diff --git a/chain/test/Test/Pos/Chain/Block/Bi.hs b/chain/test/Test/Pos/Chain/Block/Bi.hs index 39c5cdbd949..9a6263206f5 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, feedPMEpochSlots, staticHeavyDlgIndexes, - staticProxySKHeavys) + exampleSscPayload, exampleSscProof, exampleUpdatePayload, + exampleUpdateProof, feedPM, feedPMEpochSlots, + 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 b0c49c13423..0731ed2e9c3 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 (ProtocolMagic, SlotCount) 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 058b88280dc..edc1e3fb9e4 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 0737a0e536a..8c6da5401d2 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 93b5ff36c87..90445c6c478 100644 --- a/chain/test/Test/Pos/Chain/Txp/CoreSpec.hs +++ b/chain/test/Test/Pos/Chain/Txp/CoreSpec.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} -- | Specification for transaction-related core functions -- (Pos.Chain.Txp.Core). @@ -20,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 ef3b8d7d421..0cea45a498f 100644 --- a/chain/test/Test/Pos/Chain/Txp/Toil/UtxoSpec.hs +++ b/chain/test/Test/Pos/Chain/Txp/Toil/UtxoSpec.hs @@ -1,4 +1,8 @@ -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ViewPatterns #-} -- | Specification of Pos.Chain.Txp.Utxo @@ -27,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) + evalUtxoM, execUtxoM, isTxInUnknown, utxoGet, + utxoToLookup, verifyTxUtxo) import Pos.Core (addressHash, checkPubKeyAddress, makePubKeyAddressBoot, makeScriptAddress, mkCoin, sumCoins) import Pos.Core.Attributes (mkAttributes) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxInWitness (..), - TxOut (..), TxOutAux (..), TxSigData (..), TxWitness, - isTxInUnknown) import Pos.Crypto (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.Crypto.Dummy (dummyProtocolMagic) import Test.Pos.Util.QuickCheck.Arbitrary (SmallGenerator (..), diff --git a/chain/test/cardano-sl-chain-test.cabal b/chain/test/cardano-sl-chain-test.cabal index 4f9396e0618..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,31 +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 - 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 e1af6d74efb..3c74d4342b8 100644 --- a/chain/test/test.hs +++ b/chain/test/test.hs @@ -6,6 +6,7 @@ import Spec (spec) import qualified Test.Pos.Chain.Block.Bi import qualified Test.Pos.Chain.Ssc.Json +import qualified Test.Pos.Chain.Txp.Bi import qualified Test.Pos.Chain.Txp.Json import Test.Pos.Util.Tripping (runTests) @@ -15,5 +16,6 @@ main = do runTests [ Test.Pos.Chain.Block.Bi.tests , Test.Pos.Chain.Ssc.Json.tests + , Test.Pos.Chain.Txp.Bi.tests , Test.Pos.Chain.Txp.Json.tests ] diff --git a/client/src/Pos/Client/Txp/Network.hs b/client/src/Pos/Client/Txp/Network.hs index 25d8ca60039..d39c04628b8 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 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 as Core (Address, Coin, Config (..), makeRedeemAddress, mkCoin, unsafeAddCoin) -import Pos.Core.Txp (Tx, TxAux (..), TxId, TxMsgContents (..), - TxOut (..), TxOutAux (..), txaF) import Pos.Crypto (RedeemSecretKey, SafeSigner, hash, redeemToPublic) import Pos.Infra.Communication.Protocol (OutSpecs) import Pos.Infra.Communication.Specs (createOutSpecs) diff --git a/client/test/Test/Pos/Client/Txp/UtilSpec.hs b/client/test/Test/Pos/Client/Txp/UtilSpec.hs index 5d15ae70378..e578a4eab06 100644 --- a/client/test/Test/Pos/Client/Txp/UtilSpec.hs +++ b/client/test/Test/Pos/Client/Txp/UtilSpec.hs @@ -21,7 +21,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, @@ -29,8 +30,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 e8836efe566..5e05b4e825a 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 @@ -149,16 +148,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 73a69b2ff39..1152bb44e81 100644 --- a/core/src/Pos/Core/Util/LogSafe.hs +++ b/core/src/Pos/Core/Util/LogSafe.hs @@ -83,7 +83,6 @@ import qualified Language.Haskell.TH as TH import Pos.Core (Timestamp) import Pos.Core.Common (Address, Coin) -import Pos.Core.Txp (TxId) import Pos.Crypto (PassPhrase) import Pos.Util.Wlog (CanLog (..), HasLoggerName (..), LogHandlerTag (HandlerFilelike), Severity (..), logMCond) @@ -352,8 +351,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 8fe507a58b6..b008b5a5eb4 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, feedEpochSlots, 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 0a60b8fac5e..657efbf0425 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 @@ -92,7 +79,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 @@ -103,11 +89,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) @@ -115,7 +100,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 (..), pcEpochSlots) import Pos.Core.Slotting (EpochIndex (..), FlatSlotId, @@ -127,10 +111,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 (..), @@ -138,14 +118,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 (..)) @@ -328,11 +307,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 @@ -403,46 +377,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 @@ -549,15 +483,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 ef530c5bf12..458a4b2171f 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 @@ -611,99 +585,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 ---------------------------------------------------------------------------- @@ -866,9 +747,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) @@ -903,3 +781,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 302aa1ca2e6..61a7c4dd2aa 100644 --- a/core/test/cardano-sl-core-test.cabal +++ b/core/test/cardano-sl-core-test.cabal @@ -22,8 +22,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 diff --git a/db/src/Pos/DB/Block/Logic/Creation.hs b/db/src/Pos/DB/Block/Logic/Creation.hs index 0d217c464dc..a85c0e2bb2e 100644 --- a/db/src/Pos/DB/Block/Logic/Creation.hs +++ b/db/src/Pos/DB/Block/Logic/Creation.hs @@ -30,7 +30,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 as Core (BlockCount, Config (..), EpochIndex, @@ -45,7 +46,6 @@ import Pos.Core.JsonLog.LogEvents (MemPoolModifyReason (..)) import Pos.Core.Reporting (HasMisbehaviorMetrics, reportError) import Pos.Core.Slotting (MonadSlots (getCurrentSlot)) 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 (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 5e256f36a36..3973cfbdfec 100644 --- a/db/src/Pos/DB/Txp/Logic/Global.hs +++ b/db/src/Pos/DB/Txp/Logic/Global.hs @@ -26,16 +26,16 @@ 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 as Core (Config (..), HasCoreConfiguration, ProtocolMagic, configBootStakeholders, epochIndexL) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) import Pos.Core.Exception (assertionFailed) import Pos.Core.Genesis (GenesisWStakeholders) -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 a95a8a3a2e3..2d623795ae6 100644 --- a/db/src/Pos/DB/Txp/Logic/Local.hs +++ b/db/src/Pos/DB/Txp/Logic/Local.hs @@ -28,17 +28,16 @@ import Formatting (build, sformat, (%)) 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 as Core (Config (..), EpochIndex, SlotCount, configEpochSlots, 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 a456510e802..1ddc6628277 100644 --- a/db/src/Pos/DB/Txp/MemState/Class.hs +++ b/db/src/Pos/DB/Txp/MemState/Class.hs @@ -30,12 +30,11 @@ 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 as Core (Config) import Pos.Core.Reporting (MonadReporting) import Pos.Core.Slotting (MonadSlots (..)) -import Pos.Core.Txp (TxAux, TxId) import Pos.DB.Class (MonadDBRead, MonadGState (..)) import Pos.DB.Txp.MemState.Types (GenericTxpLocalData (..)) import Pos.Util.Util (HasLens (..)) diff --git a/db/src/Pos/DB/Txp/Settings.hs b/db/src/Pos/DB/Txp/Settings.hs index 525ab0496d1..73716e8e66a 100644 --- a/db/src/Pos/DB/Txp/Settings.hs +++ b/db/src/Pos/DB/Txp/Settings.hs @@ -17,10 +17,9 @@ module Pos.DB.Txp.Settings import Universum 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) import Pos.Util.Wlog (WithLogger) diff --git a/db/src/Pos/DB/Txp/Utxo.hs b/db/src/Pos/DB/Txp/Utxo.hs index 8e5084f10f7..eb359eb371d 100644 --- a/db/src/Pos/DB/Txp/Utxo.hs +++ b/db/src/Pos/DB/Txp/Utxo.hs @@ -41,11 +41,11 @@ import qualified Formatting.Buildable import Serokell.Util (Color (Red), colorize) import UnliftIO (MonadUnliftIO) -import Pos.Chain.Txp (Utxo, addrBelongsToSet, genesisUtxo, txOutStake) +import Pos.Chain.Txp (TxIn (..), TxOutAux (toaOut), Utxo, + addrBelongsToSet, genesisUtxo, txOutStake) import Pos.Core (Address, Coin, HasCoreConfiguration, coinF, 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 5233a085279..af4179b30a9 100644 --- a/db/test/Test/Pos/DB/Block/Arbitrary.hs +++ b/db/test/Test/Pos/DB/Block/Arbitrary.hs @@ -11,8 +11,8 @@ import Test.QuickCheck.Arbitrary.Generic (genericArbitrary, import Pos.Chain.Block (SlogUndo, Undo (..)) 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 c267923c69d..c0b78ec6b55 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 () import Test.Pos.Core.Dummy (dummyEpochSlots) ---------------------------------------------------------------- diff --git a/explorer/cardano-sl-explorer.cabal b/explorer/cardano-sl-explorer.cabal index 1ad75fa0b8f..5a6df652543 100644 --- a/explorer/cardano-sl-explorer.cabal +++ b/explorer/cardano-sl-explorer.cabal @@ -397,6 +397,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 36e36710434..0ceb18fc6d5 100644 --- a/explorer/src/Pos/Explorer/BListener.hs +++ b/explorer/src/Pos/Explorer/BListener.hs @@ -30,12 +30,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 a3f39306aa3..a17ac52ccba 100644 --- a/explorer/src/Pos/Explorer/DB.hs +++ b/explorer/src/Pos/Explorer/DB.hs @@ -42,12 +42,12 @@ import UnliftIO (MonadUnliftIO) import Pos.Binary.Class (serialize') import Pos.Chain.Block (HeaderHash) -import Pos.Chain.Txp (genesisUtxo, utxoF, utxoToAddressCoinPairs) +import Pos.Chain.Txp (Tx, TxId, TxOut (..), TxOutAux (..), + genesisUtxo, utxoF, utxoToAddressCoinPairs) import Pos.Core as Core (Address, Coin, Config (..), EpochIndex (..), HasConfiguration, coinToInteger, unsafeAddCoin) import Pos.Core.Chrono (NewestFirst (..)) import Pos.Core.Genesis (GenesisData) -import Pos.Core.Txp (Tx, TxId, TxOut (..), TxOutAux (..)) import Pos.DB (DBError (..), DBIteratorClass (..), DBTag (GStateDB), MonadDB, MonadDBRead (dbGet), RocksBatchOp (..), dbIterSource, dbSerializeValue, encodeWithKeyPrefix) diff --git a/explorer/src/Pos/Explorer/Socket/Methods.hs b/explorer/src/Pos/Explorer/Socket/Methods.hs index 6c8398a37d7..946f955ff53 100644 --- a/explorer/src/Pos/Explorer/Socket/Methods.hs +++ b/explorer/src/Pos/Explorer/Socket/Methods.hs @@ -65,10 +65,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, GenesisHash, SlotCount) 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 00324473ec4..1845a767082 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 (..), @@ -44,7 +45,6 @@ import Pos.Core (Address, BlockCount (..), ChainDifficulty (..), SlotLeaders, StakeholderId, difficultyL, makePubKeyAddressBoot) import Pos.Core.Ssc (SscPayload) -import Pos.Core.Txp (TxAux) import Pos.Core.Update (UpdatePayload (..)) import Pos.Crypto (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 b78a7e54c81..6e65fb6c281 100644 --- a/explorer/src/Pos/Explorer/Txp/Common.hs +++ b/explorer/src/Pos/Explorer/Txp/Common.hs @@ -12,10 +12,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 9b9dc001a1e..e61f88c9de8 100644 --- a/explorer/src/Pos/Explorer/Txp/Global.hs +++ b/explorer/src/Pos/Explorer/Txp/Global.hs @@ -10,13 +10,12 @@ 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 as Core (Config (..), HasConfiguration, SlotId (..), configBootStakeholders, epochIndexL, localSlotIndexMinBound) import Pos.Core.Chrono (NewestFirst (..)) import Pos.Core.Genesis (GenesisWStakeholders) -import Pos.Core.Txp (TxAux, TxUndo) import Pos.DB (SomeBatchOp (..)) import Pos.DB.Txp (ProcessBlundsSettings (..), TxpBlund, TxpGlobalApplyMode, TxpGlobalRollbackMode, diff --git a/explorer/src/Pos/Explorer/Txp/Local.hs b/explorer/src/Pos/Explorer/Txp/Local.hs index e8ccd31a464..79857bb1bc4 100644 --- a/explorer/src/Pos/Explorer/Txp/Local.hs +++ b/explorer/src/Pos/Explorer/Txp/Local.hs @@ -12,11 +12,11 @@ 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 as Core (Config (..), EpochIndex, Timestamp, configEpochSlots) import Pos.Core.JsonLog (CanJsonLog (..)) -import Pos.Core.Txp (TxAux (..), TxId) import Pos.Core.Update (BlockVersionData) import Pos.DB.Txp.Logic (txNormalizeAbstract, txProcessTransactionAbstract) diff --git a/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs b/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs index f4f6f6bebd2..739335d734d 100644 --- a/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs +++ b/explorer/src/Pos/Explorer/Txp/Toil/Logic.hs @@ -20,15 +20,14 @@ import qualified Data.List.NonEmpty as NE import Formatting (build, sformat, (%)) 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, Timestamp, mkCoin, sumCoins, unsafeAddCoin, unsafeSubCoin) import Pos.Core.Chrono (NewestFirst (..)) import Pos.Core.Genesis (GenesisWStakeholders) -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 f7afdce8d32..2ad348efedc 100644 --- a/explorer/src/Pos/Explorer/Txp/Toil/Monad.hs +++ b/explorer/src/Pos/Explorer/Txp/Toil/Monad.hs @@ -35,9 +35,8 @@ import Control.Monad.Reader (mapReaderT) import Control.Monad.State.Strict (mapStateT) 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 8c5f57433be..bba9e19bbdf 100644 --- a/explorer/src/Pos/Explorer/Web/ClientTypes.hs +++ b/explorer/src/Pos/Explorer/Web/ClientTypes.hs @@ -73,6 +73,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, SlotCount, SlotId (..), StakeholderId, Timestamp, addressF, coinToInteger, decodeTextAddress, getEpochIndex, @@ -80,8 +82,6 @@ import Pos.Core (Address, Coin, EpochIndex, LocalSlotIndex, SlotCount, 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 f065b95a801..cc3f852b9f5 100644 --- a/explorer/src/Pos/Explorer/Web/Server.hs +++ b/explorer/src/Pos/Explorer/Web/Server.hs @@ -59,7 +59,9 @@ 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 as Core (AddrType (..), Address (..), Coin, Config (..), EpochIndex, GenesisHash, SlotCount, Timestamp, coinToInteger, configEpochSlots, difficultyL, @@ -68,8 +70,6 @@ import Pos.Core as Core (AddrType (..), Address (..), Coin, 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 c8f79ab4ffa..42cb6c7aae6 100644 --- a/explorer/test/Test/Pos/Explorer/MockFactory.hs +++ b/explorer/test/Test/Pos/Explorer/MockFactory.hs @@ -10,8 +10,8 @@ module Test.Pos.Explorer.MockFactory import Universum +import Pos.Chain.Txp (TxOut (..)) import Pos.Core (Address, unsafeIntegerToCoin) -import Pos.Core.Txp (TxOut (..)) import Pos.Util.Wlog (LoggerName) -- | Factory to create `TxOut` diff --git a/generator/src/Pos/Generator/Block/Payload.hs b/generator/src/Pos/Generator/Block/Payload.hs index ef495f1ae35..c88f44b42ff 100644 --- a/generator/src/Pos/Generator/Block/Payload.hs +++ b/generator/src/Pos/Generator/Block/Payload.hs @@ -24,15 +24,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 as Core (AddrSpendingData (..), Address (..), Coin, Config (..), SlotId (..), addressHash, coinToInteger, makePubKeyAddressBoot, unsafeIntegerToCoin) -import Pos.Core.Txp (Tx (..), TxAux (..), TxIn (..), TxOut (..), - TxOutAux (..)) import Pos.Crypto (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 b67faa3e4c0..7871aec03ae 100644 --- a/generator/test/Test/Pos/Block/Logic/CreationSpec.hs +++ b/generator/test/Test/Pos/Block/Logic/CreationSpec.hs @@ -20,12 +20,12 @@ 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 (SlotId (..), localSlotIndexMinBound, unsafeMkLocalSlotIndex) 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) @@ -34,8 +34,8 @@ 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 (withDefUpdateConfiguration) -import Test.Pos.Core.Arbitrary.Txp (GoodTx, goodTxToTxAux) import Test.Pos.Core.Dummy (dummyBlockVersionData, dummyConfig, dummyEpochSlots, dummyK, dummyProtocolConstants) import Test.Pos.Crypto.Dummy (dummyProtocolMagic) diff --git a/generator/test/Test/Pos/Generator/Block/LrcSpec.hs b/generator/test/Test/Pos/Generator/Block/LrcSpec.hs index 432bfdd3628..3410a936aa5 100644 --- a/generator/test/Test/Pos/Generator/Block/LrcSpec.hs +++ b/generator/test/Test/Pos/Generator/Block/LrcSpec.hs @@ -25,7 +25,7 @@ import Test.QuickCheck.Monadic (pick) 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 as Core (Coin, Config (..), EpochIndex, StakeholderId, addressHash, coinF, configBlkSecurityParam, configBlockVersionData, configEpochSlots, configFtsSeed, @@ -33,7 +33,6 @@ import Pos.Core as Core (Coin, Config (..), EpochIndex, StakeholderId, import Pos.Core.Genesis (GenesisInitializer (..), TestnetBalanceOptions (..), gsSecretKeysPoor, gsSecretKeysRich) -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 3e92e0003b1..a6ccb5f924f 100644 --- a/infra/src/Pos/Infra/Communication/Types/Relay.hs +++ b/infra/src/Pos/Infra/Communication/Types/Relay.hs @@ -28,9 +28,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 59aa51b6c6b..33d9eb30020 100644 --- a/infra/src/Pos/Infra/Diffusion/Types.hs +++ b/infra/src/Pos/Infra/Diffusion/Types.hs @@ -18,11 +18,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 06572b30865..32b7468b28c 100644 --- a/lib/src/Pos/Crypto/HDDiscovery.hs +++ b/lib/src/Pos/Crypto/HDDiscovery.hs @@ -14,9 +14,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 1847081880a..d785c6df45a 100644 --- a/lib/src/Pos/Listener/Txp.hs +++ b/lib/src/Pos/Listener/Txp.hs @@ -17,9 +17,9 @@ import Formatting (build, sformat, (%)) import Node.Message.Class (Message) import Universum -import Pos.Chain.Txp (TxpConfiguration) +import Pos.Chain.Txp (TxAux (..), TxId, TxMsgContents (..), + TxpConfiguration) import Pos.Core as Core (Config) -import Pos.Core.Txp (TxAux (..), TxId, TxMsgContents (..)) import Pos.Crypto (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 112d7f13e50..424cea88c81 100644 --- a/lib/src/Pos/Logic/Full.hs +++ b/lib/src/Pos/Logic/Full.hs @@ -21,14 +21,14 @@ 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 as Core (Config (..), HasConfiguration, StakeholderId, addressHash, configBlkSecurityParam, configEpochSlots) 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 (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 0526cb6a07c..a296806e806 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 94912dc47a6..1c20fc10ccd 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 65ca201874f..84fc66aef9c 100644 --- a/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs +++ b/lib/test/Test/Pos/Types/Identity/SafeCopySpec.hs @@ -8,12 +8,12 @@ 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.Core.Arbitrary.Txp () +import Test.Pos.Chain.Txp.Arbitrary () 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 7d22b04f6a2..0f9d8071a68 100644 --- a/networking/src/Node/Message/Class.hs +++ b/networking/src/Node/Message/Class.hs @@ -36,7 +36,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 817a3403a44..e2b02da5c37 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -15337,6 +15337,7 @@ license = stdenv.lib.licenses.mit; , aeson-options , array , base +, base16-bytestring , bytestring , Cabal , cardano-crypto @@ -15454,6 +15455,7 @@ cpphs ]; testHaskellDepends = [ base +base16-bytestring bytestring cardano-crypto cardano-sl-binary @@ -15465,6 +15467,7 @@ cardano-sl-crypto-test cardano-sl-util cardano-sl-util-test containers +data-default fmt formatting generic-arbitrary @@ -15489,6 +15492,7 @@ cardano-sl-crypto cardano-sl-crypto-test cardano-sl-util-test criterion +data-default deepseq formatting generic-arbitrary @@ -15497,6 +15501,7 @@ random text universum unordered-containers +vector ]; doHaddock = false; description = "Cardano SL - transaction processing"; @@ -15507,6 +15512,7 @@ license = stdenv.lib.licenses.mit; ({ mkDerivation , base +, base16-bytestring , bytestring , cardano-crypto , cardano-sl-binary @@ -15518,6 +15524,7 @@ license = stdenv.lib.licenses.mit; , cardano-sl-crypto-test , cardano-sl-util-test , containers +, data-default , formatting , generic-arbitrary , hedgehog @@ -15527,6 +15534,7 @@ license = stdenv.lib.licenses.mit; , stdenv , universum , unordered-containers +, vector }: mkDerivation { @@ -15541,6 +15549,7 @@ configureFlags = [ ]; libraryHaskellDepends = [ base +base16-bytestring bytestring cardano-crypto cardano-sl-binary @@ -15552,6 +15561,7 @@ cardano-sl-crypto cardano-sl-crypto-test cardano-sl-util-test containers +data-default formatting generic-arbitrary hedgehog @@ -15560,6 +15570,7 @@ random reflection universum unordered-containers +vector ]; doHaddock = false; description = "Cardano SL - arbitrary instances for cardano-sl-chain"; @@ -16448,6 +16459,7 @@ cpphs benchmarkHaskellDepends = [ base cardano-sl +cardano-sl-chain-test cardano-sl-core-test criterion QuickCheck @@ -17151,6 +17163,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 @@ -17228,6 +17241,7 @@ base bytestring cardano-sl cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -17271,6 +17285,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 @@ -17572,6 +17587,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 @@ -17720,6 +17736,7 @@ bytestring cardano-crypto cardano-sl cardano-sl-chain +cardano-sl-chain-test cardano-sl-client cardano-sl-core cardano-sl-core-test @@ -17899,6 +17916,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 diff --git a/tools/cardano-sl-tools.cabal b/tools/cardano-sl-tools.cabal index 6a3929d8bdb..acc11c47681 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 @@ -543,6 +544,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 59084a6a9c5..358e7938328 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 d6025bf3bfe..d5e1ba29cdd 100755 --- a/wallet-new/cardano-sl-wallet-new.cabal +++ b/wallet-new/cardano-sl-wallet-new.cabal @@ -175,6 +175,7 @@ library , cardano-sl , cardano-sl-binary , cardano-sl-chain + , cardano-sl-chain-test , cardano-sl-client , cardano-sl-core , cardano-sl-core-test @@ -365,6 +366,7 @@ executable wal-integr-test , bytestring , cardano-sl , cardano-sl-core + , cardano-sl-chain , cardano-sl-wallet , cardano-sl-wallet-new , containers @@ -501,6 +503,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/integration/TransactionSpecs.hs b/wallet-new/integration/TransactionSpecs.hs index 15b4e130abe..aa59cd3d768 100644 --- a/wallet-new/integration/TransactionSpecs.hs +++ b/wallet-new/integration/TransactionSpecs.hs @@ -14,8 +14,8 @@ import Text.Show.Pretty (ppShow) import Util import qualified Data.Map.Strict as Map +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Txp {-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-} diff --git a/wallet-new/src/Cardano/Wallet/API/Indices.hs b/wallet-new/src/Cardano/Wallet/API/Indices.hs index 011a21dcce7..4961091344b 100644 --- a/wallet-new/src/Cardano/Wallet/API/Indices.hs +++ b/wallet-new/src/Cardano/Wallet/API/Indices.hs @@ -22,8 +22,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 Cardano.Wallet.Kernel.DB.Util.IxSet (HasPrimKey (..), 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 420149c4885..3f3663a0fe3 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 (TxId) import Pos.Client.Txp.Util (InputSelectionPolicy (..), defaultInputSelectionPolicy) import Pos.Core (Address, Timestamp) -import Pos.Core.Txp (TxId) import Cardano.Wallet.API.Request import Cardano.Wallet.API.Response 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 5ac86e8659b..0eaf4e3c143 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/LegacyHandlers/Transactions.hs @@ -6,12 +6,11 @@ import qualified Data.List.NonEmpty as NE import Formatting (build, sformat) import Servant -import Pos.Chain.Txp (TxId, TxpConfiguration) +import Pos.Chain.Txp (TxAux, TxId, TxpConfiguration) import Pos.Client.Txp.Util (defaultInputSelectionPolicy) import qualified Pos.Client.Txp.Util as V0 import Pos.Core as Core (Config (..)) import qualified Pos.Core as Core -import Pos.Core.Txp (TxAux) import qualified Pos.Util.Servant as V0 import qualified Pos.Wallet.WalletMode as V0 import qualified Pos.Wallet.Web.ClientTypes.Types 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 b6e01a444a4..73b8313ed3f 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Migration/Types.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Migration/Types.hs @@ -33,11 +33,11 @@ import Cardano.Wallet.API.V1.Generic (jsendErrorGenericParseJSON, 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 4677fd8bd10..6aea1b4867e 100644 --- a/wallet-new/src/Cardano/Wallet/API/V1/Types.hs +++ b/wallet-new/src/Cardano/Wallet/API/V1/Types.hs @@ -186,10 +186,10 @@ import Cardano.Wallet.Types.UtxoStatistics import Cardano.Wallet.Util (showApiUtcTime) import qualified Pos.Binary.Class as Bi +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 (Hash, PublicKey (..), decodeHash, hashHexF) import qualified Pos.Crypto.Signing as Core diff --git a/wallet-new/src/Cardano/Wallet/Client.hs b/wallet-new/src/Cardano/Wallet/Client.hs index e06ccf6073a..06f0dce499b 100644 --- a/wallet-new/src/Cardano/Wallet/Client.hs +++ b/wallet-new/src/Cardano/Wallet/Client.hs @@ -36,8 +36,8 @@ import Universum import Control.Exception (Exception (..)) import Servant.Client (GenResponse (..), Response, ServantError (..)) +import qualified Pos.Chain.Txp as Core import qualified Pos.Core as Core -import qualified Pos.Core.Txp as Core import Cardano.Wallet.API.Request.Filter import Cardano.Wallet.API.Request.Pagination diff --git a/wallet-new/src/Cardano/Wallet/Kernel.hs b/wallet-new/src/Cardano/Wallet/Kernel.hs index c0e81eb54ed..4d6f429dfed 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel.hs @@ -31,8 +31,8 @@ import Data.Acid (AcidState, openLocalState, openLocalStateFrom) import Data.Acid.Memory (openMemoryState) import qualified Data.Map.Strict as Map +import Pos.Chain.Txp (TxAux (..)) import Pos.Core (ProtocolMagic) -import Pos.Core.Txp (TxAux (..)) import Pos.Util.Wlog (Severity (..)) import Cardano.Wallet.Kernel.DB.AcidState (DB, defDB) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs b/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs index 33b850c8ca9..ad1401c40ed 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/CoinSelection/FromGeneric.hs @@ -37,13 +37,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 CTxp 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 5c820ceffe6..e28ee843c6d 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/AcidState.hs @@ -55,9 +55,8 @@ 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 Pos.Core.Chrono (OldestFirst (..)) -import Pos.Core.Txp (TxAux, TxId) import Pos.Core.Update (SoftwareVersion) import Cardano.Wallet.Kernel.DB.BlockContext diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs index 17f18c26ae7..f94bab99704 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/BlockMeta.hs @@ -31,8 +31,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/InDb.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs index 967aea933e4..58f4434be2c 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/InDb.hs @@ -26,11 +26,11 @@ import qualified Data.Vector as V import Test.QuickCheck (Arbitrary (..)) import qualified Pos.Chain.Block as Core +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core import qualified Pos.Core.Attributes as Core import qualified Pos.Core.Delegation as Core import qualified Pos.Core.Ssc as Ssc -import qualified Pos.Core.Txp as Txp import qualified Pos.Core.Update as Core import qualified Pos.Crypto as Core 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 43c0179a38f..3d480679a3e 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/Spec/Update.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/Spec/Update.hs @@ -30,9 +30,9 @@ import Serokell.Util (listJsonIndent) import Test.QuickCheck (Arbitrary (..), elements) 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 qualified Pos.Core.Txp as Txp import Cardano.Wallet.Kernel.DB.BlockContext import Cardano.Wallet.Kernel.DB.BlockMeta diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs index b91b3f35140..e6f83930d18 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs @@ -75,8 +75,8 @@ import Cardano.Wallet.Kernel.DB.TxMeta.Types (AccountFops (..), import qualified Cardano.Wallet.Kernel.DB.TxMeta.Types as Kernel 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) #-} 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 935ec2d331c..d2dd0ee07fb 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs @@ -59,8 +59,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 cd684424daa..edafc885402 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Diffusion.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Diffusion.hs @@ -6,7 +6,8 @@ module Cardano.Wallet.Kernel.Diffusion ( import Universum -import Pos.Core.Txp (TxAux) +import Pos.Chain.Txp (TxAux) +import Pos.Core () import Pos.Infra.Communication.Types.Protocol (NodeId) import Pos.Infra.Diffusion.Subscription.Status (SubscriptionStatus, ssMap) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Invariants.hs b/wallet-new/src/Cardano/Wallet/Kernel/Invariants.hs index c09a990033e..1b168c7e0e1 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Invariants.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Invariants.hs @@ -13,7 +13,7 @@ import Formatting (bprint, build, formatToString, (%)) import qualified Formatting.Buildable import Serokell.Util (mapJson) -import Pos.Core.Txp (TxId) +import Pos.Chain.Txp (TxId) import Cardano.Wallet.Kernel.DB.HdWallet import qualified Cardano.Wallet.Kernel.DB.Read as DB diff --git a/wallet-new/src/Cardano/Wallet/Kernel/NodeStateAdaptor.hs b/wallet-new/src/Cardano/Wallet/Kernel/NodeStateAdaptor.hs index 32da94e1faa..209d5b9c46e 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/NodeStateAdaptor.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/NodeStateAdaptor.hs @@ -63,6 +63,7 @@ import qualified Cardano.Wallet.API.V1.Types as V1 import Pos.Chain.Block (Block, HeaderHash, LastKnownHeader, LastKnownHeaderTag, MainBlock, blockHeader, headerHash, mainBlockSlot, prevBlockL) +import Pos.Chain.Txp (TxIn, TxOutAux) import Pos.Chain.Update (ConfirmedProposalState, HasUpdateConfiguration, SoftwareVersion, bvdMaxTxSize, bvdTxFeePolicy) @@ -75,7 +76,6 @@ import Pos.Core as Core (BlockCount, Config (..), GenesisHash (..), import Pos.Core.Configuration (HasConfiguration) import Pos.Core.Slotting (EpochIndex (..), HasSlottingVar (..), LocalSlotIndex (..), MonadSlots (..), SlotId (..)) -import Pos.Core.Txp (TxIn, TxOutAux) import qualified Pos.DB.Block as DB import Pos.DB.BlockIndex (getTipHeader) import Pos.DB.Class (MonadDBRead (..), getBlock) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs b/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs index 87e3c1def5a..d64f8e51fd0 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Pending.hs @@ -15,8 +15,8 @@ import Control.Concurrent.MVar (modifyMVar_) import Data.Acid.Advanced (update') +import Pos.Chain.Txp (Tx (..), TxAux (..), TxOut (..)) import Pos.Core (Coin (..)) -import Pos.Core.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 42c4c877b4f..a146875bd43 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/PrefilterTx.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/PrefilterTx.hs @@ -29,9 +29,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 (..), Coin, 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/Restore.hs b/wallet-new/src/Cardano/Wallet/Kernel/Restore.hs index 06664653446..bfdd1ce118d 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Restore.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Restore.hs @@ -48,11 +48,11 @@ import Cardano.Wallet.Kernel.Wallets (createWalletHdRnd) import Pos.Chain.Block (Block, Blund, HeaderHash, MainBlock, Undo, headerHash, mainBlockSlot) -import Pos.Chain.Txp (Utxo, genesisUtxo) +import Pos.Chain.Txp (TxIn (..), TxOut (..), TxOutAux (..), Utxo, + genesisUtxo) import Pos.Core as Core (BlockCount (..), Coin, Config (..), GenesisHash, SlotId, flattenSlotId, mkCoin, unsafeIntegerToCoin) -import Pos.Core.Txp (TxIn (..), TxOut (..), TxOutAux (..)) import Pos.Crypto (EncryptedSecretKey) import Pos.DB.Block (getFirstGenesisBlockHash, getUndo, resolveForwardLink) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs b/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs index bba762086f3..24420602731 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Submission.hs @@ -72,7 +72,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 e4fa27f30e2..1a23c5e203f 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Transactions.hs @@ -33,13 +33,12 @@ import Test.QuickCheck (Arbitrary (..), oneof) 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 qualified Pos.Client.Txp.Util as CTxp import Pos.Core (Address, Coin, TxFeePolicy (..), unsafeIntegerToCoin, unsafeSubCoin) import qualified Pos.Core as Core -import Pos.Core.Txp (Tx (..), TxAux (..), TxId, TxIn (..), TxOut (..), - TxOutAux (..)) import Pos.Crypto (EncryptedSecretKey, PassPhrase, RedeemSecretKey, SafeSigner (..), ShouldCheckPassphrase (..), hash, redeemToPublic) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/Types.hs b/wallet-new/src/Cardano/Wallet/Kernel/Types.hs index 5ca395b0a43..eefc99c9869 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/Types.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/Types.hs @@ -24,8 +24,8 @@ import qualified Data.List.NonEmpty as NE import Formatting.Buildable (Buildable (..)) import Pos.Chain.Block (MainBlock, gbBody, mbTxs, mbWitnesses) +import Pos.Chain.Txp (Tx, TxAux (..), TxId, TxIn (..), txInputs) import qualified Pos.Core as Core -import Pos.Core.Txp (Tx, TxAux (..), TxId, TxIn (..), txInputs) import Formatting (bprint, (%)) import qualified Formatting as F diff --git a/wallet-new/src/Cardano/Wallet/Types/UtxoStatistics.hs b/wallet-new/src/Cardano/Wallet/Types/UtxoStatistics.hs index 7016febdabb..4dfbd5d308c 100644 --- a/wallet-new/src/Cardano/Wallet/Types/UtxoStatistics.hs +++ b/wallet-new/src/Cardano/Wallet/Types/UtxoStatistics.hs @@ -34,9 +34,8 @@ import Test.QuickCheck (Arbitrary (..), arbitrary, choose, elements, infiniteListOf, shuffle) import Cardano.Wallet.API.V1.Swagger.Example (Example) -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (TxOut (..), TxOutAux (..), Utxo) import Pos.Core.Common (Coin (..)) -import Pos.Core.Txp (TxOut (..), TxOutAux (..)) import Pos.Infra.Util.LogSafe (BuildableSafeGen (..), deriveSafeBuildable) diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer.hs b/wallet-new/src/Cardano/Wallet/WalletLayer.hs index 1ef2c488ec6..14857e01a72 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer.hs @@ -32,10 +32,9 @@ import qualified Prelude import Test.QuickCheck (Arbitrary (..), oneof) import Pos.Chain.Block (Blund) -import Pos.Chain.Txp (Utxo) +import Pos.Chain.Txp (Tx, TxId, Utxo) import Pos.Core (Coin, Timestamp) import Pos.Core.Chrono (NE, NewestFirst (..), OldestFirst (..)) -import Pos.Core.Txp (Tx, TxId) import Pos.Core.Update (SoftwareVersion) import Pos.Crypto (EncryptedSecretKey, PassPhrase) diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Active.hs b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Active.hs index a9f91e66b3f..73d87b9efe3 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, TxFeePolicy) -import Pos.Core.Txp (Tx) import Pos.Crypto (PassPhrase) import Cardano.Wallet.API.V1.Types (unV1) diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs index 3102633cc52..c47438e07fb 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs @@ -8,9 +8,9 @@ import Universum import Control.Monad.Except import GHC.TypeLits (symbolVal) +import Pos.Chain.Txp (TxId) import Pos.Core (Address, Coin, SlotCount, SlotId, Timestamp, decodeTextAddress, flattenSlotId, getBlockCount) -import Pos.Core.Txp (TxId) import Cardano.Wallet.API.Indices import Cardano.Wallet.API.Request diff --git a/wallet-new/test/Cardano/Wallet/WalletLayer/QuickCheck.hs b/wallet-new/test/Cardano/Wallet/WalletLayer/QuickCheck.hs index 066112bff18..b17c7773c7c 100644 --- a/wallet-new/test/Cardano/Wallet/WalletLayer/QuickCheck.hs +++ b/wallet-new/test/Cardano/Wallet/WalletLayer/QuickCheck.hs @@ -22,7 +22,7 @@ import Cardano.Wallet.WalletLayer (ActiveWalletLayer (..), import Cardano.Wallet.API.V1.Types (V1 (..)) import Pos.Core () -import Test.Pos.Core.Arbitrary.Txp () +import Test.Pos.Chain.Txp.Arbitrary () import Test.QuickCheck (Arbitrary (..), arbitrary, generate, oneof) diff --git a/wallet-new/test/MarshallingSpec.hs b/wallet-new/test/MarshallingSpec.hs index 512d66028dd..c641d50c206 100644 --- a/wallet-new/test/MarshallingSpec.hs +++ b/wallet-new/test/MarshallingSpec.hs @@ -27,11 +27,11 @@ import qualified Test.QuickCheck.Property as Property import qualified Cardano.Crypto.Wallet as CCW import qualified Pos.Chain.Block as Core +import qualified Pos.Chain.Txp as Txp import qualified Pos.Core as Core import qualified Pos.Core.Attributes as Core import qualified Pos.Core.Delegation as Core import qualified Pos.Core.Ssc as Ssc -import qualified Pos.Core.Txp as Txp import qualified Pos.Core.Update as Core import qualified Pos.Crypto as Core diff --git a/wallet-new/test/unit/Arbitrary.hs b/wallet-new/test/unit/Arbitrary.hs index d08fdec31ab..6750ad9d878 100644 --- a/wallet-new/test/unit/Arbitrary.hs +++ b/wallet-new/test/unit/Arbitrary.hs @@ -19,8 +19,8 @@ import Cardano.Wallet.Kernel.DB.InDb import Cardano.Wallet.Kernel.DB.Spec import Cardano.Wallet.Kernel.DB.Spec.Pending +import Test.Pos.Chain.Txp.Arbitrary () import Test.Pos.Core.Arbitrary () -import Test.Pos.Core.Arbitrary.Txp () instance Arbitrary BlockContext where arbitrary = do @@ -76,4 +76,3 @@ instance Arbitrary Pending where arbitrary = do p <- arbitrary return $ fromTransactions p - diff --git a/wallet-new/test/unit/Test/Spec/NewPayment.hs b/wallet-new/test/unit/Test/Spec/NewPayment.hs index 02aa37eb8ec..e7facd81f12 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 fad851355c5..5fd128d692c 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, diff --git a/wallet-new/test/unit/TxMetaStorageSpecs.hs b/wallet-new/test/unit/TxMetaStorageSpecs.hs index 5a219090e6c..68af588e8cd 100644 --- a/wallet-new/test/unit/TxMetaStorageSpecs.hs +++ b/wallet-new/test/unit/TxMetaStorageSpecs.hs @@ -17,8 +17,8 @@ import qualified Data.List.NonEmpty as NonEmpty import qualified Data.Set as Set import Formatting.Buildable (build) +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 283e4643084..b97f98069ba 100644 --- a/wallet-new/test/unit/UTxO/Interpreter.hs +++ b/wallet-new/test/unit/UTxO/Interpreter.hs @@ -59,7 +59,8 @@ import Pos.Chain.Block (Block, BlockHeader (..), GenesisBlock, headerHash, 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, txAttributes, txOutStake) import Pos.Chain.Update import Pos.Client.Txp import Pos.Core @@ -68,8 +69,6 @@ import Pos.Core.Delegation (DlgPayload (..)) import Pos.Core.Genesis (GenesisWStakeholders, gdBootStakeholders, gdProtocolConsts, genesisProtocolConstantsToProtocolConstants) -import Pos.Core.Txp (TxAux (..), TxId, TxIn (..), TxOut (..), - TxOutAux (..), txAttributes) import Pos.Crypto import Pos.DB.Block (RawPayload (..), createMainBlockPure) diff --git a/wallet/cardano-sl-wallet.cabal b/wallet/cardano-sl-wallet.cabal index 875143f2d1f..f0355e34a16 100644 --- a/wallet/cardano-sl-wallet.cabal +++ b/wallet/cardano-sl-wallet.cabal @@ -240,6 +240,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 bd1e43ec73d..f05401589f2 100644 --- a/wallet/src/Pos/Wallet/Redirect.hs +++ b/wallet/src/Pos/Wallet/Redirect.hs @@ -27,12 +27,12 @@ import Data.Time.Units (Millisecond) 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 as Core (ChainDifficulty, Config, HasConfiguration, Timestamp, difficultyL, getCurrentTimestamp) -import Pos.Core.Txp (Tx, TxAux (..), TxId, TxUndo) import Pos.Crypto (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 d394a22859a..dbb43bd167d 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/History.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/History.hs @@ -23,10 +23,10 @@ import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) import Formatting (sformat, stext, (%)) import Serokell.Util (listChunkedJson, listJsonIndent) +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 4dc33a5a3ab..55a9223e9a7 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Payment.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Payment.hs @@ -21,7 +21,8 @@ import Formatting (build, sformat, (%)) import Servant.Server (err403, err405, errReasonPhrase) 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 (..)) @@ -34,7 +35,6 @@ import Pos.Core as Core (Address, Coin, Config (..), HasConfiguration, getCurrentTimestamp) import Pos.Core.Conc (concurrently, delay) import Pos.Core.Genesis (GenesisData) -import Pos.Core.Txp (TxAux (..), TxOut (..), _txOutputs) import Pos.Crypto (PassPhrase, SafeSigner, ShouldCheckPassphrase (..), checkPassMatches, hash, withSafeSignerUnsafe) import Pos.DB (MonadGState) diff --git a/wallet/src/Pos/Wallet/Web/Methods/Redeem.hs b/wallet/src/Pos/Wallet/Web/Methods/Redeem.hs index 995ed5e90fa..5dd65d32dae 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 as Core (Config (..), getCurrentTimestamp) -import Pos.Core.Txp (TxAux (..), TxOut (..)) import Pos.Crypto (PassPhrase, 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 90a93a58b97..a13b0abc35e 100644 --- a/wallet/src/Pos/Wallet/Web/Methods/Txp.hs +++ b/wallet/src/Pos/Wallet/Web/Methods/Txp.hs @@ -18,7 +18,8 @@ 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 (..), @@ -26,7 +27,6 @@ import Pos.Client.Txp.Util (InputSelectionPolicy (..), import Pos.Core as Core (Config) import Pos.Core.Chrono (getNewestFirst, toNewestFirst) import Pos.Core.Common (Coin) -import Pos.Core.Txp (Tx (..), TxAux (..), TxOut (..), TxOutAux (..)) import Pos.Crypto (PassPhrase, 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 abeb297c5f8..835abb59fc1 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 (ProtocolConstants, pcEpochSlots) -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 fc200dbe312..9b9226f5c1f 100644 --- a/wallet/src/Pos/Wallet/Web/Pending/Submission.hs +++ b/wallet/src/Pos/Wallet/Web/Pending/Submission.hs @@ -19,13 +19,12 @@ import Control.Exception.Safe (Handler (..), catches, onException) import Data.Time.Units (fromMicroseconds) import Formatting (build, sformat, shown, stext, (%)) -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 as Core (Config (..), diffTimestamp, getCurrentTimestamp) -import Pos.Core.Txp (TxAux) import Pos.Infra.Util.LogSafe (buildSafe, logInfoSP, logWarningSP, secretOnlyF) import Pos.Util.Util (maybeThrow) 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 fc6f7f76458..8b4e0ba2493 100644 --- a/wallet/src/Pos/Wallet/Web/Pending/Worker.hs +++ b/wallet/src/Pos/Wallet/Web/Pending/Worker.hs @@ -15,7 +15,7 @@ import Data.Time.Units (Microsecond, Second, convertUnit) import Formatting (build, sformat, (%)) import Serokell.Util (enumerate, listJson) -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 as Core (ChainDifficulty (..), Config (..), import Pos.Core.Chrono (getOldestFirst) import Pos.Core.Conc (delay, forConcurrently) import Pos.Core.Configuration (HasConfiguration) -import Pos.Core.Txp (TxAux) import qualified Pos.DB.BlockIndex as DB import Pos.DB.Class (MonadDBRead) import Pos.Infra.Recovery.Info (MonadRecoveryInfo) diff --git a/wallet/src/Pos/Wallet/Web/Server/Handlers.hs b/wallet/src/Pos/Wallet/Web/Server/Handlers.hs index 79b6a73c866..1368ed22105 100644 --- a/wallet/src/Pos/Wallet/Web/Server/Handlers.hs +++ b/wallet/src/Pos/Wallet/Web/Server/Handlers.hs @@ -19,10 +19,9 @@ 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 as Core (Config (..)) -import Pos.Core.Txp (TxAux) import Pos.Util.CompileInfo (HasCompileInfo) import Pos.Wallet.WalletMode (blockchainSlotDuration) diff --git a/wallet/src/Pos/Wallet/Web/State/Storage.hs b/wallet/src/Pos/Wallet/Web/State/Storage.hs index 04d3e731d00..b688016c6c7 100644 --- a/wallet/src/Pos/Wallet/Web/State/Storage.hs +++ b/wallet/src/Pos/Wallet/Web/State/Storage.hs @@ -125,13 +125,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 8b05c26af66..6ee24459b7a 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/BListener.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/BListener.hs @@ -21,10 +21,9 @@ import Formatting (build, sformat, (%)) 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 (ProtocolConstants, 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 f3cf4bcadad..03fd5c151ca 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Decrypt.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Decrypt.hs @@ -20,12 +20,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, PublicKey, WithHash (..), deriveHDPassphrase, encToPublic, unpackHDAddressAttr) 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 3fc786b4c5b..29678e133c7 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Restore.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Restore.hs @@ -7,10 +7,10 @@ import UnliftIO (MonadUnliftIO) import qualified Data.Map as M import Pos.Chain.Block (headerHash) -import Pos.Chain.Txp (genesisUtxo, utxoToModifier) +import Pos.Chain.Txp (TxIn, TxOut (..), TxOutAux (..), genesisUtxo, + utxoToModifier) import Pos.Core as Core (Address, Config (..), HasDifficulty (..)) import Pos.Core.Genesis (GenesisData) -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 aaab0facdec..785fa75cb85 100644 --- a/wallet/src/Pos/Wallet/Web/Tracking/Sync.hs +++ b/wallet/src/Pos/Wallet/Web/Tracking/Sync.hs @@ -56,8 +56,8 @@ 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 as Core (Address, BlockCount (..), @@ -65,7 +65,6 @@ import Pos.Core as Core (Address, BlockCount (..), HasDifficulty (..), ProtocolConstants, Timestamp (..), configBlkSecurityParam, pcEpochSlots, 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 66a78d680f9..913cfabcbed 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 1d2b49ed946..fdc78597518 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Mode.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Mode.hs @@ -47,6 +47,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) @@ -59,7 +60,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 c4cdf76bbdb..09f1ff6a177 100644 --- a/wallet/test/Test/Pos/Wallet/Web/Util.hs +++ b/wallet/test/Test/Pos/Wallet/Web/Util.hs @@ -38,14 +38,14 @@ 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) 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, ShouldCheckPassphrase (..), emptyPassphrase, firstHardened) @@ -63,7 +63,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.Core.Dummy (dummyConfig, dummyGenesisData, dummyGenesisSecretsPoor) import Test.Pos.Util.QuickCheck.Property (assertProperty,