From 9cec8310840989c35c61d3f78ec0d86d60a13b07 Mon Sep 17 00:00:00 2001 From: georgepisaltu Date: Wed, 16 Oct 2024 18:17:44 +0300 Subject: [PATCH] Fix system extension weights proof size Signed-off-by: georgepisaltu --- substrate/frame/system/src/extensions/check_genesis.rs | 4 +++- substrate/frame/system/src/extensions/check_mortality.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/substrate/frame/system/src/extensions/check_genesis.rs b/substrate/frame/system/src/extensions/check_genesis.rs index 86afcc8a91c4..881faa2c0eaf 100644 --- a/substrate/frame/system/src/extensions/check_genesis.rs +++ b/substrate/frame/system/src/extensions/check_genesis.rs @@ -62,7 +62,9 @@ impl TransactionExtension for CheckGene type Val = (); type Pre = (); fn weight(&self, _: &T::RuntimeCall) -> sp_weights::Weight { - ::check_genesis() + // All transactions will always read the hash of the genesis block, so to avoid + // charging this multiple times in a block we manually set the proof size to 0. + ::check_genesis().set_proof_size(0) } impl_tx_ext_default!(T::RuntimeCall; validate prepare); } diff --git a/substrate/frame/system/src/extensions/check_mortality.rs b/substrate/frame/system/src/extensions/check_mortality.rs index 458388bb7989..7da5521f353d 100644 --- a/substrate/frame/system/src/extensions/check_mortality.rs +++ b/substrate/frame/system/src/extensions/check_mortality.rs @@ -74,7 +74,10 @@ impl TransactionExtension for CheckMort fn weight(&self, _: &T::RuntimeCall) -> sp_weights::Weight { if self.0.is_immortal() { + // All immortal transactions will always read the hash of the genesis block, so to avoid + // charging this multiple times in a block we manually set the proof size to 0. ::check_mortality_immortal_transaction() + .set_proof_size(0) } else { ::check_mortality_mortal_transaction() }