Skip to content

fix(tholos-v2): prevent initialize front-running via atomic constructor - #159

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

fix(tholos-v2): prevent initialize front-running via atomic constructor#159
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-154

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Resolves #154.

In Soroban Protocol 20+, contract deployment and initialization can be front-run if initialization is performed as a separate transaction after deployment.

This PR implements __constructor on TholosV2 in contracts/tholos-v2/src/lib.rs. Soroban invokes __constructor atomically during deployment (DeployWithConstructor on-chain / env.register(TholosV2, (admin, ...)) in test environments), guaranteeing the contract instance is configured atomically upon instantiation.

Changes

  • Added pub fn __constructor(...) -> Result<(), Error> to contracts/tholos-v2/src/lib.rs delegating to Self::initialize(...).
  • Updated Fixture::new() in contracts/tholos-v2/src/test.rs to register the contract with constructor parameters.
  • Updated test suites and snapshots across tholos-v2.

Verification

  • cargo fmt --check passed.
  • cargo clippy -p tholos-v2 --all-targets -- -D warnings passed without warnings.
  • cargo test -p tholos-v2 passed (108 tests).
  • cargo test -p tholos passed (69 tests).
  • cargo test -p compute-commitment passed.

Payout Routing

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

@collinsezedike

Copy link
Copy Markdown
Collaborator

@s6pa1rta3n-lab Closing. #154 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] initialize is front-runnable in tholos-v2

2 participants