Skip to content

fix(deploy): preserve devnet state on restart, add ansible user, image versioning, skip redundant init#12

Open
wpank wants to merge 1 commit into
Nunchi-trade:mainfrom
wpank:fix/docker-devnet-ansible-versioning
Open

fix(deploy): preserve devnet state on restart, add ansible user, image versioning, skip redundant init#12
wpank wants to merge 1 commit into
Nunchi-trade:mainfrom
wpank:fix/docker-devnet-ansible-versioning

Conversation

@wpank
Copy link
Copy Markdown

@wpank wpank commented May 30, 2026

Summary

Fixes four deployment/DevOps issues across the Docker devnet scripts and Ansible playbooks:

  • chore(transport,service): add Debug implementations to network types refcell/kora#56 - devnet-run.sh always clears runtime state: Adds --keep-state and --force-clean flags so operators can preserve QMDB/archive data across restarts. Default behavior is unchanged (clean state). Ansible gets a devnet_keep_state variable for the same purpose.

  • #183 - Ansible runs as root with no sudo boundary: Creates a dedicated kora service user during provisioning. All docker/compose playbooks now use become_user: kora instead of running everything as root. The user gets limited sudoers access (docker, systemctl only) with audit logging to /var/log/kora-sudo.log. The provision playbook still runs as root for package installation.

  • #191 - No image versioning or tagging strategy: Adds a comprehensive tagging strategy to docker-bake.hcl using git SHA, branch name, semver, and OCI labels. The Dockerfile embeds KORA_GIT_SHA/KORA_BUILD_TIMESTAMP as env vars. entrypoint.sh logs the image version on startup. Local builds auto-detect git metadata. The Ansible build role passes git SHA to the bake environment.

  • #193 - devnet-run.sh re-runs init-config when config exists: Adds an init-dkg-deal compose service that runs only keygen dkg-deal without re-running keygen setup. When peer config already exists but DKG shares are missing, both devnet-run.sh and the Ansible devnet role use this service, avoiding redundant config regeneration.

Test plan

  • Run ./scripts/devnet-run.sh (default) -- verify runtime state is cleared (existing behavior preserved)
  • Run ./scripts/devnet-run.sh --keep-state -- verify runtime volumes are NOT wiped
  • Run ./scripts/devnet-run.sh --force-clean -- verify explicit clean message in output
  • Verify just build passes GIT_SHA/GIT_SHA_SHORT/BUILD_TIMESTAMP to bake
  • Verify docker inspect kora:local shows OCI labels with git revision
  • Run devnet, stop validators, clear DKG shares only, re-run -- verify init-dkg-deal is used instead of init-config
  • Review Ansible base role creates kora user with docker group membership
  • Review Ansible deploy.yml uses become_user: kora for docker operations
  • Verify ansible-playbook playbooks/provision.yml still runs as root (no become_user)

🤖 Generated with Claude Code

…e versioning, skip redundant init

- refcell#56: Add --keep-state and --force-clean flags to devnet-run.sh so
  runtime state (QMDB, archives) is not unconditionally wiped on
  restart. Default behavior unchanged; use --keep-state to preserve.
  Ansible gets a devnet_keep_state variable for the same purpose.

- #183: Create a dedicated 'kora' service user in the base ansible
  role. All docker/compose playbooks now use become_user: kora instead
  of running everything as root. The kora user gets limited sudoers
  access to docker/systemctl only, with audit logging to
  /var/log/kora-sudo.log. Provision playbook still runs as root for
  package installation and user creation.

- #191: Add image versioning via git SHA and semver tags. docker-bake.hcl
  now generates sha-<short>, branch, semver, and latest tags with OCI
  labels. Dockerfile embeds GIT_SHA/BUILD_TIMESTAMP as env vars and
  labels. entrypoint.sh logs the image version on startup. Local builds
  via Justfile and devnet-run.sh auto-detect git metadata. Ansible build
  role passes git SHA to the bake environment.

- #193: Add init-dkg-deal compose service that runs only keygen dkg-deal
  without re-running keygen setup. When peer config already exists but
  DKG shares are missing, devnet-run.sh and the ansible devnet role now
  use this service instead of init-config, avoiding redundant config
  regeneration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
wpank pushed a commit to wpank/kora that referenced this pull request May 30, 2026
… truncation ordering

Fix two related executor issues:

1. BLOCKHASH opcode returns zero during block proposal/verification (Nunchi-trade#12):
   The `RevmApplication::block_context()` method never populated
   `recent_block_hashes`, causing all BLOCKHASH queries to return zero
   during consensus. The finalization replay path correctly populated
   them via `BlockIndex::recent_block_hashes()`, creating a state root
   mismatch that would crash the node when any contract used BLOCKHASH.

   Fix: Add `block_index: Arc<BlockIndex>` to `RevmApplication` and
   call `.with_recent_block_hashes()` in `block_context()`, matching
   the finalization path.

2. Block hash truncation uses non-deterministic HashMap ordering (#081):
   When `with_recent_block_hashes()` received >256 entries, it used
   `HashMap::into_iter().take(256)` which retains an arbitrary subset
   due to HashMap's randomized iteration order. Different validators
   could retain different subsets, causing consensus divergence.

   Fix: Compute the cutoff as `max_key - 255` and filter to retain
   only the 256 most recent block numbers. The test is strengthened
   to verify the correct entries are retained.

Closes Nunchi-trade#12
Closes #081

Co-Authored-By: Claude Opus 4.6 <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