mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-11-19 14:36:34 -05:00
Cleanup, logging and parameter tuning
This commit is contained in:
parent
5f46fc6b48
commit
a8cc6cb239
5 changed files with 29 additions and 23 deletions
|
|
@ -308,7 +308,7 @@ class Link:
|
|||
self.expected_hops = RNS.Transport.hops_to(self.destination.hash)
|
||||
self.establishment_timeout = RNS.Reticulum.get_instance().get_first_hop_timeout(self.destination.hash)
|
||||
self.establishment_timeout += Link.ESTABLISHMENT_TIMEOUT_PER_HOP * max(1, RNS.Transport.hops_to(self.destination.hash))
|
||||
self.stamp_cost = RNS.Identity.recall_link_cost(self.destination.hash)
|
||||
self.stamp_cost = RNS.Identity.recall_link_cost(self.destination.hash) or RNS.Transport.LR_COST if RNS.Transport.ALWAYS_STAMP_LRS else None
|
||||
|
||||
if self.stamp_cost and RNS.Transport.STAMP_LRS: self.__defer_keys = True
|
||||
else:
|
||||
|
|
@ -350,7 +350,9 @@ class Link:
|
|||
def stamp_watchdog():
|
||||
deadline = time.time() + RNS.Transport.LINK_STAMP_TIMEOUT
|
||||
while self.stamp_status == None and time.time() <= deadline: time.sleep(1)
|
||||
if time.time() > deadline and self.stamp_job_id and not self.stamp_status: cancel_work(self.stamp_job_id)
|
||||
if time.time() > deadline and self.stamp_job_id and not self.stamp_status:
|
||||
cancel_work(self.stamp_job_id)
|
||||
RNS.log(f"Stamp generation timed out for link request to {RNS.prettyhexrep(self.destination.hash)}", RNS.LOG_NOTICE)
|
||||
|
||||
self.sig_prv = Ed25519PrivateKey.generate()
|
||||
self.sig_pub = self.sig_prv.public_key()
|
||||
|
|
|
|||
|
|
@ -487,9 +487,9 @@ class Reticulum:
|
|||
value = self.config["stamps"].as_bool(option)
|
||||
if value == True: RNS.Transport.STAMP_PRS = True
|
||||
|
||||
if option == "stamp_lrs":
|
||||
if option == "always_stamp_lrs":
|
||||
value = self.config["stamps"].as_bool(option)
|
||||
if value == True: RNS.Transport.STAMP_LRS = True
|
||||
if value == True: RNS.Transport.ALWAYS_STAMP_LRS = True
|
||||
|
||||
if option == "destination_cost":
|
||||
v = self.config["stamps"].as_int(option)
|
||||
|
|
|
|||
|
|
@ -259,9 +259,9 @@ def generate_stamp(message_id, stamp_cost, expand_rounds=WORKBLOCK_EXPAND_ROUNDS
|
|||
|
||||
stamp_cost = cost_to_fp(stamp_cost)
|
||||
start_time = time.time()
|
||||
stamp = None
|
||||
rounds = 0
|
||||
value = 0
|
||||
stamp = None
|
||||
value = None
|
||||
rounds = 0
|
||||
|
||||
if RNS.vendor.platformutils.is_windows() or RNS.vendor.platformutils.is_darwin():
|
||||
RNS.log(f"Multi-core stamp generation on this platform is not supported, work limited to single CPU core.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
|
@ -276,7 +276,8 @@ def generate_stamp(message_id, stamp_cost, expand_rounds=WORKBLOCK_EXPAND_ROUNDS
|
|||
speed = rounds/duration
|
||||
if stamp != None: value = stamp_value(workblock, stamp)
|
||||
|
||||
RNS.log(f"Stamp with value {value} generated in {RNS.prettytime(duration)}, {rounds} rounds, {RNS.prettysize(speed, suffix='rps')}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
if value != None: RNS.log(f"Stamp with value {value} generated in {RNS.prettytime(duration)}, {rounds} rounds, {RNS.prettysize(speed, suffix='rps')}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
else: RNS.log(f"Stamp generation aborted or failed after {RNS.prettytime(duration)}, {rounds} rounds", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
||||
return stamp, value
|
||||
|
||||
|
|
@ -322,8 +323,8 @@ def generate_stamped_key(material, stamp_cost):
|
|||
stamp_cost = cost_to_fp(stamp_cost)
|
||||
start_time = time.time()
|
||||
keypair = None
|
||||
value = None
|
||||
rounds = 0
|
||||
value = 0
|
||||
|
||||
if RNS.vendor.platformutils.is_windows() or RNS.vendor.platformutils.is_darwin():
|
||||
RNS.log(f"Multi-core stamp generation on this platform is not supported, work limited to single CPU core.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
|
@ -338,7 +339,8 @@ def generate_stamped_key(material, stamp_cost):
|
|||
speed = rounds/duration
|
||||
if keypair != None: value = stamp_value(material, keypair[1])
|
||||
|
||||
RNS.log(f"Stamped key with value {value} generated in {RNS.prettyshorttime(duration)}, {rounds} rounds, {RNS.prettysize(speed, suffix='rps')}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
if value != None: RNS.log(f"Stamped key with value {value} generated in {RNS.prettyshorttime(duration)}, {rounds} rounds, {RNS.prettysize(speed, suffix='rps')}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
else: RNS.log(f"Stamp generation aborted or failed after {RNS.prettytime(duration)}, {rounds} rounds", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
||||
return keypair, value
|
||||
|
||||
|
|
|
|||
|
|
@ -193,14 +193,15 @@ class Transport:
|
|||
LR_STAMPS_ENFORCED = False # Whether to enforce link request stamp requirements
|
||||
STAMP_DESTINATIONS = False # Whether to stamp destination announces emitted from this instance
|
||||
STAMP_PRS = False # Whether to stamp path requests emitted from this instance
|
||||
STAMP_LRS = False # Whether to stamp link requests emitted from this instance
|
||||
STAMP_COST_CAP = 100 # Global hard cap on stamp cost to ensure search-space viability at 14-byte stamp sizes
|
||||
LINK_COST_CAP = 40 # Global hard cap on link request cost, separate from detached stamps
|
||||
DESTINATION_COST = 23 # Default required announce cost if no specifics configured or determined
|
||||
DESTINATION_VALUE = 25 # Default target stamp value for emitted announces
|
||||
PR_COST = 19 # Default required path request cost if no specifics configured or determined
|
||||
PR_VALUE = 19 # Default target stamp value for emitted path requests
|
||||
LR_COST = 11 # Default required link request cost if not explicitly announced or configured
|
||||
STAMP_LRS = True # Whether to stamp link requests emitted from this instance
|
||||
ALWAYS_STAMP_LRS = False # Whether to stamp link requests even when no link cost is announced
|
||||
STAMP_COST_CAP = 100.0 # Global hard cap on stamp cost to ensure search-space viability at 14-byte stamp sizes
|
||||
LINK_COST_CAP = 40.0 # Global hard cap on link request cost, separate from detached stamps
|
||||
DESTINATION_COST = 23.5 # Default required announce cost if no specifics configured or determined
|
||||
DESTINATION_VALUE = 25.0 # Default target stamp value for emitted announces
|
||||
PR_COST = 19.8 # Default required path request cost if no specifics configured or determined
|
||||
PR_VALUE = 19.8 # Default target stamp value for emitted path requests
|
||||
LR_COST = 19.2 # Default required link request cost if not explicitly announced or configured
|
||||
LINK_STAMP_TIMEOUT = 15 # Default link request stamp generation timeout
|
||||
PR_STAMP_TIMEOUT = 15 # Default path request stamp generation timeout
|
||||
HOP_LIMITER = PATHFINDER_M
|
||||
|
|
|
|||
|
|
@ -314,14 +314,15 @@ instance_name = default
|
|||
# and enforcement. RNS 1.6.0 includes all the required stamp
|
||||
# generation and verification functionality, and actively
|
||||
# validates stamps, while leaving generation, emission and
|
||||
# enforcement disabled by default. Version 1.6.1 will enable
|
||||
# generation and emission by default, and version 1.6.2 will
|
||||
# finally activate enforcement. Any option can be enabled
|
||||
# early by configuration.
|
||||
# enforcement disabled by default for destinations and PRs.
|
||||
# Link requests will be stamped already from 1.6.0 if a cost
|
||||
# has been announced by the destination. Version 1.6.1 will
|
||||
# enable generation and emission by default, and version
|
||||
# 1.6.2 will finally activate enforcement. Any of these
|
||||
# options can be enabled early by configuration:
|
||||
|
||||
# stamp_destinations = yes
|
||||
# stamp_prs = yes
|
||||
# stamp_lrs = yes
|
||||
# enforce_stamps = yes
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue