Skip to content
Snippets Groups Projects

Fix weight accounting

Merged Benjamin Gallois requested to merge 167-fix-remove-member-weight into master
Compare and Show latest version
65 files
+ 2255
1654
Compare changes
  • Side-by-side
  • Inline
Files
65
+ 12
12
@@ -43,16 +43,16 @@ where
@@ -43,16 +43,16 @@ where
IdtyIndex: Decode + Encode + PartialEq + TypeInfo,
IdtyIndex: Decode + Encode + PartialEq + TypeInfo,
{
{
let &[owner_key] = owner_keys else {
let &[owner_key] = owner_keys else {
log::error!("🧙 [distance oracle] More than one Babe owner key: oracle cannot work");
log::error!("🧙 [distance oracle] Expected exactly one Babe owner key, found {}: oracle cannot work", owner_keys.len());
return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None));
return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None));
};
};
let owner_key = sp_runtime::AccountId32::new(owner_key.0);
let owner_key = sp_runtime::AccountId32::new(owner_key.0);
let session_index = client
let pool_index = client
.storage(
.storage(
parent,
parent,
&StorageKey(
&StorageKey(
frame_support::storage::storage_prefix(b"Session", b"CurrentIndex").to_vec(),
frame_support::storage::storage_prefix(b"Distance", b"CurrentPoolIndex").to_vec(),
),
),
)
)
.expect("CurrentIndex is Err")
.expect("CurrentIndex is Err")
@@ -66,11 +66,11 @@ where
@@ -66,11 +66,11 @@ where
&StorageKey(
&StorageKey(
frame_support::storage::storage_prefix(
frame_support::storage::storage_prefix(
b"Distance",
b"Distance",
match session_index % 3 {
match pool_index {
0 => b"StoragePublishedResults1",
0 => b"EvaluationPool0",
1 => b"StoragePublishedResults2",
1 => b"EvaluationPool1",
2 => b"StoragePublishedResults0",
2 => b"EvaluationPool2",
_ => unreachable!("n%3<3"),
_ => unreachable!("n<3"),
},
},
)
)
.to_vec(),
.to_vec(),
@@ -81,18 +81,18 @@ where
@@ -81,18 +81,18 @@ where
.expect("cannot decode EvaluationPool")
.expect("cannot decode EvaluationPool")
});
});
// Have we already published a result for this session?
// Have we already published a result for this period?
if published_results.evaluators.contains(&owner_key) {
if published_results.evaluators.contains(&owner_key) {
log::debug!("🧙 [distance oracle] Already published a result for this session");
log::debug!("🧙 [distance oracle] Already published a result for this period");
return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None));
return Ok(sp_distance::InherentDataProvider::<IdtyIndex>::new(None));
}
}
// Read evaluation result from file, if it exists
// Read evaluation result from file, if it exists
log::debug!(
log::debug!(
"🧙 [distance oracle] Reading evaluation result from file {:?}",
"🧙 [distance oracle] Reading evaluation result from file {:?}",
distance_dir.clone().join(session_index.to_string())
distance_dir.clone().join(pool_index.to_string())
);
);
let evaluation_result = match std::fs::read(distance_dir.join(session_index.to_string())) {
let evaluation_result = match std::fs::read(distance_dir.join(pool_index.to_string())) {
Ok(data) => data,
Ok(data) => data,
Err(e) => {
Err(e) => {
match e.kind() {
match e.kind() {
Loading