Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
50deb84
refactor: use Hathor simulator on events simulator CLI
glevco Aug 25, 2023
91b2676
Merge pull request #758 from HathorNetwork/refactor/event-simulator-cli
jansegre Sep 1, 2023
dc1e978
Merge pull request #765 from HathorNetwork/release-candidate
jansegre Sep 5, 2023
f7265f4
Merge branch 'release' into master
jansegre Sep 5, 2023
0f78923
feat(reliable-integration): add decoded outputs in event responses (#…
glevco Sep 11, 2023
db50c74
tests: decrease tests duration
glevco Aug 24, 2023
a847f51
tests: decrease tests duration
glevco Aug 25, 2023
d56924e
Merge pull request #756 from HathorNetwork/tests/decrease_tests_duration
jansegre Sep 11, 2023
2ebb62f
feat(reliable-integration): implement stream ID (#766)
glevco Sep 12, 2023
dbeaa9e
refactor: move get settings [part 1] (#768)
glevco Sep 12, 2023
87ae52e
refactor: move get settings [part 2] (#769)
glevco Sep 19, 2023
3794dd5
refactor: move get settings [part 3] (#770)
glevco Sep 20, 2023
4b34cb4
chore(python): drop support for Python 3.9
glevco Sep 21, 2023
9aad945
Merge pull request #777 from HathorNetwork/chore/drop-python-3.9
jansegre Sep 22, 2023
e2d9278
feat(p2p): Add ping salt and improve rtt information
msbrogli Sep 22, 2023
1f5eccc
feat: add --sysctl-init-file as cli command option
alexruzenhack Jul 28, 2023
bbbe1a5
Merge pull request #714 from HathorNetwork/feat/add-optional-argument
jansegre Sep 25, 2023
fe3c2e9
refactor(verification): move vertex verification to its own service
glevco Sep 22, 2023
a1cd450
Merge pull request #779 from HathorNetwork/refactor/verification-service
jansegre Sep 26, 2023
42a5179
chore: bump version to v0.57.0
jansegre Sep 26, 2023
54a1a66
Merge pull request #790 from HathorNetwork/chore/v0.57.0
jansegre Sep 26, 2023
57126e4
feat(reliable-integration): emit VERTEX_METADATA_CHANGED events in re…
glevco Sep 21, 2023
0e18dd4
Merge pull request #776 from HathorNetwork/feat/reliable-integration/…
jansegre Sep 27, 2023
1360614
fix(feature-activation): add signal bits to minimally valid block
glevco Sep 20, 2023
427a128
Merge pull request #774 from HathorNetwork/fix/feature-activation/sig…
jansegre Sep 28, 2023
2813200
chore(ci): upload codecov results on Python 3.11 test job
jansegre Sep 28, 2023
274bb12
Merge pull request #792 from HathorNetwork/chore/codecov-upload
jansegre Sep 28, 2023
9a37b94
chore(ci): fix codecov main branch name
jansegre Sep 28, 2023
a7c2ad4
Merge pull request #793 from HathorNetwork/chore/codecov-main-branch
jansegre Sep 30, 2023
c968aea
feat(p2p): run periodic bootstrap discovery
msbrogli Sep 22, 2023
064f84b
Merge pull request #783 from HathorNetwork/feat/p2p-periodic-bootstra…
jansegre Oct 2, 2023
32da24d
feat(wallet): Add BaseWallet.get_balance_per_address() method
msbrogli Sep 21, 2023
85a3bfc
refactor(settings): change HathorManager to use injected settings
glevco Sep 25, 2023
88ef27f
refactor(settings): refactor genesis module
glevco Sep 28, 2023
1cb8d78
refactor(verification): create vertex verifiers
glevco Oct 10, 2023
67085e3
chore: improve push_tx log
glevco Oct 6, 2023
45c7ba5
fix(sync-v2): Stop streaming if current block becomes voided
msbrogli Oct 13, 2023
889bf5d
test(sync-v1): Reset rate limit hit counter after simulation
msbrogli Oct 17, 2023
e305645
feat(p2p): relay all recently-seen peers for neighbors.
msbrogli Sep 22, 2023
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
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
codecov:
branch: dev
branch: master

coverage:
# https://docs.codecov.com/docs/coverage-configuration
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
- python
- pypy
python-version:
- '3.9'
- '3.10'
- '3.11'
exclude:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:
import os
import json
full_matrix = {
'python': ['3.9', '3.10', '3.11'],
'python': ['3.10', '3.11'],
# 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': [
# XXX: tests fail on these, not sure why, when running them individually each on passes, but not on `make tests`
# {'os': 'ubuntu-22.04', 'python': 'pypy-3.9'},
# {'os': 'ubuntu-22.04', 'python': 'pypy-3.10'},
],
}
# this is the fastest one:
reduced_matrix = {
'python': ['3.9'],
'python': ['3.11'],
'os': ['ubuntu-22.04'],
}
github_repository = os.environ['GITHUB_REPOSITORY']
Expand Down Expand Up @@ -99,4 +99,4 @@ jobs:
run: poetry run make tests
- name: Upload coverage
uses: codecov/codecov-action@v3
if: matrix.python == 3.9 && startsWith(matrix.os, 'ubuntu')
if: matrix.python == 3.11 && startsWith(matrix.os, 'ubuntu')
35 changes: 33 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 import HathorSettings
from hathor.conf.get_settings import get_settings
from hathor.conf.settings import HathorSettings as HathorSettingsType
from hathor.consensus import ConsensusAlgorithm
from hathor.event import EventManager
Expand All @@ -41,6 +41,7 @@
TransactionStorage,
)
from hathor.util import Random, Reactor, get_environment_info
from hathor.verification.verification_service import VerificationService, VertexVerifiers
from hathor.wallet import BaseWallet, Wallet

logger = get_logger()
Expand Down Expand Up @@ -101,6 +102,9 @@ def __init__(self) -> None:
self._feature_service: Optional[FeatureService] = None
self._bit_signaling_service: Optional[BitSignalingService] = None

self._vertex_verifiers: Optional[VertexVerifiers] = None
self._verification_service: Optional[VerificationService] = None

self._rocksdb_path: Optional[str] = None
self._rocksdb_storage: Optional[RocksDBStorage] = None
self._rocksdb_cache_capacity: Optional[int] = None
Expand Down Expand Up @@ -157,6 +161,7 @@ def build(self) -> BuildArtifacts:
tx_storage = self._get_or_create_tx_storage(indexes)
feature_service = self._get_or_create_feature_service(tx_storage)
bit_signaling_service = self._get_or_create_bit_signaling_service(tx_storage)
verification_service = self._get_or_create_verification_service()

if self._enable_address_index:
indexes.enable_address_index(pubsub)
Expand All @@ -177,6 +182,7 @@ def build(self) -> BuildArtifacts:

manager = HathorManager(
reactor,
settings=settings,
network=self._network,
pubsub=pubsub,
consensus_algorithm=consensus_algorithm,
Expand All @@ -191,6 +197,7 @@ def build(self) -> BuildArtifacts:
environment_info=get_environment_info(self._cmdline, peer_id.id),
feature_service=feature_service,
bit_signaling_service=bit_signaling_service,
verification_service=verification_service,
**kwargs
)

Expand Down Expand Up @@ -259,7 +266,7 @@ def set_peer_id(self, peer_id: PeerId) -> 'Builder':

def _get_or_create_settings(self) -> HathorSettingsType:
if self._settings is None:
self._settings = HathorSettings()
self._settings = get_settings()
return self._settings

def _get_reactor(self) -> Reactor:
Expand Down Expand Up @@ -424,6 +431,20 @@ def _get_or_create_bit_signaling_service(self, tx_storage: TransactionStorage) -

return self._bit_signaling_service

def _get_or_create_verification_service(self) -> VerificationService:
if self._verification_service is None:
verifiers = self._get_or_create_vertex_verifiers()
self._verification_service = VerificationService(verifiers=verifiers)

return self._verification_service

def _get_or_create_vertex_verifiers(self) -> VertexVerifiers:
if self._vertex_verifiers is None:
settings = self._get_or_create_settings()
self._vertex_verifiers = VertexVerifiers.create_defaults(settings=settings)

return self._vertex_verifiers

def use_memory(self) -> 'Builder':
self.check_if_can_modify()
self._storage_type = StorageType.MEMORY
Expand Down Expand Up @@ -516,6 +537,16 @@ def set_event_storage(self, event_storage: EventStorage) -> 'Builder':
self._event_storage = event_storage
return self

def set_verification_service(self, verification_service: VerificationService) -> 'Builder':
self.check_if_can_modify()
self._verification_service = verification_service
return self

def set_vertex_verifiers(self, vertex_verifiers: VertexVerifiers) -> 'Builder':
self.check_if_can_modify()
self._vertex_verifiers = vertex_verifiers
return self

def set_reactor(self, reactor: Reactor) -> 'Builder':
self.check_if_can_modify()
self._reactor = reactor
Expand Down
24 changes: 14 additions & 10 deletions hathor/builder/cli_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
from hathor.manager import HathorManager
from hathor.p2p.manager import ConnectionsManager
from hathor.p2p.peer_id import PeerId
from hathor.p2p.utils import discover_hostname
from hathor.p2p.utils import discover_hostname, get_genesis_short_hash
from hathor.pubsub import PubSubManager
from hathor.stratum import StratumFactory
from hathor.util import Random, Reactor
from hathor.verification.verification_service import VerificationService, VertexVerifiers
from hathor.wallet import BaseWallet, HDWallet, Wallet

logger = get_logger()
Expand All @@ -56,15 +57,13 @@ def check_or_raise(self, condition: bool, message: str) -> None:

def create_manager(self, reactor: Reactor) -> HathorManager:
import hathor
from hathor.conf import HathorSettings
from hathor.conf.get_settings import get_settings_source
from hathor.conf.get_settings import get_settings, get_settings_source
from hathor.daa import TestMode, _set_test_mode
from hathor.event.storage import EventMemoryStorage, EventRocksDBStorage, EventStorage
from hathor.event.websocket.factory import EventWebsocketFactory
from hathor.p2p.netfilter.utils import add_peer_id_blacklist
from hathor.p2p.peer_discovery import BootstrapPeerDiscovery, DNSPeerDiscovery
from hathor.storage import RocksDBStorage
from hathor.transaction import genesis
from hathor.transaction.storage import (
TransactionCacheStorage,
TransactionMemoryStorage,
Expand All @@ -73,7 +72,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
)
from hathor.util import get_environment_info

settings = HathorSettings()
settings = get_settings()

# only used for logging its location
settings_source = get_settings_source()
Expand All @@ -89,7 +88,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
'hathor-core v{hathor}',
hathor=hathor.__version__,
pid=os.getpid(),
genesis=genesis.GENESIS_HASH.hex()[:7],
genesis=get_genesis_short_hash(),
my_peer_id=str(peer_id.id),
python=python,
platform=platform.platform(),
Expand Down Expand Up @@ -203,6 +202,9 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
not_support_features=self._args.signal_not_support
)

vertex_verifiers = VertexVerifiers.create_defaults(settings=settings)
verification_service = VerificationService(verifiers=vertex_verifiers)

p2p_manager = ConnectionsManager(
reactor,
network=network,
Expand All @@ -218,6 +220,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:

self.manager = HathorManager(
reactor,
settings=settings,
network=network,
hostname=hostname,
pubsub=pubsub,
Expand All @@ -232,7 +235,8 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
full_verification=full_verification,
enable_event_queue=self._args.x_enable_event_queue,
feature_service=self.feature_service,
bit_signaling_service=bit_signaling_service
bit_signaling_service=bit_signaling_service,
verification_service=verification_service,
)

p2p_manager.set_manager(self.manager)
Expand All @@ -259,10 +263,10 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
dns_hosts.extend(self._args.dns)

if dns_hosts:
self.manager.add_peer_discovery(DNSPeerDiscovery(dns_hosts))
p2p_manager.add_peer_discovery(DNSPeerDiscovery(dns_hosts))

if self._args.bootstrap:
self.manager.add_peer_discovery(BootstrapPeerDiscovery(self._args.bootstrap))
p2p_manager.add_peer_discovery(BootstrapPeerDiscovery(self._args.bootstrap))

if self._args.test_mode_tx_weight:
_set_test_mode(TestMode.TEST_TX_WEIGHT)
Expand All @@ -278,7 +282,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
self.log.warn('--memory-indexes is implied for memory storage or JSON storage')

for description in self._args.listen:
self.manager.add_listen_address(description)
p2p_manager.add_listen_address(description)

if self._args.peer_id_blacklist:
self.log.info('with peer id blacklist', blacklist=self._args.peer_id_blacklist)
Expand Down
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 import HathorSettings
from hathor.conf.get_settings import get_settings
from hathor.debug_resources import (
DebugCrashResource,
DebugLogResource,
Expand Down Expand Up @@ -141,7 +141,7 @@ def create_resources(self) -> server.Site:
)
from hathor.websocket import HathorAdminWebsocketFactory, WebsocketStatsResource

settings = HathorSettings()
settings = get_settings()
cpu = get_cpu_profiler()

# TODO get this from a file. How should we do with the factory?
Expand Down
1 change: 1 addition & 0 deletions hathor/builder/sysctl_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class SysctlBuilder:
"""Builder for the sysctl tree."""

def __init__(self, artifacts: BuildArtifacts) -> None:
self.artifacts = artifacts

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 import HathorSettings
settings = HathorSettings()
from hathor.conf.get_settings import get_settings
settings = get_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 import HathorSettings
settings = HathorSettings()
from hathor.conf.get_settings import get_settings
settings = get_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
@@ -0,0 +1,32 @@
# Copyright 2023 Hathor Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any

from twisted.internet.interfaces import IAddress

from hathor.cli.events_simulator.event_forwarding_websocket_protocol import EventForwardingWebsocketProtocol
from hathor.event.websocket import EventWebsocketFactory
from hathor.simulator import Simulator


class EventForwardingWebsocketFactory(EventWebsocketFactory):
def __init__(self, simulator: Simulator, *args: Any, **kwargs: Any) -> None:
self._simulator = simulator
super().__init__(*args, **kwargs)

def buildProtocol(self, _: IAddress) -> EventForwardingWebsocketProtocol:
protocol = EventForwardingWebsocketProtocol(self._simulator)
protocol.factory = self
return protocol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2023 Hathor Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import TYPE_CHECKING

from autobahn.websocket import ConnectionRequest

from hathor.event.websocket import EventWebsocketProtocol
from hathor.simulator import Simulator

if TYPE_CHECKING:
from hathor.cli.events_simulator.event_forwarding_websocket_factory import EventForwardingWebsocketFactory


class EventForwardingWebsocketProtocol(EventWebsocketProtocol):
factory: 'EventForwardingWebsocketFactory'

def __init__(self, simulator: Simulator) -> None:
self._simulator = simulator
super().__init__()

def onConnect(self, request: ConnectionRequest) -> None:
super().onConnect(request)
self._simulator.run(60)

def onOpen(self) -> None:
super().onOpen()
self._simulator.run(60)

def onClose(self, wasClean: bool, code: int, reason: str) -> None:
super().onClose(wasClean, code, reason)
self._simulator.run(60)

def onMessage(self, payload: bytes, isBinary: bool) -> None:
super().onMessage(payload, isBinary)
self._simulator.run(60)
Loading