refactor(chain): return named parameter structs from tBTC getters - #4188
Merged
Conversation
The on-chain parameter getters returned wide positional tuples (up to 11 values plus err) that callers destructured with long blank-identifier lists, where a positional slip would compile silently. Replace them with named structs (MovingFundsParameters, WalletParameters, DepositParameters, RedemptionParameters) in pkg/tbtc so callers access fields by name. GetMovingFundsParameters lives on tbtc.BridgeChain (embedded by tbtcpg.Chain); the other three on tbtcpg.Chain. All structs live in pkg/tbtc, which the ethereum adapter and tbtcpg already import.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughTBTC parameter getters now return shared structs for deposit, redemption, wallet, and moving-funds settings. Interfaces, Ethereum and local implementations, validation logic, and fee-estimation consumers are updated to use the new struct fields. ChangesTBTC parameter consolidation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
lrsaturnino
approved these changes
Jul 29, 2026
This was referenced Aug 7, 2026
piotr-roslaniec
added a commit
that referenced
this pull request
Aug 18, 2026
…4191) ## TL;DR for reviewers **This is a pure, AST-verified relocation — no declaration body changed.** `pkg/chain/ethereum/tbtc.go` (~2400 lines, ~90 methods on `TbtcChain`) 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 | File | Concern | |---|---| | `tbtc.go` | `TbtcChain` struct, constructor, shared constants, `TxProofDifficultyFactor` | | `tbtc_sortition.go` | sortition pool, operator status, rewards, 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 + moved funds sweep | ## Notes / deviations - **8 files, not the originally-scoped 4** (deposit/redemption/wallet/moving-funds): DKG + sortition + inactivity are ~40% of the file (~900 lines), so the 4-file version would have left `tbtc.go` at ~1200 lines — still a monolith. Splitting those out too is what actually de-monoliths the adapter. - **Heartbeat** has a single method (`ValidateHeartbeatProposal`); folded into `tbtc_wallet.go` (wallet liveness) rather than given its own file. - Imports were carried verbatim into each file and pruned per-file with `goimports` (preserves the custom aliases `ecdsaabi`/`tbtcabi`/`tbtccontract`/`ecdsacontract`). ## Base / stacking Based on `refactor/named-chain-param-getters` (#4188), **not** `main`: #4188 also edits `tbtc.go` (the `Get*Parameters` getters), so splitting on top of it avoids a conflict. Once #4188 merges, this branch should be rebased `--onto main`.
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
The on-chain tBTC parameter getters returned wide positional tuples that
callers destructured with long blank-identifier lists. For example:
GetMovingFundsParametersreturned 11 values pluserr. Because many of thevalues share a type, a positional slip in one of these lists compiles cleanly
and fails silently at runtime.
This replaces the wide tuples with named structs in
pkg/tbtc, so callersaccess fields by name:
Changes
pkg/tbtc/parameters.godefiningMovingFundsParameters,WalletParameters,DepositParameters,RedemptionParameters.GetMovingFundsParameters(ontbtc.BridgeChain, embedded bytbtcpg.Chain)and the three others (on
tbtcpg.Chain) now return the corresponding struct.pkg/tbtc, which both the ethereum adapter andtbtcpgalready import, so no new dependency edges are introduced.
declarations in
pkg/tbtc/moving_funds.go, both local test chains (which getsimpler — their internal struct aliases are dropped), and all call sites.
Net: the diff removes more than it adds; the change is a simplification.
Notes for review
original tuple order, and the
tbtcpgtests discriminate a wrong-but-same-typed field pick (e.g.
moved_funds_sweepsetsTxMaxTotalFeeto 0 butSweepTxMaxTotalFeeto a non-zero value).pkg/tbtc's test-onlylocalChain.GetWalletParametersis left as the oldwide-tuple
panic("unsupported")stub. It satisfies notbtcinterface (onlytbtcpg.ChaindeclaresGetWalletParameters), so it is dead in thetbtcpackage and was left untouched to keep the change surgical.
Verification
go build ./...andgo vet ./...clean.pkg/tbtc,pkg/tbtcpg, andpkg/chain/ethereumtest suites pass.Summary by CodeRabbit
New Features
Refactor