Skip to content

Commit

Permalink
Merge pull request #1914 from CounterpartyXCP/develop
Browse files Browse the repository at this point in the history
v10.2.0
  • Loading branch information
adamkrellenstein authored Jun 11, 2024
2 parents 6378d81 + e523da4 commit 0319293
Show file tree
Hide file tree
Showing 136 changed files with 50,525 additions and 23,730 deletions.
12 changes: 4 additions & 8 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
You're about to create pull request on the Counterparty Core codebase! 🎉 As part of this process, please be sure to:

* [ ] Double-check the spelling and grammar of all strings, code comments, etc.
* [ ] Double-check that all code that needs to be is deterministic
* [ ] Add tests to cover any new features
* [ ] Ensure that the test suite passes with the proposed changes
* [ ] Double-check that all code is deterministic that needs to be
* [ ] Add tests to cover any new or revised logic
* [ ] Ensure that the test suite passes
* [ ] Update the project [release notes](release-notes/)
* [ ] Update the project documentation as appropriate with a corresponding Pull Request in the [Documentation repository](https://github.com/CounterpartyXCP/Documentation)

... and be sure to label the Pull Request as a "draft" for as long as it is not ready to be merged into `develop`.
* [ ] Update the project documentation, as appropriate, with a corresponding Pull Request in the [Documentation repository](https://github.com/CounterpartyXCP/Documentation)
91 changes: 19 additions & 72 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: PyTest

on:
push:
branches: "**"
branches:
- "**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -13,77 +14,13 @@ env:
COUNTERPARTY_RS_DIR: "./counterparty-rs"

jobs:
macos-x86_64:
runs-on: macos-12 #x86_64
steps:
- uses: actions/checkout@v4

# Install dependencies

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install leveldb
run: |
brew install leveldb
- name: Install pytest and build module
run: |
pip install pytest hatch
python -m pip install --upgrade build
# Build counterparty packages

- name: Build counterparty-rs
uses: messense/maturin-action@v1
with:
args: --release --out dist --sdist -m ${{ env.COUNTERPARTY_RS_DIR }}/Cargo.toml

- name: Build counterparty-core
run: |
cd counterparty-core && hatch build ../dist
# Install counterparty packages

- name: Install wheels
run: |
pip install dist/*.whl --force-reinstall
# Run counterparty-core tests

- name: Run counterparty-core tests
run: |
cd counterparty-core
pytest
# Upload wheels

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: macos-x86_64-wheels
path: dist

macos-m1:
runs-on: macos-14
steps:
- uses: actions/checkout@v4

# Install dependencies

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -102,11 +39,16 @@ jobs:
- name: Install pytest and build module
run: |
pip3.10 install pytest hatch
python3.10 -m pip install pytest hatch
python3.10 -m pip install --upgrade build
# Build counterparty packages

- name: Test counterparty-rs
run: |
cd ${{ env.COUNTERPARTY_RS_DIR }}
cargo test
- name: Build counterparty-rs
uses: messense/maturin-action@v1
with:
Expand All @@ -122,14 +64,14 @@ jobs:
run: |
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"
export CPATH="$CPATH:$(brew --prefix)/include"
pip3.10 install dist/*.whl --force-reinstall
python3.10 -m pip install dist/*.whl --force-reinstall
# Run counterparty-core tests

- name: Run counterparty-core tests
run: |
cd counterparty-core
pytest
hatch run pytest
# Upload wheels

Expand All @@ -138,18 +80,18 @@ jobs:
with:
name: macos-m1-wheels
path: dist

ubuntu-22-04:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

# Install dependencies

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache: "pip"

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -169,6 +111,11 @@ jobs:
# Build counterparty packages

- name: Test counterparty-rs
run: |
cd ${{ env.COUNTERPARTY_RS_DIR }}
cargo test
- name: Build counterparty-rs
uses: messense/maturin-action@v1
with:
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/publish_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Publish Docker Image
on:
release:
types: [published]
push:
branches:
- develop

env:
DOCKER_REPO: counterparty/counterparty
Expand All @@ -20,9 +23,15 @@ jobs:
sudo sh get-docker.sh
- name: Build, tag, login and push image
run: |
export VERSION=v$(cat counterparty-core/counterpartycore/lib/config.py | grep '__version__ =' | awk -F '"' '{print $2}')
if [[ ${{ github.event_name }} == 'release' ]]; then
export VERSION=v$(cat counterparty-core/counterpartycore/lib/config.py | grep '__version__ =' | awk -F '"' '{print $2}')
elif [[ ${{ github.event_name }} == 'push' && ${{ github.ref }} == 'refs/heads/develop' ]]; then
export VERSION=develop
fi
docker build -t $DOCKER_REPO:$VERSION .
docker tag $DOCKER_REPO:$VERSION $DOCKER_REPO:latest
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
docker push $DOCKER_REPO:$VERSION
docker push $DOCKER_REPO:latest
if [[ ${{ github.event_name }} == 'release' ]]; then
docker push $DOCKER_REPO:latest
fi
41 changes: 35 additions & 6 deletions .github/workflows/test_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@ docker container prune -f
docker rmi counterparty/counterparty:$VERSION || true

# build the counterparty-core new image
docker build -t counterparty/counterparty:$VERSION .
docker build -t counterparty/counterparty:$VERSION . > build.txt 2>&1
COUNTERPARTY_RS_CACHED=$(awk '/COPY \.\/counterparty-rs \/counterparty-rs/{getline; print}' build.txt | awk '{print $2}')
cat build.txt

# re-start containers
docker compose --profile mainnet up -d
docker compose --profile testnet up -d

# wait for counterparty-core to be ready
while [ "$(docker compose logs counterparty-core 2>&1 | grep 'Ready for queries')" = "" ]; do
while [ "$(docker compose logs counterparty-core 2>&1 | grep 'Catch up complete.')" = "" ]; do
echo "Waiting for counterparty-core mainnet to be ready"
sleep 1
done

while [ "$(docker compose logs counterparty-core-testnet 2>&1 | grep 'Ready for queries')" = "" ]; do
while [ "$(docker compose logs counterparty-core-testnet 2>&1 | grep 'Catch up complete.')" = "" ]; do
echo "Waiting for counterparty-core testnet to be ready"
sleep 1
done
Expand Down Expand Up @@ -75,7 +77,7 @@ if [ "$response_v1_testnet" -ne 200 ]; then
fi

# check running info with API v2 mainnet
response_v2_mainnet=$(curl http://api:[email protected]:4000/v2/ \
response_v2_mainnet=$(curl http://localhost:4000/v2/ \
--write-out '%{http_code}' --silent --output /dev/null)

if [ "$response_v2_mainnet" -ne 200 ]; then
Expand All @@ -84,22 +86,49 @@ if [ "$response_v2_mainnet" -ne 200 ]; then
fi

# check running info with API v2 testnet
response_v2_testnet=$(curl http://api:[email protected]:14000/v2/ \
response_v2_testnet=$(curl http://localhost:14000/v2/ \
--write-out '%{http_code}' --silent --output /dev/null)

if [ "$response_v2_mainnet" -ne 200 ]; then
echo "Failed to get API v2 root mainnet"
exit 1
fi

# Let's reparse 50 blocks before Dredd and compare hashes tests
CURRENT_HEIGHT=$(curl http://localhost:4000/v2/ --silent | jq '.result.counterparty_height')
REPARSE_FROM=$(($CURRENT_HEIGHT-50))

# Stop, reparse and start counterparty-core mainnet
docker compose --profile mainnet stop counterparty-core
docker compose --profile mainnet run counterparty-core reparse $REPARSE_FROM \
--backend-connect=bitcoind \
--indexd-connect=addrindexrs \
--rpc-host=0.0.0.0 \
--api-host=0.0.0.0
docker compose --profile mainnet up -d counterparty-core

# wait for counterparty-core to be ready
while [ "$(docker compose logs counterparty-core 2>&1 | grep 'Catch up complete.')" = "" ]; do
echo "Waiting for counterparty-core mainnet to be ready"
sleep 1
done

# Run dredd test
dredd

previous_counterparty_rs_hash=$(cat ../counterparty_rs_hash)
current_counterparty_rs_hash=$(find counterparty-rs/ -type f -print0 | sort -z | xargs -0 sha1sum | sha1sum | awk '{print $1}')


# Run compare hashes test
. "$HOME/.profile"
cd counterparty-core
hatch env prune

if [ "$COUNTERPARTY_RS_CACHED" != "CACHED" ]; then
echo $current_counterparty_rs_hash > ../counterparty_rs_hash
hatch env prune
fi

hatch run pytest counterpartycore/test/compare_hashes_test.py --comparehashes
cd ..

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker Compose

on:
push:
branches: ['develop', 'master', "compose"]
branches: ['develop', 'master', 'compose']

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target/
typings/
pyrightconfig.json
.DS_Store
test_dbs/

profile.txt

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

FROM ubuntu:22.04

RUN apt-get update
RUN apt update
# install dependencies
RUN apt-get install -y python3 python3-dev python3-pip libleveldb-dev curl gnupg
RUN apt install -y python3 python3-dev python3-pip libleveldb-dev curl gnupg libclang-dev

# install rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
Expand Down
Loading

0 comments on commit 0319293

Please sign in to comment.