Skip to content

Commit

Permalink
Merge pull request #153 from 0xPolygonMiden/dominik-remove-old-tx-pro…
Browse files Browse the repository at this point in the history
…of-section

try with no-verify
  • Loading branch information
Dominik1999 authored Oct 10, 2023
2 parents 226d5d2 + 965fa1a commit 62fc868
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ Playground for example programs for the [Miden VM](https://github.com/0xPolygonM

The goal of this playground is for developers to see how easy it is to write and execute code in Miden assembly. The examples come from the community and the team. If you come up with an example of your own, we are happy to include it in the list below. You can simply open a PR with your example adding the `.masm` and `.inputs` files.

Examples are written in Miden assembly, see [Miden assembly documentation](https://wiki.polygon.technology/docs/miden/user_docs/assembly/main/). External inputs can be provided to the examples and the Miden VM in two ways as public inputs and via the advice provider, see [here](https://wiki.polygon.technology/docs/miden/intro/overview/#inputs-and-outputs). Currently, in the playground you can use `operand_stack` as public input and the `advice_stack` as secret input.
Examples are written in Miden assembly, see [Miden assembly documentation](https://wiki.polygon.technology/docs/miden/user_docs/assembly/main/). External inputs can be provided to the examples and the Miden VM in two ways as public inputs and via the advice provider, see [here](https://wiki.polygon.technology/docs/miden/intro/overview/#inputs-and-outputs). Currently, in the playground you can use `operand_stack` as public input and the `advice_stack` as secret input.

In addition to running existing examples you can also write your own program and execute it. The examples can then serve as inspiration.
In addition to running existing examples you can also write your own program and execute it. The examples can then serve as inspiration.

---

## Available examples

There are several examples in our repo and we hope we get more in the future. The examples range from simple to complex and aim to show how Miden assembly can be used.

### Simple examples - to see how the code works
Expand All @@ -20,22 +22,23 @@ There are several examples in our repo and we hope we get more in the future. Th

- **Conditional**: A program which either adds or multiplies two numbers - 3 and 5 - based on the value provided via the advice tape as secret input.

### Math examples - see more complex numerical calculations
### Math examples - see more complex numerical calculations

- **Collatz**: A program which executes an unbounded loop to compute a Collatz sequence which starts with the provided value; the output of the program is the number of steps needed to reach 1 - the end of the sequence.

- **Fibonnacci**: Elegant way to calculate the 1001st fibonacci number.
- **Fibonnacci**: Elegant way to calculate the 1001st fibonacci number.

- **nPrime**: Program to calculate the n-th prime number. It will return all prime numbers up to the n-th prime number which is on top of the stack.
- **nPrime**: Program to calculate the n-th prime number. It will return all prime numbers up to the n-th prime number which is on top of the stack.

### Complex examples - larger complex nested operations

- **Game-of-Life**: Implementation of Conway's Game of Life. But we can prove it. The static example runs on a 4x4 cell universe and 1000 generations.

---

## Running the playground locally

You can also run the playground locally on your machine.
You can also run the playground locally on your machine.

### Starting site

Expand All @@ -55,6 +58,6 @@ Test rust code:
cd miden-wasm && wasm-pack test --node
```

### Acknowledgement
### Acknowledgement

We use a fork of https://github.com/timgestson/miden-assembly-playground
11 changes: 6 additions & 5 deletions benchmarking-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
# Benchmarking CLI for Miden Examples

This is a simple CLI that enables users to benchmark the Miden examples. You can run any example in https://github.com/0xPolygonMiden/examples/tree/main/examples.
This is a simple CLI that enables users to benchmark the Miden examples. You can run any example in https://github.com/0xPolygonMiden/examples/tree/main/examples.

## Usage

To run the fibonacci example, you can either run

```
cargo build
```

and then
and then

```
./target/debug/miden-benchmarking-cli --example fibonacci
```

OR you run
OR you run

```
cargo run --release -- -e fibonacci
cargo run --release -- -e fibonacci
```

You can pass two additional parameters to the CLI `security` and `output`. `security` can be `"high"` for 128-bit security and will default to 96-bit. `output` defines the number of stack outputs the program returns. It defaults to 1.
You can pass two additional parameters to the CLI `security` and `output`. `security` can be `"high"` for 128-bit security and will default to 96-bit. `output` defines the number of stack outputs the program returns. It defaults to 1.

In general the CLI works as follows:

Expand Down
13 changes: 7 additions & 6 deletions playground/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repos:
rev: v3.0.3
hooks:
- id: prettier
exclude: ^src/utils/helper_functions.tsx

- repo: https://github.com/hackaugusto/pre-commit-cargo
rev: v1.0.0
Expand All @@ -14,25 +15,25 @@ repos:
name: Cargo fmt
args: ['+stable', 'fmt', '--all']
stages: [commit]
files: ^examples/playground/miden-wasm/src/
files: ^examples/playground/miden-wasm/.*\.rs$
# Requires code to be properly formatted prior to pushing upstream
- id: cargo
name: Cargo fmt --check
args: ['+stable', 'fmt', '--all', '--check']
stages: [push, manual]
files: ^examples/playground/miden-wasm/src/
files: ^examples/playground/miden-wasm/.*\.rs$
- id: cargo
name: Cargo check --all-targets
args: ['+stable', 'check', '--all-targets']
files: ^examples/playground/miden-wasm/
files: ^examples/playground/miden-wasm/.*\.rs$
- id: cargo
name: Cargo check --all-targets --no-default-features
args: ['+stable', 'check', '--all-targets', '--no-default-features']
files: ^examples/playground/miden-wasm/src/
files: ^examples/playground/miden-wasm/.*\.rs$
- id: cargo
name: Cargo check --all-targets --all-features
args: ['+stable', 'check', '--all-targets', '--all-features']
files: ^examples/playground/miden-wasm/
files: ^examples/playground/miden-wasm/.*\.rs$
# Unlike fmt, clippy will not be automatically applied
- id: cargo
name: Cargo clippy
Expand All @@ -47,4 +48,4 @@ repos:
'--deny',
'warnings'
]
files: ^examples/playground/miden-wasm/src/
files: ^examples/playground/miden-wasm/.*\.rs$
2 changes: 1 addition & 1 deletion playground/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ignore artifacts:
build
coverage
miden-wasm
src/utils/helper_functions.tsx
13 changes: 5 additions & 8 deletions playground/src/utils/helper_functions.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// prettier-ignore-file
import * as yup from 'yup';
import type { DebugOutput } from 'miden-wasm';

Expand Down Expand Up @@ -140,17 +141,15 @@ export const checkInputs = (inputString: string): checkedData => {
let input: JSON;
try {
input = JSON.parse(inputString);
} catch (error: any) {
// eslint-disable-line @typescript-eslint/no-explicit-any
} catch (error: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
const errorMessage = `Inputs must be a valid JSON object: ${error.message}`;
return { isValid: false, errorMessage: errorMessage };
}

try {
inputSchema.validateSync(input, { strict: true, stripUnknown: false });
return { isValid: true, errorMessage: '' };
} catch (error: any) {
// eslint-disable-line @typescript-eslint/no-explicit-any
} catch (error: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
return { isValid: false, errorMessage: `Invalid inputs: ${error.message}` };
}
};
Expand All @@ -176,8 +175,7 @@ export function checkOutputs(jsonString: string): checkedData {
let jsonOutput!: JSON;
try {
jsonOutput = JSON.parse(jsonString);
} catch (e: any) {
// eslint-disable-line @typescript-eslint/no-explicit-any
} catch (e: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
const errorMessage = `Miden VM Outputs need to be a valid JSON object:
${e.message}
Did you prove the program first?`;
Expand All @@ -190,8 +188,7 @@ Did you prove the program first?`;
stripUnknown: false
});
return { isValid: true, errorMessage: '' };
} catch (error: any) {
// eslint-disable-line @typescript-eslint/no-explicit-any
} catch (error: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
return {
isValid: false,
errorMessage: `Invalid outputs: ${error.message}`
Expand Down

0 comments on commit 62fc868

Please sign in to comment.