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
4b034045
Unverified
Commit
4b034045
authored
Apr 02, 2021
by
asynchronous rob
Committed by
GitHub
Apr 02, 2021
Browse files
add disputes members to `HostConfiguration` (#2806)
* add disputes members to `HostConfiguration` * revert bad rename
parent
96dc1f7a
Pipeline
#132498
failed with stages
in 14 minutes and 46 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
node/service/src/chain_spec.rs
View file @
4b034045
...
...
@@ -387,7 +387,7 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
//5Fnu4YYBx9V71ihCBkJyFGsKw9Q2jjNzRQL9kRNpKTPNSAhc
hex!
[
"03e9393ee30ae95fc2b7864230f53e45409a807949390140ce2bc77756cdb4bb83"
]
.unchecked_into
(),
),
];
const
ENDOWMENT
:
u128
=
1_000_000
*
WND
;
...
...
@@ -839,7 +839,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
hex!
[
"4e262811acdfe94528bfc3c65036080426a0e1301b9ada8d687a70ffcae99c26"
]
.unchecked_into
(),
//5E41Znrr2YtZu8bZp3nvRuLVHg3jFksfQ3tXuviLku4wsao7
hex!
[
"025e84e95ed043e387ddb8668176b42f8e2773ddd84f7f58a6d9bf436a4b527986"
]
.unchecked_into
(),
),
),
];
const
ENDOWMENT
:
u128
=
1_000_000
*
ROC
;
...
...
@@ -891,7 +891,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
config
:
polkadot_runtime_parachains
::
configuration
::
HostConfiguration
{
validation_upgrade_frequency
:
600u32
,
validation_upgrade_delay
:
300
,
acceptance
_period
:
1200
,
code_retention
_period
:
1200
,
max_code_size
:
5
*
1024
*
1024
,
max_pov_size
:
MAX_POV_SIZE
,
max_head_data_size
:
32
*
1024
,
...
...
@@ -1440,7 +1440,7 @@ pub fn rococo_testnet_genesis(
config
:
polkadot_runtime_parachains
::
configuration
::
HostConfiguration
{
validation_upgrade_frequency
:
600u32
,
validation_upgrade_delay
:
300
,
acceptance
_period
:
1200
,
code_retention
_period
:
1200
,
max_code_size
:
5
*
1024
*
1024
,
max_pov_size
:
50
*
1024
*
1024
,
max_head_data_size
:
32
*
1024
,
...
...
node/test/service/src/chain_spec.rs
View file @
4b034045
...
...
@@ -178,7 +178,7 @@ fn polkadot_testnet_genesis(
config
:
polkadot_runtime_parachains
::
configuration
::
HostConfiguration
{
validation_upgrade_frequency
:
10u32
,
validation_upgrade_delay
:
5
,
acceptance
_period
:
1200
,
code_retention
_period
:
1200
,
max_code_size
:
5
*
1024
*
1024
,
max_pov_size
:
50
*
1024
*
1024
,
max_head_data_size
:
32
*
1024
,
...
...
roadmap/implementers-guide/src/types/runtime.md
View file @
4b034045
...
...
@@ -12,9 +12,9 @@ struct HostConfiguration {
pub
validation_upgrade_frequency
:
BlockNumber
,
/// The delay, in blocks, before a validation upgrade is applied.
pub
validation_upgrade_delay
:
BlockNumber
,
///
The acceptance period, in blocks. This is the amount of blocks after availability that validator
s
///
and fishermen have to perform secondary checks or issue reports
.
pub
acceptance
_period
:
BlockNumber
,
///
How long to keep code on-chain, in blocks. This should be sufficiently long that dispute
s
///
have concluded
.
pub
code_retention
_period
:
BlockNumber
,
/// The maximum validation code size, in bytes.
pub
max_code_size
:
u32
,
/// The maximum head-data size, in bytes.
...
...
runtime/parachains/src/configuration.rs
View file @
4b034045
...
...
@@ -118,9 +118,9 @@ pub struct HostConfiguration<BlockNumber> {
* Parameters that will unlikely be needed by parachains.
*/
///
The acceptance period, in blocks. This is the amount of blocks after availability that validator
s
///
and fishermen have to perform secondary checks or issue reports
.
pub
acceptance
_period
:
BlockNumber
,
///
How long to keep code on-chain, in blocks. This should be sufficiently long that dispute
s
///
have concluded
.
pub
code_retention
_period
:
BlockNumber
,
/// The amount of execution cores to dedicate to parathread execution.
pub
parathread_cores
:
u32
,
/// The number of retries that a parathread author has to submit their block.
...
...
@@ -152,6 +152,12 @@ pub struct HostConfiguration<BlockNumber> {
pub
max_validators
:
Option
<
u32
>
,
/// The amount of sessions to keep for disputes.
pub
dispute_period
:
SessionIndex
,
/// How long after dispute conclusion to accept statements.
pub
dispute_post_conclusion_acceptance_period
:
BlockNumber
,
/// The maximum number of dispute spam slots
pub
dispute_max_spam_slots
:
u32
,
/// How long it takes for a dispute to conclude by time-out, if no supermajority is reached.
pub
dispute_conclusion_by_time_out_period
:
BlockNumber
,
/// The amount of consensus slots that must pass between submitting an assignment and
/// submitting an approval vote before a validator is considered a no-show.
///
...
...
@@ -177,7 +183,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
no_show_slots
:
1u32
.into
(),
validation_upgrade_frequency
:
Default
::
default
(),
validation_upgrade_delay
:
Default
::
default
(),
acceptance
_period
:
Default
::
default
(),
code_retention
_period
:
Default
::
default
(),
max_code_size
:
Default
::
default
(),
max_pov_size
:
Default
::
default
(),
max_head_data_size
:
Default
::
default
(),
...
...
@@ -186,7 +192,10 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
scheduling_lookahead
:
Default
::
default
(),
max_validators_per_core
:
Default
::
default
(),
max_validators
:
None
,
dispute_period
:
Default
::
default
(),
dispute_period
:
6
,
dispute_post_conclusion_acceptance_period
:
100
.into
(),
dispute_max_spam_slots
:
2
,
dispute_conclusion_by_time_out_period
:
200
.into
(),
n_delay_tranches
:
Default
::
default
(),
zeroth_delay_tranche_width
:
Default
::
default
(),
needed_approvals
:
Default
::
default
(),
...
...
@@ -287,10 +296,10 @@ decl_module! {
/// Set the acceptance period for an included candidate.
#[weight
=
(
1_000
,
DispatchClass::Operational)]
pub
fn
set_
acceptance
_period
(
origin
,
new
:
T
::
BlockNumber
)
->
DispatchResult
{
pub
fn
set_
code_retention
_period
(
origin
,
new
:
T
::
BlockNumber
)
->
DispatchResult
{
ensure_root
(
origin
)
?
;
Self
::
update_config_member
(|
config
|
{
sp_std
::
mem
::
replace
(
&
mut
config
.
acceptance
_period
,
new
)
!=
new
sp_std
::
mem
::
replace
(
&
mut
config
.
code_retention
_period
,
new
)
!=
new
});
Ok
(())
}
...
...
@@ -425,6 +434,41 @@ decl_module! {
Ok
(())
}
/// Set the dispute post conclusion acceptance period.
#[weight
=
(
1_000
,
DispatchClass::Operational)]
pub
fn
set_dispute_post_conclusion_acceptance_period
(
origin
,
new
:
T
::
BlockNumber
,
)
->
DispatchResult
{
ensure_root
(
origin
)
?
;
Self
::
update_config_member
(|
config
|
{
sp_std
::
mem
::
replace
(
&
mut
config
.dispute_post_conclusion_acceptance_period
,
new
)
!=
new
});
Ok
(())
}
/// Set the maximum number of dispute spam slots.
#[weight
=
(
1_000
,
DispatchClass::Operational)]
pub
fn
set_dispute_max_spam_slots
(
origin
,
new
:
u32
)
->
DispatchResult
{
ensure_root
(
origin
)
?
;
Self
::
update_config_member
(|
config
|
{
sp_std
::
mem
::
replace
(
&
mut
config
.dispute_max_spam_slots
,
new
)
!=
new
});
Ok
(())
}
/// Set the dispute conclusion by time out period.
#[weight
=
(
1_000
,
DispatchClass::Operational)]
pub
fn
set_dispute_conclusion_by_time_out_period
(
origin
,
new
:
T
::
BlockNumber
)
->
DispatchResult
{
ensure_root
(
origin
)
?
;
Self
::
update_config_member
(|
config
|
{
sp_std
::
mem
::
replace
(
&
mut
config
.dispute_conclusion_by_time_out_period
,
new
)
!=
new
});
Ok
(())
}
/// Set the no show slots, in number of number of consensus slots.
/// Must be at least 1.
#[weight
=
(
1_000
,
DispatchClass::Operational)]
...
...
@@ -731,7 +775,7 @@ mod tests {
let
new_config
=
HostConfiguration
{
validation_upgrade_frequency
:
100
,
validation_upgrade_delay
:
10
,
acceptance
_period
:
5
,
code_retention
_period
:
5
,
max_code_size
:
100_000
,
max_pov_size
:
1024
,
max_head_data_size
:
1_000
,
...
...
@@ -744,6 +788,9 @@ mod tests {
max_validators_per_core
:
None
,
max_validators
:
None
,
dispute_period
:
239
,
dispute_post_conclusion_acceptance_period
:
10
,
dispute_max_spam_slots
:
2
,
dispute_conclusion_by_time_out_period
:
512
,
no_show_slots
:
240
,
n_delay_tranches
:
241
,
zeroth_delay_tranche_width
:
242
,
...
...
@@ -776,8 +823,8 @@ mod tests {
Configuration
::
set_validation_upgrade_delay
(
Origin
::
root
(),
new_config
.validation_upgrade_delay
,
)
.unwrap
();
Configuration
::
set_
acceptance
_period
(
Origin
::
root
(),
new_config
.
acceptance
_period
,
Configuration
::
set_
code_retention
_period
(
Origin
::
root
(),
new_config
.
code_retention
_period
,
)
.unwrap
();
Configuration
::
set_max_code_size
(
Origin
::
root
(),
new_config
.max_code_size
,
...
...
@@ -815,6 +862,15 @@ mod tests {
Configuration
::
set_dispute_period
(
Origin
::
root
(),
new_config
.dispute_period
,
)
.unwrap
();
Configuration
::
set_dispute_post_conclusion_acceptance_period
(
Origin
::
root
(),
new_config
.dispute_post_conclusion_acceptance_period
,
)
.unwrap
();
Configuration
::
set_dispute_max_spam_slots
(
Origin
::
root
(),
new_config
.dispute_max_spam_slots
,
)
.unwrap
();
Configuration
::
set_dispute_conclusion_by_time_out_period
(
Origin
::
root
(),
new_config
.dispute_conclusion_by_time_out_period
,
)
.unwrap
();
Configuration
::
set_no_show_slots
(
Origin
::
root
(),
new_config
.no_show_slots
,
)
.unwrap
();
...
...
runtime/parachains/src/paras.rs
View file @
4b034045
...
...
@@ -575,14 +575,14 @@ impl<T: Config> Module<T> {
// that are too old.
fn
prune_old_code
(
now
:
T
::
BlockNumber
)
->
Weight
{
let
config
=
configuration
::
Module
::
<
T
>
::
config
();
let
acceptance
_period
=
config
.
acceptance
_period
;
if
now
<=
acceptance
_period
{
let
code_retention
_period
=
config
.
code_retention
_period
;
if
now
<=
code_retention
_period
{
let
weight
=
T
::
DbWeight
::
get
()
.reads_writes
(
1
,
0
);
return
weight
;
}
// The height of any changes we no longer should keep around.
let
pruning_height
=
now
-
(
acceptance
_period
+
One
::
one
());
let
pruning_height
=
now
-
(
code_retention
_period
+
One
::
one
());
let
pruning_tasks_done
=
<
Self
as
Store
>
::
PastCodePruning
::
mutate
(|
pruning_tasks
:
&
mut
Vec
<
(
_
,
T
::
BlockNumber
)
>
|
{
...
...
@@ -1071,7 +1071,7 @@ mod tests {
#[test]
fn
para_past_code_pruning_in_initialize
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
paras
=
vec!
[
(
0u32
.into
(),
ParaGenesisArgs
{
parachain
:
true
,
...
...
@@ -1089,7 +1089,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1113,7 +1113,7 @@ mod tests {
<
Paras
as
Store
>
::
PastCodeMeta
::
insert
(
&
id
,
&
code_meta
);
}
let
pruned_at
:
BlockNumber
=
included_block
+
acceptance
_period
+
1
;
let
pruned_at
:
BlockNumber
=
included_block
+
code_retention
_period
+
1
;
assert_eq!
(
<
Paras
as
Store
>
::
PastCodeHash
::
get
(
&
(
id
,
at_block
)),
Some
(
validation_code
.hash
()));
check_code_is_stored
(
&
validation_code
);
...
...
@@ -1131,7 +1131,7 @@ mod tests {
#[test]
fn
note_new_head_sets_head
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
paras
=
vec!
[
(
0u32
.into
(),
ParaGenesisArgs
{
parachain
:
true
,
...
...
@@ -1144,7 +1144,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1165,7 +1165,7 @@ mod tests {
#[test]
fn
note_past_code_sets_up_pruning_correctly
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
paras
=
vec!
[
(
0u32
.into
(),
ParaGenesisArgs
{
parachain
:
true
,
...
...
@@ -1183,7 +1183,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1218,7 +1218,7 @@ mod tests {
#[test]
fn
code_upgrade_applied_after_delay
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
validation_upgrade_delay
=
5
;
let
original_code
=
ValidationCode
(
vec!
[
1
,
2
,
3
]);
...
...
@@ -1234,7 +1234,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
validation_upgrade_delay
,
..
Default
::
default
()
},
...
...
@@ -1309,7 +1309,7 @@ mod tests {
#[test]
fn
code_upgrade_applied_after_delay_even_when_late
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
validation_upgrade_delay
=
5
;
let
original_code
=
ValidationCode
(
vec!
[
1
,
2
,
3
]);
...
...
@@ -1325,7 +1325,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
validation_upgrade_delay
,
..
Default
::
default
()
},
...
...
@@ -1379,7 +1379,7 @@ mod tests {
#[test]
fn
submit_code_change_when_not_allowed_is_err
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
paras
=
vec!
[
(
0u32
.into
(),
ParaGenesisArgs
{
...
...
@@ -1393,7 +1393,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1422,7 +1422,7 @@ mod tests {
#[test]
fn
full_parachain_cleanup_storage
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
original_code
=
ValidationCode
(
vec!
[
1
,
2
,
3
]);
let
paras
=
vec!
[
...
...
@@ -1437,7 +1437,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1509,7 +1509,7 @@ mod tests {
check_code_is_not_stored
(
&
new_code
);
// run to do the final cleanup
let
cleaned_up_at
=
3
+
acceptance
_period
+
1
;
let
cleaned_up_at
=
3
+
code_retention
_period
+
1
;
run_to_block
(
cleaned_up_at
,
None
);
// now the final cleanup: last past code cleaned up, and this triggers meta cleanup.
...
...
@@ -1600,7 +1600,7 @@ mod tests {
#[test]
fn
code_at_with_intermediate
()
{
let
acceptance
_period
=
10
;
let
code_retention
_period
=
10
;
let
paras
=
vec!
[
(
0u32
.into
(),
ParaGenesisArgs
{
...
...
@@ -1614,7 +1614,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1642,7 +1642,7 @@ mod tests {
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
11
,
Some
(
10
)),
Some
(
new_code
.clone
()));
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
100
,
Some
(
11
)),
Some
(
new_code
.clone
()));
run_to_block
(
acceptance
_period
+
5
,
None
);
run_to_block
(
code_retention
_period
+
5
,
None
);
// at <= intermediate not allowed
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
10
,
Some
(
10
)),
None
);
...
...
@@ -1651,8 +1651,8 @@ mod tests {
}
#[test]
fn
code_at_returns_up_to_end_of_
acceptance
_period
()
{
let
acceptance
_period
=
10
;
fn
code_at_returns_up_to_end_of_
code_retention
_period
()
{
let
code_retention
_period
=
10
;
let
paras
=
vec!
[
(
0u32
.into
(),
ParaGenesisArgs
{
...
...
@@ -1666,7 +1666,7 @@ mod tests {
paras
:
GenesisConfig
{
paras
,
..
Default
::
default
()
},
configuration
:
crate
::
configuration
::
GenesisConfig
{
config
:
HostConfiguration
{
acceptance
_period
,
code_retention
_period
,
..
Default
::
default
()
},
..
Default
::
default
()
...
...
@@ -1691,12 +1691,12 @@ mod tests {
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
2
,
None
),
Some
(
old_code
.clone
()));
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
3
,
None
),
Some
(
new_code
.clone
()));
run_to_block
(
10
+
acceptance
_period
,
None
);
run_to_block
(
10
+
code_retention
_period
,
None
);
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
2
,
None
),
Some
(
old_code
.clone
()));
assert_eq!
(
Paras
::
validation_code_at
(
para_id
,
3
,
None
),
Some
(
new_code
.clone
()));
run_to_block
(
10
+
acceptance
_period
+
1
,
None
);
run_to_block
(
10
+
code_retention
_period
+
1
,
None
);
// code entry should be pruned now.
...
...
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