1818
1919#![cfg_attr(not(feature = "std"), no_std)]
2020
21- use account::SYSTEM_ACCOUNT_SIZE;
21+ use account::{AccountId20, SYSTEM_ACCOUNT_SIZE} ;
2222use core::marker::PhantomData;
2323use fp_evm::Log;
2424use frame_support::{
@@ -28,7 +28,7 @@ use frame_support::{
2828 weights::Weight,
2929};
3030use pallet_evm::AddressMapping;
31- use parity_scale_codec::DecodeLimit as _;
31+ use parity_scale_codec::{ DecodeLimit as _, MaxEncodedLen} ;
3232use precompile_utils::prelude::*;
3333use sp_core::{Decode, Get, H160, H256};
3434use sp_runtime::traits::Dispatchable;
@@ -310,9 +310,11 @@ where
310310 #[precompile::public("members()")]
311311 #[precompile::view]
312312 fn members(handle: &mut impl PrecompileHandle) -> EvmResult<Vec<Address>> {
313- // Members: Vec(20 * MaxMembers)
313+ // Record cost of reading the Members storage item, which contains up to MaxMembers accounts
314+ // Cost: AccountId20 size × MaxMembers
314315 handle.record_db_read::<Runtime>(
315- 20 * (<Runtime as pallet_collective::Config<Instance>>::MaxProposals::get() as usize),
316+ AccountId20::max_encoded_len()
317+ * (<Runtime as pallet_collective::Config<Instance>>::MaxMembers::get() as usize),
316318 )?;
317319
318320 let members = pallet_collective::Members::<Runtime, Instance>::get();
@@ -324,9 +326,11 @@ where
324326 #[precompile::public("isMember(address)")]
325327 #[precompile::view]
326328 fn is_member(handle: &mut impl PrecompileHandle, account: Address) -> EvmResult<bool> {
327- // Members: Vec(20 * MaxMembers)
329+ // Record cost of reading the Members storage item, which contains up to MaxMembers accounts
330+ // Cost: AccountId20 size × MaxMembers
328331 handle.record_db_read::<Runtime>(
329- 20 * (<Runtime as pallet_collective::Config<Instance>>::MaxProposals::get() as usize),
332+ AccountId20::max_encoded_len()
333+ * (<Runtime as pallet_collective::Config<Instance>>::MaxMembers::get() as usize),
330334 )?;
331335
332336 let account = Runtime::AddressMapping::into_account_id(account.into());
0 commit comments