mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 10:55:42 +00:00
Companion for substrate#14471 (#7432)
* Companion for substrate#14471 * add missing MaxNominators constant * missing MaxNominators in test-runtime * missing MaxNominators in runtime/integration_tests * Dont use deprecated functions Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixup Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * update lockfile for {"substrate"} * Update Substrate dep Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -51,7 +51,7 @@ impl<
|
||||
.map_err(|_| ProcessMessageError::Unsupported)?;
|
||||
let pre = XcmExecutor::prepare(message).map_err(|_| ProcessMessageError::Unsupported)?;
|
||||
let required = pre.weight_of();
|
||||
ensure!(meter.can_accrue(required), ProcessMessageError::Overweight(required));
|
||||
ensure!(meter.can_consume(required), ProcessMessageError::Overweight(required));
|
||||
|
||||
let (consumed, result) = match XcmExecutor::execute(origin.into(), pre, id, Weight::zero())
|
||||
{
|
||||
@@ -60,7 +60,7 @@ impl<
|
||||
// In the error-case we assume the worst case and consume all possible weight.
|
||||
Outcome::Error(_) => (required, Err(ProcessMessageError::Unsupported)),
|
||||
};
|
||||
meter.defensive_saturating_accrue(consumed);
|
||||
meter.consume(consumed);
|
||||
result
|
||||
}
|
||||
}
|
||||
@@ -116,14 +116,14 @@ mod tests {
|
||||
Processor::process_message(msg, ORIGIN, meter, &mut id),
|
||||
Overweight(1000.into())
|
||||
);
|
||||
assert_eq!(meter.consumed, 0.into());
|
||||
assert_eq!(meter.consumed(), 0.into());
|
||||
}
|
||||
|
||||
// Works with a limit of 1000.
|
||||
let meter = &mut WeightMeter::from_limit(1000.into());
|
||||
let mut id = [0; 32];
|
||||
assert_ok!(Processor::process_message(msg, ORIGIN, meter, &mut id));
|
||||
assert_eq!(meter.consumed, 1000.into());
|
||||
assert_eq!(meter.consumed(), 1000.into());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user