sidecar: harden /tx?hash= discriminator and lock ctx-plumbing audit#173
Merged
Conversation
Closes seictl#172 items 1 and 2. Item 3 (fee_payer/granter integration
assertion) ships with the gov-vote handler PR.
Replace the free-form err.Error() substring match with a typed
*rpctypes.RPCError assertion. Transport errors (DNS lookup failures,
connection-refused, http transport timeouts) are wrapped Go errors —
NOT *RPCError — so errors.As fences them out at the gate. A DNS "host
not found" can no longer be confused with a missing tx.
Server-side, sei-tendermint converts every handler error to
RPCError{Code: CodeInternalError, Data: err.Error()} via MakeError
(rpc/jsonrpc/types/types.go), so the discriminator must look at the
Data substring — Code alone catches every internal error indiscriminately.
The ctx-plumbing audit (item 2) confirmed http.NewRequestWithContext
is used in the vendored jsonrpc client. The 30s tmRPCTimeout from #170
is a redundant upper bound, not the only stop. A code comment locks
that finding so future readers don't re-derive it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 tasks
bdchatham
added a commit
that referenced
this pull request
May 12, 2026
First user-facing gov sign-tx handler. Composes on the sign-tx foundation (#170) and hardening (#173). ## Summary - New \`TaskGovVote\` task type + \`sidecar/tasks/gov_vote.go\` handler that builds Cosmos gov v1beta1 \`MsgVote\` and delegates to \`SignAndBroadcast\`. - \`GovVoteTask\` Go client SDK helper. - No chain-query idempotency — chain handles last-write-wins on \`(proposalID, voter)\`; caller's request is authoritative. - Also closes #172 item 3 (deferred from #173): \`TestSignedTxHasNoFeePayerOrGranter\` decodes the signed proto Tx and asserts \`AuthInfo.Fee.Payer\` / \`Granter\` are empty strings. - Exported \`ParseVoteOption\` so client and server share one canonical option set (no drift). - Two follow-ups tracked in #174: per-handler idempotency review template (load-bearing once a non-idempotent sign-tx handler ships), \`TaskResult.Output\` engine extension. ## Test plan - [x] \`TestParseVoteOption\` table — case-insensitivity, kebab alias, empty/unknown rejection - [x] \`TestBuildVoteMsg\` subtests — happy path (incl. \`ValidateBasic\` assertion), zero proposalID, invalid option, nil keyring, empty keyName, missing key — all Terminal - [x] \`TestSignedTxHasNoFeePayerOrGranter\` — proto-level fee-payer/granter empty assertion - [x] \`go build ./...\` clean - [x] \`go test ./... -count=1\` clean (all packages) - [x] \`go test -race ./sidecar/tasks/\` clean - [x] \`golangci-lint run --new-from-rev=origin/main ./...\` reports 0 issues - [x] Coral trio cross-review (platform / kubernetes / security) — synthesized findings applied; remaining deferred to #174 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **High Risk** > Adds a new sign-and-broadcast task that can submit on-chain governance votes using the validator’s keyring, which is security-sensitive (especially given the sidecar API exposure). Also introduces new invariants around tx fee payer/granter enforced by tests, but mistakes could still result in unintended transactions/fees. > > **Overview** > Adds a new `gov-vote` task end-to-end: registers `engine.TaskGovVote` in `serve.go`, defines the task type in `engine/types.go`, and implements `sidecar/tasks/gov_vote.go` to build a gov v1beta1 `MsgVote` and delegate signing/broadcasting to `SignAndBroadcast`. > > Extends the Go client SDK (`sidecar/client/tasks.go`) with a typed `GovVoteTask` (validation + wire params) and shares vote-option parsing via exported `tasks.ParseVoteOption`. > > Hardens tx signing tests by capturing broadcast tx bytes and asserting, at the protobuf level, that `AuthInfo.Fee.Payer` and `AuthInfo.Fee.Granter` are empty, preventing accidental fee delegation regressions. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b1061c3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8 tasks
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.
Closes #172 items 1 and 2. Item 3 (fee_payer/granter integration assertion) ships with the gov-vote handler PR — it makes more sense alongside a handler that actually signs a tx end-to-end.
Summary
strings.Contains(strings.ToLower(err.Error()), \"not found\")with a typed*rpctypes.RPCErrordiscriminator (isTxNotFound). Transport errors are wrapped Go errors, not*RPCError, soerrors.Asfences them out — DNS "host not found" can no longer be confused with a missing tx.http.NewRequestWithContext, so the 30stmRPCTimeoutfrom feat(sidecar): sign-tx foundation (PR-A of #163, foundation-only) #170 is a redundant upper bound, not the only stop.Test plan
TestIsTxNotFoundcovers: server-side tx-not-found, other server internal error, wrapped RPCError, transport error containing "not found" as decoy substring, nil🤖 Generated with Claude Code
Note
Low Risk
Low risk: small, well-tested change to error classification in
QueryTxplus a clarifying comment about context cancellation; main impact is how missing-tx vs real transport errors are handled.Overview
Tightens
QueryTxerror handling by replacing the substring-based "not found" check with a typed*rpctypes.RPCErrordiscriminator (isTxNotFound), preventing transport/DNS errors from being misclassified as missing transactions.Adds a unit test suite for
isTxNotFound(including wrapped RPC errors and decoy "not found" transport messages) and documents thatctxcancellation propagates into the underlying Tendermint JSON-RPC HTTP request (making the existing 30s timeout a secondary bound).Reviewed by Cursor Bugbot for commit 8ec8d48. Bugbot is set up for automated code reviews on this repo. Configure here.