Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/movy-replay/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ impl<
Self { db }
}

pub fn std_abi(&self, test: bool) -> Result<BTreeMap<MoveAddress, MovePackageAbi>, MovyError> {
let std = if test {
include_bytes!(concat!(env!("OUT_DIR"), "/std.testing")).to_vec()
} else {
include_bytes!(concat!(env!("OUT_DIR"), "/std")).to_vec()
};
let stds: Vec<SuiCompiledPackage> = serde_json::from_slice(&std)?;
let mut out = BTreeMap::new();
for std in stds {
out.insert(std.package_id.into(), std.abi()?);
}
Ok(out)
}

pub fn install_std(&self, test: bool) -> Result<(), MovyError> {
// This is pretty hacky but works
let stds = if test {
Expand Down Expand Up @@ -164,6 +178,15 @@ impl<
gas,
None,
)?;
if results.effects.status().is_err() {
let err = eyre!(
"movy_init failed at {}: {:?}",
md.module_id,
results.effects.status()
);
log::warn!("{err}");
continue;
}
log::info!("Commiting movy_init effects...");
log::debug!(
"Status: {:?} Changed Objects: {}, Removed Objects: {}",
Expand Down
1 change: 1 addition & 0 deletions crates/movy-replay/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl Metadata {
for (addr, abi) in local_abis {
abis.insert(addr, abi);
}
abis.remove(&MoveAddress::from_str("0xa")?);

// Map every module address back to its package id.
let mut module_address_to_package = BTreeMap::new();
Expand Down
4 changes: 2 additions & 2 deletions crates/movy-types/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ impl MoveAbiSignatureToken {
}

pub fn is_balance(&self) -> bool {
let MoveAbiSignatureToken::Struct(inner) = self else {
let MoveAbiSignatureToken::StructInstantiation(inner, _) = self else {
return false;
};
inner.module_id.module_address == MoveAddress::two()
Expand All @@ -559,7 +559,7 @@ impl MoveAbiSignatureToken {
}

pub fn is_coin(&self) -> bool {
let MoveAbiSignatureToken::Struct(inner) = self else {
let MoveAbiSignatureToken::StructInstantiation(inner, _) = self else {
return false;
};
inner.module_id.module_address == MoveAddress::two()
Expand Down
7 changes: 1 addition & 6 deletions crates/movy/src/sui/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ use sui_types::storage::{BackingPackageStore, BackingStore, ObjectStore};

#[derive(Args, Clone, Debug, Serialize, Deserialize)]
pub struct SuiTargetArgs {
#[arg(
short,
long,
value_delimiter = ',',
help = "The onchain packages to add."
)]
#[arg(long, value_delimiter = ',', help = "The onchain packages to add.")]
pub onchains: Option<Vec<MoveAddress>>,
#[arg(
long,
Expand Down
13 changes: 10 additions & 3 deletions crates/movy/src/sui/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,17 @@ impl SuiFuzzArgs {
let gas_id = ObjectID::random_from_rng(&mut rand);
env.mint_coin_id(
MoveTypeTag::from_str("0x2::sui::SUI").unwrap(),
MoveOwner::AddressOwner(self.deployer),
MoveOwner::AddressOwner(self.attacker),
gas_id.into(),
100_000_000_000,
)?;
// Mint SUI to attacker for fuzzing
env.mint_coin_id(
MoveTypeTag::from_str("0x2::sui::SUI").unwrap(),
MoveOwner::AddressOwner(self.attacker),
ObjectID::random_from_rng(&mut rand).into(),
100_000_000_000,
)?;
let testing_env = SuiTestingEnv::new(env);
testing_env.mock_testing_std()?;

Expand All @@ -217,8 +224,8 @@ impl SuiFuzzArgs {
&graphql,
)
.await?;
let mut abis = BTreeMap::new();
let mut testing_abis = BTreeMap::new();
let mut abis = testing_env.std_abi(false)?;
let mut testing_abis = testing_env.std_abi(true)?;

for (testing_abi, abi, names) in local_abis {
let testing_pkg = testing_abi.package_id;
Expand Down