Skip to content

snapshot create match result appears unused #2397

@leighmcculloch

Description

@leighmcculloch

What problem does your feature solve?

In cmd/soroban-cli/src/commands/snapshot/create.rs, the second match on val.data (around line 383) returns true or false from each arm, which looks like it was intended to filter whether an entry should be saved into the snapshot. However the result of the match is discarded (semicolon on the closing brace), and the snapshot.ledger_entries.push(...) and count_saved += 1 that follow execute unconditionally for every entry:

ScVal::ContractInstance(ScContractInstance {
executable: ContractExecutable::StellarAsset,
storage: Some(storage),
}) => {
if let Some(name) =
get_name_from_stellar_asset_contract_storage(storage)
{
let asset: builder::Asset = name.parse()?;
if let Some(issuer) = match asset
.resolve(&global_args.locator)?
{
Asset::Native => None,
Asset::CreditAlphanum4(a4) => Some(a4.issuer),
Asset::CreditAlphanum12(a12) => Some(a12.issuer),
} {
print.infoln(format!(
"Adding asset issuer {issuer} to search"
));
next.account_ids.insert(issuer);
}
}
}
_ => {}
}
}
keep
}
_ => false,
};
snapshot
.ledger_entries
.push((Box::new(key), (Box::new(val), Some(u32::MAX))));

match &val.data {
    LedgerEntryData::ConfigSetting(ConfigSettingEntry::StateArchival(
        state_archival,
    )) => {
        // ...
        false
    }
    LedgerEntryData::ContractData(e) => {
        // ...
        keep
    }
    _ => false,
};  // <-- result discarded
snapshot
    .ledger_entries
    .push((Box::new(key), (Box::new(val), Some(u32::MAX))));
count_saved += 1;

Does this mean all matched entries (including ConfigSetting entries that return false) are being unconditionally included in the final snapshot? I think so.

What would you like to see?

The match result should be used to conditionally save the entry, if that was the original intent.

What alternatives are there?

If all entries are intentionally being saved, the false return values in the match arms are dead code and should be cleaned up to avoid confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions