Why are Fetch and NoSuchKey considered ledger Actions?
- ShaulOP 5
In the DAML ledger model there are four actions defined:
Create,Exercise,Fetch, andNoSuchKey.Only
CreateandExercisecan have consequences which cause Events on the ledger API’s flat transaction stream. Similarly, the only commands available in the ledger API are variants ofCreateandExercise.If
FetchandNoSuchKeyare not available on the DAML Ledger API and have no visible effect on the ledger transaction stream, why are they considered ledger Actions? - bernhard 4
The fact that
FetchandNoSuchKeyare not available over the LedgerAPI is an oversight in my opinion. The Ledger API should give you everything you need to validate a DAML Ledger.And that idea is also the reason why
Fetch, nonconsumingExerciseandNoSuchKeyare actions. The transaction graph (Ie the graph of Actions) should contain the information you need to decompose a DAML Ledger into individual party views (aka projections) and validate those. You need theFetchandNoSuchKeynodes to be able to decompose into projections, and you need the information on those nodes to validate those projections.Let’s just imagine a simple example where you sent me an instance of the
DisclosureRequestbelow:template DisclosedAsset with assetCid : ContractId Asset asset : Asset disclosee : Party where signatory [asset.owner, disclosee] template DisclosureRequest with requester : Party requestee : Party where signatory requester controller requestee can Disclose : ContractId DisclosedAsset with assetCid : ContractId Asset do asset <- fetch assetCid create DisclosedAsset with disclosee = requestee; ..When I exercise
Disclose, the current Ledger Model says that there are three nodes:Exercise (assetCid) | - Fetch (assetCid -> asset) | - Create (DisclosedAsset assetCid asset requester)You and I validate the whole thing. The Fetch node contains the contract arguments of the
Assetcontract which allow you to execute thecreatestatement.
The asset issuer only gets to see and validate theFetchnode.This model is safe:
- I can’t fake the contents of
assetCidbecause theFetchnode is validated by the issuer. - I can’t create
DisclosedAssetcontents by any other means because they need your signature.
So you have the guarantee that unless the issuer collaborates with me, the
assetinDisclosedAssetwill always matchassetCid, and the contract is active at the time of the transaction.Now let’s imagine we only had
CreateandExercisenodes in the Ledger Model. Now the resulting transaction looks like this:Exercise (assetCid) | - Create (DisclosedAsset assetCid asset requester)What does the
issuerget to see here? If nothing, you are at my mercy when it comes to saying whatassetcontains. You lose the guarantee thatassetCidandassetmatch.But let’s say we have a magic wand which given an
Assetand aContractId Assetallows us to check that they match and that the contract is active. You as a human reading this DAML code can infer that if you see the transaction above, theassetandassetCidmust match, and you can verify that using the magic wand. Thus, you can verify the whole transaction. But you can’t always do that. Imagine I added a second choice toDisclosureRequest:controller requestee can DiscloseHigher : ContractId DisclosedAsset with assetCid1 : ContractId Asset assetCid2 : ContractId Asset do asset1 <- fetch assetCid1 asset2 <- fetch assetCid2 let (assetCid, asset) = if asset1.quantity >= asset2.quantity then (assetCid1, asset1) else (assetCid2, asset2) create DisclosedAsset with disclosee = requestee; ..If I exercised that, you’d see this:
Exercise (assetCid1, assetCid2) | - Create (DisclosedAsset assetCid asset requester)What can you infer now? With your magic wand you can still check that
assetCidandassetmatch, and that the contract was active, but you have no chance to check that I evaluated theif..elsestatement correctly. The only way you could validate that is to know what the fetches result in. Ie you need to know theFetchnodes.With
NoSuchKeyit’s more about the validation than sharing the needed information. You need a node that you can send to the maintainers of the key to confirm the non-existence. - I can’t fake the contents of
- drsk 1
Could someone shed some more light on the
NoSuchKeynode? I found the documentation on it rather sparse.[Edit by @bernhard] Split out into new topic Could someone shed some more light on the NoSuchKey node?
- drsk
Looking at the mentioned ticket, this node does not actually exist. So that answers my question. Thanks!