Conversation
🦋 Changeset detectedLatest commit: a4d043e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds GCP KMS integration and runtime envs, replaces default keeper with a named Changes
Sequence DiagramsequenceDiagram
participant Client
participant PersonaHook as Persona Hook
participant RiskSvc as Risk Assessment
participant Allower as Firewall/Allower
participant GCP as GCP KMS
participant Chain as Chain / keeper
Client->>PersonaHook: POST inquiry
PersonaHook->>RiskSvc: perform risk assessment
RiskSvc-->>PersonaHook: pass/fail
alt pass
PersonaHook->>PersonaHook: derive account
PersonaHook->>Allower: getAllower()
Allower->>GCP: init credentials / request KMS-backed account
GCP-->>Allower: LocalAccount / credentials
Allower-->>PersonaHook: allower client ready
PersonaHook->>Allower: allow(account)
Allower-->>PersonaHook: allow result
PersonaHook->>Chain: keeper.poke(account, { ignore: [...] })
Chain-->>PersonaHook: tx hash / result
PersonaHook-->>Client: 200 success
else fail
PersonaHook-->>Client: rejection
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @aguxez, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the server's account management and security by integrating Google Cloud KMS for a new Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #839 +/- ##
==========================================
- Coverage 71.13% 71.04% -0.09%
==========================================
Files 211 212 +1
Lines 8355 8502 +147
Branches 2724 2766 +42
==========================================
+ Hits 5943 6040 +97
- Misses 2133 2164 +31
- Partials 279 298 +19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c642d46 to
88aa6aa
Compare
d4deb72 to
e474bf6
Compare
Additional Comments (1)
At runtime this is safe — only ETH entries have Consider asserting non-null at the call site to make the invariant explicit: Or narrow the type at build time by storing ETH entries and market entries in separate arrays. |
| await keeper | ||
| .poke(account, { ignore: [`NotAllowed(${account})`] }) | ||
| .catch((error: unknown) => captureException(error, { level: "error" })); |
There was a problem hiding this comment.
🚩 NoBalance() special handling removed without replacement
The old activity.ts had a specific retry-and-capture flow for NoBalance() errors: it used { ignore: ["NoBalance()"] } in exaSend, then re-threw inside .then() to trigger withRetry, and finally captured the error as a warning (not error) if all retries were exhausted.
The new code passes { ignore: [\NotAllowed(${account})`] }instead, meaningNoBalance()is no longer ignored byexaSend. If a poke reverts with NoBalance(), the withRetryinsidepoke (server/utils/accounts.ts:137-163) will retry it (default retry behavior), but each retry's failure is captured at errorlevel viaexaSend's catch block — previously it was only warning` after all retries.
The corresponding test (captures no balance once after retries) was also removed. This seems intentional per the PR's simplification goals, but changes error noise characteristics in Sentry.
Was this helpful? React with 👍 or 👎 to provide feedback.
17aa7dc to
115a36a
Compare
Additional Comments (2)
Downstream in await initializeGcpCredentials(); // returns cached no-op promise
if (!(await hasCredentials())) throw … // file is gone → always throwsThe server cannot recover without a full restart. The Suggested fix: Call export async function getAccount(): Promise<LocalAccount> {
await initializeGcpCredentials();
if (!(await hasCredentials())) {
resetGcpInitialization(); // allow next caller to retry
throw new Error(…);
}
…
}
These GCP env-var checks run at module import time, before any GCP-dependent code is invoked. This breaks the deployment of unrelated features if GCP credentials are not configured, and makes testing hooks that use Suggested fix: Move the GCP env-var validation inside export async function getAccount(): Promise<LocalAccount> {
if (!process.env.GCP_PROJECT_ID) throw new Error("GCP_PROJECT_ID is required");
const projectId = process.env.GCP_PROJECT_ID;
if (!/^[a-z][a-z0-9-]{4,28}[a-z0-9]$/.test(projectId)) {
throw new Error("GCP_PROJECT_ID must be a valid GCP project ID format");
}
// … validate GCP_KMS_KEY_RING and GCP_KMS_KEY_VERSION here too
await initializeGcpCredentials();
…
}This keeps |
Additional Comments (3)
Prefer the explicit exponentiation operator instead:
The triple base64 decode ( Consider adding a comment to the constant (and possibly the app.yaml instructions) documenting the expected encoding:
The |
closes #643
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores
Greptile Summary
This PR integrates Google Cloud KMS (via
@google-cloud/kmsand@valora/viem-account-hsm-gcp) to sign firewallallowtransactions with an HSM-backed key, and adds a newkeeper.pokeutility that proactively pokes account assets (ETH, WETH, ERC-20) after KYC approval and on activity webhooks.Key changes:
server/utils/gcp.ts— new module handles credential bootstrapping (triple base64 decode →/tmp/gcp-service-account.json), lazy initialization with promise caching, and retryable KMS error classification.server/utils/accounts.ts— addsgetAccount()(GCP KMS → viemLocalAccount),allower()(wallet client that wrapsallowon the Firewall contract), andpoke()(scans balances and pokes every non-zero asset viaexaSend).server/hooks/persona.ts— after KYC approval callsallowthen fire-and-forgetspoke;allowerPromisecaches the expensive KMS init across requests.server/hooks/activity.ts— callspokeafter account deployment, withNotAllowedin the ignore list.Verified findings:
delayfunction inpoke'swithRetryuses bitwise left-shift which overflows atcount >= 31(currently safe withretryCount: 10, but a footgun if the parameter is raised).DECODING_ITERATIONS = 3constant lacks documentation explaining the triple base64 encoding strategy.keeperclient'sonFetchRequesthook lacks error handling, unlike theallowerversion, making it susceptible to unhandled exceptions on malformed RPC payloads.Confidence Score: 3/5
retryCountis raised, (2) the triple base64 decoding strategy lacks documentation creating fragility, and (3) the missing try/catch inkeeper'sonFetchRequestcreates an inconsistency withallowerthat could surface unhandled exceptions. None of these are critical under normal conditions, but they represent code-quality debt worth fixing before production ramp-up.server/utils/accounts.ts(bitwise-shift delay, error handling inconsistency) andserver/utils/gcp.ts(undocumented constant).Last reviewed commit: 0275499
Context used:
dashboard- AGENTS.md (source)dashboard- CLAUDE.md (source)