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

Replace 'Maybe Bool' with a dedicated sum-type. #1717

Merged
merged 3 commits into from
Jun 3, 2020

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Jun 3, 2020

Issue Number

#1701

Overview

  • 9aaf4ad
    📍 log when no migration is needed

  • 7c3d459
    📍 replace 'Maybe Bool' with a dedicated sum-type for more clarity

Comments

Caught me one time already... Won't caught anyone else.

@KtorZ KtorZ added the RESOLVING ISSUE Mark a PR as resolving issues, for auto-generated CHANGELOG label Jun 3, 2020
@KtorZ KtorZ self-assigned this Jun 3, 2020
@KtorZ KtorZ force-pushed the KtorZ/1701/passphrase-scheme-fix branch from 7c3d459 to 0c24254 Compare June 3, 2020 10:40
Comment on lines 312 to 314
= TableDoesntExist
| ColumnDoesntExist
| ColumnExists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this wording would be a little more concise:

Suggested change
= TableDoesntExist
| ColumnDoesntExist
| ColumnExists
= TableMissing
| ColumnMissing
| ColumnPresent

@@ -306,6 +306,13 @@ findDatabases tr dir = do
where
expectedPrefix = T.pack $ keyTypeDescriptor $ Proxy @k

-- | A data-type for capturing column status. Used to be represented as a
-- 'Maybe Bool' which is somewhat confusing to interpret.
data SQLColumnStatus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: use PascalCase here, treating SQL as a word.

Suggested change
data SQLColumnStatus
data SqlColumnStatus

Similar examples:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do actually prefer the golang guidelines on acronyms, but whatever ^.^

@KtorZ KtorZ force-pushed the KtorZ/1701/passphrase-scheme-fix branch from 0c24254 to d96d0a0 Compare June 3, 2020 12:18
Comment on lines +309 to +310
-- | A data-type for capturing column status. Used to be represented as a
-- 'Maybe Bool' which is somewhat confusing to interpret.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: remove the line starting with "Used to be represented...".

Justification: the new code is already very clear. 👍

(We don't need to remind the reader how confusing it used to be 😸)

Suggested change
-- | A data-type for capturing column status. Used to be represented as a
-- 'Maybe Bool' which is somewhat confusing to interpret.
-- | Indicates whether or not a column and its parent table are present
-- in the database.

@piotr-iohk
Copy link
Contributor

Unfortunately I still see behavior as in: #1552

To reproduce:

  1. Launch server using cardano-wallet v2020-03-16
cd lib/jormungandr/test/data/jormungandr/test_scripts
./wallet_launch.sh
  1. Create a wallet (e.g. faucet shelley wallet from integration tests: absurd seat ball together donate bulk sustain loop convince capital peanut mutual notice improve jewel)
  2. Stop wallet and start wallet with version from this branch
  3. Submit transaction from that wallet
    Result:
Code = 403,
Message = {"code":"no_root_key","message":"I couldn't find a root private key for the given wallet: f425f750be117385fb7c4280dee5cf9be2f0e71c. However, this operation requires that I do have such a key. Either there's no such wallet, or I don't fully own it."}

@piotr-iohk
Copy link
Contributor

What is interesting that after point 4 (from the above) when you restart wallet again (using the same version) you are able to send transaction... 🤔

@KtorZ
Copy link
Member Author

KtorZ commented Jun 3, 2020

@piotr-iohk My guess here is that, when you first restart it, the automatic migration hasn't happened yet, so the column doesn't yet exists and can't be populated (so, running into the bug as before). Manual migrations are ran BEFORE automatic migration. which is, somewhat necessary for the active slot coeff as it requires to alter the tables before attempting an automatic migration, but problematic for this one which requires the passphrase_scheme to be set :| ...

We could "force-create" the column if it doesn't exist. It won't hurt and we are sure it's there.

Unfortunately, the manual migration are applied before the automated
migration. Yet, the passphraseScheme migration requires the column to
already exists in order to populate it. Therefore, we make sure to first
create it, and then, can safely assign it a value. If it already exists,
we simply assign a value.
Copy link
Contributor

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works on my computer 🎉

@KtorZ
Copy link
Member Author

KtorZ commented Jun 3, 2020

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 3, 2020

@iohk-bors iohk-bors bot merged commit cddd59f into master Jun 3, 2020
@iohk-bors iohk-bors bot deleted the KtorZ/1701/passphrase-scheme-fix branch June 3, 2020 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RESOLVING ISSUE Mark a PR as resolving issues, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants