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

Bump github.com/cosmos/cosmos-proto from 1.0.0-beta.2 to 1.0.0-beta.3 #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build Quasar

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

# This workflow makes x86_64 binaries for linux.
# TODO: add darwin later
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64]
targetos: [linux]
name: quasar ${{ matrix.arch }} for ${{ matrix.targetos }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: 1.18
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
- name: Display go version
run: go version
- name: Build quasarnoded
run: make build-reproducible-${{ matrix.arch }}
- uses: actions/upload-artifact@v2
with:
name: quasarnoded-${{ matrix.targetos }}-${{ matrix.arch }}
path: build/quasarnoded-${{ matrix.targetos }}-${{ matrix.arch }}
- name: Build smart contracts
run: make compile-wasm-artifacts
- uses: actions/upload-artifact@v2
with:
name: smart-contracts
path: |
smart-contracts/artifacts/basic_vault.wasm
smart-contracts/artifacts/lp_strategy.wasm
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint Quasar code

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

# This workflow makes x86_64 binaries for linux.
# TODO: add darwin later
jobs:
lint-go:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Display go version
run: go version
- name: Go lint
run: make lint
lint-rust:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Show versions
run: rustc -V && cargo -V
- name: Rust lint
run: cd smart-contracts && RUSTFLAGS="-Dwarnings" cargo clippy --workspace -- -D warnings
- name: Rust format check
run: cd smart-contracts && cargo fmt --all -- --check
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test Quasar

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

# This workflow makes x86_64 binaries for linux.
# TODO: add darwin later
jobs:
test-go:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Display go version
run: go version
- name: Run all tests
run: make test-cover
- name: Code coverage report
uses: codecov/[email protected]
test-rust:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run unit-tests
run: cd smart-contracts && cargo test --lib
- name: Run vault-tests
run: cd smart-contracts && cargo test --lib -p basic-vault
# - name: Compile wasm code
# uses: docker://cosmwasm/rust-optimizer:0.12.6
# with:
# args: >-
# --rm -v "$(pwd)":/code
# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target
# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry

19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.idea/
.vscode/
.DS_Store
.env
tmp/
*.tmp
*.log
__debug_bin

release/
build/
run/

node_modules/
vue/

**/**/artifacts
**/**/target
local_testnet_run-*nodes/
73 changes: 73 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION="1.18"
ARG RUNNER_IMAGE="gcr.io/distroless/static"

# --------------------------------------------------------
# Builder
# --------------------------------------------------------

FROM golang:${GO_VERSION}-alpine as builder

ARG GIT_VERSION
ARG GIT_COMMIT

RUN apk add --no-cache \
ca-certificates \
build-base \
linux-headers

# Download go dependencies
WORKDIR /quasar
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# Cosmwasm - Download correct libwasmvm version
RUN WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm_muslc.$(uname -m).a \
-O /lib/libwasmvm_muslc.a && \
# verify checksum
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \
sha256sum /lib/libwasmvm_muslc.a | grep $(cat /tmp/checksums.txt | grep $(uname -m) | cut -d ' ' -f 1)

# Copy the remaining files
COPY . .

# Build quasarnoded binary
# force it to use static lib (from above) not standard libgo_cosmwasm.so file
# then log output of file /quasar/build/quasarnoded
# then ensure static linking
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
GOWORK=off go build \
-mod=readonly \
-tags "netgo,ledger,muslc" \
-ldflags \
"-X github.com/cosmos/cosmos-sdk/version.Name="quasar" \
-X github.com/cosmos/cosmos-sdk/version.AppName="quasarnoded" \
-X github.com/cosmos/cosmos-sdk/version.Version=${GIT_VERSION} \
-X github.com/cosmos/cosmos-sdk/version.Commit=${GIT_COMMIT} \
-X github.com/cosmos/cosmos-sdk/version.BuildTags='netgo,ledger,muslc' \
-w -s -linkmode=external -extldflags '-Wl,-z,muldefs -static'" \
-trimpath \
-o build/quasarnoded ./cmd/quasarnoded


# --------------------------------------------------------
# Runner
# --------------------------------------------------------

FROM ${RUNNER_IMAGE}

COPY --from=builder /quasar/build/quasarnoded /bin/quasarnoded

ENV HOME /quasar
WORKDIR $HOME

EXPOSE 26656
EXPOSE 26657
EXPOSE 1317

ENTRYPOINT ["quasarnoded"]
132 changes: 132 additions & 0 deletions LOCALNET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@

# Quasar Local Testnet (localnet)

To run a small network of Quasar nodes locally, first generate their respective configuration:

## Setup

### Cosmovisor

Cosmovisor should be installed and available to use, [follow these instructions](https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor#installation).

Note, the current method for installation of the latest version of cosmovisor is broken, but you can still build it from source:

```bash
git clone [email protected]:cosmos/cosmos-sdk
cd cosmos-sdk
git checkout cosmovisor/v1.1.0
make cosmovisor
cp cosmovisor/cosmovisor ~/go/bin/cosmovisor
echo "$(which cosmovisor)"
```

```bash
make build # make sure we have a quasar executable available first
scripts/localnet init_default_cluster
```

This will create a set of configuration files per node, under `run/localnet`.

By default, there is a total of 4 nodes: `node1`, `node2`, `node3`, `node4`

The network is now ready to be started.

Note that the chain state will be kept under the `run/localnet` node folders.
Running `scripts/localnet init_default_cluster` a second time will fail if existing state is present in `run/localnet`.

If a reset is desired, the entire content of `run/localnet` can be removed and `scripts/localnet init_default_cluster` can be run again.

## Start

```bash
scripts/localnet start_all
```

To see if the nodes are running:

```bash
scripts/localnet status_all
```

Once the network is running, you can see the logging per node, this way:

```bash
scripts/localnet node 0 log
```

Here, `0` is the node identifier, you can use, `1`, `2`, or `3` to see the logging of the other nodes.

## Commands

You can also issue query or tx commands against each node:

```bash
scripts/localnet node 0 cmd tx bank send main quasar1khfcjt5w0dfjgkcudlrnnun2rtq359ulrgv7gw 1000uqsar
```

This will send a bank transfer from `node0`'s `main` address, to another quasar address `quasar1khfcjt5w0dfjgkcudlrnnun2rtq359ulrgv7gw`.

You can check the balance after the transfer:

```bash
curl http://localhost:1300/bank/balances/quasar1khfcjt5w0dfjgkcudlrnnun2rtq359ulrgv7gw
```

Note that the API for `node0` is available at `localhost:1300`, while the API for `node1` is at `localhost:1301`, and so forth.

## Test a chain upgrade

You can test a dummy upgrade by doing the following steps.

Once the network is running, you can first introduce a Quasar upgrade, using the following script. It will add source code for a dummy upgrade under `app/upgrades/dummy`:

```bash
scripts/add_dummy_upgrade
```

Then make sure the upgrade is registered in the `app.go`:

```golang
// imports
// ...
dummy "github.com/quasarlabs/quasarnode/app/upgrades/dummy"

// var block declaration
// ...
Upgrades = []upgrades.Upgrade{dummy.Upgrade}
```

Then you can recompile the quasar node binary and install it in the local node folders:

```bash
make build
scripts/localnet install_upgrade_binaries dummy
```

You can confirm that the new binaries are installed correctly and ready to be used:

```bash
ls run/localnet/node*/home/cosmovisor/upgrades/dummy/bin
```

Now we can trigger the upgrade via a governance proposal and `cosmovisor` will swap and restart the new binary.

You can also run a terminal window tailing the logging of one of the nodes (`scripts/localnet node 0 log`), to witness the upgrade happening.

```bash
scripts/localnet register_upgrade 1 BLOCK_HEIGHT dummy
```

Here we instruct the first proposal (`1`), to run the `dummy` upgrade at height `BLOCK_HEIGHT`.

The script will instruct all 4 validator nodes to vote yes on this proposal, that will happen at `BLOCK_HEIGHT`, choose a block height about a minute in the future, ~100 blocks away from now for instance, this will allow for the voting period to end (20 seconds configured) and the proposal to pass successfully.

After the target block height has been reached, you should see the restart happening in the logs, as well as the dummy print statement from the upgrade itself (`Dummy Quasar migration`).

## Stop

Last but not least, to stop the network:

```bash
scripts/localnet stop_all
```
Loading