user6086: (This is not related to CIP-33.)
I want a validator to ensure another validator is also run.
Naively I could construct one, get the hash, and hard code it into the other.
Presumably two validators can't mutually reference each other. How do people get around this/ What is the canonical way to handle this?
Same question with minting policies and validators.
The plutus API provide a forwardToValidator minting policy.
I want a validator to then know its 'canonical' currency symbol,
but as far as I can see ownCurrencySymbol is vacuous in the context of a validator.
This started by trying to establish how a state machine knows its state token is an NFT. As far as I can see, it doesn't. If an untrusted party initialized a machine, it would be down to a curious user to verify the statetoken is an NFT.
I'm surely not the first person to encounter this but trawling SE and discord didn't shed light on this.

user2335: If you want to ensure that a validator A run alongside another validator B, you need to check that the validator hash is present by the other in a transaction. This can be done by indexing if an output is spent with that hash as a credential (1).
On the problem of mutually referencing in plutus scripts, you need to later inject this data in the script via, for example, by referencing an input that contains the validator/minting hash of both the scripts. So scripts can mutually reference each other, but you cannot hard-code this in each script at the same time.
The forwardValidator that you provided is an example of a minting policy that checks whether a certain validator/minting script is present. As you stated, a validator is not a minting script and thus has no ownCurrencySymbol, this also has to be injected via another way, like a referencing script. If this minting policy is the result of a validator that you run alongside the validation of this script, you could create the minting policy first and hard-code its policy ID in the validator script. It all depends on what you are trying to achieve.

6086: <p>(This is not related to <a href="https://github.com/cardano-foundation/CIPs/pull/161" rel="nofollow noreferrer">CIP-33</a>.)</p>
<p>I want a validator to ensure another validator is also run.</p>
<p>Naively I could construct one, get the hash, and hard code it into the other.
Presumably two validators can't mutually reference each other. How do people get around this/ What is the canonical way to handle this?</p>
<p>Same question with minting policies and validators.
The plutus API provide a <a href="https://github.com/input-output-hk/plutus-apps/blob/d637b1916522e4ec20b719487a8a2e066937aceb/plutus-ledger/src/Ledger/Typed/Scripts/MonetaryPolicies.hs#L53" rel="nofollow noreferrer"><code>forwardToValidator</code></a> minting policy.
I want a validator to then know its 'canonical' currency symbol,
but as far as I can see <a href="https://github.com/input-output-hk/plutus/blob/71b1c4337dd97dd6b33daf89c4920f629efdbfbb/plutus-ledger-api/src/Plutus/V1/Ledger/Contexts.hs#L294" rel="nofollow noreferrer"><code>ownCurrencySymbol</code></a> is vacuous in the context of a validator.</p>
<p>This started by trying to establish how a state machine knows its state token is an NFT. As far as I can see, it doesn't. If an untrusted party initialized a machine, it would be down to a curious user to verify the statetoken is an NFT.</p>
<p>I'm surely not the first person to encounter this but trawling SE and discord didn't shed light on this.</p>
 2335: <p>If you want to ensure that a validator <code>A</code> run alongside another validator <code>B</code>, you need to check that the validator hash is present by the other in a transaction. This can be done by indexing if an output is spent with that hash as a credential <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Credential.html#t:Credential" rel="nofollow noreferrer">(1)</a>.</p>
<p>On the problem of mutually referencing in plutus scripts, you need to later inject this data in the script via, for example, by referencing an input that contains the validator/minting hash of both the scripts. So scripts can mutually reference each other, but you cannot hard-code this in each script at the same time.</p>
<p>The <code>forwardValidator</code> that you provided is an example of a minting policy that checks whether a certain validator/minting script is present. As you stated, a validator is not a minting script and thus has no <code>ownCurrencySymbol</code>, this also has to be injected via another way, like a referencing script. If this minting policy is the result of a validator that you run alongside the validation of this script, you could create the minting policy first and hard-code its policy ID in the validator script. It all depends on what you are trying to achieve.</p>
