Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Martin Pugh
polkadot
Commits
68d2f385
Commit
68d2f385
authored
Sep 11, 2020
by
Peter Goodspeed-Niklaus
Browse files
to revert: demo that forwarding the test runtime to the real impl blows up
parent
2ae8cee5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
68d2f385
...
...
@@ -5528,6 +5528,7 @@ dependencies = [
"polkadot-parachain",
"polkadot-primitives",
"polkadot-runtime-common",
"polkadot-runtime-parachains",
"rustc-hex",
"serde",
"serde_derive",
...
...
runtime/test-runtime/Cargo.toml
View file @
68d2f385
...
...
@@ -55,6 +55,7 @@ pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "ma
runtime-common
=
{
package
=
"polkadot-runtime-common"
,
path
=
"../common"
,
default-features
=
false
}
primitives
=
{
package
=
"polkadot-primitives"
,
path
=
"../../primitives"
,
default-features
=
false
}
polkadot-parachain
=
{
path
=
"../../parachain"
,
default-features
=
false
}
polkadot-runtime-parachains
=
{
path
=
"../parachains"
}
[dev-dependencies]
hex-literal
=
"0.2.1"
...
...
runtime/test-runtime/src/lib.rs
View file @
68d2f385
...
...
@@ -22,6 +22,7 @@
use
rstd
::
prelude
::
*
;
use
codec
::{
Encode
,
Decode
};
use
polkadot_runtime_parachains
::
runtime_api_impl
::
v1
as
runtime_impl
;
use
primitives
::
v0
as
p_v0
;
use
primitives
::
v1
::{
AccountId
,
AccountIndex
,
Balance
,
BlockNumber
,
Hash
as
HashT
,
Nonce
,
Signature
,
Moment
,
...
...
@@ -552,76 +553,44 @@ sp_api::impl_runtime_apis! {
}
}
// REVIEW: I have _no idea_ what I'm really doing here, what invariants are necessary for the
// test context I'm setting up. I'm mainly just dumbly translating from the v0 impl.
// This whole impl probably wants some particular attention.
//
// Note: it's forbidden to implement two traits with the same name on the same type, even
// if the traits are distinct. I therefore had to remove the v0 ParachainHost impl.
impl
primitives
::
v1
::
ParachainHost
<
Block
,
Hash
,
BlockNumber
>
for
Runtime
{
fn
validators
()
->
Vec
<
p_v1
::
ValidatorId
>
{
// this is a compile-time check of size equality. note that we don't invoke
// the function and nothing here is unsafe.
let
_
=
core
::
mem
::
transmute
::
<
p_v0
::
ValidatorId
,
AccountId
>
;
// Yes, these aren't actually the parachain session keys.
// It doesn't matter, but we shouldn't return a zero-sized vector here.
// As there are no parachains
Session
::
validators
()
.into_iter
()
.map
(|
k
|
k
.using_encoded
(|
s
|
Decode
::
decode
(
&
mut
&
s
[
..
]))
.expect
(
"correct size and raw-bytes; qed"
))
.collect
()
runtime_impl
::
validators
()
}
fn
validator_groups
()
->
(
Vec
<
Vec
<
p_v1
::
ValidatorIndex
>>
,
p_v1
::
GroupRotationInfo
<
BlockNumber
>
)
{
const
N
:
usize
=
3
;
let
validators
=
Self
::
validators
();
let
mut
groups
=
vec!
[
Vec
::
with_capacity
(
validators
.len
()
/
N
+
1
);
N
];
for
idx
in
0
..
validators
.len
()
{
let
vidx
=
idx
as
p_v1
::
ValidatorIndex
;
groups
[
idx
%
N
]
.push
(
vidx
);
}
let
rotation_info
=
p_v1
::
GroupRotationInfo
{
session_start_block
:
0
,
group_rotation_frequency
:
0
,
now
:
123
,
};
(
groups
,
rotation_info
)
runtime_impl
::
validator_groups
()
}
fn
availability_cores
()
->
Vec
<
p_v1
::
CoreState
<
BlockNumber
>>
{
let
validators
=
Self
::
validators
();
vec!
[
p_v1
::
CoreState
::
Free
;
validators
.len
()]
runtime_impl
::
avaiilability_cores
()
}
fn
full_validation_data
(
_
para_id
:
p_v1
::
Id
,
_
assumption
:
p_v1
::
OccupiedCoreAssumption
)
fn
full_validation_data
(
para_id
:
p_v1
::
Id
,
assumption
:
p_v1
::
OccupiedCoreAssumption
)
->
Option
<
p_v1
::
ValidationData
<
BlockNumber
>>
{
N
on
e
runtime_impl
::
full_validation_data
(
para_id
,
assumpti
on
)
}
fn
persisted_validation_data
(
_
para_id
:
p_v1
::
Id
,
_
assumption
:
p_v1
::
OccupiedCoreAssumption
)
fn
persisted_validation_data
(
para_id
:
p_v1
::
Id
,
assumption
:
p_v1
::
OccupiedCoreAssumption
)
->
Option
<
p_v1
::
PersistedValidationData
<
BlockNumber
>>
{
None
runtime_impl
::
persisted_validation_data
(
para_id
,
assumption
)
}
fn
session_index_for_child
()
->
p_v1
::
SessionIndex
{
0
runtime_impl
::
session_index_for_child
()
}
fn
validation_code
(
_
para_id
:
p_v1
::
Id
,
_
assumption
:
p_v1
::
OccupiedCoreAssumption
)
fn
validation_code
(
para_id
:
p_v1
::
Id
,
assumption
:
p_v1
::
OccupiedCoreAssumption
)
->
Option
<
p_v1
::
ValidationCode
>
{
None
runtime_impl
::
validation_code
(
para_id
,
assumption
)
}
fn
candidate_pending_availability
(
_
para_id
:
p_v1
::
Id
)
->
Option
<
p_v1
::
CommittedCandidateReceipt
<
Hash
>>
{
None
fn
candidate_pending_availability
(
para_id
:
p_v1
::
Id
)
->
Option
<
p_v1
::
CommittedCandidateReceipt
<
Hash
>>
{
runtime_impl
::
candidate_pending_availability
(
para_id
)
}
fn
candidate_events
()
->
Vec
<
p_v1
::
CandidateEvent
<
Hash
>>
{
Vec
::
new
()
runtime_impl
::
candidate_events
()
}
}
...
...
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