user2236: 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.

user2236: Turns out I wasn't using the correct checkout of plutus. More details can be found at the following Cardano StackExchange answer: plutus-playground-server sense of time is incorrect

2236: <p>I'm having some trouble figuring out the vesting logic in <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week03/src/Week03/Homework1.hs#L45-L49" rel="nofollow noreferrer">homework 1</a> of the Plutus pioneer program lecture. I eventually gave up and looked at the <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week03/src/Week03/Solution1.hs#L46-L5" rel="nofollow noreferrer">solution</a> which seems to be exhibiting the same &quot;bug&quot; (I put bug in quotes because clearly I'm misunderstanding something).</p>
<p>As I understand the logic of the <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week03/src/Week03/Homework1.hs#L82-L128" rel="nofollow noreferrer">transaction construction</a>, the <code>giver</code> (or <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week03/src/Week03/Homework1.hs#L87" rel="nofollow noreferrer"><code>beneficiary2</code></a>) can claim the gift anytime after the deadline while the recipient (or <code>beneficiary1</code>) can claim the gift anytime before the deadline (inclusive). Is that correct?</p>
<p>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:</p>
<p><a href="https://i.stack.imgur.com/xyPCt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xyPCt.png" alt="enter image description here" /></a></p>
<p>and here the final state of the blockchain:</p>
<p><a href="https://i.stack.imgur.com/qdAcC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qdAcC.png" alt="enter image description here" /></a></p>
<p>In this simulation, Wallet 1 is giving 10 ADA to <code>39f713d0a644253f04529421b9f51b9b08979d08295959c4f3990ee617f5139f</code> 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 <code>1596059101000</code> which is slot 10 based on:</p>
<pre><code>Prelude Ledger Wallet.Emulator Data.Default Ledger.TimeSlot Week03.Homework2&gt; posixTimeToEnclosingSlot def 1596059101000
Slot {getSlot = 10}
</code></pre>
<p>and</p>
<pre><code>Prelude Ledger Wallet.Emulator Data.Default Ledger.TimeSlot Week03.Homework2&gt; slotToBeginPOSIXTime de
f 10
POSIXTime {getPOSIXTime = 1596059101000}
</code></pre>
<p>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.</p>
<p><a href="https://i.stack.imgur.com/CTXjb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CTXjb.png" alt="enter image description here" /></a></p>
<p>Is there a bug with the solution for homework 1 in lecture 3? Am I misunderstanding something about the logic of the solution?</p>
<p>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 &quot;grab&quot; transaction never reaches the blockchain and seems to fail client side with <code>found 0 gift(s) to grab</code>.</p>
 2236: <p>Turns out I wasn't using the correct checkout of <code>plutus</code>. More details can be found at the following Cardano StackExchange answer: <a href="https://cardano.stackexchange.com/questions/3997/plutus-playground-server-sense-of-time-is-incorrect/3998#3998">plutus-playground-server sense of time is incorrect</a></p>
