rosetta

command module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

Celo Rosetta

CircleCI License

A monitoring server for celo-blockchain

What is Celo Rosetta?

Celo Rosetta is an RPC server that exposes an API to:

  • Query Celo's Blockchain
  • Obtain Balance Changing Operations
  • Construct Airgapped Transactions

With a special focus on getting balance change operations, Celo Rosetta provides an easy way to obtain changes that are not easily queryable using the celo-blockchain rpc; such as:

  • Gas Fee distribution
  • Gold transfers (internal & external). Taking in account Tobin Tax
  • Epoch Rewards Distribution
  • LockedGold & Election Operations

RPC endpoints

Rosetta exposes the following endpoints:

  • POST /network/list: Get List of Available Networks
  • POST /network/status: Get Network Status
  • POST /network/options: Get Network Options
  • POST /block: Get a Block
  • POST /block/transaction: Get a Block Transaction
  • POST /mempool: Get All Mempool Transactions
  • POST /mempool/transaction: Get a Mempool Transaction
  • POST /account/balance: Get an Account Balance
  • POST /construction/metadata: Get Transaction Construction Metadata
  • POST /construction/submit: Submit a Signed Transaction

For an understanding of inputs & outputs check servicer.go

Running Rosetta Docker Image

Rosetta is released as a docker image: us.gcr.io/celo-testnet/rosetta. All version can be found on the registry page

Within the docker image, we pack rosetta binary and also geth binary from celo-blockchain. Rosetta will run both.

Configuration

The necessary parameters to run Celo Rosetta are:

  • genesis.json for the target network (can be found by curl 'https://storage.googleapis.com/genesis_blocks/baklava' > genesis.json)
  • staticNode enodeURL. Rosetta will directly peer to the list of staticNode provided (it doens't run discovery protocol for the moment). This node can be any you have access to. For a public list check https://storage.cloud.google.com/static_nodes/baklava

Additionaly, it needs a data directory for the geth datadir & rosetta.db

Run

To run Celo Rosetta:

# Use the last release
export RELEASE="0.1.2"
# folder for rosetta to use as data directory (saves rosetta.db & celo-blockchain datadir)
export DATADIR="/var/rosetta"
# enode for a known address to peer
export STATICNODE="enode://33ac194052ccd10ce54101c8340dbbe7831de02a3e7dcbca7fd35832ff8c53a72fd75e57ce8c8e73a0ace650dc2c2ec1e36f0440e904bc20a3cf5927f2323e85@34.83.199.225:30303"
docker pull us.gcr.io/celo-testnet/rosetta:$RELEASE
docker run --name rosetta --rm \
  -v "${DATADIR}:/data" \
  -p 8080:8080 \
  us.gcr.io/celo-testnet/rosetta:$RELEASE \
  run --staticNode $STATICNODE

Developer Guide

Setup

You need:

Makefile requires the following env variables:

  • CELO_BLOCKCHAIN_PATH: By default defines as ../celo-blockchain
  • CELO_MONOREPO_PATH: By default defines as ../celo-monorepo

go.mod is set up to build celo-blockchain from ../celo-blockchain. Which is the default path, if you need to change it DON'T COMMIT IT

Build Commands

Important commands:

  • make all: Builds project (compiles go project, compiles bls-zexe)
  • make gen-contracts: Regenerates contract wrappers
  • make test or go test ./... to run unit tests
  • go build ./... to build all modules (only compiles, doesn't generate or compile rust library)
Managing Generated Contracts

Rosetta requires a few Celo Core Contracts

  • The list of required contracts is defined on scripts/gen-contracts.go file
  • Generation requires acces to celo-blockchain & celo-monorepo.
  • Generation assumes both projects are already properly built
  • To run generator do make gen-contracts

How to build Docker Image

Commands:

  • make docker-build
  • make docker-publish

How to run rosetta-validator

go get -u github.com/coinbase/rosetta-validator@v0.1.2
mkdir validator-data 
go run examples/generate_balances/main.go \
  https://storage.googleapis.com/genesis_blocks/alfajores \
  validator-data/bootstrap_balances.json
rosetta-validator check:complete
Running on development
Running on RC1:

Prerequisites:

  • Download celo-monorepo branch rc1 and yarn && yarn build
  • Download celo-blockchain branch rc1-tracing-fix and make all
  • Download rosetta branch master update go.mod and make gen-contracts && make all
  • Run make rc1-env to create an empty datadir with the genesis block
go run main.go run \
  --genesis ./envs/rc1/genesis.json \
  --geth ../celo-blockchain/build/bin/geth \
  --staticNode "enode://5e0f4e3aaa096e2a2db76622b335cab4d3224d08d16cb11e8855a3a5f30c19d35d81a74b21271562e459495ab203c2f3a5a5747a83eb53ba046aeeb09aa240ff@34.83.110.24:30303"
  --datadir "./envs/rc1"
Running on Alfajores:

Prerequisites:

  • Download celo-monorepo branch alfajores and yarn && yarn build
  • Download celo-blockchain branch alfajores-tracing-fix and make all
  • Download rosetta branch master update go.mod and make gen-contracts && make all
  • Run make alfajores-env to create an empty datadir with the genesis block
go run main.go run \
  --genesis ./envs/alfajores/genesis.json \
  --geth ../celo-blockchain/build/bin/geth \
  --staticNode "enode://05977f6b7d3e16a99d27b714f8a029a006e41ec7732167d373dd920d31f72b3a1776650798d8763560854369d36867e9564dad13b4b60a90c347feeb491d83a9@34.83.42.50:30303"
  --datadir "./envs/alfajores"
Running on RC0:

Prerequisites:

  • Download celo-monorepo branch rc0 and yarn && yarn build
  • Download celo-blockchain branch mc/rosetta-rc0 and make all
  • Download rosetta branch rc0 update go.mod and make gen-contracts && make all
  • Run make rc0-env to create an empty datadir with the genesis block
go run main.go run \
  --genesis ./envs/rc0/genesis.json \
  --geth ../celo-blockchain/build/bin/geth \
  --staticNode "enode://33ac194052ccd10ce54101c8340dbbe7831de02a3e7dcbca7fd35832ff8c53a72fd75e57ce8c8e73a0ace650dc2c2ec1e36f0440e904bc20a3cf5927f2323e85@34.83.199.225:30303" \
  --datadir "./envs/rc0"

Documentation

Overview

Copyright © 2020 Celo Org

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL