mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 07:01:02 +00:00
contracts: Prevent PoV attack vector with minimal viable solution (#11372)
* Add ContractAccessWeight * Apply suggestions from code review Co-authored-by: Michael Müller <michi@parity.io> Co-authored-by: Michael Müller <michi@parity.io>
This commit is contained in:
committed by
GitHub
parent
e30c18d61d
commit
4b64c9085a
@@ -38,7 +38,7 @@ use crate::{
|
||||
use frame_support::{
|
||||
dispatch::{DispatchError, DispatchResult},
|
||||
ensure,
|
||||
traits::ReservableCurrency,
|
||||
traits::{Get, ReservableCurrency},
|
||||
};
|
||||
use sp_core::crypto::UncheckedFrom;
|
||||
use sp_runtime::traits::BadOrigin;
|
||||
@@ -216,8 +216,12 @@ impl<T: Config> Token<T> for CodeToken {
|
||||
// size of the contract.
|
||||
match *self {
|
||||
Reinstrument(len) => T::WeightInfo::reinstrument(len),
|
||||
Load(len) => T::WeightInfo::call_with_code_per_byte(len)
|
||||
.saturating_sub(T::WeightInfo::call_with_code_per_byte(0)),
|
||||
Load(len) => {
|
||||
let computation = T::WeightInfo::call_with_code_per_byte(len)
|
||||
.saturating_sub(T::WeightInfo::call_with_code_per_byte(0));
|
||||
let bandwith = T::ContractAccessWeight::get().saturating_mul(len.into());
|
||||
computation.max(bandwith)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user