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

The returned data from Ogmios TX evaluation is not bubbled up #34

Closed
arjaz opened this issue Jun 28, 2024 · 6 comments · Fixed by #40
Closed

The returned data from Ogmios TX evaluation is not bubbled up #34

arjaz opened this issue Jun 28, 2024 · 6 comments · Fixed by #40

Comments

@arjaz
Copy link

arjaz commented Jun 28, 2024

No description provided.

@caike
Copy link
Member

caike commented Jul 1, 2024

Could you provide the code you are using ?

Xogmios returns all data it receives from Ogmios. For example, take the following tx CBOR from preview testnet:

cbor = "84a80082825820232c8e27c806a0eea8049a6b8217f4325a7348f38ed4913e7adb9d127261fe6d00825820232c8e27c806a0eea8049a6b8217f4325a7348f38ed4913e7adb9d127261fe6d030181825839006bd95fcacb2373d68ae094fdefcc4811358e11ca0306a9f4b3bcbbe866499a2e015b6b02a783f0c5c8af0a9506a648725c951f8d4e2ecbc61a6e2cf031021a0002ae820b5820d9f3a918ad71f3416d150c3cc2224c4d4e371abcd02afb699b94cf45e8748e340d81825820232c8e27c806a0eea8049a6b8217f4325a7348f38ed4913e7adb9d127261fe6d0310825839006bd95fcacb2373d68ae094fdefcc4811358e11ca0306a9f4b3bcbbe866499a2e015b6b02a783f0c5c8af0a9506a648725c951f8d4e2ecbc61a6dfdd230111a000405c31281825820232c8e27c806a0eea8049a6b8217f4325a7348f38ed4913e7adb9d127261fe6d01a300818258205bb407d6f3a428c1102b0daf423b093a2e0cbf51517c30e63f2f003d06dd763a5840472a7b08e6400601f4bb2d596b0b0fc9b8113e06f45a7d8b7235e670b81acd20b20017e7c9c0f6a5da5e5f213b51213e02cab57174bbe5194dd6b663e59f5a03049fd87980ff0581840000d879808219044c1a000382d4f5f6"
ex(2)> XomgiosClient.TxSubmissionClient.evaluate_tx(cbor)
{:ok,
 [
   %{
     "budget" => %{"cpu" => 230100, "memory" => 1100},
     "validator" => %{"index" => 0, "purpose" => "spend"}
   }
 ]}

And this is the code for the client module:

defmodule XomgiosClient.TxSubmissionClient do
 use Xogmios, :tx_submission
 alias Xogmios.TxSubmission

 def start_link(opts) do
   Xogmios.start_tx_submission_link(__MODULE__, opts)
 end

 def submit_tx(pid \\ __MODULE__, cbor) do
   TxSubmission.submit_tx(pid, cbor)
 end

 def evaluate_tx(pid \\ __MODULE__, raw_tx_cbor) do
   TxSubmission.evaluate_tx(pid, raw_tx_cbor)
 end
end

@caike
Copy link
Member

caike commented Jul 12, 2024

Closing this for now but let me know if the issue persists.

@caike caike closed this as completed Jul 12, 2024
@arjaz
Copy link
Author

arjaz commented Aug 28, 2024

Hi, sorry for not responding here for a long time. I can't really provide a full example because of NDA reasons, but here's a relevant part of a log I get:

** (CaseClauseError) no case clause matching: {:error, "The transaction failed because the provided script integrity hash doesn't match the computed one. This is crucial for ensuring the integrity of cost models and Plutus version used during script execution. The field 'data.providedScriptIntegrity' correspond to what was given, if any, and 'data.computedScriptIntegrity' is what was expected. If the latter is null, this means you shouldn't have included a script integrity hash to begin with."}

What I have for the submission client is pretty much what you have, but I case this thing only surfaces on error, not on valid submissions.

@caike caike reopened this Aug 29, 2024
@caike
Copy link
Member

caike commented Sep 2, 2024

Hi, sorry for not responding here for a long time. I can't really provide a full example because of NDA reasons, but here's a relevant part of a log I get:

** (CaseClauseError) no case clause matching: {:error, "The transaction failed because the provided script integrity hash doesn't match the computed one. This is crucial for ensuring the integrity of cost models and Plutus version used during script execution. The field 'data.providedScriptIntegrity' correspond to what was given, if any, and 'data.computedScriptIntegrity' is what was expected. If the latter is null, this means you shouldn't have included a script integrity hash to begin with."}

What I have for the submission client is pretty much what you have, but I case this thing only surfaces on error, not on valid submissions.

It appears this error is coming from the code that's calling Xogmios which might not have a proper clause matching the :error tuple that's being returned. The underlying code simply returns anything that is not an :ok tuple:

def submit_tx(client \\ __MODULE__, cbor) do
  with {:ok, message} <- build_submit_message(cbor),
       {:ok, %Response{} = response} <- call(client, message) do
    {:ok, response.result}
  end
  # No explicit else block here so anything that is not an :ok tuple is returned
end

I double checked this by providing an invalid cbor, and I'm getting the following:

iex(1)> Tx.evaluate_tx(invalid_cbor)
{:error,
 "Invalid transaction; It looks like the given transaction wasn't well-formed. Note that I try to decode the transaction in every possible era and it was malformed in ALL eras. Yet, I can't pinpoint the exact issue for I do not know in which era / format you intended the transaction to be. The 'data' field, therefore, contains errors for each era."}

If you are able to provide a snippet of the Elixir code that is calling TxSubmission.submit_tx/2 then I might be able to help dig this further.

@arjaz
Copy link
Author

arjaz commented Sep 3, 2024

You get the same thing in your example with The 'data' field, therefore, contains errors for each era. This data isn't bubbled up from wherever it's accessible.

@caike
Copy link
Member

caike commented Sep 4, 2024

Should be fixed on the most recent release https://github.com/wowica/xogmios/releases/tag/v0.5.1

iex(1)> Tx.evaluate_tx(invalid_cbor)
{:error,
 %{
   "code" => -32602,
   "data" => %{
     "allegra" => "invalid or incomplete value of type 'Transaction': Size mismatch when decoding Object / Array. Expected 4, but found 3.",
     "alonzo" => "invalid or incomplete value of type 'Transaction': An error occured while decoding Not a valid key:. 16",
     "babbage" => "invalid or incomplete value of type 'Transaction': Failed to decode AuxiliaryData",
     "conway" => "invalid or incomplete value of type 'Transaction': Failed to decode AuxiliaryData",
     "mary" => "invalid or incomplete value of type 'Transaction': Size mismatch when decoding Object / Array. Expected 4, but found 3.",
     "shelley" => "invalid or incomplete value of type 'Transaction': Size mismatch when decoding Object / Array. Expected 4, but found 3."
   },
   "message" => "Invalid transaction; It looks like the given transaction wasn't well-formed. Note that I try to decode the transaction in every possible era and it was malformed in ALL eras. Yet, I can't pinpoint the exact issue for I do not know in which era / format you intended the transaction to be. The 'data' field, therefore, contains errors for each era."
 }}

Thank you for reporting the issue 💚

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 a pull request may close this issue.

2 participants