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

Candidate for 5.0.15 release #1036

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6241e86
6.0.0 version set in readme
kushti Nov 6, 2023
727ed8d
evolution version
kushti Nov 22, 2023
048add3
comments fixed
kushti Nov 22, 2023
e7e4c1d
Merge pull request #939 from ScorexFoundation/v6.0.0-activation
kushti Nov 22, 2023
be98cc8
Merge branch 'master' into v6.0.0
kushti Dec 21, 2023
f985679
versioned tests
kushti Apr 2, 2024
fbaaa13
merging w. 5.0.14 RC
kushti Apr 3, 2024
0216468
Merge branch 'v5.0.14-RC' of github.com:ScorexFoundation/sigmastate-i…
kushti Apr 4, 2024
815b224
importing tonbits method for playing with
kushti Apr 10, 2024
4fc62c6
version test for nbits
kushti Apr 11, 2024
72814c0
merging w. develop
kushti May 1, 2024
98e2756
moving failing test from #612 to here
kushti May 6, 2024
038afc7
Merge branch 'develop' of github.com:ScorexFoundation/sigmastate-inte…
kushti May 6, 2024
2c6bd15
Merge branch 'v6.0.0' of github.com:ScorexFoundation/sigmastate-inter…
kushti May 6, 2024
624558f
executeFromVar tests are passing
kushti May 7, 2024
690a3e2
Global.deserialize method
kushti May 7, 2024
023ad09
deserialize int - test passing
kushti May 8, 2024
7648182
unused code removal
kushti May 9, 2024
79b4d11
executeFromVar is passing for SigmaProp
kushti May 9, 2024
a470406
more executeFromVar and deserialize tests, all passing
kushti May 9, 2024
c1947d4
negative test for DeserializeContext in executeFromVar, new stubs for…
kushti May 9, 2024
cec0add
long roundtrip
kushti May 9, 2024
838a617
box rouundtrip test
kushti May 10, 2024
fd589a8
bigInt test
kushti May 10, 2024
4404741
Short test
kushti May 10, 2024
7d69ebc
group elem impl & test
kushti May 10, 2024
48f112a
sigmaprop test & impl
kushti May 12, 2024
63f8ccc
non evaluated sigmaprop test
kushti May 12, 2024
516f05d
avltree test & impl
kushti May 12, 2024
9b2d56e
removing 6.0 related code
kushti May 13, 2024
d4d77f8
merging w. develop, Scaladoc
kushti Jul 22, 2024
00996ec
scrypto version updated
kushti Nov 27, 2024
f6288f7
Merge branch 'v5.0.15' of github.com:ScorexFoundation/sigmastate-inte…
kushti Nov 27, 2024
e6bf0f4
Merge pull request #976 from ergoplatform/i443
kushti Dec 5, 2024
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
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ ThisBuild / dynverSeparator := "-"

val bouncycastleBcprov = "org.bouncycastle" % "bcprov-jdk15on" % "1.66"

val scrypto = "org.scorexfoundation" %% "scrypto" % "2.3.0-4-a0bc6176-SNAPSHOT"
val scrypto = "org.scorexfoundation" %% "scrypto" % "3.0.0"
val scryptoDependency =
libraryDependencies += "org.scorexfoundation" %%% "scrypto" % "2.3.0-4-a0bc6176-SNAPSHOT"
libraryDependencies += "org.scorexfoundation" %%% "scrypto" % "3.0.0"

val scorexUtil = "org.scorexfoundation" %% "scorex-util" % "0.2.1"
val scorexUtilDependency =
Expand Down
33 changes: 16 additions & 17 deletions data/shared/src/main/scala/sigma/ast/SigmaPredef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@ object SigmaPredef {
Seq(ArgInfo("condition", "boolean value to embed in SigmaProp value")))
)

val GetVarFunc = PredefinedFunc("getVar",
Lambda(Array(paramT), Array("varId" -> SByte), SOption(tT), None),
PredefFuncInfo(
{ case (Ident(_, SFunc(_, SOption(rtpe), _)), Seq(id: Constant[SNumericType]@unchecked)) =>
mkGetVar(SByte.downcast(id.value.asInstanceOf[AnyVal]), rtpe)
}),
OperationInfo(GetVar,
"Get context variable with given \\lst{varId} and type.",
Seq(ArgInfo("varId", "\\lst{Byte} identifier of context variable")))
)

def PKFunc(networkPrefix: NetworkPrefix) = PredefinedFunc("PK",
Lambda(Array("input" -> SString), SSigmaProp, None),
PredefFuncInfo(
Expand Down Expand Up @@ -366,13 +355,23 @@ object SigmaPredef {
ArgInfo("newValues", "new values to be injected into the corresponding positions in ErgoTree.constants array")))
)

