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

epic: migration for v0.21 with passing tests #wip #238

Merged
merged 25 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f366162
Fixing imports for v0.21, need gogoproto for release
AnishP15 Jul 1, 2023
65a34c1
Broken epochs from nibiru_proto
AnishP15 Jul 3, 2023
8cb03cc
#wip: no import errors on test runs
Unique-Divine Jul 4, 2023
e8b4e46
saved #wip
AnishP15 Jul 4, 2023
72b3b79
fixed tx service halts #wip
AnishP15 Jul 5, 2023
8ed9157
Pass spot tests if pool dne
AnishP15 Jul 5, 2023
248532c
Fix stablecoin test
AnishP15 Jul 5, 2023
5e797bc
all passing tests on v0.21
AnishP15 Jul 5, 2023
339e00b
Ran pre-commit auto update
AnishP15 Jul 5, 2023
1154b57
Add tx query to include missing fields from grpc resp
AnishP15 Jul 6, 2023
75b72a3
save #wip: fixing InactiveRpcError
Unique-Divine Jul 7, 2023
772b7b4
fix!: improvements to broadcast fn
Unique-Divine Jul 8, 2023
1d73353
fix,docs(tx.py)!:
Unique-Divine Jul 8, 2023
c3ec279
fix,ci(scripts): (1) Add --no-build flag for localnet.sh,
Unique-Divine Jul 8, 2023
21b16bb
ci(scripts.yml): trigger run
Unique-Divine Jul 8, 2023
8834d98
ci: fix typo
Unique-Divine Jul 8, 2023
8262abf
ci: lower the sleep time since the network starts pretty quickly
Unique-Divine Jul 8, 2023
3166b06
ci(scripts.yml): run localnet.sh in the background
Unique-Divine Jul 8, 2023
39022c4
appease linter
Unique-Divine Jul 8, 2023
af91a02
ci(lint.yml): make linter more specific
Unique-Divine Jul 8, 2023
ce6149e
run black and flake8
Unique-Divine Jul 8, 2023
e15615a
fix: both isort and black should be poetry 'dev' dependencies
Unique-Divine Jul 8, 2023
0da4df8
ci(lint.yml): wrong job name
Unique-Divine Jul 8, 2023
d5296aa
ci(lint.yml): clean up workflow even more + concurrency restart
Unique-Divine Jul 8, 2023
f0e0363
ci(lint.yml): invalid run/uses syntax for job:lint-py
Unique-Divine Jul 8, 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
77 changes: 54 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,69 @@
name: Linting
name: "Linting"
on:
push:
branches:
- master
pull_request:
branches:
- master
branches: ["master"]
push:
branches: ["master"]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}

jobs:
test:
lint-py:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 2
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Check out the repo
uses: actions/checkout@v3

- name: Setup Python
- name: "Setup Python"
uses: actions/setup-python@v2
with:
python-version: "3.9.13"

#----------------------------------------------
# load pip cache if cache exists
#----------------------------------------------
- uses: actions/cache@v2
- name: "Load pip cache if cache exists"
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip
#----------------------------------------------
# install and run linters
#----------------------------------------------
- run: python -m pip install black flake8 isort
- run: |
flake8 .
black . --check
isort .
- name: "Install and run flake8"
run: |
python -m pip install flake8
flake8 nibiru
flake8 tests
flake8 examples

# ----------------------------------------------
# Try to load a cached poetry binary
# See https://github.com/snok/install-poetry#caching-the-poetry-installation for the source
# ----------------------------------------------
- name: "Load cached Poetry installation"
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-0 # increment to reset cache

- name: "Install poetry"
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: latest
- name: "Load cached venv"
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: "Install dependencies with poetry (using cache)"
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run checks for black and isort
run: |
poetry run black . --check
poetry run isort .
33 changes: 16 additions & 17 deletions .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E 🐍 tests
name: "E2E 🐍 tests"

on:
pull_request:
Expand Down Expand Up @@ -29,12 +29,6 @@ jobs:
runs-on: ubuntu-latest
env:
# https://www.notion.so/nibiru/Resources-and-Repo-Configs-b31aa8074a2b419d80b0c946ed5efab0
LCD_ENDPOINT: "http://localhost:1317"
GRPC_ENDPOINT: "localhost:9090"
TENDERMINT_RPC_ENDPOINT: "http://localhost:26657"
USE_LOCALNET: true
WEBSOCKET_ENDPOINT: "ws://localhost:26657/websocket"
CHAIN_ID: "nibiru-localnet-0"
VALIDATOR_MNEMONIC: "guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
DEVNET_NUMBER: ${{ secrets.DEVNET_NUMBER }}
steps:
Expand All @@ -54,7 +48,7 @@ jobs:
# 3.8.16 is the highest 3.8 version available on pyenv
# See `grep '3.8' <<< $(pyenv install -l)` to view the available list.

- name: Run python
- name: Run python # sanity check on the installation.
run: python --version && python -c "print('hello')"

# ----------------------------------------------
Expand Down Expand Up @@ -99,16 +93,21 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run chaosnet
uses: NibiruChain/[email protected]
id: chaosnet
with:
services: nibiru pricefeeder
ghtoken: ${{ secrets.GITHUB_TOKEN }}
ghactor: ${{ github.actor }}
- name: Run localnet.sh in the background.
run: |
curl -s https://get.nibiru.fi/@v0.21.5! | bash
bash scripts/localnet.sh --no-build &

# - name: Run chaosnet
# uses: NibiruChain/[email protected]
# id: chaosnet
# with:
# services: nibiru pricefeeder
# ghtoken: ${{ secrets.GITHUB_TOKEN }}
# ghactor: ${{ github.actor }}

- name: sleep 30 seconds
run: sleep 30
- name: "Sleep so that the network has time to start."
run: sleep 5
#----------------------------------------------
# run tests
#----------------------------------------------
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "py-sdk/scripts"

on:
pull_request:
branches: ["master"]
paths:
[
"scripts",
"**.py",
"pyproject.toml",
"poetry.lock",
".github/workflows/pytests.yml",
]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}

jobs:
localnet:
# The localnet job verifies that the repo's script for starting a local Nibiru
# chain runs without errors.
runs-on: ubuntu-latest
env:
# https://www.notion.so/nibiru/Resources-and-Repo-Configs-b31aa8074a2b419d80b0c946ed5efab0
VALIDATOR_MNEMONIC: "guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
DEVNET_NUMBER: ${{ secrets.DEVNET_NUMBER }}
steps:
# ----------------------------------------------
# check-out repo and set-up python
# ----------------------------------------------
- name: Check out the repo
uses: actions/checkout@v3

- name: Run localnet.sh in the background.
run: |
curl -s https://get.nibiru.fi/@v0.21.5! | bash
bash scripts/localnet.sh --no-build &
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
coverage.txt
examples/trading_bot.py

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: "0.4.0" # the revision or tag to clone at
rev: "1.1.0" # the revision or tag to clone at
hooks:
- id: sync_with_poetry
args: [] # optional args
Expand All @@ -14,7 +14,7 @@ repos:
exclude: nibiru/proto/.+

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
files: \.py$
Expand Down
2 changes: 1 addition & 1 deletion nibiru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
Network,
NetworkType,
PoolAsset,
TxBroadcastMode,
TxConfig,
TxType,
)
from nibiru.sdk import Sdk # noqa
from nibiru.tx import Transaction # noqa
Expand Down
13 changes: 8 additions & 5 deletions nibiru/event_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from enum import Enum

import google.protobuf.message
from nibiru_proto.proto.oracle.v1 import event_pb2 as oracle_events
from nibiru_proto.proto.perp.v2 import event_pb2 as perp_events
from nibiru_proto.proto.spot.v1 import event_pb2 as spot_events
from nibiru_proto.proto.stablecoin.v1 import events_pb2 as stablecoin_events # noqa
from nibiru_proto.nibiru.oracle.v1 import event_pb2 as oracle_events
from nibiru_proto.nibiru.perp.v2 import event_pb2 as perp_events
from nibiru_proto.nibiru.spot.v1 import event_pb2 as spot_events
from nibiru_proto.nibiru.stablecoin.v1 import events_pb2 as stablecoin_events # noqa


class EventType(Enum):
Expand Down Expand Up @@ -35,7 +35,10 @@ class EventType(Enum):
BuybackEvent = stablecoin_events.EventBuyback

# Oracle events
PriceUpdate = oracle_events.OraclePriceUpdate
PriceUpdate = oracle_events.EventPriceUpdate
EventDelegateFeederConsent = oracle_events.EventDelegateFeederConsent
EventAggregateVote = oracle_events.EventAggregateVote
EventAggregatePrevote = oracle_events.EventAggregatePrevote

# Bank
Transfer = "transfer"
Expand Down
4 changes: 4 additions & 0 deletions nibiru/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ class TxError(NibiruError):
pass


class ErrorQueryTx(NibiruError):
"""Expresses failure to to query a tx with its hash."""


class QueryError(NibiruError):
pass
Loading