diff --git a/rusk-recovery/config/example_gov.toml b/rusk-recovery/config/example_gov.toml index a333b26ab7..96a1088997 100644 --- a/rusk-recovery/config/example_gov.toml +++ b/rusk-recovery/config/example_gov.toml @@ -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 diff --git a/rusk-recovery/src/state.rs b/rusk-recovery/src/state.rs index 2618606ccd..bb2e5a69dc 100644 --- a/rusk-recovery/src/state.rs +++ b/rusk-recovery/src/state.rs @@ -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; @@ -48,47 +48,6 @@ pub static FAUCET_KEY: Lazy = Lazy::new(|| { PublicKey::from_slice(&bytes).expect("faucet should have a valid key") }); -fn deploy_governance_contract( - session: &mut Session, - governance: &Governance, -) -> Result<(), Box> { - 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, @@ -263,10 +222,6 @@ pub fn deploy>( 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)?; diff --git a/rusk-recovery/src/state/snapshot.rs b/rusk-recovery/src/state/snapshot.rs index 84b0af9999..ab1388c13e 100644 --- a/rusk-recovery/src/state/snapshot.rs +++ b/rusk-recovery/src/state/snapshot.rs @@ -11,7 +11,6 @@ use phoenix_core::PublicKey; use rusk_abi::dusk::Dusk; use serde_derive::{Deserialize, Serialize}; -mod governance; mod stake; mod wrapper; @@ -19,8 +18,6 @@ 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, @@ -45,8 +42,6 @@ pub struct Snapshot { balance: Vec, #[serde(skip_serializing_if = "Vec::is_empty", default = "Vec::new")] stake: Vec, - #[serde(skip_serializing_if = "Vec::is_empty", default = "Vec::new")] - governance: Vec, } impl Debug for Snapshot { @@ -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 { - self.governance.iter() - } } #[cfg(test)] diff --git a/rusk-recovery/src/state/snapshot/governance.rs b/rusk-recovery/src/state/snapshot/governance.rs deleted file mode 100644 index 3083761faa..0000000000 --- a/rusk-recovery/src/state/snapshot/governance.rs +++ /dev/null @@ -1,45 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -use bls12_381_bls::PublicKey as BlsPublicKey; -use dusk_bytes::Serializable; -use jubjub_schnorr::PublicKey as SchnorrPublicKey; -use phoenix_core::PublicKey; -use rusk_abi::ContractId; -use serde_derive::{Deserialize, Serialize}; - -use super::wrapper::Wrapper; -use crate::state; - -#[derive(Serialize, Deserialize, PartialEq, Eq)] -pub struct Governance { - pub(crate) contract_owner: Option>, - pub contract_address: u64, - pub name: String, - pub(crate) authority: Wrapper, - pub(crate) broker: Wrapper, -} - -impl Governance { - pub fn owner(&self) -> [u8; PublicKey::SIZE] { - let dusk = Wrapper::from(*state::DUSK_KEY); - self.contract_owner.as_ref().unwrap_or(&dusk).to_bytes() - } - - pub fn authority(&self) -> &BlsPublicKey { - &self.authority - } - pub fn broker(&self) -> &SchnorrPublicKey { - &self.broker - } - - pub fn contract(&self) -> ContractId { - let mut data = [0u8; 32]; - let address = self.contract_address.to_be_bytes(); - data[24..].copy_from_slice(&address); - ContractId::from(data) - } -}