◇ OpenCyber Academy
Bachelor's · Chapter 30 · English

Chapter 30 — Laboratory II

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Chapter 30 — Laboratory II

Lesson map

Lesson 30 published. Map, example, EX088.

flowchart TD
  N0["Learning outcomes"]
  N1["30.1 Configuration as evidence"]
  N2["Lab — Deployment configuration check"]
  N3["30.2 Reading the result"]
  N4["30.3 Deciding whether to deploy"]
  N5["Synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5
  N5 --> EX["Worked example"]
  EX --> Q["Exercise EX088"]

Logical drawing

flowchart LR
  N0["Learning outcomes"]
  N1["30.1 Configuration as evidence"]
  N2["Lab — Deployment configuration check"]
  N3["30.2 Reading the result"]
  N4["30.3 Deciding whether to deploy"]
  N5["Synthesis"]
  N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX088"]
[Learning outcomes]
    |
    v
[30.1 Configuration as evidence]
    |
    v
[Lab — Deployment configuration check]
    |
    v
[30.2 Reading the result]
    |
    v
[30.3 Deciding whether to deploy]
    |
    v
[Synthesis]
    |
    v
[Worked example] --> [Exercise EX088]

Learning outcomes

You will (1) check a deployment configuration against policy; (2) interpret configuration findings; (3) decide whether to deploy.

30.1 Configuration as evidence

Before deploying an updated voucher contract, the cooperative's policy requires checks: the treasury multisig has at least two signers, mint and upgrade actions have timelocks of at least 48 hours, the compiler is pinned, and every test passes. Sofia writes these as a small read-only script that reads a synthetic configuration and reports any differences from the policy. Turning policy into an automatic check means it is applied the same way every time, without relying on memory, and the output becomes evidence for the deployment decision recorded by the board.

Lab — Deployment configuration check

"""Check a synthetic deployment configuration against a written policy (read-only)."""
CONFIG = {
    "treasury_threshold": (2, 3), "mint_timelock_h": 24, "upgrade_timelock_h": 48,
    "pause_holders": 2, "compiler_pinned": True, "tests_passed": 41, "tests_total": 42,
}
def main():
    issues = []
    m, n = CONFIG["treasury_threshold"]
    if m < 2:
        issues.append("treasury needs at least 2 signers")
    for k in ("mint_timelock_h", "upgrade_timelock_h"):
        if CONFIG[k] < 48:
            issues.append(f"{k} {CONFIG[k]} < 48")
    if not CONFIG["compiler_pinned"]:
        issues.append("compiler not pinned")
    if CONFIG["tests_passed"] != CONFIG["tests_total"]:
        issues.append(f"tests {CONFIG['tests_passed']}/{CONFIG['tests_total']}")
    print(f"checks 4; issues {len(issues)}")
    for i in issues:
        print(" -", i)

if __name__ == "__main__":
    main()

Run with python3 lab_config.py. Verified output:

checks 4; issues 2
 - mint_timelock_h 24 < 48
 - tests 41/42

30.2 Reading the result

The script runs four checks and reports two issues. The mint timelock is 24 hours, below the 48-hour policy, and 41 of 42 tests pass. The treasury threshold of two of three and the pinned compiler meet the policy. Sofia investigates: the developer had shortened the mint timelock during testing to speed things up and forgot to restore it; the failing test concerns the zero-amount check added after the tool review. Both are fixable. She records the findings with the configuration version and date, so the record can be compared with the next run.

30.3 Deciding whether to deploy

Sofia recommends not deploying until both issues are fixed. The developer restores the 48-hour timelock and fixes the failing test, and the script then reports no issues. The board approves deployment at its next meeting, and two keyholders sign the deployment. Sofia notes that a configuration check is only as good as its policy: if the policy omits something important, the script will not catch it. She proposes reviewing the policy annually. Automated checks make good decisions easier, but people still decide, and the decision is recorded with its evidence.

Worked example

The script reports a 24-hour mint timelock below 48 and 41/42 tests passing; both are fixed before the board approves deployment.

Synthetic case. The configuration and deployment are synthetic.

Errors and limits

A configuration check cannot catch risks its policy does not include.

Exercises

Synthesis

Policy-as-checks provide consistent deployment evidence, while people make the final decision.

Continue studying — chapter 30 of 40

← Chapter 29 (draft) · Course chapter index · Chapter 31 (draft) →