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

Preparation refactoring towards v5.0 (part 5) #734

Merged
merged 13 commits into from
Nov 3, 2021

Conversation

aslesarenko
Copy link
Member

In this PR:

  • implemented all eval methods of Value classes (aka ErgoTree operations)
  • all eval methods contain cost accumulation
  • costKind descriptors with final cost parameters (based on profiling) declared for all operations

@codecov
Copy link

codecov bot commented Jul 26, 2021

Codecov Report

Merging #734 (262a14d) into develop (571571f) will decrease coverage by 2.75%.
The diff coverage is 27.81%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #734      +/-   ##
===========================================
- Coverage    69.08%   66.32%   -2.76%     
===========================================
  Files          245      247       +2     
  Lines        17567    18596    +1029     
  Branches       517      548      +31     
===========================================
+ Hits         12136    12334     +198     
- Misses        5431     6262     +831     
Impacted Files Coverage Δ
common/src/main/scala/scalan/AnyVals.scala 54.54% <0.00%> (-8.62%) ⬇️
.../src/main/scala/sigmastate/DataValueComparer.scala 0.00% <0.00%> (ø)
...ala/sigmastate/interpreter/ErgoTreeEvaluator.scala 0.00% <0.00%> (ø)
...te/src/main/scala/sigmastate/lang/SigmaTyper.scala 74.15% <ø> (ø)
...mastate/src/main/scala/sigmastate/lang/Terms.scala 55.07% <7.89%> (-17.93%) ⬇️
sigmastate/src/main/scala/sigmastate/Values.scala 69.78% <14.28%> (-11.75%) ⬇️
...src/main/scala/sigmastate/eval/BigIntegerOps.scala 47.61% <16.66%> (+15.47%) ⬆️
.../src/main/scala/sigmastate/utxo/transformers.scala 56.52% <21.92%> (-42.42%) ⬇️
sigmastate/src/main/scala/sigmastate/trees.scala 59.00% <26.08%> (-32.88%) ⬇️
.../main/scala/org/ergoplatform/ErgoLikeContext.scala 74.22% <33.33%> (-13.45%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 571571f...262a14d. Read the comment docs.

@aslesarenko aslesarenko requested a review from kushti August 11, 2021 12:37
@kushti kushti changed the base branch from prepare-v5.0-eval to develop August 19, 2021 21:24
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.

I see no any tests for DataValueComparer.scala, ErgoTreeEvaluator etc

@aslesarenko
Copy link
Member Author

aslesarenko commented Aug 25, 2021

The tests will be in the next (and probably the last incremental PR). A lot of changes in the tests alone (~2K lines). It will be easier to review, because it will be clear that no implementation code is changed and only tests are added.
Also, the new Evaluator will run in parallel with the old version in almost all test cases so that the results are compared. This means the new implementation is fully covered (but in the next PR)
So I suggest to merge this PR without tests.

@@ -248,7 +248,7 @@ class ErgoTreeSerializer {

def substituteConstants(scriptBytes: Array[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.

fixed

Copy link
Member

Choose a reason for hiding this comment

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

description of the second output is 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.

fixed

Copy link
Member

@greenhat greenhat left a comment

Choose a reason for hiding this comment

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

IR nodes evaluation looks good to me. I'm actually very familiar with this JIT evaluation already since almost all of the sigma-rust interpreter is implemented with this JIT evaluation as a reference (I used direct-tree-eval branch).
I did not check AOT vs. JIT costing equivalency. I suppose there are(will be) tests for that but I did not find them with a quick search. Since we're about to start costing implementation in sigma-rust these tests would be an excellent reference and we would build our costing tests around it.

Please also check notes/questions I made in the comments.

@@ -72,6 +89,13 @@ object NumericOps {
override def times(x: BigInt, y: BigInt): BigInt = n.times(x, y)
}

implicit object BigIntIsExactIntegral extends ExactIntegral[BigInt] {
Copy link
Member

Choose a reason for hiding this comment

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

ScalaDoc is 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.

fixed

@greenhat
Copy link
Member

I did not check AOT vs. JIT costing equivalency. I suppose there are(will be) tests for that but I did not find them with a quick search. Since we're about to start costing implementation in sigma-rust these tests would be an excellent reference and we would build our costing tests around it.

I found commented JitCostingSpecification.scala in #738 - https://github.com/ScorexFoundation/sigmastate-interpreter/pull/738/files#diff-dd46271e18b352136f7afb1216c3651fce6cc1691321b544462dab8ff4000e32
I plan to use it as a test vector to ensure sigma-rust costing equivalency

@aslesarenko
Copy link
Member Author

aslesarenko commented Oct 20, 2021

Since we're about to start costing implementation in sigma-rust these tests would be an excellent reference and we would build our costing tests around it.

@greenhat The AOT and JIT costs are different, so they are not equivalent.
However JIT costs are lower then AOT costs and as result the node with JIT interpreter can do a full sync without problems. (at least when I did it in May-June)

For sigma-rust you can look at SigmaDslSpecification in #738
It has a lot of test vectors and covers all operations.

@aslesarenko aslesarenko force-pushed the prepare-v5.0-evaluator branch from c335cbd to 3c3f6f1 Compare October 20, 2021 12:44
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.

Approved, but please check comments

@@ -248,7 +248,7 @@ class ErgoTreeSerializer {

def substituteConstants(scriptBytes: Array[Byte],
Copy link
Member

Choose a reason for hiding this comment

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

description of the second output is missed

sigmastate/src/main/scala/sigmastate/trees.scala Outdated Show resolved Hide resolved
sigmastate/src/main/scala/sigmastate/trees.scala Outdated Show resolved Hide resolved
@aslesarenko aslesarenko merged commit 8c7d397 into develop Nov 3, 2021
@aslesarenko aslesarenko mentioned this pull request Nov 24, 2021
@aslesarenko aslesarenko deleted the prepare-v5.0-evaluator branch March 12, 2022 09:13
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