Skip to content

Commit

Permalink
feat: update configurations for core
Browse files Browse the repository at this point in the history
  • Loading branch information
easonchan17 committed Mar 24, 2024
1 parent 3867c85 commit f25f973
Show file tree
Hide file tree
Showing 40 changed files with 1,534 additions and 116,633 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to rosetta-ethereum
# Contributing to rosetta-core

## Code of Conduct

Expand Down 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/coredao-org/rosetta-core/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-
33 changes: 17 additions & 16 deletions Dockerfile → Dockerfile.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

RUN mkdir -p /app \
&& chown -R nobody:nogroup /app
WORKDIR /app

RUN apt-get update && apt-get install -y curl make gcc g++ git
ENV GOLANG_VERSION 1.16.8
ENV GOLANG_DOWNLOAD_SHA256 f32501aeb8b7b723bc7215f6c373abb6981bbc7e1c7b44e9f07317e1a300dce2
ENV GOLANG_VERSION 1.19.8
ENV GOLANG_DOWNLOAD_SHA256 e1a0bf0ab18c8218805a1003fd702a41e2e807710b770e787e5979d1cf947aba
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz

RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
Expand All @@ -36,29 +36,30 @@ RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
# Compile geth
FROM golang-builder as geth-builder

# VERSION: go-ethereum v.1.10.16
RUN git clone https://github.com/ethereum/go-ethereum \
&& cd go-ethereum \
&& git checkout 20356e57b119b4e70ce47665a71964434e15200d
# VERSION: core-chain v1.0.6
ARG core_chain_version
RUN git clone https://github.com/coredao-org/core-chain.git \
&& cd core-chain \
&& git checkout v1.0.6

RUN cd go-ethereum \
RUN cd core-chain \
&& make geth

RUN mv go-ethereum/build/bin/geth /app/geth \
&& rm -rf go-ethereum
RUN mv core-chain/build/bin/geth /app/geth \
&& rm -rf core-chain

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

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

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

## Build Final Image
Expand All @@ -78,9 +79,9 @@ COPY --from=geth-builder /app/geth /app/geth

# 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/rosetta-core /app/rosetta-core

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

CMD ["/app/rosetta-ethereum", "run"]
CMD ["/app/rosetta-core", "run"]
87 changes: 87 additions & 0 deletions Dockerfile.testnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright 2020 Coinbase, Inc.
#
# 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.

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

RUN mkdir -p /app \
&& chown -R nobody:nogroup /app
WORKDIR /app

RUN apt-get update && apt-get install -y curl make gcc g++ git
ENV GOLANG_VERSION 1.19.8
ENV GOLANG_DOWNLOAD_SHA256 e1a0bf0ab18c8218805a1003fd702a41e2e807710b770e787e5979d1cf947aba
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz

RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz

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

# VERSION: core-chain v1.0.6
ARG core_chain_version
RUN git clone https://github.com/coredao-org/core-chain.git \
&& cd core-chain \
&& git checkout v1.0.6

RUN cd core-chain \
&& make geth

RUN mv core-chain/build/bin/geth /app/geth \
&& rm -rf core-chain

# Compile rosetta-core
FROM golang-builder as rosetta-builder

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

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

## Build Final Image
FROM ubuntu:20.04

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

RUN mkdir -p /app \
&& chown -R nobody:nogroup /app \
&& mkdir -p /data \
&& chown -R nobody:nogroup /data

WORKDIR /app

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

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

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

CMD ["/app/rosetta-core", "run"]
53 changes: 36 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.PHONY: deps build run lint run-mainnet-online run-mainnet-offline run-testnet-online \
.PHONY: deps lint run-mainnet-online run-mainnet-offline run-testnet-online \
run-testnet-offline check-comments add-license check-license shorten-lines \
spellcheck salus build-local format check-format update-tracer test coverage coverage-local \
update-bootstrap-balances mocks
spellcheck salus format check-format update-tracer test coverage coverage-local \
update-bootstrap-balances mocks build-testnet build-mainnet build-testnet-local \
build-mainnet-local build-testnet-release build-mainnet-release run-mainnet-remote run-testnet-remote

ADDLICENSE_IGNORE=-ignore ".github/**/*" -ignore ".idea/**/*"
ADDLICENSE_INSTALL=go install github.com/google/addlicense@latest
Expand All @@ -10,7 +11,7 @@ ADDLICENCE_SCRIPT=${ADDLICENSE_CMD} -c "Coinbase, Inc." -l "apache" -v ${ADDLICE
SPELLCHECK_CMD=go run github.com/client9/misspell/cmd/misspell
GOLINES_INSTALL=go install github.com/segmentio/golines@latest
GOLINES_CMD=golines
GOLINT_INSTALL=go get golang.org/x/lint/golint
GOLINT_INSTALL=go install golang.org/x/lint/golint
GOLINT_CMD=golint
GOVERALLS_INSTALL=go install github.com/mattn/goveralls@latest
GOVERALLS_CMD=goveralls
Expand All @@ -22,47 +23,65 @@ LINT_SETTINGS=golint,misspell,gocyclo,gocritic,whitespace,goconst,gocognit,bodyc
PWD=$(shell pwd)
NOFILE=100000

PLATFORM_FLAG :=
DOCKER_API_VERSION := $(shell docker version --format '{{.Server.APIVersion}}')
ifeq ($(shell expr $(DOCKER_API_VERSION) \>= 1.41), 1)
PLATFORM_FLAG := --platform linux/amd64
endif

deps:
go get ./...

test:
${TEST_SCRIPT}

build:
docker build -t rosetta-ethereum:latest https://github.com/coinbase/rosetta-ethereum.git
build-testnet:
docker build ${PLATFORM_FLAG} -t rosetta-core:testnet-latest -f Dockerfile.testnet https://github.com/coredao-org/rosetta-core.git

build-mainnet:
docker build ${PLATFORM_FLAG} -t rosetta-core:mainnet-latest -f Dockerfile.mainnet https://github.com/coredao-org/rosetta-core.git

build-testnet-local:
docker build ${PLATFORM_FLAG} -t rosetta-core:testnet-latest -f Dockerfile.testnet .

build-local:
docker build -t rosetta-ethereum:latest .
build-mainnet-local:
docker build ${PLATFORM_FLAG} -t rosetta-core:mainnet-latest -f Dockerfile.mainnet .

build-testnet-release:
# make sure to always set version with vX.X.X
docker build ${PLATFORM_FLAG} -t rosetta-core:testnet-$(version) -f Dockerfile.testnet .;
docker save rosetta-core:testnet-$(version) | gzip > rosetta-core-testnet-$(version).tar.gz;

build-release:
build-mainnet-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 ${PLATFORM_FLAG} -t rosetta-core:mainnet-$(version) -f Dockerfile.mainnet .;
docker save rosetta-core:mainnet-$(version) | gzip > rosetta-core-mainnet-$(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

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 ethereum/genesis_files/devnet.json rosetta-cli-conf/devnet/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 ${PLATFORM_FLAG} --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/core-mainnet-data:/data" -e "MODE=ONLINE" -e "NETWORK=CORE" -e "PORT=8080" -p 8080:8080 -p 35021:35021 -p 8579:8579 rosetta-core:mainnet-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 ${PLATFORM_FLAG} -e "MODE=OFFLINE" -e "NETWORK=CORE" -e "PORT=8081" -p 8081:8081 rosetta-core:mainnet-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 -p 8545:8545 rosetta-ethereum:latest
docker run -d --rm ${PLATFORM_FLAG} --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/core-testnet-data:/data" -e "MODE=ONLINE" -e "NETWORK=BUFFALO" -e "PORT=8080" -p 8080:8080 -p 35012:35012 -p 8575:8575 rosetta-core:testnet-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 ${PLATFORM_FLAG} -e "MODE=OFFLINE" -e "NETWORK=BUFFALO" -e "PORT=8081" -p 8081:8081 rosetta-core:testnet-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 ${PLATFORM_FLAG} --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=CORE" -e "PORT=8080" -e "GETH=$(geth)" -p 8080:8080 rosetta-core:mainnet-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 ${PLATFORM_FLAG} --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=BUFFALO" -e "PORT=8080" -e "GETH=$(geth)" -p 8080:8080 rosetta-core:testnet-latest

check-comments:
${GOLINT_INSTALL}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ This repository contains a sample implementation of Rosetta API for the Ethereum
</p>
<!-- Badges -->
<p align="center">
<a href="https://actions-badge.atrox.dev/coinbase/rosetta-ethereum/goto?ref=master"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fcoinbase%2Frosetta-ethereum%2Fbadge%3Fref%3Dmaster&style=popout" /></a>
<a href="https://actions-badge.atrox.dev/coredao-org/rosetta-core/goto?ref=master"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fcoinbase%2Frosetta-ethereum%2Fbadge%3Fref%3Dmaster&style=popout" /></a>
<!-- <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://github.com/coredao-org/rosetta-core/blob/master/LICENSE.txt"><img src="https://img.shields.io/github/license/coredao-org/rosetta-core.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>
</p>
<!-- Rosetta Tagline -->
Expand Down
6 changes: 3 additions & 3 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-core",
Short: "CoreChain implementation of the Rosetta API",
}

// SignalReceived is set to true when a signal causes us to exit. This makes
Expand All @@ -36,7 +36,7 @@ var (
)

// Execute handles all invocations of the
// rosetta-ethereum cmd.
// rosetta-core cmd.
func Execute() error {
return rootCmd.Execute()
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const (
var (
runCmd = &cobra.Command{
Use: "run",
Short: "Run rosetta-ethereum",
Short: "Run rosetta-core",
RunE: runRunCmd,
}
)
Expand Down Expand Up @@ -127,7 +127,7 @@ func runRunCmd(cmd *cobra.Command, args []string) error {

err = g.Wait()
if SignalReceived {
return errors.New("rosetta-ethereum halted")
return errors.New("rosetta-core halted")
}

return err
Expand Down
Loading

0 comments on commit f25f973

Please sign in to comment.