hydra-tx
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Tx.Snapshot

Synopsis

SnapshotNumber and SnapshotVersion

newtype SnapshotNumber Source #

Instances

Instances details
FromJSON SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

parseJSON :: Value -> Parser SnapshotNumber

parseJSONList :: Value -> Parser [SnapshotNumber]

omittedField :: Maybe SnapshotNumber

ToJSON SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Enum SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Generic SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep SnapshotNumber :: Type -> Type Source #

Num SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Integral SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Real SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Show SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

FromCBOR SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

fromCBOR :: Decoder s SnapshotNumber

label :: Proxy SnapshotNumber -> Text

ToCBOR SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: SnapshotNumber -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SnapshotNumber -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SnapshotNumber] -> Size

Eq SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Ord SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotNumber = D1 ('MetaData "SnapshotNumber" "Hydra.Tx.Snapshot" "hydra-tx-2.3.0-AmphLXDqLbeiaw5uNmLIz" 'True) (C1 ('MetaCons "UnsafeSnapshotNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))

newtype SnapshotVersion Source #

Instances

Instances details
FromJSON SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

ToJSON SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Enum SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Generic SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep SnapshotVersion :: Type -> Type Source #

Num SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Integral SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Real SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Show SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

FromCBOR SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

fromCBOR :: Decoder s SnapshotVersion

label :: Proxy SnapshotVersion -> Text

ToCBOR SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: SnapshotVersion -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SnapshotVersion -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SnapshotVersion] -> Size

Eq SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Ord SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotVersion = D1 ('MetaData "SnapshotVersion" "Hydra.Tx.Snapshot" "hydra-tx-2.3.0-AmphLXDqLbeiaw5uNmLIz" 'True) (C1 ('MetaCons "UnsafeSnapshotVersion" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))

Snapshot

data Snapshot tx Source #

Constructors

Snapshot 

Fields

Instances

Instances details
IsTx tx => FromJSON (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

parseJSON :: Value -> Parser (Snapshot tx)

parseJSONList :: Value -> Parser [Snapshot tx]

omittedField :: Maybe (Snapshot tx)

IsTx tx => ToJSON (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toJSON :: Snapshot tx -> Value

toEncoding :: Snapshot tx -> Encoding

toJSONList :: [Snapshot tx] -> Value

toEncodingList :: [Snapshot tx] -> Encoding

omitField :: Snapshot tx -> Bool

Generic (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep (Snapshot tx) :: Type -> Type Source #

Methods

from :: Snapshot tx -> Rep (Snapshot tx) x Source #

to :: Rep (Snapshot tx) x -> Snapshot tx Source #

IsTx tx => Show (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

IsTx tx => FromCBOR (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

fromCBOR :: Decoder s (Snapshot tx)

label :: Proxy (Snapshot tx) -> Text

IsTx tx => ToCBOR (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: Snapshot tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (Snapshot tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Snapshot tx] -> Size

IsTx tx => SignableRepresentation (Snapshot tx) Source #

Binary representation of snapshot signatures. That is, concatenated CBOR for Snapshot, $sel:version:Snapshot, $sel:number:Snapshot, accumulatorHash, decommitOutputsHash, and commitOutputsHash according to CDDL schemata:

headId = bytes .size 28 version = uint number = uint accumulatorHash = bytes .size 32 ; blake2b-256 hash of the compressed G1 accumulator commitment decommitOutputsHash = bytes .size 32 ; sha2-256 of the ordered decommit outputs (Uω) commitOutputsHash = bytes .size 32 ; sha2-256 of the ordered commit outputs (Uα) ; and of the deposit transaction id

The BLS accumulator commitment (bound via accumulatorHash) commits to the full UTxO set. decommitOutputsHash and commitOutputsHash additionally bind the exact ordered sets of decommit (Uω) and commit (Uα) outputs, so the on-chain decrement and increment validators can recompute them from the materialized L1 decommit outputs claimed deposit and reject any redirectedaltered output.

commitOutputsHash further binds $sel:depositTxId:Snapshot. Committed content on its own does not identify a deposit: a deposit datum is unauthenticated data anyone can copy into a look-alike deposit holding less value, which would otherwise hash the same and accept this snapshot's signatures. See the matching computation in checkIncrement.

Instance details

Defined in Hydra.Tx.Snapshot

IsTx tx => Eq (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

(==) :: Snapshot tx -> Snapshot tx -> Bool Source #

(/=) :: Snapshot tx -> Snapshot tx -> Bool Source #

type Rep (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

commitOutputsHash :: forall tx. IsTx tx => Snapshot tx -> ByteString Source #

Digest of a snapshot's pending commit (Uα) as bound into its signature: the ordered commit outputs together with the id of the deposit transaction they come from.

Both halves are required. The outputs alone do not identify a deposit, since a deposit datum is unauthenticated data anyone can copy into a look-alike deposit holding less value; binding the deposit's transaction id makes the signature usable for that one deposit only. The increment validator recomputes this from the deposit input it claims, see checkIncrement. Close, contest and decrement transactions cannot recompute it (they spend no deposit) and carry it in their redeemer instead, where it only feeds signature verification.

snapshotCBORTag :: Text Source #

Tag of the current on-disk/wire layout, which carries $sel:depositTxId:Snapshot.

The fields are a bare concatenation with no length prefix, so a layout change is only decodable when the tag distinguishes it: snapshotCBORTagV1 names the one written before $sel:depositTxId:Snapshot existed and is still accepted, letting a node replay an event log from an earlier version.

snapshotCBORTagV1 :: Text Source #

Tag of the layout without $sel:depositTxId:Snapshot. Decoded, never written.

snapshotUTxO :: IsTx tx => Snapshot tx -> UTxOType tx Source #

All UTxOs represented by this snapshot: settled plus any pending commit/decommit.

ConfirmedSnapshot

data ConfirmedSnapshot tx Source #

A snapshot that can be used to close a head with. Either the initial one, or when it was signed by all parties, i.e. it is confirmed.

Instances

Instances details
IsTx tx => FromJSON (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

parseJSON :: Value -> Parser (ConfirmedSnapshot tx)

parseJSONList :: Value -> Parser [ConfirmedSnapshot tx]

omittedField :: Maybe (ConfirmedSnapshot tx)

IsTx tx => ToJSON (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toJSON :: ConfirmedSnapshot tx -> Value

toEncoding :: ConfirmedSnapshot tx -> Encoding

toJSONList :: [ConfirmedSnapshot tx] -> Value

toEncodingList :: [ConfirmedSnapshot tx] -> Encoding

omitField :: ConfirmedSnapshot tx -> Bool

Generic (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep (ConfirmedSnapshot tx) :: Type -> Type Source #

IsTx tx => Show (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

IsTx tx => FromCBOR (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

fromCBOR :: Decoder s (ConfirmedSnapshot tx)

label :: Proxy (ConfirmedSnapshot tx) -> Text

IsTx tx => ToCBOR (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: ConfirmedSnapshot tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (ConfirmedSnapshot tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [ConfirmedSnapshot tx] -> Size

IsTx tx => Eq (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep (ConfirmedSnapshot tx) = D1 ('MetaData "ConfirmedSnapshot" "Hydra.Tx.Snapshot" "hydra-tx-2.3.0-AmphLXDqLbeiaw5uNmLIz" 'False) (C1 ('MetaCons "InitialSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)) :+: C1 ('MetaCons "ConfirmedSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot tx)))))

getSnapshot :: forall tx. IsTx tx => ConfirmedSnapshot tx -> Snapshot tx Source #

Safely get a Snapshot from a confirmed snapshot.

NOTE: While we could use $sel:snapshot:InitialSnapshot directly, this is a record-field accessor which may become partial (and lead to unnoticed runtime errors) if we ever add a new branch to the sumtype. So, we explicitly define a getter which will force us into thinking about changing the signature properly if this happens.