Offline evaluator to use in NewmChainService#701
Offline evaluator to use in NewmChainService#701sae3023 wants to merge 7 commits intoprojectNEWM:masterfrom
NewmChainService#701Conversation
| .from(scalaSeq) | ||
| } | ||
|
|
||
| private fun hexToByteArray(hex: String): ByteArray = hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray() |
There was a problem hiding this comment.
Remove helper function in favor of String.hexToByteArray() extension function in io.newm.chain.util.CardanoKtx
| * @param utxos All UTxOs needed for evaluation (source + reference inputs) | ||
| * @param config The configuration object containing network information | ||
| */ | ||
| fun evaluateTx( |
There was a problem hiding this comment.
Where do the plutus cost models come into play here? Are they hardcoded somewhere in CardanoInfo? If so, this seems brittle and we should get the plutus cost model from the blockchain instead.
There was a problem hiding this comment.
Indeed, the CostModels are in ProtocolParameters, which are in CardanoInfo.
The evaluator itself needs only the slot config, the major protocol version and the cost models, so if the following signature is fine:
fun evaluateTx(
cborBytes: ByteArray,
utxos: Set<Utxo>,
slotConfig: SlotConfig,
costModels: CostModels
)Both of these types seem to be very straightforward to map to Scalus ledger types
There was a problem hiding this comment.
if this looks fine, I'd appreciate a hint of where these types are described in newm, and I'll ping you when I fix the function
There was a problem hiding this comment.
@sae3023 In TransactionBuilder.kt, it is constructed with a protocolParametersResult. Inside this structure is the plutusCostModels. All of this data currently comes from Ogmios through Kogmios which is our Ogmios gRPC wrapper in Kotlin. We're not trying to entirely eliminate Ogmios with this fix, just utilize Scalus where it makes sense for efficiency.
|
@AndrewWestberg PTAL I did the cost models, but I'm not entirely sure about the casts, doesn't look like it's the best way to do it, but I've sort of threw it together quickly. I'll take another look in the morning too. |
| RedeemerTag.valueOf("Cert") -> "certificate" | ||
| RedeemerTag.valueOf("Reward") -> "withdrawal" | ||
| RedeemerTag.valueOf("Voting") -> "vote" | ||
| RedeemerTag.valueOf("Proposing") -> "propose" |
There was a problem hiding this comment.
Is RedeemerTag an enum and RedeemerTag.valueOf() returns the value? If so, we should use the enum values directly here in the left side. Example:
RedeemerTag.Spend -> "spend"
There was a problem hiding this comment.
done, lmk if there's anything else I can do
# Conflicts: # buildSrc/src/main/kotlin/Versions.kt
|
@sae3023 Please run Also run |
45dd63b to
05a919c
Compare
|
@AndrewWestberg please take another look |
|
Hello again! I can see that the tests are failing, however, I feel a little out of my depth trying to investigate and fix it. Is there any chance you can take a look at the remaining errors and the root cause? |
There's a FIXME in
NewmChainServiceabout using something that would allow you to omit Ogmois.Scalus contains an offline Plutus script evaluator, and this commit in my fork adds a tiny integration of the evaluator to newm-server.
Glad to ask any questions or to help with further integration.