Skip to content

fix(erpc:PLA-1613): isolate vendor cache keys#97

Open
0x666c6f wants to merge 7 commits into
morpho-mainfrom
feature/pla-1613-fix-erpc-provider-mapping-vendor-cache-and-repository-method
Open

fix(erpc:PLA-1613): isolate vendor cache keys#97
0x666c6f wants to merge 7 commits into
morpho-mainfrom
feature/pla-1613-fix-erpc-provider-mapping-vendor-cache-and-repository-method

Conversation

@0x666c6f

@0x666c6f 0x666c6f commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Scope remote catalog cache keys by provider id plus vendor-specific inputs for QuickNode, Chainstack, and Repository.
  • Replace raw secret key parts with opaque process-local tokens so cache keys do not expose or digest API keys.
  • Update provider docs for QuickNode tag-based endpoint groups.

Linear: https://linear.app/morpho-labs/issue/PLA-1613/fix-erpc-provider-mapping-vendor-cache-and-repository-method

Validation

  • go test ./thirdparty ./common -count=1

Notes

  • go test ./... was attempted locally but Docker-backed tests fail on this host with rootless Docker not found, failed to create Docker provider.

Copilot AI review requested due to automatic review settings June 24, 2026 14:11
Comment thread thirdparty/vendor_cache_key.go Outdated
return fmt.Sprintf("%s|provider=%s|key=%s", vendorName, providerID, hex.EncodeToString(h.Sum(nil))[:24])
}

type cacheHash interface {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'cacheHash' interface duplicates io.Writer; use io.Writer instead to avoid an unnecessary local type and simplify the code.

Details

✨ AI Reasoning
​A new small helper interface is introduced solely to expose a Write([]byte) method. The standard library already provides io.Writer with the exact signature. Using io.Writer would reduce indirection and avoid defining an unnecessary local type, improving readability without changing behavior.

🔧 How do I fix it?
Rewrite the snippet in the simpler, behavior-equivalent form: return a boolean expression directly instead of if cond return true else return false, avoid using lists when they are guaranteed to contain one element, etc.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Comment thread thirdparty/vendor_cache_key.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Scopes vendor remote-catalog cache keys by provider id and vendor-specific inputs (and hashes secret-bearing parts) so multiple providers can safely share the same vendor account credentials without RemoteDataCache snapshot collisions.

Changes:

  • Introduces a shared cache-key helper (vendorCapabilityCacheKey) that mixes vendor name + provider id + hashed parts (with secretCachePart).
  • Updates QuickNode, Chainstack, and Repository vendors to use provider-scoped cache keys (and adjusts tests accordingly).
  • Updates provider docs to reflect the new QuickNode tag-group behavior (with examples).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
thirdparty/vendor_cache_key.go Adds helper utilities for provider-scoped, secret-safe remote cache keys.
thirdparty/vendor_cache_key_test.go Adds focused tests ensuring provider isolation and secret redaction in keys.
thirdparty/repository.go Scopes repository remote cache entries by provider id + repository URL (hashed into key).
thirdparty/quicknode.go Scopes QuickNode endpoint snapshots by provider id + apiKey (hashed) + tag filters.
thirdparty/quicknode_test.go Updates snapshot keys to match new QuickNode cache-key scheme; adds reuse test.
thirdparty/provider.go Injects provider id into vendor settings to enable provider-scoped cache keys.
thirdparty/provider_test.go Verifies provider id injection does not mutate original settings; adds template test.
thirdparty/chainstack.go Scopes Chainstack node snapshots by provider id + apiKey (hashed) + filters.
thirdparty/chainstack_test.go Updates cache-key test to assert provider scoping and no raw apiKey leakage.
docs/pages/config/projects/providers.mdx Updates QuickNode guidance and examples for provider-id + tag-based isolation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

apiKey: \${QN_ARCHIVE_KEY}
apiKey: \${QN_API_KEY}
tagLabels: archive
# fast tip-of-chain endpoints on a separate key

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b04d2e4bf2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread thirdparty/provider.go
Copilot AI review requested due to automatic review settings June 24, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comment thread thirdparty/vendor_cache_key.go Outdated
Comment on lines +77 to +80
key := name + "\x00" + value
if cached, ok := secretCachePartIDs.Load(key); ok {
return name + "=secret:" + cached.(string)
}
Copilot AI review requested due to automatic review settings June 24, 2026 14:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread thirdparty/chainstack_test.go
Comment thread thirdparty/quicknode_test.go
Comment thread thirdparty/vendor_cache_key.go Outdated
Comment thread thirdparty/vendor_cache_key.go Outdated
return name + "=secret:" + hex.EncodeToString(mac.Sum(nil))[:24]
}

func writeSecretCachePart(mac hashWriter, name, value string) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeSecretCachePart issues multiple small writes and temporary byte conversions; combine into a single write (single buffer or formatted write) to simplify and reduce allocations.

Details

✨ AI Reasoning
​The helper writeSecretCachePart writes the name, separator, length and value via four separate mac.Write calls with temporary byte conversions. This is more verbose than necessary and creates repeated allocations for small byte slices. Building a single byte slice (or using fmt.Fprintf with a bytes.Buffer) and writing once would be simpler and clearer while preserving semantics.

🔧 How do I fix it?
Rewrite the snippet in the simpler, behavior-equivalent form: return a boolean expression directly instead of if cond return true else return false, avoid using lists when they are guaranteed to contain one element, etc.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Copilot AI review requested due to automatic review settings June 24, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

thirdparty/provider.go:165

  • applyUpstreamIDTemplate now substitutes <EVM_CHAIN_ID> with the literal string N/A for non-evm: networks. This changes upstream ID generation behavior (previously the placeholder would typically be removed/empty), which can be a breaking change for deployments relying on stable IDs/metrics naming, and it’s not mentioned in the PR description (which focuses on vendor cache keys). Consider either (a) reverting to the prior empty-string behavior for backward compatibility, or (b) explicitly calling out this behavior change in the PR description/release notes so users can opt in by updating templates.
	// If network is in "evm:<someChainId>" format, then <EVM_CHAIN_ID> = <someChainId>.
	// Otherwise, we replace that placeholder with N/A.
	if strings.HasPrefix(networkId, "evm:") {
		evmChainId := strings.TrimPrefix(networkId, "evm:")
		result = strings.ReplaceAll(result, "<EVM_CHAIN_ID>", evmChainId)
	} else {
		result = strings.ReplaceAll(result, "<EVM_CHAIN_ID>", "N/A")
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants