Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

allowed proxies #75

Merged
merged 2 commits into from
Jul 28, 2023
Merged
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
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions pallet-ismp/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

//! Host implementation for ISMP
use crate::{
dispatcher::Receipt, primitives::ConsensusClientProvider, ChallengePeriod, Config,
ConsensusClientUpdateTime, ConsensusStateClient, ConsensusStates, FrozenConsensusClients,
FrozenHeights, LatestStateMachineHeight, Nonce, RequestCommitments, RequestReceipts,
ResponseReceipts, StateCommitments, UnbondingPeriod,
dispatcher::Receipt, primitives::ConsensusClientProvider, AllowedProxies, ChallengePeriod,
Config, ConsensusClientUpdateTime, ConsensusStateClient, ConsensusStates,
FrozenConsensusClients, FrozenHeights, LatestStateMachineHeight, Nonce, RequestCommitments,
RequestReceipts, ResponseReceipts, StateCommitments, UnbondingPeriod,
};
use alloc::{format, string::ToString};
use core::time::Duration;
Expand Down Expand Up @@ -250,4 +250,12 @@ where
ChallengePeriod::<T>::insert(consensus_state_id, period);
Ok(())
}

fn allowed_proxies(&self) -> Vec<StateMachine> {
AllowedProxies::<T>::get()
}

fn store_allowed_proxies(&self, allowed: Vec<StateMachine>) {
AllowedProxies::<T>::set(allowed);
}
}
18 changes: 17 additions & 1 deletion pallet-ismp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ pub mod pallet {

/// Configurable router that dispatches calls to modules
type IsmpRouter: IsmpRouter + Default;

/// Provides concrete implementations of consensus clients
type ConsensusClientProvider: ConsensusClientProvider;

Expand Down Expand Up @@ -205,6 +204,11 @@ pub mod pallet {
pub type LatestStateMachineHeight<T: Config> =
StorageMap<_, Blake2_128Concat, StateMachineId, u64, ValueQuery>;

/// Bounded vec of allowed proxies
#[pallet::storage]
#[pallet::getter(fn allowed_proxies)]
pub type AllowedProxies<T: Config> = StorageValue<_, Vec<StateMachine>, ValueQuery>;

/// Holds the timestamp at which a consensus client was recently updated.
/// Used in ensuring that the configured challenge period elapses.
#[pallet::storage]
Expand Down Expand Up @@ -365,6 +369,18 @@ pub mod pallet {

Ok(())
}

/// Set the allowed proxies
#[pallet::weight(<T as frame_system::Config>::DbWeight::get().writes(1))]
#[pallet::call_index(3)]
pub fn set_config(origin: OriginFor<T>, allowed: Vec<StateMachine>) -> DispatchResult {
T::AdminOrigin::ensure_origin(origin)?;

let host = Host::<T>::default();
host.store_allowed_proxies(allowed);

Ok(())
}
}

#[pallet::event]
Expand Down