From e9a2e71124af0d9e14ec73c348986f6965858bdd Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Fri, 5 Jun 2026 15:43:38 +1000 Subject: [PATCH] add namespaces to the grants cache --- src/xrpld/app/hook/applyHook.h | 3 ++- src/xrpld/app/hook/detail/HookAPI.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/xrpld/app/hook/applyHook.h b/src/xrpld/app/hook/applyHook.h index 0a807cf34..97b0e5e92 100644 --- a/src/xrpld/app/hook/applyHook.h +++ b/src/xrpld/app/hook/applyHook.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -174,7 +175,7 @@ struct HookResult false; // hook_again allows strong pre-apply to nominate // additional weak post-apply execution std::shared_ptr provisionalMeta; - std::set + std::set> foreignStateGrantCache; // add found grants here to avoid rechecking }; diff --git a/src/xrpld/app/hook/detail/HookAPI.cpp b/src/xrpld/app/hook/detail/HookAPI.cpp index 12e64550b..23b4d9faa 100644 --- a/src/xrpld/app/hook/detail/HookAPI.cpp +++ b/src/xrpld/app/hook/detail/HookAPI.cpp @@ -1940,7 +1940,7 @@ HookAPI::state_foreign_set( // check if we've used a grant to modify this state entry before, if not // look up possible grants if (!hasFix || - hookCtx.result.foreignStateGrantCache.find(account) == + hookCtx.result.foreignStateGrantCache.find({account, ns}) == hookCtx.result.foreignStateGrantCache.end()) { auto const sle = @@ -2016,7 +2016,7 @@ HookAPI::state_foreign_set( } // add the grant to the cache - hookCtx.result.foreignStateGrantCache.emplace(account); + hookCtx.result.foreignStateGrantCache.emplace(account, ns); } if (auto ret = set_state_cache(account, ns, key, data, true);