Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

bug: fix activation after leave #119

Merged
merged 14 commits into from
Jun 12, 2023
2 changes: 2 additions & 0 deletions gateway/src/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ impl Subnet {
self.stake += value;
if self.stake < st.min_stake {
self.status = Status::Inactive;
} else {
self.status = Status::Active;
}
st.flush_subnet(rt.store(), self)?;
Ok(())
Expand Down
5 changes: 5 additions & 0 deletions gateway/tests/gateway_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ fn release_stake() {
ExitCode::USR_ILLEGAL_STATE,
)
.unwrap();

// Add some stake to see if we activate again
h.add_stake(&mut rt, &shid, &value, ExitCode::OK).unwrap();
let subnet = h.get_subnet(&rt, &shid).unwrap();
assert_eq!(subnet.status, Active);
}

#[test]
Expand Down
5 changes: 5 additions & 0 deletions subnet-actor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ impl SubnetActor for Actor {
return Err(actor_error!(illegal_state, "not validator"));
}

// always translate to f0-based SubnetID
let mut ch = ch;
ch.enforce_f0_source(rt)
.map_err(|_| actor_error!(illegal_argument, "cannot translate source subnetID"))?;

state
.verify_checkpoint(rt, &ch)
.map_err(|e| actor_error!(illegal_state, format!("checkpoint failed: {}", e)))?;
Expand Down