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
4325cc6e
Unverified
Commit
4325cc6e
authored
Mar 25, 2021
by
André Silva
Committed by
GitHub
Mar 25, 2021
Browse files
rococo: use insecure parent hash randomness (#2701)
parent
c836fb85
Changes
1
Hide whitespace changes
Inline
Side-by-side
runtime/rococo/src/lib.rs
View file @
4325cc6e
...
...
@@ -612,21 +612,17 @@ impl paras_registrar::Config for Runtime {
type
WeightInfo
=
paras_registrar
::
TestWeightInfo
;
}
// A wrapper around `babe::CurrentBlockRandomness` that does not return `Option<Random>`.
pub
struct
CurrentBlockRandomness
;
/// An insecure randomness beacon that uses the parent block hash as random material.
///
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
pub
struct
ParentHashRandomness
;
impl
Randomness
<
Hash
,
BlockNumber
>
for
Cur
rent
Block
Randomness
{
impl
Randomness
<
Hash
,
BlockNumber
>
for
Pa
rent
Hash
Randomness
{
fn
random
(
subject
:
&
[
u8
])
->
(
Hash
,
BlockNumber
)
{
let
(
randomness
,
block_number
)
=
pallet_babe
::
CurrentBlockRandomness
::
<
Runtime
>
::
random
(
subject
);
let
randomness
=
randomness
.expect
(
"only returns None when secondary VRF slots are not enabled;
\
secondary VRF slots are enbaled for rococo runtime;
\
qed."
,
);
(
randomness
,
block_number
)
(
(
System
::
parent_hash
(),
subject
)
.using_encoded
(
sp_io
::
hashing
::
blake2_256
)
.into
(),
System
::
block_number
(),
)
}
}
...
...
@@ -640,7 +636,7 @@ impl auctions::Config for Runtime {
type
Leaser
=
Slots
;
type
EndingPeriod
=
EndingPeriod
;
type
SampleLength
=
SampleLength
;
type
Randomness
=
Cur
rent
Block
Randomness
;
type
Randomness
=
Pa
rent
Hash
Randomness
;
type
InitiateOrigin
=
EnsureRoot
<
AccountId
>
;
type
WeightInfo
=
auctions
::
TestWeightInfo
;
}
...
...
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