Skip to content

An example of layer 1 fuzzing for radixdlt-scrypto commit 2645831e

License

Notifications You must be signed in to change notification settings

hknio/l1-fuzzing-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Layer 1 protocol fuzzing example

This project shows how to add a simple fuzzing target in radixdlt/radixdlt-scrypto commit 2645831e and find some critical issues with it.

This repository is a part of Layer 1 fuzzing workshop. To check how fuzzing was implemented check commit history.

Commands used so far

  1. rustup default nightly-2024-06-24
  2. rustup target add wasm32-unknown-unknown
  3. cargo install cargo-fuzz
  4. cargo-fuzz init --fuzz-dir radix-engine-fuzzer --target fuzzer
  5. Install llvm-18 - https://apt.llvm.org/ or use brew install llvm@18
  6. cargo install cargo-afl

Scrypto

Language for building DeFi apps on Radix.

Documentation: https://docs-babylon.radixdlt.com/main/scrypto/introduction.html

Installation

  1. Install Rust - this requires Rust 1.60+ (if rust is already installed, upgrade with rustup update)
    • Windows:
    • macOS:
      • Make sure you have the xcode command line tools: xcode-select --install.
      • Install cmake: brew install cmake
      • Install the Rust compiler:
          curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    • Linux:
      • Make sure a C++ compiler, LLVM and cmake is installed (sudo apt install build-essential llvm cmake).
      • Install the Rust compiler:
      curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Enable cargo in the current shell:
    • Windows:
      • Start a new PowerShell
    • Linux and macOS:
      source $HOME/.cargo/env
      
  3. Add WebAssembly target
    rustup target add wasm32-unknown-unknown
    
  4. Install simulator
    git clone https://github.com/radixdlt/radixdlt-scrypto.git
    cd radixdlt-scrypto
    cargo install --path ./simulator
    
  5. (Optional) Open Scrypto documentation for later use
    ./doc.sh
    

Getting Started

If you want a quick walkthrough of how to deploy and run some code, please see the Run Your First Project tutorial. If you prefer to soldier through on your own, keep reading below.

Writing Scrypto Code

  1. Start by creating a new package:
scrypto new-package <package_name>
cd <package_name>
  1. Check out the files under your current directory:
  • Source code is within src/lib.rs;
  • Test code is within tests/lib.rs.
  1. Build your package:
scrypto build
  1. Run tests:
scrypto test

Playing with Radix Engine

Action Command
Create an account resim new-account
Change the default account resim set-default-account <account_address> <account_public_key>
Create a token with fixed supply resim new-token-fixed <amount>
Create a token with mutable supply resim new-token-mutable <minter_resource_address>
Create a badge with fixed supply resim new-badge-fixed <amount>
Create a badge with mutable supply resim new-badge-mutable <minter_resource_address>
Mint resource resim mint <amount> <resource_address> <minter_resource_address>
Transfer resource resim transfer <amount> <resource_address> <recipient_component_address>
Publish a package resim publish <path_to_package_dir>
Call a function resim call-function <package_address> <blueprint_name> <function> <args>
Call a method resim call-method <component_address> <method> <args>
Export the ABI of a blueprint resim export-abi <package_address> <blueprint_name>
Show info about an entity resim show <id>
List all entities in simulator resim show-ledger
Reset simulator state resim reset

Note: The commands use the default account as transaction sender.

Project Layout

  • sbor: The binary data format used by Scrypto.
  • sbor-derive: Derives for encoding and decoding Rust struct and enum.
  • scrypto: Scrypto standard library.
  • scrypto-schema: Scrypto package schema.
  • scrypto-derive: Derives for defining and importing Scrypto blueprints.
  • radix-engine: The Scrypto execution engine.
  • simulator: A simulator that run Scrypto code on a filesystem based ledger.
  • transaction: Radix transaction manifest compiler, transaction models, signing and validationg logic.

Contribute

To learn more about how to contribute to this project, read the Contributing Guide.

License

This software/code is licensed and used pursuant to the Radix License, Version 1.0 and includes modified third party work which is reproduced here pursuant to the Apache 2.0 licensing regime. Where third party software has been used this is identified together with the appropriate open-source licence.

A copy of the Radix License, Version 1.0 may be found in the LICENSE file in the root directory of this repository.

About

An example of layer 1 fuzzing for radixdlt-scrypto commit 2645831e

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages