Skip to content

Commit

Permalink
fix(iota-replay): sandbox snapshots are outdated due to rename (#2269)
Browse files Browse the repository at this point in the history
* fix(iota-replay): script for generation replay snapshots has been created, regenerating snapshots based on testnet transactions
  • Loading branch information
Dkwcs authored Nov 26, 2024
1 parent 29eda32 commit 2f569f3
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 3 deletions.
4 changes: 4 additions & 0 deletions crates/iota-replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ move-bytecode-utils.workspace = true
move-core-types.workspace = true
move-vm-config.workspace = true
shared-crypto.workspace = true

[[example]]
name = "make_sandbox_snapshot"
path = "examples/make_sandbox_snapshot.rs"
32 changes: 32 additions & 0 deletions crates/iota-replay/examples/make_sandbox_snapshot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use std::{env, path::PathBuf, str::FromStr};

use anyhow::Result;
use iota_replay::{ReplayToolCommand, execute_replay_command};

const TESTNET_ADDR: &str = "https://api.testnet.iota.cafe";

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/sandbox_snapshots");

// Retrieve `tx_digest` from command-line arguments
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
println!("Usage: <tx_digest>");
return Ok(());
}
let tx_digest = &args[1]; // tx_digest passed as the first argument
let localnet_addr = String::from_str(TESTNET_ADDR).unwrap();

let cmd = ReplayToolCommand::PersistSandbox {
tx_digest: tx_digest.clone(),
base_path: path,
};

execute_replay_command(Some(localnet_addr), true, true, None, None, cmd).await?;
Ok(())
}
9 changes: 9 additions & 0 deletions crates/iota-replay/examples/move/tx_instance/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "tx_instance"
version = "0.0.1"

[dependencies]
Iota = { local = "../../../../iota-framework/packages/iota-framework" }

[addresses]
tx_instance = "0x0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module tx_instance::tx_instance {
use iota::event;
use iota::tx_context::{Self, TxContext};

struct TxInstance has copy, drop {
user: address,
published: bool
}

fun init(ctx: &mut TxContext) {
event::emit(TxInstance {
user: tx_context::sender(ctx),
published: true
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module tx_instance::tx_instance_upgrade {
use iota::event;
use iota::tx_context::{Self, TxContext};

struct TxInstance has copy, drop {
user: address,
published: bool,
name: vector<u8>
}

fun init(ctx: &mut TxContext) {
event::emit(TxInstance {
user: tx_context::sender(ctx),
published: true,
name: b"TxInstance"
})
}
}
9 changes: 9 additions & 0 deletions crates/iota-replay/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The sandbox snapshots are generated according to specific transactions we want to replay.

To make a snapshot(local example):

1. iota-test-validator - `cargo run`
2. `iota client faucet`
3. iota-replay/examples/move/tx_instance - `iota client publish --gas-budget 1000000000`
4. Save tx digest
5. iota-replay - `cargo run --example make_sandbox_snapshot <your tx digest>`
1 change: 0 additions & 1 deletion crates/iota-replay/tests/regression_replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::path::PathBuf;
use iota_replay::{ReplayToolCommand, execute_replay_command};

#[tokio::test]
#[ignore = "sandbox snapshots are invalidated by rename"]
async fn replay_sandboxes() {
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/sandbox_snapshots");
Expand Down

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

0 comments on commit 2f569f3

Please sign in to comment.