Skip to content

Commit

Permalink
Move runtime folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Remco Bloemen committed Aug 18, 2019
1 parent 37c7083 commit 13b77bf
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,17 @@ jobs:
do
wasm-gc $i.wasm $i.compact.wasm
done
# TODO: Copy to root folder or something
# TODO: Update include location in substrate-note for native support
# TODO:
- run:
name: Lint with rustformat nightly
command: cargo +$NIGHTLY fmt $PROJECTS -- --check
# TODO: Also cover substrate projects
- run:
name: Lint with clippy
command: cargo clippy $PROJECTS --all-targets
# TODO: Also cover substrate projects
- run:
name: Test debug build
command: cargo test $PROJECTS -- --nocapture
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"macros_impl",
"macros_lib",
"substrate-node",
"substrate-runtime",
]

# Don't forget to run `cargo clean` to force a rebuild of all dependencies!
Expand Down
105 changes: 105 additions & 0 deletions notebook/StarkProof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Stark Proof

* $\mathbb{F}$: Finite field with roots of unity $ω_n$ of order $n$.
* $N$: Trace table length.
* $W$: Number of columns.
* $g = ω_N$: Generator for the trace table.
* $G = \{g^i | i \in [0, N)\}$
* $β = 16$: Blowup factor.
* $ω$: Generator for the extended domain.
* $Ω = \{ω^i | i \in [0, β N)\}$ extended evaluation domain.
* $z$: Out of domain sampling value.
* $T \in \mathbb{F}^{N \times W}$: Trace table such tat $T_{ij}$ is the $j$th column of the $i$th row.
* $T_i(x) \in \mathbb{F}[x]$ column polynomial such that $T_i(g^j) = T_{ij}$.

## Constraints

The constraints are multivariate algebraic functions over the trace table. The constraints are parameterized by the public inputs.

A Stark proofs the claim that the prover knowns a trace table that satisfies all
the constraints.



## Proof system

Public inputs can be either

* field elements that show up in the constraints, or
* exponents that show up in the zeros-fraction.

Trace table:

The trace table has $N$ rows and some small (<1000) number of columns. Let the
$i$th column be interpolated on domain $G$ to produce a polynomial $T_i(x)$ such
that $T_i(g^j)$ is the value in the $i$th row and $j$th column.

Constraints:

$$
C_i(x) = B_i(T) \frac{N_i(x)}{D_i(x)}
$$

where $B_i$ is some relation between the trace table fields that is required to
be zero on certain rows and $N/D$ an expression that divides out these rows.
Typical values for $N/D$ are:

$$
\begin{aligned}
\frac{1}{x - g^i} && && &&
\frac{x - g^N}{x^N - 1} &&
\end{aligned}
$$

The first means the constraint only applies at row $i$, the second that it
applies everywhere. (TODO: Example where it applies every $m$th row.)

Typical expressions for $B$ are:

$$
\begin{aligned}
T_0(x) - c && && &&
T_1(x⋅g) - T_0(x) - T_1(x) &&
\end{aligned}
$$

Where the first means the value in column $0$ is equal to $c$ and the second
means the value in column $1$ in the next row is the sum of the values in
columns $0$ and $1$ in the current row.

## Proof transcript

0. Setup.

The prover and verifier agree on a constraint system, the Stark construction and
security parameters.

1. P->V: Public inputs.

Prover sends the public inputs.

1. P->V: Trace table commitment on LDE points.

The trace polynomials are evaluated on $Ω$ and the values committed to with a
merkle tree.

Each leaf is a vector of the columns evaluated at that leaf:

$$
[T_0(ω^i), T_1(ω^i), ... T_M(ω^i)]
$$

2. V->P: Constraint coefficients

Two for each constraint: one for the plain constraint and one for the
degree adjusted constraint.

Later, in the FRI part we will proof that these polynomials have degree less than
or equal to $N$. Our constraints have could be of different degree, for example.

**Example.**

3. P->V: Combined constraint on LDE points

4. V->P: Out of domain sampling value

2 changes: 1 addition & 1 deletion substrate-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package = 'substrate-network'
rev = 'fc206f3a009b64fc746202e5b4c701bf7e24d1f1'

[dependencies.substrate-node-runtime]
path = 'runtime'
path = '../substrate-runtime'

[dependencies.primitives]
git = 'https://github.com/paritytech/substrate.git'
Expand Down
22 changes: 0 additions & 22 deletions substrate-node/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
# Our substrate node
This package is a thin node template from the substrate team which we are modifying to run the STARK based exchange chain. Please see below for the node building and deploying instructions from the Substrate team :

# Building

Install Rust:

```bash
curl https://sh.rustup.rs -sSf | sh
```

Install required tools:

```bash
./scripts/init.sh
```

Build the WebAssembly binary:

```bash
./scripts/build.sh
```

Build all native code:

```bash
cargo build
```
Expand Down
26 changes: 0 additions & 26 deletions substrate-node/scripts/build.sh

This file was deleted.

16 changes: 0 additions & 16 deletions substrate-node/scripts/init.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[package]
authors = ['Parity Technologies <[email protected]>']
edition = '2018'
name = 'substrate-node-runtime'
version = '1.0.0'

[features]
default = ['std']
std = [
Expand Down Expand Up @@ -30,11 +36,6 @@ primefield = { path = "../../primefield", default_features = false}
u256 = { path = "../../u256", default_features = false}
macros-decl = { path = "../../macros_decl" }

[package]
authors = ['Parity Technologies <[email protected]>']
edition = '2018'
name = 'substrate-node-runtime'
version = '1.0.0'
[dependencies.aura]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 13b77bf

Please sign in to comment.