Skip to content

[Feature] bond_amount is immutable post-initialize in tholos v1 #134

Description

@collinsezedike

Summary

bond_amount is validated and set once in initialize (contracts/tholos/src/lib.rs:266-282) and read by assert_outcome (lib.rs:586) for every new assertion. There is no function anywhere in contracts/tholos/src/lib.rs that changes it afterward. A deployment that needs to adjust its bond, for example in response to real usage data, a token's price movement, or spam/griefing patterns observed in production, has no on-chain path to do so; the only option is deploying an entirely new contract instance.

This is the same class of gap as the admin-rotation issues (#128/#129), scoped narrowly to just this one parameter.

Scope

  • Add a set_bond_amount(new_bond_amount) function, admin-gated the same way update_resolvers and set_paused already are, validated against the same bounds initialize already enforces (bond_amount > 0, bond_amount <= MAX_BOND_AMOUNT).
  • Decided: a bond change applies only to assertions created after the change. No new snapshot field is needed for this: Assertion.bond (lib.rs:106) already pins the bond amount at creation, and every payout path (dispute at lib.rs:668, finalize at lib.rs:712/735, resolve at lib.rs:801) already reads assertion.bond, never the live DataKey::BondAmount, so this guarantee already holds structurally. Update Assertion.bond's doc comment to state this pinning explicitly (it's currently true only as an implicit consequence of no payout path re-reading DataKey::BondAmount, not stated anywhere), and add a regression test proving a set_bond_amount call doesn't retroactively change an already-open assertion's payout.
  • Emit an event on change, and add tests covering the update itself, auth-gating, and bound validation.

Proposed approach

A direct set_bond_amount, gated by admin.require_auth(), reusing initialize's existing bond_amount <= 0 || bond_amount > MAX_BOND_AMOUNT check, writing straight to DataKey::BondAmount. Pair it with the doc-comment update and regression test described above so the pinning guarantee is explicit and tested rather than an unstated accident of the current code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaigneasySmall, low-risk changeenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions