Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardano.Api -> Cardano.Api.Typed and HardForkBlock #1909

Merged
merged 87 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
22f1ad3
Bump cardano-node to latest master
rvl Jul 15, 2020
e19290b
Regenerate nix
rvl Jul 18, 2020
1cf38d1
Bump iohk-nix
rvl Jul 18, 2020
ba14f34
Cardano.Api → Cardano.Api.Typed and HardForkBlock support
rvl Jul 15, 2020
6941c2b
Revert Cardano.Wallet.Shelley.Transaction back to master, start again.
rvl Jul 20, 2020
71113ed
Start converting Shelley TransactionLayer to new Cardano.Api.Typed
Anviking Jul 20, 2020
a0b5c83
Add toCardanoNetworkId and remove @n from tl
Anviking Jul 20, 2020
cef8ce7
bump iohk-nix
rvl Jul 20, 2020
4bbb56d
Debugging
rvl Jul 20, 2020
e048c92
Bump cardano-node to latest master
rvl Jul 20, 2020
1ced70d
Fix cli genesis
rvl Jul 20, 2020
51dff8d
Fix shelley genesis file in $CARDANO_NODE_CONFIGS
rvl Jul 20, 2020
9bdd026
Logging more info
rvl Jul 20, 2020
c5f815d
Update shelley transactionspec
rvl Jul 20, 2020
671e6c8
Fill in a few more gaps in Shelley tl
Anviking Jul 20, 2020
059fc96
TransactionSpec: replace type errors with runtime errors
rvl Jul 20, 2020
6054462
Test compile fixes
rvl Jul 20, 2020
50efea0
Re-add construction of dummy byron witnesses
Anviking Jul 20, 2020
77325a8
Remove redundant imports
Anviking Jul 20, 2020
a9afb7d
Add HasNetworkId class replacing toCardanoNetworkId
Anviking Jul 20, 2020
13739f4
Build fixes
rvl Jul 21, 2020
78af00b
Remove shelley genesis CLI options - only use byron genesis
rvl Jul 21, 2020
4f8d715
Fix FIXMEs in unit tests, re-add shelley toSealed
Anviking Jul 21, 2020
2cd1ffe
Update (slightly) failing fee estimation goldens
Anviking Jul 21, 2020
4e9b64f
Fix compile
rvl Jul 21, 2020
c639444
toShelleyGenTx -> unsealShelleyTx
rvl Jul 21, 2020
ae919a3
PostTx type family
rvl Jul 19, 2020
8ec27d0
Rename
rvl Jul 21, 2020
88b98cb
Revert "PostTx type family"
rvl Jul 21, 2020
75d3b89
fixup
rvl Jul 21, 2020
b544b38
Fix toSealed
rvl Jul 21, 2020
ca03f0c
Include byron address attributes in tx witnesses
rvl Jul 21, 2020
81646b1
fix stylish-haskell issues in Primitive.Slotting
KtorZ Jul 21, 2020
615e864
slightly refactor 'mkByronWitness' to be consistent with 'mkShelleyWi…
KtorZ Jul 21, 2020
85ed3e8
fix fee estimation for byron;shelley transaction layer
KtorZ Jul 21, 2020
4fdaf3e
revert adding 'block' type parameter to GetStakeDistribution type family
KtorZ Jul 21, 2020
6416a80
fix staging configuration parsing for cardano-wallet-shelley
KtorZ Jul 21, 2020
6bd5fb8
revert shelley bootstrap witness creation, re-use makeBootstrapWitness
KtorZ Jul 21, 2020
78af3f5
Add support for Byron;Shelley integration test cluster
Anviking Jul 18, 2020
25183c0
Print cartouche when waiting for hard-fork to finish
Anviking Jul 21, 2020
5d1e611
wip: add working sendFaucetFundsTo
Anviking Jul 22, 2020
728c953
some cosmetic changes while reviewing code
KtorZ Jul 22, 2020
46dc9a7
Remove shelley wallets from shelley genesis (now automatic)
Anviking Jul 22, 2020
a4f2378
wip: Add byron faucet funds
Anviking Jul 22, 2020
ce022fe
Fixup: Add NO_POOLS option, and remove dev functions
Anviking Jul 22, 2020
0c0571d
fixup Crypto.HD
Anviking Jul 22, 2020
2abee4f
remove multi-mode support (default to byron;shelley) and rename setup…
KtorZ Jul 22, 2020
468669d
Fixup: remove submitTxNoRetry
Anviking Jul 22, 2020
067353f
Automate generation of shelley faucet funds
Anviking Jul 22, 2020
cb7f8cc
Re-add call to prepareKeyRegistration, fix mistake in addr
Anviking Jul 22, 2020
c6e59d9
Adjust documentation in shelley-genesis
Anviking Jul 22, 2020
1f5531f
replace hard-coded occurences of 'Secure Passphrase' with a named con…
KtorZ Jul 22, 2020
f232302
add little correction to size estimation for Byron change addresses
KtorZ Jul 22, 2020
76f188f
get rid of Shelley's fee estimator from test integration
KtorZ Jul 22, 2020
a870993
replace fee estimator from Scenario/API/Shelley/Transactions with API…
KtorZ Jul 22, 2020
3bc5fd1
fix 'slotRangeFromTimeRange' time interpreter query
KtorZ Jul 22, 2020
66fe2a5
Use genesis block parameters for waitForHardFork in tests
rvl Jul 23, 2020
9f99b2f
fix race-condition in big wallet migration scenario + temporarily dis…
KtorZ Jul 23, 2020
79ea9b7
Fix hard for sleep delay
rvl Jul 23, 2020
f5fda2b
Make sure to use the correct timeInterpreter in DB
Anviking Jul 23, 2020
12108e4
Simplify confusing TestShelleyHardFork setup (still trigger manually)
Anviking Jul 23, 2020
42b3ea6
Fixup unused imports in slotting
Anviking Jul 23, 2020
6a7c75d
Use SlotNo without qualified Cardano prefix in Slotting module
Anviking Jul 23, 2020
3041453
get rid of #feeEstimator in shelley specs for stake pools
KtorZ Jul 23, 2020
016063b
remove invalid function 'toCardanoStakeAddress'
KtorZ Jul 23, 2020
ce5ea16
increase maxLovelaceSupply in shelley to have a non-null reserve (& r…
KtorZ Jul 23, 2020
7169334
bump to cardano-1.17.0
KtorZ Jul 23, 2020
35e1b12
reduce 'eventually' timeout upper bound to a more reasonable value
KtorZ Jul 23, 2020
a7ecfe2
use time interpreter in the network information endpoint instead of t…
KtorZ Jul 23, 2020
1db9616
compare epoch numbers in the shelley stake pools specifications inste…
KtorZ Jul 23, 2020
32238d3
fix stylish-haskell & hlint & weeder
KtorZ Jul 24, 2020
6355a74
fixup! Regenerate nix
Jul 24, 2020
37fa444
use BYRON genesis for initial cluster funds
KtorZ Jul 24, 2020
876321a
add more debug & info logs during for more visibility during migration
KtorZ Jul 24, 2020
5966130
nuke blatant lurking bug in the migration algorithm... sitting there …
KtorZ Jul 24, 2020
9a685cc
add 'leftovers' to api migration information
KtorZ Jul 24, 2020
c96a5bb
re-enable 'big wallet' migration test, now that everything is fixed.
KtorZ Jul 24, 2020
f26697d
tweak fee estimation on migrations so that it assumes worst case scen…
KtorZ Jul 24, 2020
f8b34da
align Byron migration scenarios with recent changes done on their She…
KtorZ Jul 24, 2020
11f35b4
turn on integration scenarios using Byron wallets (and requiring boot…
KtorZ Jul 24, 2020
7ab39b1
make feeOpt dependent on minimum utxo
paweljakubas Jul 24, 2020
dc9e571
add non-null dust & property reflecting it for 'rebalanceSelection'
KtorZ Jul 24, 2020
ec9ea5d
acknowledge dust threshold in fee balancing
KtorZ Jul 24, 2020
70235f0
revert refactor on 'rebalanceSelection' and coalesce dust AFTER rebal…
KtorZ Jul 25, 2020
c4e978a
Merge pull request #1947 from input-output-hk/paweljakubas/proper-tre…
KtorZ Jul 25, 2020
bca0b7a
adjust pool pool retirement configuration and retire first pool when …
KtorZ Jul 25, 2020
4eb4bf3
use correct pool id instead of arbitrary one and fix new file names f…
KtorZ Jul 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 6 additions & 10 deletions cardano-1.15.x.yaml → cardano-1.17.x.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cardano-1.15.x
name: cardano-1.17.x

resolver: lts-14.25

Expand Down Expand Up @@ -54,7 +54,7 @@ packages:
- word-wrap-0.4.1

- git: https://github.com/input-output-hk/cardano-base
commit: 5e0b8bc8c7862be12da6989440f8644ba7c1e1cf
commit: 7d795c3040ea7785812efa1c97864bbb41b15d3e
subdirs:
- binary
- binary/test
Expand All @@ -66,7 +66,7 @@ packages:
commit: 2547ad1e80aeabca2899951601079408becbc92c

- git: https://github.com/input-output-hk/cardano-ledger-specs
commit: 12b13f390d64df6af6054b0d33bb3767756da041
commit: a790fb38cced04d8d8a9aeacc2a761717f11f94e
subdirs:
- byron/ledger/impl
- byron/crypto
Expand All @@ -75,12 +75,13 @@ packages:
- byron/chain/executable-spec
- byron/ledger/executable-spec
- semantics/executable-spec
- semantics/small-steps-test
- shelley/chain-and-ledger/dependencies/non-integer
- shelley/chain-and-ledger/executable-spec
- shelley/chain-and-ledger/executable-spec/test

- git: https://github.com/input-output-hk/cardano-node
commit: 97b3e95c67940608f5acda929cf861e8ebfeddd1
commit: 0191ff56d194b6ac074af0d51e67493c14e08ffa
subdirs:
- cardano-api
- cardano-cli
Expand All @@ -93,11 +94,6 @@ packages:
- .
- test

- git: https://github.com/input-output-hk/cardano-shell
commit: 5257fc818ef7df60986834310432e197aac90711
subdirs:
- cardano-shell

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

Expand All @@ -117,7 +113,7 @@ packages:
- plugins/backend-trace-forwarder

- git: https://github.com/input-output-hk/ouroboros-network
commit: 1361bb92814c65e5964732777fc7f8ec9ebdccfe
commit: 34e380f54ed24772479763ba6d67f4893d82aac2
subdirs:
- io-sim
- io-sim-classes
Expand Down
4 changes: 2 additions & 2 deletions lib/byron/src/Cardano/Wallet/Byron/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ server byron icarus ntp =
byronMigrations :: Server (ByronMigrations n)
byronMigrations =
(\wid -> withLegacyLayer wid
(byron , getMigrationInfo byron wid)
(icarus, getMigrationInfo icarus wid)
(byron , getMigrationInfo @_ @_ @_ @n byron wid)
(icarus, getMigrationInfo @_ @_ @_ @n icarus wid)
)
:<|> (\wid m -> withLegacyLayer wid
(byron , migrateWallet byron wid m)
Expand Down
6 changes: 3 additions & 3 deletions lib/byron/src/Cardano/Wallet/Byron/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ import Network.Mux
( MuxError (..), MuxErrorType (..), WithMuxBearer )
import Ouroboros.Consensus.Byron.Ledger
( ByronBlock (..)
, ByronNodeToClientVersion (ByronNodeToClientVersion2)
, ByronNodeToClientVersion (ByronNodeToClientVersion1)
, GenTx
, Query (..)
)
Expand Down Expand Up @@ -354,7 +354,7 @@ mkWalletClient gp chainSyncQ = do
} = gp

codecs :: MonadST m => ClientCodecs ByronBlock m
codecs = clientCodecs (byronCodecConfig gp) ByronNodeToClientVersion2
codecs = clientCodecs (byronCodecConfig gp) ByronNodeToClientVersion1

-- A low-level DEBUG chain sync tracer.
--
Expand Down Expand Up @@ -444,7 +444,7 @@ mkTipSyncClient tr np localTxSubmissionQ onTipUpdate onProtocolParamsUpdate = do
} = W.genesisParameters np

codecs :: MonadST m => DefaultCodecs ByronBlock m
codecs = defaultCodecs (byronCodecConfig gp) ByronNodeToClientVersion2
codecs = defaultCodecs (byronCodecConfig gp) ByronNodeToClientVersion1

debounce :: (Eq a, MonadSTM m) => (a -> m ()) -> m (a -> m ())
debounce action = do
Expand Down
99 changes: 73 additions & 26 deletions lib/core-integration/src/Test/Integration/Faucet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}

Expand All @@ -16,11 +17,15 @@ module Test.Integration.Faucet
, icaMnemonics
, rndMnemonics

-- * Integration test funds
, shelleyIntegrationTestFunds

-- * Internals
, genByronFaucets
, genIcarusFaucets
, genShelleyFaucets
, genMnemonics
, genShelleyAddresses
) where

import Prelude hiding
Expand Down Expand Up @@ -48,9 +53,9 @@ import Cardano.Wallet.Primitive.AddressDerivation
, liftIndex
)
import Cardano.Wallet.Primitive.Types
( Address (..), Coin )
( Address (..), Coin (..) )
import Cardano.Wallet.Unsafe
( unsafeMkMnemonic )
( unsafeFromHex, unsafeMkMnemonic )
import Control.Concurrent.MVar
( MVar, putMVar, takeMVar )
import Control.Monad
Expand Down Expand Up @@ -1388,38 +1393,31 @@ genIcarusFaucets = genFaucet encodeAddress genAddresses
--
-- >>> genMnemonics 100 >>= genShelleyFaucets "shelley-faucets.yaml"
genShelleyFaucets :: FilePath -> [Mnemonic 15] -> IO ()
genShelleyFaucets = genFaucet encodeAddress genAddresses
genShelleyFaucets = genFaucet encodeAddress genShelleyAddresses
where
encodeAddress :: Address -> Text
encodeAddress (Address bytes) =
T.decodeUtf8 $ convertToBase Base16 bytes

genAddresses :: Mnemonic 15 -> [Address]
genAddresses mw =
let
(seed, pwd) =
(SomeMnemonic mw, mempty)
rootXPrv =
Shelley.generateKeyFromSeed (seed, Nothing) pwd
accXPrv =
deriveAccountPrivateKey pwd rootXPrv minBound
addrXPrv =
deriveAddressPrivateKey pwd accXPrv UTxOExternal
in
[ paymentAddress @'Mainnet $ publicKey $ addrXPrv ix
| ix <- [minBound..maxBound]
]
genShelleyAddresses :: Mnemonic 15 -> [Address]
genShelleyAddresses mw =
let
(seed, pwd) =
(SomeMnemonic mw, mempty)
rootXPrv =
Shelley.generateKeyFromSeed (seed, Nothing) pwd
accXPrv =
deriveAccountPrivateKey pwd rootXPrv minBound
addrXPrv =
deriveAddressPrivateKey pwd accXPrv UTxOExternal
in
[ paymentAddress @'Mainnet $ publicKey $ addrXPrv ix
| ix <- [minBound..maxBound]
]

-- | Abstract function for generating a faucet.
genFaucet
:: forall mw ent csz.
( ValidMnemonicSentence mw
, ValidEntropySize ent
, ValidChecksumSize ent csz
, ent ~ EntropySize mw
, mw ~ MnemonicWords ent
)
=> (Address -> Text)
:: (Address -> Text)
-> (Mnemonic mw -> [Address])
-> FilePath
-> [Mnemonic mw]
Expand Down Expand Up @@ -1451,6 +1449,55 @@ genMnemonics
genMnemonics n =
replicateM n (entropyToMnemonic @mw <$> genEntropy)

--
-- Integration test funds
--

-- | A special wallet with only dust
onlyDustWallet :: Mnemonic 15
onlyDustWallet = unsafeMkMnemonic
[ "either" , "flip" , "maple" , "shift" , "dismiss"
, "bridge" , "sweet" , "reveal" , "green" , "tornado"
, "need" , "patient" , "wall" , "stamp" , "pass"
]

-- | A special Shelley Wallet with 200 UTxOs where 100 of them are dust
bigDustWallet :: Mnemonic 15
bigDustWallet = unsafeMkMnemonic
[ "radar", "scare", "sense", "winner", "little"
, "jeans", "blue", "spell", "mystery", "sketch"
, "omit", "time", "tiger", "leave", "load"
]

shelleyIntegrationTestFunds :: [(Address, Coin)]
shelleyIntegrationTestFunds = mconcat
[ seqMnemonics >>= (take 10 . map (, defaultAmt) . addresses)

, zip (addresses onlyDustWallet) (map Coin [1,1,5,12,1,5,3,10,2,3])

, take 100 (map (, defaultAmt) $ addresses bigDustWallet)
, take 100 . drop 100 $ map (,Coin 1) $ addresses bigDustWallet

, preregKeyWalletFunds
]
where
defaultAmt = Coin 100000000000
addresses = genShelleyAddresses

