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

Merge main into dev branch 1 #5

Merged
merged 10 commits into from
Aug 22, 2024
105 changes: 0 additions & 105 deletions .circleci/config.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: ci

on:
pull_request:
branches:
- '**'

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.2.0
with:
run-unit-tests: true
run-integration-tests: false
run-lint: true

docker_pipeline:
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.2.0
secrets: inherit
with:
publish: false
dockerfile: ./contrib/images/staking-expiry-checker/Dockerfile
25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: docker_publish

on:
push:
branches:
- 'main'
- 'dev'
tags:
- '*'

jobs:
lint_test:
uses: babylonlabs-io/.github/.github/workflows/reusable_go_lint_test.yml@v0.2.0
with:
run-unit-tests: true
run-integration-tests: false
run-lint: true

docker_pipeline:
needs: ["lint_test"]
uses: babylonlabs-io/.github/.github/workflows/reusable_docker_pipeline.yml@v0.2.0
secrets: inherit
with:
publish: true
dockerfile: ./contrib/images/staking-expiry-checker/Dockerfile
86 changes: 78 additions & 8 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,84 @@ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.

Parameters

Licensor: Babylonchain, Inc.

Licensed Work: staking-expiry-checker
The Licensed Work is (c) 2024 Babylonchain, Inc.

Additional Use Grant: None.

Change Date: 2027-05-15 (March 15th, 2027]
Licensor: Babylon Labs Ltd.

Licensed Work: Staking Expiry Checker
The Licensed Work is (c) 2024 Babylon Labs, Ltd.

Additional Use Grant:

In addition to the uses permitted under the non-production license below,
we grant you a limited, non-exclusive, non-transferable, non-sublicensable,
revocable license, limited as set forth below, to use the Licensed Work
in this repository for production commercial uses built on or using and integrated
with the Babylon Protocol, not including Competing Uses.

Any use beyond the scope of this license, including uses that are not built on or
using and integrated with the Babylon Protocol, or are Competing Uses,
will terminate this license to you, automatically and without notice.

This License applies separately and solely to the specific versions of the Licensed Work
in the specified repository on or before the date of this License, and we may require a
different license and different provisions for each subsequent version of the
Licensed Work released by us.

"Babylon Labs", "we", "our", or "us" means Babylon Labs Ltd.

"Babylon Protocol" means the Bitcoin staking protocol as further described in the documentation
here (https://docs.babylonlabs.io/docs/introduction/babylon-overview), as updated from time to time.

"Competing Use" means any use of the Licensed Work in any product, software, protocol, network,
application, or service that is made available to any party and that
(i) substitutes for the use of the Babylon Protocol,
(ii) offers the same or substantially similar functionality as the Babylon Protocol or
(iii) is built on or uses a protocol with substantially similar functionality as the Babylon Protocol
or otherwise facilitates the staking of bitcoin other than by utilizing the Babylon Protocol.

The provisions in this License apply to each individual, entity, group, or association
(each and collectively, "you" or "your") who uses the Licensed Work for production,
and you agree to such provisions. Your production use of the Licensed Work is conditional on your
agreement to this License. If you do not agree and consent to be bound to this License,
do not so use the Software.

If you do not fall within the limited scope of this license as described above or below,
or are otherwise not in strict compliance with this License, then this production license does not
extend to you and does not grant you any production use, including any copying, distributing, or
making any derivative use of the Licensed Work for production purposes.

Limited Scope of License. Your commercial production license to the Licensed Work
under this License does not extend to any use:

1. unless you have legal capacity to consent and agree to be bound by this License;
2. unless you have the technical knowledge necessary or advisable to understand and evaluate the
risks of using the Licensed Work and the Babylon Protocol;
3. if you are a resident or agent of, or an entity organized, incorporated or doing business in,
Afghanistan, Belarus, Bosnia and Herzegovina, Burundi, Central African Republic, Crimea, Cuba,
Democratic People's Republic of Korea, Democratic Republic of the Congo,
Donetsk or Luhansk Regions of Ukraine, Eritrea, Guinea, Guinea-Bissau, Haiti, Iran, Iraq, Lebanon,
Libya, Mali, Myanmar, Nicaragua, Russia, Somalia, South Sudan, Sudan, Syria, Venezuela, Yemen,
or Zimbabwe or any other country to which the United States, the United Kingdom,
the European Union or any of its member states or the United Nations or any of its member states
(collectively, the "Major Jurisdictions") embargoes goods or imposes sanctions
(such embargoed or sanctioned territories, collectively, the "Restricted Territories");
4. if you are, or if you directly or indirectly own or control, from any person or entity that is
listed on any sanctions list or equivalent maintained by any of the Major Jurisdictions
(collectively, "Sanctions Lists Persons");
5. to transact in or with any Restricted Territories or Sanctions List Persons;
6. if you are a U.S. Person as defined in 17 CFR § 230.902, or currently or ordinarily located or
resident in (or incorporated or organized in) the United States of America, Canada, or
Australia (collectively, "Excluded Jurisdictions"), or to transact in or with Excluded Jurisdictions;
7. to defraud, or otherwise materially mislead, any person;
8. in violation of applicable laws, rules or regulations in your relevant jurisdiction;
9. that circumvents any sanctions or export controls targeting you or the country or territory where
you are located; or
10. in any activity that transmits, exchanges, or is otherwise supported by the direct or indirect
proceeds of criminal or fraudulent activity.

Any production use of the Licensed Work by you confirms your agreement to the foregoing limitations,
and your understanding and agreement that they are limitations and not restrictions.

Change Date: 2027-03-15 (March 15th, 2027)

Change License: Apache 2.0

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ build-docker:
$(MAKE) BBN_PRIV_DEPLOY_KEY=${BBN_PRIV_DEPLOY_KEY} -C contrib/images staking-expiry-checker

start-staking-expiry-checker: build-docker stop-service
docker-compose up -d
docker compose up -d

stop-service:
docker-compose down
docker compose down

run-local:
./bin/local-startup.sh;
Expand All @@ -46,6 +46,6 @@ generate-mock-interface:
cd internal/db && mockery --name=DbInterface --output=../../tests/mocks --outpkg=mocks --filename=mock_db_client.go
cd internal/btcclient && mockery --name=BtcInterface --output=../../tests/mocks --outpkg=mocks --filename=mock_btc_client.go

tests:
test:
./bin/local-startup.sh;
go test -v -cover ./...
6 changes: 4 additions & 2 deletions bin/local-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ $(docker ps -q -f name=^/${MONGO_CONTAINER_NAME}$) ]; then
else
echo "Starting MongoDB"
# Start MongoDB
docker-compose up mongodb -d
docker compose up -d mongodb
fi

# Check if the RabbitMQ container is already running
Expand All @@ -17,5 +17,7 @@ if [ $(docker ps -q -f name=^/${RABBITMQ_CONTAINER_NAME}$) ]; then
else
echo "Starting RabbitMQ"
# Start RabbitMQ
docker-compose up rabbitmq -d
docker compose up -d rabbitmq
# Wait for RabbitMQ to start
sleep 10
fi
16 changes: 8 additions & 8 deletions cmd/staking-expiry-checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"github.com/joho/godotenv"
"github.com/rs/zerolog/log"

"github.com/babylonchain/staking-expiry-checker/cmd/staking-expiry-checker/cli"
"github.com/babylonchain/staking-expiry-checker/internal/btcclient"
"github.com/babylonchain/staking-expiry-checker/internal/config"
"github.com/babylonchain/staking-expiry-checker/internal/db"
"github.com/babylonchain/staking-expiry-checker/internal/observability/metrics"
"github.com/babylonchain/staking-expiry-checker/internal/poller"
"github.com/babylonchain/staking-expiry-checker/internal/queue"
"github.com/babylonchain/staking-expiry-checker/internal/services"
"github.com/babylonlabs-io/staking-expiry-checker/cmd/staking-expiry-checker/cli"
"github.com/babylonlabs-io/staking-expiry-checker/internal/btcclient"
"github.com/babylonlabs-io/staking-expiry-checker/internal/config"
"github.com/babylonlabs-io/staking-expiry-checker/internal/db"
"github.com/babylonlabs-io/staking-expiry-checker/internal/observability/metrics"
"github.com/babylonlabs-io/staking-expiry-checker/internal/poller"
"github.com/babylonlabs-io/staking-expiry-checker/internal/queue"
"github.com/babylonlabs-io/staking-expiry-checker/internal/services"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions config/config-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ btc:
rpc-user: rpcuser
rpc-pass: rpcpass
queue:
queue_user: guest # can be replaced by values in .env file
queue_password: guest
queue_user: user # can be replaced by values in .env file
queue_password: password
url: "localhost:5672"
processing_timeout: 5 # 5 second
msg_max_retry_attempts: 10
Expand Down
4 changes: 2 additions & 2 deletions config/config-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ btc:
rpc-user: rpcuser
rpc-pass: rpcpass
queue:
queue_user: guest # can be replaced by values in .env file
queue_password: guest
queue_user: user # can be replaced by values in .env file
queue_password: password
url: "localhost:5672"
processing_timeout: 5 # 5 second
msg_max_retry_attempts: 3
Expand Down
4 changes: 2 additions & 2 deletions contrib/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ DOCKER = $(shell which docker)
.PHONY: staking-expiry-checker staking-expiry-checker-rmi

staking-expiry-checker:
$(DOCKER) build --tag babylonchain/staking-expiry-checker -f staking-expiry-checker/Dockerfile \
$(DOCKER) build --tag babylonlabs-io/staking-expiry-checker -f staking-expiry-checker/Dockerfile \
$(shell git rev-parse --show-toplevel)

staking-expiry-checker-rmi:
$(DOCKER) rmi babylonchain/staking-expiry-checker 2>/dev/null; true
$(DOCKER) rmi babylonlabs-io/staking-expiry-checker 2>/dev/null; true
12 changes: 6 additions & 6 deletions contrib/images/staking-expiry-checker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
openssh

# Build
WORKDIR /go/src/github.com/babylonchain/staking-expiry-checker
WORKDIR /go/src/github.com/babylonlabs-io/staking-expiry-checker
# Cache dependencies
COPY go.mod go.sum /go/src/github.com/babylonchain/staking-expiry-checker/
COPY go.mod go.sum /go/src/github.com/babylonlabs-io/staking-expiry-checker/

# Copy the rest of the files
COPY ./ /go/src/github.com/babylonchain/staking-expiry-checker/
COPY ./ /go/src/github.com/babylonlabs-io/staking-expiry-checker/


RUN LDFLAGS='-extldflags "-static" -v' \
Expand All @@ -31,18 +31,18 @@
make build

# Final minimal image with binary only
FROM alpine:3.16 as run

Check warning on line 34 in contrib/images/staking-expiry-checker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 34 in contrib/images/staking-expiry-checker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 34 in contrib/images/staking-expiry-checker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

RUN addgroup --gid 1138 -S staking-expiry-checker && adduser --uid 1138 -S staking-expiry-checker -G staking-expiry-checker
RUN apk add bash curl jq

# Label should match your github repo
LABEL org.opencontainers.image.source="https://github.com/babylonchain/staking-expiry-checker:${VERSION}"
LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/staking-expiry-checker:${VERSION}"

Check warning on line 40 in contrib/images/staking-expiry-checker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 40 in contrib/images/staking-expiry-checker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 40 in contrib/images/staking-expiry-checker/Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$VERSION' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/


# Copy over binaries from the build-env
COPY --from=builder /go/src/github.com/babylonchain/staking-expiry-checker/build/staking-expiry-checker /bin/staking-expiry-checker
COPY --from=builder /go/src/github.com/babylonchain/staking-expiry-checker/contrib/images/staking-expiry-checker/entrypoint.sh /bin/entrypoint.sh
COPY --from=builder /go/src/github.com/babylonlabs-io/staking-expiry-checker/build/staking-expiry-checker /bin/staking-expiry-checker
COPY --from=builder /go/src/github.com/babylonlabs-io/staking-expiry-checker/contrib/images/staking-expiry-checker/entrypoint.sh /bin/entrypoint.sh

WORKDIR /home/staking-expiry-checker
RUN chown -R staking-expiry-checker /home/staking-expiry-checker
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"
services:
staking-expiry-checker:
image: babylonchain/staking-expiry-checker:latest
image: babylonlabs/staking-expiry-checker:latest
container_name: staking-expiry-checker
environment:
- CONFIG=/home/staking-expiry-checker/config.yml
Expand Down Expand Up @@ -29,7 +29,7 @@ services:
- "5672:5672" # AMQP protocol port
- "15672:15672" # Management UI port
environment:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
RABBITMQ_DEFAULT_USER: user
RABBITMQ_DEFAULT_PASS: password
volumes:
- "./rabbitmq_data:/var/lib/rabbitmq"
Loading