#ContextExtension
1 messages · Page 1 of 1 (latest)
I don't think ContextExtension is exposed in the playground API. I tried to make as simple as possible.
I tried working around the playground API limitations by creating a tx through the API and then remaking it with my custom bindings like:
val initTx = Transaction(
// tx details...
)
val initTxWithExt = new UnsignedErgoLikeTransaction(
initTx.inputs.map(i => new UnsignedInput(i.boxId, i.extension.copy(bindings.toMap))),
initTx.dataInputs,
initTx.outputCandidates
)
but then when I send the tx to the mock blockchain I get this:
[error] java.lang.IllegalArgumentException: requirement failed: box (index 0) verification failed (cost 10151)
[error] at scala.Predef$.require(Predef.scala:281)
[error] at org.ergoplatform.playgroundenv.utils.TransactionVerifier$.$anonfun$verify$1(TransactionVerifier.scala:53)
[error] at org.ergoplatform.playgroundenv.utils.TransactionVerifier$.$anonfun$verify$1$adapted(TransactionVerifier.scala:33)
in the verifier.
Is that because of playground limitations as well?
Tx verifier honor context extension - https://github.com/ergoplatform/ergo-playgrounds/blob/03a6e776be652cd5cd68a32c47236c6fe63b0487/playground-env/src/main/scala/org/ergoplatform/playgroundenv/utils/TransactionVerifier.scala#L46
What's the script in that input box? Maybe it fails for another reason (not context extension).
At this point I am just setting "true" as the contract. I hacked it down just to the essentials:
val blockchainSim = newBlockChainSimulationScenario("mockchain")
val party = blockchainSim.newParty("party")
party.generateUnspentBoxes(toSpend = 800000000)
val contract = "true"
val bindings = Map(
1.toByte -> Values.IntConstant(10),
)
val initTx_ = Transaction(
inputs = party.selectUnspentBoxes(toSpend = 100000000),
outputs = List(Box(value = 100000000, script = ErgoScriptCompiler.compile(scriptEnv, contract))),
fee = MinTxFee,
sendChangeTo = party.wallet.getAddress
)
val initTx = new UnsignedErgoLikeTransaction(
initTx_.inputs.map(i => new UnsignedInput(i.boxId, i.extension.add(bindings.toMap.toArray:_*))),
initTx_.dataInputs,
initTx_.outputCandidates
)
blockchainSim.send(party.wallet.sign(initTx))
It works if I comment out 1.toByte -> Values.IntConstant(10), but when I leave it in I get the requirement failed: box (index 0) verification failed (cost 10151) error.
I think the cause is the prover in wallet.sign ignores and removes the context extensions, but the signed message is a serialized tx with context extensions. The ergo-playgrounds uses an old appkit version where context extensions are ignored in the prover. Thus, producing invalid proofs, which the verifier fails to verify. I tried to update the appkit version, but it breaks the build, probably due to way too different sigmastate-interpreter versions used in ergo-script-compiler and appkit.
I made https://github.com/ergoplatform/ergo-playgrounds/issues/27 but I'm knee-deep in oracle v2 and sigma-rust now so I'm not sure when I'll be able to take care of it. Feel free to take a look at it if you're interested. I'll be happy to help.
See #1042839384698925106 message Updating appkit breaks the build, probably because of too many differences in the sigmastate version in a...
I tried to upgrade to a few different version combinations of app-kit / ergo-scala-compiler / sigmastate but they all produced crazy lowlevel runtime exceptions. 🥹