val GetVarFunc = PredefinedFunc("getVar",
Lambda(Array(paramT), Array("varId" -> SByte), SOption(tT), None),
PredefFuncInfo(
{ case (Ident(_, SFunc(_, SOption(rtpe), _)), Seq(id: Constant[SNumericType]@unchecked)) =>
mkGetVar(SByte.downcast(id.value.asInstanceOf[AnyVal]), rtpe)
}),
OperationInfo(GetVar,
"Get context variable with given \\lst{varId} and type.",
Seq(ArgInfo("varId", "\\lst{Byte} identifier of context variable")))
)

val ExecuteFromVarFunc = PredefinedFunc("executeFromVar",
Lambda(
Seq(paramT),
Array("id" -> SByte),
tT, None
),
PredefFuncInfo(undefined),
Lambda(Array(paramT), Array("id" -> SByte), tT, None),
PredefFuncInfo(
{ case (Ident(_, SFunc(_, rtpe, _)), Seq(id: Constant[SNumericType]@unchecked)) =>
mkDeserializeContext(SByte.downcast(id.value.asInstanceOf[AnyVal]), rtpe)
}),
OperationInfo(DeserializeContext,
"""Extracts context variable as \lst{Coll[Byte]}, deserializes it to script
| and then executes this script in the current context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ trait Interpreter {
case _ => None
}

/** Extracts proposition for ErgoTree handing soft-fork condition.
/** Extracts proposition for ErgoTree handling soft-fork condition.
* @note soft-fork handler */
protected def propositionFromErgoTree(ergoTree: ErgoTree, context: CTX): SigmaPropValue = {
val validationSettings = context.validationSettings
Expand Down
2 changes: 0 additions & 2 deletions profile-sbt.sh

This file was deleted.

15 changes: 8 additions & 7 deletions sc/shared/src/main/scala/sigma/compiler/ir/Base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package sigma.compiler.ir

import debox.{cfor, Buffer => DBuffer}
import sigma.compiler.ir.core.MutableLazy
import sigma.data.OverloadHack.Overloaded1
import sigma.ast.{DeserializeContext, SType}
import sigma.data.{AVHashMap, Nullable, RType}
import sigma.data.OverloadHack.Overloaded1
import sigma.reflection.RConstructor
import sigma.util.StringUtil

Expand Down Expand Up @@ -169,7 +170,7 @@ abstract class Base { thisIR: IRContext =>

/** Create a copy of this definition applying the given transformer to all `syms`. */
def transform(t: Transformer): Def[T] =
!!!(s"Cannot transfrom definition using transform($this)", self)
!!!(s"Cannot transform definition using transform($this)", self)

/** Clone this definition transforming all symbols using `t`.
* If new Def[A] is created, it is added to the graph with collapsing and rewriting.
Expand Down Expand Up @@ -203,10 +204,11 @@ abstract class Base { thisIR: IRContext =>
}
}

/** Logical AND between two pattern matches of the save value `x`.
* Can be used to construct patterns like `case P1 && P2 => ...` */
object && {
def unapply[T](x: T): Option[(T,T)] = Some((x, x))
/**
* Def done in order to carry on DeserializeContext through stages of compilation intact
*/
case class DeserializeContextDef[V <: SType](d: DeserializeContext[V], e: Elem[V]) extends Def[V] {
override def resultType: Elem[V] = e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a problem with typing here. In a type like Elem[V], the V should be a type of data value (Int, Long, Boolean, Coll, GroupElement). However, the V <: SType part suggests V to be SInt, SLong, SBoolean, etc.
The compiler is not complaining likely because of .asInstanceOf[] being used.
It should be ..., e: Elem[V#WrappedType]) extends Def[V#WrappedType] ...

}

/** Base class for virtualized instances of type companions.
Expand Down Expand Up @@ -383,7 +385,6 @@ abstract class Base { thisIR: IRContext =>
/** Returns the string like `x45: Int = Const(10)` */
def toStringWithDefinition: String
def varNameWithType = varName + ":" + elem.name

}

/** Untyped shortcut sinonim of Ref, which is used as untyped reference to graph nodes (definitions).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ trait GraphBuilding extends Base with DefRewriting { IR: IRContext =>
val e = stypeToElem(optTpe.elemType)
ctx.getVar(id)(e)

case d: DeserializeContext[T] =>
val e = stypeToElem(d.tpe).asInstanceOf[Elem[T]]
DeserializeContextDef(d, e)

case ValUse(valId, _) =>
env.getOrElse(valId, !!!(s"ValUse $valId not found in environment $env"))

Expand Down
3 changes: 3 additions & 0 deletions sc/shared/src/main/scala/sigma/compiler/ir/TreeBuilding.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ trait TreeBuilding extends Base { IR: IRContext =>
val tpe = elemToSType(s.elem)
mkConstant[tpe.type](wc.constValue.asInstanceOf[tpe.WrappedType], tpe)

case Def(DeserializeContextDef(d, _)) =>
d

case Def(IsContextProperty(v)) => v
case s if s == sigmaDslBuilder => Global

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SigmaTyper(val builder: SigmaBuilder,

private def processGlobalMethod(srcCtx: Nullable[SourceContext],
method: SMethod,
args: IndexedSeq[SValue]) = {
args: IndexedSeq[SValue]): SValue = {
val global = Global.withPropagatedSrcCtx(srcCtx)
val node = for {
pf <- method.irInfo.irBuilder if lowerMethodCalls
Expand Down
2 changes: 1 addition & 1 deletion sc/shared/src/test/scala/sigma/SigmaDslTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class SigmaDslTesting extends AnyPropSpec
// Compile script the same way it is performed by applications (i.e. via Ergo Appkit)
val prop = compile(env, code)(IR).asSigmaProp

// Add additional oparations which are not yet implemented in ErgoScript compiler
// Add additional operations which are not yet implemented in ErgoScript compiler
val multisig = AtLeast(
IntConstant(2),
Array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sigmastate.utxo

import org.ergoplatform.ErgoBox.{AdditionalRegisters, R6, R8}
import org.ergoplatform._
import sigma.Colls
import sigma.Extensions.ArrayOps
import sigma.ast.SCollection.SByteArray
import sigma.ast.SType.AnyOps
Expand All @@ -19,6 +20,7 @@ import sigmastate.interpreter.Interpreter._
import sigma.ast.Apply
import sigma.eval.EvalSettings
import sigma.exceptions.InvalidType
import sigma.serialization.ValueSerializer
import sigmastate.utils.Helpers._

import java.math.BigInteger
Expand Down Expand Up @@ -157,6 +159,50 @@ class BasicOpsSpecification extends CompilerTestingCommons
)
}

property("executeFromVar - SigmaProp") {
val script = GT(Height, IntConstant(-1)).toSigmaProp
val scriptBytes = ValueSerializer.serialize(script)
val customExt = Seq(21.toByte -> ByteArrayConstant(scriptBytes))
test("executeFromVar", env, customExt,
"executeFromVar[SigmaProp](21)",
null,
true
)
}

property("executeFromVar - Int") {
val valueBytes = ValueSerializer.serialize(Plus(IntConstant(2), IntConstant(3)))
val customExt = Seq(21.toByte -> ByteArrayConstant(valueBytes))
test("executeFromVar", env, customExt,
"{ executeFromVar[Int](21) == 5 }",
null,
true
)
}

property("executeFromVar - Coll[Byte]") {
val bytes = Slice(ByteArrayConstant(Colls.fromArray(Array.fill(5)(1.toByte))), IntConstant(1), IntConstant(3))
val valueBytes = ValueSerializer.serialize(bytes)
val customExt = Seq(21.toByte -> ByteArrayConstant(valueBytes))
test("executeFromVar", env, customExt,
"{val ba = executeFromVar[Coll[Byte]](21); ba.size == 2 }",
null,
true
)
}

// test which is showing impossibility of nested Deserialize*
property("executeFromVar - deserialize") {
val script = DeserializeContext(21.toByte, SSigmaProp)
val scriptBytes = ValueSerializer.serialize(script)
val customExt = Seq(21.toByte -> ByteArrayConstant(scriptBytes))
an [Exception] should be thrownBy test("executeFromVar", env, customExt,
"executeFromVar[SigmaProp](21)",
null,
true
)
}

property("Relation operations") {
test("R1", env, ext,
"{ allOf(Coll(getVar[Boolean](trueVar).get, true, true)) }",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import sigma.ast.ByteArrayConstant
class ExecuteFromExamplesSpecification extends CompilerTestingCommons { suite =>
implicit lazy val IR = new TestingIRContext

private val reg1 = ErgoBox.nonMandatoryRegisters(0)

case class OracleContract[Spec <: ContractSpec]
(alice: Spec#ProvingParty)
(implicit val spec: Spec) extends SigmaContractSyntax with StdContracts
Expand Down Expand Up @@ -40,8 +38,7 @@ class ExecuteFromExamplesSpecification extends CompilerTestingCommons { suite =>

lazy val alice = spec.ProvingParty("Alice")

// TODO soft-fork: related to https://github.com/ScorexFoundation/sigmastate-interpreter/issues/443
ignore("Execute from var example (ErgoDsl)") {
property("Execute from var example (ErgoDsl)") {
val contract = OracleContract[spec.type](alice)(spec)
import contract.spec._

Expand Down
Loading