-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Anoma compilation resource machine builtin tests (#3208)
This PR: * Updates the anomalib nock stdlib to the latest head of `artem/juvix-node-integration-v0.28` containing the latest testnet fixes. * Re-enables the Anoma resource machine builtins tests
- Loading branch information
1 parent
fcd59c9
commit 9210e39
Showing
9 changed files
with
196 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Package; | ||
|
||
import PackageDescription.V2 open; | ||
|
||
package : Package := | ||
defaultPackage@?{ | ||
name := "test085"; | ||
dependencies := [defaultStdlib; path "client/"]; | ||
}; |
8 changes: 8 additions & 0 deletions
8
tests/Anoma/Compilation/positive/test085/client/Package.juvix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Package; | ||
|
||
import PackageDescription.V2 open; | ||
|
||
package : Package := | ||
defaultPackage@?{ | ||
name := "addtransaction"; | ||
}; |
130 changes: 130 additions & 0 deletions
130
tests/Anoma/Compilation/positive/test085/client/ResourceMachine.juvix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- A rendering of https://github.com/anoma/anoma/blob/f52cd44235f35a907c22c428ce1fdf3237c97927/hoon/resource-machine.hoon | ||
module ResourceMachine; | ||
|
||
import Stdlib.Prelude open; | ||
|
||
module Resource; | ||
|
||
Resource-Logic : Type := Public-Inputs -> Private-Inputs -> Bool; | ||
|
||
builtin anoma-resource | ||
type Resource := | ||
mkResource@{ | ||
label : Nat; | ||
logic : Resource-Logic; | ||
ephemeral : Bool; | ||
quantity : Nat; | ||
data : Pair Nat Nat; | ||
--- 256 bits | ||
nullifier-key : Nat; | ||
--- nonce for commitments 256 bits | ||
nonce : Nat; | ||
rseed : Nat; | ||
}; | ||
|
||
positive | ||
type Public-Inputs := | ||
mkPublic-Inputs@{ | ||
commitments : List Nat; | ||
nullifiers : List Nat; | ||
--- exactly one commitment or nullifier | ||
self-tag : Nat; | ||
other-public : Nat; | ||
}; | ||
|
||
positive | ||
type Private-Inputs := | ||
mkPrivate-Inputs@{ | ||
committed-resources : List Resource; | ||
nullified-resources : List Resource; | ||
other-private : Nat; | ||
}; | ||
|
||
end; | ||
|
||
open Resource using { | ||
Resource; | ||
mkResource; | ||
Resource-Logic; | ||
Public-Inputs; | ||
mkPublic-Inputs; | ||
Private-Inputs; | ||
mkPrivate-Inputs; | ||
} public; | ||
|
||
builtin anoma-delta | ||
axiom Delta : Type; | ||
|
||
builtin anoma-kind | ||
axiom Kind : Type; | ||
|
||
builtin anoma-resource-commitment | ||
axiom commitment : Resource -> Nat; | ||
|
||
builtin anoma-resource-nullifier | ||
axiom nullifier : Resource -> Nat; | ||
|
||
builtin anoma-resource-kind | ||
axiom kind : Resource -> Kind; | ||
|
||
builtin anoma-resource-delta | ||
axiom resource-delta : Resource -> Delta; | ||
|
||
type Logic-Proof : Type := | ||
mkLogicProof@{ | ||
resource : Resource; | ||
inputs : Pair Public-Inputs Private-Inputs; | ||
}; | ||
|
||
Compliance-Proof : Type := Nat; | ||
|
||
type Proof := | ||
| proofCompliance | ||
| proofLogic Resource (Pair Public-Inputs Private-Inputs); | ||
|
||
mkProofCompliance (_ : Compliance-Proof) : Proof := proofCompliance; | ||
|
||
mkProofLogic | ||
(resource : Resource) (inputs : Pair Public-Inputs Private-Inputs) : Proof := | ||
proofLogic resource inputs; | ||
|
||
builtin anoma-action | ||
type Action := | ||
mkAction@{ | ||
commitments : List Nat; | ||
nullifiers : List Nat; | ||
proofs : List Proof; | ||
app-data : Nat; | ||
}; | ||
|
||
builtin anoma-action-delta | ||
axiom actionDelta : Action -> Delta; | ||
|
||
builtin anoma-actions-delta | ||
axiom actionsDelta : List Action -> Delta; | ||
|
||
builtin anoma-prove-action | ||
axiom proveAction : Action -> Nat; | ||
|
||
builtin anoma-prove-delta | ||
axiom proveDelta : Delta -> Nat; | ||
|
||
builtin anoma-zero-delta | ||
axiom zeroDelta : Delta; | ||
|
||
builtin anoma-add-delta | ||
axiom addDelta : Delta -> Delta -> Delta; | ||
|
||
builtin anoma-sub-delta | ||
axiom subDelta : Delta -> Delta -> Delta; | ||
|
||
Commitment-Root : Type := Nat; | ||
|
||
type Transaction := | ||
mkTransaction@{ | ||
--- root set for spent resources | ||
roots : List Commitment-Root; | ||
actions : List Action; | ||
delta : Delta; | ||
delta-proof : Nat; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module delta; | ||
|
||
import Stdlib.Prelude open; | ||
import Stdlib.Debug.Trace open; | ||
import ResourceMachine open; | ||
|
||
main : Delta := | ||
let | ||
resource : Resource := | ||
mkResource@{ | ||
label := 11; | ||
logic := \{_ _ := true}; | ||
ephemeral := true; | ||
quantity := 55; | ||
data := 0, 0; | ||
nullifier-key := 0; | ||
nonce := 0; | ||
rseed := 0; | ||
}; | ||
action : Action := | ||
mkAction@{ | ||
commitments := []; | ||
nullifiers := []; | ||
proofs := []; | ||
app-data := 1; | ||
}; | ||
in -- Most of these call return large nouns that are not appropritate for testing. | ||
-- This test checks that these functions do not crash. | ||
commitment | ||
resource | ||
>-> nullifier resource | ||
>-> kind resource | ||
>-> addDelta (resource-delta resource) (resource-delta resource) | ||
>-> addDelta (resource-delta resource) (resource-delta resource) | ||
>-> proveDelta zeroDelta | ||
>-> trace (subDelta zeroDelta zeroDelta) | ||
>-> trace (addDelta zeroDelta zeroDelta) | ||
>-> proveAction action | ||
>-> trace (actionDelta action) | ||
>-> actionsDelta [action]; |