Skip to content

fix(asserter-consumer): add admin authentication and pinned tholos storage (#157) - #162

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

fix(asserter-consumer): add admin authentication and pinned tholos storage (#157)#162
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-157

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Resolves #157 by adding admin-gated initialization and caller authentication to contracts/asserter-consumer.

Root Cause

Previously, AsserterConsumer::create_assertion_as_self accepted caller-supplied tholos_id, token_id, and bond_amount parameters with no caller authentication (require_auth()). This allowed arbitrary callers to execute pre-authorized transfers of arbitrary tokens held by the contract address to arbitrary contract targets.

Changes

  1. Added DataKey enum (Admin, TholosId, TokenId) and Error enum (AlreadyInitialized, NotInitialized) in contracts/asserter-consumer/src/lib.rs.
  2. Added initialize(env, admin, tholos_id, token_id) -> Result<(), Error> entrypoint that verifies admin.require_auth() and pins the configuration in contract instance storage once.
  3. Updated create_assertion_as_self(env, bond_amount, outcome) -> Result<u64, Error> to read stored configuration and enforce admin.require_auth().
  4. Updated get_status(env, id) -> Result<tholos::Assertion, Error> to read pinned tholos_id from instance storage.
  5. Added comprehensive test coverage in contracts/asserter-consumer/src/test.rs covering:
    • Initialized assertion flow with admin authorization.
    • Prevention of duplicate initialization (AlreadyInitialized).
    • Assertion creation blocked before initialization (NotInitialized).
    • Status check blocked before initialization (NotInitialized).
    • Admin authorization enforcement on initialize and create_assertion_as_self.

Verification

  • cargo test --workspace: all 183 tests passed (0 failures).
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings.
  • cargo fmt --check: clean formatting.
  • make build-wasm: WASM compilation verified.

Payout Routing

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

…orage to prevent unauthorized assertion spoofing (drydocs#157)
@collinsezedike

Copy link
Copy Markdown
Collaborator

@s6pa1rta3n-lab Closing. #157 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] create_assertion_as_self has no caller authentication

2 participants