Proving a particular policy script constraint i.e 'before'

My understanding is that the nodes have the script when they verify the transaction: The script is part of the signed transaction, but only the script’s hash (not the whole script) is in the transaction body and stored on the blockchain after the transaction has been verified. The Plutus Book discusses this, and the Ledger Specification implicitly describes this.

1 Like

But where do they get the script,when i start up a node a month later and it revalidates the blockchain?

1 Like

I don’t think they can get the script later, and I don’t think that a node you start months later actually validates every past transaction. Rather, it discovers the consensus of past validations of block-producing nodes, as embodied in the state of the blockchain among all the nodes.

The specifics should be described in the documentation for Ouroboros. These great questions of yours are motivating me to dig into the Ouroboros papers and videos. I’ll post any clarifications or elaborations in this thread.

One implication of this situation is that one needs an off-chain record of scripts and contracts, if they will be later used or audited. (This is my motivation, for instance, for storing a “permanent” copy of my NFT-minting scripts on IPFS.)

1 Like

ok means we have to trust the stake-pool node that he validated the transaction’s script correctly… sounds sketchy

Every stakepool node attempts to verify the transaction, and the consensus of the stakepool nodes determines whether the transaction is valid and added to the blockchain. So we really need to trust the majority of the stakepools, the Ouroboros consensus protocol, and the correctness of its software implementation. There is an animation and game illustrating Ouroboros here and a video here.

2 Likes

Someone found out it is actually stored in the cahin

ht-tps://cardano.stackexchange.com/questions/24/how-can-a-node-verify-a-transaction-with-a-script-address-without-the-script/85

1 Like

Thanks again for pointing me to the link with documentation. I was able to use this information to retrieve all the scripts that have witnessed transactions on mainnet so far. It’s interesting to see what sort of scripts people are using:

Policy Description Number of Policies
before 2
keyHash 1345
keyHash and before 2945
keyHash or after 1
before and after 1
keyHash and keyHash 2
before and after and keyHash 1
keyHash and keyHash and before 1
complex combination of keyHashs and before 6

The individual scripts are here: ipns://QmZQEPpi5A4SXCntiUb1carkuB23niLgejtyxLhECQ24pA

1 Like

Hi how did you managed this? With the cli or db-sync? Or what else?

Custom Haskell code. Unfortunately, db-sync doesn’t record transaction witnesses and cardano-cli cannot query them. However, the cardano-node repo now has an example of how to walk through all of the blocks and extract information.

Cool is this feature already included in your tool or was it just a proof of concept?

I added the feature this morning. It was a good exercise in learning how to access the data in blocks, and I was curious to see what sort of monetary policy scripts folks have been using for tokens.

Some of the older Plutus documentation and commentary seems to indicate that Plutus scripts will not be stored in the blocks like the Shelley and Mary scripts now are. It will be interesting to see if that is really true; I imagine that we’ll know when the Plutus testnet become available.

Cool looks interesting, do you have any buildinstructions for mantis? The cardano-node folder and .gitmodules is empty. Do i just have to clone the node into it and then nix-shell?

The following works for me on NixOS:

  1. Clone git@github.com:functionally/mantis.git.
  2. Remove the cardano-node/ folder and just clone version 1.26.2 of git@github.com:input-output-hk/cardano-node.git there.
  3. Run a nix-shell. Using the IOHK caches speeds this up immensely.
  4. Execute cabal v1-build or cabal v1-run.

I haven’t tried it on a non-NixOS installation of Nix, or on a non-Nix system. There’s and odd interaction between the Nix derivations used by cardano-node and git submodules that appeared with cardano-node-1.25.0, and I haven’t resolved that yet. I need to overhall the build configuration, and creating a straightforward and robust build for this is high on my to-do list, but stuff like extracting scripts from mainnet is more fun. Please feel free to post issues. The tool is a quirky because at this point it’s evolving and mostly just focused on the use cases that I’ve been encountering.

Ok build is running… see you in some hours ^^

1 Like

Here are the instructions for using the IOHK binary cache, if you’re not already using it.

I’m now sufficiently motivated to work on streamlining the build! :blush:

1 Like

I’ve added the cache but it still takes a long time, but i think it’s only on the first time

Yes, after the first time it’s fast.

Also, I’m making progress on using IOHK’s haskell.nix system for this build. Once that’s working, installing should be as simple as nix-build -A mantis.

1 Like

FYI, the tool now builds using IOHK’s haskell.nix system. I also added better installation instructions and more documentation about the configuration file.

nix-build -A mantis.components.exes.mantis -o build

Hi @bwbush i’ts been a while but today i continued and got it working. I also dockerized your project: GitHub - wutzebaer/mantis-docker

Maybe i’ll use it later for https://cardano-tools.io to retrieve the policies of nft’s.

1 Like

Thanks for the news and the links. Please feel free to submit issues if you’d like additional features or find problems. In particular, I could create a REST API for some or all of the command-line functions.

The development branch of the tool has a couple of new features: real-time monitoring of new scripts, of transactions at an address, or of transactions involving a specific token or policy. I’ll include that in the main branch after I’ve documented the new features.

1 Like