Priority: P2 — multi-process wallet access assumptions: the daemon and the CLI can open the same bbolt wallet concurrently.

オープン
#504 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Amperstrand がすでに取り組んでいます。

2026年11月2日 から。

  • #742 @Amperstrand による — マージされずにクローズ
  • #870 @Amperstrand による — マージされずにクローズ
  • #1173 @Amperstrand による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
docker, go

調査の方向性

Start by auditing wallet-opening paths in src/cmd/tollgate-cli/, src/tollwallet/{select.go,sidecar.go}, daemon startup, and migration tools; verify the gonuts storage/bolt.go lock options. Then document the single-writer invariant and establish the intended behavior for daemon-plus-CLI and sidecar configurations. Done means the inventory is merged and the required concurrency, filesystem, and recovery tests show no dual writer.

索引モデルが issue の本文から書いたものです。

説明

Priority: P2 — multi-process wallet access assumptions: the daemon and the CLI can open the same bbolt wallet concurrently.

Problem

tollgate-cli (drain, fund, wallet ops) opens the same wallet.db (bbolt) as the running daemon. bbolt takes an OS file lock, so the file is single-writer — but the failure mode when the lock is held is an error at CLI time, and if any code path ever runs with the DB on a filesystem where flock is unreliable (some overlayfs/NAND configurations on OpenWrt), two writers corrupting the counter lineage is exactly the #480/#266 class again. Additionally the sidecar backend (src/tollwallet/sidecar.go) introduces a second daemon with its own wallet access by design.

Why it matters

Wallet-state writers must be provably single-writer per DB, or counter discipline (monotonic, reserved-before-expose) is unenforceable across processes. This is an audit + documentation + guard-rail issue, not an expected daily failure.

Current behavior (source refs)

  • src/cmd/tollgate-cli/ — opens wallet via same tollwallet.New path (verify: which subcommands open the DB while the daemon runs? drain does).
  • gonuts wallet/storage/bolt.go — bolt.Open(path, 0600, nil) default (no NoSync, blocking lock) — lock behavior on conflict = error after timeout? verify options.
  • Sidecar: separate daemon owns the wallet; the in-process daemon must then NOT also open it (policy enforcement?).

Desired invariant

Exactly one process has write access to a wallet DB at any time; conflicting access fails fast with a clear operator message; the sidecar architecture enforces this structurally (daemon never opens the DB when a sidecar owns it).

Proposed scope

  1. Audit: enumerate every wallet-opening entry point (daemon boot, CLI subcommands, sidecar, migration tools); document lock semantics on target filesystems (ext4 rootfs, overlayfs on NAND, btrfs?) — lab-verify flock on the MT3000's storage.
  2. CLI UX: pre-flight check for daemon-held lock → either route through the daemon socket (preferred for online ops) or refuse with guidance.
  3. Sidecar policy: config validation rejects simultaneous in-process wallet + sidecar for overlapping mints.
  4. Document the single-writer rule in AGENTS.md's implementation section (cross-ref).

Areas / files

src/cmd/tollgate-cli/, src/tollwallet/{select.go,sidecar.go}, gonuts storage/bolt.go (options only), docs.

Acceptance criteria

  • Inventory doc merged; concurrent-open attempt produces the defined behavior on lab hardware (evidence attached); no path can dual-open with the sidecar.

Required tests

  • Integration: daemon running → CLI drain attempt → defined outcome (routed or refused, never a second writer).
  • Filesystem: flock behavior test on overlayfs image (CI docker with overlay storage).

Failure-injection tests

  • Kill daemon while CLI holds a brief lock → daemon recovery re-acquires cleanly.
  • Simulated flock-less FS (fuse stub or documented waiver) → wallet opens read-only or refuses.

Compatibility

CLI behavioral change possible (route-through-daemon) — release-note it.

Dependencies

None.

Out of scope

  • bbolt replacement.
主要言語
Go
スター
12
フォーク
14
平均マージ
3日 20時間
マージ済み PR(30日)
261

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenTollGate/tollgate-module-basic-go のほかの issue

OpenTollGate/tollgate-module-basic-go の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。