| License | Apache-2.0 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
Conformance.Replay
Description
These pure helpers classify replay data for a phase-2 refusal, which carries no observed reason by itself. Callers supply two runs of the failing script: the deployed bytes under the transaction's declared units, and traced bytes of the same source with the same parameters under the protocol maximum. This module decides what those two supplied runs establish.
A reason is admitted only when both runs fail as a validator and the traced run leaves exactly one user-defined trace; that line, verbatim, is the reason. Every other result is an unobserved reason with its cause, and every cause is its own value. A reason is compared with the model's only once admitted.
Pure: the runs arrive as data. Capturing and evaluating those runs is outside this module.
Synopsis
- data RunOutcome
- data ReplayRun = ReplayRun {
- runBytesHash :: Text
- runBudgetLimit :: (Integer, Integer)
- runBudgetUsed :: Maybe (Integer, Integer)
- runOutcome :: RunOutcome
- runLogs :: [Text]
- data UnobservedCause
- causeName :: UnobservedCause -> Text
- data ReplayClass
- = Admitted Text
- | Unobserved UnobservedCause
- admitReason :: ReplayRun -> ReplayRun -> Maybe UnobservedCause -> ReplayClass
- userTraces :: [Text] -> [Text]
- data ScriptFamily = ScriptFamily {
- sfTitle :: Text
- sfRouted :: Bool
- sfCandidates :: [Text]
- identifyScript :: [ScriptFamily] -> Maybe Text -> Text -> Either UnobservedCause Text
- data ReasonComparison
- = Agrees
- | Differs {
- chainReason :: Text
- leanReason :: Text
- | Uncompared UnobservedCause
- compareReason :: Text -> ReplayClass -> ReasonComparison
- stepComparison :: Text -> Text -> [(Text, ReplayClass)] -> ReasonComparison
- comparisonName :: ReasonComparison -> Text
- admittedFor :: Text -> [(Text, ReplayClass)] -> Maybe Text
- data PurposeReplay = PurposeReplay {
- prPurpose :: Text
- prDeployedHash :: Text
- prTracedHash :: Maybe Text
- prDeployed :: Maybe ReplayRun
- prTraced :: Maybe ReplayRun
- prClass :: ReplayClass
- acceptingControlGaps :: [Value] -> [Text]
- data TracedProvenance = TracedProvenance {
- tpSource :: Text
- tpCompiler :: Text
- tpFlags :: Text
- tpUntracedHashes :: Map Text Text
- toolchainCause :: TracedProvenance -> Map Text Text -> Maybe UnobservedCause
- captureIdOf :: [(FilePath, ByteString)] -> Text
- data ReplayEvidence = ReplayEvidence {
- replayDeployedHash :: Text
- replayTracedHash :: Maybe Text
- replayReason :: Maybe Text
- replayCause :: Maybe Text
- replayCaptureId :: Maybe Text
- rejectionEvidence :: Maybe Text -> [Text] -> [PurposeReplay] -> [ReplayClass] -> [ReplayEvidence]
- data ReplayCorrespondence = ReplayCorrespondence {
- correspondenceSource :: Text
- correspondenceCompiler :: Text
- correspondenceFlags :: Text
- correspondenceDigest :: Text
- correspondenceOf :: TracedProvenance -> ReplayCorrespondence
Runs
data RunOutcome Source #
How one evaluation of one script on one purpose's arguments ended.
Constructors
| Succeeded | the script returned |
| ValidatorFailure | the script failed: an |
| BudgetExhausted | the budget ran out before the script finished |
| EvaluationError Text | the evaluator could not run the script at all |
Instances
| ToJSON RunOutcome Source # | |
Defined in Conformance.Replay Methods toJSON :: RunOutcome -> Value toEncoding :: RunOutcome -> Encoding toJSONList :: [RunOutcome] -> Value toEncodingList :: [RunOutcome] -> Encoding omitField :: RunOutcome -> Bool | |
| Show RunOutcome Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> RunOutcome -> ShowS Source # show :: RunOutcome -> String Source # showList :: [RunOutcome] -> ShowS Source # | |
| Eq RunOutcome Source # | |
Defined in Conformance.Replay Methods (==) :: RunOutcome -> RunOutcome -> Bool Source # (/=) :: RunOutcome -> RunOutcome -> Bool Source # | |
One evaluation: which bytes, under which limit, using what, how it ended.
Constructors
| ReplayRun | |
Fields
| |
Classes
data UnobservedCause Source #
Why a replay admits no reason. Each is distinct; none stands for another.
Constructors
| CaptureIncomplete | the capture does not resolve every output the transaction names |
| ContextUnavailable | the ledger's arguments for the failing purpose could not be built |
| ToolchainMismatch | the deployed blueprint is not the one the traced build corresponds to |
| NoReplayRoute | the failing script's family is identified, but the replay traces none of it |
| ParametersMismatch | the family is identified by the capture; its applications do not reproduce the hash |
| UnidentifiedScript | no family is identified and no application is claimed |
| DeployedSucceeds | |
| DeployedBudget | |
| TracedSucceeds | |
| TracedBudget | |
| NoUserTrace | the traced run failed without a user-defined trace |
| SeveralUserTraces | the traced run failed with more than one user-defined trace |
| Phase1 | the node rejected the transaction before any script ran |
| SetupFailure | the run could not reach the evaluation |
| Timeout | |
| ClientException | |
| EvaluatorFailed | the evaluator itself failed, on either run |
Instances
causeName :: UnobservedCause -> Text Source #
The cause as the replay evidence spells it.
data ReplayClass Source #
What a replay establishes about the chain-side reason.
Constructors
| Admitted Text | |
| Unobserved UnobservedCause |
Instances
| ToJSON ReplayClass Source # | |
Defined in Conformance.Replay Methods toJSON :: ReplayClass -> Value toEncoding :: ReplayClass -> Encoding toJSONList :: [ReplayClass] -> Value toEncodingList :: [ReplayClass] -> Encoding omitField :: ReplayClass -> Bool | |
| Show ReplayClass Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> ReplayClass -> ShowS Source # show :: ReplayClass -> String Source # showList :: [ReplayClass] -> ShowS Source # | |
| Eq ReplayClass Source # | |
Defined in Conformance.Replay Methods (==) :: ReplayClass -> ReplayClass -> Bool Source # (/=) :: ReplayClass -> ReplayClass -> Bool Source # | |
admitReason :: ReplayRun -> ReplayRun -> Maybe UnobservedCause -> ReplayClass Source #
Decide what the deployed run and the traced run admit. An earlier cause (capture, toolchain, parameters, or the run never reaching evaluation) wins.
userTraces :: [Text] -> [Text] Source #
The user-defined lines of an evaluation log. The traced build keeps only user-defined traces, so every non-blank line is one.
data ScriptFamily Source #
A validator family the replay can recognise a failing hash by.
Constructors
| ScriptFamily | |
Fields
| |
Instances
| Show ScriptFamily Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> ScriptFamily -> ShowS Source # show :: ScriptFamily -> String Source # showList :: [ScriptFamily] -> ShowS Source # | |
| Eq ScriptFamily Source # | |
Defined in Conformance.Replay Methods (==) :: ScriptFamily -> ScriptFamily -> Bool Source # (/=) :: ScriptFamily -> ScriptFamily -> Bool Source # | |
identifyScript :: [ScriptFamily] -> Maybe Text -> Text -> Either UnobservedCause Text Source #
Which family a failing hash belongs to: a routed family whose candidate
reproduces it is replayed; an unrouted one is NoReplayRoute; a family the
capture records for the script (its role), none of whose candidates reproduce
it, is ParametersMismatch; otherwise UnidentifiedScript.
Comparison
data ReasonComparison Source #
A refused step's chain-side reason against the model's.
Constructors
| Agrees | |
| Differs | |
Fields
| |
| Uncompared UnobservedCause | |
Instances
| Show ReasonComparison Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> ReasonComparison -> ShowS Source # show :: ReasonComparison -> String Source # showList :: [ReasonComparison] -> ShowS Source # | |
| Eq ReasonComparison Source # | |
Defined in Conformance.Replay Methods (==) :: ReasonComparison -> ReasonComparison -> Bool Source # (/=) :: ReasonComparison -> ReasonComparison -> Bool Source # | |
compareReason :: Text -> ReplayClass -> ReasonComparison Source #
Compare an admitted reason with Lean's; an unobserved one is not compared.
stepComparison :: Text -> Text -> [(Text, ReplayClass)] -> ReasonComparison Source #
A refused step's comparison: the purposes of the script the step is
judged by (its marker hash) against Lean's reason. It agrees only when every
such purpose agrees; any purpose that differs makes it differ; otherwise it
is uncompared, with the first cause — or ContextUnavailable when the
marker's script is not among the failing purposes at all.
comparisonName :: ReasonComparison -> Text Source #
The comparison as the replay index spells it.
admittedFor :: Text -> [(Text, ReplayClass)] -> Maybe Text Source #
The reason the marker's script admitted, when every purpose of it admits the same one.
Evidence
data PurposeReplay Source #
One failing purpose of one rejected transaction, and its two runs.
Constructors
| PurposeReplay | |
Fields
| |
Instances
| ToJSON PurposeReplay Source # | |
Defined in Conformance.Replay Methods toJSON :: PurposeReplay -> Value toEncoding :: PurposeReplay -> Encoding toJSONList :: [PurposeReplay] -> Value toEncodingList :: [PurposeReplay] -> Encoding omitField :: PurposeReplay -> Bool | |
| Show PurposeReplay Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> PurposeReplay -> ShowS Source # show :: PurposeReplay -> String Source # showList :: [PurposeReplay] -> ShowS Source # | |
| Eq PurposeReplay Source # | |
Defined in Conformance.Replay Methods (==) :: PurposeReplay -> PurposeReplay -> Bool Source # (/=) :: PurposeReplay -> PurposeReplay -> Bool Source # | |
acceptingControlGaps :: [Value] -> [Text] Source #
What the replay index lacks for FR-13: every script role a refusal names
(a validator title — a bare hash names no family a control could replay) needs
an accepting-control entry in which that role's deployed and traced runs
both succeeded. One line per missing or failing role; none when complete.
data TracedProvenance Source #
The traced build's provenance, as the flake writes it beside it.
Constructors
| TracedProvenance | |
Fields
| |
Instances
| FromJSON TracedProvenance Source # | |
Defined in Conformance.Replay Methods parseJSON :: Value -> Parser TracedProvenance parseJSONList :: Value -> Parser [TracedProvenance] omittedField :: Maybe TracedProvenance | |
| Show TracedProvenance Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> TracedProvenance -> ShowS Source # show :: TracedProvenance -> String Source # showList :: [TracedProvenance] -> ShowS Source # | |
| Eq TracedProvenance Source # | |
Defined in Conformance.Replay Methods (==) :: TracedProvenance -> TracedProvenance -> Bool Source # (/=) :: TracedProvenance -> TracedProvenance -> Bool Source # | |
toolchainCause :: TracedProvenance -> Map Text Text -> Maybe UnobservedCause Source #
ToolchainMismatch unless the deployed blueprint's validators are
exactly the ones the traced build's untraced twin produced, hash for hash.
captureIdOf :: [(FilePath, ByteString)] -> Text Source #
The identity of a capture: SHA-256 over each file's canonical name and content hash, in name order, so the order the files were written in does not move it.
Receipt evidence
data ReplayEvidence Source #
One failing purpose's replay as a receipt carries it: the hash the node reported, the traced hash of the same parameters once the replay applied one, the reason it admitted or the cause it admits none — never both — and the capture it was replayed from.
Constructors
| ReplayEvidence | |
Fields
| |
Instances
| FromJSON ReplayEvidence Source # | |
Defined in Conformance.Replay Methods parseJSON :: Value -> Parser ReplayEvidence parseJSONList :: Value -> Parser [ReplayEvidence] omittedField :: Maybe ReplayEvidence | |
| ToJSON ReplayEvidence Source # | |
Defined in Conformance.Replay Methods toJSON :: ReplayEvidence -> Value toEncoding :: ReplayEvidence -> Encoding toJSONList :: [ReplayEvidence] -> Value toEncodingList :: [ReplayEvidence] -> Encoding omitField :: ReplayEvidence -> Bool | |
| Show ReplayEvidence Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> ReplayEvidence -> ShowS Source # show :: ReplayEvidence -> String Source # showList :: [ReplayEvidence] -> ShowS Source # | |
| Eq ReplayEvidence Source # | |
Defined in Conformance.Replay Methods (==) :: ReplayEvidence -> ReplayEvidence -> Bool Source # (/=) :: ReplayEvidence -> ReplayEvidence -> Bool Source # | |
Arguments
| :: Maybe Text | the capture's identity |
| -> [Text] | the failing hashes the node reported |
| -> [PurposeReplay] | |
| -> [ReplayClass] | what the replay established, in the index's order |
| -> [ReplayEvidence] |
A rejection's evidence, one entry per failing purpose the replay met; a replay that ended before reaching any purpose gives each failing hash the cause it ended with.
data ReplayCorrespondence Source #
The traced build a receipt's replay reasons rely on: its source, compiler and trace flags, and a digest of the untraced hashes it was held to.
Constructors
| ReplayCorrespondence | |
Fields
| |
Instances
| FromJSON ReplayCorrespondence Source # | |
Defined in Conformance.Replay Methods parseJSON :: Value -> Parser ReplayCorrespondence parseJSONList :: Value -> Parser [ReplayCorrespondence] omittedField :: Maybe ReplayCorrespondence | |
| ToJSON ReplayCorrespondence Source # | |
Defined in Conformance.Replay Methods toJSON :: ReplayCorrespondence -> Value toEncoding :: ReplayCorrespondence -> Encoding toJSONList :: [ReplayCorrespondence] -> Value toEncodingList :: [ReplayCorrespondence] -> Encoding omitField :: ReplayCorrespondence -> Bool | |
| Show ReplayCorrespondence Source # | |
Defined in Conformance.Replay Methods showsPrec :: Int -> ReplayCorrespondence -> ShowS Source # show :: ReplayCorrespondence -> String Source # showList :: [ReplayCorrespondence] -> ShowS Source # | |
| Eq ReplayCorrespondence Source # | |
Defined in Conformance.Replay Methods (==) :: ReplayCorrespondence -> ReplayCorrespondence -> Bool Source # (/=) :: ReplayCorrespondence -> ReplayCorrespondence -> Bool Source # | |
correspondenceOf :: TracedProvenance -> ReplayCorrespondence Source #
The correspondence a traced build's provenance states.