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

VersionContext added #705

Merged
merged 16 commits into from
Dec 17, 2020
Merged

VersionContext added #705

merged 16 commits into from
Dec 17, 2020

Conversation

aslesarenko
Copy link
Member

No description provided.

# Conflicts:
#	sigmastate/src/main/scala/sigmastate/interpreter/InterpreterContext.scala
#	sigmastate/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala
@coveralls
Copy link

coveralls commented Nov 26, 2020

Pull Request Test Coverage Report for Build 5366

  • 9 of 18 (50.0%) changed or added relevant lines in 5 files are covered.
  • 2419 unchanged lines in 187 files lost coverage.
  • Overall coverage decreased (-0.1%) to 34.378%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sigmastate/src/main/scala/org/ergoplatform/JsonCodecs.scala 3 5 60.0%
sigmastate/src/main/scala/sigmastate/interpreter/Interpreter.scala 1 3 33.33%
sigmastate/src/main/scala/sigmastate/interpreter/InterpreterContext.scala 4 6 66.67%
sigmastate/src/main/scala/sigmastate/Values.scala 0 3 0.0%
Files with Coverage Reduction New Missed Lines %
common/src/main/scala/scalan/AnyVals.scala 1 36.84%
common/src/main/scala/scalan/ExactIntegral.scala 1 8.0%
common/src/main/scala/scalan/Lazy.scala 1 30.0%
common/src/main/scala/scalan/package.scala 1 25.0%
common/src/main/scala/scalan/util/StringUtil.scala 1 21.74%
core/src/main/scala/scalan/Modules.scala 1 33.33%
core/src/main/scala/scalan/primitives/Equal.scala 1 33.33%
core/src/main/scala/scalan/staged/ProgramGraphs.scala 1 0%
library-api/src/main/scala/special/SpecialPredef.scala 1 14.29%
library-api/src/main/scala/special/Types.scala 1 52.94%
Totals Coverage Status
Change from base Build 5292: -0.1%
Covered Lines: 5671
Relevant Lines: 16496

💛 - Coveralls

Copy link
Member

@kushti kushti left a comment

Choose a reason for hiding this comment

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

Found some problems with updated ErgoLikeContext:

  • remove default value for "val activatedScriptVersion: Byte'
  • add the new field to JSON codecs

@@ -400,7 +400,8 @@ trait JsonCodecs {
"extension" -> ctx.extension.asJson,
"validationSettings" -> ctx.validationSettings.asJson,
"costLimit" -> ctx.costLimit.asJson,
"initCost" -> ctx.initCost.asJson
"initCost" -> ctx.initCost.asJson,
"activatedVersion" -> ctx.activatedScriptVersion.asJson
Copy link
Member

Choose a reason for hiding this comment

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

"scriptVersion" is more clean. Also, in particular, this JSON can be provided via /executeWithContext API, where activation is irrelevant

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -417,7 +418,11 @@ trait JsonCodecs {
validationSettings <- cursor.downField("validationSettings").as[SigmaValidationSettings]
costLimit <- cursor.downField("costLimit").as[Long]
initCost <- cursor.downField("initCost").as[Long]
} yield new ErgoLikeContext(lastBlockUtxoRoot, Colls.fromArray(headers.toArray), preHeader,
dataBoxes, boxesToSpend, spendingTransaction, selfIndex, extension, validationSettings, costLimit, initCost)
version <- cursor.downField("activatedVersion").as[Byte]
Copy link
Member

Choose a reason for hiding this comment

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

"scriptVersion"

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

* [[sigmastate.Values.ConstantPlaceholder]]
* @param resolvePlaceholdersToConstants if true then resolved constants will be
* substituted in the tree instead of the placeholder.
* @param versionContext optional version context to support soft and
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't look like optional parameter (Option[...])

Copy link
Member Author

Choose a reason for hiding this comment

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

parameter removed

@@ -1058,6 +1058,13 @@ object Values {
(header | version).toByte
}

@inline def headerWithVersion(version: Byte): Byte = {
Copy link
Member

Choose a reason for hiding this comment

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

ScalaDoc missed

Copy link
Member Author

Choose a reason for hiding this comment

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

added

@inline def headerWithVersion(version: Byte): Byte = {
var h = updateVersionBits(DefaultHeader, version)
if (version > 0)
h = (h | ErgoTree.SizeFlag).toByte
Copy link
Member

Choose a reason for hiding this comment

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

logic unclear, please add comments

Copy link
Member Author

Choose a reason for hiding this comment

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

clarified

object VersionContext {

/** Descriptor of the max supported versions. */
val MaxSupportedVersion = VersionContext(
Copy link
Member

Choose a reason for hiding this comment

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

Used in testing code only, let's move to the testing code then ? Or eliminate, as it is used once.

Copy link
Member Author

Choose a reason for hiding this comment

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

VersionContext removed entirely

@@ -79,6 +93,7 @@ abstract class SigmaSerializer[TFamily, T <: TFamily] extends Serializer[TFamily
val sigmaByteReader = new SigmaByteReader(r,
new ConstantStore(),
resolvePlaceholdersToConstants = false,
versionContext = VersionContext(0),
Copy link
Member

Choose a reason for hiding this comment

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

Magic number

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@@ -17,29 +18,42 @@ object SigmaSerializer {
val MaxPropositionSize: Int = SigmaConstants.MaxPropositionBytes.value
val MaxTreeDepth: Int = SigmaConstants.MaxTreeDepth.value

/** Helper function to be use in serializers.
//TODO v5.0: remove default value of versionContext parameter
// All usages of this method should pass a version context explicitly.
Copy link
Member

Choose a reason for hiding this comment

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

Why not to do it now?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed

@kushti kushti merged commit 0b949f4 into v4.0 Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants