Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
13839ce
Add a simple direct storage access module
pepyakin Dec 16, 2019
34e363f
WIP
pepyakin Dec 17, 2019
f528e8d
Completely migrate to the transactional system.
pepyakin Dec 18, 2019
3b2d311
Format
pepyakin Dec 18, 2019
f83e656
Fix wasm compilation
pepyakin Dec 18, 2019
4d7b8fb
Get rid of account_db module
pepyakin Dec 18, 2019
4d59704
Make deposit event eager
pepyakin Dec 19, 2019
4c9f607
Make restore_to eager
pepyakin Dec 19, 2019
86c8b32
It almost compiles.
pepyakin Jun 11, 2020
125ba66
Make it compile.
pepyakin Jun 11, 2020
5b2c571
Make the tests compile
pepyakin Jun 11, 2020
3a6edb4
Get rid of account_db
pepyakin Jun 11, 2020
57aa37c
Drop the result.
pepyakin Jun 11, 2020
73dce0c
Backport the book keeping.
pepyakin Jun 11, 2020
571ea1f
Fix all remaining tests.
pepyakin Jun 11, 2020
f68bff9
Make it compile for std
pepyakin Jun 12, 2020
d3d2351
Remove a stale TODO marker
pepyakin Jun 17, 2020
a2ff223
Remove another stale TODO
pepyakin Jun 17, 2020
0b4b7ac
Add proof for `terminate`
pepyakin Jun 17, 2020
9755c6d
Remove a stale comment.
pepyakin Jun 17, 2020
164a767
Make restoration diverging.
pepyakin Jun 17, 2020
b21f66f
Remove redudnant trait: `ComputeDispatchFee`
pepyakin Jun 19, 2020
04ca866
Update frame/contracts/src/exec.rs
pepyakin Jun 19, 2020
cefce04
Introduce proper errors into the storage module.
pepyakin Jun 19, 2020
d767cb9
Adds comments for contract storage module.
pepyakin Jun 19, 2020
4166768
Inline `ExecutionContext::terminate`.
pepyakin Jun 19, 2020
e54d6a9
Restore_to should not let sacrifice itself if the contract present on…
pepyakin Jun 19, 2020
92b9706
Inline `transfer` function
pepyakin Jun 19, 2020
d34fad6
Update doc - add "if succeeded"
pepyakin Jun 19, 2020
4e58ce5
Adapt to TransactionOutcome changes
athei Jun 23, 2020
f9e4674
Updates the docs for `ext_restore_to`
pepyakin Jun 23, 2020
8893488
Add a proper assert.
pepyakin Jun 23, 2020
68a56dc
Update frame/contracts/src/wasm/runtime.rs
pepyakin Jun 23, 2020
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
Prev Previous commit
Next Next commit
Format
  • Loading branch information
pepyakin authored and athei committed Jun 23, 2020
commit 3b2d3117bbfcaef8d6f9d24d4a58d67ab46cc87b
19 changes: 14 additions & 5 deletions frame/contracts/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use crate::{
exec::{AccountIdOf, StorageKey},
ContractInfo, AliveContractInfo, BalanceOf, CodeHash, ContractInfoOf, Trait, TrieId,
AliveContractInfo, BalanceOf, CodeHash, ContractInfo, ContractInfoOf, Trait, TrieId,
};
use sp_io::hashing::blake2_256;
use sp_runtime::traits::Bounded;
Expand All @@ -26,13 +26,20 @@ pub fn read_contract_storage(trie_id: &TrieId, key: &StorageKey) -> Option<Vec<u
child::get_raw(trie_id, &blake2_256(key))
}

pub fn write_contract_storage<T: Trait>(account: &AccountIdOf<T>, trie_id: &TrieId, key: &StorageKey, value: Option<Vec<u8>>) {
pub fn write_contract_storage<T: Trait>(
account: &AccountIdOf<T>,
trie_id: &TrieId,
key: &StorageKey,
value: Option<Vec<u8>>,
) {
let hashed_key = blake2_256(key);

// We need to accurately track the size of the storage of the contract.
//
// For that we query the previous value and get its size.
let existing_size = child::get_raw(trie_id, &hashed_key).map(|v| v.len()).unwrap_or(0);
let existing_size = child::get_raw(trie_id, &hashed_key)
.map(|v| v.len())
.unwrap_or(0);
let new_size = match value {
Some(v) => {
child::put_raw(trie_id, &hashed_key, &v);
Expand All @@ -50,7 +57,7 @@ pub fn write_contract_storage<T: Trait>(account: &AccountIdOf<T>, trie_id: &Trie
alive_info.storage_size -= existing_size as u32;
alive_info.storage_size += new_size as u32;
alive_info.last_write = Some(<system::Module<T>>::block_number());
},
}
_ => panic!(), // TODO: Justify this.
}
});
Expand All @@ -63,7 +70,9 @@ pub fn rent_allowance<T: Trait>(account: &AccountIdOf<T>) -> Option<BalanceOf<T>
pub fn set_rent_allowance<T: Trait>(account: &AccountIdOf<T>, rent_allowance: BalanceOf<T>) {
<ContractInfoOf<T>>::mutate(account, |maybe_contract_info| {
match maybe_contract_info {
Some(ContractInfo::Alive(ref mut alive_info)) => alive_info.rent_allowance = rent_allowance,
Some(ContractInfo::Alive(ref mut alive_info)) => {
alive_info.rent_allowance = rent_allowance
}
_ => panic!(), // TODO: Justify this.
}
})
Expand Down