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

Filter out transactions with negative-id context extension variables during deserialization #952

Open
kushti opened this issue Jan 24, 2024 · 0 comments
Assignees

Comments

@kushti
Copy link
Member

kushti commented Jan 24, 2024

While negative ids of context extension variables are allowed in deserializer :

// ContextExtension.serializer

val values = (0 until extSize)
          .map(_ => (r.getByte(), r.getValue().asInstanceOf[EvaluatedValue[_ <: SType]]))

negative id will cause exception during validation due to

// ErgoLikeContext.toSigmaContext

def contextVars(m: Map[Byte, AnyValue]): Coll[AnyValue] = {
      val maxKey = if (m.keys.isEmpty) 0 else m.keys.max  // TODO optimize: max takes 90% of this method
      val res = new Array[AnyValue](maxKey + 1)
      for ((id, v) <- m) {
        res(id) = v
      }
      CSigmaDslBuilder.Colls.fromArray(res)
}

Rejection tests are done in ergoplatform/ergo#2104 .

Happily, a transaction with neg-id context extension variable will be rejected on all the levels (block/mempool/block candidate generation).

Thus shaping semantics of context extension variable ids (prohibition of negative ids) can be done in deserializer in non-breaking way.

Will be done in #951

@kushti kushti self-assigned this Jan 24, 2024
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

No branches or pull requests

1 participant