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

Prohibition for using 6.0 types in register and context extension vars #1047

Open
wants to merge 7 commits into
base: v6.0.0
Choose a base branch
from

Conversation

kushti
Copy link
Member

@kushti kushti commented Jan 8, 2025

No description provided.

@kushti kushti added this to the 6.0.0 milestone Jan 8, 2025
@kushti kushti self-assigned this Jan 8, 2025
@kushti kushti changed the base branch from develop to v6.0.0 January 8, 2025 14:04
case c: Constant[_] => v6TypeCheck(c.tpe)
case c: EvaluatedCollection[_, _] => v6TypeCheck(c.elementType)
case GroupGenerator =>
}
Copy link
Member

Choose a reason for hiding this comment

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

What is the motivation to add and check this rule?

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that deserialization of values in registers and context extension is not versioned, so newly supported serializable types (Header, Option[], UnsignedBigInt) can't be put there (but serialized as Coll[Byte] value can be put there to be used with Global.deserialize )

}
}
v match {
case c: Constant[_] => v6TypeCheck(c.tpe)
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems it is possible to serialize/parse Tuple with v6 type

  property("impossible to use v6 types in box registers") {
    val trueProp = ErgoTreePredef.TrueProp(ErgoTree.defaultHeaderWithVersion(3))

    val b = new ErgoBoxCandidate(1L, trueProp, 1,
                  additionalRegisters = Map(R4 -> Tuple(UnsignedBigIntConstant(new BigInteger("1")), IntConstant(1))))
    VersionContext.withVersions(3, 3) {
      val bs = ErgoBoxCandidate.serializer.toBytes(b)
      a[sigma.validation.ValidationException] should be thrownBy ErgoBoxCandidate.serializer.fromBytes(bs)
    }
}

doesn't throw exception

Copy link
Member Author

Choose a reason for hiding this comment

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

@SethDusek fixed, the reason was c.elementType being SAny for Tuple. Made test for UBI as second tuple element, and collection as well

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