From af21a8138c47ce3c4ac1d55f54894cc1a563f800 Mon Sep 17 00:00:00 2001 From: olgahryniuk <67585499+olgahryniuk@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:31:41 +0300 Subject: [PATCH] Update and rename docs/13-smart-contracts/01-plutus/06-collateral-mechanism.mdx to docs/03-learn/17-collateral-mechanism.mdx --- .../17-collateral-mechanism.mdx} | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) rename docs/{13-smart-contracts/01-plutus/06-collateral-mechanism.mdx => 03-learn/17-collateral-mechanism.mdx} (79%) diff --git a/docs/13-smart-contracts/01-plutus/06-collateral-mechanism.mdx b/docs/03-learn/17-collateral-mechanism.mdx similarity index 79% rename from docs/13-smart-contracts/01-plutus/06-collateral-mechanism.mdx rename to docs/03-learn/17-collateral-mechanism.mdx index b5117f30..0371cdfd 100644 --- a/docs/13-smart-contracts/01-plutus/06-collateral-mechanism.mdx +++ b/docs/03-learn/17-collateral-mechanism.mdx @@ -1,7 +1,6 @@ --- title: About the collateral mechanism metaTitle: About the collateral mechanism -sidebar_position: 6 --- The collateral mechanism is an important feature that has been designed to @@ -9,12 +8,12 @@ ensure successful smart contract execution. Relying on the guarantees provided by the deterministic design of the ledger, Cardano implements a two-phase validation scheme. The main reason for -introducing two-phase validation is to limit the amount of uncompensated +two-phase validation is to limit the amount of uncompensated validation work by nodes. Each phase serves a purpose in achieving this goal: - The first phase checks whether the transaction is constructed correctly and can pay its processing fee -- The second phase runs the scripts included in the transaction +- The second phase runs the scripts included in the transaction. If the transaction is _phase-1 valid_, phase-2 scripts run. If phase-1 fails, no scripts run, and the transaction is immediately discarded. @@ -22,7 +21,7 @@ scripts run, and the transaction is immediately discarded. Collateral is used to guarantee that nodes are compensated for their work in case phase-2 validation fails. Thus, collateral is the monetary guarantee a user gives to assure that the contract has been carefully designed and thoroughly -tested. Collateral amount is specified at the time of constructing the +tested. The collateral amount is specified at the time of constructing the transaction. Not directly, but by adding collateral inputs to the transaction. The total balance in the UTXOs corresponding to these specially marked inputs is the transaction’s collateral amount. If the user fulfills the conditions of the @@ -39,7 +38,7 @@ users at little cost. ## The solution When a user initiates a transaction, they commit enough ada to cover its -execution cost. In Alonzo, transactions that call and use non-native smart +execution cost. On Cardano, transactions that call and use non-native smart contracts (known as phase-2 contracts) also need enough collateral to cover costs related to potential transaction failures. This amount can be small, but it is sufficient to make a denial of service (DOS) attack prohibitively @@ -60,11 +59,10 @@ transaction before submitting it. This feature is different from other blockchains, including Ethereum, where other network activity can influence the gas cost. The required amount of collateral depends only on the execution cost. -The -[Cardano testnet](https://testnets.cardano.org/en/testnets/cardano/overview/) -provides a safe environment with free test ada, so distributed application -(DApp) developers can thoroughly test their smart contracts before deploying to -the mainnet. If transactions succeed on the testnet, the developer can be +The Cardano testnet +provides a safe environment with free test ada, so decentralized application +(DApp) developers can thoroughly test their smart contracts before deploying them to +mainnet. If transactions succeed on testnet, the developer can be perfectly sure that all the scripts will indeed succeed. If the on-chain conditions have changed since the transaction was constructed, @@ -77,7 +75,7 @@ The term collateral refers to the total ada contained in the UTXOs referenced by collateral inputs. A transaction uses collateral inputs to cover its fees if a phase-2 script fails. -The Shelley formal specification introduced the concept of “multi-signature” +The Shelley formal specification introduced the concept of 'multi-signature' scripts. Phase-1 scripts, such as these, are captured entirely by the ledger rules. Execution costs can therefore be easily assessed before they are processed by the implementation, and any fees can be calculated directly within @@ -85,14 +83,13 @@ the ledger rule implementation, based on the size of the transaction that includes the script, for example. In contrast, phase-2 scripts can perform arbitrary (and, in principle, -Turing-complete) computations. We require transactions that use phase-2 scripts +Turing-complete) computations. Cardano requires transactions that use phase-2 scripts to have a budget in terms of a number of abstract ExUnits. This budget gives a quantitative bound on resource usage in terms of a number of specific metrics, including memory usage or abstract execution steps. The budget is then used as -part of the transaction fee calculation. For more details, read the -[Cardano ledger specification for Plutus Core](https://www.google.com/url?q=https://hydra.iohk.io/build/7172824/download/1/alonzo-changes.pdf&sa=D&source=editors&ust=1631287783465000&usg=AOvVaw09WTwSfKshbLCGW7dyup62). +part of the transaction fee calculation. -With the Vasil upgrade, DApp developers also have the possibility to specify a +After the Vasil upgrade, DApp developers can also specify a change address for the script collateral. This means that in case the script fails phase-2 validation, only the right amount will be taken, and the remaining funds will be sent to the provided change address. The