This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Contracts module rejig #1358
Merged
Merged
Contracts module rejig #1358
Changes from 114 commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
429a030
Move prepare under code.
pepyakin 169c5e8
Schedule update
pepyakin eb64e5e
CodeHash
pepyakin f79aa14
create takes code_hash
pepyakin 32bbbbd
pass mem def and use code in vm::execute
pepyakin 7f5df27
Actually save and load code
pepyakin ee53c8c
Use T::Hash as CodeHash
pepyakin 045b1d8
Explicit entrypoint name
pepyakin 1c846b7
Return code_hash and deposit an Event
pepyakin 29fd7b2
Charge for deployed code with gas.
pepyakin 40163e4
ImportSatisfyCheck and FunctionImplProvider
pepyakin f7b28b3
Progress.
pepyakin 0a08178
Use new infrastructure for checking imports
pepyakin 487c630
Rename entrypoint to entrypoint_name
pepyakin 62e7b5d
Use strings instead of a Error enum
pepyakin 09d9a2b
Clean
pepyakin e520a2d
WIP
pepyakin c1e0018
Fix macro_define_env test.
pepyakin 9738d81
Fix vm code tests.
pepyakin 56f0c4f
Remove tests for now.
pepyakin 2d8dd9c
Fix borked merge
pepyakin 601359d
Fix build for wasm
pepyakin 4271c48
fmt
pepyakin 56280a0
Scaffolding for abstracting vm.
pepyakin 7053d29
Hook up execution to exec layer.
pepyakin e629768
Fix vm tests.
pepyakin cef469f
Use schedule directly in WasmLoader
pepyakin e1969ae
Implement test language.
pepyakin bbb50cd
Add input_data test.
pepyakin 53ca6be
Max depth test
pepyakin 3324b8e
ext_caller
pepyakin c851fd6
Simplify test.
pepyakin 2c025f7
Add TODO
pepyakin d43d5e3
Some tests and todos.
pepyakin 09ca3b5
top_level
pepyakin 4a12044
Clean.
pepyakin 700cf43
Restore a couple of integration tests.
pepyakin 8f58d0e
Add a few comments.
pepyakin 34a26b0
Add ext_address runtime call.
pepyakin 6519b69
Deduplicate caller/self_account
pepyakin f40a2c7
Add not_exists test.
pepyakin f2727a3
Change bool to TransferCause.
pepyakin ddf9658
Add address tests.
pepyakin b6ded65
Remove output_buf from parameter.
pepyakin 5b62988
return from start fn.
pepyakin b5fd8dc
Smart gas meter
pepyakin 8b1f113
Tracing
pepyakin e2559c6
Fix prepare tests.
pepyakin a07066a
Code moving
pepyakin de81162
Add ExecFeeToken
pepyakin 97eb2a9
Use tokens everywhere.
pepyakin 16351ca
Make it compile in no_std.
pepyakin d9d2769
Lift all test requirements to TestAuxiliaries
pepyakin 81be0fd
A minor clean
pepyakin 7451166
First create tests
pepyakin bf094c7
Remove unneeded TODO
pepyakin 5239bf8
Docs.
pepyakin 46ac8fa
Code shuffling
pepyakin e17b369
Rename create → instantiate
pepyakin 6d5e0aa
Add test address.
pepyakin f48f565
Merge remote-tracking branch 'origin/master' into ser-putcode-model
pepyakin 5365d8b
Code shuffling
pepyakin 224fadf
Add base_fee tests.
pepyakin 01390c7
rejig the code
pepyakin 3f6b174
Add some comments
pepyakin 83e4ee1
on_finalise comment
pepyakin 452977d
Move event deposit further
pepyakin 0af6aa8
Update Cargo.lock
pepyakin a5a5d20
Use crates.io version of pwasm-utils
pepyakin af9427b
Format todo comments
pepyakin 89932cd
Fix formatting
pepyakin 9265e73
Comments
pepyakin 56e9969
EmptyOutputBuf and OutputBuf split.
pepyakin 755fccd
Restore code_hash
pepyakin d3693df
Fix node-executor.
pepyakin f807766
Fix typo
pepyakin e58fa2c
Fix fmt
pepyakin 088ec93
Merge remote-tracking branch 'origin/master'
pepyakin 2cbf622
Update srml/contract/src/account_db.rs
gnunicorn 785bbb9
Update srml/contract/src/lib.rs
gnunicorn 4e2e443
Line wraps
pepyakin a2fada6
Wrapping macros
pepyakin d8f433f
Add _ prefix
pepyakin bf2c8ae
Grumbles
pepyakin 7c8d487
Doc updates.
pepyakin 25cce89
Update srml/contract/src/wasm/mod.rs
gnunicorn a9fc6ef
Update srml/contract/src/lib.rs
gnunicorn c166e74
Merge branch 'ser-putcode-model' of github.com:paritytech/substrate i…
pepyakin cad39fe
Add comment
pepyakin bbbac91
Use saturation to signal overflow
pepyakin 09e4a99
Add prepare_test! macro
pepyakin 0087a63
Require deploy function.
pepyakin 260665d
Add entry point tests
pepyakin 59a2a76
Add comment.
pepyakin b666bd6
Rename code → code_cache to better describe
pepyakin 9b13600
Get rid of weird match!
pepyakin c351d9e
Recompile binaries
pepyakin 49e4d04
Add comments
pepyakin 1ebe45f
refuse_instantiate_with_value_below_existential_deposit
pepyakin 7d76184
Little fix
pepyakin 7b40828
Make test more complete
pepyakin 1aa7dc7
Clean
pepyakin 66e2cc6
Add integration test for instantiation
pepyakin fd085c7
Merge remote-tracking branch 'origin/master' into ser-putcode-model
pepyakin 9974158
Rebuild runtime.
pepyakin e19d643
Merge remote-tracking branch 'origin/master' into ser-putcode-model
pepyakin 27f9d5f
Add some tests.
pepyakin 1401dec
Attach an issue to a TODO
pepyakin 449f5ad
Attach another issue
pepyakin 34a1698
Apply suggestions from code review
gnunicorn 8108d87
Update srml/contract/src/exec.rs
gnunicorn 930cbf2
Update srml/contract/src/exec.rs
gnunicorn 40cf826
Recompile node_runtime
pepyakin 8cc6f33
Merge remote-tracking branch 'origin/master' into ser-putcode-model
pepyakin 7c9c8a6
Merge and fix merge conflicts
pepyakin 41f769a
Merge and fix conflicts
pepyakin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file modified
BIN
+19.6 KB
(100%)
node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <[email protected]>"] | |
|
||
[dependencies] | ||
serde = { version = "1.0", default-features = false } | ||
pwasm-utils = { version = "0.3", default-features = false } | ||
pwasm-utils = { version = "0.6.1", default-features = false } | ||
parity-codec = { version = "2.1", default-features = false } | ||
parity-codec-derive = { version = "2.1", default-features = false } | ||
parity-wasm = { version = "0.31", default-features = false } | ||
|
@@ -21,6 +21,7 @@ srml-balances = { path = "../balances", default-features = false } | |
[dev-dependencies] | ||
wabt = "~0.7.4" | ||
assert_matches = "1.1" | ||
hex-literal = "0.1.0" | ||
|
||
[features] | ||
default = ["std"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
|
||
//! Auxilliaries to help with managing partial changes to accounts state. | ||
|
||
use super::{CodeOf, StorageOf, Trait}; | ||
use super::{CodeHash, CodeHashOf, StorageOf, Trait}; | ||
use rstd::cell::RefCell; | ||
use rstd::collections::btree_map::{BTreeMap, Entry}; | ||
use rstd::prelude::*; | ||
|
@@ -25,7 +25,8 @@ use {balances, system}; | |
|
||
pub struct ChangeEntry<T: Trait> { | ||
balance: Option<T::Balance>, | ||
code: Option<Vec<u8>>, | ||
/// In the case the outer option is None, the code_hash remains untouched, while providing `Some(None)` signifies a removing of the code in question | ||
code: Option<Option<CodeHash<T>>>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not introduce an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this code was written in this style because there is some usage of |
||
storage: BTreeMap<Vec<u8>, Option<Vec<u8>>>, | ||
} | ||
|
||
|
@@ -44,7 +45,7 @@ pub type ChangeSet<T> = BTreeMap<<T as system::Trait>::AccountId, ChangeEntry<T> | |
|
||
pub trait AccountDb<T: Trait> { | ||
fn get_storage(&self, account: &T::AccountId, location: &[u8]) -> Option<Vec<u8>>; | ||
fn get_code(&self, account: &T::AccountId) -> Vec<u8>; | ||
fn get_code(&self, account: &T::AccountId) -> Option<CodeHash<T>>; | ||
fn get_balance(&self, account: &T::AccountId) -> T::Balance; | ||
|
||
fn commit(&mut self, change_set: ChangeSet<T>); | ||
|
@@ -55,8 +56,8 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb { | |
fn get_storage(&self, account: &T::AccountId, location: &[u8]) -> Option<Vec<u8>> { | ||
<StorageOf<T>>::get(account.clone(), location.to_vec()) | ||
} | ||
fn get_code(&self, account: &T::AccountId) -> Vec<u8> { | ||
<CodeOf<T>>::get(account) | ||
fn get_code(&self, account: &T::AccountId) -> Option<CodeHash<T>> { | ||
<CodeHashOf<T>>::get(account) | ||
} | ||
fn get_balance(&self, account: &T::AccountId) -> T::Balance { | ||
balances::Module::<T>::free_balance(account) | ||
|
@@ -68,13 +69,17 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb { | |
balances::Module::<T>::set_free_balance_creating(&address, balance) | ||
{ | ||
// Account killed. This will ultimately lead to calling `OnFreeBalanceZero` callback | ||
// which will make removal of CodeOf and StorageOf for this account. | ||
// which will make removal of CodeHashOf and StorageOf for this account. | ||
// In order to avoid writing over the deleted properties we `continue` here. | ||
continue; | ||
} | ||
} | ||
if let Some(code) = changed.code { | ||
<CodeOf<T>>::insert(&address, &code); | ||
if let Some(code) = code { | ||
<CodeHashOf<T>>::insert(&address, code); | ||
} else { | ||
<CodeHashOf<T>>::remove(&address); | ||
} | ||
} | ||
for (k, v) in changed.storage.into_iter() { | ||
if let Some(value) = v { | ||
|
@@ -116,7 +121,7 @@ impl<'a, T: Trait> OverlayAccountDb<'a, T> { | |
.storage | ||
.insert(location, value); | ||
} | ||
pub fn set_code(&mut self, account: &T::AccountId, code: Vec<u8>) { | ||
pub fn set_code(&mut self, account: &T::AccountId, code: Option<CodeHash<T>>) { | ||
self.local | ||
.borrow_mut() | ||
.entry(account.clone()) | ||
|
@@ -141,7 +146,7 @@ impl<'a, T: Trait> AccountDb<T> for OverlayAccountDb<'a, T> { | |
.cloned() | ||
.unwrap_or_else(|| self.underlying.get_storage(account, location)) | ||
} | ||
fn get_code(&self, account: &T::AccountId) -> Vec<u8> { | ||
fn get_code(&self, account: &T::AccountId) -> Option<CodeHash<T>> { | ||
self.local | ||
.borrow() | ||
.get(account) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is rust not complaining that his pub structs doesn't have appropriate docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason is although it's public it is not exported, thus even if we leave doc here it will not be externally visible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possibility is that we don't have
#![deny(missing_docs)]
in this crate : )