Skip to content
Open

WIP #18

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
7c7e0e1
Add simple Par and tests
hilltracer Apr 19, 2023
9055e97
Simplification with matching, separation to many files
hilltracer Jun 16, 2023
e394dce
Add simple tests for all existing pars, repairnig existing pars
hilltracer Jun 19, 2023
be2f678
Delete locallyFree field
hilltracer Jun 19, 2023
b75cedd
Repaire comments
hilltracer Jun 19, 2023
6bf5205
Append ReceiveN and refactoring metadata processing
hilltracer Jun 20, 2023
35780ba
Refactoring 2
hilltracer Jun 21, 2023
74d4c07
Add type for match
hilltracer Jun 21, 2023
49e3754
Add type for New
hilltracer Jun 23, 2023
51887c4
Add GBool
hilltracer Jun 23, 2023
eea7b58
Change name VarN.value to VarN.idx. Update comments
hilltracer Jun 23, 2023
25fe512
Add BigInt
hilltracer Jun 26, 2023
a15d95b
Add GString
hilltracer Jun 26, 2023
659c743
Add another metadata testing
hilltracer Jun 26, 2023
c25122e
Add GUri
hilltracer Jun 26, 2023
9d6ffc1
Add unforgeable names
hilltracer Jun 26, 2023
1081ede
Add SysAuthToken
hilltracer Jun 27, 2023
8dbe9c0
Add Etuple
hilltracer Jun 27, 2023
4fd7eee
Files renaming and add GbyteArray
hilltracer Jun 27, 2023
e622f28
Reformat basic traits, add ENeg operations
hilltracer Jun 27, 2023
bf8719c
Add all operations
hilltracer Jun 28, 2023
624126a
Add bundle
hilltracer Jun 29, 2023
4954009
Move Nil to Basic trait
hilltracer Jun 29, 2023
068b97f
Add connective simple types
hilltracer Jun 30, 2023
143b3d7
Add connective logic operations and varRef
hilltracer Jun 30, 2023
7f59153
Add Set and SetSpec
hilltracer Jul 1, 2023
e34cbee
Add compare Pars in Sorting object
hilltracer Jul 1, 2023
cef012e
Add Map, collection methods and CollectionSpec
hilltracer Jul 3, 2023
3d351a2
Add sortedPs method in ParProc, add sorting test for collections
hilltracer Jul 3, 2023
ab221cc
Add NewType->OldType convertor methods
hilltracer Jul 5, 2023
51a7168
Add OldType->NewType convertor methods
hilltracer Jul 6, 2023
26f3f97
Change position unforgeable names in processing
hilltracer Jul 6, 2023
81dec92
Add injections in NewN par
hilltracer Jul 6, 2023
5458507
Update rho types in ProcMatcherSpec
hilltracer Jul 19, 2023
b35587e
Update types for Send in normalizer
hilltracer Jul 19, 2023
5e30d0c
Update types for New
hilltracer Jul 19, 2023
70bfcb2
Update types for bundle
hilltracer Jul 19, 2023
95ee7dc
Update tuypes for receive
hilltracer Jul 20, 2023
743fbdf
Add sorting for bindings in Receive
hilltracer Jul 20, 2023
a23c750
Update types for receive binding creation and sorting
hilltracer Jul 21, 2023
72f715a
Update types for match
hilltracer Jul 21, 2023
8c12944
Update types for Var
hilltracer Jul 21, 2023
ad3250b
Update types for VarRef
hilltracer Jul 22, 2023
a82a7e6
Update types for conjunction
hilltracer Jul 22, 2023
8ed7e49
Update types for disjunction
hilltracer Jul 22, 2023
1d6c49c
Update types for contract
hilltracer Jul 22, 2023
37ce59d
Update types for Eval
hilltracer Jul 22, 2023
6bb3fb9
Update types for PGround
hilltracer Jul 22, 2023
c11d8b6
Update types for If
hilltracer Jul 24, 2023
fce8435
Update types for Let
hilltracer Jul 24, 2023
2fd7864
update types for matches
hilltracer Jul 24, 2023
6cd71d3
Update types for EMethod
hilltracer Jul 24, 2023
792a402
Update types for negation and connectives
hilltracer Jul 25, 2023
ffc43ff
Update types for collections
hilltracer Jul 25, 2023
1e8570e
Update types for ground and name normalizers
hilltracer Jul 25, 2023
a85cfbb
Delete old code for sorting receive bind in normalizer
hilltracer Jul 25, 2023
6360e9f
Change group for SysAuthToken type from `Other` to `Unforgeable`
hilltracer Jul 26, 2023
4dc23dc
Fix tests
hilltracer Jul 27, 2023
ce0cb80
Fix tests 2
hilltracer Jul 27, 2023
4eb1d01
Revert old sorting for receive binds
hilltracer Jul 29, 2023
4fbb819
Fix tests 3
hilltracer Jul 29, 2023
d702c2e
Fix test 4
hilltracer Jul 29, 2023
fdf0e30
Fix tests 5
hilltracer Aug 2, 2023
1b23d8a
Update type for input.par in normalizer
hilltracer Jul 25, 2023
beed88a
Add flatting for ParProc
hilltracer Jul 29, 2023
afe2ae1
Update type for output.par in normalizer
hilltracer Jul 29, 2023
5559e50
Fix tests
hilltracer Jul 30, 2023
0c2adbd
Update type for NameVisitOutputs.par
hilltracer Jul 30, 2023
39ea398
Rename ParN.add method
hilltracer Jul 30, 2023
3c6c0a4
Update types for Bool and collection normalizer
hilltracer Jul 30, 2023
4a8d089
Fix tests
hilltracer Jul 31, 2023
241ecab
Changing types for connectives and expressions
hilltracer Jul 31, 2023
da6ce43
Fix tests
hilltracer Jul 31, 2023
559c153
Rename rholangN -> rholangn
hilltracer Aug 2, 2023
42c4813
Rename package ParManager -> parmanager
hilltracer Aug 2, 2023
e507f22
Change ByteVector to Array[Byte].
hilltracer Aug 3, 2023
1857ad5
Change asserts to throw exceptions
hilltracer Aug 3, 2023
e6bb64b
Change bindings
hilltracer Aug 3, 2023
4d36be3
Convert empty parameter class to object
hilltracer Aug 3, 2023
7dcde19
Simplify bindings
hilltracer Aug 3, 2023
58d7f8b
Convert class NilN() to object
hilltracer Aug 3, 2023
13b504c
SetBench
hilltracer Aug 4, 2023
732e1fd
Remove custom dependency
nzpr Aug 4, 2023
81780cb
Fix wartremover
hilltracer Aug 4, 2023
eefc526
Simplify hash comparing
hilltracer Aug 4, 2023
3be9d73
Fix tests
hilltracer Aug 4, 2023
8513a2d
Remove unused Option as input argument
tgrospic Aug 8, 2023
d3caa7b
Materialize list to prevent multiple iterations
tgrospic Aug 8, 2023
5d41939
Remove function with Option argument
tgrospic Aug 8, 2023
7497744
Append sorting test
hilltracer Aug 8, 2023
da50de4
Fix 1
hilltracer Aug 8, 2023
781245c
Fix 2
hilltracer Aug 8, 2023
315fb6d
Fix comments for collection remainder
hilltracer Aug 8, 2023
4f1a3fc
Add ordering to ParN object
hilltracer Aug 8, 2023
170fac3
Transfer unused methods in ParN object
hilltracer Aug 8, 2023
6f0805c
Transfer toBytes and combine methods to ParN object
hilltracer Aug 8, 2023
862b06b
Simplify .length match
hilltracer Aug 8, 2023
28d7f09
Fix 3
hilltracer Aug 8, 2023
723c021
Fix 4
hilltracer Aug 8, 2023
33b8060
Fix 5
hilltracer Aug 8, 2023
3bbba35
Fix 6
hilltracer Aug 8, 2023
0c866ab
Fix 7
hilltracer Aug 8, 2023
e77c34c
Fix 8
hilltracer Aug 9, 2023
0dbbfbd
Fix 9
hilltracer Aug 9, 2023
581ca86
Fix 10
hilltracer Aug 9, 2023
5108502
Print undefined type
nzpr Aug 11, 2023
75dbb51
Merge pull request #34 from hilltracer/new-rho-types
nzpr Aug 15, 2023
084fc2b
Stack safe serialization for the new core types
tgrospic Aug 10, 2023
77fe476
Simplify recursive part of stack safe serialization
tgrospic Aug 10, 2023
c3a2f4e
Fix recursive call to Eval field on base type (memoization fix)
tgrospic Aug 10, 2023
717a42a
Stacksafe deserialization of the new core types
tgrospic Aug 10, 2023
b27b2b9
Fix serialization output, refactor deserialize seq
tgrospic Aug 10, 2023
6b6aaa3
Remove flatMap custom function
tgrospic Aug 10, 2023
09f9bdd
Use readInt instead of readLength (removed)
tgrospic Aug 10, 2023
5dfd447
Serialization cleanup, add comments
tgrospic Aug 10, 2023
417ac6d
Fix serialized size calc (trampoline)
tgrospic Aug 12, 2023
53628a4
Fix stack safe test - use Eval value in comparison
tgrospic Aug 12, 2023
9f611b1
Refactor serialization, add protobuf output classes
tgrospic Aug 18, 2023
b6be109
Serialization - reorder case analysis by arity of constructors
tgrospic Aug 19, 2023
0beb158
Fix deserialization and reorder case analysis by arity of constructors
tgrospic Aug 19, 2023
dacd2f0
Fix serialization of raw bytes w/ and w/o size prefix
tgrospic Aug 19, 2023
e26a036
Separate wire logic from traversal
nzpr Aug 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/test/test_propose.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"contract_2.rho": 197,
"contract_3.rho": 329,
"contract_4.rho": 782,
"contract_5.rho": 3892,
"contract_5.rho": 3868,
}

@contextmanager
Expand Down
1 change: 1 addition & 0 deletions models/src/main/scala/coop/rchain/models/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package coop.rchain
import coop.rchain.models.ByteStringSyntax
import coop.rchain.models.ByteArraySyntax
import coop.rchain.models.StringSyntax
import coop.rchain.models.rholangn.parmanager.primitive.syntax.PrimitiveWriterSyntax

package object models {
// Importing syntax object means using all extensions in the project
Expand Down
162 changes: 162 additions & 0 deletions models/src/main/scala/coop/rchain/models/rholangn/Basic.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
package coop.rchain.models.rholangn

object NilN extends BasicN

/** *
* Rholang process
*
* For example, `@0!(1) | @2!(3) | for(x <- @0) { Nil }` has two sends
* and one receive.
*/
final class ParProcN(val ps: Seq[ParN]) extends BasicN {
def sortedPs: Seq[ParN] = parmanager.Manager.sortPars(ps)
}
object ParProcN { def apply(ps: Seq[ParN]): ParProcN = new ParProcN(ps) }

/** *
* A send is written `chan!(data)` or `chan!!(data)` for a persistent send.
* Upon send, all free variables in data are substituted with their values.
*/
final class SendN(val chan: ParN, val data: Seq[ParN], val persistent: Boolean) extends BasicN
object SendN {
def apply(chan: ParN, data: Seq[ParN], persistent: Boolean): SendN =
new SendN(chan, data, persistent)

def apply(chan: ParN, data: Seq[ParN]): SendN =
apply(chan, data, persistent = false)

def apply(chan: ParN, data: ParN, persistent: Boolean): SendN =
apply(chan, Seq(data), persistent)

def apply(chan: ParN, data: ParN): SendN =
apply(chan, Seq(data), persistent = false)
}

/** *
* A receive is written `for(binds) { body }`
* i.e. `for(patterns <- source) { body }`
* or for a persistent recieve: `for(patterns <= source) { body }`.
*
* It's an error for free Variable to occur more than once in a pattern.
*/
final class ReceiveN(
val binds: Seq[ReceiveBindN],
val body: ParN,
val persistent: Boolean,
val peek: Boolean,
val bindCount: Int
) extends BasicN {
def sortedBinds: Seq[ReceiveBindN] = parmanager.Manager.sortBinds(binds)
}
object ReceiveN {
def apply(
binds: Seq[ReceiveBindN],
body: ParN,
persistent: Boolean,
peek: Boolean,
bindCount: Int
): ReceiveN =
new ReceiveN(binds, body, persistent, peek, bindCount)

def apply(
bind: ReceiveBindN,
body: ParN,
persistent: Boolean,
peek: Boolean,
bindCount: Int
): ReceiveN =
apply(Seq(bind), body, persistent, peek, bindCount)

def apply(binds: Seq[ReceiveBindN], body: ParN, bindCount: Int): ReceiveN =
apply(binds, body, persistent = false, peek = false, bindCount)

def apply(bind: ReceiveBindN, body: ParN, bindCount: Int): ReceiveN =
apply(Seq(bind), body, bindCount)
}

final class ReceiveBindN(
val patterns: Seq[ParN],
val source: ParN,
val remainder: Option[VarN],
val freeCount: Int
) extends AuxParN

object ReceiveBindN {
def apply(
patterns: Seq[ParN],
source: ParN,
remainder: Option[VarN],
freeCount: Int
): ReceiveBindN = new ReceiveBindN(patterns, source, remainder, freeCount)

def apply(pattern: ParN, source: ParN, remainder: Option[VarN], freeCount: Int): ReceiveBindN =
apply(Seq(pattern), source, remainder, freeCount)

def apply(patterns: Seq[ParN], source: ParN, freeCount: Int): ReceiveBindN =
new ReceiveBindN(patterns, source, None, freeCount)

def apply(pattern: ParN, source: ParN, freeCount: Int): ReceiveBindN =
apply(Seq(pattern), source, freeCount)

def apply(pattern: ParN, source: ParN): ReceiveBindN =
apply(Seq(pattern), source, 0)
}

/**
*
*/
final class MatchN(val target: ParN, val cases: Seq[MatchCaseN]) extends BasicN

object MatchN {
def apply(target: ParN, cases: Seq[MatchCaseN]): MatchN = new MatchN(target, cases)
def apply(target: ParN, mCase: MatchCaseN): MatchN = apply(target, Seq(mCase))
}

final class MatchCaseN(val pattern: ParN, val source: ParN, val freeCount: Int) extends AuxParN

object MatchCaseN {
def apply(pattern: ParN, source: ParN, freeCount: Int = 0): MatchCaseN =
new MatchCaseN(pattern, source, freeCount)
}

/**
* The new construct serves as a variable binder with scope Proc which producesan unforgeable process
* for each uniquely declared variable and substitutes these (quoted) processes for the variables.
*
* @param bindCount Total number of variables entered in p. This makes it easier to substitute or walk a term.
* @param p Rholang executable code inside New.
* For normalized form, p should not contain solely another new.
* Also for normalized form, the first use should be level+0, next use level+1
* up to level+count for the last used variable.
* @param uri List of names Rho built-in processes listening on channels (e.g. `rho:io:stdout`).
* For normalization, uri-referenced variables come at the end, and in lexicographical order.
* @param injections List of injected uri-referenced variables (e.g. rho:rchain:deployId).
* Should be sort by key in lexicographical order.
*/
final class NewN(
val bindCount: Int,
val p: ParN,
val uri: Seq[String],
val injections: Map[String, ParN]
) extends BasicN {
def sortedUri: Seq[String] = parmanager.Manager.sortUris(uri)
def sortedInjections: Seq[(String, ParN)] = parmanager.Manager.sortInjections(injections)
}

object NewN {
def apply(
bindCount: Int,
p: ParN,
uri: Seq[String],
injections: Map[String, ParN]
): NewN = new NewN(bindCount, p, uri, injections)

def apply(
bindCount: Int,
p: ParN,
uri: Seq[String],
injections: Seq[(String, ParN)]
): NewN = new NewN(bindCount, p, uri, Map.from(injections))

def apply(bindCount: Int, p: ParN): NewN = new NewN(bindCount, p, Seq(), Map())
}
30 changes: 30 additions & 0 deletions models/src/main/scala/coop/rchain/models/rholangn/Bindings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package coop.rchain.models.rholangn

import coop.rchain.models._

object Bindings {
def toProto(p: ParN): Par = BindingsToProto.toProto(p)
def toProto(ps: Seq[ParN]): Seq[Par] = ps.map(toProto)
def toProtoVarOpt(p: VarN): Var = BindingsToProto.toVar(p)
def toProtoExpr(e: ExprN): Expr = BindingsToProto.toExpr(e)
def toProtoVar(v: VarN): Var = BindingsToProto.toVar(v)
def toProtoUnforgeable(u: UnforgeableN): GUnforgeable = BindingsToProto.toUnforgeable(u)
def toProtoConnective(c: ConnectiveN): Connective = BindingsToProto.toConnective(c)
def toProtoSend(x: SendN): Send = BindingsToProto.toSend(x)
def toProtoReceive(x: ReceiveN): Receive = BindingsToProto.toReceive(x)
def toProtoMatch(x: MatchN): Match = BindingsToProto.toMatch(x)
def toProtoNew(x: NewN): New = BindingsToProto.toNew(x)

def fromProto(p: Par): ParN = BindingsFromProto.fromProto(p)
def fromProto(ps: Seq[Par]): Seq[ParN] = ps.map(fromProto)
def fromProtoVarOpt(p: Var): VarN = BindingsFromProto.fromVar(p)
def fromProtoExpr(e: Expr): ExprN = BindingsFromProto.fromExpr(e)
def fromProtoVar(v: Var): VarN = BindingsFromProto.fromVar(v)
def fromProtoUnforgeable(u: GUnforgeable): UnforgeableN = BindingsFromProto.fromUnforgeable(u)
def fromProtoConnective(c: Connective): ConnectiveN = BindingsFromProto.fromConnective(c)
def fromProtoSend(x: Send): SendN = BindingsFromProto.fromSend(x)
def fromProtoReceive(x: Receive): ReceiveN = BindingsFromProto.fromReceive(x)
def fromProtoMatch(x: Match): MatchN = BindingsFromProto.fromMatch(x)
def fromProtoNew(x: New): NewN = BindingsFromProto.fromNew(x)

}
Loading