Skip to content

Commit

Permalink
Merge #1912 #1973 #1976
Browse files Browse the repository at this point in the history
1912: Add shelley package to nightly windows tests r=rvl a=rvl

### Overview

- Github actions steps need to be coded in yaml.
- Shelley tests were not in the list of steps.
- Fix local cluster setup for windows.


1973: do not migrate hardfork column as non-null r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

N/A

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have adjusted the migration of the hardfork countdown column.

# Comments

<!-- Additional comments or screenshots to attach if any -->

```
'hardfork_epoch'. Adding this field with a default value of NULL.
SQLite3 returned ErrorError while attempting to perform prepare "ALTER TABLE protocol_parameters ADD COLUMN hardfork_epoch INTEGER NOT NULL DEFAULT NULL ;": Cannot add a NOT NULL column with default value NULL
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


1976: use dummy time interpreter in database benchmarks. r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

N/A

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have used dummy time interpreter in database benchmarks.

# Comments

<!-- Additional comments or screenshots to attach if any -->

Database benchmarks are now running fine for me locally.

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: KtorZ <[email protected]>
  • Loading branch information
3 people authored Jul 28, 2020
4 parents a86120d + 70f7012 + 58bc883 + 4f32499 commit ca96c43
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ jobs:
run: '.\\cardano-wallet-core-test-unit.exe --color'
- name: 'cardano-wallet-byron:unit'
run: '.\\cardano-wallet-byron-test-unit.exe --color'
- name: 'cardano-wallet-byron:integration'
run: '.\\cardano-wallet-byron-test-integration.exe --color'
timeout-minutes: 60
- name: 'cardano-wallet-shelley:unit'
run: '.\\cardano-wallet-shelley-test-unit.exe --color'
- name: 'cardano-wallet-cli:unit'
run: '.\\cardano-wallet-cli-test-unit.exe --color'
- name: 'text-class:unit'
run: '.\\text-class-test-unit.exe --color'
- name: 'cardano-wallet-launcher:unit'
run: '.\\cardano-wallet-launcher-test-unit.exe --color'
continue-on-error: true
- name: 'cardano-wallet-shelley:integration'
run: '.\\cardano-wallet-shelley-test-integration.exe --color'
timeout-minutes: 60
- name: 'cardano-wallet-byron:integration'
run: '.\\cardano-wallet-byron-test-integration.exe --color'
timeout-minutes: 60
- name: 'cardano-wallet-jormungandr:unit'
run: '.\\cardano-wallet-jormungandr-test-unit.exe --color'
- name: 'cardano-wallet-jormungandr:integration'
Expand Down
14 changes: 8 additions & 6 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ migrateManually tr defaultFieldValues =
--
addActiveSlotCoefficientIfMissing :: Sqlite.Connection -> IO ()
addActiveSlotCoefficientIfMissing conn =
addColumn conn (DBField CheckpointActiveSlotCoeff) value
addColumn conn True (DBField CheckpointActiveSlotCoeff) value
where
value = toText
$ W.unActiveSlotCoefficient
Expand All @@ -447,7 +447,7 @@ migrateManually tr defaultFieldValues =
--
addDesiredPoolNumberIfMissing :: Sqlite.Connection -> IO ()
addDesiredPoolNumberIfMissing conn = do
addColumn conn (DBField ProtocolParametersDesiredNumberOfPools) value
addColumn conn True (DBField ProtocolParametersDesiredNumberOfPools) value
where
value = T.pack $ show $ defaultDesiredNumberOfPool defaultFieldValues

Expand All @@ -456,7 +456,7 @@ migrateManually tr defaultFieldValues =
--
addMinimumUTxOValueIfMissing :: Sqlite.Connection -> IO ()
addMinimumUTxOValueIfMissing conn = do
addColumn conn (DBField ProtocolParametersMinimumUtxoValue) value
addColumn conn True (DBField ProtocolParametersMinimumUtxoValue) value
where
value = T.pack $ show $ W.getCoin $ defaultMinimumUTxOValue defaultFieldValues

Expand All @@ -465,7 +465,7 @@ migrateManually tr defaultFieldValues =
--
addHardforkEpochIfMissing :: Sqlite.Connection -> IO ()
addHardforkEpochIfMissing conn = do
addColumn conn (DBField ProtocolParametersHardforkEpoch) value
addColumn conn False (DBField ProtocolParametersHardforkEpoch) value
where
value = case defaultHardforkEpoch defaultFieldValues of
Nothing -> "NULL"
Expand Down Expand Up @@ -499,10 +499,11 @@ migrateManually tr defaultFieldValues =
-- it's a common use-case.
addColumn
:: Sqlite.Connection
-> Bool
-> DBField
-> Text
-> IO ()
addColumn conn field value = do
addColumn conn notNull field value = do
isFieldPresent conn field >>= \case
TableMissing ->
traceWith tr $ MsgManualMigrationNotNeeded field
Expand All @@ -511,7 +512,8 @@ migrateManually tr defaultFieldValues =
query <- Sqlite.prepare conn $ T.unwords
[ "ALTER TABLE", tableName field
, "ADD COLUMN", fieldName field
, fieldType field, "NOT NULL", "DEFAULT", value
, fieldType field, if notNull then "NOT NULL" else ""
, "DEFAULT", value
, ";"
]
_ <- Sqlite.step query
Expand Down
21 changes: 20 additions & 1 deletion lib/core/test/bench/db/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,23 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Sequential
)
import Cardano.Wallet.Primitive.Model
( Wallet, initWallet, unsafeInitWallet )
import Cardano.Wallet.Primitive.Slotting
( singleEraInterpreter )
import Cardano.Wallet.Primitive.Types
( ActiveSlotCoefficient (..)
, ActiveSlotCoefficient (..)
, Address (..)
, BlockHeader (..)
, Coin (..)
, Direction (..)
, EpochLength (..)
, GenesisParameters (..)
, Hash (..)
, Range (..)
, SlotLength (..)
, SlotNo (..)
, SortOrder (..)
, StartTime (..)
, TransactionInfo
, Tx (..)
, TxIn (..)
Expand Down Expand Up @@ -119,12 +126,16 @@ import Data.ByteString
( ByteString )
import Data.Functor
( ($>) )
import Data.Functor.Identity
( Identity (..) )
import Data.Maybe
( fromMaybe )
import Data.Proxy
( Proxy (..) )
import Data.Quantity
( Quantity (..) )
import Data.Time.Clock.POSIX
( posixSecondsToUTCTime )
import Data.Time.Clock.System
( SystemTime (..), systemToUTCTime )
import Data.Typeable
Expand All @@ -146,6 +157,7 @@ import System.IO.Unsafe
import System.Random
( mkStdGen, randoms )

import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import qualified Data.Map.Strict as Map

Expand Down Expand Up @@ -337,7 +349,14 @@ setupDB = do
(ctx, db) <- newDBLayer nullTracer defaultFieldValues (Just f) ti
pure (f, ctx, db)
where
ti = error "timeInterpreter" -- EpochLength 500 was used here.
ti = pure . runIdentity . singleEraInterpreter (GenesisParameters
{ getGenesisBlockHash = Hash $ BS.replicate 32 0
, getGenesisBlockDate = StartTime $ posixSecondsToUTCTime 0
, getSlotLength = SlotLength 1
, getEpochLength = EpochLength 21600
, getEpochStability = Quantity 108
, getActiveSlotCoefficient = ActiveSlotCoefficient 1
})

defaultFieldValues :: DefaultFieldValues
defaultFieldValues = DefaultFieldValues
Expand Down
2 changes: 1 addition & 1 deletion lib/shelley/src/Cardano/Wallet/Shelley/Launch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ withCluster
withCluster tr severity poolConfigs dir onByron onFork onClusterStart =
bracketTracer' tr "withCluster" $ do
let poolCount = length poolConfigs
systemStart <- addUTCTime 1 <$> getCurrentTime
(port0:ports) <- randomUnusedTCPPorts (poolCount + 2)
systemStart <- addUTCTime 1 <$> getCurrentTime
let bftCfg = NodeParams severity systemStart (head $ rotate ports)
withBFTNode tr dir bftCfg $ \bftSocket block0 params -> do
let runningBftNode = RunningNode bftSocket block0 params
Expand Down
3 changes: 2 additions & 1 deletion nix/windows-testing-bundle.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
, cardano-wallet-byron
, cardano-wallet-shelley
, cardano-node
, cardano-cli
, tests ? []
, benchmarks ? []
}:
Expand Down Expand Up @@ -44,7 +45,7 @@ in pkgs.runCommand name {
cd jm
# Copy in wallet and node EXEs and DLLs.
for pkg in ${cardano-wallet-jormungandr} ${cardano-wallet-byron} ${cardano-wallet-shelley}; do
for pkg in ${cardano-wallet-jormungandr} ${cardano-wallet-byron} ${cardano-wallet-shelley} ${cardano-cli}; do
cp -vf $pkg/bin/* .
done
Expand Down
1 change: 1 addition & 0 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ let
cardano-wallet-byron = winJobs.cardano-wallet-byron.x86_64-linux;
cardano-wallet-shelley = winJobs.cardano-wallet-shelley.x86_64-linux;
cardano-node = winJobs.cardano-node.x86_64-linux;
cardano-cli = winJobs.cardano-cli.x86_64-linux;
tests = collectTests winJobs.tests;
benchmarks = collectTests winJobs.benchmarks;
};
Expand Down

0 comments on commit ca96c43

Please sign in to comment.