Skip to content

Commit

Permalink
merge main & resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed Dec 1, 2022
2 parents 460f106 + 60934f1 commit 38d4c37
Show file tree
Hide file tree
Showing 697 changed files with 30,674 additions and 5,259 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ docs/
networks/
proto/
scripts/
tests/
tools/
.github/
.git/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,51 @@ env:
GOLANG_VERSION: 1.18
GENESIS_URL: https://github.com/osmosis-labs/networks/raw/main/osmosis-1/genesis.json
ADDRBOOK_URL: https://dl2.quicksync.io/json/addrbook.osmosis.json
SNAPSHOT_BUCKET: https://osmosis-snapshot.sfo3.cdn.digitaloceanspaces.com
SNAPSHOT_BUCKET: https://snapshots.osmosis.zone
RPC_ENDPOINT: https://rpc.osmosis.zone
LCD_ENDPOINT: https://lcd.osmosis.zone
DELTA_HALT_HEIGHT: 50

jobs:

compare_versions:
# Compare current mainnet osmosis major version with the major version of github branch
# Skip the next job if the current github major is greater than the current mainnet major
runs-on: self-hosted
outputs:
should_i_run: ${{ steps.compare_versions.outputs.should_i_run }}
mainnet_major_version: ${{ steps.mainnet_version.outputs.mainnet_major_version }}
steps:
-
name: Get mainnet major version
id: mainnet_version
run: |
# Find current major version via rpc.osmosis.zone/abci_info
RPC_ABCI_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_ENDPOINT }}/abci_info)
MAINNET_MAJOR_VERSION=$(echo $RPC_ABCI_INFO | dasel --plain -r json 'result.response.version' | cut -f 1 -d '.')
echo "MAINNET_MAJOR_VERSION=$MAINNET_MAJOR_VERSION" >> $GITHUB_ENV
echo "mainnet_major_version=$MAINNET_MAJOR_VERSION" >> $GITHUB_OUTPUT
-
name: Get GitHub branch major version
id: compare_versions
run: |
CURRENT_BRANCH_MAJOR_VERSION=$(echo ${{ github.event.pull_request.base.ref }} | tr -dc '0-9')
SHOULD_I_RUN=$(( $CURRENT_BRANCH_MAJOR_VERSION <= $MAINNET_MAJOR_VERSION ))
echo -n "Mainnet version: $MAINNET_MAJOR_VERSION | Branch version: $CURRENT_BRANCH_MAJOR_VERSION | Should I run: "
if (( $CURRENT_BRANCH_MAJOR_VERSION <= $MAINNET_MAJOR_VERSION ));
then
echo 'should_i_run=true' >> $GITHUB_OUTPUT;
echo "true"
else
echo 'should_i_run=false' >> $GITHUB_OUTPUT;
echo "false"
fi
check_state_compatibility:
# DO NOT CHANGE THIS: please read the note above
if: ${{ github.event.pull_request.head.repo.full_name == 'osmosis-labs/osmosis' }}
if: ${{ github.event.pull_request.head.repo.full_name == 'osmosis-labs/osmosis' && needs.compare_versions.outputs.should_i_run == 'true' }}
runs-on: self-hosted
steps:
-
Expand All @@ -73,7 +108,7 @@ jobs:
# Download genesis file if not present
mkdir -p /mnt/data/genesis/osmosis-1/
if [ ! -f "/mnt/data/genesis/osmosis-1/genesis.json" ]; then
wget -O /mnt/data/genesis/osmosis-1/genesis.json ${{ env.GENESIS_URL }}
wget -q -O /mnt/data/genesis/osmosis-1/genesis.json ${{ env.GENESIS_URL }}
fi
# Copy genesis to config folder
Expand All @@ -82,23 +117,12 @@ jobs:
name: ⏬ Download last pre-epoch snapshot
run: |
REPO_MAJOR_VERSION=$(echo $(git describe --tags) | cut -f 1 -d '.') # with v prefix
# Find current major version via rpc.osmosis.zone/abci_info
RPC_ABCI_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_ENDPOINT }}/abci_info)
CHAIN_MAJOR_VERSION=$(echo $RPC_ABCI_INFO | dasel --plain -r json 'result.response.version' | cut -f 1 -d '.') # no v prefix
# Get correct url to fetch snapshot comparing versions
if [ $REPO_MAJOR_VERSION == v$CHAIN_MAJOR_VERSION ]; then
# I'm in the latest major
SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/osmosis.json
else
SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/$REPO_MAJOR_VERSION/osmosis.json
fi
SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/$REPO_MAJOR_VERSION/snapshots.json
# Get the latest pre-epoch snapshot information from bucket
SNAPSHOT_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" $SNAPSHOT_INFO_URL)
SNAPSHOT_URL=$(echo $SNAPSHOT_INFO | dasel --plain -r json '(file=osmosis-1-pre-epoch).url')
SNAPSHOT_ID=$(echo $SNAPSHOT_INFO | dasel --plain -r json '(file=osmosis-1-pre-epoch).filename' | cut -f 1 -d '.')
SNAPSHOT_URL=$(echo $SNAPSHOT_INFO | jq -r '.[] | select(.type == "pre-epoch").url')
SNAPSHOT_ID=$(echo $SNAPSHOT_INFO | jq -r '.[] | select(.type == "pre-epoch").filename' | cut -f 1 -d '.')
# Download snapshot if not already present
mkdir -p /mnt/data/snapshots/$REPO_MAJOR_VERSION/
Expand All @@ -114,24 +138,20 @@ jobs:
name: 🧪 Configure Osmosis Node
run: |
CONFIG_FOLDER=$HOME/.osmosisd/config
# Find current major version via rpc.osmosis.zone/abci_info
RPC_ABCI_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" ${{ env.RPC_ENDPOINT }}/abci_info)
CHAIN_MAJOR_VERSION=$(echo $RPC_ABCI_INFO | dasel --plain -r json 'result.response.version' | cut -f 1 -d '.')
# Find last epoch block comparing repo version to current chain version
REPO_MAJOR_VERSION=$(echo $(git describe --tags) | sed 's/^v//' | cut -f 1 -d '.') # without v prefix
if [ $REPO_MAJOR_VERSION == $CHAIN_MAJOR_VERSION ]; then
if [ $REPO_MAJOR_VERSION == $MAINNET_MAJOR_VERSION ]; then
# I'm in the latest major, fetch the epoch info from the lcd endpoint
LAST_EPOCH_BLOCK_HEIGHT=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 ${{ env.LCD_ENDPOINT }}/osmosis/epochs/v1beta1/epochs | dasel --plain -r json 'epochs.(identifier=day).current_epoch_start_height')
else
# I'm in a previous major, calculate the epoch height from the snapshot height
# (Snapshot is taken 100 blocks before epoch)
SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/v$REPO_MAJOR_VERSION/osmosis.json
SNAPSHOT_INFO_URL=${{ env.SNAPSHOT_BUCKET }}/v$REPO_MAJOR_VERSION/snapshots.json
SNAPSHOT_INFO=$(curl -s --retry 5 --retry-delay 5 --connect-timeout 30 -H "Accept: application/json" $SNAPSHOT_INFO_URL)
SNAPSHOT_BLOCK_HEIGHT=$(echo $SNAPSHOT_INFO | dasel --plain -r json '(file=osmosis-1-pre-epoch).height')
SNAPSHOT_BLOCK_HEIGHT=$(echo $SNAPSHOT_INFO | jq -r '.[] | select(.type == "pre-epoch").height')
LAST_EPOCH_BLOCK_HEIGHT=$(($SNAPSHOT_BLOCK_HEIGHT + 100))
fi
Expand All @@ -143,14 +163,16 @@ jobs:
# Edit config.toml
dasel put string -f $CONFIG_FOLDER/config.toml '.tx_index.indexer' null
dasel put string -f $CONFIG_FOLDER/config.toml '.p2p.persistent_peers' 'b59016320a74525f92dbc3348521c64f2bf3f006@p2p.archive.osmosis.zone:26656'
dasel put string -f $CONFIG_FOLDER/config.toml 'seeds' ''
# Edit app.toml
dasel put string -f $CONFIG_FOLDER/app.toml '.halt-height' $HALT_HEIGHT
dasel put string -f $CONFIG_FOLDER/app.toml '.pruning' everything
dasel put string -f $CONFIG_FOLDER/app.toml '.state-sync.snapshot-interval' 0
# Download addrbook
wget -O $CONFIG_FOLDER/addrbook.json ${{ env.ADDRBOOK_URL }}
wget -q -O $CONFIG_FOLDER/addrbook.json ${{ env.ADDRBOOK_URL }}
-
name: 🧪 Start Osmosis Node
run: build/osmosisd start
Expand Down
72 changes: 36 additions & 36 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ on:

jobs:
test:
name: Test Suite
name: Test Cosmwasm Contracts
runs-on: ubuntu-latest
strategy:
matrix:
contract: [{workdir: ./x/ibc-rate-limit/, output: testdata/rate_limiter.wasm, build: artifacts/rate_limiter-x86_64.wasm, name: rate_limiter}]
contract: [{workdir: ./x/ibc-rate-limit/, output: bytecode/rate_limiter.wasm, build: artifacts/rate_limiter.wasm, name: rate_limiter}]

steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand All @@ -29,51 +29,47 @@ jobs:
go.mod
**/**cargo.toml
- name: Install toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@1.65.0
with:
toolchain: nightly
target: wasm32-unknown-unknown

- name: Add the wasm target
working-directory: ${{ matrix.contract.workdir }}
run: >
rustup target add wasm32-unknown-unknown;
- name: Build
working-directory: ${{ matrix.contract.workdir }}
run: >
cargo build --release --target wasm32-unknown-unknown
- name: Test
working-directory: ${{ matrix.contract.workdir }}
run: >
cargo test
- name: Set latest cw-optimizoor version
run: >
echo "CW_OPTIMIZOOR_VERSION=`cargo search cw-optimizoor -q | cut -d '"' -f 2`" >> $GITHUB_ENV
- name: Cache cw-optimizoor
id: cache-cw-optimizoor
uses: actions/cache@v3
env:
cache-name: cache-cw-optimizoor
with:
# cargo bin files are stored in `~/.cargo/bin/` on Linux/macOS
path: ~/.cargo/bin/cargo-cw-optimizoor
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CW_OPTIMIZOOR_VERSION }}

- if: ${{ steps.cache-cw-optimizoor.outputs.cache-hit != 'true' }}
name: Install cw-optimizoor
continue-on-error: true
run: >
cargo install cw-optimizoor
# - name: Set latest cw-optimizoor version
# run: >
# echo "CW_OPTIMIZOOR_VERSION=0.8.0" >> $GITHUB_ENV
#
# - name: Cache cw-optimizoor
# id: cache-cw-optimizoor
# uses: actions/cache@v3
# env:
# cache-name: cache-cw-optimizoor
# with:
# # cargo bin files are stored in `~/.cargo/bin/` on Linux/macOS
# path: ~/.cargo/bin/cargo-cw-optimizoor
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.CW_OPTIMIZOOR_VERSION }}
#
# - if: ${{ steps.cache-cw-optimizoor.outputs.cache-hit != 'true' }}
# name: Install cw-optimizoor
# continue-on-error: true
# run: >
# cargo install cw-optimizoor

- name: Optimize
working-directory: ${{ matrix.contract.workdir }}
run: >
cargo cw-optimizoor
docker run --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 \
cosmwasm/workspace-optimizer:0.12.10
- name: 'Upload optimized contract artifact'
uses: actions/upload-artifact@v3
Expand All @@ -82,6 +78,13 @@ jobs:
path: ${{ matrix.contract.workdir }}${{ matrix.contract.build }}
retention-days: 1

- name: 'Upload Cargo.lock artifact'
uses: actions/upload-artifact@v3
with:
name: Cargo.lock
path: ${{ matrix.contract.workdir }}Cargo.lock
retention-days: 1

- name: Check Test Data
working-directory: ${{ matrix.contract.workdir }}
if: ${{ matrix.contract.output != null }}
Expand All @@ -98,17 +101,14 @@ jobs:

steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.rs
- name: Install toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@1.65.0
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Format
Expand Down
Loading

0 comments on commit 38d4c37

Please sign in to comment.