Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kvinwang committed Oct 8, 2023
1 parent a42f5c5 commit c253492
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 1,828 deletions.
5 changes: 3 additions & 2 deletions crates/phala-trie-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ use std::iter::FromIterator;
use parity_scale_codec::Codec;
use sp_core::storage::ChildInfo;
use sp_core::Hasher;
use sp_state_machine::{Backend, BackendTransaction, IterArgs, TrieBackend, TrieBackendBuilder};
use sp_state_machine::{Backend, IterArgs, TrieBackend, TrieBackendBuilder};
use sp_trie::{trie_types::TrieDBMutBuilderV0 as TrieDBMutBuilder, TrieMut};

pub use memdb::GenericMemoryDB as MemoryDB;
pub use sp_state_machine::BackendTransaction;

/// Storage key.
pub type StorageKey = Vec<u8>;
Expand Down Expand Up @@ -152,7 +153,7 @@ where
}

/// Apply storage changes calculated from `calc_root_if_changes`.
pub fn apply_changes(&mut self, root: H::Out, transaction: MemoryDB<H>) {
pub fn apply_changes(&mut self, root: H::Out, transaction: BackendTransaction<H>) {
let mut storage = core::mem::take(self).0.into_storage();
storage.consolidate(transaction);
let _ = core::mem::replace(&mut self.0, TrieBackendBuilder::new(storage, root).build());
Expand Down
1 change: 1 addition & 0 deletions crates/phala-trie-storage/src/memdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::{borrow::Borrow, cmp::Eq, hash, marker::PhantomData};

use sp_state_machine::{DefaultError, TrieBackendStorage};
use trie_db::DBValue;
use sp_trie::PrefixedMemoryDB;

pub trait MaybeDebug: std::fmt::Debug {}
impl<T: std::fmt::Debug> MaybeDebug for T {}
Expand Down
15 changes: 5 additions & 10 deletions crates/pink/runtime/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mod extension;
mod pallet_pink;
mod weights;

use crate::types::{AccountId, Balance, BlockNumber, Hash, Hashing, Nonce};
use frame_support::{
Expand All @@ -10,7 +9,8 @@ use frame_support::{
};
use log::info;
use pallet_contracts::{
migration::{v09, v10, v11, v12},
migration::{v11, v12},
weights::SubstrateWeight,
Config, Frame, Migration, Schedule,
};
use sp_runtime::{traits::IdentityLookup, Perbill};
Expand Down Expand Up @@ -68,7 +68,7 @@ impl pallet_balances::Config for PinkRuntime {
type FreezeIdentifier = ();
type MaxHolds = ();
type MaxFreezes = ();
type RuntimeHoldReason = ();
type RuntimeHoldReason = RuntimeHoldReason;
}

impl frame_system::Config for PinkRuntime {
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Config for PinkRuntime {
type CallFilter = frame_support::traits::Nothing;
type CallStack = [Frame<Self>; 5];
type WeightPrice = Pink;
type WeightInfo = weights::PinkWeights<Self>;
type WeightInfo = SubstrateWeight<Self>;
type ChainExtension = extension::PinkExtension;
type Schedule = DefaultSchedule;
type DepositPerByte = DepositPerStorageByte;
Expand All @@ -153,12 +153,7 @@ impl Config for PinkRuntime {
type MaxStorageKeyLen = MaxStorageKeyLen;
type UnsafeUnstableInterface = ConstBool<false>;
type MaxDebugBufferLen = MaxDebugBufferLen;
type Migrations = (
v09::Migration<Self>,
v10::Migration<Self>,
v11::Migration<Self>,
v12::Migration<Self, Balances>,
);
type Migrations = (v11::Migration<Self>, v12::Migration<Self, Balances>);
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type MaxDelegateDependencies = ConstU32<32>;
type RuntimeHoldReason = RuntimeHoldReason;
Expand Down
5 changes: 0 additions & 5 deletions crates/pink/runtime/src/runtime/pallet_pink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ pub mod pallet {
);
UncheckedFrom::unchecked_from(<T as frame_system::Config>::Hashing::hash(&buf))
}

fn deposit_address(contract_addr: &T::AccountId) -> T::AccountId {
let entropy = (b"contract_depo_v1", contract_addr).using_encoded(T::Hashing::hash);
UncheckedFrom::unchecked_from(entropy)
}
}

impl<T: Config> Pallet<T> {
Expand Down
Loading

0 comments on commit c253492

Please sign in to comment.