Skip to content

Commit a218858

Browse files
committed
fix types and restore
1 parent 94b9e43 commit a218858

File tree

9 files changed

+126
-106
lines changed

9 files changed

+126
-106
lines changed

include/anoma/start.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ Logger.configure(level: :none)
22
eclient = Anoma.Client.Examples.EClient.create_example_client()
33
http_port = Application.get_env(:anoma_client, Anoma.Client.Web.Endpoint)[:http][:port]
44
IO.puts("#{http_port} #{eclient.node.node_id}")
5-
Logger.configure(level: :debug) # uncomment this for debug messages
5+
# Logger.configure(level: :debug) # uncomment this for debug messages
66
Anoma.Node.Utility.Consensus.start_link(node_id: eclient.node.node_id, interval: 500)

justfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ stackParallelFlag := if disableParallel == '' { '-j' + stackParallelFlagJobs } e
4646
stackArgs := stackOptFlag + ' ' + stackParallelFlag + ' ' + stackGhcParallelFlag
4747

4848
# flags used in the stack test command
49-
testArgs := ""
49+
testArgs := "--hide-successes"
5050
rtsFlag := if disableParallel == '' { '+RTS -N' + numParallelJobs + ' -RTS' } else { '' }
5151

5252
# flag used to enable tracing of bash commands

src/Juvix/Compiler/Nockma/AnomaLib.hs

+45-45
Original file line numberDiff line numberDiff line change
@@ -69,52 +69,52 @@ anomaLibPath = \case
6969
StdlibFoldBytes ->
7070
[nock|
7171
[ 8
72-
[1 0]
73-
[ 1
74-
8
75-
[9 46 0 16.383]
76-
9
77-
2
78-
10
79-
[ 6
80-
[0 14]
81-
7
82-
[0 3]
83-
8
84-
[1 0 0]
85-
[ 1
86-
8
87-
[9 20 0 131.071]
88-
9
89-
2
90-
10
91-
[ 6
92-
[ 7
93-
[0 3]
94-
8
95-
[8 [9 10 0 16.383] 9 90 10 [6 7 [0 3] 1 3] 0 2]
96-
9
97-
2
98-
10
99-
[6 [7 [0 3] 1 1] 0 29]
100-
0
101-
2
102-
]
103-
0
104-
28
72+
[1 0]
73+
[ 1
74+
8
75+
[9 46 0 16.383]
76+
9
77+
2
78+
10
79+
[ 6
80+
[0 14]
81+
7
82+
[0 3]
83+
8
84+
[1 0 0]
85+
[ 1
86+
8
87+
[9 20 0 131.071]
88+
9
89+
2
90+
10
91+
[ 6
92+
[ 7
93+
[0 3]
94+
8
95+
[8 [9 10 0 16.383] 9 90 10 [6 7 [0 3] 1 3] 0 2]
96+
9
97+
2
98+
10
99+
[6 [7 [0 3] 1 1] 0 29]
100+
0
101+
2
102+
]
103+
0
104+
28
105+
]
106+
0
107+
2
108+
]
109+
0
110+
1
111+
]
112+
0
113+
2
114+
]
115+
0
116+
1
105117
]
106-
0
107-
2
108-
]
109-
0
110-
1
111-
]
112-
0
113-
2
114-
]
115-
0
116-
1
117-
]
118118
|]
119119
-- Obtained from the urbit dojo using:
120120
--

test/Anoma/Compilation/Positive.hs

+2-4
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ allTests :: TestTree
245245
allTests =
246246
testGroup
247247
"Anoma positive tests"
248-
[ -- haskellNockmaTests,
248+
[ haskellNockmaTests,
249249
anomaNodeTests
250250
]
251251
where
@@ -257,9 +257,7 @@ allTests =
257257
(map mkAnomaNodeTest (filter shouldRun anomaTests))
258258
where
259259
shouldRun :: AnomaTest -> Bool
260-
shouldRun a@AnomaTest {..} =
261-
_anomaTestNum == 80909995
262-
-- classify a == ClassWorking
260+
shouldRun a = classify a == ClassWorking
263261

264262
haskellNockmaTests :: TestTree
265263
haskellNockmaTests =

test/Main.hs

+24-26
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,37 @@ slowTests =
3232
"Juvix slow tests"
3333
AllFinish
3434
<$> sequence
35-
[ -- return Runtime.allTests,
36-
-- return Reg.allTests,
37-
-- return Asm.allTests,
38-
-- return Tree.allTests,
39-
-- return Core.allTests,
40-
-- return Internal.allTests,
41-
-- return Compilation.allTests,
42-
-- return Examples.allTests,
43-
-- Casm.allTests,
44-
return Anoma.allTests
45-
-- return Repl.allTests
35+
[ return Runtime.allTests,
36+
return Reg.allTests,
37+
return Asm.allTests,
38+
return Tree.allTests,
39+
return Core.allTests,
40+
return Internal.allTests,
41+
return Compilation.allTests,
42+
return Examples.allTests,
43+
Casm.allTests,
44+
return Anoma.allTests,
45+
return Repl.allTests
4646
]
47-
48-
-- <> sequence (if Config.config ^. Config.configRust then [Rust.allTests] else [])
47+
<> sequence (if Config.config ^. Config.configRust then [Rust.allTests] else [])
4948

5049
fastTests :: IO TestTree
5150
fastTests =
5251
return $
5352
testGroup
5453
"Juvix fast tests"
55-
[]
56-
57-
-- Parsing.allTests,
58-
-- Resolver.allTests,
59-
-- Scope.allTests,
60-
-- Termination.allTests,
61-
-- Typecheck.allTests,
62-
-- Format.allTests,
63-
-- Formatter.allTests,
64-
-- Package.allTests,
65-
-- BackendMarkdown.allTests,
66-
-- Isabelle.allTests,
67-
-- Nockma.allTests
54+
[ Parsing.allTests,
55+
Resolver.allTests,
56+
Scope.allTests,
57+
Termination.allTests,
58+
Typecheck.allTests,
59+
Format.allTests,
60+
Formatter.allTests,
61+
Package.allTests,
62+
BackendMarkdown.allTests,
63+
Isabelle.allTests,
64+
Nockma.allTests
65+
]
6866

6967
main :: IO ()
7068
main = do

tests/Anoma/Client/Swap.juvix

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ trivial_true_resource_eph : Resource :=
1515
ephemeral := true;
1616
quantity := 1;
1717
value := AnomaAtom.fromNat 0;
18-
nullifierKeyCommitment :=
19-
NullifierKeyCommitment.toAnomaAtom NullifierKeyCommitment.zero;
18+
nullifierKeyCommitment := NullifierKeyCommitment.zero;
2019
unusedRandSeed := 0;
2120
nonce := Nonce.fromNat 0;
2221
};
@@ -45,8 +44,7 @@ trivial_true_resource : Resource :=
4544
ephemeral := true;
4645
quantity := 1;
4746
value := AnomaAtom.fromNat 0;
48-
nullifierKeyCommitment :=
49-
NullifierKeyCommitment.toAnomaAtom NullifierKeyCommitment.zero;
47+
nullifierKeyCommitment := NullifierKeyCommitment.zero;
5048
unusedRandSeed := 0;
5149
nonce := Nonce.fromNat 2;
5250
};

tests/Anoma/Client/library/ResourceMachine.juvix

+3-5
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,15 @@ type ConsumedItem :=
9494
mk@{
9595
nullifier : Nullifier;
9696
root : CommitmentRoot;
97-
logic : Nat;
98-
-- TODO change to Encoded Logic
97+
logic : Encoded Logic;
9998
};
10099

101100
type DeltaHash := privateMk Nat;
102101

103102
type CreatedItem :=
104103
mk@{
105104
commitment : Commitment;
106-
logic : Nat;
107-
-- TODO change to Encoded Logic
105+
logic : Encoded Logic;
108106
};
109107

110108
type Instance :=
@@ -214,7 +212,7 @@ type Resource :=
214212
quantity : Nat;
215213
ephemeral : Bool;
216214
nonce : Nonce;
217-
nullifierKeyCommitment : AnomaAtom;
215+
nullifierKeyCommitment : NullifierKeyCommitment;
218216
unusedRandSeed : Nat;
219217
}
220218
with

tests/Anoma/Compilation/positive/test085/client/ResourceMachine.juvix

+46-17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module ResourceMachine;
33
import Encode open;
44
import ByteArray open;
55
import Stdlib.Prelude open;
6+
import Stdlib.Debug.Fail open;
67

78
type Tag :=
89
| Created Commitment
@@ -31,18 +32,17 @@ end;
3132

3233
--- The nullifier key type describing a secret required to compute the ;Nullifier; of a resource
3334
builtin anoma-nullifier-key
34-
type NullifierKey :=
35-
privateMk@{
36-
unNullifierKey : ByteArray;
37-
}
35+
type NullifierKey := privateMk ByteArray
3836
with
37+
size : Nat := 64;
38+
3939
fromByteArray : ByteArray -> NullifierKey := privateMk;
4040

4141
toByteArray : NullifierKey -> ByteArray
4242
| (privateMk b) := b;
4343

4444
module Transparent;
45-
mk : NullifierKey := privateMk (ByteArray.zero 64);
45+
mk : NullifierKey := privateMk (ByteArray.zero size);
4646
end;
4747

4848
deriving instance
@@ -94,15 +94,15 @@ type ConsumedItem :=
9494
mk@{
9595
nullifier : Nullifier;
9696
root : CommitmentRoot;
97-
logic : Nat;
97+
logic : Encoded Logic;
9898
};
9999

100100
type DeltaHash := privateMk Nat;
101101

102102
type CreatedItem :=
103103
mk@{
104104
commitment : Commitment;
105-
logic : Nat;
105+
logic : Encoded Logic;
106106
};
107107

108108
type Instance :=
@@ -134,6 +134,7 @@ type Logic : Type :=
134134
compute : Logic.Arg -> Bool;
135135
}
136136
with
137+
-- called RLPS.Instance
137138
positive
138139
type Arg :=
139140
mk@{
@@ -161,18 +162,18 @@ end;
161162

162163
--- A fixed-size data type encoding a number to be used once ensuring that the resource commitment is unique.
163164
--- NOTE: This should be a number having an at most negligible chance of repeating is sufficient, e.g., a pseudo-random number.
164-
type Nonce := internalMk ByteArray
165+
type Nonce := privateMk ByteArray
165166
with
166167
size : Nat := 32;
167168

168-
fromNat : Nat -> Nonce := fromAnomaContents size >> internalMk;
169+
fromNat : Nat -> Nonce := fromAnomaContents size >> privateMk;
169170

170-
from32SizedByteArray : ByteArray -> Nonce := internalMk;
171+
from32SizedByteArray : ByteArray -> Nonce := privateMk;
171172

172173
toAnomaAtom : Nonce -> AnomaAtom := toNat >> AnomaAtom.fromNat;
173174

174175
toNat : Nonce -> Nat
175-
| (internalMk nonce) := toAnomaContents nonce;
176+
| (privateMk nonce) := toAnomaContents nonce;
176177

177178
deriving instance
178179
Nonce-Ord : Ord Nonce;
@@ -210,8 +211,8 @@ type Resource :=
210211
value : AnomaAtom;
211212
quantity : Nat;
212213
ephemeral : Bool;
213-
nonce : AnomaAtom;
214-
nullifierKeyCommitment : AnomaAtom;
214+
nonce : Nonce;
215+
nullifierKeyCommitment : NullifierKeyCommitment;
215216
unusedRandSeed : Nat;
216217
}
217218
with
@@ -377,6 +378,36 @@ with
377378
end;
378379
end;
379380

381+
type RootedNullifiableResource :=
382+
mk@{
383+
key : NullifierKey;
384+
resource : Resource;
385+
root : CommitmentRoot;
386+
}
387+
with
388+
module Transparent;
389+
mkEphemeral (resource : Resource) : RootedNullifiableResource :=
390+
if
391+
| Resource.ephemeral resource :=
392+
mk@{
393+
resource;
394+
root := CommitmentRoot.fromNat 0;
395+
}
396+
| else :=
397+
failwith "mkEphemeral requires an ephemeral resource as an argument";
398+
399+
mk
400+
(resource : Resource)
401+
(root : CommitmentRoot)
402+
: RootedNullifiableResource :=
403+
RootedNullifiableResource.mk@{
404+
resource;
405+
root;
406+
key := NullifierKey.Transparent.mk;
407+
};
408+
end;
409+
end;
410+
380411
type NullifiableResource :=
381412
mk@{
382413
key : NullifierKey;
@@ -416,21 +447,19 @@ with
416447
axiom listDelta : List Action -> Delta;
417448

418449
create
419-
(consumed : List NullifiableResource)
450+
(consumed : List RootedNullifiableResource)
420451
(created : List Resource)
421452
(appData : AppData)
422453
: Action :=
423454
builtinCreate@{
424-
-- consumed := AnomaSet.fromList consumed;
425-
-- created := AnomaSet.fromList created;
426455
consumed;
427456
created;
428457
appData;
429458
};
430459

431460
builtin anoma-action-create
432461
axiom builtinCreate
433-
(consumed : List NullifiableResource)
462+
(consumed : List RootedNullifiableResource)
434463
(created : List Resource)
435464
(appData : AppData)
436465
: Action;

0 commit comments

Comments
 (0)