Skip to content

Commit

Permalink
Merge pull request #715 from ScorexFoundation/develop
Browse files Browse the repository at this point in the history
Release v4.0.1
  • Loading branch information
aslesarenko authored Jan 23, 2021
2 parents cc8d409 + 9f6d129 commit 7cea39a
Show file tree
Hide file tree
Showing 136 changed files with 2,794 additions and 1,243 deletions.
2 changes: 2 additions & 0 deletions common/src/main/scala/scalan/MutableLazy.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scalan

import scala.language.implicitConversions

/** Non-thread safe (but efficient on single thread) immutable lazy value with reset.
* The `block` may execute potentially many times, but only once before each reset. */
final class MutableLazy[A] private (block: => A) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/scala/scalan/TypeDesc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scalan

import scala.reflect.ClassTag
import scala.annotation.implicitNotFound
import scala.language.implicitConversions

/** Base type for all runtime type descriptors. Sigma uses type descriptors to
* represent structure of the data values. Data values of registers and context
Expand Down
1 change: 1 addition & 0 deletions common/src/main/scala/scalan/util/CollectionUtil.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scalan.util

import scala.language.higherKinds
import java.util
import java.util.Objects
import java.util.function.BiConsumer
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/scala/scalan/util/Extensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ object Extensions {
* @see BigInteger#longValueExact
*/
@inline final def to256BitValueExact: BigInteger = {
if (x.bitLength() <= 255) x
if (x.bitLength() <= 255) x // TODO HF: allow 256 bit values
else
throw new ArithmeticException("BigInteger out of 256 bit range");
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/scala/scalan/util/ReflectionUtil.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scalan.util

import java.lang.reflect.{Method, AnnotatedElement}

import scala.language.existentials
import scala.reflect.{classTag, ClassTag}
import scalan.OverloadId

Expand Down
1 change: 1 addition & 0 deletions common/src/test/scala/scalan/BaseTests.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scalan

import scala.language.implicitConversions
import org.scalatest.words.ResultOfStringPassedToVerb
import org.scalatest.{FlatSpec, _}

Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/scalan/Base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scalan
import java.lang.reflect.{Constructor => Constr}
import java.util.Arrays
import scalan.OverloadHack.Overloaded1
import scala.language.implicitConversions
import scala.annotation.implicitNotFound
import scala.annotation.unchecked.uncheckedVariance
import scalan.compilation.GraphVizConfig
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalan/TypeDescs.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scalan

import java.lang.reflect.{InvocationTargetException, Method}

import scala.language.{implicitConversions, higherKinds}
import scala.annotation.implicitNotFound
import scala.collection.immutable.ListMap
import scala.reflect.runtime.universe._
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/scalan/primitives/OrderingOps.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package scalan.primitives

import scalan.{Base, Scalan, ExactOrdering}
import scala.language.implicitConversions

/** Slice in Scala cake with definitions of comparison operations. */
trait OrderingOps extends Base { self: Scalan =>
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/scalan/primitives/Thunks.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scalan.primitives

import scala.language.{existentials, implicitConversions}
import scalan.compilation.{GraphVizConfig, GraphVizExport}
import scalan.{Liftable => _, _}
import debox.{Set => DSet, Buffer => DBuffer}
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/scalan/primitives/Tuples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package scalan.primitives

import scala.language.implicitConversions
import scalan.{Base, Scalan, AVHashMap}

trait Tuples extends Base { self: Scalan =>
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/scalan/staged/Transforming.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scalan.staged
import java.lang.reflect.Method
import java.util

import scala.language.existentials
import scalan.{Nullable, DelayInvokeException, Lazy, Scalan, AVHashMap}
import debox.{Buffer => DBuffer}
import spire.syntax.all.cfor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special

import scala.language.implicitConversions
import scalan.RType
import scala.reflect.{ClassTag, classTag}

Expand Down
1 change: 1 addition & 0 deletions library/src/main/scala/scalan/Library.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scalan

import scala.language.implicitConversions
import special.collection._
import special.wrappers.{WrappersSpecModule, WrappersModule}
import scalan.util.{MemoizedFunc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.collection.mutable.WrappedArray

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collection

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.wrappers

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package wrappers.scala

import scala.language.{existentials,implicitConversions}
import scalan._
import special.wrappers.WrappersModule
import special.wrappers.OptionWrapSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package wrappers.scalan

import scala.language.{existentials,implicitConversions}
import scalan._
import scalan.RType
import special.wrappers.WrappersModule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package wrappers.special

import scala.language.{existentials,implicitConversions}
import scalan._
import impl._
import special.wrappers.WrappersModule
Expand Down
1 change: 1 addition & 0 deletions library/src/test/scala/special/collections/CollGens.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collections

import scala.language.{existentials,implicitConversions}
import scala.collection.mutable.ArrayBuffer
import org.scalacheck.util.Buildable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.collections

import scala.language.{existentials,implicitConversions}
import special.collection.{Coll, PairOfCols, CollOverArray, CReplColl}
import org.scalacheck.Gen
import org.scalatest.{PropSpec, Matchers}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.sigma

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.collection.mutable.WrappedArray

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.sigma

import scala.language.{existentials,implicitConversions}
import scalan._
import scala.reflect.runtime.universe._
import scala.reflect._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import java.util
import org.ergoplatform.ErgoBox._
import org.ergoplatform.settings.ErgoAlgos
import scorex.crypto.hash.Digest32
import scorex.util.{bytesToId, idToBytes, ModifierId}
import scorex.util.{bytesToId, ModifierId}
import sigmastate.Values._
import sigmastate._
import sigmastate.SType.AnyOps
import sigmastate.lang.Terms._
import sigmastate.serialization.SigmaSerializer
import sigmastate.utils.{SigmaByteReader, SigmaByteWriter}
import special.collection.Coll
Expand Down
13 changes: 11 additions & 2 deletions sigmastate/src/main/scala/org/ergoplatform/ErgoScriptPredef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ object ErgoScriptPredef {
IR.buildTree(calcF)
}

val FalseProp = ErgoTree.withoutSegregation(FalseSigmaProp)
val TrueProp = ErgoTree.withoutSegregation(TrueSigmaProp)
/** Create ErgoTree with `false` proposition, which is never true.
* @param headerFlags ErgoTree header flags to be combined with default header
* @see ErgoTree.headerWithVersion()
*/
def FalseProp(headerFlags: Byte): ErgoTree = ErgoTree.withoutSegregation(headerFlags, FalseSigmaProp)

/** Create ErgoTree with `true` proposition, which is always true.
* @param headerFlags ErgoTree header flags to be combined with default header
* @see ErgoTree.headerWithVersion()
*/
def TrueProp(headerFlags: Byte): ErgoTree = ErgoTree.withoutSegregation(headerFlags, TrueSigmaProp)

/**
* Byte array value of the serialized reward output script proposition with pk being substituted
Expand Down
4 changes: 2 additions & 2 deletions sigmastate/src/main/scala/org/ergoplatform/JsonCodecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import scorex.crypto.hash.Digest32
import scorex.util.ModifierId
import sigmastate.Values.{ErgoTree, EvaluatedValue}
import sigmastate.eval.Extensions._
import sigmastate.eval.{CGroupElement, CPreHeader, WrapperOf, _}
import sigmastate.eval.{CPreHeader, WrapperOf, _}
import sigmastate.interpreter.{ContextExtension, ProverResult}
import sigmastate.lang.exceptions.SigmaException
import sigmastate.serialization.{DataJsonEncoder, ErgoTreeSerializer, ValueSerializer}
import sigmastate.{AvlTreeData, AvlTreeFlags, SType}
import special.collection.Coll
import special.sigma.{AnyValue, Header, PreHeader}
import scala.util.Try
import sigmastate.utils.Helpers._
import sigmastate.utils.Helpers._ // required for Scala 2.11

trait JsonCodecs {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ trait ContractSyntax { contract: SigmaContract =>

def Coll[T](items: T*)(implicit cT: RType[T]) = builder.Colls.fromItems(items:_*)

def proposition(name: String, dslSpec: Proposition, scriptCode: String) = {
def proposition(name: String,
dslSpec: Proposition,
scriptCode: String,
scriptVersion: Option[Byte] = None): spec.PropositionSpec = {
val env = contractEnv.mapValues { v =>
val tV = Evaluation.rtypeOf(v).get
val elemTpe = Evaluation.rtypeToSType(tV)
spec.IR.builder.mkConstant[SType](v.asWrappedType, elemTpe)
}
spec.mkPropositionSpec(name, dslSpec, ErgoScript(env, scriptCode))
spec.mkPropositionSpec(name, dslSpec, ErgoScript(env, scriptCode, scriptVersion))
}

def Env(entries: (String, Any)*): ScriptEnv = Map(entries:_*)
}
object ContractSyntax {
type Proposition = Context => SigmaProp
type TokenId = Coll[Byte]
case class ErgoScript(env: ScriptEnv, code: String)
case class ErgoScript(env: ScriptEnv, code: String, scriptVersion: Option[Byte])
case class Token(id: TokenId, value: Long)
}

Expand Down
1 change: 0 additions & 1 deletion sigmastate/src/main/scala/sigmastate/SigSerializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Helpers.xor
import gf2t.GF2_192_Poly
import sigmastate.basics.{SecondDiffieHellmanTupleProverMessage, ProveDHTuple}


object SigSerializer {

val hashSize = CryptoConstants.soundnessBits / 8
Expand Down
Loading

0 comments on commit 7cea39a

Please sign in to comment.