Repository navigation
refactor: migrate witness terminology to validator (one-cycle compat) - #3
Merged
Merged
Conversation
Rename the virtual op struct and its inner `witness` field to `validator`. Add manual `init(from:)` with `legacyWitness = "witness"` CodingKey fallback so legacy chain data still decodes. Add deprecated typealias `WitnessReward` and a deprecated `init(witness:shares:)` overload plus `witness` computed property for source compatibility. Rename `testVirtualDecode_witnessReward` to `testVirtualDecode_validatorReward` and add `testDecode_validatorReward_legacyWitnessKey` that exercises decoding legacy JSON bodies directly via `AssertDecodes`. Update XCTestManifests.
…rSignature with dual-key decode
…with dual-key decode
Pins every deprecated typealias, computed property, and init overload introduced by Tasks 2–9 of the witness→validator migration. The whole XCTestCase is marked @available(*, deprecated) so deprecation warnings inside it are suppressed — Swift propagates the deprecation context. If any deprecated symbol is removed during Phase C cleanup, this file fails to compile, surfacing the breaking change before release.
…alias use - Register ChainIdTest (3 methods) which was entirely missing from the Linux manifest. - Add testOperationId_acceptsLegacyAndNewNames, testGeneratePrivateFromSeed, testInitWithOp, testAppend to their respective manifest extensions. - Annotate the DeprecatedAliasesTest manifest extension as deprecated so the reference to the deprecated class no longer emits a warning. - Refactor testOperationId_acceptsLegacyAndNewNames to compare against the canonical Validator* types rather than the deprecated Witness* typealiases, eliminating 5 deprecation warnings while preserving the same semantics. After this change the manifest registers exactly one entry per func test* method (120 total, matching swift test --filter UnitTests), and the build emits zero warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@available(*, deprecated, renamed:)aliasesWhat changed
5
OperationIdcases renamed; dual-string decodewitness_update→validator_update,account_witness_vote→account_validator_vote,account_witness_proxy→account_validator_proxy,shutdown_witness→shutdown_validator,witness_reward→validator_reward. Decoders accept both legacy and new op-name strings.5
Operation.*Swift types renamed (with deprecated typealiases)WitnessUpdate→ValidatorUpdate,AccountWitnessVote→AccountValidatorVote,AccountWitnessProxy→AccountValidatorProxy,ShutdownWitness→ShutdownValidator,WitnessReward→ValidatorReward.3 inner field renames with manual dual-key
init(from:)Operation.AccountValidatorVote.witness→validatorOperation.ValidatorReward.witness→validatorBlockHeader/SignedBlockHeader:witness/witnessSignature→validator/validatorSignature5 API response fields renamed
DynamicGlobalProperties:currentWitness→currentValidator,inflationWitnessPercent→inflationValidatorPercentExtendedAccount:witnessesVotedFor→validatorsVotedFor,witnessesVoteWeight→validatorsVoteWeight,witnessVotes→validatorVotesClient namespace routing
Client.swiftnow routes both legacy*_witness*and new*_validator*JSON-RPC method names to thevalidator_apinamespace.Deprecated aliases compile-smoke test
New
Tests/UnitTests/DeprecatedAliases.swift(class marked@available(*, deprecated)to suppress inner warnings) instantiates every deprecated alias/typealias/property/init overload at least once, guarding against accidental removal during Phase C cleanup.Test plan
swift test --filter UnitTests— 120 tests pass (was 109 on master, +11 new tests covering legacy-key decode and deprecated-alias smoke)swift build— 0 warningsswift build --build-tests— 0 warnings (no stalewitness*references in production code)XCTestManifests.swift) aligned with all 120 tests; audit also caught 7 pre-existing manifest gaps (ChainIdTest,testGeneratePrivateFromSeed,testInitWithOp,testAppend,testOperationId_acceptsLegacyAndNewNames) and registered themhttps://node.viz.cx) — should be run after the node rolls forward; the live wire format is the canaryPhase C cleanup (future PR, after one release cycle)
The migration is reversible-by-deletion. Grep for these
legacy*markers to find every back-compat code path:Plus the
// MARK: - Deprecated aliases (witness → validator migration, 2026-05-19)blocks at the bottom ofOperation.swift,Block.swift, andAPI.swift.References
docs/superpowers/specs/2026-05-19-witness-to-validator-design.mddocs/superpowers/plans/2026-05-19-witness-to-validator.md