A monitoring server for celo-blockchain
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
Rosetta exposes the following endpoints:
POST /network/list
: Get List of Available NetworksPOST /network/status
: Get Network StatusPOST /network/options
: Get Network OptionsPOST /block
: Get a BlockPOST /block/transaction
: Get a Block TransactionPOST /mempool
: Get All Mempool TransactionsPOST /mempool/transaction
: Get a Mempool TransactionPOST /account/balance
: Get an Account BalancePOST /construction/metadata
: Get Transaction Construction MetadataPOST /construction/submit
: Submit a Signed Transaction
For an understanding of inputs & outputs check servicer.go
The main command is rosetta run
, whose arguments are:
Usage:
rosetta run [flags]
Flags:
--datadir string datadir to use
--geth.binary string Path to the celo-blockchain binary
--geth.bootnodes string Bootnodes to use (separated by ,)
--geth.genesis string path to the genesis.json
--geth.syncmode string Geth blockchain sync mode (fast, full, light)
--geth.gcmode string Geth garbage collection mode (full, archive)
--geth.ipcpath string Path to the geth ipc file
--geth.logfile string Path to logs file
--geth.publicip string Public Ip to configure geth (sometimes required for discovery)
--geth.staticnodes string StaticNode to use (separated by ,)
--geth.verbosity string Geth log verbosity (number between [1-5])
-h, --help help for run
--rpc.address string Listening address for http server
--rpc.port uint Listening port for http server (default 8080)
--rpc.reqTimeout duration Timeout when serving a request (default 25s)
Every argument can be defined using environment variables using ROSETTA_
prefix; and replacing .
for _
; for example:
ROSETTA_DATADIR="/my/dir"
ROSETTA_GETH_GENESIS="/path/to/genesis.json"
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.
To run Rosetta using the docker container, the following options must be configured:
genesis.json
for the target network (can be found bycurl 'https://storage.googleapis.com/genesis_blocks/baklava' > genesis.json
)staticNodes
orbootnodes
.- With
staticNodes
Rosetta will directly peer to the list of staticNode provided. This node can be any you have access to. For a public list checkhttps://storage.cloud.google.com/static_nodes/baklava
- With
Additionaly, it needs a data directory for the geth datadir & rosetta.db
To run Celo Rosetta:
# Use the last release
export RELEASE="0.5.4" #might be outdated
# folder for rosetta to use as data directory (saves rosetta.db & celo-blockchain datadir)
export DATADIR="/var/rosetta"
docker pull us.gcr.io/celo-testnet/rosetta:$RELEASE
docker run --name rosetta --rm \
-v "${DATADIR}:/data" \
-p 8080:8080 \
-e ROSETTA_GETH_STATICNODES="enode://33ac194052ccd10ce54101c8340dbbe7831de02a3e7dcbca7fd35832ff8c53a72fd75e57ce8c8e73a0ace650dc2c2ec1e36f0440e904bc20a3cf5927f2323e85@34.83.199.225:30303"
us.gcr.io/celo-testnet/rosetta:$RELEASE \
run --staticNode $STATICNODE
The Celo Rosetta Airgap module is designed to facilitate signing transactions, parameterized by contemporaenous network metadata, in an offline context.
Examples of this metadata include:
- network wide state like "gas price minimum"
- argument specific state like vote amount "effect on validator priority queue"
AirGapServer {
ObtainMetadata(TxArgs): TxMetadata
SubmitTx(Tx): Status
}
AirGapClient {
ConstructTxFromMetadata(TxMetadata): Tx
SignTx(Tx, PrivateKey): Tx
}
For a documentation resource, please see the custody docs.
For a code resource, please see the examples.
You need:
- go >= 1.13
- rust >= 1.41.0
- openapi-generator To re-generate rpc scaffold (install link)
- golangci To run linter (check https://github.com/golangci/golangci-lint#install )
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
Important commands:
make all
: Builds project (compiles go project, compiles bls-zexe)make gen-contracts
: Regenerates contract wrappersmake test
orgo test ./...
to run unit testsgo build ./...
to build all modules (only compiles, doesn't generate or compile rust library)
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
Commands:
make docker-build
make docker-publish
Install the rosetta-cli
according to the instructions. Current testing has been done with v0.5.16
.
- Run the Rosetta service in the background for the respective network (currently only alfajores)
- Run the CLI checks as follows:
# alfajores; specify construction or data
rosetta-cli check:construction --configuration-file PATH/TO/rosetta/rosetta-cli-conf/testnet/cli-config.json
This is only necessary for running the data checks if it has not already been created for the particular network. Here's how to generate this for alfajores (for another network, specify the appropriate genesis block URL and output path):
go run examples/generate_balances/main.go \
https://storage.googleapis.com/genesis_blocks/alfajores \
rosetta-cli-conf/testnet/bootstrap_balances.json
Prerequisites:
- Download
celo-monorepo
branchrc1
andyarn && yarn build
- Download
celo-blockchain
branchrc1-tracing-fix
andmake all
- Download
rosetta
branchmaster
update go.mod andmake gen-contracts && make all
- Run
make rc1-env
to create an empty datadir with the genesis block
go run main.go run \
--geth.genesis ./envs/rc1/genesis.json \
--geth.binary ../celo-blockchain/build/bin/geth \
--geth.syncmode full \
--geth.gcmode archive \
--geth.staticnodes "enode://5e0f4e3aaa096e2a2db76622b335cab4d3224d08d16cb11e8855a3a5f30c19d35d81a74b21271562e459495ab203c2f3a5a5747a83eb53ba046aeeb09aa240ff@34.83.110.24:30303" \
--datadir "./envs/rc1"
Prerequisites:
- Download
celo-monorepo
branchalfajores
andyarn && yarn build
- Download
celo-blockchain
branchalfajores-tracing-fix
andmake all
- Download
rosetta
branchmaster
update go.mod andmake gen-contracts && make all
- Run
make alfajores-env
to create an empty datadir with the genesis block
go run main.go run \
--geth.genesis ./envs/alfajores/genesis.json \
--geth.binary ../celo-blockchain/build/bin/geth \
--geth.syncmode full \
--geth.gcmode archive \
--geth.staticnodes "enode://05977f6b7d3e16a99d27b714f8a029a006e41ec7732167d373dd920d31f72b3a1776650798d8763560854369d36867e9564dad13b4b60a90c347feeb491d83a9@34.83.42.50:30303" \
--datadir "./envs/alfajores"
go run main.go run \
--geth.genesis ./envs/alfajoresstaging/genesis.json \
--geth.binary ../celo-blockchain/build/bin/geth \
--geth.syncmode full \
--geth.gcmode archive \
--geth.staticnodes "enode://ec86feaa5738d806cbe5431cfef97ce147c6ca4efa815f5684008c2f9455d8d39a8540e3fa19c151b3c9f5db89e86cb2565a05a4dbfb2d13f30834a01297e964@34.82.69.157:30303" \
--datadir "./envs/alfajoresstaging"