-
Notifications
You must be signed in to change notification settings - Fork 86
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
Account for contestation period in validators #351
Conversation
cc0ed45
to
3f97816
Compare
Transactions CostsSizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using
Cost of Init Transaction
Cost of Commit TransactionCurrently only one UTxO per commit allowed (this is about to change soon)
Cost of CollectCom Transaction
Cost of Close Transaction
Cost of Abort Transaction
Cost of FanOut TransactionInvolves spending head output and burning head tokens. Uses ada-only UTxO for better comparability.
|
@@ -546,14 +604,21 @@ finalizeTx TinyWallet{sign, getUTxO, coverFee} headState partialTx = do | |||
Right validatedTx -> do | |||
pure $ sign validatedTx | |||
|
|||
-- | Hardcoded grace time for close transaction to be valid. | |||
-- TODO: replace/remove with deadline contestation |
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 guess this TODO is moot now as we moved to a deadline already?
getContestationDeadline :: OnChainHeadState 'StClosed -> POSIXTime | ||
getContestationDeadline | ||
OnChainHeadState{stateMachine = Closed{closedThreadOutput = ClosedThreadOutput{closedContestationDeadline}}} = | ||
closedContestationDeadline |
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 is slightly side-stepping the "non-introspectability" of the OnChainHeadState
, but it's fine given the direction this is going.
, initialContestationPeriod :: OnChain.ContestationPeriod | ||
, initialParties :: [OnChain.Party] | ||
} | ||
deriving (Eq, Show) |
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 like the direction in which this is going. As I said it yesterday, this is very similar to the InitObservation
and I'm quite keen to unify them :)
} | ||
utxoHash = toBuiltin $ hashTxOuts $ toList utxo | ||
|
||
fanoutTx :: | ||
-- | Snapshotted UTxO to fanout on layer 1 | ||
UTxO -> | ||
-- | Everything needed to spend the Head state-machine output. | ||
(TxIn, TxOut CtxUTxO, ScriptData) -> | ||
UTxOWithScript -> |
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.
Could be a ClosedThreadOutput
, utxoHash | ||
, parties | ||
, contestationDeadline = | ||
-- FIXME: we don't have useful functions for manipulating time on-chain seemingly |
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.
What exactly is it to fix here? Sounds more like a complaint but slotNoToPOSIXTime
works in this case?
} | ||
, SomeMutation MutateValidityPastDeadline . ChangeValidityInterval <$> do | ||
lb <- arbitrary | ||
ub <- TxValidityUpperBound <$> arbitrary `suchThat` slotOverContestationDeadline |
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.
Also here.. you're on a naming roll!
@@ -35,7 +35,7 @@ import Test.QuickCheck (generate) | |||
spec :: Spec | |||
spec = do | |||
it "can init and abort a head given nothing has been committed" $ | |||
failAfter 10 $ | |||
failAfter 20 $ |
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.
Did this become slower?
let expectedOutputDatum = | ||
Closed | ||
{ parties | ||
, snapshotNumber = 0 | ||
, utxoHash = initialUtxoHash | ||
, contestationDeadline = makeContestationDeadline cperiod ctx | ||
} | ||
in checkHeadOutputDatum ctx expectedOutputDatum |
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.
Introducing a variable for this feels a bit too verbose?
let expectedOutputDatum = | |
Closed | |
{ parties | |
, snapshotNumber = 0 | |
, utxoHash = initialUtxoHash | |
, contestationDeadline = makeContestationDeadline cperiod ctx | |
} | |
in checkHeadOutputDatum ctx expectedOutputDatum | |
checkHeadOutputDatum ctx $ | |
Closed | |
{ parties | |
, snapshotNumber = 0 | |
, utxoHash = initialUtxoHash | |
, contestationDeadline = makeContestationDeadline cperiod ctx | |
} |
| otherwise = traceError "negative snapshot number" | ||
{-# INLINEABLE checkClose #-} | ||
|
||
-- | Checks that the datum |
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.
that the datum.. ?
millisToPico = (* millisInPico) | ||
|
||
millisInPico :: Integer | ||
millisInPico = 10 ^ (9 :: Integer) |
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.
Name wrong way around? isn't it 10^9 pico seconds in a millisecond?
Also enhance cardano-api with pinned era types for lower and upper bound
Currently set to arbitrary value as it's not really tested
We should probably drop this test anyway
One mutation for close is still failing, on purpose
d447fc2
to
312ac0f
Compare
Fix #356