Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
c79e4bdf
Unverified
Commit
c79e4bdf
authored
Apr 21, 2020
by
cheme
Committed by
GitHub
Apr 21, 2020
Browse files
Companion to child trie api change #4857 (#950)
parent
5ac55efc
Pipeline
#88799
failed with stages
in 1 minute and 48 seconds
Changes
8
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
c79e4bdf
This diff is collapsed.
Click to expand it.
parachain/src/wasm_executor/mod.rs
View file @
c79e4bdf
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
use
std
::
any
::{
TypeId
,
Any
};
use
std
::
any
::{
TypeId
,
Any
};
use
crate
::
primitives
::{
ValidationParams
,
ValidationResult
,
UpwardMessage
};
use
crate
::
primitives
::{
ValidationParams
,
ValidationResult
,
UpwardMessage
};
use
codec
::{
Decode
,
Encode
};
use
codec
::{
Decode
,
Encode
};
use
sp_core
::
storage
::
{
ChildStorageKey
,
ChildInfo
}
;
use
sp_core
::
storage
::
ChildInfo
;
use
sp_core
::
traits
::
CallInWasm
;
use
sp_core
::
traits
::
CallInWasm
;
use
sp_wasm_interface
::
HostFunctions
as
_
;
use
sp_wasm_interface
::
HostFunctions
as
_
;
...
@@ -205,15 +205,15 @@ impl sp_externalities::Externalities for ValidationExternalities {
...
@@ -205,15 +205,15 @@ impl sp_externalities::Externalities for ValidationExternalities {
panic!
(
"storage_hash: unsupported feature for parachain validation"
)
panic!
(
"storage_hash: unsupported feature for parachain validation"
)
}
}
fn
child_storage_hash
(
&
self
,
_
:
ChildStorageKey
,
_
:
ChildInfo
,
_
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
fn
child_storage_hash
(
&
self
,
_
:
&
ChildInfo
,
_
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
panic!
(
"child_storage_hash: unsupported feature for parachain validation"
)
panic!
(
"child_storage_hash: unsupported feature for parachain validation"
)
}
}
fn
child_storage
(
&
self
,
_
:
ChildStorageKey
,
_
:
ChildInfo
,
_
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
fn
child_storage
(
&
self
,
_
:
&
ChildInfo
,
_
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
panic!
(
"child_storage: unsupported feature for parachain validation"
)
panic!
(
"child_storage: unsupported feature for parachain validation"
)
}
}
fn
kill_child_storage
(
&
mut
self
,
_
:
ChildStorageKey
,
_
:
ChildInfo
)
{
fn
kill_child_storage
(
&
mut
self
,
_
:
&
ChildInfo
)
{
panic!
(
"kill_child_storage: unsupported feature for parachain validation"
)
panic!
(
"kill_child_storage: unsupported feature for parachain validation"
)
}
}
...
@@ -221,7 +221,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
...
@@ -221,7 +221,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
panic!
(
"clear_prefix: unsupported feature for parachain validation"
)
panic!
(
"clear_prefix: unsupported feature for parachain validation"
)
}
}
fn
clear_child_prefix
(
&
mut
self
,
_
:
ChildStorageKey
,
_
:
ChildInfo
,
_
:
&
[
u8
])
{
fn
clear_child_prefix
(
&
mut
self
,
_
:
&
ChildInfo
,
_
:
&
[
u8
])
{
panic!
(
"clear_child_prefix: unsupported feature for parachain validation"
)
panic!
(
"clear_child_prefix: unsupported feature for parachain validation"
)
}
}
...
@@ -229,7 +229,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
...
@@ -229,7 +229,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
panic!
(
"place_storage: unsupported feature for parachain validation"
)
panic!
(
"place_storage: unsupported feature for parachain validation"
)
}
}
fn
place_child_storage
(
&
mut
self
,
_
:
ChildStorageKey
,
_
:
ChildInfo
,
_
:
Vec
<
u8
>
,
_
:
Option
<
Vec
<
u8
>>
)
{
fn
place_child_storage
(
&
mut
self
,
_
:
&
ChildInfo
,
_
:
Vec
<
u8
>
,
_
:
Option
<
Vec
<
u8
>>
)
{
panic!
(
"place_child_storage: unsupported feature for parachain validation"
)
panic!
(
"place_child_storage: unsupported feature for parachain validation"
)
}
}
...
@@ -241,7 +241,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
...
@@ -241,7 +241,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
panic!
(
"storage_root: unsupported feature for parachain validation"
)
panic!
(
"storage_root: unsupported feature for parachain validation"
)
}
}
fn
child_storage_root
(
&
mut
self
,
_
:
Child
StorageKey
)
->
Vec
<
u8
>
{
fn
child_storage_root
(
&
mut
self
,
_
:
&
Child
Info
)
->
Vec
<
u8
>
{
panic!
(
"child_storage_root: unsupported feature for parachain validation"
)
panic!
(
"child_storage_root: unsupported feature for parachain validation"
)
}
}
...
@@ -249,7 +249,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
...
@@ -249,7 +249,7 @@ impl sp_externalities::Externalities for ValidationExternalities {
panic!
(
"storage_changes_root: unsupported feature for parachain validation"
)
panic!
(
"storage_changes_root: unsupported feature for parachain validation"
)
}
}
fn
next_child_storage_key
(
&
self
,
_
:
ChildStorageKey
,
_
:
ChildInfo
,
_
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
fn
next_child_storage_key
(
&
self
,
_
:
&
ChildInfo
,
_
:
&
[
u8
])
->
Option
<
Vec
<
u8
>>
{
panic!
(
"next_child_storage_key: unsupported feature for parachain validation"
)
panic!
(
"next_child_storage_key: unsupported feature for parachain validation"
)
}
}
...
...
runtime/common/src/crowdfund.rs
View file @
c79e4bdf
...
@@ -80,7 +80,6 @@ use sp_runtime::{ModuleId,
...
@@ -80,7 +80,6 @@ use sp_runtime::{ModuleId,
use
crate
::
slots
;
use
crate
::
slots
;
use
codec
::{
Encode
,
Decode
};
use
codec
::{
Encode
,
Decode
};
use
sp_std
::
vec
::
Vec
;
use
sp_std
::
vec
::
Vec
;
use
sp_core
::
storage
::
well_known_keys
::
CHILD_STORAGE_KEY_PREFIX
;
use
primitives
::
parachain
::{
Id
as
ParaId
,
HeadData
};
use
primitives
::
parachain
::{
Id
as
ParaId
,
HeadData
};
const
MODULE_ID
:
ModuleId
=
ModuleId
(
*
b"py/cfund"
);
const
MODULE_ID
:
ModuleId
=
ModuleId
(
*
b"py/cfund"
);
...
@@ -529,46 +528,30 @@ impl<T: Trait> Module<T> {
...
@@ -529,46 +528,30 @@ impl<T: Trait> Module<T> {
MODULE_ID
.into_sub_account
(
index
)
MODULE_ID
.into_sub_account
(
index
)
}
}
pub
fn
id_from_index
(
index
:
FundIndex
)
->
Vec
<
u8
>
{
pub
fn
id_from_index
(
index
:
FundIndex
)
->
child
::
ChildInfo
{
let
mut
buf
=
Vec
::
new
();
let
mut
buf
=
Vec
::
new
();
buf
.extend_from_slice
(
b"crowdfund"
);
buf
.extend_from_slice
(
b"crowdfund"
);
buf
.extend_from_slice
(
&
index
.to_le_bytes
()[
..
]);
buf
.extend_from_slice
(
&
index
.to_le_bytes
()[
..
]);
child
::
ChildInfo
::
new_default
(
T
::
Hashing
::
hash
(
&
buf
[
..
])
.as_ref
())
CHILD_STORAGE_KEY_PREFIX
.into_iter
()
.chain
(
b"default:"
)
.chain
(
T
::
Hashing
::
hash
(
&
buf
[
..
])
.as_ref
()
.into_iter
())
.cloned
()
.collect
()
}
/// Child trie unique id for a crowdfund is built from the hash part of the fund id.
pub
fn
trie_unique_id
(
fund_id
:
&
[
u8
])
->
child
::
ChildInfo
{
let
start
=
CHILD_STORAGE_KEY_PREFIX
.len
()
+
b"default:"
.len
();
child
::
ChildInfo
::
new_default
(
&
fund_id
[
start
..
])
}
}
pub
fn
contribution_put
(
index
:
FundIndex
,
who
:
&
T
::
AccountId
,
balance
:
&
BalanceOf
<
T
>
)
{
pub
fn
contribution_put
(
index
:
FundIndex
,
who
:
&
T
::
AccountId
,
balance
:
&
BalanceOf
<
T
>
)
{
let
id
=
Self
::
id_from_index
(
index
);
who
.using_encoded
(|
b
|
child
::
put
(
&
Self
::
id_from_index
(
index
),
b
,
balance
));
who
.using_encoded
(|
b
|
child
::
put
(
id
.as_ref
(),
Self
::
trie_unique_id
(
id
.as_ref
()),
b
,
balance
));
}
}
pub
fn
contribution_get
(
index
:
FundIndex
,
who
:
&
T
::
AccountId
)
->
BalanceOf
<
T
>
{
pub
fn
contribution_get
(
index
:
FundIndex
,
who
:
&
T
::
AccountId
)
->
BalanceOf
<
T
>
{
let
id
=
Self
::
id_from_index
(
index
);
who
.using_encoded
(|
b
|
child
::
get_or_default
::
<
BalanceOf
<
T
>>
(
who
.using_encoded
(|
b
|
child
::
get_or_default
::
<
BalanceOf
<
T
>>
(
id
.as_ref
(),
&
Self
::
id_from_index
(
index
),
Self
::
trie_unique_id
(
id
.as_ref
()),
b
,
b
,
))
))
}
}
pub
fn
contribution_kill
(
index
:
FundIndex
,
who
:
&
T
::
AccountId
)
{
pub
fn
contribution_kill
(
index
:
FundIndex
,
who
:
&
T
::
AccountId
)
{
let
id
=
Self
::
id_from_index
(
index
);
who
.using_encoded
(|
b
|
child
::
kill
(
&
Self
::
id_from_index
(
index
),
b
));
who
.using_encoded
(|
b
|
child
::
kill
(
id
.as_ref
(),
Self
::
trie_unique_id
(
id
.as_ref
()),
b
));
}
}
pub
fn
crowdfund_kill
(
index
:
FundIndex
)
{
pub
fn
crowdfund_kill
(
index
:
FundIndex
)
{
let
id
=
Self
::
id_from_index
(
index
);
child
::
kill_storage
(
&
Self
::
id_from_index
(
index
));
child
::
kill_storage
(
id
.as_ref
(),
Self
::
trie_unique_id
(
id
.as_ref
()));
}
}
}
}
...
...
runtime/kusama/src/lib.rs
View file @
c79e4bdf
...
@@ -84,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
...
@@ -84,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"kusama"
),
spec_name
:
create_runtime_str!
(
"kusama"
),
impl_name
:
create_runtime_str!
(
"parity-kusama"
),
impl_name
:
create_runtime_str!
(
"parity-kusama"
),
authoring_version
:
2
,
authoring_version
:
2
,
spec_version
:
105
8
,
spec_version
:
105
9
,
impl_version
:
0
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
apis
:
RUNTIME_API_VERSIONS
,
transaction_version
:
1
,
transaction_version
:
1
,
...
...
runtime/polkadot/src/lib.rs
View file @
c79e4bdf
...
@@ -86,7 +86,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
...
@@ -86,7 +86,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"polkadot"
),
spec_name
:
create_runtime_str!
(
"polkadot"
),
impl_name
:
create_runtime_str!
(
"parity-polkadot"
),
impl_name
:
create_runtime_str!
(
"parity-polkadot"
),
authoring_version
:
2
,
authoring_version
:
2
,
spec_version
:
100
7
,
spec_version
:
100
8
,
impl_version
:
0
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
apis
:
RUNTIME_API_VERSIONS
,
transaction_version
:
1
,
transaction_version
:
1
,
...
...
runtime/test-runtime/client/src/lib.rs
View file @
c79e4bdf
...
@@ -118,7 +118,7 @@ impl substrate_test_client::GenesisInit for GenesisParameters {
...
@@ -118,7 +118,7 @@ impl substrate_test_client::GenesisInit for GenesisParameters {
let
mut
storage
=
self
.genesis_config
()
.genesis_map
();
let
mut
storage
=
self
.genesis_config
()
.genesis_map
();
let
child_roots
=
storage
.children
.iter
()
.map
(|(
sk
,
child_content
)|
{
let
child_roots
=
storage
.children
_default
.iter
()
.map
(|(
sk
,
child_content
)|
{
let
state_root
=
<<<
runtime
::
Block
as
BlockT
>
::
Header
as
HeaderT
>
::
Hashing
as
HashT
>
::
trie_root
(
let
state_root
=
<<<
runtime
::
Block
as
BlockT
>
::
Header
as
HeaderT
>
::
Hashing
as
HashT
>
::
trie_root
(
child_content
.data
.clone
()
.into_iter
()
.collect
()
child_content
.data
.clone
()
.into_iter
()
.collect
()
);
);
...
@@ -198,7 +198,7 @@ pub trait TestClientBuilderExt<B>: Sized {
...
@@ -198,7 +198,7 @@ pub trait TestClientBuilderExt<B>: Sized {
let
key
=
key
.into
();
let
key
=
key
.into
();
assert!
(
!
storage_key
.is_empty
());
assert!
(
!
storage_key
.is_empty
());
assert!
(
!
key
.is_empty
());
assert!
(
!
key
.is_empty
());
self
.genesis_init_mut
()
.extra_storage.children
self
.genesis_init_mut
()
.extra_storage.children
_default
.entry
(
storage_key
)
.entry
(
storage_key
)
.or_insert_with
(||
StorageChild
{
.or_insert_with
(||
StorageChild
{
data
:
Default
::
default
(),
data
:
Default
::
default
(),
...
...
runtime/test-runtime/src/lib.rs
View file @
c79e4bdf
...
@@ -80,7 +80,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
...
@@ -80,7 +80,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"polkadot-test-runtime"
),
spec_name
:
create_runtime_str!
(
"polkadot-test-runtime"
),
impl_name
:
create_runtime_str!
(
"parity-polkadot-test-runtime"
),
impl_name
:
create_runtime_str!
(
"parity-polkadot-test-runtime"
),
authoring_version
:
2
,
authoring_version
:
2
,
spec_version
:
105
0
,
spec_version
:
105
1
,
impl_version
:
0
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
apis
:
RUNTIME_API_VERSIONS
,
transaction_version
:
1
,
transaction_version
:
1
,
...
...
runtime/westend/src/lib.rs
View file @
c79e4bdf
...
@@ -83,7 +83,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
...
@@ -83,7 +83,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"westend"
),
spec_name
:
create_runtime_str!
(
"westend"
),
impl_name
:
create_runtime_str!
(
"parity-westend"
),
impl_name
:
create_runtime_str!
(
"parity-westend"
),
authoring_version
:
2
,
authoring_version
:
2
,
spec_version
:
3
,
spec_version
:
4
,
impl_version
:
0
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
apis
:
RUNTIME_API_VERSIONS
,
transaction_version
:
1
,
transaction_version
:
1
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment