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

[v6.0] Accumulate ErgoTree deserialization cost #938

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/shared/src/main/scala/sigma/VersionContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object VersionContext {
* - in 6.x must be 3
* etc.
*/
val MaxSupportedScriptVersion: Byte = 2 // supported versions 0, 1, 2
val MaxSupportedScriptVersion: Byte = 3 // supported versions 0, 1, 2, 3

/** The first version of ErgoTree starting from which the JIT costing interpreter must be used.
* It must also be used for all subsequent versions (3, 4, etc).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ trait Interpreter {
val currCost = Evaluation.addCostChecked(context.initCost, deserializeSubstitutionCost, context.costLimit)
val context1 = context.withInitCost(currCost).asInstanceOf[CTX]
val (propTree, context2) = trySoftForkable[(SigmaPropValue, CTX)](whenSoftFork = (TrueSigmaProp, context1)) {
applyDeserializeContextJITC(context, prop)
// Before ErgoTree V3 the deserialization cost was not added to the total cost
applyDeserializeContextJITC(if (VersionContext.current.activatedVersion >= 3) {
SethDusek marked this conversation as resolved.
Show resolved Hide resolved
context1
} else {
context
}, prop)
}

// here we assume that when `propTree` is TrueProp then `reduceToCrypto` always succeeds
Expand Down Expand Up @@ -593,4 +598,4 @@ object Interpreter {
/** Helper method to throw errors from Interpreter. */
def error(msg: String) = throw new InterpreterException(msg)

}
}
Loading
Loading