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

0x9c09…af17

0x9c09231a9a38481bb52e7ffdf369c6d9a694af17

Verification

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

Sources

Nargo.toml7 lines
1[package]
2name = "tour_calls"
3type = "bin"
4authors = ["BlockTracer capability tour"]
5
6[dependencies]
7
Prover.toml3 lines
1n = "4"
2seed = "9"
3
src/arith.nr25 lines
1// A second module, so a step-in crosses a file boundary and the call trace
2// shows a frame whose source lives in a document the pane was not already
3// displaying.
4
5pub unconstrained fn mix(acc: u32, value: u32) -> u32 {
6 let rotated = rotate(acc, 7);
7 rotated ^ value
8}
9
10pub unconstrained fn finish(acc: u32) -> u32 {
11 let folded = rotate(acc, 13);
12 folded + 1
13}
14
15// The deepest frame in this module, and the only one with a loop in it — so a
16// step-out from here has a loop iteration to return into.
17unconstrained fn rotate(value: u32, by: u8) -> u32 {
18 let mut out = value;
19 for _ in 0..by {
20 let carry = out & 1;
21 out = (out >> 1) | (carry * 0x8000_0000);
22 }
23 out
24}
25
src/main.nr82 lines
1// TOUR: calls and recursion
2//
3// The subject is the call trace. This program builds a call tree that is worth
4// looking at rather than a flat list: recursion that goes several frames deep,
5// two functions that call each other, and a helper called from three different
6// places so the same frame appears in the tree under three different parents.
7//
8// Stepping into, over and out of a frame all need somewhere to go, and a
9// program whose deepest call is one frame gives them nowhere.
10
11mod arith;
12
13unconstrained fn factorial(n: u32) -> u32 {
14 // Direct recursion. Frame depth is `n + 1`, so calling it with 5 puts six
15 // frames of the same function on the stack, each with a different `n` —
16 // which is the case that distinguishes a call trace from a source view.
17 if n <= 1 {
18 1
19 } else {
20 n * factorial(n - 1)
21 }
22}
23
24unconstrained fn is_even(n: u32) -> bool {
25 // Mutual recursion, the pair. `is_even` and `is_odd` alternate all the way
26 // down, so the trace shows two names interleaving rather than one repeating.
27 if n == 0 {
28 true
29 } else {
30 is_odd(n - 1)
31 }
32}
33
34unconstrained fn is_odd(n: u32) -> bool {
35 if n == 0 {
36 false
37 } else {
38 is_even(n - 1)
39 }
40}
41
42unconstrained fn fib(n: u32) -> u32 {
43 // Tree recursion: each call makes TWO calls, so the trace branches instead
44 // of descending. `fib(6)` is 25 calls — small enough to read, large enough
45 // that the shape is a tree and not a line.
46 if n < 2 {
47 n
48 } else {
49 fib(n - 1) + fib(n - 2)
50 }
51}
52
53unconstrained fn checksum(values: [u32; 4]) -> u32 {
54 // A frame that calls into another module, so stepping in crosses a file
55 // boundary and the source pane has to follow.
56 let mut total: u32 = 0;
57 for i in 0..4 {
58 total = arith::mix(total, values[i]);
59 }
60 arith::finish(total)
61}
62
63unconstrained fn main(n: u32, seed: pub u32) -> pub u32 {
64 let f = factorial(5);
65 let even = is_even(n);
66 let t = fib(6);
67 let c = checksum([seed, seed + 1, seed + 2, seed + 3]);
68
69 // `arith::mix` is reached from `checksum` above and directly from here, so
70 // the same function has two distinct parents in the call trace.
71 let direct = arith::mix(f, t);
72
73 assert(f == 120);
74 assert(t == 8);
75 assert(even);
76
77 // Both halves are folded into a small range before being added: this
78 // program is about the shape of the call tree, and an arithmetic overflow
79 // in its last line would end the recording somewhere uninteresting.
80 (direct % 1000) + (c % 1000)
81}
82
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.