Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust codegen Phantom handling bug #237

Open
bladyjoker opened this issue Jul 10, 2024 · 1 comment
Open

Rust codegen Phantom handling bug #237

bladyjoker opened this issue Jul 10, 2024 · 1 comment
Labels

Comments

@bladyjoker
Copy link
Collaborator

Phantom handling in Rust codegen is not correct I believe

collectPhantomTyArgs :: PC.TyDefs -> PC.ModuleName -> PC.TyName -> [PC.Ty] -> [PC.TyArg] -> [PC.TyArg]

record CreateScriptsRequest a = {
  scripts : Map ScriptHash (ScriptDatum a)
  }
derive Eq (CreateScriptsRequest a)
derive Json (CreateScriptsRequest a)

record ScriptDatum a = {
  scriptType : a,
  -- ^ Protocol specific script type stored in this UTxO
  redeemer : AssetClass
  -- ^ Wallet containing `$redeemer` must sign the 'delete-script' transaction as an authorization method
}
derive Eq (ScriptDatum a)
derive PlutusData (ScriptDatum a)
derive Json (ScriptDatum a)

creates a

#[derive(std::fmt::Debug, std::clone::Clone)]
pub struct CreateScriptsRequest<A>{pub scripts: lbf_prelude::prelude::Map<lbf_plutus::plutus::v1::ScriptHash
                                  ,crate::cardano::extra::scriptstorage::validation::ScriptDatum<A>>,
                                  phantom_A: std::marker::PhantomData<A>}

#[derive(std::fmt::Debug, std::clone::Clone)]
pub struct ScriptDatum<A>{pub script_type: A,
                         pub redeemer: lbf_plutus::plutus::v1::AssetClass}

There's 2 problems here.

  1. There's no actual phantom types in the original LB type def
  2. Even if there was, we have a problem when phantom values are not made pub in Rust
@bladyjoker
Copy link
Collaborator Author

In #239 we solved the issue with phantomdata fields not being public. We still have the issue with phantoms analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant