Closed Sword-Smith closed 3 years ago
The problem here would be that the balance check-guard for a specific TransferCall
would happen before the EvaluatedTcValue
for this TransferCall
was set in storage. This would mean that the EvaluatedTcValue
might never be set for this TransferCall
and that PT0
's payout was stuck (or certainly delayed) in the derivative contract.
Our fix must work both when a non-invoked PT_i
, for i != 0
has a zero value and a positive value. The only way to ensure this is to ensure a specific flow looping over all TCs even when balance(TC_i) = 0
, for i != 0
. In other words: we must ensure payout evaluation of all PT
s although balance(PT_i) = 0
, for i != 0
.
It seems to me that the current state of the compiler only makes the evaluation when the branch is dead, but not when the branch has a zero or non-zero value but the branch is not dead.
This has been verified to work correctly through commits up to 3dbdb189c343d3fdf7b253692c2d5af81832c3b5 in geth_tools
. Here, we have tested that PT0 calls to pay()
work even though no TransferCall
payout values have been evaluated prior to the call to pay()
by the party with a non-zero PT0
balance but a zero PT_i
balance for all i != 0
.
PT_0
will only get their payouts once allPT_i
values are evaluated such that they are no longer stored as-1
values in storage. If we on aPT0
payout execution encounter a-1
evaluated value for the ith PT we must check if thePT_i
value can be calculated before we determine if thePT_0
payout should occur or not.