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 slotting to separate module #1890

Merged
merged 2 commits into from
Jul 14, 2020
Merged

Conversation

Anviking
Copy link
Collaborator

@Anviking Anviking commented Jul 9, 2020

Issue Number

ADP-356 #1868, #1869

Overview

  • I have moved the existing slotting logic (flatSlot, slotAt, etc.) to a new module Cardano.Wallet.Primitive.Slotting
    • It is easier to keep track of remaining uses of static slotting this way
  • I started adding a ouroboros-consensus wrapper on top (currently unused)
    • Added property runQuery epochOf singleEraInterpreter == epochNumber . fromFlatSlot

Comments

  • I left tests for slotting arithmetic in TypesSpec because the boundary between Range tests and slotting tests seemed unclear.
  • Next step: Wrap all existing slotting logic using Qry/Interpreter.
  • Could split into two PRs if you want

@Anviking Anviking self-assigned this Jul 9, 2020
@Anviking Anviking changed the base branch from master to anviking/1868/rename-slotNo July 9, 2020 13:43
@Anviking Anviking force-pushed the anviking/1868/move-slotting branch from 62b4720 to 1d1bea8 Compare July 9, 2020 13:50
@Anviking Anviking force-pushed the anviking/1868/rename-slotNo branch from 48d3ccd to 8a85564 Compare July 9, 2020 14:14
@Anviking Anviking force-pushed the anviking/1868/move-slotting branch from 1d1bea8 to c238d9b Compare July 9, 2020 14:18
@KtorZ KtorZ force-pushed the anviking/1868/rename-slotNo branch from 8a85564 to 357bb22 Compare July 10, 2020 17:28
Base automatically changed from anviking/1868/rename-slotNo to master July 10, 2020 20:12
@Anviking Anviking force-pushed the anviking/1868/move-slotting branch from df09036 to b2e34a7 Compare July 13, 2020 12:40
@Anviking Anviking mentioned this pull request Jul 13, 2020
5 tasks
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +67 to +72
import Ouroboros.Consensus.HardFork.History.EraParams
( EraParams (..), noLowerBoundSafeZone )
import Ouroboros.Consensus.HardFork.History.Qry
( Qry, runQuery, slotToEpoch )
import Ouroboros.Consensus.HardFork.History.Summary
( Summary (..), neverForksSummary )
Copy link
Contributor

Choose a reason for hiding this comment

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

Importing of Ouroboros.Consensus doesn't seem right for the cardano-wallet-core package - it is cardano-node backend specific. Is there any way to move this to the cardano-wallet-shelley package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Core already depends on ouroboros-network: https://github.com/input-output-hk/cardano-wallet/blob/315b875cd3c6a78b8c4d4e58bfec6bd4d9acffcd/lib/core/src/Ouroboros/Network/Client/Wallet.hs#L12-L20

  • To avoid having Qry in core, we'd need to duplicate the interface
  • Jormungandr can satisfy the Qry interface

I do think it is fine.

Slightly related thread: point vs forcing jormungandr to use SlotNo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The boundary between jormungandr and byron/shelley could also be revisited later.

Comment on lines +89 to +90
-- TODO: The type should be changed to @Interpreter@ when we bump
-- ouroboros-consensus.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do this? Another PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No rush. I don't think we need it until #1870 is starting.

- We will use it to correctly deal with time across hard-forks
- Added tests for equivalence with old implementation
@Anviking Anviking force-pushed the anviking/1868/move-slotting branch from b2e34a7 to 1be1ac1 Compare July 14, 2020 09:50
@Anviking Anviking removed the request for review from jonathanknowles July 14, 2020 10:31
@Anviking
Copy link
Collaborator Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 14, 2020

@iohk-bors iohk-bors bot merged commit 42872e6 into master Jul 14, 2020
@iohk-bors iohk-bors bot deleted the anviking/1868/move-slotting branch July 14, 2020 11:29
iohk-bors bot added a commit that referenced this pull request Jul 17, 2020
1901: Use SlotNo and TimeInterpreter r=Anviking a=Anviking

# Issue Number

ADP-356 #1868 #1869 


# Overview

- [x] Add TimeInterpreter, necessary queries, and a way to run them
Add tests comparing them with old implementation

- [x] Fundamentally change wallet to use SlotNo instead of SlotId
    - Patch together cardano-wallet-jormungandr to still work, despite the
binary using SlotId.

- [x] Remove redundant byron code

- [x] Sync progress calculation compares times now instead of slots

- [x] Rename the `slot` tables to `slot_no` to force automatic migration, preventing catastrophic re-interpretation of old data

# Comments

- Depends on #1890 

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

<!-- 
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: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this pull request Jul 17, 2020
1901: Use SlotNo and TimeInterpreter r=Anviking a=Anviking

# Issue Number

ADP-356 #1868 #1869 


# Overview

- [x] Add TimeInterpreter, necessary queries, and a way to run them
Add tests comparing them with old implementation

- [x] Fundamentally change wallet to use SlotNo instead of SlotId
    - Patch together cardano-wallet-jormungandr to still work, despite the
binary using SlotId.

- [x] Remove redundant byron code

- [x] Sync progress calculation compares times now instead of slots

- [x] Rename the `slot` tables to `slot_no` to force automatic migration, preventing catastrophic re-interpretation of old data

# Comments

- Depends on #1890 

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

<!-- 
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: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this pull request Jul 17, 2020
1901: Use SlotNo and TimeInterpreter r=Anviking a=Anviking

# Issue Number

ADP-356 #1868 #1869 


# Overview

- [x] Add TimeInterpreter, necessary queries, and a way to run them
Add tests comparing them with old implementation

- [x] Fundamentally change wallet to use SlotNo instead of SlotId
    - Patch together cardano-wallet-jormungandr to still work, despite the
binary using SlotId.

- [x] Remove redundant byron code

- [x] Sync progress calculation compares times now instead of slots

- [x] Rename the `slot` tables to `slot_no` to force automatic migration, preventing catastrophic re-interpretation of old data

# Comments

- Depends on #1890 

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

<!-- 
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: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this pull request Jul 17, 2020
1901: Use SlotNo and TimeInterpreter r=Anviking a=Anviking

# Issue Number

ADP-356 #1868 #1869 


# Overview

- [x] Add TimeInterpreter, necessary queries, and a way to run them
Add tests comparing them with old implementation

- [x] Fundamentally change wallet to use SlotNo instead of SlotId
    - Patch together cardano-wallet-jormungandr to still work, despite the
binary using SlotId.

- [x] Remove redundant byron code

- [x] Sync progress calculation compares times now instead of slots

- [x] Rename the `slot` tables to `slot_no` to force automatic migration, preventing catastrophic re-interpretation of old data

# Comments

- Depends on #1890 

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

<!-- 
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: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this pull request Jul 17, 2020
1901: Use SlotNo and TimeInterpreter r=Anviking a=Anviking

# Issue Number

ADP-356 #1868 #1869 


# Overview

- [x] Add TimeInterpreter, necessary queries, and a way to run them
Add tests comparing them with old implementation

- [x] Fundamentally change wallet to use SlotNo instead of SlotId
    - Patch together cardano-wallet-jormungandr to still work, despite the
binary using SlotId.

- [x] Remove redundant byron code

- [x] Sync progress calculation compares times now instead of slots

- [x] Rename the `slot` tables to `slot_no` to force automatic migration, preventing catastrophic re-interpretation of old data

# Comments

- Depends on #1890 

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

<!-- 
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: Johannes Lund <johannes.lund@iohk.io>
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.

None yet

2 participants