Skip to content

Commit

Permalink
firedancer: don't assume tar command exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgee-jump authored and alpeng-jump committed Sep 16, 2024
1 parent d7c3bc8 commit 7c9b60a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
5 changes: 5 additions & 0 deletions ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ tokio = { workspace = true, features = ["full"] }
tokio-stream = { workspace = true }
trees = { workspace = true }

# FIREDANCER: We switch from assuming tar command exists locally to linking
# the library. This resolves some deployment and debugging issues.
tar = { workspace = true }
bzip2 = { workspace = true }

[dependencies.rocksdb]
# Avoid the vendored bzip2 within rocksdb-sys that can cause linker conflicts
# when also using the bzip2 crate
Expand Down
59 changes: 33 additions & 26 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4862,32 +4862,39 @@ pub fn create_new_ledger(
drop(blockstore);

let archive_path = ledger_path.join(DEFAULT_GENESIS_ARCHIVE);
let args = vec![
"jcfhS",
archive_path.to_str().unwrap(),
"-C",
ledger_path.to_str().unwrap(),
DEFAULT_GENESIS_FILE,
blockstore_dir,
];
let output = std::process::Command::new("tar")
.env("COPYFILE_DISABLE", "1")
.args(args)
.output()
.unwrap();
if !output.status.success() {
use std::str::from_utf8;
error!("tar stdout: {}", from_utf8(&output.stdout).unwrap_or("?"));
error!("tar stderr: {}", from_utf8(&output.stderr).unwrap_or("?"));

return Err(BlockstoreError::Io(IoError::new(
ErrorKind::Other,
format!(
"Error trying to generate snapshot archive: {}",
output.status
),
)));
}
// FIREDANCER: We switch from assuming tar command exists locally to linking
// the library. This resolves some deployment and debugging issues.
let mut archive = tar::Builder::new(bzip2::write::BzEncoder::new(std::fs::File::create(&archive_path)?, bzip2::Compression::default()));
archive.append_path_with_name(ledger_path.join(DEFAULT_GENESIS_FILE), DEFAULT_GENESIS_FILE)?;
archive.append_dir_all("rocksdb", ledger_path.join(blockstore_dir))?;
archive.finish()?;
drop(archive);
// let args = vec![
// "jcfhS",
// archive_path.to_str().unwrap(),
// "-C",
// ledger_path.to_str().unwrap(),
// DEFAULT_GENESIS_FILE,
// blockstore_dir,
// ];
// let output = std::process::Command::new("tar")
// .env("COPYFILE_DISABLE", "1")
// .args(args)
// .output()
// .unwrap();
// if !output.status.success() {
// use std::str::from_utf8;
// error!("tar stdout: {}", from_utf8(&output.stdout).unwrap_or("?"));
// error!("tar stderr: {}", from_utf8(&output.stderr).unwrap_or("?"));

// return Err(BlockstoreError::Io(IoError::new(
// ErrorKind::Other,
// format!(
// "Error trying to generate snapshot archive: {}",
// output.status
// ),
// )));
// }

// ensure the genesis archive can be unpacked and it is under
// max_genesis_archive_unpacked_size, immediately after creating it above.
Expand Down

0 comments on commit 7c9b60a

Please sign in to comment.