stellar / stellar-cli

CLI for Soroban contracts.
57 stars 48 forks source link

Use the network setting for max TTL extension #1204

Open dmkozh opened 4 months ago

dmkozh commented 4 months ago

During TTL extension operation ledgers_to_extend is incorrectly truncated to MAX_LEDGERS_TO_EXTEND constant. Instead, the max ledgers to extend should be read from the network config, specifically from the stateArchivalSettings.maxEntryTTL setting for the respective network. The check could probably happen on the simulation side, so it could be sufficient for CLI to simply remove the truncation code.

willemneal commented 1 month ago

@dmkozh Where is this network endpoint? Is it through Horizon? Currently we only use soroban-rpc. Do you suggest this should be a compile time constant?

dmkozh commented 1 month ago

No, this is not a constant, which is the reason for the issue. You need to fetch the stateArchivalSettings ledger entry and use maxEntryTTL from it. I'm not sure if RPC provides a shortcut for that, but if you just use the getLedgerEntry API using a ledger key, then your key would be of type CONFIG_SETTING with configSettingID set to CONFIG_SETTING_STATE_ARCHIVAL.