Skip to content

fix(solana): auto-load wallet from ~/.blockrun/.solana-session (parity with Base)#10

Merged
VickyXAI merged 2 commits into
BlockRunAI:mainfrom
KillerQueen-Z:fix/solana-wallet-autoload
Jun 14, 2026
Merged

fix(solana): auto-load wallet from ~/.blockrun/.solana-session (parity with Base)#10
VickyXAI merged 2 commits into
BlockRunAI:mainfrom
KillerQueen-Z:fix/solana-wallet-autoload

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Contributor

Problem

SolanaLLMClient / AsyncSolanaLLMClient resolved the wallet key from private_key or the SOLANA_WALLET_KEY env var only:

key = private_key or os.environ.get("SOLANA_WALLET_KEY")

The Base LLMClient already falls back to the on-disk session:

key = private_key or os.environ.get("BLOCKRUN_WALLET_KEY") or os.environ.get("BASE_CHAIN_WALLET_KEY") or load_wallet()

So with a Solana wallet at ~/.blockrun/.solana-session you still had to export SOLANA_WALLET_KEY, and the blockrun-litellm sidecar's fail-fast wallet check refused to start without it — a confusing asymmetry with Base.

Fix

Add the missing load_solana_wallet() fallback to both sync and async clients, mirroring the Base clients:

key = (
    private_key
    or os.environ.get("SOLANA_WALLET_KEY")
    or load_solana_wallet()  # ~/.blockrun/.solana-session
)

Now SOLANA_WALLET_KEY is optional when a session file exists. No behavior change when the env var or an explicit key is provided.

Tests

  • test_raises_without_key now patches load_solana_wallet -> None so it's deterministic regardless of whether the host has a session file.
  • New test_init_from_session_file covers the fallback.
  • Full unit suite: 256 passed.

SolanaLLMClient resolved its key from `private_key` or the SOLANA_WALLET_KEY env
var only — unlike the Base LLMClient, which also falls back to load_wallet()
(~/.blockrun/.session). So a host with a Solana wallet session on disk still had
to export SOLANA_WALLET_KEY, and the blockrun-litellm sidecar refused to start
(its fail-fast wallet check) without it.

Add the missing load_solana_wallet() fallback to both SolanaLLMClient and
AsyncSolanaLLMClient, mirroring the Base clients. Now the env var is optional
when a session file exists.

Tests: test_raises_without_key now patches load_solana_wallet -> None so it's
deterministic regardless of the host's session file; new test_init_from_session_file
covers the fallback. Full unit suite: 256 passed.
…over async + bad-key

Review follow-ups to the session-file auto-load:
- Fix misleading comment/error: load_solana_wallet() scans the newest
  ~/.*/solana-wallet.json from ANY provider first, then ~/.blockrun/.solana-session
  — the old text named only the session file, hiding which key is actually used.
- Validate the resolved key for true Base parity: wrap _create_signer so a
  malformed key (incl. one auto-loaded from disk) raises a clean ValueError
  instead of a raw base58/solders exception. Both sync and async clients.
- Guard the legacy session-file read against OSError (unreadable file → no wallet,
  not a crash), matching the provider-scan path.
- Tests: add async session-file fallback + invalid-key coverage.
@VickyXAI VickyXAI merged commit 996f50d into BlockRunAI:main Jun 14, 2026
3 checks passed
VickyXAI pushed a commit that referenced this pull request Jun 15, 2026
Bump 1.4.1 -> 1.4.2. Ships the #10 fix: SolanaLLMClient / AsyncSolanaLLMClient
fall back to the on-disk wallet session when SOLANA_WALLET_KEY is unset, with
clean error handling for malformed/unreadable keys.
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