Skip to content

Commit

Permalink
rusk-recovery: Remove governance-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
moCello committed May 27, 2024
1 parent 754a626 commit 5428129
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 112 deletions.
12 changes: 0 additions & 12 deletions rusk-recovery/config/example_gov.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
[[governance]]
contract_address = 3
name = "security_1"
authority = "22uowXa4bAwa9uehMFoSZjGCDTUSLGhFjCWxrEGHng8kWsEJSQBZxcCa8PeGMdTXWt9XyYNEx4S85XrGwfE8G1iG5j1ptEU4sSu1Hq3QKHsnBEZwTDLNBQeesSfmUadSjfRh"
broker = "GrVMPSMnnMeuHnG2i1Vgqw1vMMbfd15NNTV7hbSM19Rt"

[[governance]]
contract_address = 4
name = "security_2"
authority = "uazLgN2HtLqaDZCxAtJtkkurQTXyZWXjQYJ3HdSVbpBjGRzMvKaqvpx3MRw8HTv7bTwyviLosEJAa56G66cdNjL4CJdqTUyFHdufzWWfLz9E7eF97tdc6jZsVTiGXGNGf2E"
broker = "BzmjwPNbgWDKHxkVrGtiHyo18c9UZgtGm246GCAsHk43"

[[balance]]
address = '5i9RZjT87TLa1BtWXRRoFy3FoMzFHiXT3GWasHdUaxuo3YapUKYeXXiY1yuAeKng2hmxxaYsGNhKhjyrE9KYTSE7'
seed = 0xdead_beef
Expand Down
47 changes: 1 addition & 46 deletions rusk-recovery/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use std::path::Path;
use tracing::info;
use url::Url;

pub use snapshot::{Balance, GenesisStake, Governance, Snapshot};
pub use snapshot::{Balance, GenesisStake, Snapshot};
use stake_contract_types::StakeData;
use transfer_contract_types::Mint;

Expand All @@ -48,47 +48,6 @@ pub static FAUCET_KEY: Lazy<PublicKey> = Lazy::new(|| {
PublicKey::from_slice(&bytes).expect("faucet should have a valid key")
});

fn deploy_governance_contract(
session: &mut Session,
governance: &Governance,
) -> Result<(), Box<dyn Error>> {
let contract_id = governance.contract();
let bytecode = include_bytes!(
"../../target/wasm32-unknown-unknown/release/governance_contract.wasm"
);

let theme = Theme::default();
info!(
"{} {} governance to {}",
theme.action("Deploying"),
governance.name,
hex::encode(contract_id)
);
session.deploy(
bytecode,
ContractData::builder()
.owner(governance.owner())
.contract_id(contract_id),
u64::MAX,
)?;

// Set the broker and the authority of the governance contract
session.call::<_, ()>(
contract_id,
"set_broker",
governance.broker(),
u64::MAX,
)?;
session.call::<_, ()>(
contract_id,
"set_authority",
governance.authority(),
u64::MAX,
)?;

Ok(())
}

fn generate_transfer_state(
session: &mut Session,
snapshot: &Snapshot,
Expand Down Expand Up @@ -263,10 +222,6 @@ pub fn deploy<P: AsRef<Path>>(
generate_transfer_state(&mut session, snapshot)?;
generate_stake_state(&mut session, snapshot)?;

for governance in snapshot.governance_contracts() {
deploy_governance_contract(&mut session, governance)?;
}

info!("{} persisted id", theme.success("Storing"));
let commit_id = session.commit()?;
fs::write(state_id_path, commit_id)?;
Expand Down
9 changes: 0 additions & 9 deletions rusk-recovery/src/state/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ use phoenix_core::PublicKey;
use rusk_abi::dusk::Dusk;
use serde_derive::{Deserialize, Serialize};

mod governance;
mod stake;
mod wrapper;

use crate::state;
pub use stake::GenesisStake;
use wrapper::Wrapper;

pub use self::governance::Governance;

#[derive(Serialize, Deserialize, PartialEq, Eq)]
pub struct Balance {
address: Wrapper<PublicKey, { PublicKey::SIZE }>,
Expand All @@ -45,8 +42,6 @@ pub struct Snapshot {
balance: Vec<Balance>,
#[serde(skip_serializing_if = "Vec::is_empty", default = "Vec::new")]
stake: Vec<GenesisStake>,
#[serde(skip_serializing_if = "Vec::is_empty", default = "Vec::new")]
governance: Vec<Governance>,
}

impl Debug for Snapshot {
Expand Down Expand Up @@ -79,10 +74,6 @@ impl Snapshot {
pub fn base_state(&self) -> Option<&str> {
self.base_state.as_deref()
}

pub fn governance_contracts(&self) -> impl Iterator<Item = &Governance> {
self.governance.iter()
}
}

#[cfg(test)]
Expand Down
45 changes: 0 additions & 45 deletions rusk-recovery/src/state/snapshot/governance.rs

This file was deleted.

0 comments on commit 5428129

Please sign in to comment.