Giter Club home page Giter Club logo

pallet-chaos's Introduction

Chaos Pallet

The Chaos module is used to inject chaos into a Substrate Runtime and intentionally break things.

Overview

The Chaos module provides functions for:

  • Make Substrate Runtimes behave in ways that they're not supposed to.
  • Explore Runtime edge cases.
  • Explore Extrinsic weights and their economic implications.
  • Expose Runtime Attack Vectors.

Dispatchable Functions

overflow_adder

Inspired by overflow extrinsic implementation from Alexander Popiak's how-not-to-build-a-pallet, performs an unchecked sum over the Adder storage object. If the result is above 4_294_967_296, then Adder overflows.

This extrinsic illustrates the importance of using safe operations such as checked_add, checked_sub and their variants from substrate_primitives::U256.

clear_adder

Simply clears the Adder storage object so that unwrap_add can illustrate bad unwraps.

dragBlockUnitWeight(n)

Injects a heavy computation payload into the runtime, effectively dragging block production by calculating hashes in a loop (n times), with constant unitary extrinsic weight.

This extrinsic illustrates the importance of proper weight design.

block dragger

Usage

chaoscope provides a CLI utility to automate interaction with pallet-chaos on a local setup.

  1. In case you want to interact with it manually, follow the steps below.
  2. Include pallet-chaos to a substrate-node-template, build it, and start the chain:
$ ./target/release/node-template --dev --tmp
  1. On PolkadotJS, connect to DEVELOPMENT Chain (ws://127.0.0.1:9944).
  2. Open Developer->Extrinsics.

Overflowing

On a browser new tab, open Developer->Chain state. Then choose chaos-> adder(), and click the + sign. This is how you'll monitor the Adder storage object.

On the extrinsics tab you had previously open, choose chaos->overflowAdder(n).

While monitoring adder() on the Chain state tab, keep adding numbers at will, until you reach 4_294_967_296.

Observe what happens after you add above this value, and imagine what would be the implications if Adder actually represented something meaningful in your chain.

Dragging Blocks

Choose chaos->dragBlockUnitWeight(n).

Here's where the experimentation starts. Choose different values for n, call Submit Transaction and observe the effects on block production.

License

AGPL-3.0

pallet-chaos's People

Contributors

bernardoaraujor avatar

Watchers

 avatar

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.