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

Integrate Rosetta API into Launchpad. #7602

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
370adb8
Temp commit to switch context.
jgimeno Oct 20, 2020
8df46be
Fix tests.
jgimeno Oct 23, 2020
5cc65ba
Create skeleton for rosetta.
jgimeno Oct 23, 2020
ec63e27
Add cobra command to run rosetta service.
jgimeno Oct 23, 2020
54bb0b0
Move codec outside types.
jgimeno Oct 26, 2020
3f79776
Remove config.
jgimeno Oct 26, 2020
3b5c8d9
Fix bug.
jgimeno Oct 26, 2020
7d0645e
Fix tests.
jgimeno Oct 26, 2020
1d2bfc6
Remove Bech32 prefix.
jgimeno Oct 26, 2020
77ee959
remove bech32 param
jgimeno Oct 26, 2020
3f5e86d
Temp commit.
jgimeno Oct 26, 2020
ba40d76
Revert in process Rosetta server.
jgimeno Oct 27, 2020
b2815d3
Fix Linter errors.
jgimeno Oct 27, 2020
7f62f8d
update service
jgimeno Oct 28, 2020
03d927b
add logger
jgimeno Oct 28, 2020
55f7e5f
update msg type
jgimeno Oct 28, 2020
8102873
remove ctx
jgimeno Oct 28, 2020
1642d0b
Change name to operationTransfer to OperationMsgSend
jgimeno Oct 28, 2020
58f30aa
Update listen address.
jgimeno Oct 28, 2020
eeb4c53
Add nolint.
jgimeno Oct 28, 2020
db857d7
add: rosetta ci
fdymylja Nov 19, 2020
62b1748
fix: simd overwriting keystore data
fdymylja Nov 19, 2020
17dc252
add: finalize rosetta CI
fdymylja Nov 23, 2020
27fadf5
fix: remove staking balance from boot
fdymylja Nov 23, 2020
0981f23
add: replicable node data
fdymylja Nov 23, 2020
6140864
change: split simd and simcli main files
fdymylja Nov 23, 2020
145f3eb
Merge branch 'launchpad/backports' of github.com:cosmos/cosmos-sdk in…
sahith-narahari Nov 29, 2020
f215cc8
update go mod
sahith-narahari Nov 29, 2020
ff6c501
init commit
sahith-narahari Nov 29, 2020
2966fe3
change: bump cosmos rosetta gateway version, update implementation
fdymylja Nov 30, 2020
72c573a
Merge branch 'jonathan-integrate-rosetta' into fdymylja/rosetta-ci-la…
fdymylja Nov 30, 2020
afa1a56
add: facilities to recreate the network data
fdymylja Dec 1, 2020
05833b1
add: go.sum changelist
fdymylja Dec 1, 2020
8bf8059
Merge pull request #8005 from cosmos/fdymylja/rosetta-ci-launchpad
jgimeno Dec 1, 2020
4835781
Merge branch 'jonathan-integrate-rosetta' of github.com:cosmos/cosmos…
sahith-narahari Dec 1, 2020
1a3cd0c
backport fees, staking
sahith-narahari Dec 1, 2020
3d25d6a
fix lint
sahith-narahari Dec 2, 2020
ebb82ef
add memo to payloads
sahith-narahari Dec 2, 2020
063a597
update imports
sahith-narahari Dec 2, 2020
8660547
update utils
sahith-narahari Dec 2, 2020
38e60f9
add rosetta-cli
sahith-narahari Dec 3, 2020
136dab5
update tests
sahith-narahari Dec 3, 2020
2b024bf
Merge pull request #8057 from cosmos/sahith/backport-fees
jgimeno Dec 3, 2020
4b57dbd
remove coment
jgimeno Dec 7, 2020
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
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,20 @@ jobs:
with:
file: ./coverage.txt
if: "env.GIT_DIFF != ''"

test-rosetta:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: test rosetta
run: |
make test-rosetta
if: env.GIT_DIFF
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ test-cover:
@export VERSION=$(VERSION); bash -x tests/test_cover.sh
.PHONY: test-cover

test-rosetta:
docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile .
docker-compose -f contrib/rosetta/docker-compose.yaml up --abort-on-container-exit --exit-code-from test_rosetta --build
.PHONY: test-rosetta

lint: golangci-lint
$(BINDIR)/golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
Expand Down Expand Up @@ -214,3 +219,15 @@ devdoc-update:
docker pull tendermint/devdoc

.PHONY: devdoc devdoc-clean devdoc-init devdoc-save devdoc-update

###############################################################################
### rosetta ###
###############################################################################
# builds rosetta test data dir
rosetta-data:
-docker container rm data_dir_build
docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile .
docker run --name data_dir_build -t rosetta-ci:latest sh /rosetta/data.sh
docker cp data_dir_build:/tmp/data.tar.gz "$(CURDIR)/contrib/rosetta/node/data.tar.gz"
docker container rm data_dir_build
.PHONY: rosetta-data
27 changes: 27 additions & 0 deletions contrib/rosetta/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# rosetta

Contains the files required to run the rosetta CI. It builds a simapp based on the current codebase.

## docker-compose.yaml

Builds:
- cosmos-sdk simapp node, with prefixed data directory, keys etc. This is required to test historical balances.
- faucet is required so we can test construction API, it was literally impossible to put there a deterministic address to request funds for
- rosetta is the rosetta node used by rosetta-cli to interact with the cosmos-sdk app
- test_rosetta runs the rosetta-cli test against construction API and data API

## configuration

Contains the required files to set up rosetta cli and make it work against its workflows

## node

Contains the files for a deterministic network, with fixed keys and some actions on there, to test parsing of msgs and historical balances.

# simd

Contains the files to build a `simd` and `simcli` binary

## Notes

- Keyring password is 12345678
12 changes: 12 additions & 0 deletions contrib/rosetta/configuration/bootstrap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"account_identifier": {
"address":"cosmos16qhazsqdrzw96d03h37rp0p4m06hu8tyam3fjs"
},
"currency":{
"symbol":"stake",
"decimals":0
},
"value": "990000000000"
}
]
63 changes: 63 additions & 0 deletions contrib/rosetta/configuration/data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

set -e

wait_simd() {
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 26657
}

echo clearing old configs
rm -rf /root/.simapp
rm -rf /root/.simcli
# init config files
simd init simd --chain-id testing
# configure cli
simcli config chain-id testing
simcli config output json
simcli config trust-node true

# use keyring backend
simcli config keyring-backend test

# create accounts
simcli keys add fd

# give the accounts some money
simd add-genesis-account $(simcli keys show fd -a) 1000000000000stake

# save configs for the daemon
simd gentx --name fd --keyring-backend test --amount 10000000000stake

# input genTx to the genesis file
simd collect-gentxs
# verify genesis file is fine
simd validate-genesis
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
addr=$(simcli keys show fd -a)
echo sending transaction with addr $addr
simcli tx send "$addr" cosmos1dee3p7gl4emuzyaqw7us5flaq5ajq3de8vrw3l 100stake --yes --keyring-backend=test --broadcast-mode=block

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/

echo new address for bootstrap.json "$addr"
24 changes: 24 additions & 0 deletions contrib/rosetta/configuration/faucet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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()
51 changes: 51 additions & 0 deletions contrib/rosetta/configuration/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
}
}
}
28 changes: 28 additions & 0 deletions contrib/rosetta/configuration/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

set -e

wait_for_node() {
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' cosmos 26657
echo "tendermint rpc is up"
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' rest 1317
echo "rest server is up"
}
wait_for_rosetta() {
timeout 30 sh -c 'until nc -z $0 $1; do sleep 1; done' rosetta 8080
}

echo "waiting for node to be up"
wait_for_node

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

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

set -e

simcli tx send cosmos16qhazsqdrzw96d03h37rp0p4m06hu8tyam3fjs "$1" 100stake --chain-id="testing" --node tcp://cosmos:26657 --yes
30 changes: 30 additions & 0 deletions contrib/rosetta/configuration/staking.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"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": "staking.ros",
"end_conditions": {
"staking": 3
}
}
}
Loading