-
Notifications
You must be signed in to change notification settings - Fork 29
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
Plutus v3 #83
Plutus v3 #83
Conversation
test validator for sancho net: validator {
fn params(_datum: Void, _redeemer: Void, context: ScriptContext) -> Bool {
when context.purpose is {
Spend(_) -> {
let d = #"97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"
let g1 = builtin.bls12_381_g1_uncompress(d)
let x = g1 |> builtin.bls12_381_g1_compress
x == d
}
_ -> False
}
}
} Should be able to compile the script, create a reference script utxo, and spend into and out of that contract. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for doing this. I have made a few naming suggestion essentially trying to explicit some of the guidelines / conventions that we've been following in the standard library.
I'd be nice to get also extend those acceptance tests here: https://github.com/aiken-lang/aiken/tree/main/examples/acceptance_tests/script_context with Conway transactions, though this requires having already updated Aiken's simulate
command and internals with the ability to create full Plutus V3 script contexts. In the meantime, using Ogmios for evaluating transactions is a viable option.
With Aiken 1.0.26, the use of the Dict type was discouraged. https://github.com/logicalmechanism/stdlib/blob/plutus-v3/lib/aiken/transaction.ak#L67-L87 Does this mean all of these Dicts should be turned into lists of tuples too? like List<(x,y)> @KtorZ |
Not really. It wasn't discourage, but simply made safer. We will still use |
Well when the Pair type comes out in 1.0.27 I think I will revisit this and see what to change or update. I am attempting to use this branch on SanchoNet with some interesting errors so I was assuming something may be went wrong because of the Dict type. |
New types are generated from: v1.30.0.0 Context. Key changes: ScriptContext using ScriptInfo now and has the redeemer field. There are naming conflicts introduced here so to avoid any issues, the ScriptPurpose uses the verb form of the action and the ScriptInfo will use the present tense verb form. The new types need an additional review due to the introduction of Pair/Pairs type. I want to make sure everything still agrees with the current branch of both the stdlib and plutus. |
ChangedParameters -> ChangedProtocolParameters Co-authored-by: Matthias Benkort <[email protected]>
ParameterChange -> ProtocolParameterChange Co-authored-by: Matthias Benkort <[email protected]>
return_addr -> return_address Co-authored-by: Matthias Benkort <[email protected]>
constitution -> guardrails Co-authored-by: Matthias Benkort <[email protected]>
Co-authored-by: Matthias Benkort <[email protected]>
Co-authored-by: Matthias Benkort <[email protected]>
Co-authored-by: Matthias Benkort <[email protected]>
Co-authored-by: Matthias Benkort <[email protected]>
Unfortunately, we cannot simply map those as a large record because it is encoded as a cbor Map, and not as a constructor. We can't also just provide it as a Dict or Pairs because the resulting types are: (1) non-canonical (rationales are encoded as arrays instead of a constructor with two fields, unlike in other places....) (2) heterogeneous (protocol parameters have different types). Providing accessors like so will play nicely with future updates as well. One big downside: we traverse the map for every access x_x ... In the long-run, we might to provide some method to fold over parameters and traverse the map only _once_. This would require to temporarily store parameters inside an ADT which users can pattern-match on at the call site. ``` pub fn fold(self, zero: b, with: fn(ProtocolParameter, b) -> b) -> b { ... } pub type ProtocolParameter { MinFeeCoefficient(Int), MinFeeConstant(Int), ... } ``` This would provide some kind of optimal traversal of the parameters, modulo the creation of the intermediate ADT. Having the ability to use case/constr here would be nice.
Beginning of the v2 to v3 transition. This branch is pure Plutus V3. It contains breaking changes.
Each new type needs a review and double check but it at least lays down the groundwork for this transition.
New types are generated from: v1.22.1.0 Context
I tried to group types where they should be going so some movement might be needed.