From 74296a0775ee1d5437b0b9843d6a23188c96143f Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 5 Oct 2025 05:34:18 -0400 Subject: [PATCH] Fix timeline for incrementing providers e1671dd71b219bf7439c28f1c5bdf988b1e00ff5 incremented the providers for every single transaction's sender before execution, noting the solution was fragile but it worked for us at this time. It did not work for us at this time. The new solution replaces `inc_providers` with direct access to the `Account` `StorageMap` to increment the providers, achieving the desired goal, _without_ emitting an event (which is ordered, and the disparate order between building and execution was causing mismatches of the state root). This solution is also fragile and may also be insufficient. None of this code exists anymore on `next` however. It just has to work sufficiently for now. --- substrate/runtime/src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/substrate/runtime/src/lib.rs b/substrate/runtime/src/lib.rs index 1f8a9298..0331b80a 100644 --- a/substrate/runtime/src/lib.rs +++ b/substrate/runtime/src/lib.rs @@ -383,9 +383,11 @@ sp_api::impl_runtime_apis! { fn execute_block(block: Block) { for tx in &block.extrinsics { if let Some(signer) = tx.signer() { - let signer = signer.0.into(); - if System::providers(&signer) == 0 { - System::inc_providers(&signer); + let signer = PublicKey::from(signer.0); + let mut info = frame_system::Account::::get(&signer); + if info.providers == 0 { + info.providers = 1; + frame_system::Account::::set(&signer, info); } } } @@ -401,9 +403,11 @@ sp_api::impl_runtime_apis! { impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { if let Some(signer) = extrinsic.signer() { - let signer = signer.0.into(); - if System::providers(&signer) == 0 { - System::inc_providers(&signer); + let signer = PublicKey::from(signer.0); + let mut info = frame_system::Account::::get(&signer); + if info.providers == 0 { + info.providers = 1; + frame_system::Account::::set(&signer, info); } } Executive::apply_extrinsic(extrinsic)