Skip to content

Commit

Permalink
Merge #2400
Browse files Browse the repository at this point in the history
2400: Make wallet run on Mary r=Anviking a=Anviking

# Issue Number

ADP-623

# Overview

- [x] Make the wallet run on Mary,
- [x] MA Value types are converted to/from TokenBundles.
- [x] Roundtrip tests for Value/TokenBundle
- [x] Fix disabled era error https://input-output-rnd.slack.com/archives/CFKLUH4R0/p1608146419455500
- [x] Test cluster does hard forks at start up - instantly.
- [x] Uses latest cardano-node master branch, with IntersectMBO/cardano-node#2270 merged.

# Comments

- I imagine properly thinking about and removing the duplication would be pretty fun. (rvl: we can do that in the next PR)
- Local test cluster changes for testing in multiple eras ⇒ #2438



Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: Johannes Lund <[email protected]>
  • Loading branch information
3 people authored Jan 12, 2021
2 parents 4e49b1f + d818cb7 commit f7fdc3c
Show file tree
Hide file tree
Showing 73 changed files with 846 additions and 459 deletions.
4 changes: 3 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ steps:
system: x86_64-linux

- label: 'Check auto-generated Nix'
command: './nix/regenerate.sh && nix-build ./nix -A iohkNix.checkStackProject -o check-stack-project.sh && ./check-stack-project.sh'
commands:
- './nix/regenerate.sh --cache /dev/null'
- 'nix-build ./nix -A iohkNix.checkStackProject -o check-stack-project.sh && ./check-stack-project.sh'
agents:
system: x86_64-linux

Expand Down
158 changes: 158 additions & 0 deletions cardano-1.25.0-pre.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# cardano-node master branch on 2020-01-12
name: cardano-1.25.0-pre

resolver: lts-14.25

packages:
- base16-0.1.2.1
- base16-bytestring-1.0.1.0
- base58-bytestring-0.1.0
- base64-0.4.2
- bech32-1.1.0
- bech32-th-1.0.2
- binary-0.8.7.0
- bimap-0.4.0
- canonical-json-0.6.0.0
- cborg-0.2.4.0
- clock-0.8
- config-ini-0.2.4.0
- connection-0.3.1
- containers-0.5.11.0
- data-clist-0.1.2.2
- dns-3.0.4
- generic-monoid-0.1.0.0
- generics-sop-0.5.1.0
- ghc-byteorder-4.11.0.0.10
- gray-code-0.3.1
- hedgehog-1.0.2
- hedgehog-corpus-0.2.0
- hedgehog-quickcheck-0.1.1
- hspec-2.7.0
- hspec-core-2.7.0
- hspec-discover-2.7.0
- io-streams-1.5.1.0
- io-streams-haproxy-1.0.1.0
- katip-0.8.4.0
- libsystemd-journal-1.4.4
- micro-recursion-schemes-5.0.2.2
- moo-1.2
- network-3.1.2.1
- partial-order-0.2.0.0
- primitive-0.7.1.0
- prometheus-2.1.2
- protolude-0.3.0
- quickcheck-instances-0.3.19
- QuickCheck-2.12.6.1
- quiet-0.2
- semialign-1.1.0.1
- snap-core-1.0.4.1
- snap-server-1.1.1.1
- sop-core-0.5.0.1
- statistics-linreg-0.3
- streaming-binary-0.2.2.0
- streaming-bytestring-0.2.0
- systemd-2.3.0
- tasty-hedgehog-1.0.0.2
- text-1.2.4.0
- text-ansi-0.1.0
- text-conversions-0.3.1
- text-zipper-0.10.1
- th-lift-instances-0.1.14
- these-1.1.1.1
- time-units-1.0.0
- transformers-except-0.1.1
- unordered-containers-0.2.12.0
- Unique-0.4.7.6
- word-wrap-0.4.1
- websockets-0.12.6.1
- Win32-2.6.2.0
- nothunks-0.1.2

- git: https://github.com/input-output-hk/cardano-base
commit: 6a6ea9695ee898dd7d4fd7a5d2cc639d7d5764f7
subdirs:
- binary
- binary/test
- cardano-crypto-class
- cardano-crypto-tests
- cardano-crypto-praos
- slotting

- git: https://github.com/input-output-hk/cardano-crypto
commit: 2547ad1e80aeabca2899951601079408becbc92c

- git: https://github.com/input-output-hk/cardano-ledger-specs
commit: a638b9fa854fced8b8165631885268e3814f2d90
subdirs:
- byron/chain/executable-spec
- byron/crypto
- byron/crypto/test
- byron/ledger/executable-spec
- byron/ledger/impl
- byron/ledger/impl/test
- semantics/executable-spec
- semantics/small-steps-test
- shelley/chain-and-ledger/dependencies/non-integer
- shelley/chain-and-ledger/executable-spec
- shelley/chain-and-ledger/shelley-spec-ledger-test
- shelley-ma/impl

- git: https://github.com/input-output-hk/cardano-node
commit: 695a882dcf93bd645108b14821e3730af56b8eaa
subdirs:
- cardano-api
- cardano-api/test
- cardano-cli
- cardano-config
- cardano-node
- cardano-node-chairman
- hedgehog-extras

- git: https://github.com/input-output-hk/cardano-prelude
commit: ee4e7b547a991876e6b05ba542f4e62909f4a571
subdirs:
- cardano-prelude
- cardano-prelude-test

- git: https://github.com/input-output-hk/cardano-sl-x509
commit: 43a036c5bbe68ca2e9cbe611eab7982e2348fe49

- git: https://github.com/input-output-hk/goblins
commit: cde90a2b27f79187ca8310b6549331e59595e7ba

- git: https://github.com/input-output-hk/iohk-monitoring-framework
commit: a89c38ed5825ba17ca79fddb85651007753d699d
subdirs:
- contra-tracer
- iohk-monitoring
- plugins/backend-aggregation
- plugins/backend-ekg
- plugins/backend-monitoring
- plugins/backend-trace-forwarder
- plugins/scribe-systemd
- tracer-transformers

- git: https://github.com/input-output-hk/ouroboros-network
commit: 4fdc309f855792ed30271c30dcd9159232404787
subdirs:
- io-sim
- io-sim-classes
- network-mux
- ouroboros-consensus
- ouroboros-consensus-byron
- ouroboros-consensus-cardano
- ouroboros-consensus-shelley
- ouroboros-network
- ouroboros-network-framework
- typed-protocols
- typed-protocols-examples
- Win32-network
# Extra packages not used by cardano-node
- cardano-client
- ntp-client
- ouroboros-consensus-mock

- git: https://github.com/snoyberg/http-client.git
commit: 1a75bdfca014723dd5d40760fad854b3f0f37156
subdirs:
- http-client
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ mkTxMetaEntity wid txid mfee meta derived = TxMeta
, txMetaAmount = getQuantity (derived ^. #amount)
, txMetaFee = fromIntegral . W.unCoin <$> mfee
, txMetaSlotExpires = derived ^. #expiry
, txMetaData = meta
, txMetadata = meta
}

-- note: TxIn records must already be sorted by order
Expand All @@ -1669,7 +1669,7 @@ txHistoryFromEntity ti tip metas ins outs ws =
mapM mkItem metas
where
startTime' = interpretQuery ti . slotToUTCTime
mkItem m = mkTxWith (txMetaTxId m) (txMetaFee m) (txMetaData m) (mkTxDerived m)
mkItem m = mkTxWith (txMetaTxId m) (txMetaFee m) (txMetadata m) (mkTxDerived m)
mkTxWith txid mfee meta derived = do
t <- startTime' (derived ^. #slotNo)
return $ W.TransactionInfo
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet/DB/Sqlite/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TxMeta
txMetaSlot SlotNo sql=slot
txMetaBlockHeight Word32 sql=block_height
txMetaAmount Natural sql=amount
txMetaData W.TxMetadata Maybe sql=data
txMetadata W.TxMetadata Maybe sql=data
txMetaSlotExpires SlotNo Maybe sql=slot_expires
txMetaFee Natural Maybe sql=fee

Expand Down
29 changes: 13 additions & 16 deletions lib/core/src/Cardano/Wallet/Primitive/Types/TokenPolicy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
module Cardano.Wallet.Primitive.Types.TokenPolicy
(
-- * Token Policies
TokenPolicyId
TokenPolicyId (..)

-- * Token Names
, TokenName
, TokenName (..)

) where

