I'm having some trouble figuring out the vesting logic in homework 1 of the Plutus pioneer program lecture. I eventually gave up and looked at the solution which seems to be exhibiting the same "bug" (I put bug in quotes because clearly I'm misunderstanding something).
As I understand the logic of the transaction construction, the giver
(or beneficiary2
) can claim the gift anytime after the deadline while the recipient (or beneficiary1
) can claim the gift anytime before the deadline (inclusive). Is that correct?
If so, I'm having trouble understanding why the following simulation seems to succeed. I'll provide screenshots and then go through my understanding of it. Here are the values entered for the simulation that seems buggy to me:
and here the final state of the blockchain:
In this simulation, Wallet 1 is giving 10 ADA to 39f713d0a644253f04529421b9f51b9b08979d08295959c4f3990ee617f5139f
which is the hash of Wallet 2 (this can be confirmed by looking at the hash of the wallets in the final state screenshot). This gift has a deadline of 1596059101000
which is slot 10 based on:
Prelude Ledger Wallet.Emulator Data.Default Ledger.TimeSlot Week03.Homework2> posixTimeToEnclosingSlot def 1596059101000
Slot {getSlot = 10}
and
Prelude Ledger Wallet.Emulator Data.Default Ledger.TimeSlot Week03.Homework2> slotToBeginPOSIXTime de
f 10
POSIXTime {getPOSIXTime = 1596059101000}
Curiously, it seems that Wallet 2 can grab the gift at slot 11 which is after the deadline. It's very possible that my understanding of the transaction logic is incorrect. To double check, I also ran the same code with the following simulation (the only difference is that the second step of the simulation waits until slot 5 instead of slot 11) and it also succeeded which confuses me even more. I expect that one of these simulations should fail but can't figure out why.
Is there a bug with the solution for homework 1 in lecture 3? Am I misunderstanding something about the logic of the solution?
EDIT: here's another interesting point, with the suggested solution I can't seem to get Wallet 1 to grab the gift it provides. I've tried waiting for 1 block after the gift, waiting until slot 5 and waiting until slot 15 before attempting for Wallet 1 to grab it's gift and in all cases it fails - the "grab" transaction never reaches the blockchain and seems to fail client side with found 0 gift(s) to grab
.
ea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4
but now I'm realizing that the required plutus commit changes from week to week.ea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4
is from week 1 while week 3 requires219992289c6615e197069d022735cb4059d43229
.plutus
repo to219992289c6615e197069d022735cb4059d43229
doesn't fix this unfortunately 🙁219992289c6615e197069d022735cb4059d43229
does solve the problem, I must have fat fingered something in the earlier comment which said it doesn't. Commitea0ca4e9f9821a9dbfc5255fa0f42b6f2b3887c4
seems to have a broken notion of time: cardano.stackexchange.com/questions/3997/…