Skip to content

fix(simulator): implement missing CLI commands and align help/completer#5

Merged
8lecramm merged 7 commits into
DEROFDN:community-devfrom
moralpriest:fix/simulator-commands
Mar 14, 2026
Merged

fix(simulator): implement missing CLI commands and align help/completer#5
8lecramm merged 7 commits into
DEROFDN:community-devfrom
moralpriest:fix/simulator-commands

Conversation

@moralpriest

Copy link
Copy Markdown

Description

The simulator CLI had significant command-surface drift: many commands listed in help had no dispatch handler, and the three independent surfaces (dispatch switch cases, usage() help text, readline completer) had diverged.

This PR implements 11 missing command handlers and synchronizes all three surfaces so every listed command works.

Changes by commit:

  1. feat(simulator): add diff and print_height handlers — Implements diff (shows current network difficulty) and print_height (shows current chain height).

  2. feat(simulator): add print_bc handler for topo range output — Implements print_bc to display block info for a topo-height range, matching daemon behavior. Adds math/big import for difficulty display.

  3. feat(simulator): add print_tx command support — Implements print_tx to look up and display transaction details by hash. Uncomments the transaction package import.

  4. feat(simulator): add peer, sync, ban, and mining stub handlers — Implements peer_list, sync_info, ban, unban, bans using existing p2p functions. Adds start_mining/stop_mining stubs that return explicit "not supported in simulator" messages.

  5. fix(simulator): align help and completer with command handlers — Synchronizes usage() and completer with the full set of implemented commands. Fixes swapped mempool_flush/"Flush regpool" and regpool_flush/"Flush mempool" descriptions. Fixes case-sensitive help dispatch (was line == "help", now uses command == "help" which goes through strings.ToLower()).

  6. fix(simulator): improve unknown command guidance — Unknown commands now print "unknown command: X, try 'help'" instead of silently falling through.

NOTE: This PR targets community-dev rather than dev as this is the active development branch for community contributions.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This will require a HardFork to be enabled

Which part is impacted ?

  • Wallet
  • Daemon
  • Miner
  • Explorer
  • Simulator
  • Misc (documentation, comments, text...)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

License

I am contributing & releasing the code under DERO Research License (which can be found here).

@8lecramm 8lecramm self-assigned this Mar 5, 2026

@8lecramm 8lecramm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I see no issues with the "core" functions such as "diff", "print_bc" and so on.
Do we really need p2p and mining commands? It has no use in simulator mode.

@moralpriest

Copy link
Copy Markdown
Author

I think it would preferable to get ride of them instead of printing "command is not supported in simulator" unless there's value to have parity with the daemon. I fail to see that.

@8lecramm 8lecramm merged commit a5071c9 into DEROFDN:community-dev Mar 14, 2026
@moralpriest moralpriest deleted the fix/simulator-commands branch April 23, 2026 04:08
DHEBP added a commit to DHEBP/derohe that referenced this pull request Jul 2, 2026
…etroactive scrub (review #1/DEROFDN#4/DEROFDN#5/DEROFDN#6)

DEROFDN#6 — Entry.String() printed "Sender: %s" unconditionally: a scrubbed ring>2
transfer rendered a bare "Sender: " line that reads as a decode bug — the
exact "looks broken" outcome the design meant to avoid, contradicting the
truth table documented on SenderVerified in the same file. The Sender line
now follows the table: verified -> the address; scrubbed (no payload
error) -> "unknown (unverifiable, ring size N)"; decode failure -> a
distinct "unknown (payload decode failed)". Blast radius: two CLI debug
dumps (%+v in show_transfers error paths); JSON marshalling untouched.
Pinned by rpc/wallet_rpc_test.go (offline, sub-second): all three arms,
plus forbids the bare line and scrub/decode-failure conflation.

DEROFDN#4/DEROFDN#5 — the non-retroactive caveat lived only in commit 4e9de56's message.
Now in the docs consumers read: SenderVerified's doc comment states the
scrub is decode-time only (pre-upgrade entries keep their guessed Sender
and unscrubbed Data[0], served as-is by Get_Transfers; the guarantee holds
only for blocks decoded post-upgrade), the upgrade is one-way for the
privacy property, and pre-upgrade entries deserialize
SenderVerified=false, RingSize=0 — indistinguishable from a scrub without
re-decoding, so a migration MUST re-derive RingSize from chain data (a
read-path scrub keyed on persisted fields would wrongly blank the wallet's
own verified sends — why the rescan is a follow-up, not this commit).
RingSize's doc gains the "0 = pre-upgrade/unknown, not a real ring" note;
the GetTransfers handler doc points RPC consumers at the contract.

#1 hardening — both decode arms bounded sender_idx against
Statement.RingSize while indexing Statement.Publickeylist. Safe today
(len(Publickeylist)==RingSize holds at that point), but the guard now
bounds against the slice actually indexed, so it survives any future break
of that invariant.

Existing pins green: the scrub-behavior sim test and the source-grep guard
(its regexes key on the scrub lines, untouched here).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants