Synthetic demo datademo

Every block, transaction, address and hash on this chain is generated from a fixed seed. None of them exists on any network, and none of these values can be looked up anywhere else. The execution trace is real — it is a recorded Noir program — but it is not the execution of the transaction it is published under.

Verified source

0x78e9…8f93

0x78e90b3df9e8d22c227fbe2ff98a7e1ce2778f93

Verification

Code hash
0xde6a9f6f42c73c881d63b726b7171a6816a49de8
Status
full match
Provider
demo-vendored
Compiler
nargo 1.0.0-beta.26
Language
noir
Bundle
sha1:5ecec0583d0a5755ad163b7460e254b420fbd981

Sources

Nargo.toml7 lines
1[package]
2name = "tour_branches"
3type = "bin"
4authors = ["BlockTracer capability tour"]
5
6[dependencies]
7
Prover.toml3 lines
1low = "-77"
2high = "88"
3
src/main.nr77 lines
1// TOUR: branches and conditions
2//
3// The subject is which arm ran. Every `if` below is written so that BOTH arms
4// are reachable and the inputs decide, and the program calls each classifier
5// more than once with values that land in different arms — so the same source
6// line is marked taken on one visit and not-taken on another.
7//
8// A branch that can only go one way is a branch the marking cannot teach
9// anything about, so there are none of those here.
10
11struct Reading {
12 sensor: u8,
13 value: i32,
14}
15
16unconstrained fn classify(value: i32) -> u8 {
17 // A three-way chain. Exactly one arm runs per call, and the three calls in
18 // `main` between them run all three.
19 if value < -50 {
20 0 // under
21 } else if value > 50 {
22 2 // over
23 } else {
24 1 // nominal
25 }
26}
27
28unconstrained fn clamp(value: i32, lo: i32, hi: i32) -> i32 {
29 // Nested conditions: the outer test decides whether the inner one is
30 // reached at all, so a not-taken outer arm hides an inner branch that was
31 // never evaluated rather than one that was evaluated and went the other
32 // way. Those are different facts and the marking distinguishes them.
33 let mut out = value;
34 if value < lo {
35 out = lo;
36 } else {
37 if value > hi {
38 out = hi;
39 }
40 }
41 out
42}
43
44unconstrained fn describe(r: Reading) -> u8 {
45 // Boolean operators in the condition itself, so the condition is worth
46 // inspecting and not just its outcome.
47 let known = (r.sensor == 1) | (r.sensor == 2);
48 let extreme = (r.value < -50) | (r.value > 50);
49 if known & extreme {
50 9
51 } else if known {
52 classify(r.value)
53 } else {
54 255 // unknown sensor
55 }
56}
57
58unconstrained fn main(low: i32, high: pub i32) -> pub u32 {
59 // Three readings chosen so the three arms of `classify` each run once and
60 // `describe`'s unknown-sensor arm runs exactly once.
61 let a = describe(Reading { sensor: 1, value: low });
62 let b = describe(Reading { sensor: 2, value: 12 });
63 let c = describe(Reading { sensor: 7, value: high });
64
65 let clamped_low = clamp(low, -10, 10);
66 let clamped_mid = clamp(3, -10, 10);
67 let clamped_high = clamp(high, -10, 10);
68
69 assert(clamped_mid == 3);
70 assert(clamped_low == -10);
71 assert(clamped_high == 10);
72
73 // Widened before summing: `describe` answers in a `u8` and three of its
74 // answers do not fit in one.
75 a as u32 + b as u32 + c as u32
76}
77
This is a circuit, not a contract. It declares no ABI and no storage layout, so there is no interface list and no slot mapping to show. The source above is the whole of what it publishes.

Deployments

This code is deployed at one address. Any other address running the same bytecode would appear here too, already verified.