Code Monkey home page Code Monkey logo

chain-importer's Introduction

Chain Importer

Importing state data from a different chain looks difficult in the first place. Fortunately, Parity's fat-db functionality allows us to easily iterate over account and contract state. Therefore, we can gather all relevant parts of a parition or the whole source chain and construct a new target chain, with the benefit to be under our control.

Modifications can be performed for various purposes, such as fuzzing of mainnet or testnet contracts. This is our fuzzing preparation step when using Galactuzz.

Summarized approach for importing a chain state:

1. Export state data from (synced) source chain
2. Generate new genesis spec based on template
3. Run chain based on generated (and possibly modified) genesis spec

Installation

YAJL is required to parse large files, otherwise the standard python json lib is used.

On MacOS:

brew install yajl

On Debian-based systems:

apt-get install libyajl-dev

The next steps involves the python requirements need to be installed:

pip install -r requirements.txt

Usage

As prerequisite a synced (mainnet-) chain is required. Furthermore, the chain is expected to be synced with Parity's fat-db functionality:

parity --fat-db=on --min-peers=50 --max-peers=100 --cache-size=4096

When the target block height has been synchronized (if different heights are targeted, running the node in archive mode should be considered), the state can be exported:

parity export state ./state_export.bin

Now we are able to generate a genesis spec, which contains the exported state. However, we are able to modify various parts beforehand (e.g. account balances). Make sure to configure config/chain.spec.template. Finally, generate the genesis spec as follows:

python chainspec_generator.py -s ./state_export.bin -t ./config/chain.spec.template -o ./config/chain.spec

We are now able to start the local testchain:

parity --chain ./config/chain.spec --reseal-min-period 0 --no-discovery --no-download --jsonrpc-apis all --min-gas-price 0

chain-importer's People

Contributors

1ultimat3 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.