Skip to content

Release v0.59.0 #961

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

Merged
merged 53 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4bfa5c5
Merge branch 'release' into master
jansegre Dec 27, 2023
0040f51
chore(feature-activation): improve phased testing logs (#905)
glevco Dec 27, 2023
c0364ba
fix(reactor): fix reactor initialization on CLI tools (#906)
glevco Dec 28, 2023
126bae3
fix(events): fix events simulator CLI (#907)
glevco Dec 29, 2023
abbd054
tests(p2p): improve protocol test (#918)
glevco Jan 8, 2024
109ffc7
tests(event): fix missing hash update
jansegre Jan 10, 2024
9b1bbcc
Merge pull request #921 from HathorNetwork/tests/fix-missing-hash-update
jansegre Jan 11, 2024
2410024
feat(debug): make it possible to connect a remote ipython shell
jansegre Jan 8, 2024
6c95fad
Merge pull request #900 from HathorNetwork/feat/shell-ipykernel
jansegre Jan 15, 2024
8e579c4
chore: add support for Python 3.12
jansegre Oct 30, 2023
0ea7abb
Merge pull request #844 from HathorNetwork/chore/python-3.12
jansegre Jan 15, 2024
1b2b955
feat(feature-activation): decrease mainnet evaluation interval to 1 week
glevco Dec 21, 2023
6448f56
Merge pull request #903 from HathorNetwork/feat/feature-activation/de…
jansegre Jan 16, 2024
9cf7d79
tests: fix CI regression on Windows + Python 3.10
jansegre Jan 16, 2024
f5ef856
Merge pull request #926 from HathorNetwork/tests/fix-recursion-limit-…
jansegre Jan 16, 2024
7e8ec09
refactor(settings): rename get_settings to get_global_settings (#919)
glevco Jan 16, 2024
eaf76bd
refactor(settings): remove some calls to HathorSettings (#920)
glevco Jan 17, 2024
8725d21
fix(p2p): fix update whitelist handler (#885)
glevco Jan 18, 2024
6a43a05
feat(feature-activation): configure NOP features on mainnet (#908)
glevco Jan 19, 2024
ded4c79
feat(feature-activation): update NOP features config on mainnet (#929)
glevco Jan 19, 2024
a653335
refactor(feature-activation): remove enable_usage (#909)
glevco Jan 19, 2024
9d042eb
refactor(storage): create StorageProtocol (#922)
glevco Jan 19, 2024
0ddab4f
chore: bump version to v0.59.0
jansegre Jan 23, 2024
8cc0f3f
Merge pull request #934 from HathorNetwork/chore/v0.59.0
jansegre Jan 26, 2024
2be371f
fix(feature-activation): fix get ancestor (#930)
glevco Jan 26, 2024
f651e2a
refactor(settings): remove some more calls to HathorSettings (#923)
glevco Jan 26, 2024
b6748ee
fix(feature-activation): add missing metadata migration (#927)
glevco Jan 29, 2024
94d29e3
chore(feature-activation): phased testing adjustments (#931)
glevco Jan 30, 2024
a9a643d
feat(merged-mining): configure new max merkle path length on testnet
glevco Jan 5, 2024
d01aecc
Merge pull request #910 from HathorNetwork/feat/new-max-merkle-path-l…
jansegre Jan 30, 2024
94696f2
feat(cli): mark sync-v2 parameters as safe and deprecate --x-* ones
jansegre Jan 26, 2024
a8b7357
Merge pull request #935 from HathorNetwork/feat/cli-mark-sync-v2-safe
jansegre Jan 30, 2024
f26bd2c
Merge pull request #937 from HathorNetwork/master
jansegre Jan 30, 2024
0f5ff70
chore(deps): Upgrade hathorlib to v0.5.2
msbrogli Feb 6, 2024
8b13de7
fix: health endpoint when using --x-asyncio-reactor (#940)
luislhl Feb 8, 2024
6e4bfff
feat(sync-v2): Improve logging when unexpected TRANSACTIONS-END or BL…
msbrogli Feb 8, 2024
08f1bd4
refactor(cli): improve handling of sync version from arguments
jansegre Feb 8, 2024
d267f62
Merge pull request #943 from HathorNetwork/chore/make-sync-v2-default
jansegre Feb 8, 2024
3ce172f
feat(sync-v2): Add mempool sync status
msbrogli Feb 8, 2024
a7cf1ba
feat(cli): Add feature flag and CLI parameters for Nano Contracts
msbrogli Mar 1, 2023
f4d6a28
feat(sysctl): Add p2p.kill_connection to sysctl
msbrogli Feb 9, 2024
1f68ec7
feat(sysctl): Add core module with profiler commands to sysctl
msbrogli Feb 9, 2024
b33f03e
feat(cli): Use SIGUSR2 to run sysctl commands
msbrogli Feb 9, 2024
d885d7f
fix: test broke after #951
jansegre Feb 15, 2024
2d51d03
Merge pull request #953 from HathorNetwork/fix/sysctl-profiler-test
jansegre Feb 15, 2024
00967a7
fix(cli): Fix issue when running sysctl through USR2 in macOS
msbrogli Feb 16, 2024
7876fa5
feat(sysctl): Add sysctl tools for debugging
msbrogli Feb 14, 2024
cc3129a
Merge pull request #954 from HathorNetwork/master
jansegre Feb 20, 2024
d5ed0fa
feat(feature-activation): configure new NOP features on mainnet (#958)
glevco Feb 22, 2024
20476d1
fix: Fix slow tx processing on some edge cases
msbrogli Feb 21, 2024
d3f2993
chore(cli): make sync-bridge the default
jansegre Feb 22, 2024
da4a89c
Merge pull request #959 from HathorNetwork/chore/default-to-sync-bridge
jansegre Feb 23, 2024
f46f0be
Merge pull request #960 from HathorNetwork/master
jansegre Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ jobs:
matrix:
python-impl:
- python
- pypy
python-version:
- '3.10'
- '3.11'
exclude:
# XXX: pypy-3.11 does exist yet
- '3.12'
include:
- python-impl: pypy
python-version: '3.11'
python-version: '3.10'
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
import os
import json
full_matrix = {
'python': ['3.10', '3.11'],
'python': ['3.10', '3.11', '3.12'],
# available OS's: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
'os': ['ubuntu-22.04', 'macos-12', 'windows-2022'],
'include': [
Expand All @@ -33,7 +33,7 @@ jobs:
}
# this is the fastest one:
reduced_matrix = {
'python': ['3.11'],
'python': ['3.12'],
'os': ['ubuntu-22.04'],
}
github_repository = os.environ['GITHUB_REPOSITORY']
Expand Down
4 changes: 2 additions & 2 deletions hathor/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from structlog import get_logger

from hathor.checkpoint import Checkpoint
from hathor.conf.get_settings import get_settings
from hathor.conf.get_settings import get_global_settings
from hathor.conf.settings import HathorSettings as HathorSettingsType
from hathor.consensus import ConsensusAlgorithm
from hathor.daa import DifficultyAdjustmentAlgorithm
Expand Down Expand Up @@ -285,7 +285,7 @@ def set_peer_id(self, peer_id: PeerId) -> 'Builder':
def _get_or_create_settings(self) -> HathorSettingsType:
"""Return the HathorSettings instance set on this builder, or a new one if not set."""
if self._settings is None:
self._settings = get_settings()
self._settings = get_global_settings()
return self._settings

def _get_reactor(self) -> Reactor:
Expand Down
65 changes: 61 additions & 4 deletions hathor/builder/cli_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import platform
import sys
from enum import Enum, auto
from typing import Any, Optional

from structlog import get_logger
Expand Down Expand Up @@ -45,6 +46,12 @@
logger = get_logger()


class SyncChoice(Enum):
V1_ONLY = auto()
V2_ONLY = auto()
BRIDGE = auto()


class CliBuilder:
"""CliBuilder builds the core objects from args.

Expand All @@ -61,7 +68,7 @@ def check_or_raise(self, condition: bool, message: str) -> None:

def create_manager(self, reactor: Reactor) -> HathorManager:
import hathor
from hathor.conf.get_settings import get_settings, get_settings_source
from hathor.conf.get_settings import get_global_settings, get_settings_source
from hathor.daa import TestMode
from hathor.event.storage import EventMemoryStorage, EventRocksDBStorage, EventStorage
from hathor.event.websocket.factory import EventWebsocketFactory
Expand All @@ -79,7 +86,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
)
from hathor.util import get_environment_info

settings = get_settings()
settings = get_global_settings()

# only used for logging its location
settings_source = get_settings_source()
Expand All @@ -103,6 +110,12 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
reactor_type=type(reactor).__name__,
)

# XXX Remove this protection after Nano Contracts are launched.
if settings.NETWORK_NAME not in {'nano-testnet-alpha', 'unittests'}:
# Add protection to prevent enabling Nano Contracts due to misconfigurations.
self.check_or_raise(not settings.ENABLE_NANO_CONTRACTS,
'configuration error: NanoContracts can only be enabled on localnets for now')

tx_storage: TransactionStorage
event_storage: EventStorage
indexes: IndexesManager
Expand Down Expand Up @@ -158,8 +171,36 @@ def create_manager(self, reactor: Reactor) -> HathorManager:

hostname = self.get_hostname()
network = settings.NETWORK_NAME
enable_sync_v1 = not self._args.x_sync_v2_only
enable_sync_v2 = self._args.x_sync_v2_only or self._args.x_sync_bridge

sync_choice: SyncChoice
if self._args.sync_bridge:
self.log.warn('--sync-bridge is the default, this parameter has no effect')
sync_choice = SyncChoice.BRIDGE
elif self._args.sync_v1_only:
sync_choice = SyncChoice.V1_ONLY
elif self._args.sync_v2_only:
sync_choice = SyncChoice.V2_ONLY
elif self._args.x_sync_bridge:
self.log.warn('--x-sync-bridge is deprecated and will be removed, use --sync-bridge instead')
sync_choice = SyncChoice.BRIDGE
elif self._args.x_sync_v2_only:
self.log.warn('--x-sync-v2-only is deprecated and will be removed, use --sync-v2-only instead')
sync_choice = SyncChoice.V2_ONLY
else:
sync_choice = SyncChoice.BRIDGE

enable_sync_v1: bool
enable_sync_v2: bool
match sync_choice:
case SyncChoice.V1_ONLY:
enable_sync_v1 = True
enable_sync_v2 = False
case SyncChoice.V2_ONLY:
enable_sync_v1 = False
enable_sync_v2 = True
case SyncChoice.BRIDGE:
enable_sync_v1 = True
enable_sync_v2 = True

pubsub = PubSubManager(reactor)

Expand Down Expand Up @@ -270,6 +311,11 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
cpu_mining_service=cpu_mining_service
)

if self._args.x_ipython_kernel:
self.check_or_raise(self._args.x_asyncio_reactor,
'--x-ipython-kernel must be used with --x-asyncio-reactor')
self._start_ipykernel()

p2p_manager.set_manager(self.manager)

if self._args.stratum:
Expand Down Expand Up @@ -376,3 +422,14 @@ def create_wallet(self) -> BaseWallet:
return wallet
else:
raise BuilderError('Invalid type of wallet')

def _start_ipykernel(self) -> None:
# breakpoints are not expected to be used with the embeded ipykernel, to prevent this warning from being
# unnecessarily annoying, PYDEVD_DISABLE_FILE_VALIDATION should be set to 1 before debugpy is imported, or in
# practice, before importing hathor.ipykernel, if for any reason support for breakpoints is needed, the flag
# -Xfrozen_modules=off has to be passed to the python interpreter
# see:
# https://github.com/microsoft/debugpy/blob/main/src/debugpy/_vendored/pydevd/pydevd_file_utils.py#L587-L592
os.environ['PYDEVD_DISABLE_FILE_VALIDATION'] = '1'
from hathor.ipykernel import embed_kernel
embed_kernel(self.manager, runtime_dir=self._args.data, extra_ns=dict(run_node=self))
4 changes: 2 additions & 2 deletions hathor/builder/resources_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create_prometheus(self) -> PrometheusMetricsExporter:
return prometheus

def create_resources(self) -> server.Site:
from hathor.conf.get_settings import get_settings
from hathor.conf.get_settings import get_global_settings
from hathor.debug_resources import (
DebugCrashResource,
DebugLogResource,
Expand Down Expand Up @@ -142,7 +142,7 @@ def create_resources(self) -> server.Site:
)
from hathor.websocket import HathorAdminWebsocketFactory, WebsocketStatsResource

settings = get_settings()
settings = get_global_settings()
cpu = get_cpu_profiler()

# TODO get this from a file. How should we do with the factory?
Expand Down
3 changes: 2 additions & 1 deletion hathor/builder/sysctl_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from hathor.builder import BuildArtifacts
from hathor.sysctl import ConnectionsManagerSysctl, Sysctl, WebsocketManagerSysctl
from hathor.sysctl import ConnectionsManagerSysctl, HathorManagerSysctl, Sysctl, WebsocketManagerSysctl


class SysctlBuilder:
Expand All @@ -25,6 +25,7 @@ def __init__(self, artifacts: BuildArtifacts) -> None:
def build(self) -> Sysctl:
"""Build the sysctl tree."""
root = Sysctl()
root.put_child('core', HathorManagerSysctl(self.artifacts.manager))
root.put_child('p2p', ConnectionsManagerSysctl(self.artifacts.p2p_manager))

ws_factory = self.artifacts.manager.metrics.websocket_factory
Expand Down
8 changes: 4 additions & 4 deletions hathor/cli/db_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def register_signal_handlers(self) -> None:

@classmethod
def create_parser(cls) -> ArgumentParser:
from hathor.conf.get_settings import get_settings
settings = get_settings()
from hathor.conf.get_settings import get_global_settings
settings = get_global_settings()

def max_height(arg: str) -> Optional[int]:
if arg.lower() == 'checkpoint':
Expand Down Expand Up @@ -80,8 +80,8 @@ def prepare(self, *, register_resources: bool = True) -> None:
self.skip_voided = self._args.export_skip_voided

def iter_tx(self) -> Iterator['BaseTransaction']:
from hathor.conf.get_settings import get_settings
settings = get_settings()
from hathor.conf.get_settings import get_global_settings
settings = get_global_settings()
soft_voided_ids = set(settings.SOFT_VOIDED_TX_IDS)

for tx in self._iter_tx:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, simulator: 'Simulator', *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)

def buildProtocol(self, _: IAddress) -> 'EventForwardingWebsocketProtocol':
from hathor.cli.events_simulator.event_forwarding_websocket_protocol import EventForwardingWebsocketProtocol
protocol = EventForwardingWebsocketProtocol(self._simulator)
protocol.factory = self
return protocol
12 changes: 8 additions & 4 deletions hathor/cli/events_simulator/events_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

import os
from argparse import ArgumentParser, Namespace
from typing import TYPE_CHECKING

from autobahn.twisted.resource import WebSocketResource
from structlog import get_logger
from twisted.web.resource import Resource
from twisted.web.server import Site

if TYPE_CHECKING:
from hathor.reactor import ReactorProtocol

DEFAULT_PORT = 8080

logger = get_logger()
Expand All @@ -39,12 +43,11 @@ def create_parser() -> ArgumentParser:
return parser


def execute(args: Namespace) -> None:
def execute(args: Namespace, reactor: 'ReactorProtocol') -> None:
from hathor.conf import UNITTESTS_SETTINGS_FILEPATH
os.environ['HATHOR_CONFIG_YAML'] = UNITTESTS_SETTINGS_FILEPATH
from hathor.cli.events_simulator.event_forwarding_websocket_factory import EventForwardingWebsocketFactory
from hathor.cli.events_simulator.scenario import Scenario
from hathor.reactor import get_global_reactor
from hathor.simulator import Simulator

try:
Expand All @@ -53,7 +56,6 @@ def execute(args: Namespace) -> None:
possible_scenarios = [scenario.name for scenario in Scenario]
raise ValueError(f'Invalid scenario "{args.scenario}". Choose one of {possible_scenarios}') from e

reactor = get_global_reactor()
log = logger.new()
simulator = Simulator(args.seed)
simulator.start()
Expand Down Expand Up @@ -90,6 +92,8 @@ def execute(args: Namespace) -> None:


def main():
from hathor.reactor import initialize_global_reactor
parser = create_parser()
args = parser.parse_args()
execute(args)
reactor = initialize_global_reactor()
execute(args, reactor)
9 changes: 5 additions & 4 deletions hathor/cli/events_simulator/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def simulate_single_chain_one_block(simulator: 'Simulator', manager: 'HathorMana


def simulate_single_chain_blocks_and_transactions(simulator: 'Simulator', manager: 'HathorManager') -> None:
from hathor.conf.get_settings import get_settings
from hathor.conf.get_settings import get_global_settings
from hathor.simulator.utils import add_new_blocks, gen_new_tx

settings = get_settings()
settings = get_global_settings()
assert manager.wallet is not None
address = manager.wallet.get_unused_address(mark_as_used=False)

Expand Down Expand Up @@ -97,11 +97,11 @@ def simulate_reorg(simulator: 'Simulator', manager: 'HathorManager') -> None:


def simulate_unvoided_transaction(simulator: 'Simulator', manager: 'HathorManager') -> None:
from hathor.conf.get_settings import get_settings
from hathor.conf.get_settings import get_global_settings
from hathor.simulator.utils import add_new_block, add_new_blocks, gen_new_tx
from hathor.util import not_none

settings = get_settings()
settings = get_global_settings()
assert manager.wallet is not None
address = manager.wallet.get_unused_address(mark_as_used=False)

Expand Down Expand Up @@ -134,6 +134,7 @@ def simulate_unvoided_transaction(simulator: 'Simulator', manager: 'HathorManage
settings.GENESIS_TX1_HASH,
not_none(tx2.hash),
]
block.update_hash()
assert manager.propagate_tx(block, fails_silently=False)
simulator.run(60)

Expand Down
8 changes: 5 additions & 3 deletions hathor/cli/mining.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ def execute(args: Namespace) -> None:
block.nonce, block.weight))

try:
from hathor.conf.get_settings import get_settings
from unittest.mock import Mock

from hathor.conf.get_settings import get_global_settings
from hathor.daa import DifficultyAdjustmentAlgorithm
from hathor.verification.verification_service import VerificationService, VertexVerifiers
settings = get_settings()
settings = get_global_settings()
daa = DifficultyAdjustmentAlgorithm(settings=settings)
verifiers = VertexVerifiers.create_defaults(settings=settings, daa=daa)
verifiers = VertexVerifiers.create_defaults(settings=settings, daa=daa, feature_service=Mock())
verification_service = VerificationService(verifiers=verifiers)
verification_service.verify_without_storage(block)
except HathorError:
Expand Down
4 changes: 2 additions & 2 deletions hathor/cli/nginx_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def generate_nginx_config(openapi: dict[str, Any], *, out_file: TextIO, rate_k:
"""
from datetime import datetime

from hathor.conf.get_settings import get_settings
from hathor.conf.get_settings import get_global_settings

settings = get_settings()
settings = get_global_settings()
api_prefix = settings.API_VERSION_PREFIX

locations: dict[str, dict[str, Any]] = {}
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.58.0"
"version": "0.59.0"
},
"consumes": [
"application/json"
Expand Down
Loading