-
Notifications
You must be signed in to change notification settings - Fork 11
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
Time changes: no more builtin ms and tweaks. #233
Conversation
0d3f433
to
b2418a3
Compare
b2418a3
to
412fad6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is a nice simplification of the API of MonadBlockChain
, and also contains a few useful tweaks. As discussed, I left my review in form of a few commits 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some comments on the validity range of auctions that, if addressed, could expose the bug we observed in cooked v1.
Co-authored-by: Facundo Domínguez <facundominguez@gmail.com>
-- | Return the slot that contains the given time. It holds that | ||
-- | ||
-- > slotToTimeInterval (getEnclosingSlot t) == (a, b) ==> a <= t <= b | ||
-- | ||
-- and | ||
-- | ||
-- > slotToTimeInterval n == (a, b) ==> getEnclosingSlot a == n && getEnclosingSlot b == n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- | Return the slot that contains the given time. It holds that | |
-- | |
-- > slotToTimeInterval (getEnclosingSlot t) == (a, b) ==> a <= t <= b | |
-- | |
-- and | |
-- | |
-- > slotToTimeInterval n == (a, b) ==> getEnclosingSlot a == n && getEnclosingSlot b == n | |
-- | Return the slot that contains the given time. | |
-- | |
-- See 'slotToTimeInterval' for its relationship to 'getEnclosingSlot'. |
Perhaps we could avoid maintaining two copies of these properties.
Ledger.Slot nr <- getEnclosingSlot r | ||
return (nl, nr) of | ||
Left _err -> False | ||
Right ((nl, nr), _) -> nl == 42 && nr == 42, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 42 instead of some arbitrary integer? (Similar to the property-based test below)
@@ -86,7 +86,7 @@ txBid submitter offerOref bid = do | |||
Just deadline = A.getBidDeadline datum | |||
seller = A.getSeller datum | |||
lotPlusPreviousBidPlusNft = outputValue output | |||
validityInterval <- slotRangeBefore deadline | |||
validityInterval <- slotRangeBefore (deadline - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this remain slotRangeBefore deadline
? The bid validator should accept a transaction on the deadline if the node interprets slots the same as the off-chain code.
examples/src/Auction/Offchain.hs
Outdated
@@ -149,7 +149,7 @@ txHammer submitter offerOref = do | |||
let datum = output ^. outputDatumL | |||
Just deadline = A.getBidDeadline datum | |||
seller = A.getSeller datum | |||
validityInterval <- slotRangeAfter deadline | |||
validityInterval <- slotRangeAfter (deadline + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar question here.
The change in the meaning of |
This PR is both: