fix(smart-router): extract policy validation from ParseMsg#2244
Conversation
Review Summary by QodoReplace global policy verification flag with per-instance setting
WalkthroughsDescription• Replace global SkipPolicyVerification bool with per-instance field on BaseChainParser • Smart-router automatically skips policy verification at chain parser creation • Remove --skip-policy-verification flag from smart-router command • Update ChainParser interface and mock implementations with new method Diagramflowchart LR
A["Global SkipPolicyVerification bool"] -->|"Replaced with"| B["Per-instance skipPolicyVerification field"]
B -->|"Set via"| C["SetSkipPolicyVerification method"]
D["Smart-router CreateSmartRouterEndpoint"] -->|"Calls"| C
C -->|"Enables"| E["Policy verification skipped for static providers"]
File Changes1. protocol/chainlib/base_chain_parser.go
|
Code Review by Qodo
1.
|
2c6c3b1 to
d983346
Compare
01e69d0 to
8041bba
Compare
…uiring flag The smart-router uses static providers without on-chain pairing, so addon/extension policy verification is not applicable. Previously this required operators to pass --skip-policy-verification, which was a footgun — addon requests would silently fail without it. Replace the global SkipPolicyVerification bool with a per-instance skipPolicyVerification field on BaseChainParser. The smart-router now calls SetSkipPolicyVerification() on each chain parser at creation time, removing the flag entirely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ateMessage Instead of adding a skip flag to BaseChainParser, move addon policy validation out of ParseMsg entirely. Consumer and provider explicitly call ValidateMessage after parsing; smart-router simply doesn't. This keeps smart-router concerns out of shared chainlib code: - Remove SkipPolicyVerification global and skipPolicyVerification field - Remove SetSkipPolicyVerification from ChainParser interface - Add ValidateMessage(ChainMessage) to ChainParser interface - Remove Validate call from ParseMsg in all 4 chain parsers - Consumer/provider call ValidateMessage after ParseMsg Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Consumer and provider now call ParseAndValidateMessage instead of separate ParseMsg + ValidateMessage calls. This makes the validated path the obvious default and prevents callers from forgetting to validate. Smart-router continues calling ParseMsg directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The skip parameter only existed for SkipPolicyVerification which was removed. AllowedExtension now just does a map lookup, matching the isAddon pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ith allowedAddons isExtension now does a direct map lookup on BaseChainParser, matching the isAddon pattern. Remove allowedExtensions and AllowedExtension from ExtensionParser since it only handled configured extensions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8041bba to
f36ff0a
Compare
User description
Summary
ParseMsgwas rejecting addon requests unless operators passed--skip-policy-verification. Instead of adding a skip flag, validation is extracted into an explicitValidateMessage()step — consumer and provider callParseAndValidateMessage(), smart-router callsParseMsgdirectly.allowedExtensionsfromExtensionParsertoBaseChainParsersoisExtensionmatches theisAddonpattern (direct map lookup). Remove deadAllowedExtensionmethod and skip parameter.Changes
ParseMsgnow only parses — no longer validates against consumer policyValidateMessage(ChainMessage) erroronChainParserinterface, called viaParseAndValidateMessageconvenience functionParseAndValidateMessage; smart-router usesParseMsgdirectlySkipPolicyVerification--skip-policy-verificationSkipPolicyVerificationFlagTest plan
go build ./protocol/...compiles cleanlygo test ./protocol/chainlib/passesgo test ./protocol/rpcprovider/passesgolangci-lint)SkipPolicyVerification🤖 Generated with Claude Code
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Refactor the parsing flow so
ParseMsgfocuses on decoding andParseAndValidateMessageenforces the consumer policy through the newValidateMessagehook onChainParser, allowing consumers/providers to reject disallowed addons while the smart router still reuses the raw parser. AlignBaseChainParser’s policy state with the extension system so addon/extension checks use the same allowance maps and the CLI no longer exposes a policy-skip flag.ParseAndValidateMessagehelper,ValidateMessageinterface, and parser changes so consumers/providers validate addon policy after parsing while smart-router keeps callingParseMsg, updating mocks and tests plus removing the obsolete skip flag and flag constant.Modified files (12)
Latest Contributors(2)
BaseChainParserand simplifyExtensionParsersoisExtensionuses the shared map, updating the parser constructor and tests accordingly.Modified files (3)
Latest Contributors(2)