Giter Club home page Giter Club logo

starklings's Introduction

Starklings

An interactive tutorial to get you up and running with Starknet

This repository is no more maintained and has been moved to :

starklings-cairo1

Installation

Clone the repository to your local machine:

git clone --branch stable --single-branch https://github.com/onlydustxyz/starklings.git

Then install the tool, run:

curl -L https://raw.githubusercontent.com/onlydustxyz/starklings/master/install.sh | bash

Usage

Run the tool in watch mode in the repository and follow the instructions:

cd PATH_TO_THE_CLONED_REPO
starklings --watch

To verify an exercise without the watch mode run:

starklings --verify relative_path_to_the_exercise_file

To display one solution to a given exercise run:

starklings --solution relative_path_to_the_exercise_file

Update

The tool is in continuous evolution. You might want to update it regularly.

git pull
bash install.sh

Inspiration

  • Protostar for all the project tooling and setup, deployment, packaging
  • Rustlings for the amazing pedagogy and brilliant concept of progressive and interactive tutorial

Contributing

See CONTRIBUTING.md.

starklings's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starklings's Issues

Bitwise operations basic exercise

Description

Bitwise operations such as AND, OR, and XOR, are not basic operations for felts.
The Bitwise builtin is an ad-hoc module to enable those common operations
and require implicit arguments.

Write a basic exercise to demonstrate how to use bit-wise in Cairo.

Resource:

Acceptance criteria

  • Add a common library exercise on bit-wise operation using builtins
  • The contract compiles and tests pass
  • An exercise patch is generated

Exercise on packing data in felt using bitwise

Description

Felts can be used to pack multiple pieces of data more efficiently.
Show how to can encode and decode multiple variables in a felt using bitwise operations and bit masking.

Resource:

Acceptance criteria

  • Add a bitwise exercise on data packing
  • The contract compiles and tests pass
  • An exercise patch is generated

Beginner exercises ideas

Right now we have 5 beginners exercises, that cover:

  • storage
  • externals and views
  • structures
  • arrays and recursion
  • basic revocated references occurences

I believe we can add a few more exercises to cover more of cairo features and edge cases.
Feel free to submit ideas about what you would like to see this tutorial cover in the future !

Automate .patch files generation for new section

When adding a new section to the exercises, one must provide .patch files that contains the solutions
A tool to automatize the generation of such files would be welcome.
A shell script is probably the way to go here

Exercise on the uses of assert

Description

Show that Cairo uses the assert keyword for two purposes:

  • Verifying a value against a memory location
  • Assigning a value to a memory location

Resource:

Acceptance criteria

  • The exercise shows different uses of assert
  • The contract compiles and tests pass
  • An exercise patch is generated

Update to Cairo-lang 0.8.2

Starkware has released a new version of the Cairo lang, version 0.8.2, we might want to update our dependency/exercises.

CI: run tests on patched exercises in github action

We can do this using the patch_and_test_exercises.sh script and check if it returned an error code or 0.

To discuss:
In the current implementation the script test that each exercise that have a patch, pass the test.
Maybe we instead want to check for each existing exercises if 1) it have a patch 2) it pass the tests once patched
Should it be blocking in order to guarantee that every added exercise is doable ?

Run a smoke test when building binaries

Non-working binaries have been released in the past, which is not acceptable.

We must add a simple smoke test in the binary build workflow, running a simple --help would assure the binary at least runs without error.

Split beginner section into more thematic sections

Beginner section is a heritage from the Amsterdam workshop, and it would benefit from being split into thematic section based on what concept each exercise teaches.
This would help students work on a consistent pedagogical path.

Patches not processed correctly

Description

When displaying a solution with the command python starklings.py -s path/to/exercise.cairo, mid-file changes are applied one line above the actual changes which can break solutions.
This looks like an off-by-one issue in the patch library used in src/solutions.py

Acceptance criteria

  • Patching an exercise file should give the same output as patch exercise.cairo solution.cairo -o -

Use directly protostar test functions

We currently use a subprocess to call protostar, requiring the user to have protostar installed, which is unnecessary.
We can directly use Protostar as a library and call it to test our files.

Run a single check at a time

If the user saves multiple times a file, and the checker is still running, a new checker will be spawned for each save, making the tool check concurrently the same file.
We need to have a single check at a time to make the experience smooth for the user.

Find next exercise to do

  1. loop through a list of exercises
  2. parse each file
  3. stop on the first having the "I'm not done" comment
  4. Execute related test. And output Done / Not Done

Improve console prints

We'd like to follow Rustlings practice by clearing the console output when the program communicates with the user, instead of always appending to the previous prints.
This will make the console more readable and the experience enhanced.

Check for local repository state when running the CLI

Some users face issues when running a too recent version of the tool because they did not update their local repo. We should check that the release commit is present in the local commit history when running the tool to make sure it will run smoothly.

Iteration over struct

Description

Create a recursion exercise on iteration over structs using arrays pointers.
The exercise should use MyStruct.SIZE in the loop call and recover the struct using type casting.

Resources:

Acceptance criteria

  • The exercise explains how to loop through a struct array using recursion
  • The contract compiles and tests pass
  • An exercise patch is generated

Synchronization issues between binary and local repository

When the development team adds commits to the main branch, and the students git pull these changes without benefiting from an update of the CLI, they might encounter unwanted behaviour.
For example, removing the advanced exercises broke the CLI and needs a publish.

Exercise on the common math operations

Description

The common library contains predefined functions to handle common math operations.
Such as <, <=, > 0, range checks, absolute value, felt division.
Provide an exercise to learn how to use those functions.

Resource:

Acceptance criteria

  • The exercise showcase math common library functions
  • The contract compiles and tests pass
  • An exercise patch is generated

Migrate exercises to a protostar model

Current exercises are written in cairo, in a contracts folder. The test are written in python in the tests folder.

We want to replicate the process of Rustlings, so exercises must have their tests directly written in the exercise file, and organized in a exercises folder by pedagogic theme, such as storage or references for example.

Exercise on key pairs for the Stark Curve

Description

Show how to create stark_keys using a randomly generated private key.
Cairo has a python module for generating key pairs on the Stark curve.

Resource:

Acceptance criteria

  • The exercise show how to create stark keys
  • The contract compiles and tests pass
  • An exercise patch is generated

Add on exercise on arrays

Description

In Cairo, there are several natural ways of scanning array elements.
Provide an exercise on looping through an array in different traversal directions using recursion.

Exercise on verifying ECDSA signatures

Description

Users can sign messages using their stark_key as seen on the key pair exercise.
Cairo implements the signing in python and the verification in Cairo.
Provide an exercise that verifies a generated signature using the ecdsa builtin.

Resource:

Acceptance criteria

  • The exercise show how to securely verify an ECDSA signature.
  • The contract compiles and tests pass
  • An exercise patch is generated

feature: soluce command in the CLI

using this command (on a specific exercise or while in watch mode) will patch the exercise file with it's solution
steps:

  • git restore -s origin/main <path to exercise file> (in order to get rid of any user modification and avoid conflicts)
  • patch <path to exercise file> <path to corresponding patch file>

Add exercises about low-level cairo

Many exercises related to low-level cairo can be added, like:

  • low-level function calls, including:
    • retrieve function arguments / implicits / returns as a struct
    • how to pass arguments
    • how to retrieve arguments
  • how to be generic with structs (handle structs as felt*)

Solution not displaying and showing error

Hello,
I can't display the solution for an exercise.
How to reproduce this issue:
get to the root of the repo,
Use the command : starklings -s exercises/recursions/recursion01.cairo

image

Compatibility with protostar 0.2.0

Since protostar outputs changed with 0.2.0, we need to adapt the assertions we make in the wrapper around protostar.

Best solution would be to directly use the python API of Protostar, but we need the package to be published for that.

Cairo short strings basic exercise

Description

Implement a basic exercise to understand how short strings are defined in Cairo

Acceptance criteria

  • The exercise shows how Cairo handles felt-encoded strings
  • The contract compiles and tests pass
  • An exercise patch is generated

Exercises about recursions

Recursions are a big part of the Cairo language, they must be introduced as exercises.

From basic recursions to the very common recursive pointer update pattern, exercises should cover the most encountered recursive patterns found in Cairo.

Syntax learning track

We realized that the first exercise of the beginner track lost a lot of students, so we are bringing a sequel in the form of a syntax theme.

Demonstrate Cairo hints

Description

Hints are a very powerful tool when programming in Cairo, they allow deferring part of a computation to an external program.
With this great power comes the great responsibility of making sure the external computation is safe.

Write a basic exercise that demonstrate how to instantiate a variable inside a Cairo hint.

Resource:

Acceptance criteria

  • The exercise uses Cairo hints
  • The contract compiles and tests pass
  • An exercise patch is generated

Fix version printing

Currently the --version command fails at printing the tool version and the Cairo lang version.
This might be an issue with the file path used to grab the version in the pyproject.toml file.

Check exercises in the user directory

Exercises are currently checked in the binary directory, which is of very low interest for a real world use case.
Exercises should be modified by the user in its cloned repository.

Remove advanced exercises

These exercises where basically made for a workshop in Amsterdam, and do not really fit in the Starklings spirit anymore.

One should remove them.

Implicit arguments track

Implicit arguments is a very powerful feature of the Cairo language, Starklings should integrate exercises about these.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.