From de21a706a1d4fac5b4d26cb791437cfdb836f013 Mon Sep 17 00:00:00 2001 From: Gabriel Levcovitz Date: Wed, 19 Mar 2025 13:07:26 -0300 Subject: [PATCH] chore: add localnet config --- hathor/cli/run_node.py | 5 ++++- hathor/cli/run_node_args.py | 1 + hathor/conf/__init__.py | 2 ++ hathor/conf/localnet.yml | 27 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 hathor/conf/localnet.yml diff --git a/hathor/cli/run_node.py b/hathor/cli/run_node.py index c745b346c..31151363d 100644 --- a/hathor/cli/run_node.py +++ b/hathor/cli/run_node.py @@ -79,6 +79,7 @@ def create_parser(cls) -> ArgumentParser: netargs = parser.add_mutually_exclusive_group() netargs.add_argument('--nano-testnet', action='store_true', help='Connect to Hathor nano-testnet') netargs.add_argument('--testnet', action='store_true', help='Connect to Hathor testnet') + netargs.add_argument('--localnet', action='store_true', help='Create a localnet with default configuration.') parser.add_argument('--test-mode-tx-weight', action='store_true', help='Reduces tx weight to 1 for testing purposes') @@ -487,7 +488,7 @@ def check_python_version(self) -> None: ])) def __init__(self, *, argv=None): - from hathor.conf import NANO_TESTNET_SETTINGS_FILEPATH, TESTNET_SETTINGS_FILEPATH + from hathor.conf import LOCALNET_SETTINGS_FILEPATH, NANO_TESTNET_SETTINGS_FILEPATH, TESTNET_SETTINGS_FILEPATH from hathor.conf.get_settings import get_global_settings self.log = logger.new() @@ -506,6 +507,8 @@ def __init__(self, *, argv=None): os.environ['HATHOR_CONFIG_YAML'] = TESTNET_SETTINGS_FILEPATH elif self._args.nano_testnet: os.environ['HATHOR_CONFIG_YAML'] = NANO_TESTNET_SETTINGS_FILEPATH + elif self._args.localnet: + os.environ['HATHOR_CONFIG_YAML'] = LOCALNET_SETTINGS_FILEPATH try: get_global_settings() diff --git a/hathor/cli/run_node_args.py b/hathor/cli/run_node_args.py index e46059b51..cdebb7830 100644 --- a/hathor/cli/run_node_args.py +++ b/hathor/cli/run_node_args.py @@ -86,3 +86,4 @@ class RunNodeArgs(BaseModel, extra=Extra.allow): disable_ws_history_streaming: bool x_enable_ipv6: bool x_disable_ipv4: bool + localnet: bool diff --git a/hathor/conf/__init__.py b/hathor/conf/__init__.py index 36fecbae5..95287288f 100644 --- a/hathor/conf/__init__.py +++ b/hathor/conf/__init__.py @@ -21,12 +21,14 @@ MAINNET_SETTINGS_FILEPATH = str(parent_dir / 'mainnet.yml') TESTNET_SETTINGS_FILEPATH = str(parent_dir / 'testnet.yml') NANO_TESTNET_SETTINGS_FILEPATH = str(parent_dir / 'nano_testnet.yml') +LOCALNET_SETTINGS_FILEPATH = str(parent_dir / 'localnet.yml') UNITTESTS_SETTINGS_FILEPATH = str(parent_dir / 'unittests.yml') __all__ = [ 'MAINNET_SETTINGS_FILEPATH', 'TESTNET_SETTINGS_FILEPATH', 'NANO_TESTNET_SETTINGS_FILEPATH', + 'LOCALNET_SETTINGS_FILEPATH', 'UNITTESTS_SETTINGS_FILEPATH', 'HathorSettings', ] diff --git a/hathor/conf/localnet.yml b/hathor/conf/localnet.yml new file mode 100644 index 000000000..d175faeaf --- /dev/null +++ b/hathor/conf/localnet.yml @@ -0,0 +1,27 @@ +P2PKH_VERSION_BYTE: x49 +MULTISIG_VERSION_BYTE: x87 +NETWORK_NAME: local-privatenet +BOOTSTRAP_DNS: [] + +# Ledger genesis +GENESIS_OUTPUT_SCRIPT: 76a91466665b27f7dbc4c8c089d2f686c170c74d66f0b588ac +GENESIS_BLOCK_TIMESTAMP: 1643902665 +GENESIS_BLOCK_NONCE: 4784939 +GENESIS_BLOCK_HASH: 00000334a21fbb58b4db8d7ff282d018e03e2977abd3004cf378fb1d677c3967 +GENESIS_TX1_NONCE: 0 +GENESIS_TX1_HASH: 54165cef1fd4cf2240d702b8383c307c822c16ca407f78014bdefa189a7571c2 +GENESIS_TX2_NONCE: 0 +GENESIS_TX2_HASH: 039906854ce6309b3180945f2a23deb9edff369753f7082e19053f5ac11bfbae + +# Genesis wallet: +# avocado spot town typical traffic vault danger century property shallow divorce festival +# spend attack anchor afford rotate green audit adjust fade wagon depart level + +MIN_TX_WEIGHT_K: 0 +MIN_TX_WEIGHT_COEFFICIENT: 0 +MIN_TX_WEIGHT: 1 +REWARD_SPEND_MIN_BLOCKS: 1 + +CHECKPOINTS: [] + +extends: testnet.yml