fix(config): require multiRewardDistributor for EVM comptroller chains#307
Closed
Conversation
Close the root cause behind MOO-413: the contracts config made `multiRewardDistributor?` optional, so an EVM comptroller chain could omit it with no compile error — which is how Ethereum shipped without it, silently breaking the frontend reward-claim flow (it falls back to the Moonbeam 0x..0808 precompile path and reverts). createContractsConfig now intersects a conditional constraint: a config that has a `comptroller` but no `governor` (Base/Optimism/Ethereum) must define `multiRewardDistributor`, or it fails to compile. Moonbeam/Moonriver carry a `governor` and use the WELL precompile reward model, so they remain exempt; chains without a comptroller (arbitrum/avalanche/polygon) are unaffected. Adds a runtime invariant test over publicEnvironments as the universal backstop (covers envs built outside the factory and any `as`-cast bypass).
Collaborator
Author
|
Closing — not needed. The fix lives entirely in #306 (adds Ethereum's |
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
Closes the root cause behind MOO-413 / #306: the contracts config typed
multiRewardDistributor?as optional, so an EVM comptroller chain could omit it with no compile error — which is exactly how Ethereum shipped without it and silently broke the frontend reward-claim flow (it falls back to the Moonbeam0x…0808precompile path, which reverts).Change
createContractsConfignow intersects a conditional constraint onto its input:Discriminator:
comptrollerpresent +governorabsent ⟹ EVM comptroller chain ⟹ MRD required. Verified against all 8 definitions: Base/Optimism/Ethereum (require, and have it); Moonbeam/Moonriver (havegovernor→ exempt); arbitrum/avalanche/polygon (no comptroller → exempt).Verification
pnpm typecheckpasses for all 8 current definitions.ethereum/contracts.tsnow produceserror TS2741: Property 'multiRewardDistributor' is missing.Tests added
src/environments/contracts-invariants.test.ts— runtime backstop iteratingpublicEnvironments: asserts every EVM comptroller env (comptroller, no governor) has a validmultiRewardDistributor.address. Covers envs built outside the factory and anyas-cast bypass. Registered in the vitest include list.Reviewer notes (triaged)
governor: undefinedbypass (🟡). Verified not reproducible under this repo'sexactOptionalPropertyTypes: true—governor: undefinedis itself a compile error (TS2375), so it can't take the exempt branch. No code change made (guarding an impossible case would add noise).governor-presence discriminator is a structural proxy for "Moonbeam-family home chain." Sound for all current/foreseeable chains; if a future chain breaks the heuristic, an explicitkindtag would be the more durable design. Noted as a future option, not done now (disproportionate to this fix).Semver
Marked minor (breaking) per the repo's breaking-change hook: direct callers of the exported
createContractsConfigthat omit MRD on an EVM comptroller config will no longer compile. Internal definitions are all updated/valid.