Skip to content

Commit

Permalink
Merge pull request #346 from HathorNetwork/dev
Browse files Browse the repository at this point in the history
Release v0.46.0
  • Loading branch information
jansegre authored Dec 14, 2021
2 parents befc4d9 + c6f6dc1 commit 9fe53b5
Show file tree
Hide file tree
Showing 31 changed files with 504 additions and 1,353 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,10 @@ jobs:
run: pip -q --no-input install poetry
- name: Install Poetry dependencies
run: poetry install -n --no-root
- name: Generate protobuf files
run: poetry run make protos
- name: Build source package
run: |
rm hathor/protos/.gitignore
poetry build -f wheel
run: poetry build -f wheel
- name: Generate requirements
run: |
poetry remove -D grpcio-tools --dry-run # workaround for Poetry bug
poetry export -o requirements.txt -E rocksdb -E sentry
run: poetry export -o requirements.txt -E rocksdb -E sentry
- name: Cache Docker layers
uses: actions/cache@v2
with:
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@ jobs:
test:
name: python-${{ matrix.python }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 60 # default is 360
timeout-minutes: 120 # default is 360
strategy:
fail-fast: false
matrix:
python:
- 3.6
- 3.7
- 3.8
- 3.9
os:
- ubuntu-latest
- macos-latest
include:
- os: windows-latest
python: 3.6
- os: windows-latest
python: 3.7
# these still have some errors:
Expand Down Expand Up @@ -56,8 +53,6 @@ jobs:
- name: Install Poetry dependencies (without rocksdb)
if: matrix.os == 'windows-latest'
run: poetry install -n --no-root
- name: Compile protos
run: poetry run make protos
- name: Cache mypy
uses: actions/cache@v2
with:
Expand Down
22 changes: 1 addition & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,14 @@ ENV POETRY_VIRTUALENVS_IN_PROJECT=true
COPY pyproject.toml poetry.lock ./
RUN poetry install -n -E rocksdb -E sentry --no-root --no-dev

# stage-1: install all dev dependencies and build protos, reuse .venv from stage-0
FROM python:$PYTHON-alpine$ALPINE as stage-1
ARG PYTHON
WORKDIR /usr/src/app/
RUN apk add --no-cache openssl libffi graphviz
RUN apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb
RUN apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb-dev
RUN apk add openssl-dev libffi-dev build-base rust cargo
RUN pip --no-input --no-cache-dir install --upgrade pip poetry
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
COPY pyproject.toml poetry.lock ./
RUN poetry install -n -E rocksdb -E sentry --no-root --no-dev
# up to the line above is be the same as in stage-0, and thus all layers are re-used
RUN poetry install -n -E rocksdb -E sentry --no-root
COPY Makefile ./
COPY hathor/protos ./hathor/protos/
RUN make clean-protos
RUN poetry run make protos

# finally: use production .venv (from stage-0) and compiled protos (from stage-1)
# stage-1: use production .venv (from stage-0)
# lean and mean: this image should be about ~110MB, would be about ~470MB if using the whole stage-1
FROM python:$PYTHON-alpine$ALPINE
ARG PYTHON
WORKDIR /usr/src/app/
RUN apk add --no-cache openssl libffi graphviz
RUN apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing rocksdb
COPY --from=stage-0 /usr/src/app/.venv/lib/python${PYTHON}/site-packages /usr/local/lib/python${PYTHON}/site-packages
COPY --from=stage-1 /usr/src/app/hathor/protos/*.py /usr/src/app/hathor/protos/
COPY hathor ./hathor
EXPOSE 40403 8080
ENTRYPOINT ["python", "-m", "hathor"]
28 changes: 1 addition & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,6 @@ isort:

# generation:

proto_dir = ./hathor/protos
proto_srcs = $(wildcard $(proto_dir)/*.proto)
proto_srcs_old = $(proto_dir)/transaction_storage.proto
proto_outputs = $(patsubst %.proto,%_pb2.py,$(proto_srcs)) $(patsubst %.proto,%_pb2.pyi,$(proto_srcs))
proto_outputs_old = $(patsubst %.proto,%_pb2_grpc.py,$(proto_srcs) $(proto_srcs_old))
GRPC_TOOLS_VERSION = "$(shell python -m grpc_tools.protoc --version 2>/dev/null || true)"
#ifdef GRPC_TOOLS_VERSION
ifneq ($(GRPC_TOOLS_VERSION),"")
protoc := python -m grpc_tools.protoc
else
protoc := protoc
endif

# all proto_srcs are added as deps so when a change on any of them triggers all to be rebuilt
%_pb2.pyi %_pb2.py: %.proto $(proto_srcs)
$(protoc) -I. --python_out=. --mypy_out=. $<

.PHONY: protos
protos: $(proto_outputs)

# cleaning:

.PHONY: clean-protos
clean-protos:
rm -f $(proto_outputs) $(proto_outputs_old)

.PHONY: clean-pyc
clean-pyc:
find hathor tests -name \*.pyc -delete
Expand All @@ -129,7 +103,7 @@ clean-dist:
rm -f requirements.txt

.PHONY: clean
clean: clean-pyc clean-protos clean-caches clean-dist
clean: clean-pyc clean-caches clean-dist

# building:

Expand Down
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For more information about our HTTP API, check out our [API Documentation](https

## From source-code

First, you need to have Python 3.6 installed. If you don't, we recommend you to install using `pyenv` (check this
First, you need to have Python >=3.7 installed. If you don't, we recommend you to install using `pyenv` (check this
[link](https://github.com/pyenv/pyenv#installation)).

### System dependencies
Expand All @@ -59,11 +59,11 @@ First, you need to have Python 3.6 installed. If you don't, we recommend you to
brew install pyenv
```

then Python 3.6 (you could check the latest 3.6.x version with `pyenv install --list`):
then Python 3.7 (you could check the latest 3.7.x version with `pyenv install --list`):

```
pyenv install 3.6.11
pyenv local 3.6.11
pyenv install 3.7.11
pyenv local 3.7.11
pip install -U poetry
```

Expand All @@ -75,7 +75,7 @@ First, you need to have Python 3.6 installed. If you don't, we recommend you to
- on Windows 10 (using [winget](https://github.com/microsoft/winget-cli)):

```
winget install python-3.6
winget install python-3.7
pip install -U poetry
```

Expand All @@ -98,12 +98,6 @@ poetry install
poetry install -E rocksdb
```

Generate protobuf modules:

```
poetry run make protos
```

### Running the full-node

```
Expand Down
2 changes: 1 addition & 1 deletion hathor/cli/openapi_files/openapi_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"info": {
"title": "Hathor API",
"version": "0.45.0"
"version": "0.46.0"
},
"consumes": [
"application/json"
Expand Down
7 changes: 0 additions & 7 deletions hathor/cli/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def create_parser(self) -> ArgumentParser:
parser.add_argument('--data', help='Data directory')
storage = parser.add_mutually_exclusive_group()
storage.add_argument('--rocksdb-storage', action='store_true', help='Use RocksDB storage backend (default)')
storage.add_argument('--old-rocksdb-storage', action='store_true',
help='Use old RocksDB storage backend (deprecated)')
storage.add_argument('--memory-storage', action='store_true', help='Do not use any storage')
storage.add_argument('--json-storage', action='store_true', help='Use legacy JSON storage (not recommended)')
parser.add_argument('--rocksdb-cache', type=int, help='RocksDB block-table cache size (bytes)', default=None)
Expand Down Expand Up @@ -115,7 +113,6 @@ def prepare(self, args: Namespace) -> None:
TransactionCacheStorage,
TransactionCompactStorage,
TransactionMemoryStorage,
TransactionOldRocksDBStorage,
TransactionRocksDBStorage,
TransactionStorage,
)
Expand Down Expand Up @@ -202,10 +199,6 @@ def create_wallet():
elif args.json_storage:
check_or_exit(args.data, '--data is expected')
tx_storage = TransactionCompactStorage(path=args.data, with_index=(not args.cache))
elif args.old_rocksdb_storage:
check_or_exit(args.data, '--data is expected')
self.log.warn('the old rocksdb storage is deprecated and support will be removed')
tx_storage = TransactionOldRocksDBStorage(path=args.data)
else:
check_or_exit(args.data, '--data is expected')
if args.rocksdb_storage:
Expand Down
2 changes: 2 additions & 0 deletions hathor/conf/mainnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
cp(1_600_000, bytes.fromhex('00000000000000011098dda3dbe2ac95287ec0f3c12edc5c054dd8edc70cd6c3')),
cp(1_700_000, bytes.fromhex('000000000000000054278ce817fda6cd3287144545babf0a415f883d074601ab')),
cp(1_800_000, bytes.fromhex('00000000000000002110c5ccb781bee9fea0a4cbbd49e52023ffb5900732ee4d')),
cp(1_900_000, bytes.fromhex('000000000000000032a8f2411190e1e49ff577d352950011083b85d935453338')),
cp(2_000_000, bytes.fromhex('000000000000000005c31cc418e95497dbb2017a6ae2683a1550bd61f180b5b1')),
],
SOFT_VOIDED_TX_IDS=list(map(bytes.fromhex, [
'0000000012a922a6887497bed9c41e5ed7dc7213cae107db295602168266cd02',
Expand Down
20 changes: 18 additions & 2 deletions hathor/conf/testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from hathor.checkpoint import Checkpoint as cp
from hathor.conf.settings import HathorSettings

SETTINGS = HathorSettings(
P2PKH_VERSION_BYTE=b'\x49',
MULTISIG_VERSION_BYTE=b'\x87',
NETWORK_NAME='testnet-foxtrot',
BOOTSTRAP_DNS=['foxtrot.testnet.hathor.network'],
NETWORK_NAME='testnet-golf',
BOOTSTRAP_DNS=['golf.testnet.hathor.network'],
# Genesis stuff
GENESIS_OUTPUT_SCRIPT=bytes.fromhex('76a914a584cf48b161e4a49223ed220df30037ab740e0088ac'),
GENESIS_TIMESTAMP=1577836800,
Expand All @@ -32,4 +33,19 @@
MIN_TX_WEIGHT_K=0,
MIN_TX_WEIGHT_COEFFICIENT=0,
MIN_TX_WEIGHT=8,
CHECKPOINTS=[
cp(100_000, bytes.fromhex('0000007ece4c7830169f360ed11c51b776e1b72bf0060e6e5b325ca8be474ac5')),
cp(200_000, bytes.fromhex('00000113ecd4b666116abf3d3f05ad509d903d6b456a1e8c35e46a9e426af11a')),
cp(300_000, bytes.fromhex('000000e42df13e4e7490cee98f303cb3b0ca33f362af180c5f7df740c98699d9')),
cp(400_000, bytes.fromhex('000000e9a748b34fc4d662d88bb36ef2a033ba129960924208be14eccdac1a65')),
cp(500_000, bytes.fromhex('000000b5c4572d7b85e585849540ece44b73948c5cdbc6f17a9a3a77fbd0f29a')),
cp(600_000, bytes.fromhex('000000f6743ba3d67e51d7adc21821b8263726ce3bc86010d5e1a905bf2531dc')),
cp(700_000, bytes.fromhex('0000008fda01c9e5fd6f99a5461e6dbf1039cba38cc8d0fc738a097d71caa968')),
cp(800_000, bytes.fromhex('000000397af32fcc4eeb6985d96326c1ff4644792631872a00394688b1782af5')),
cp(900_000, bytes.fromhex('00000097ae405036614f4335ad0e631df8fc5f7434e82c3421627e2fea4e1830')),
cp(1_000_000, bytes.fromhex('000000145ba662cdee0d72034658f93a0a3a4568d5ba5083ff09013ca1e6556c')),
cp(1_100_000, bytes.fromhex('000000404e6ff6a23695a6ffe712ce1c4efc02e75bbc11c3129f4c2377b07743')),
cp(1_200_000, bytes.fromhex('0000003be5fae5bb2c9ceaed589d172bcd9e74ca6c8d7d2ca06567f65cea7c9b')),
cp(1_300_000, bytes.fromhex('0000000000007d39de6e781c377bc202213b0b5b60db14c13d0b16e06d6fd5ac')),
],
)
4 changes: 0 additions & 4 deletions hathor/protos/.gitignore

This file was deleted.

36 changes: 0 additions & 36 deletions hathor/protos/__init__.py

This file was deleted.

98 changes: 0 additions & 98 deletions hathor/protos/transaction.proto

This file was deleted.

Loading

0 comments on commit 9fe53b5

Please sign in to comment.