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

Finish executeFromVar implementation #976

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open

Finish executeFromVar implementation #976

wants to merge 31 commits into from

Conversation

kushti
Copy link
Contributor

@kushti kushti commented May 6, 2024

This PR contains complete implementation (with tests) of executeFromVar support in the ErgoScript compiler.

Related to #443, #600

TODO: open an issue on executeFromSelfReg

@kushti kushti mentioned this pull request May 6, 2024
2 tasks
@kushti kushti added this to the v6.0 milestone May 7, 2024
@kushti kushti changed the base branch from v6.0.0 to develop May 13, 2024 09:57
@kushti kushti changed the title [6.0.0] Finish executeFromX implementation Finish executeFromX implementation May 13, 2024
@kushti kushti modified the milestones: v6.0, v5.x May 13, 2024
@kushti kushti changed the title Finish executeFromX implementation Finish executeFromVar implementation Jul 22, 2024
@kushti kushti requested a review from aslesarenko July 22, 2024 21:52
* 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
Collaborator

Choose a reason for hiding this comment

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

The connection between SType and Elem[T] is a bit more nuanced.
V <: SType corresponds to Elem[V#WrappedType], in other words, V is a descriptor for V#WrappedType and Elem[T] is a descriptor for T.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does that mean ? What do you propose?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be e: Elem[V#WrappedType].

true
)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please also add test to LanguageSpecificationV6.
DeserializeContext was not covered there before because it was not supported by compiler, and scripts are required there.
Now it can be added.

Copy link
Contributor Author

@kushti kushti Jul 24, 2024

Choose a reason for hiding this comment

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

??? There is nothing 6.0 specific or versioned in general in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

DeserializeContext in not covered in LanguageSpecificationV6, above I explained why. Now it can be covered, but also probably was not used in practice due to lack of ErgoScript support. Now it will be available, so better be covered in the specification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I do not understand, what do you propose to test ? I mean, which DeserializeContext properties, and why in LanguageSpecificationV6 specifically. All other tests in this specification are testing versioned behavior of features added in 6.0. And ScalaDoc for LanguageSpecificationBase is also proposing to test versioned behavior in LanguageSpecification tests. Have you changed ScalaDoc in some PR maybe ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no contradiction, every feature can be tested for many versions, but at least for one. Importantly, all components of the interpreter is tested, parsing, compiler stages, tree serialization, evaluation on different inputs, positive and negative cases, expected values are checked. That is why there should be tests for each language feature (operation) here. Versioning is not a central part of it, but important capability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then I guess DeserializeContext should be in LanguageSpecificationV3 along with all features existing since the mainnet launch. But then you need to open an issue at least about doing what you are proposing for all the nodes existing since the launch, to avoid chaotic implementation of 2-3 nodes before it will be forgotten forever. And the question about properties is still not answered. A typical check in LSV6 is like

      lazy val bitAnd = newFeature(
      { (x: (Int, Int)) => x._1 & x._2 },
      "{ (x: (Int, Int)) => x._1 & x._2 }",
      sinceVersion = VersionContext.V6SoftForkVersion)
      forAll { x: Int =>
        Seq(toAbs).foreach(_.checkEquality(x))
      }
      forAll { x: (Int, Int) =>
        Seq(compareTo, bitOr, bitAnd).foreach(_.checkEquality(x))
      }

So a check is testing that for V6 a new features has some behavior. What do you want to check about DeserializeContext in LSV* ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it is an existing feature so can be added to LSV5 as existingFeature(...).
I believe described above what I "want to check" by creating a new property(){...} for DeserializeContext.
Most of the other cases like this are either not known or already recorded as issues. Don't think this PR depend on this.

@kushti
Copy link
Contributor Author

kushti commented Jul 24, 2024

@aslesarenko comments addressed, please make another pass

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.

2 participants