Skip to content

fix(tholos-v2): bound max_total_weight to max_position ratio at initialize (#168) - #178

Closed
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-168
Closed

fix(tholos-v2): bound max_total_weight to max_position ratio at initialize (#168)#178
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-168

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Closes #168.

This change adds Sybil resistance bounding to TholosV2::initialize by constraining max_total_weight relative to max_position:

  • Introduces MAX_TOTAL_WEIGHT_TO_POSITION_RATIO = 10.
  • Enforces max_total_weight <= max_position.checked_mul(MAX_TOTAL_WEIGHT_TO_POSITION_RATIO).unwrap_or(i128::MAX).
  • Adds error variant Error::InvalidWeightRatio = 37 returned when the ratio bound is violated.
  • Adds comprehensive unit tests in contracts/tholos-v2/src/test.rs validating that initialize rejects configurations exceeding the ratio bound and accepts configurations at the exact ratio boundary.
  • Adjusts test_register_exceeds_max_position_fails parameterization to satisfy the ratio constraint while verifying PositionExceedsMax.
  • Updates docs/src/CONTRACT_V2.md with the new error variant, updated policy parameter descriptions, and an explicit analysis of Sybil resistance mechanics and residual plutocratic risk.

Economic and Sybil Analysis

In Tholos v2, max_position caps individual voter stake while max_total_weight caps total bonded stake W. Without a ratio constraint, an attacker with large capital can split into many positions of size max_position and dominate total voting weight cheaply if max_total_weight is set arbitrarily large relative to max_position. Capping the ratio to 10 limits the round to at most 10 maximum-sized positions, forcing any single Sybil attacker seeking a strict majority (>50% of W) to split and coordinate across at least 6 separate maximum-stake accounts. As documented, linear stake-weighting without external identity verification cannot eliminate plutocratic control by a >50% coalition; this ratio bound establishes a concrete capital-fragmentation lower bound while preserving operational flexibility.

Issue Stipulations & Compliance Checklist

  • Bound max_total_weight as a function of max_position during contract initialization.
  • Return dedicated error variant InvalidWeightRatio (variant 37).
  • Add unit test asserting InvalidWeightRatio when max_total_weight > max_position * 10.
  • Add unit test asserting initialization success when max_total_weight == max_position * 10.
  • Document InvalidWeightRatio in docs/src/CONTRACT_V2.md.
  • Document Sybil resistance rationale and residual plutocratic risk in docs/src/CONTRACT_V2.md.
  • Maintain zero regression across all existing contract test suites.

Test plan

  • cargo fmt --check passes cleanly.
  • shellcheck -x scripts/*.sh scripts/lib/*.sh passes cleanly.
  • cargo clippy --workspace --all-targets -- -D warnings passes with zero warnings.
  • cargo test --workspace passes (all 109 tests in tholos-v2, 69 in tholos).
  • cargo build --workspace --lib --target wasm32v1-none --release --locked builds successfully.
  • docs/src/CONTRACT_V2.md updated with public error specification and ratio constraints.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

@collinsezedike

Copy link
Copy Markdown
Collaborator

@s6pa1rta3n-lab Closing. #168 has no assignee. Comment on the issue and wait to be assigned before opening a PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] register() has no Sybil resistance in tholos-v2

2 participants