mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-08 22:28:12 -05:00
doc/spec/contract: deployooor contract spec added
This commit is contained in:
@@ -89,13 +89,16 @@
|
||||
- [Concepts](spec/concepts.md)
|
||||
- [Cryptographic Schemes](spec/crypto-schemes.md)
|
||||
- [Contracts]()
|
||||
- [Money](spec/contract/money/money.md)
|
||||
- [Model](spec/contract/money/model.md)
|
||||
- [Scheme](spec/contract/money/scheme.md)
|
||||
- [DAO](spec/contract/dao/dao.md)
|
||||
- [Concepts](spec/contract/dao/concepts.md)
|
||||
- [Model](spec/contract/dao/model.md)
|
||||
- [Scheme](spec/contract/dao/scheme.md)
|
||||
- [Money](spec/contract/money/money.md)
|
||||
- [Model](spec/contract/money/model.md)
|
||||
- [Scheme](spec/contract/money/scheme.md)
|
||||
- [Deployooor](spec/contract/deploy/deploy.md)
|
||||
- [Concepts](spec/contract/deploy/concepts.md)
|
||||
- [Scheme](spec/contract/deploy/scheme.md)
|
||||
- [Vesting](spec/contract/vesting/vesting.md)
|
||||
|
||||
# P2P API Tutorial
|
||||
|
||||
31
doc/src/spec/contract/deploy/concepts.md
Normal file
31
doc/src/spec/contract/deploy/concepts.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Concepts
|
||||
|
||||
The smart contract deployment process consists of two steps that are
|
||||
outlined below:
|
||||
|
||||
* **Deploy:** smart contract is initialized on the blockchain.
|
||||
* **Lock:** smart contract is finalized and can't be modified
|
||||
further.
|
||||
|
||||
## Deploy
|
||||
|
||||
User creates a new smart contract and posts it on chain. The provided
|
||||
`WASM` bincode will initialize all the database trees required by the
|
||||
smart contract. The contract state definition consinst of the current
|
||||
contract `WASM` bincode and its database opened trees.
|
||||
|
||||
The smart contract state definition can be updated, as long as its
|
||||
unlocked.
|
||||
|
||||
### Smart Contract Status
|
||||
|
||||
* *Unlocked*: the smart contract state definition can be updated.
|
||||
* *Locked*: the smart contract is finalized and no more changes are
|
||||
allowed.
|
||||
|
||||
## Lock
|
||||
|
||||
User can finalize their smart contract state definition on chain,
|
||||
locking down the contract, preventing further state changes. This
|
||||
action is irreversible and the smart contract state definitions cannot
|
||||
be modified afterwards.
|
||||
13
doc/src/spec/contract/deploy/deploy.md
Normal file
13
doc/src/spec/contract/deploy/deploy.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Deployooor
|
||||
|
||||
## Abstract
|
||||
|
||||
This contract enables deployment and management of custom smart
|
||||
contracts on chain. Users can create an authority to control the smart
|
||||
contract and deploy their custom `WASM` bincodes. Additionally, they
|
||||
can update their code or lock the contract so its code is final and
|
||||
can't be modified further.
|
||||
|
||||
- [Concepts](concepts.md)
|
||||
- [Scheme](scheme.md)
|
||||
|
||||
61
doc/src/spec/contract/deploy/scheme.md
Normal file
61
doc/src/spec/contract/deploy/scheme.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Scheme
|
||||
|
||||
Let $ℙₚ$ be defined as in the section [Pallas and Vesta](../../crypto-schemes.md#pallas-and-vesta).
|
||||
|
||||
## Deploy
|
||||
|
||||
This function initializes a smart contract deployment.
|
||||
|
||||
* Wallet builder: `src/contract/deployooor/src/client/deploy_v1.rs`
|
||||
* WASM VM code: `src/contract/deployooor/src/entrypoint/deploy_v1.rs`
|
||||
|
||||
### Function Params
|
||||
|
||||
Define the deploy params
|
||||
$$ \begin{aligned}
|
||||
\t{Params}_\t{Deploy}.WASM &∈ \t𝔹^* \\
|
||||
\t{Params}_\t{Deploy}.PK &∈ ℙₚ \\
|
||||
\t{Params}_\t{Deploy}.IX &∈ 𝔹^* \\
|
||||
\end{aligned} $$
|
||||
|
||||
```rust
|
||||
{{#include ../../../../../src/sdk/src/deploy.rs:deploy-deploy-params}}
|
||||
```
|
||||
|
||||
### Contract Statement
|
||||
|
||||
**Contract deployment status**   whether the contract is locked. If yes then fail.
|
||||
|
||||
**WASM bincode validity**   whether the provided `WASM` bincode is valid. If no then fail.
|
||||
|
||||
### Signatures
|
||||
|
||||
There should be a single signature attached, which uses $\t{PK}$ as the
|
||||
signature public key.
|
||||
|
||||
## Lock
|
||||
|
||||
This function finalizes the smart contract state definition.
|
||||
|
||||
* Wallet builder: `src/contract/deployooor/src/client/lock_v1.rs`
|
||||
* WASM VM code: `src/contract/deployooor/src/entrypoint/lock_v1.rs`
|
||||
|
||||
### Function Params
|
||||
|
||||
Define the lock params
|
||||
$$ \begin{aligned}
|
||||
\t{Params}_\t{Lock}.PK &∈ \tℙₚ \\
|
||||
\end{aligned} $$
|
||||
|
||||
```rust
|
||||
{{#include ../../../../../src/contract/deployooor/src/model.rs:deploy-lock-params}}
|
||||
```
|
||||
|
||||
### Contract Statement
|
||||
|
||||
**Contract deployment status**   whether the contract is already locked. If yes then fail.
|
||||
|
||||
### Signatures
|
||||
|
||||
There should be a single signature attached, which uses $\t{PK}$ as the
|
||||
signature public key.
|
||||
Reference in New Issue
Block a user