Skip to content

Commit

Permalink
Remove CLI option --restart from tumbler
Browse files Browse the repository at this point in the history
Prior to this commit, the --restart option was still present in the help
documentation of tumbler.py, however this functionality has been removed
from the algorithm (restarting now just means "running again", since the
algorithm now functions the same way independent of the location of the
coins in mixdepths). Moreover, running with this option could lead to
crash conditions.
After this commit, the --restart option is removed from the help text,
and no longer executed in code. Further, a slight change is made to the
wording of the tumblerguide.md documentation, section "Restarting", to
make the situation clearer.
  • Loading branch information
AdamISZ committed Sep 1, 2023
1 parent b65a5f3 commit 5e325e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 60 deletions.
2 changes: 1 addition & 1 deletion docs/tumblerguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Here is a test example schedule with those parameters:

### Restarting

Even before discussing practical code-level actions, we can see: this approach allows us to have coins in *any* mixdepth when we start; so we no longer have the concept of "restarting" if you manually ended the run halfway, or if a transaction repeatedly failed and you had to give up. You can judge for yourself; if you started a tumbler run of 8 mixdepths and it stopped after 3, you can do another run with 5 mixdepths later, if you like. W.r.t the destination addresses, you were never able to control the ratio that arrives at different destinations anyway (it's technically possible but not recommended, you'd need to create schedules manually and think carefully about it), so this really doesn't change that aspect.
Even before discussing practical code-level actions, we can see: this approach allows us to have coins in *any* mixdepth when we start; so we no longer have a special option `--restart` if you manually ended the run halfway, or if a transaction repeatedly failed and you had to give up. You can judge for yourself; if you started a tumbler run of 8 mixdepths and it stopped after 3, you can do another run with 5 mixdepths later, if you like. W.r.t the destination addresses, you were never able to control the ratio that arrives at different destinations anyway (it's technically possible but not recommended, you'd need to create schedules manually and think carefully about it), so this really doesn't change that aspect.

Delaying the whole process by stopping and restarting it is quite sensible anyway; as explained above, we *want* this process to be slow, not fast.

Expand Down
7 changes: 0 additions & 7 deletions jmclient/jmclient/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,6 @@ def get_tumbler_parser():
' be configured to ask for more address mid-run, giving the user'
' a chance to click `Generate New Deposit Address` on whatever service'
' they are using.')
parser.add_option('--restart',
action='store_true',
dest='restart',
default=False,
help=('Restarts the schedule currently found in the schedule file in the '
'logs directory, with name TUMBLE.schedule or what is set in the '
'schedulefile option.'))
parser.add_option('--schedulefile',
type='string',
dest='schedulefile',
Expand Down
63 changes: 11 additions & 52 deletions scripts/tumbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,58 +75,17 @@ def main():
jmprint("Invalid destination address: " + daddr, "error")
sys.exit(EXIT_ARGERROR)
jmprint("Destination addresses: " + str(destaddrs), "important")
#If the --restart flag is set we read the schedule
#from the file, and filter out entries that are
#already complete
if options['restart']:
res, schedule = get_schedule(os.path.join(logsdir,
options['schedulefile']))
if not res:
jmprint("Failed to load schedule, name: " + str(
options['schedulefile']), "error")
jmprint("Error was: " + str(schedule), "error")
sys.exit(EXIT_FAILURE)
#This removes all entries that are marked as done
schedule = [s for s in schedule if s[-1] != 1]
# remaining destination addresses must be stored in Taker.tdestaddrs
# in case of tweaks; note we can't change, so any passed on command
# line must be ignored:
if len(destaddrs) > 0:
jmprint("For restarts, destinations are taken from schedule file,"
" so passed destinations on the command line were ignored.",
"important")
if input("OK? (y/n)") != "y":
sys.exit(EXIT_SUCCESS)
destaddrs = [s[3] for s in schedule if s[3] not in ["INTERNAL", "addrask"]]
jmprint("Remaining destination addresses in restart: " + ",".join(destaddrs),
"important")
if isinstance(schedule[0][-1], str) and len(schedule[0][-1]) == 64:
#ensure last transaction is confirmed before restart
tumble_log.info("WAITING TO RESTART...")
txid = schedule[0][-1]
restart_waiter(txid)
#remove the already-done entry (this connects to the other TODO,
#probably better *not* to truncate the done-already txs from file,
#but simplest for now.
schedule = schedule[1:]
elif schedule[0][-1] != 0:
print("Error: first schedule entry is invalid.")
sys.exit(EXIT_FAILURE)
with open(os.path.join(logsdir, options['schedulefile']), "wb") as f:
f.write(schedule_to_text(schedule))
tumble_log.info("TUMBLE RESTARTING")
else:
#Create a new schedule from scratch
try:
schedule = get_tumble_schedule(options, destaddrs,
wallet.get_balance_by_mixdepth(), wallet_service.mixdepth)
except ScheduleGenerationErrorNoFunds:
jmprint("No funds in wallet to tumble.", "error")
sys.exit(EXIT_FAILURE)
tumble_log.info("TUMBLE STARTING")
with open(os.path.join(logsdir, options['schedulefile']), "wb") as f:
f.write(schedule_to_text(schedule))
print("Schedule written to logs/" + options['schedulefile'])
#Create a new schedule from scratch
try:
schedule = get_tumble_schedule(options, destaddrs,
wallet.get_balance_by_mixdepth(), wallet_service.mixdepth)
except ScheduleGenerationErrorNoFunds:
jmprint("No funds in wallet to tumble.", "error")
sys.exit(EXIT_FAILURE)
tumble_log.info("TUMBLE STARTING")
with open(os.path.join(logsdir, options['schedulefile']), "wb") as f:
f.write(schedule_to_text(schedule))
print("Schedule written to logs/" + options['schedulefile'])
tumble_log.info("With this schedule: ")
tumble_log.info(pprint.pformat(schedule))

Expand Down

0 comments on commit 5e325e1

Please sign in to comment.