Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #124 from klaytn/release/v1.0.1
Browse files Browse the repository at this point in the history
[rosetta-klaytn]_release/v1.0.1
  • Loading branch information
jimni1222 authored Aug 2, 2022
2 parents d89694c + 2159657 commit 191fdba
Show file tree
Hide file tree
Showing 45 changed files with 3,211 additions and 2,885 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version: 2.1
executors:
default:
docker:
- image: cimg/go:1.16
- image: cimg/go:1.18.4
user: root # go directory is owned by root
working_directory: /go/src/github.com/klaytn/rosetta-klaytn
environment:
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @jimni1222 @aeharvlee
* @jimni1222 @kjhman21

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/CLA.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened, closed, synchronize]

jobs:
CLAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
uses: cla-assistant/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_PERSONAL_ACCESS_TOKEN }}
with:
path-to-signatures: "${{ github.event.repository.name }}/signatures/version1/cla.json"
path-to-document: "https://gist.github.com/e78f99e1c527225637e269cff1bc7e49" # Klaytn Gist
branch: "master"
allowlist: dependabot[bot]
remote-repository-name: ${{ secrets.CLA_REPOSITORY }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rosetta-klaytn
klaytn-data
cli-data
.idea
.idea
.DS_Store
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ RUN mkdir -p /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.18.4
ENV GOLANG_DOWNLOAD_SHA256 c9b099b68d93f5c5c8a8844a89f8db07eaa58270e3a1e01804f17f4cf8df02f5
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 Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ run-testnet-offline:
run-testnet-offline-m1:
docker run --platform linux/amd64 -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest

run-local-online:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest

run-local-online-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -v "${PWD}/klaytn-data:/data" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest

run-local-offline:
docker run -d --rm -e "MODE=OFFLINE" -e "NETWORK=LOCAL" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest

run-local-offline-m1:
docker run --platform linux/amd64 -d --rm -e "MODE=OFFLINE" -e "NETWORK=LOCAL" -e "PORT=8081" -p 8081:8081 rosetta-klaytn:latest

run-mainnet-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=MAINNET" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest

Expand All @@ -98,6 +110,12 @@ run-testnet-remote:
run-testnet-remote-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=TESTNET" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest

run-local-remote:
docker run -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest

run-local-remote-m1:
docker run --platform linux/amd64 -d --rm --ulimit "nofile=${NOFILE}:${NOFILE}" -e "MODE=ONLINE" -e "NETWORK=LOCAL" -e "PORT=8080" -e "KEN=$(ken)" -p 8080:8080 -p 30303:30303 rosetta-klaytn:latest

check-comments:
${GOLINT_INSTALL}
${GOLINT_CMD} -set_exit_status ${GO_FOLDERS} .
Expand Down
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ The project started with a fork of [23561f903bc93d4fa97bebc1fbbe4c7e5b374e5e com
* Idempotent access to all transaction traces and receipts

## System Requirements
### For rosetta-klaytn
`rosetta-klaytn` 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-klaytn` will exit with an OOM error.

### Recommended OS Settings
#### Recommended OS Settings
To increase the load `rosetta-klaytn` 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)):
Expand All @@ -40,6 +41,29 @@ enabling it._
You should also modify your open file settings to `100000`. This can be done on a linux-based OS
with the command: `ulimit -n 100000`.

### For Klaytn Node
For Klaytn Node, you should operate an [EN(Endpoint Node)](https://docs.klaytn.foundation/node/endpoint-node) with `arcive` mode.
And also you can see the system requirements for [Endpoint Node](https://docs.klaytn.foundation/node/endpoint-node/system-requirements) in here.

#### Recommended `kend.conf` configuration
To serve rosetta-klaytn API, EN should enable rpc api like `RPC_ENABLE=1` and serve `klay`, `debug`, `txpool`, `governance` and `admin`(admin rpc api is optional) rpc apis.

```text
# rpc options setting
RPC_ENABLE=1 # if this is set, the following options will be used
RPC_API="admin,debug,klay,txpool,governance"
RPC_CONCURRENCYLIMIT=48000
RPC_READ_TIMEOUT=48000
RPC_WRITE_TIMEOUT=48000
RPC_IDLE_TIMEOUT=48000
RPC_EXECUTION_TIMEOUT=48000
# Raw options e.g) "--txpool.nolocals"
ADDITIONAL="--gcmode archive"
```

To run EN in archive mode, you can append the `--gcmode archive` flag to `ADDITIONAL`.

## Usage
As specified in the [Rosetta API Principles](https://www.rosetta-api.org/docs/automated_deployment.html),
all Rosetta implementations must be deployable via Docker and support running via either an
Expand Down Expand Up @@ -121,7 +145,7 @@ docker run --platform linux/amd64 -d --rm -e "MODE=OFFLINE" -e "NETWORK=TESTNET"
```

## Testing with rosetta-cli
To validate `rosetta-klaytn`, [install `rosetta-cli`](https://github.com/klaytn/rosetta-cli#install)
To validate `rosetta-klaytn`, [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 Klaytn `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.
Expand All @@ -138,6 +162,39 @@ Interested in helping fix issues in this repository? You can find to-dos in the
* `make build-local` to build a Docker image from the local context
* `make coverage-local` to generate a coverage report

## How to create test data for block testing in client_test.go
We need to execute client_test.go by generating the API result and creating the expected result as json data.

### Generate a test data in the network
You can create test data by sending a transaction to the network.

Alternatively, it is okay to use data that already exists in the network.

### Make test data files
In this step, the return data of the API called when the client function is executed is made into a json file, and when the actual test is performed, the data is returned using a mock.

Create a `block_{block number}.json` file using the value of the "result" field of the API result below.
```shell
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"klay_getBlockByNumber","params":["0x{block number}", true],"id":1}' http://{your en url}:8551 > block.txt
```

Create a `block_receipts_0x{block hash}.json` file using the value of the "result" field of the API result below.
```shell
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"klay_getBlockReceipts","params":["0x{block hash}"],"id":1}' http://{your en url}:8551 > receipts.txt
```

Create a `block_trace_0x{block hash}.json` file using the value of the "result" field of the API result below.
```shell
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceBlockByHash","params":["0x{block hash}", {"tracer": "fastCallTracer"}],"id":1}' http://{your en url}:8551 > trace.txt
```

### Make expected response data
Create a response object to be returned based on the above result in the `block_response_{block number}.json` file.

You can refer to `block_response_1078.json` file.

-

## License
This project is available open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).

Expand Down
2 changes: 1 addition & 1 deletion configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const (
SkipAdminEnv = "SKIP_ADMIN"

// MiddlewareVersion is the version of rosetta-klaytn.
MiddlewareVersion = "1.0.0"
MiddlewareVersion = "1.0.1"
)

// Configuration determines how
Expand Down
22 changes: 10 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
module github.com/klaytn/rosetta-klaytn

require (
github.com/fatih/color v1.13.0
github.com/klaytn/klaytn v1.9.0
github.com/klaytn/rosetta-sdk-go-klaytn v0.7.10
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
)

require (
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/aws/aws-sdk-go v1.43.31 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/fatih/color v1.13.0
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klaytn/klaytn v1.8.3
github.com/klaytn/rosetta-sdk-go-klaytn v0.7.10
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/onsi/gomega v1.15.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/spf13/cobra v1.4.0
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.1
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886 // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb // indirect
google.golang.org/protobuf v1.28.0 // indirect
)
Expand Down
Loading

0 comments on commit 191fdba

Please sign in to comment.