Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rosetta-cli test #34

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
1d6db57
build(deps): bump cosmossdk.io/math from 1.0.1 to 1.1.2 (#21)
dependabot[bot] Aug 31, 2023
f4f74b4
refactor: cosmos-sdk v0.50 upgrade and multi zone enhancements (#27)
bizk Sep 1, 2023
3c104b2
refactor: Improvements on error handling (#29)
bizk Sep 4, 2023
64c262c
initialization rosetta-cli pipeline test
bizk Sep 7, 2023
ba60839
build(deps): bump google.golang.org/grpc from 1.56.2 to 1.58.0 (#33)
dependabot[bot] Sep 8, 2023
f4b83ca
added workflow for rosetta-cli
bizk Sep 9, 2023
c7b9f3d
rosetta CLI installation
bizk Sep 9, 2023
69ecab7
added bin folder to rosetta CLI execution
bizk Sep 10, 2023
cf0cec8
debugging failing job
bizk Sep 10, 2023
641629a
added config.json file content
bizk Sep 10, 2023
5c48307
added job paralelization
bizk Sep 10, 2023
ef7ea37
debugging rosetta build step
bizk Sep 10, 2023
2891c25
debugging
bizk Sep 10, 2023
9afeb98
added simapp
bizk Sep 10, 2023
6a5b619
added cosmos-sdk repo
bizk Sep 10, 2023
7b8896d
added cosmos-sdk repo
bizk Sep 10, 2023
000524f
removed path from git clone
bizk Sep 10, 2023
61ceb0b
removed unused commands
bizk Sep 10, 2023
3982713
added simapp
bizk Sep 10, 2023
3e65e99
added simapp
bizk Sep 10, 2023
c1c22c7
added simd binary
bizk Sep 10, 2023
9d786aa
added start on simd
bizk Sep 10, 2023
7d5b343
added paralel step
bizk Sep 11, 2023
5b9f9c6
added rosetta to run in background
bizk Sep 11, 2023
da3f258
removed conditional building
bizk Sep 11, 2023
0cc5db8
added make plugin
bizk Sep 11, 2023
3ff64ac
removed double build command
bizk Sep 11, 2023
ddc5792
debug
bizk Sep 11, 2023
9035e83
solved typo
bizk Sep 11, 2023
de3c48a
fix on plugin file
bizk Sep 11, 2023
2c72368
trying to solve untracked file issue
bizk Sep 11, 2023
1c09529
trying to solve untracked file issue
bizk Sep 11, 2023
d11650c
small update on plugin file
bizk Sep 11, 2023
87376fe
Merge branch 'main' into tag47/cli
bizk Sep 11, 2023
9bb1c49
added checkout
bizk Sep 11, 2023
12541d8
Revert "added checkout"
bizk Sep 11, 2023
d268485
Revert "Merge branch 'main' into tag47/cli"
bizk Sep 11, 2023
c9ce6fc
added checkout
bizk Sep 11, 2023
ed624ad
added waiting after starting simd node
bizk Sep 11, 2023
1dc7a3d
test running serialized jobs
bizk Sep 12, 2023
7a13603
added debugging flag
bizk Sep 12, 2023
66389ac
added debugging flag
bizk Sep 12, 2023
8bed88b
docker compose files
bizk Sep 12, 2023
562db5b
added docker compose file and dockerfile
bizk Sep 13, 2023
724ccbc
dockerfile build working
bizk Sep 14, 2023
98244ea
added flag parsing to docker image
bizk Sep 14, 2023
fc02a43
commented publishing info to docker for now
bizk Sep 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build rosetta docker image
# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed
on:
pull_request:
merge_group:
push:
branches:
- main
- release/**
permissions:
contents: read

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ jobs:
###################
- name: Build Rosetta
if: env.GIT_DIFF
run: GOARCH=${{ matrix.go-arch }} make rosetta
run: GOARCH=${{ matrix.go-arch }} make rosetta
- name: Run proxy in background
run: ./rosetta-filecoin-proxy&
- run: ./rosetta-cli-test.sh
35 changes: 35 additions & 0 deletions .github/workflows/rosetta-cli-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: rosetta-cli-test

on:
push:
branches:
- main
- release/**
pull_request:
merge_group:

permissions:
contents: read

jobs:
run-simapp:
runs-on: ubuntu-latest
steps:
- name: Get cosmos-sdk repo
uses: actions/checkout@v3
with:
repository: cosmos/cosmos-sdk
ref: main
- name: set up simapp
run: make build && export SIMD_BIN=./build/simd && make init-simapp && ./build/simd start && curl localhost:26657/status &
- name: Sleep for 2 minutes
run: sleep 120s
shell: bash
- uses: actions/checkout@v3
- name: review
run: curl localhost:26657/status
- name: Build Rosetta
run: go mod tidy && make rosetta && make plugin && ./rosetta --blockchain "cosmos" --network "cosmos" --tendermint "tcp://localhost:26657" --addr "localhost:8080" --grpc "localhost:9090 &"
- uses: actions/checkout@v3
- name: Rosetta-cli setup & test
run: make rosetta-cli
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.20 AS build-env

# Set working directory for the build
WORKDIR /go/src/github.com/cosmos/rosetta

# optimization: if go.sum didn't change, docker will use cached image
COPY go.mod go.sum ./

RUN go mod download

# Add source files
COPY . .

RUN make build
RUN make plugin

EXPOSE 8080

# Run simd by default
CMD ["./rosetta", "--blockchain", "app", "--network", "network", "--tendermint", "cosmos:26657", "--grpc", "cosmos:9090", "--addr", ":8080"]
ENTRYPOINT ["./rosetta"]
STOPSIGNAL SIGTERM
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ lint-fix:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
@./scripts/go-lint-all.bash --fix

.PHONY: all build rosetta test lint lint-fix
.PHONY: all build rosetta test lint lint-fix

rosetta-cli:
echo "Installing rosetta linter"
curl -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/master/scripts/install.sh | sh -s
./bin/rosetta-cli --configuration-file ./configs/rosetta-config-cli.json check:data
10 changes: 5 additions & 5 deletions plugins/cosmos-hub/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcTypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"

ibcLightClient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibcClient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
Expand All @@ -15,13 +15,13 @@ import (

func InitZone() {
config := sdk.GetConfig()
prefix := "evmos"
prefix := "cosmos-hub"
config.SetBech32PrefixForAccount(prefix, prefix+"pub")
}

func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
ibcclienttypes.RegisterInterfaces(registry)
ibcLightClient.RegisterInterfaces(registry)
ibcTypes.RegisterInterfaces(registry)
ibcClient.RegisterInterfaces(registry)
sdk.RegisterInterfaces(registry)
txtypes.RegisterInterfaces(registry)
cryptocodec.RegisterInterfaces(registry)
Expand Down
14 changes: 14 additions & 0 deletions scripts/rosetta-cll-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -o nounset -o pipefail -o errexit
set +u
trap "exit 1" INT

go install github.com/coinbase/[email protected]

printf "### Running rosetta-cli tests \n"

#Add all rosetta-cli checks here
rosetta-cli check:data --configuration-file ./configs/rosetta-config-cli.json

printf "### Tests finished\n"
12 changes: 12 additions & 0 deletions tests/config/bootstrap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"account_identifier": {
"address":"cosmos1f3d3s7jjy5zune554w7fnhrhyuxhll7s7rps0h"
},
"currency":{
"symbol":"stake",
"decimals":0
},
"value": "999990000000"
}
]
59 changes: 59 additions & 0 deletions tests/config/data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh

set -e

wait_simd() {
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 9090
}
# this script is used to recreate the data dir
echo clearing /root/.simapp
rm -rf /root/.simapp
echo initting new chain
# init config files
simd init simd --chain-id testing

# create accounts
simd keys add fd --keyring-backend=test

addr=$(simd keys show fd -a --keyring-backend=test)
val_addr=$(simd keys show fd --keyring-backend=test --bech val -a)

# give the accounts some money
simd add-genesis-account "$addr" 1000000000000stake --keyring-backend=test

# save config for the daemon
simd gentx fd 10000000stake --chain-id testing --keyring-backend=test

# input genTx to the genesis file
simd collect-gentxs
# verify genesis file is fine
simd validate-genesis
echo changing network settings
sed -i 's/127.0.0.1/0.0.0.0/g' /root/.simapp/config/config.toml

# start simd
echo starting simd...
simd start --pruning=nothing &
pid=$!
echo simd started with PID $pid

echo awaiting for simd to be ready
wait_simd
echo simd is ready
sleep 10


# send transaction to deterministic address
echo sending transaction with addr $addr
simd tx bank send "$addr" cosmos19g9cm8ymzchq2qkcdv3zgqtwayj9asv3hjv5u5 100stake --yes --keyring-backend=test --broadcast-mode=block --chain-id=testing

sleep 10

echo stopping simd...
kill -9 $pid

echo zipping data dir and saving to /tmp/data.tar.gz

tar -czvf /tmp/data.tar.gz /root/.simapp

echo new address for bootstrap.json "$addr" "$val_addr"
23 changes: 23 additions & 0 deletions tests/config/faucet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from http.server import HTTPServer, BaseHTTPRequestHandler
import subprocess

import os

class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
try:
content_len = int(self.headers.get('Content-Length'))
addr = self.rfile.read(content_len).decode("utf-8")
print("sending funds to " + addr)
subprocess.call(['sh', './send_funds.sh', addr])
self.send_response(200)
self.end_headers()
except Exception as e:
print("failed " + str(e))
os._exit(1)


if __name__ == "__main__":
print("starting faucet server...")
httpd = HTTPServer(('0.0.0.0', 8000), SimpleHTTPRequestHandler)
httpd.serve_forever()
39 changes: 39 additions & 0 deletions tests/config/rosetta-config-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"network": {
"blockchain": "cosmos",
"network": "cosmos"
},
"online_url":"http://localhost:8080",
"data_directory":"",
"http_timeout":10,
"max_retries":5,
"retry_elapsed_time":0,
"max_online_connections":120,
"max_sync_concurrency":64,
"tip_delay":300,
"max_reorg_depth":100,
"log_configuration":false,
"compression_disabled":false,
"data":{
"active_reconciliation_concurrency":16,
"inactive_reconciliation_concurrency":4,
"inactive_reconciliation_frequency":250,
"log_blocks":true,
"log_transactions":false,
"log_balance_changes":false,
"log_reconciliations":false,
"ignore_reconciliation_error":false,
"reconciliation_disabled":true,
"reconciliation_drain_disabled":false,
"inactive_discrepancy_search_disabled":false,
"balance_tracking_disabled":false,
"coin_tracking_disabled":false,
"status_port":9090,
"results_output_file":"",
"initial_balance_fetch_disabled":false,
"end_conditions": {
"index": 1800
}
},
"construction":null
}
51 changes: 51 additions & 0 deletions tests/config/rosetta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"network": {
"blockchain": "app",
"network": "network"
},
"online_url": "http://rosetta:8080",
"data_directory": "",
"http_timeout": 300,
"max_retries": 5,
"retry_elapsed_time": 0,
"max_online_connections": 0,
"max_sync_concurrency": 0,
"tip_delay": 60,
"log_configuration": true,
"construction": {
"offline_url": "http://rosetta:8080",
"max_offline_connections": 0,
"stale_depth": 0,
"broadcast_limit": 0,
"ignore_broadcast_failures": false,
"clear_broadcasts": false,
"broadcast_behind_tip": false,
"block_broadcast_limit": 0,
"rebroadcast_all": false,
"constructor_dsl_file": "transfer.ros",
"end_conditions": {
"create_account": 1,
"transfer": 1
}
},
"data": {
"active_reconciliation_concurrency": 0,
"inactive_reconciliation_concurrency": 0,
"inactive_reconciliation_frequency": 0,
"log_blocks": false,
"log_transactions": false,
"log_balance_changes": false,
"log_reconciliations": false,
"ignore_reconciliation_error": false,
"exempt_accounts": "",
"bootstrap_balances": "bootstrap.json",
"interesting_accounts": "",
"reconciliation_disabled": false,
"inactive_discrepency_search_disabled": false,
"balance_tracking_disabled": false,
"coin_tracking_disabled": false,
"end_conditions": {
"tip": true
}
}
}
17 changes: 17 additions & 0 deletions tests/config/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh


set -e

wait_for_rosetta() {
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' rosetta 8080
}

echo "waiting for rosetta instance to be up"
wait_for_rosetta

echo "checking data API"
rosetta-cli check:data --configuration-file ./config/rosetta.json

echo "checking construction API"
rosetta-cli check:construction --configuration-file ./config/rosetta.json
5 changes: 5 additions & 0 deletions tests/config/send_funds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e
addr=$(simd keys show fd -a --keyring-backend=test)
echo "12345678" | simd tx bank send "$addr" "$1" 100stake --chain-id="testing" --node tcp://cosmos:26657 --yes --keyring-backend=test
Loading