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

fix(STO-020): check entity stake for new account #765

Merged
merged 2 commits into from
Aug 26, 2024
Merged
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
22 changes: 13 additions & 9 deletions crates/sim/src/simulation/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,23 @@ where
slot,
) => {
let needs_stake_entity = needs_stake.and_then(|t| entity_infos.get(t));
if let Some(needs_stake_entity) = needs_stake_entity {
if needs_stake_entity.is_staked {
tracing::debug!("Associated storage accessed by staked entity during deploy, and entity is staked");
continue;

if needs_stake.is_none() {
if let Some(factory) = entity_infos.get(EntityType::Factory) {
if factory.is_staked {
tracing::debug!("Associated storage accessed by staked entity during deploy, and factory is staked");
continue;
}
}
}
if let Some(factory) = entity_infos.get(EntityType::Factory) {
if factory.is_staked {
tracing::debug!("Associated storage accessed by staked entity during deploy, and factory is staked");

if let Some(needs_stake_entity_info) = needs_stake_entity {
if needs_stake_entity_info.is_staked {
tracing::debug!("Associated storage accessed by staked entity during deploy, and entity is staked");
continue;
}
}

// [STO-022]
violations.push(SimulationViolation::AssociatedStorageDuringDeploy(
needs_stake_entity.map(|ei| ei.entity),
Expand Down Expand Up @@ -1174,8 +1179,7 @@ mod tests {
)]
);

// staked causes no errors
context.entity_infos.factory.as_mut().unwrap().is_staked = true;
context.entity_infos.paymaster.as_mut().unwrap().is_staked = true;
let res = simulator.gather_context_violations(&mut context);
assert!(res.unwrap().is_empty());
}
Expand Down
Loading