Repository navigation
fix(tax): guard division-by-zero panic in community-tax split adjustment - #670
Merged
fragwuerdig merged 3 commits intoOct 3, 2026
Merged
Conversation
The community-tax adjustment in ProcessTaxSplits divides by communityTax*(1-oracleSplitRate). With communityTax == 1.0 (100%, allowed by the SDK's distribution param validation) and oracleSplitRate == 0 (allowed by validateOraceSplit), the denominator is zero and the LegacyDec division panics — inside every taxable transaction (bank sends, market swaps, wasm calls), halting the chain until the parameter is fixed via an emergency upgrade. Both values are ordinary governance-settable params, so a single passed proposal could brick all taxable activity. Reproduced with the exact original expression on the governing inputs: panics with "division by zero". Extract the computation into types.CommunityTaxAdjustment (pure function, no keeper state) with an explicit guard: when the numerator or divisor is non-positive, return the unadjusted communityTax. Behavior is identical for every previously-working parameter combination; only the panicking configuration changes (no community-tax share of the distribution delta is taken — consistent with that configuration's semantics). Adds table + edge-case tests including the previously panicking inputs. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
GeoffreySHD
force-pushed
the
fix/tax-split-div-zero
branch
from
September 9, 2026 17:40
fb90d48 to
2bb430a
Compare
The strangelove-ventures GitHub org was renamed/moved to amygdala-labs, which killed the ghcr.io/strangelove-ventures/heighliner/osmosis image path baked into interchaintest's built-in chain config. Both PFM tests (TestTerraGaiaOsmoPFM, TestTerraPFM) now fail during chain setup with "denied" when pulling the image, independent of the code under test. Override the osmosis image repository per ChainSpec (the spec-level Images list replaces the built-in one; ChainSpec.Version still applies to Images[0]) to the same tags under the new amygdala-labs org. Verified the replacement manifests are pullable. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Contributor
Author
Contributor
Author
|
Friendly bump — fully green (31/31), e2e matrix included. This closes a governance-reachable chain-halt: in |
GeoffreySHD
added a commit
to GeoffreySHD/core
that referenced
this pull request
Sep 9, 2026
Complete writeup of the audit shipped across classic-terra#667/classic-terra#668/classic-terra#669/classic-terra#670 plus the part-2 pass over oracle price-staleness windows and treasury distribution params, and the posted MM2 (classic-terra#664) review. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
fragwuerdig
self-requested a review
September 23, 2026 11:21
fragwuerdig
approved these changes
Sep 23, 2026
StrathCole
reviewed
Sep 28, 2026
Co-authored-by: StrathCole <7449529+StrathCole@users.noreply.github.com>
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.
Description (severity: chain-halt risk reachable via governance)
ProcessTaxSplitsinx/tax/keeper/tax_split.gocomputes the community-tax adjustment as:The divisor is
communityTax·(1 − oracleSplitRate). Both inputs are ordinary governance-settable parameters:communityTax= 1.0 is accepted by the SDK's distribution param validation,oracleSplitRate= 0 is accepted byvalidateOraceSplit(only rejects negatives and >1).With that combination the denominator is zero and the
LegacyDecdivision panics — insideProcessTaxSplits, which runs within every taxable transaction (bank sends, market swaps, wasm calls through the tax handler wrappers). A single passed governance proposal setting those two values would make every taxable transaction panic → chain halt until an emergency upgrade corrects the parameter.Reproduction (exact original expression, governing inputs): panics with
division by zero.Fix
Extract the computation into a pure, testable helper
types.CommunityTaxAdjustmentthat returns the unadjustedcommunityTaxwhenever the numerator or denominator is non-positive. Behavior is identical for every previously-working parameter combination; only the panicking configuration changes (no community-tax share is taken — consistent with that configuration's semantics).Testing
x/tax/types/compute_test.go(main's existingComputeTaxestests are preserved) covering the hand-computed normal case, zero inputs, and the previously panicking configuration (NotPanics).x/tax/...suite passes;golangci-lint(pinned v2.1.6) reports 0 issues on the canonical tree.