Skip to content

Commit

Permalink
Merge branch 'i958-2' of github.com:ScorexFoundation/sigmastate-inter…
Browse files Browse the repository at this point in the history
…preter into i958
  • Loading branch information
kushti committed Aug 30, 2024
2 parents f347dfd + ea0890b commit dfedb4a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 32 deletions.
15 changes: 2 additions & 13 deletions data/shared/src/main/scala/sigma/ast/SMethod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ case class SMethod(
irInfo: MethodIRInfo,
docInfo: Option[OperationInfo],
costFunc: Option[MethodCostFunc],
userDefinedInvoke: Option[SMethod.InvokeHandler],
sinceVersion: Byte
userDefinedInvoke: Option[SMethod.InvokeHandler]
) {

/** Operation descriptor of this method. */
Expand Down Expand Up @@ -315,17 +314,7 @@ object SMethod {
): SMethod = {
SMethod(
objType, name, stype, methodId, costKind, explicitTypeArgs,
MethodIRInfo(None, None, None), None, None, None, 0)
}

/** Convenience factory method. */
def apply(objType: MethodsContainer, name: String, stype: SFunc,
methodId: Byte,
costKind: CostKind,
sinceVersion: Byte): SMethod = {
SMethod(
objType, name, stype, methodId, costKind, Nil,
MethodIRInfo(None, None, None), None, None, None, sinceVersion)
MethodIRInfo(None, None, None), None, None, None)
}


Expand Down
3 changes: 1 addition & 2 deletions data/shared/src/main/scala/sigma/ast/methods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,7 @@ case object SHeaderMethods extends MonoTypeMethods {

// cost of checkPoW is 700 as about 2*32 hashes required, and 1 hash (id) over short data costs 10
lazy val checkPowMethod = SMethod(
this, "checkPow", SFunc(Array(SHeader), SBoolean), 16, FixedCost(JitCost(700)),
sinceVersion = VersionContext.V6SoftForkVersion)
this, "checkPow", SFunc(Array(SHeader), SBoolean), 16, FixedCost(JitCost(700)))
.withIRInfo(MethodCallIrBuilder)
.withInfo(MethodCall, "Validate header's proof-of-work")

Expand Down
3 changes: 0 additions & 3 deletions data/shared/src/main/scala/sigma/ast/values.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1313,9 +1313,6 @@ case class MethodCall(
addCost(MethodCall.costKind) // MethodCall overhead
method.costKind match {
case fixed: FixedCost =>
if (method.sinceVersion > 0 && E.context.currentErgoTreeVersion < method.sinceVersion) {
syntax.error(s"Method ${method.name} is not supported in tree version ${E.context.currentErgoTreeVersion}")
}
val extra = method.extraDescriptors
val extraLen = extra.length
val len = args.length
Expand Down
23 changes: 15 additions & 8 deletions data/shared/src/main/scala/sigma/pow/Autolykos2PowValidation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ import sigma.crypto.{BcDlogGroup, BigIntegers, CryptoConstants}
import sigma.util.NBitsUtils

/**
* Functions used to validate Autolykos2 Proof-of-Work
* Functions used to validate Autolykos2 Proof-of-Work.
*/
object Autolykos2PowValidation {

type Height = Int

val k = 32

val NStart = 26
/**
* k value for k-sum problem Autolykos is based on (find k numbers in table on N size)
*/
private val k = 32

val group: BcDlogGroup = CryptoConstants.dlogGroup
/**
* Initial size of N value for k-sum problem Autolykos is based on (find k numbers in table on N size).
* It grows from it since predefined block height in Autolykos 2.
*/
private val NStart = 26

// Group order, used in Autolykos V.1 for non-outsourceability,
// and also to obtain target in both Autolykos v1 and v2
val q: BigInt = group.order
/**
* Group order, used in Autolykos V.1 for non-outsourceability,
* and also to obtain target in both Autolykos v1 and v2
*/
private val q: BigInt = CryptoConstants.dlogGroup.order

/**
* Number of elements in a table to find k-sum problem solution on top of
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 @@ -872,7 +872,7 @@ class SigmaDslTesting extends AnyPropSpec
extends Feature[A, B] {

override def isSupportedIn(vc: VersionContext): Boolean =
vc.activatedVersion >= sinceVersion && vc.ergoTreeVersion >= sinceVersion
vc.activatedVersion >= sinceVersion

override def scalaFunc: A => B = { x =>
if (isSupportedIn(VersionContext.current)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,7 @@ class TestingInterpreterSpecification extends CompilerTestingCommons
if (activatedVersionInTests < V6SoftForkVersion) {
an [Exception] should be thrownBy testEval(source)
} else {
if(ergoTreeVersionInTests >= V6SoftForkVersion) {
testEval(source)
} else {
an [Exception] should be thrownBy testEval(source)
}
testEval(source)
}
}

Expand Down

0 comments on commit dfedb4a

Please sign in to comment.