Expand All @@ -33,12 +33,11 @@ import GHC.Generics
import Quiet
( Quiet (..) )

--------------------------------------------------------------------------------
-- Token policy identifiers
--------------------------------------------------------------------------------

newtype TokenPolicyId = TokenPolicyId
{ unTokenPolicyId :: Hash "TokenPolicy" }
-- | Token policy identifiers, represented by the hash of the monetary policy
-- script.
newtype TokenPolicyId =
-- | Construct a 'TokenPolicyId' without any validation.
UnsafeTokenPolicyId { unTokenPolicyId :: Hash "TokenPolicy" }
deriving stock (Eq, Ord, Generic)
deriving (Read, Show) via (Quiet TokenPolicyId)

Expand All @@ -57,14 +56,12 @@ instance ToText TokenPolicyId where
toText = toText . unTokenPolicyId

instance FromText TokenPolicyId where
fromText = fmap TokenPolicyId . fromText

--------------------------------------------------------------------------------
-- Token names
--------------------------------------------------------------------------------
fromText = fmap UnsafeTokenPolicyId . fromText

newtype TokenName = TokenName
{ unTokenName :: Text }
-- | Token names, defined by the monetary policy script.
newtype TokenName =
-- | Construct a 'TokenName' without any validation.
UnsafeTokenName { unTokenName :: Text }
deriving stock (Eq, Ord, Generic)
deriving (Read, Show) via (Quiet TokenName)

Expand All @@ -83,4 +80,4 @@ instance ToText TokenName where
toText = unTokenName

instance FromText TokenName where
fromText = pure . TokenName
fromText = pure . UnsafeTokenName
2 changes: 1 addition & 1 deletion lib/core/test/unit/Cardano/WalletSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Prelude

import Cardano.Address.Derivation
( XPrv, xpubToBytes )
import Cardano.API
import Cardano.Api
( AnyCardanoEra (..), CardanoEra (..) )
import Cardano.BM.Trace
( nullTracer )
Expand Down
11 changes: 4 additions & 7 deletions lib/shelley/bench/Latency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,16 @@ withShelleyServer tracers action = do
[]
dir
Nothing
onByron
(afterFork dir)
(onClusterStart act db)
onByron _ = pure ()
afterFork dir _ = do
(onClusterStart act dir)

setupFaucet dir = do
let encodeAddr = T.unpack . encodeAddress @'Mainnet
let addresses = map (first encodeAddr) shelleyIntegrationTestFunds
sendFaucetFundsTo nullTracer dir addresses

onClusterStart act db (RunningNode socketPath block0 (gp, vData)) = do
listen <- walletListenFromEnv
-- NOTE: We may want to keep a wallet running across the fork, but
-- having three callbacks like this might not work well for that.
setupFaucet db
serveWallet
(SomeNetworkDiscriminant $ Proxy @'Mainnet)
tracers
Expand Down
8 changes: 3 additions & 5 deletions lib/shelley/exe/shelley-test-cluster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,9 @@ main = withLocalClusterSetup $ \dir clusterLogs walletLogs ->
poolConfigs
dir
Nothing
whenByron
(whenShelley dir (trMessageText trCluster))
(whenReady dir (trMessageText trCluster) walletLogs)
where
whenByron _ = pure ()

whenShelley dir trCluster _ = do
setupFaucet dir trCluster = do
traceWith trCluster MsgSettingUpFaucet
let trCluster' = contramap MsgCluster trCluster
let encodeAddr = T.unpack . encodeAddress @'Mainnet
Expand All @@ -226,6 +222,8 @@ main = withLocalClusterSetup $ \dir clusterLogs walletLogs ->

whenReady dir trCluster logs (RunningNode socketPath block0 (gp, vData)) =
withLoggingNamed "cardano-wallet" logs $ \(sb, (cfg, tr)) -> do
setupFaucet dir trCluster

ekgEnabled >>= flip when (EKG.plugin cfg tr sb >>= loadPlugin sb)

let tracers = setupTracers (tracerSeverities (Just Debug)) tr
Expand Down
Loading

0 comments on commit f7fdc3c

Please sign in to comment.