Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshot subcommand that creates a ledger snapshot from an archive #1368

Merged
merged 74 commits into from
Aug 5, 2024

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Jun 11, 2024

What

Add snapshot subcommand that creates a ledger snapshot from an archive.

Why

To make it possible to easily test against mainnet state.

Try it out

Install stellar-cli:

cargo install \
  --locked \
  --git https://github.com/stellar/stellar-cli \
  --branch snap \
  stellar-cli

Snapshot ledger:

stellar snapshot \
  --output json
  --address CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75 \
  --out snapshot.json

Write a test importing it:

#![cfg(test)]
use soroban_sdk::{token::TokenClient, Address, Env, String};

#[test]
fn test() {
    let e = Env::from_ledger_snapshot_file("snapshot.json");
    let contract = TokenClient::new(
        &e,
        &Address::from_string(&String::from_str(
            &e,
            "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75",
        )),
    );
    let wallet = Address::from_string(&String::from_str(
        &e,
        "CAZ6W4WHVGQBGURYTUOLCUOOHW6VQGAAPSPCD72VEDZMBBPY7H43AYEC",
    ));
    assert_eq!(contract.balance(&wallet), 553804322934);
}

Close #383

@leighmcculloch

This comment was marked as outdated.

@leighmcculloch leighmcculloch marked this pull request as ready for review August 1, 2024 05:39
@leighmcculloch leighmcculloch enabled auto-merge (squash) August 1, 2024 05:40
@leighmcculloch
Copy link
Member Author

leighmcculloch commented Aug 1, 2024

Todo:

  • automatically pickup trust lines and accounts that hold the asset of a stellar asset contract
  • fix bug where a wasm could be inserted twice into the resulting snapshot
  • make resulting snapshot reproducible and stable independent of input order whether inputs were derived or explicit

Makefile Outdated Show resolved Hide resolved
@leighmcculloch leighmcculloch requested a review from fnando August 3, 2024 07:15
@leighmcculloch leighmcculloch merged commit 0344571 into main Aug 5, 2024
26 checks passed
@leighmcculloch leighmcculloch deleted the snap branch August 5, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add command for creating ledger snapshot
2 participants