Skip to content

Task3/richer slash with invalid block hash#35

Open
aprilyab wants to merge 5 commits intoiCog-Labs-Dev:devfrom
aprilyab:task3/richer-slash-with-invalid-block-hash
Open

Task3/richer slash with invalid block hash#35
aprilyab wants to merge 5 commits intoiCog-Labs-Dev:devfrom
aprilyab:task3/richer-slash-with-invalid-block-hash

Conversation

@aprilyab
Copy link
Copy Markdown
Collaborator

Fixes #34

Summary

Extended SystemDeployRequest::Slash to include invalid_block_hash field and updated the f1r3node adapter to pass the real invalid block hash instead of using validator bytes as placeholder.

Why this change is needed

f1r3node's SlashDeploy requires both the validator's public key AND the hash of the equivocating block being slashed. Our SystemDeployRequest::Slash only carried the validator NodeId, forcing the adapter to use validator bytes as a placeholder for invalid_block_hash. This was semantically wrong - f1r3node would receive the wrong hash for equivocation detection, potentially leading to incorrect slashing behavior.

What changed

  • Core API: Added invalid_block_hash: Vec<u8> field to SystemDeployRequest::Slash enum
  • MockRuntime: Updated pattern matching to handle new field (preserves it through execution)
  • Adapter: Modified system_deploy_to_f1r3node() to pass real invalid_block_hash instead of validator placeholder
  • Tests: Updated all test fixtures to include example invalid block hashes
  • Documentation: Updated all relevant docs to reflect breaking change and mark Task 3 as completed

Test plan

  • Core tests: cargo +nightly-2025-06-15 test -p cordial-miners-core (17/17 runtime tests pass)
  • Adapter tests: cargo +nightly-2025-06-15 test -p cordial-f1r3space-adapter (13/13 translation tests pass)
  • Verification: Tests confirm real invalid_block_hash is passed through to f1r3node's SlashDeploy

Integration crates modified

  • cordial-miners-core: Extended public API (SystemDeployRequest::Slash) - this is the breaking change
  • cordial-f1r3space-adapter: Updated translation logic to use new field
  • No changes to: cordial-f1r3node - layering rules preserved

Breaking change impact

  • Public API change: SystemDeployRequest::Slash now requires invalid_block_hash parameter
  • Internal consumers only: MockRuntime and F1r3RspaceRuntime (both updated)
  • Migration: Callers must provide invalid_block_hash when constructing slash requests

Documentation updates

  • docs/implementation.md: Updated API table and removed caveat about placeholder
  • docs/INTEGRATION_NEXT_STEPS.md: Marked Task 3 as COMPLETED
  • docs/cordial-miners-vs-cbc-casper.md: Updated Phase 3 status table

This fixes the core integration issue where f1r3node would receive incorrect block hashes for slashing operations, ensuring proper equivocation detection in the consensus layer.

f1r3node's SlashDeploy requires both validator public key and the hash of
the equivocating block being slashed. Our SystemDeployRequest::Slash only
carried the validator NodeId, forcing the adapter to use validator bytes as
a placeholder for invalid_block_hash, which is semantically wrong.

Added invalid_block_hash: Vec<u8> field to the enum and updated MockRuntime
pattern matching to handle the new field. MockRuntime preserves the field
through execution but doesn't use it for logic (deterministic hashing based
on processed results, not inputs).
The adapter was using validator.0 as placeholder for invalid_block_hash
when converting SystemDeployRequest::Slash to f1r3node's SystemDeployEnum.
This meant f1r3node received the wrong hash for equivocation detection.

Updated system_deploy_to_f1r3node() to pass the actual invalid_block_hash
field instead of validator bytes placeholder. Documentation updated to
reflect the breaking change and correct semantics.
Updated all documentation to reflect that SystemDeployRequest::Slash now
carries both validator and invalid_block_hash fields, fixing the API
limitation where only validator ID was available.

Changes:
- implementation.md: Updated API table and caveats section
- INTEGRATION_NEXT_STEPS.md: Marked Task 3 as COMPLETED
- cordial-miners-vs-cbc-casper.md: Updated Phase 3 status table

Breaking change properly documented across all relevant documentation.
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