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

Move delegation certificate declaration in a separate table #980

Merged
merged 2 commits into from
Nov 8, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Nov 7, 2019

Issue Number

#913

Overview

  • I have moved tracking of delegation "certificate" into a separate SQLite table
  • I have adjusted readWalletMetadata to now pull the delegation status from the right table
  • I have added a putDelegationCertificate function to insert a new row in the database when new certificates are discovered
  • I have extended the state-machine tests accordingly, with proper tagging

Comments

Cardano.Wallet.DB.Sqlite
  Sqlite State machine tests
    Sequential
      +++ OK, passed 400 tests:
      65.8% UnsuccessfulReadTxHistory
      57.8% SuccessfulReadCheckpoint
      57.2% CreateThenList
      55.0% TxUnsortedInputs
      54.8% TxUnsortedOutputs
      49.0% CreateWalletTwice
      32.5% ReadTxHistoryAfterDelete
      28.5% PutCheckpointTwice
      27.8% UnsuccessfulReadCheckpoint
      24.8% ReadMetaAfterPutCert
      22.5% CreateThreeWallets
      18.5% RemovePendingTxTwice
      17.5% RolledBackOnce
      14.2% SuccessfulReadPrivateKey
      13.2% SuccessfulReadTxHistory
      12.0% RemoveWalletTwice
    Parallel
      # PENDING: No reason given
  Sqlite State machine (RndState)
    Sequential state machine tests
      +++ OK, passed 400 tests:
      65.8% UnsuccessfulReadTxHistory
      57.8% SuccessfulReadCheckpoint
      57.2% CreateThenList
      55.0% TxUnsortedInputs
      54.8% TxUnsortedOutputs
      49.0% CreateWalletTwice
      32.5% ReadTxHistoryAfterDelete
      28.5% PutCheckpointTwice
      27.8% UnsuccessfulReadCheckpoint
      24.8% ReadMetaAfterPutCert
      22.5% CreateThreeWallets
      18.5% RemovePendingTxTwice
      17.5% RolledBackOnce
      14.2% SuccessfulReadPrivateKey
      13.2% SuccessfulReadTxHistory
      12.0% RemoveWalletTwice

This is because certificates are affected by rollbacks and need to be associate to a
given slot, unlike other static metadata of a wallet
@KtorZ KtorZ self-assigned this Nov 7, 2019
-> Hash "Tx"
-> ExceptT ErrRemovePendingTx m ()
-- ^ Remove a pending transaction.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved up next to other calls related to txs.

toJSON = String . toText

instance FromJSON PoolId where
parseJSON = aesonFromText "PoolId"
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 still don't understand why persistent requires this for field involved in a PrimaryKey. This is non-sense.

@@ -506,7 +507,11 @@ instance Eq XPrv where

instance Arbitrary (Hash purpose) where
arbitrary = do
Hash . convertToBase Base16 . BS.pack <$> vectorOf 32 arbitrary
Hash . convertToBase Base16 . BS.pack <$> vectorOf 16 arbitrary
Copy link
Member Author

Choose a reason for hiding this comment

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

Generate only 16 initial bytes here since the conversion to Base16 will double the underlying size. It doesn't matter much but it gives nicer QC failures with shorter ids.

@@ -359,6 +360,9 @@ newDBLayer logConfig trace mDatabaseFile = do
deleteCheckpoints wid
[ CheckpointSlot >. point
]
deleteDelegationCertificates wid
[ CertSlot >. point
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

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

LGTM

@KtorZ
Copy link
Member Author

KtorZ commented Nov 8, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request Nov 8, 2019
975: Fix bench-db on windows r=KtorZ a=rvl

Relates to #703.

# Overview

The database benchmark was failing with:

```
cardano-wallet-core-2019.11.6-bench-db.exe: C:\users\rodney\Temp\benf0f5.db: DeleteFile "\\\\?\\C:\\users\\rodney\\Temp\\benf0f5.db": permission denied (Sharing violation.)
```

And:

```
db.exe: <stdout>: commitBuffer: invalid argument (Invalid argument)
```

It works on windows but not under wine (encoding problem).



980: Move delegation certificate declaration in a separate table r=KtorZ a=KtorZ

# Issue Number

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

#913

# Overview

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

- [x] I have moved tracking of delegation "certificate" into a separate SQLite table
- [x] I have adjusted `readWalletMetadata` to now pull the delegation status from the right table 
- [x] I have added a `putDelegationCertificate` function to insert a new row in the database when new certificates are discovered
- [x] I have extended the state-machine tests accordingly, with proper tagging

# Comments

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

```
Cardano.Wallet.DB.Sqlite
  Sqlite State machine tests
    Sequential
      +++ OK, passed 400 tests:
      65.8% UnsuccessfulReadTxHistory
      57.8% SuccessfulReadCheckpoint
      57.2% CreateThenList
      55.0% TxUnsortedInputs
      54.8% TxUnsortedOutputs
      49.0% CreateWalletTwice
      32.5% ReadTxHistoryAfterDelete
      28.5% PutCheckpointTwice
      27.8% UnsuccessfulReadCheckpoint
      24.8% ReadMetaAfterPutCert
      22.5% CreateThreeWallets
      18.5% RemovePendingTxTwice
      17.5% RolledBackOnce
      14.2% SuccessfulReadPrivateKey
      13.2% SuccessfulReadTxHistory
      12.0% RemoveWalletTwice
    Parallel
      # PENDING: No reason given
  Sqlite State machine (RndState)
    Sequential state machine tests
      +++ OK, passed 400 tests:
      65.8% UnsuccessfulReadTxHistory
      57.8% SuccessfulReadCheckpoint
      57.2% CreateThenList
      55.0% TxUnsortedInputs
      54.8% TxUnsortedOutputs
      49.0% CreateWalletTwice
      32.5% ReadTxHistoryAfterDelete
      28.5% PutCheckpointTwice
      27.8% UnsuccessfulReadCheckpoint
      24.8% ReadMetaAfterPutCert
      22.5% CreateThreeWallets
      18.5% RemovePendingTxTwice
      17.5% RolledBackOnce
      14.2% SuccessfulReadPrivateKey
      13.2% SuccessfulReadTxHistory
      12.0% RemoveWalletTwice
```

<!-- 
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
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 8, 2019

Build succeeded

@iohk-bors iohk-bors bot merged commit c973d89 into master Nov 8, 2019
@KtorZ KtorZ deleted the KtorZ/913/delegation-certificate-table branch November 11, 2019 16:08
@KtorZ KtorZ added this to the Support Delegated Addresses milestone Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants