Skip to content

Set up contracts in clusterd#1033

Merged
chris124567 merged 2 commits intomainfrom
christopher/contract-create
Apr 15, 2025
Merged

Set up contracts in clusterd#1033
chris124567 merged 2 commits intomainfrom
christopher/contract-create

Conversation

@chris124567
Copy link
Member

@chris124567 chris124567 commented Apr 4, 2025

If we have network=v1 or network=v2, we will:

  • Fund a new address by mining a block
  • Use it to create 3 contracts
    • One that we let expire (expiredContract)
    • One that we revise and then submit a storage proof for (successfulContract)
    • One that we renew (renewedContract)
    • And expose these contract addresses via /fixtures/explored.

Example successful response:

{"expiredContract":"664aa3a708fce114eebb6ff352af8956c45aaaf0cb6b55f9808a3af7e5137af3","successfulContract":"297048b6a99a484598d1ce41c71b8ac05377cf71e6d03e0db7d51a596f37db04","renewedContract":"0a44d067f23bc315211439376b85297afc133cd0ac453043f86a758ffa8d5fb5"}

Example unsuccessful response:

{"expiredContract":null,"successfulContract":null,"renewedContract":null}

I think it is best to do it in Go vs JS because for v2 creating the contracts is already serious pain in the neck.

Update: We decided not to expose a special endpoint where the contract addresses could be retrieved. Instead, you can find the transaction where all the contracts were formed by looking at blocks until you find one containing a transaction where 3 contracts are formed. Then for instance you could query the state of those contracts using the explored API to get the expected state and compare that to what is displayed in the UI.

@changeset-bot
Copy link

changeset-bot bot commented Apr 4, 2025

⚠️ No Changeset found

Latest commit: a957f70

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Apr 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Apr 15, 2025 1:03pm
explorer-zen ⬜️ Ignored (Inspect) Visit Preview Apr 15, 2025 1:03pm
hostd ⬜️ Ignored (Inspect) Visit Preview Apr 15, 2025 1:03pm
renterd ⬜️ Ignored (Inspect) Visit Preview Apr 15, 2025 1:03pm
website ⬜️ Ignored (Inspect) Visit Preview Apr 15, 2025 1:03pm

alexfreska

This comment was marked as resolved.

@chris124567 chris124567 force-pushed the christopher/contract-create branch from 21ca70f to b0f091c Compare April 4, 2025 19:50
@chris124567
Copy link
Member Author

Added v1/v2 endpoints

/fixtures/explored/v1
/fixtures/explored/v2

which return types.FileContractElements and types.V2FileContractElements respectively instead of just IDs.

@ChrisSchinnerl ChrisSchinnerl requested a review from n8mgr April 7, 2025 08:41
@chris124567 chris124567 force-pushed the christopher/contract-create branch from 694c233 to 8bb2da8 Compare April 9, 2025 19:38
@ChrisSchinnerl ChrisSchinnerl requested a review from peterjan April 10, 2025 08:29
@chris124567 chris124567 requested a review from peterjan April 12, 2025 04:12
@chris124567 chris124567 requested review from ChrisSchinnerl and removed request for ChrisSchinnerl April 14, 2025 15:47
@chris124567 chris124567 force-pushed the christopher/contract-create branch from 1676c53 to 3d7f146 Compare April 14, 2025 15:55
@chris124567 chris124567 force-pushed the christopher/contract-create branch from 2e277c9 to a957f70 Compare April 15, 2025 13:03
@chris124567
Copy link
Member Author

It turns out that for the transition network, depending on how many renterd/walletd/hostd nodes we spin up, we might be before the require height or after it by the time the contract formation code runs. We could check the current height and decide to either form v1 contracts or v2 contracts, but that seems like it could cause confusion. So I just decided to disable contract formation on transition.

@chris124567 chris124567 merged commit 292b02d into main Apr 15, 2025
40 checks passed
@chris124567 chris124567 deleted the christopher/contract-create branch April 15, 2025 20:57
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.

4 participants