fix(tip403): cache policy id counter#515
Open
mattsse wants to merge 1 commit into
Open
Conversation
93b735e to
5ef8730
Compare
5ef8730 to
c5d4d04
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
policyIdCounterintoPolicyCacheduring node startup.Option<u64>so an unseeded cache remains explicitly unknown.policyIdCounter()cache miss, fetch the authoritative value from L1 atlast_l1_block, cache it, and return it.PolicyCheck::policy_id_counter()calls from local cache state.Root Cause
The previous implementation derived
policyIdCounter()frommax(cached policy id) + 1, but the policy cache can be missing policies that exist on L1. That makes the derived value only a lower bound. Keeping the authoritative value in the cache fixes the undercount without putting an L1 RPC call on every zone precompile invocation.Impact
Contracts calling the zone TIP-403 proxy get a locally served counter after startup seeding or the first cache-miss fallback. If the counter is genuinely unknown, the proxy fetches it once from L1 and stores it for future calls instead of fabricating
2or performing network IO every time.