{-# OPTIONS --safe #-}
open import Prelude
open import Hash
open import Jolteon.Assumptions
module Jolteon.Properties.Steps.Blocks (⋯ : _) (open Assumptions ⋯) where
open import Jolteon ⋯
open import Jolteon.Properties.State.Messages ⋯
open import Jolteon.Properties.State.Invariants ⋯
open import Jolteon.Properties.Steps.Core ⋯
open import Jolteon.Properties.Steps.Voting ⋯
open import Jolteon.Properties.Steps.QCHigh ⋯
b∈⇒ch∈ : ∀ {s} → ⦃ _ : Honest p ⦄ → Reachable s → let db = (s @ p) .db in
b ∙∈ db
────────────────────────
∃ λ (ch : Chain) →
(b ∷ ch) ∙∈ db
b∈⇒ch∈ {p} (_ , refl , (_ ∎)) b∈
rewrite pLookup-replicate p initLocalState
= contradict b∈
b∈⇒ch∈ {p}{b} ⦃ hp ⦄ (_ , s-init , (s' ⟨ st₀ ∣ s ⟩←— tr)) b∈
with Rs ← _ , s-init , tr
with IH ← b∈⇒ch∈ {p}{b} Rs
with st₀
... | WaitUntil _ _ _
= IH b∈
... | Deliver {tpm} _
rewrite receiveMsg-ls≡ {p}{s .stateMap} (honestTPMessage tpm)
= IH b∈
... | DishonestLocalStep _ _ = IH b∈
... | LocalStep {p = p′} {ls′ = ls′} st
with p ≟ p′
... | no p≢ rewrite pLookup∘updateAt′ p p′ {const ls′} (p≢ ∘ ↑-injective) (s .stateMap)
= IH b∈
... | yes refl rewrite pLookup∘updateAt p ⦃ hp ⦄ {const ls′} (s .stateMap)
with st
... | InitTC _ _
= IH b∈
... | InitNoTC _ _
= IH b∈
... | ProposeBlockNoOp _ _
= IH b∈
... | EnoughTimeouts _ _ _ _
= IH b∈
... | RegisterTimeout _ _ _ _
= map₂ chain-∈-mono $ IH b∈
... | RegisterTC _ _ _ _
= map₂ chain-∈-mono $ IH b∈
... | TimerExpired _ _
= IH b∈
... | RegisterVote _ _ _ _ _ _
= map₂ chain-∈-mono $ IH b∈
... | AdvanceRoundQC _ _ _
= IH b∈
... | AdvanceRoundTC _ _ _
= IH b∈
... | AdvanceRoundNoOp _ _ _
= IH b∈
... | Lock _ _
= IH b∈
... | Commit _ _
= IH b∈
... | CommitNoOp _ _
= IH b∈
... | VoteBlock _ _ _
= IH b∈
... | VoteBlockNoOp _ _
= IH b∈
... | ProposeBlock {txn = txn} ph≡ _
= IH b∈
... | RegisterProposal _ _ _ _ vp@(_ , mk {ch} ch∈ b↝)
with ⟫ b∈
... | ⟫ there b∈ = map₂ chain-∈-mono $ IH b∈
... | ⟫ here refl
with b .blockQC ≟ qc₀
... | yes refl
= [] , here refl ∷ []
⊣ connects∶ refl refl
(ValidProposal⇒ValidBlock vp)
... | no qc₀≢ = ch , b∈ ∷ chain-∈-mono ch∈ ⊣ b↝