Coder Social home page Coder Social logo

data-restore's Introduction

Prerequisites: docker, docker-compose and gsutil or awscli.

Clone the repository:

git clone https://github.com/matter-labs/data-restore.git

Create volumes for containers:

$ mkdir -p volumes/data-restore volumes/postgres

Before starting containers configure data-restore.env:

# genesis or continue
COMMAND=

# mainnet, rinkeby or ropsten
NETWORK=

# Ethereum node URL
WEB3_URL=

# Optionally, you can put a database dump into volumes/data-restore and specify its name here.
# Make sure to run in continue mode.
PG_DUMP=

# Finite mode flag. Restore data until the last verified block and exit.
# If set to false, the driver will continuously scan Ethereum blocks unless
# it is manually interrupted.
# true (default if left empty) or false
FINITE_MODE=

Restoring from genesis is quite expensive and takes a long time, so we publish nightly database dumps that you can download and use for PG_DUMP:

# Mainnet
# GCP
gsutil -u <your GCP project> cp gs://zksync-data-restore/data_restore.dump ./volumes/data-restore/data_restore.dump
# Or AWS
aws s3 cp s3://zksync-data-restore/data_restore.dump ./volumes/data-restore/data_restore.dump --request-payer requester

# Rinkeby
# GCP
gsutil -u <your GCP project> cp gs://zksync-data-restore/data_restore_rinkeby.dump ./volumes/data-restore/data_restore_rinkeby.dump
# Or AWS
aws s3 cp s3://zksync-data-restore/data_restore_rinkeby.dump ./volumes/data-restore/data_restore_rinkeby.dump --request-payer requester

Your GCP project/AWS account is required because the bucket is set to requester pays (GCP, AWS), to keep the setup sustainable.

Once downloaded, just set PG_DUMP=data_restore.dump, which should save you a few days of syncing.

Warning: only set PG_DUMP for a single run, remove it for consequent usage. If data-restore is interrupted, it's advised to start again with the PG_DUMP set.

To run the restore:

$ docker-compose up

To manually connect to the running postgres service:

$ psql -h localhost -p 5432 -U postgres -d plasma

Once you're done, shut down the services:

$ docker-compose down

Running zkSync web3 read-only node

Some use-cases may require you to read data from zkSync in a trustless manner. To bootstrap a local read-only zkSync node, which reads the data from Ethereum, run the following command:

docker-compose -f docker-compose-zksync-node.yml up

This will run the data-restore tool as well as server, which will read data directly from the database created by it.

The web3 API can be accessed via the following endpoint:

http://127.0.0.1:3002

To change the port to which the zkSync node binds, you should modify the following parameter:

API_WEB3_PORT=3002

Make sure to change the port in the docker-compose-zksync-node.yml as well.

data-restore's People

Contributors

adrianchifor avatar deniallugo avatar slumber avatar stanislavbreadless 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.