Skip to content

Conversation

@mikekeke
Copy link
Contributor

@mikekeke mikekeke commented May 24, 2022

Related issue: #100
This PR aims to fix time <-> slot conversions.

Changes:

  • new effects added for time -> slot, slot -> time and time range -> slot range conversions
  • plutus-ledger functions for time <-> slot conversions replaced with new ones, which re-use functions from ledger and should give correct conversions sustainable to slot length changes
  • pcSlotConfig removed from PABConfig as it is not required anymore

New conversions were tested on public testnet with this validator.

mikekeke added 5 commits May 17, 2022 17:41
- v1 working variant, checked on testnet
- cleanup TimeSlot module
- refactoring
- removing `SlotConfig` from `PABConfig`
- testnet debugging enhancements
- minor refactoring and docs
@mikekeke mikekeke force-pushed the misha/issue-100-time-conversions branch from 4ff096c to d184cdb Compare May 30, 2022 13:06
mikekeke added 2 commits May 31, 2022 10:41
- removing debug contract
- formatting
@mikekeke mikekeke marked this pull request as ready for review May 31, 2022 09:16
let lowerB = LowerBound startSlot startSlotClosure
upperB = UpperBound endSlot endSlotClosure
pure $ Interval lowerB upperB
where
Copy link
Contributor

Choose a reason for hiding this comment

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

These are a litttle involved, lets get some type signatures on them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type signatures added

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think @samuelWilliams99 ment the convertExtended and getExtClosure functions, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added signatures there as well and clarification comments.

, teRawCBOR = fromRight (error "failed to unpack CBOR hex") $ unhex "84a500848258205d677265fa5bb21ce6d8c7502aca70b9316d10e958611f3c6b758f65ad9599960182582076ed2fcda860de2cbacd0f3a169058fa91eff47bc1e1e5b6d84497159fbc9300008258209405c89393ba84b14bf8d3e7ed4788cc6e2257831943b58338bee8d37a3668fc00825820a1be9565ccac4a04d2b5bf0d0167196ae467da0d88161c9c827fbe76452b24ef000d8182582076ed2fcda860de2cbacd0f3a169058fa91eff47bc1e1e5b6d84497159fbc930000018482581d600f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f975461a3b8cc4a582581d600f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546821a00150bd0a1581c1d6445ddeda578117f393848e685128f1e78ad0c4e48129c5964dc2ea14974657374546f6b656e1a000d062782581d606696936bb8ae24859d0c2e4d05584106601f58a5e9466282c8561b88821a00150bd0a1581c1d6445ddeda578117f393848e685128f1e78ad0c4e48129c5964dc2ea14974657374546f6b656e1282581d60981fc565bcf0c95c0cfa6ee6693875b60d529d87ed7082e9bf03c6a4821a00150bd0a1581c1d6445ddeda578117f393848e685128f1e78ad0c4e48129c5964dc2ea14974657374546f6b656e0f021a000320250e81581c0f45aaf1b2959db6e5ff94dbb1f823bf257680c3c723ac2d49f97546a10081825820096092b8515d75c2a2f75d6aa7c5191996755840e81deaa403dba5b690f091b65840295a93849a67cecabb8286e561c407b6bd49abf8d2da8bfb821105eae4d28ef0ef1b9ee5e8abb8fd334059f3dfc78c0a65e74057a2dc8d1d12e46842abea600ff5f6"
}

mockSlotRange ::
Copy link
Contributor

Choose a reason for hiding this comment

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

Given we're mocking this, can we get a test for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it will require this to make it clean and straightforward. There is bunch of node queries required to get all arguments for conversion and they need to be mocked also if we are not calling real node.
(there will be still some parts tho, that I'm not sure how get easily atm, like EraHistory)

QueryChainIndex :: ChainIndexQuery -> PABEffect w ChainIndexResponse
EstimateBudget :: TxFile -> PABEffect w (Either BudgetEstimationError TxBudget)
SaveBudget :: Ledger.TxId -> TxBudget -> PABEffect w ()
SlotToPOSIXTime ::
Copy link
Collaborator

Choose a reason for hiding this comment

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

I started to get a feeling that instead of introducing new effects here for each cardano-api related query, we should have a more general QueryNode that uses this (this would also make later attempts to use cardano-api instead of the cli or chain-index a bit simpler)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is great idea, I think. It will also make things more testable (e.g. like this one).
But not sure if it should be done under this PR. To make it right budget execution related logic need to be changed also.

Or maybe just change part related to slot/time conversions to QueryNode effect and leave ex-budget for separate issue?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed yes, let's make that a new issue (the problem with refactoring issues is that they tend to be forgotten, staying in the backlog forever, so I like to couple them with some useful feature)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made an issue #109

Copy link
Collaborator

@szg251 szg251 left a comment

Choose a reason for hiding this comment

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

There are still a few small ones

let lowerB = LowerBound startSlot startSlotClosure
upperB = UpperBound endSlot endSlotClosure
pure $ Interval lowerB upperB
where
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think @samuelWilliams99 ment the convertExtended and getExtClosure functions, no?

mikekeke added 3 commits June 3, 2022 11:12
- review comments resolved
- link to sources for mintining policies sorting comment corrected
- overlooked redundant Slot conversion in `convertExtended` removed
@mikekeke mikekeke merged commit 0908ade into master Jun 3, 2022
@mikekeke mikekeke deleted the misha/issue-100-time-conversions branch June 3, 2022 12:34
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.

4 participants