stellar / stellar-core

Reference implementation for the peer-to-peer agent that manages the Stellar network.
https://www.stellar.org
Other
3.12k stars 967 forks source link

Add `--stop-at-ledger` option to `stellar run` #4427

Open leighmcculloch opened 1 month ago

leighmcculloch commented 1 month ago

Description

Explain in detail the additional functionality you would like to see in stellar-core.

The ability to optionally specify a --stop-at-ledger when using stellar-core run.

When the option is provided the run stops and exits cleanly after having processed that ledger.

Explain why this feature is important

Today as a non-validator-operator user of the network I can use stellar-core to replay meta, starting at a specified ledger. For example, using the following command:

stellar-core run \
    --in-memory \
    --start-at-ledger 1000515 \
    --start-at-hash d73003ad99a048123bc2b6ef4b8b399728af53c7b57c3f599c8e09280cbe0a50 \
    --metadata-output-stream fd:1 > meta.xdr

However, the command keeps going indefinitely until the process is killed. But when replaying from a specific ledger I almost always want to collect some specific range, or even just one ledger. I have to monitor the current ledger of the stellar-core and then kill it when that ledger has been passed.

Describe the solution you'd like

The ability to optionally specify a --stop-at-ledger when using stellar-core run.

When the option is provided the run stops and exits cleanly after having processed that ledger.

Describe alternatives you've considered

Scripting reading the current ledger from the /info endpoint and killing the process, but that feels so brittle.

Additional context

N/A

MonsieurNicolas commented 1 month ago

for replaying ranges, can't you just use catchup ?

leighmcculloch commented 1 month ago

🤦🏻 Ah of course, I can use the following command to get the same output but to have it stop:

stellar-core catchup \
    --in-memory \
    1000515/1 \
    --trusted-hash d73003ad99a048123bc2b6ef4b8b399728af53c7b57c3f599c8e09280cbe0a50 \
    --metadata-output-stream fd:1 > meta.xdr

Is that the only difference between catchup and run, they do the same thing, just one will stop at a ledger?

MonsieurNicolas commented 1 month ago

run is used to connect to the network (so connects to peers, etc), catchup only uses history archives

leighmcculloch commented 1 month ago

Ah, so if I want a ledger that isn't in an archive yet, I need to use run, but then run doesn't have a way to stop at the ledger I need. So I think the use case is still applicable, albeit narrow, and may not be meaningful since in the time it takes to catch up pubnet I could probably wait a similar amount of time for a checkpoint to be published.