Skip to content

Commit

Permalink
begin repurposing for ubiq
Browse files Browse the repository at this point in the history
  • Loading branch information
iquidus committed May 11, 2022
1 parent 51f20a5 commit da0d451
Show file tree
Hide file tree
Showing 114 changed files with 318 additions and 400 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ethereum-data
ubiq-data
cli-data
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rosetta-ethereum
ethereum-data
rosetta-ubiq
ubiq-data
cli-data
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ be locked to prevent further discussion.

All support requests must be made via [our support team][3].

[1]: https://github.com/coinbase/rosetta-ethereum/issues
[1]: https://github.com/ubiq/rosetta-ubiq/issues
[2]: https://chris.beams.io/posts/git-commit/#seven-rules
[3]: https://support.coinbase.com/customer/en/portal/articles/2288496-how-can-i-contact-coinbase-support-
44 changes: 22 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Compile golang
FROM ubuntu:20.04 as golang-builder
FROM --platform=linux/amd64 ubuntu:20.04 as golang-builder

RUN mkdir -p /app \
&& chown -R nobody:nogroup /app
Expand All @@ -33,36 +33,36 @@ ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"

# Compile geth
FROM golang-builder as geth-builder
# Compile gubiq
FROM golang-builder as gubiq-builder

# VERSION: go-ethereum v.1.10.16
RUN git clone https://github.com/ethereum/go-ethereum \
&& cd go-ethereum \
&& git checkout 20356e57b119b4e70ce47665a71964434e15200d
# VERSION: go-ubiq v7.0.0
RUN git clone https://github.com/ubiq/go-ubiq \
&& cd go-ubiq \
&& git checkout c9009e89cb6db5b27375086b7b10fce6f7c1d643

RUN cd go-ethereum \
&& make geth
RUN cd go-ubiq \
&& make gubiq

RUN mv go-ethereum/build/bin/geth /app/geth \
&& rm -rf go-ethereum
RUN mv go-ubiq/build/bin/gubiq /app/gubiq \
&& rm -rf go-ubiq

# Compile rosetta-ethereum
# Compile rosetta-ubiq
FROM golang-builder as rosetta-builder

# Use native remote build context to build in any directory
COPY . src
RUN cd src \
&& go build

RUN mv src/rosetta-ethereum /app/rosetta-ethereum \
&& mkdir /app/ethereum \
&& mv src/ethereum/call_tracer.js /app/ethereum/call_tracer.js \
&& mv src/ethereum/geth.toml /app/ethereum/geth.toml \
RUN mv src/rosetta-ubiq /app/rosetta-ubiq \
&& mkdir /app/ubiq \
&& mv src/ubiq/call_tracer.js /app/ubiq/call_tracer.js \
&& mv src/ubiq/gubiq.toml /app/ubiq/gubiq.toml \
&& rm -rf src

## Build Final Image
FROM ubuntu:20.04
FROM --platform=linux/amd64 ubuntu:20.04

RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates

Expand All @@ -73,14 +73,14 @@ RUN mkdir -p /app \

WORKDIR /app

# Copy binary from geth-builder
COPY --from=geth-builder /app/geth /app/geth
# Copy binary from gubiq-builder
COPY --from=gubiq-builder /app/gubiq /app/gubiq

# Copy binary from rosetta-builder
COPY --from=rosetta-builder /app/ethereum /app/ethereum
COPY --from=rosetta-builder /app/rosetta-ethereum /app/rosetta-ethereum
COPY --from=rosetta-builder /app/ubiq /app/ubiq
COPY --from=rosetta-builder /app/rosetta-ubiq /app/rosetta-ubiq

# Set permissions for everything added to /app
RUN chmod -R 755 /app/*

CMD ["/app/rosetta-ethereum", "run"]
CMD ["/app/rosetta-ubiq", "run"]
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GOLINT_CMD=golint
GOVERALLS_INSTALL=go install github.com/mattn/goveralls@latest
GOVERALLS_CMD=goveralls
GOIMPORTS_CMD=go run golang.org/x/tools/cmd/goimports
GO_PACKAGES=./services/... ./cmd/... ./configuration/... ./ethereum/...
GO_PACKAGES=./services/... ./cmd/... ./configuration/... ./ubiq/...
GO_FOLDERS=$(shell echo ${GO_PACKAGES} | sed -e "s/\.\///g" | sed -e "s/\/\.\.\.//g")
TEST_SCRIPT=go test ${GO_PACKAGES}
LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyclose,unconvert,lll,unparam
Expand All @@ -29,40 +29,40 @@ test:
${TEST_SCRIPT}

build:
docker build -t rosetta-ethereum:latest https://github.com/coinbase/rosetta-ethereum.git
docker build -t rosetta-ubiq:latest https://github.com/ubiq/rosetta-ubiq.git

build-local:
docker build -t rosetta-ethereum:latest .
docker build -t rosetta-ubiq:latest .

build-release:
# make sure to always set version with vX.X.X
docker build -t rosetta-ethereum:$(version) .;
docker save rosetta-ethereum:$(version) | gzip > rosetta-ethereum-$(version).tar.gz;
docker build -t rosetta-ubiq:$(version) .;
docker save rosetta-ubiq:$(version) | gzip > rosetta-ubiq-$(version).tar.gz;

update-tracer:
curl https://raw.githubusercontent.com/ethereum/go-ethereum/master/eth/tracers/js/internal/tracers/call_tracer_js.js -o ethereum/call_tracer.js
curl https://raw.githubusercontent.com/ubiq/go-ubiq/master/eth/tracers/js/internal/tracers/call_tracer_js.js -o ubiq/call_tracer.js

update-bootstrap-balances:
go run main.go utils:generate-bootstrap ethereum/genesis_files/mainnet.json rosetta-cli-conf/mainnet/bootstrap_balances.json;
go run main.go utils:generate-bootstrap ethereum/genesis_files/testnet.json rosetta-cli-conf/testnet/bootstrap_balances.json;
go run main.go utils:generate-bootstrap ubiq/genesis_files/mainnet.json rosetta-cli-conf/mainnet/bootstrap_balances.json;
go run main.go utils:generate-bootstrap ubiq/genesis_files/testnet.json rosetta-cli-conf/testnet/bootstrap_balances.json;

run-mainnet-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/ethereum-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/ubiq-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 30388:30388 rosetta-ubiq:latest

run-mainnet-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-ethereum:latest
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-ubiq:latest

run-testnet-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/ethereum-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/ubiq-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 30388:30388 rosetta-ubiq:latest

run-testnet-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-ethereum:latest
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-ubiq:latest

run-mainnet-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "GETH=$(geth)" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "GUBIQ=$(gubiq)" -p 8080:8080 -p 30388:30388 rosetta-ubiq:latest

run-testnet-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "GETH=$(geth)" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "GUBIQ=$(gubiq)" -p 8080:8080 -p 30388:30388 rosetta-ubiq:latest

check-comments:
${GOLINT_INSTALL}
Expand Down Expand Up @@ -108,6 +108,6 @@ coverage-local:
mocks:
rm -rf mocks;
mockery --dir services --all --case underscore --outpkg services --output mocks/services;
mockery --dir ethereum --all --case underscore --outpkg ethereum --output mocks/ethereum;
mockery --dir ubiq --all --case underscore --outpkg ubiq --output mocks/ubiq;
${ADDLICENSE_INSTALL}
${ADDLICENCE_SCRIPT} .;
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
</a>
</p>
<h3 align="center">
Rosetta Ethereum
Rosetta Ubiq
</h3>
<p align="center">
<a href="https://circleci.com/gh/coinbase/rosetta-ethereum/tree/master"><img src="https://circleci.com/gh/coinbase/rosetta-ethereum/tree/master.svg?style=shield" /></a>
<a href="https://coveralls.io/github/coinbase/rosetta-ethereum"><img src="https://coveralls.io/repos/github/coinbase/rosetta-ethereum/badge.svg" /></a>
<a href="https://goreportcard.com/report/github.com/coinbase/rosetta-ethereum"><img src="https://goreportcard.com/badge/github.com/coinbase/rosetta-ethereum" /></a>
<a href="https://github.com/coinbase/rosetta-ethereum/blob/master/LICENSE.txt"><img src="https://img.shields.io/github/license/coinbase/rosetta-ethereum.svg" /></a>
<a href="https://pkg.go.dev/github.com/coinbase/rosetta-ethereum?tab=overview"><img src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=shield" /></a>
<a href="https://goreportcard.com/report/github.com/ubiq/rosetta-ubiq"><img src="https://goreportcard.com/badge/github.com/ubiq/rosetta-ubiq" /></a>
<a href="https://github.com/ubiq/rosetta-ubiq/blob/master/LICENSE.txt"><img src="https://img.shields.io/github/license/coinbase/rosetta-ethereum.svg" /></a>
<a href="https://pkg.go.dev/github.com/ubiq/rosetta-ubiq?tab=overview"><img src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=shield" /></a>
</p>

<p align="center"><b>
ROSETTA-ETHEREUM IS CONSIDERED <a href="https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha">ALPHA SOFTWARE</a>.
ROSETTA-UBIQ IS CONSIDERED <a href="https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha">ALPHA SOFTWARE</a>.
USE AT YOUR OWN RISK! COINBASE ASSUMES NO RESPONSIBILITY OR LIABILITY IF THERE IS A BUG IN THIS IMPLEMENTATION.
</b></p>

## Overview
`rosetta-ethereum` provides a reference implementation of the Rosetta API for Ethereum in Golang. If you haven't heard of the Rosetta API, you can find more information [here](https://rosetta-api.org).
`rosetta-ubiq` provides a reference implementation of the Rosetta API for Ubiq in Golang. If you haven't heard of the Rosetta API, you can find more information [here](https://rosetta-api.org).

## Features
* Comprehensive tracking of all ETH balance changes
* Stateless, offline, curve-based transaction construction (with address checksum validation)
* Atomic balance lookups using go-ethereum's GraphQL Endpoint
* Atomic balance lookups using go-ubiq's GraphQL Endpoint
* Idempotent access to all transaction traces and receipts

## System Requirements
`rosetta-ethereum` has been tested on an [AWS c5.2xlarge instance](https://aws.amazon.com/ec2/instance-types/c5).
`rosetta-ubiq` has been tested on an [AWS c5.2xlarge instance](https://aws.amazon.com/ec2/instance-types/c5).
This instance type has 8 vCPU and 16 GB of RAM. If you use a computer with less than 16 GB of RAM,
it is possible that `rosetta-ethereum` will exit with an OOM error.
it is possible that `rosetta-ubiq` will exit with an OOM error.

### Recommended OS Settings
To increase the load `rosetta-ethereum` can handle, it is recommended to tune your OS
To increase the load `rosetta-ubiq` can handle, it is recommended to tune your OS
settings to allow for more connections. On a linux-based OS, you can run the following
commands ([source](http://www.tweaked.io/guide/kernel)):
```text
Expand All @@ -45,7 +45,7 @@ sysctl -w net.ipv4.tcp_max_syn_backlog=10000
sysctl -w net.core.somaxconn=10000
sysctl -p (when done)
```
_We have not tested `rosetta-ethereum` with `net.ipv4.tcp_tw_recycle` and do not recommend
_We have not tested `rosetta-ubiq` with `net.ipv4.tcp_tw_recycle` and do not recommend
enabling it._

You should also modify your open file settings to `100000`. This can be done on a linux-based OS
Expand All @@ -60,15 +60,15 @@ all Rosetta implementations must be deployable via Docker and support running vi
DOCKER [HERE](https://www.docker.com/get-started).**

### Install
Running the following commands will create a Docker image called `rosetta-ethereum:latest`.
Running the following commands will create a Docker image called `rosetta-ubiq:latest`.

#### From GitHub
To download the pre-built Docker image from the latest release, run:
```text
curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-ethereum/master/install.sh | sh -s
curl -sSfL https://raw.githubusercontent.com/ubiq/rosetta-ubiq/master/install.sh | sh -s
```

_Do not try to install rosetta-ethereum using GitHub Packages!_
_Do not try to install rosetta-ubiq using GitHub Packages!_


#### From Source
Expand All @@ -80,61 +80,61 @@ make build-local
### Run
Running the following commands will start a Docker container in
[detached mode](https://docs.docker.com/engine/reference/run/#detached--d) with
a data directory at `<working directory>/ethereum-data` and the Rosetta API accessible
a data directory at `<working directory>/ubiq-data` and the Rosetta API accessible
at port `8080`.

#### Configuration Environment Variables
* `MODE` (required) - Determines if Rosetta can make outbound connections. Options: `ONLINE` or `OFFLINE`.
* `NETWORK` (required) - Ethereum network to launch and/or communicate with. Options: `MAINNET`, `ROPSTEN`, `RINKEBY`, `GOERLI` or `TESTNET` (which defaults to `ROPSTEN` for backwards compatibility).
* `NETWORK` (required) - Ubiq network to launch and/or communicate with. Options: `MAINNET`, `ROPSTEN`, `RINKEBY`, `GOERLI` or `TESTNET` (which defaults to `ROPSTEN` for backwards compatibility).
* `PORT`(required) - Which port to use for Rosetta.
* `GETH` (optional) - Point to a remote `geth` node instead of initializing one
* `SKIP_GETH_ADMIN` (optional, default: `FALSE`) - Instruct Rosetta to not use the `geth` `admin` RPC calls. This is typically disabled by hosted blockchain node services.
* `GUBIQ` (optional) - Point to a remote `gubiq` node instead of initializing one
* `SKIP_GUBIQ_ADMIN` (optional, default: `FALSE`) - Instruct Rosetta to not use the `geth` `admin` RPC calls. This is typically disabled by hosted blockchain node services.

#### Mainnet:Online
```text
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/ethereum-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/ubiq-data:/data" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-ubiq:latest
```
_If you cloned the repository, you can run `make run-mainnet-online`._

#### Mainnet:Online (Remote)
```text
docker run -d --rm --ulimit "nofile=100000:100000" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "GETH=<NODE URL>" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=100000:100000" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "GUBIQ=<NODE URL>" -p 8080:8080 -p 30303:30303 rosetta-ubiq:latest
```
_If you cloned the repository, you can run `make run-mainnet-remote geth=<NODE URL>`._

#### Mainnet:Offline
```text
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-ethereum:latest
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=MAINNET" -e "PORT=8081" -p 8081:8081 rosetta-ubiq:latest
```
_If you cloned the repository, you can run `make run-mainnet-offline`._

#### Testnet:Online
```text
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/ethereum-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=100000:100000" -v "$(pwd)/ubiq-data:/data" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-ubiq:latest
```
_If you cloned the repository, you can run `make run-testnet-online`._

#### Testnet:Online (Remote)
```text
docker run -d --rm --ulimit "nofile=100000:100000" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "GETH=<NODE URL>" -p 8080:8080 -p 30303:30303 rosetta-ethereum:latest
docker run -d --rm --ulimit "nofile=100000:100000" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "GUBIQ=<NODE URL>" -p 8080:8080 -p 30303:30303 rosetta-ubiq:latest
```
_If you cloned the repository, you can run `make run-testnet-remote geth=<NODE URL>`._

#### Testnet:Offline
```text
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-ethereum:latest
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-ubiq:latest
```
_If you cloned the repository, you can run `make run-testnet-offline`._

## Testing with rosetta-cli
To validate `rosetta-ethereum`, [install `rosetta-cli`](https://github.com/coinbase/rosetta-cli#install)
To validate `rosetta-ubiq`, [install `rosetta-cli`](https://github.com/coinbase/rosetta-cli#install)
and run one of the following commands:
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/testnet/config.json` - This command validates that the Data API implementation is correct using the ethereum `testnet` node. It also ensures that the implementation does not miss any balance-changing operations.
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/testnet/config.json` - This command validates that the Data API implementation is correct using the ubiq `testnet` node. It also ensures that the implementation does not miss any balance-changing operations.
* `rosetta-cli check:construction --configuration-file rosetta-cli-conf/testnet/config.json` - This command validates the Construction API implementation. It also verifies transaction construction, signing, and submissions to the `testnet` network.
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/mainnet/config.json` - This command validates that the Data API implementation is correct using the ethereum `mainnet` node. It also ensures that the implementation does not miss any balance-changing operations.
* `rosetta-cli check:data --configuration-file rosetta-cli-conf/mainnet/config.json` - This command validates that the Data API implementation is correct using the ubiq `mainnet` node. It also ensures that the implementation does not miss any balance-changing operations.

## Issues
Interested in helping fix issues in this repository? You can find to-dos in the [Issues](https://github.com/coinbase/rosetta-ethereum/issues) section. Be sure to reach out on our [community](https://community.rosetta-api.org) before you tackle anything on this list.
Interested in helping fix issues in this repository? You can find to-dos in the [Issues](https://github.com/ubiq/rosetta-ubiq/issues) section. Be sure to reach out on our [community](https://community.rosetta-api.org) before you tackle anything on this list.

## Development
* `make deps` to install dependencies
Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (

var (
rootCmd = &cobra.Command{
Use: "rosetta-ethereum",
Short: "Ethereum implementation of the Rosetta API",
Use: "rosetta-ubiq",
Short: "Ubiq implementation of the Rosetta API",
}

// SignalReceived is set to true when a signal causes us to exit. This makes
Expand Down
Loading

0 comments on commit da0d451

Please sign in to comment.