<div dir="ltr"><div dir="ltr">On Thu, May 23, 2019 at 9:58 PM Pieter Wuille via bitcoin-dev &lt;<a href="mailto:bitcoin-dev@lists.linuxfoundation.org">bitcoin-dev@lists.linuxfoundation.org</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If the difficulty can be directly observed by the script language, you<br>
would need to re-evaluate all scripts in unconfirmed transactions<br>
whenever the difficulty changes. This complicates implementation of<br>
mempools, but it also makes reasoning about validity of (chains of)<br>
unconfirmed transactions harder, as an unconfirmed predecessor may<br>
have conditions that change over time.</blockquote><div><br></div><div>To deal with potentially wildly varying difficulty, could the value exposed be the sum of accumulated PoW, or in other words the sum of each block&#39;s difficulty value in the entire chain? This should be a value that will only rise unless a reorg happens after a difficulty drop happens (only likely to be the result of users manually blacklisting an otherwise valid block that is several blocks back in the chain).</div><div><br></div><div>This mimics the effect of the block number which only grows. So if you&#39;re starting at time A with difficulty X, then you&#39;d estimate what you think the accumulated PoW ought to be at time B with expected difficulty Y (as compared to the current value at time A), and put that value into the script.</div></div></div>