-- Funds for wallet with a pre-registered stake key.
--
-- _preregKeyWallet :: Mnemonic 15
-- _preregKeyWallet = unsafeMkMnemonic
-- ["over", "decorate", "flock", "badge", "beauty"
-- , "stamp", "chest", "owner", "excess", "omit"
-- , "bid", "raccoon", "spin", "reduce", "rival"
-- ]
--
preregKeyWalletFunds = map ((,defaultAmt) . Address . unsafeFromHex)
[ "6199a7c32aaa55a628d936b539f01d5415318dec8bcb5e59ec71af695b"
, "61386c7a86d8844f4085a50241556043c9842d72c315c897a42a8a0510"
]

--
-- Helpers
--
Expand Down
21 changes: 14 additions & 7 deletions lib/core-integration/src/Test/Integration/Framework/DSL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,19 @@ eventuallyUsingDelay
-> IO a
eventuallyUsingDelay delay desc io = do
lastErrorRef <- newIORef Nothing
winner <- race (threadDelay $ 300 * oneSecond) (trial lastErrorRef)
-- NOTE
-- This __90s__ is mostly justified by the parameters in the shelley
-- genesis. The longest action we have two wait for are about 2 epochs,
-- which corresponds to 80s with the current parameters. Using something
-- much longer than that isn't really useful (in particular, this doesn't
-- depend on the host machine running the test, because the protocol moves
-- forward at the same speed regardless...)
winner <- race (threadDelay $ 90 * oneSecond) (trial lastErrorRef)
case winner of
Left () -> do
lastError <- readIORef lastErrorRef
fail $ mconcat
[ "Waited longer than 5 minutes for action to resolve. "
[ "Waited longer than 2 minutes for an action to resolve. "
, "Action: "
, show desc
, ". Error condition: "
Expand Down Expand Up @@ -671,25 +678,25 @@ emptyRandomWallet :: Context t -> IO ApiByronWallet
emptyRandomWallet ctx = do
mnemonic <- mnemonicToText @12 . entropyToMnemonic <$> genEntropy
emptyByronWalletWith ctx "random"
("Random Wallet", mnemonic, "Secure Passphrase")
("Random Wallet", mnemonic, fixturePassphrase)

emptyRandomWalletMws :: Context t -> IO (ApiByronWallet, Mnemonic 12)
emptyRandomWalletMws ctx = do
mnemonic <- entropyToMnemonic <$> genEntropy
(,mnemonic) <$> emptyByronWalletWith ctx "random"
("Random Wallet", mnemonicToText @12 mnemonic, "Secure Passphrase")
("Random Wallet", mnemonicToText @12 mnemonic, fixturePassphrase)

emptyIcarusWallet :: Context t -> IO ApiByronWallet
emptyIcarusWallet ctx = do
mnemonic <- mnemonicToText @15 . entropyToMnemonic <$> genEntropy
emptyByronWalletWith ctx "icarus"
("Icarus Wallet", mnemonic, "Secure Passphrase")
("Icarus Wallet", mnemonic, fixturePassphrase)

emptyIcarusWalletMws :: Context t -> IO (ApiByronWallet, Mnemonic 15)
emptyIcarusWalletMws ctx = do
mnemonic <- entropyToMnemonic <$> genEntropy
(,mnemonic) <$> emptyByronWalletWith ctx "icarus"
("Icarus Wallet",mnemonicToText @15 mnemonic, "Secure Passphrase")
("Icarus Wallet",mnemonicToText @15 mnemonic, fixturePassphrase)

emptyRandomWalletWithPasswd :: Context t -> Text -> IO ApiByronWallet
emptyRandomWalletWithPasswd ctx rawPwd = do
Expand Down Expand Up @@ -756,7 +763,7 @@ emptyWallet ctx = do
let payload = Json [aesonQQ| {
"name": "Empty Wallet",
"mnemonic_sentence": #{mnemonic},
"passphrase": "Secure Passphrase"
"passphrase": #{fixturePassphrase}
}|]
r <- request @ApiWallet ctx
(Link.postWallet @'Shelley) Default payload
Expand Down
14 changes: 9 additions & 5 deletions lib/core-integration/src/Test/Integration/Framework/TestData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import Data.Text
import Numeric.Natural
( Natural )
import Test.Integration.Framework.DSL
( Payload (..), json )
( Payload (..), fixturePassphrase, json )

falseWalletIds :: [(String, String)]
falseWalletIds =
Expand Down Expand Up @@ -216,14 +216,14 @@ payloadWith :: Text -> [Text] -> Payload
payloadWith name mnemonics = Json [json| {
"name": #{name},
"mnemonic_sentence": #{mnemonics},
"passphrase": "Secure passphrase"
"passphrase": #{fixturePassphrase}
} |]

simplePayload :: Payload
simplePayload = Json [json| {
"name": "Secure Wallet",
"mnemonic_sentence": #{mnemonics21},
"passphrase": "Secure passphrase"
"passphrase": #{fixturePassphrase}
} |]

updateNamePayload :: Text -> Payload
Expand Down Expand Up @@ -287,12 +287,16 @@ errMsg403NotEnoughMoney_ =
"I can't process this payment because there's not enough UTxO available in \
\the wallet."

errMsg403NotEnoughMoney :: Int -> Int -> String
errMsg403NotEnoughMoney :: Integral i => i -> i -> String
errMsg403NotEnoughMoney has needs = "I can't process this payment because there's\
\ not enough UTxO available in the wallet. The total UTxO sums up to\
\ " ++ show has ++ " Lovelace, but I need " ++ show needs ++ " Lovelace\
\ " ++ has' ++ " Lovelace, but I need " ++ needs' ++ " Lovelace\
\ (excluding fee amount) in order to proceed with the payment."

where
needs' = show (toInteger needs)
has' = show (toInteger has)

errMsg403TxTooBig :: Int -> String
errMsg403TxTooBig n = "I had to select " ++ show n ++ " inputs to construct the\
\ requested transaction. Unfortunately, this would create a transaction\
Expand Down
Loading