Repository navigation
fix(daocond,basedao): a guaranteed render panic, a permanent DAO brick, and NaN escaping the threshold conditions - #67
Merged
Conversation
RenderWithVotes consumed three format verbs (%g, %s, %s) while passing two arguments. gno's ufmt panics on an argument shortfall rather than emitting Go's cosmetic "%!s(MISSING)", so every proposal-detail render for a DAO whose condition contains a RoleThreshold panicked — permanently, since publishing is immutable. The existing suite never caught it: daocond_test.gno only calls RenderWithVotes inside its failure branch, so a passing run never executes the line. The new test exercises it directly.
RemoveMember checked only IsMember, so a single-member DAO could remove itself: 1/1 = 100% clears any threshold, and nothing stopped the removal. The resulting zero-member DAO is unrecoverable — assertCallerIsMember rejects every entry point, so not even AddMember can be proposed, and every threshold evaluates 0/0 = NaN, which is never >= the threshold. Publishing is immutable, so the brick would be permanent. Test lives in members_removal_test.gno rather than members_test.gno to avoid colliding with the file added in the realm-identity-hardening branch.
Both threshold conditions divide yes-votes by the size of their electorate. gno's float64 divide has no zero guard — unlike every integer case, which raises "division by zero" — so an empty electorate produces 0/0 = NaN. NaN then escapes through Eval, Signal and RenderWithVotes; Signal is a progress value and math.Min(NaN/threshold, 1) is NaN, not 1. The minimum-member guard added alongside this does not cover it: a role can reachably reach zero holders while the DAO still has members, via RemoveRoleFromMember (a default-registered governance action), RemoveRole, or removing the last holder of a role while others remain. Zero resolves to 0.0, never 1.0 — reading an empty electorate as vacuous truth would let a proposal pass with nobody entitled to vote on it. This mirrors the guard gnolovDaoCondThreshold.voteRatio already carries for its zero-power case.
zxxma
force-pushed
the
fix/pre-freeze-safety-hardening
branch
from
July 20, 2026 11:44
531d12b to
fc44fad
Compare
zxxma
changed the base branch from
feat/topaz-v2-rename
to
chore/vendor-dep-closure
July 20, 2026 11:44
getUserRole panicked when a voter held none of the condition's tier roles. Core.Vote gates on membership only, never on holding a tier role, so such a voter can reach the ballot — as can any member when the condition is built over a subset of the DAO's roles, which is exactly what the "T3 abstaining" case models. The panic was raised from inside the ballot walk, so one such vote made every later Eval, Signal and Render on that proposal panic. On an immutable publish that is unrecoverable, and it is reached by an ordinary member casting an ordinary vote. A voter outside the condition's roles now carries no voting power: "" is absent from votingPowersByTier, so the lookup yields 0.0 and they contribute nothing. This changes a deliberately asserted behaviour, so it is worth being explicit about why it is a fix rather than a regression. The existing matrix case carried `panic: true` alongside `expectedYes: 7.0/10.0` — and 7/10 is precisely the tally with the T3 votes excluded, i.e. the number the case would produce under this change. The panic flag documented what the code did; the expectation recorded what it was meant to do. With the flag removed the case now genuinely evaluates Eval(ballot) == true instead of passing through the recover path, so the assertion is exercised for the first time.
zxxma
changed the base branch from
chore/vendor-dep-closure
to
feat/topaz-v2-rename
July 20, 2026 12:19
This was referenced Jul 20, 2026
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
Three defects that become permanent the moment we publish to topaz-1. All three are in exported public API, all three were reproduced by a failing test before being fixed, and none is covered by the existing suite.
Based on
feat/topaz-v2-rename(#65) rather thanmain, because that is the source the ceremony publishes and becausemainis pre-interrealm-v2 — its unsuffixedp/nt/*imports cannot resolve on topaz-1 at all. Each fix is independent of the others.1.
RoleThresholdproposals panic instead of renderingcond_role_treshold.gno:59consumed three format verbs (%g,%s,%s) while passing two arguments. gno'sufmtpanics on an argument shortfall rather than emitting Go's cosmetic%!s(MISSING), so every proposal-detail render for a DAO whose condition contains aRoleThresholdpanicked — permanently.Reproduced:
panic: ufmt: not enough argumentsatufmt.gno:199, raised fromcond_role_treshold.gno:59.Why the suite never caught it:
daocond_test.gno:175callsRenderWithVotesonly inside its failure branch, so a passing run never executes the line. The new test exercises it directly. (%%is a literal percent and consumes no argument — the verb count is genuinely 3.)2. Removing the last member bricks the DAO permanently
RemoveMemberchecked onlyIsMember, so a single-member DAO could remove itself — 1/1 = 100% clears any threshold. The resulting zero-member DAO is unrecoverable:assertCallerIsMemberrejects every entry point, so not evenAddMembercan be proposed again.Reproduced:
Panic value: nil— the removal succeeded silently. The control case (removal with others remaining) passes before and after, so the test discriminates rather than blanket-refusing.3. An empty electorate yields NaN, not an unmet condition
Both threshold conditions divide yes-votes by the size of their electorate. gno's float64 divide has no zero guard — unlike every integer case, which raises
division by zero— so an empty electorate produces0/0 = NaN. NaN then escapes throughEval,SignalandRenderWithVotes;Signalis a progress value andmath.Min(NaN/threshold, 1)is NaN, not 1.The minimum-member guard in (2) does not cover this: a role can reach zero holders while the DAO still has members, via
RemoveRoleFromMember(a default-registered governance action),RemoveRole, or removing the last holder of a role while others remain. Zero resolves to0.0, never1.0— reading an empty electorate as vacuous truth would let a proposal pass with nobody entitled to vote on it. This mirrors the guardgnolovDaoCondThreshold.voteRatioalready carries for its zero-power case.Test plan
ok, lint clean,gno fmtzero diff — run fully offline against a vendored dependency closure including thep/samcrew/avlfork.merge-treeverified clean againstfix/realm-identity-hardening(fix(basedao): reject empty member ids and use the constructor's realm #66).gno lint/gno testresolve dependencies fromrpc.gno.land, which CNAMEs to a mutable testnet serving pre-interrealm-v2 sources, so a hermetically pinned compiler is fed by a live unversioned source. Bumping the toolchain pin does not fix it. Vendoring the dependency closure does, and is proven end-to-end offline — but the vendor set must be pinned to the fork (p/samcrew/avl), not toexamples/at the pin, or the green signal would be compiled against the two-value avl that topaz-1 does not have. That is a separate PR and it depends on #65.4. A roleless voter permanently bricks a gnolove DAO proposal
cond_gnolovedao.gno:112getUserRolepanicked when a voter held none of the condition's tier roles.Core.Votegates on membership only, never on holding a tier role, so such a voter can reach the ballot — as can any member when the condition is built over a subset of the DAO's roles, which is exactly what the "T3 abstaining" case models. The panic was raised from inside the ballot walk, so one such vote made every laterEval,SignalandRenderon that proposal panic. Unrecoverable once published, and reached by an ordinary member casting an ordinary vote.A voter outside the condition's roles now carries no voting power.
This changes a deliberately asserted behaviour, so it deserves scrutiny. The matrix case carried
panic: truealongsideexpectedYes: 7.0/10.0— and 7/10 is precisely the tally with the T3 votes excluded, i.e. the number the case produces under this change. The panic flag documented what the code did; the expectation recorded what it was meant to do. With the flag removed, that case now genuinely evaluatesEval(ballot) == trueinstead of passing through the recover path, so the assertion is exercised for the first time.Test plan
ok, lint clean,gno fmtzero diff — run fully offline against the vendored closure.