refactor(ethereum): split tBTC chain adapter into per-concern files#4191
Open
piotr-roslaniec wants to merge 1 commit into
Open
refactor(ethereum): split tBTC chain adapter into per-concern files#4191piotr-roslaniec wants to merge 1 commit into
piotr-roslaniec wants to merge 1 commit into
Conversation
pkg/chain/ethereum/tbtc.go had grown to ~2400 lines and ~90 methods spanning every tBTC concern. Split it into per-concern files within the same package so the adapter is navigable: - tbtc.go: TbtcChain struct, constructor, shared constants - tbtc_sortition.go: sortition pool, operator status, group selection - tbtc_dkg.go: DKG lifecycle, result assembly and validation - tbtc_inactivity.go: inactivity claims - tbtc_deposit.go: deposit reveal, sweep proposals and proofs - tbtc_redemption.go: redemption requests, proposals and proofs - tbtc_wallet.go: wallet registration/state, heartbeat proposals - tbtc_moving_funds.go: moving funds and moved funds sweep Pure relocation: no declaration bodies changed. Verified by comparing the AST of every top-level declaration before and after the split - all 96 declarations are byte-identical.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
TL;DR for reviewers
This is a pure, AST-verified relocation — no declaration body changed.
pkg/chain/ethereum/tbtc.go(~2400 lines, ~90 methods onTbtcChain) is split into per-concern files within the same package. Every top-level declaration was moved verbatim; a tool compared the AST of all 96 declarations before and after the split and confirmed each is byte-identical. Build,go vet, and the ethereum test suite all pass. It should review in minutes, not hours: check the file assignments, not the bodies.Why
The adapter had become a monolith spanning every tBTC concern (sortition, DKG, inactivity, deposit, redemption, wallet, moving funds) in one file, making it hard to navigate. Same-package split ⇒ no visibility or interface-satisfaction changes.
New file layout
tbtc.goTbtcChainstruct, constructor, shared constants,TxProofDifficultyFactortbtc_sortition.gotbtc_dkg.gotbtc_inactivity.gotbtc_deposit.gotbtc_redemption.gotbtc_wallet.gotbtc_moving_funds.goNotes / deviations
tbtc.goat ~1200 lines — still a monolith. Splitting those out too is what actually de-monoliths the adapter.ValidateHeartbeatProposal); folded intotbtc_wallet.go(wallet liveness) rather than given its own file.goimports(preserves the custom aliasesecdsaabi/tbtcabi/tbtccontract/ecdsacontract).Base / stacking
Based on
refactor/named-chain-param-getters(#4188), notmain: #4188 also editstbtc.go(theGet*Parametersgetters), so splitting on top of it avoids a conflict. Once #4188 merges, this branch should be rebased--onto main.