Skip to content

test(vrf): add e2e test with real paymaster and VRF services#518

Draft
kariy wants to merge 9 commits intomainfrom
test/vrf-e2e
Draft

test(vrf): add e2e test with real paymaster and VRF services#518
kariy wants to merge 9 commits intomainfrom
test/vrf-e2e

Conversation

@kariy
Copy link
Copy Markdown
Member

@kariy kariy commented Apr 1, 2026

Summary

  • Add a full end-to-end test for the VRF flow using real paymaster-service and vrf-server sidecar binaries
  • Fix chain_id format sent to VRF server: was hex string, should be Cairo short string (caused signature mismatch)
  • Fix missing Span<felt252> length prefix in SignedOutsideExecutionCall conversion (caused deserialization failure)
  • Add Cairo vrng_test::Simple contract with constructor-based VRF provider address
  • Include a build.rs that compiles the Cairo contracts with scarb

Test plan

  • cargo run -p vrf-e2e-test passes locally (requires vrf-server and paymaster-service binaries in PATH, built from revs in sidecar-versions.toml)
  • CI builds successfully
  • Verify the two bug fixes don't break existing cartridge_vrf mock-based tests

🤖 Generated with Claude Code

kariy and others added 8 commits April 1, 2026 14:12
Sets up a VRF e2e test that spins up a Katana node, declares and deploys
the vrng_test Simple contract, and verifies deployment via RPC assertions.
Includes a build script to compile the Cairo contracts with scarb.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Update Cairo contract to accept VRF provider address via constructor
- Add full test flow: node startup, paymaster/VRF bootstrap, sidecar
  startup, contract deployment, and outside execution submission
- Fix missing signature length prefix in VRF client's
  SignedOutsideExecution → Call conversion (was causing
  "Failed to deserialize param #2")
- Whitelist VRF and estimate accounts on AVNU forwarder

WIP: signature verification on VRF account's execute_from_outside_v2
still fails ("SRC9: invalid signature").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix three bugs discovered during e2e testing:

1. Fix chain_id format sent to VRF server (rpc-server/cartridge/vrf.rs):
   Was sending hex string (e.g. "0x534e5f5345504f4c4941") but VRF server
   expects Cairo short string (e.g. "SN_SEPOLIA"). This caused signature
   hash mismatch → "SRC9: invalid signature".

2. Fix missing signature length prefix (cartridge/vrf/client.rs):
   The SignedOutsideExecution→Call conversion was missing the Span<felt252>
   length prefix before signature elements, causing "Failed to deserialize
   param #2" in the VRF account contract.

3. Deploy SRC9-compatible player account for VRF flow:
   The VRF flow wraps player calls in execute_from_outside_v2, which
   requires the player account to support SRC9. Genesis OZ accounts don't,
   so we deploy a CartridgeVrfAccount instance as the player.

Additional setup needed for e2e:
- Whitelist VRF and estimate accounts on AVNU forwarder
- Pre-allocate RPC port so VRF server gets correct RPC URL
- Sign outside execution with SNIP-12 using player's private key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use abigen! macro to generate typed contract bindings for SimpleVrfApp,
replacing manual RPC call construction. Add initial state assertion and
reorder dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace manual PaymasterServiceConfigBuilder and VrfServer setup with
the existing bootstrap_paymaster and bootstrap_vrf helpers from the
katana-cli sidecar module, which handle genesis account extraction
and config building internally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the type hashes, struct hash computation steps, and link to
the SNIP-12 specification. Note the account_sdk dependency conflict
that prevents reusing MessageHashRev1 directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant