Resolve "Implement GrandpaApi::submit_report_equivocation_unsigned_extrinsic"
Goal of the changes
Enable GRANDPA equivocation reporting through the runtime API (it previously returned None), and add an integration test proving the API path works end-to-end.
What changed
- Implemented GRANDPA runtime API support in
runtime/common/src/apis.rs:-
GrandpaApi_submit_report_equivocation_unsigned_extrinsicnow:- decodes
OpaqueKeyOwnershipProof, - calls
Grandpa::submit_unsigned_equivocation_report(...), - returns
Some(())on success.
- decodes
-
GrandpaApi_generate_key_ownership_proofnow:- uses
Historical::prove((sp_consensus_grandpa::KEY_TYPE, authority_id)), - encodes it as
OpaqueKeyOwnershipProof, - returns
Some(proof)when available.
- uses
-
- Added a new integration test in
runtime/gdev/tests/offence_tests.rs:-
test_grandpa_runtime_api_submit_report_equivocation_unsigned_extrinsic. - Builds a valid GRANDPA equivocation proof.
- Calls runtime APIs via
gdev_runtime::api::dispatch(...). - Verifies:
- key ownership proof is returned,
- submit API returns
Some(()), - one unsigned extrinsic is pushed to offchain tx pool,
- the extrinsic is
RuntimeCall::Grandpa(report_equivocation_unsigned { .. }).
-
- Added test-only dependency
finality-grandpa = "0.16.3"inruntime/gdev/Cargo.toml(and lockfile update).
Reviewer notes
- This fixes a real behavior gap: GRANDPA equivocation submission was effectively disabled in runtime API.
- The new test validates the runtime API call path itself (not only direct
Offences::report_offence), which guards against regressions in API wiring and proof handling. - Scope is limited to GRANDPA runtime API behavior and test coverage; no change to offence handling policy (still blacklist/offline, no slashing logic introduced).
Breaking changes
None expected.
- Runtime API behavior changed from “always
None” to functional reporting for GRANDPA equivocations. - This is a compatibility improvement and aligns GRANDPA behavior with expected equivocation-report flow.
Testing
Executed:
cargo test -p gdev-runtime --test offence_tests test_grandpa_runtime_api_submit_report_equivocation_unsigned_extrinsiccargo test -p gdev-runtime --test offence_tests
Closes #351 (closed)