-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
504 changed files
with
78,268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
Oops, something went wrong.