fix(wallet): send tx instruction as a byte string, not QVariantList<u32>

LogosWalletProvider::submitPublicTransaction passed the RISC0 instruction
words to send_generic_public_transaction as a QVariantList<u32>. That param
is a byte string (bstr): the module's QtRO glue mangles a list-of-u32 crossing
the module process boundary, so the guest deserialized a corrupted Instruction
variant and panicked, e.g.

  Guest panicked: called `Result::unwrap()` on an `Err` value:
  Custom("invalid value: integer `53765`, expected variant index 0 <= i < 10")

(53765 = 0x0000D205 — the guest read a 4-byte word where 0x05, the AddLiquidity
variant, is a single byte.) This broke every submit through the shared provider,
including the new-position / add-liquidity flow.

Send the little-endian bytes of the u32 words as a QByteArray instead — the same
encoding the AMM swap path already uses (it calls the module directly and never
went through this provider). signingRequirements stays a QVariantList<bool>;
only the instruction needed the bstr encoding.
This commit is contained in:
r4bbit 2026-07-24 18:11:17 +02:00
parent 44b355ac7d
commit 34c6c5e821
No known key found for this signature in database
GPG Key ID: E95F1E9447DC91A9

View File

@ -1,5 +1,6 @@
#include "LogosWalletProvider.h"
#include <QByteArray>
#include <QDir>
#include <QFileInfo>
#include <QJsonDocument>
@ -274,16 +275,26 @@ WalletSubmission LogosWalletProvider::submitPublicTransaction(
for (bool required : transaction.signingRequirements)
signingRequirements.append(required);
QVariantList instruction;
instruction.reserve(transaction.instruction.size());
for (quint32 word : transaction.instruction)
instruction.append(word);
// `send_generic_public_transaction`'s `instruction` param is a byte string
// (bstr). Passing a QVariantList<u32> makes the module's QtRO glue mangle it,
// so the guest reads a garbage Instruction variant. Send the little-endian
// bytes of the u32 words instead — same encoding the AMM swap path uses.
// See docs/amm-swap-qtro-serialization-bug.md.
QByteArray instructionBytes;
instructionBytes.reserve(
static_cast<int>(transaction.instruction.size() * sizeof(quint32)));
for (const quint32 word : transaction.instruction) {
instructionBytes.append(static_cast<char>(word & 0xff));
instructionBytes.append(static_cast<char>((word >> 8) & 0xff));
instructionBytes.append(static_cast<char>((word >> 16) & 0xff));
instructionBytes.append(static_cast<char>((word >> 24) & 0xff));
}
const QString response =
m_impl->logos->logos_execution_zone.send_generic_public_transaction(
transaction.accountIds,
signingRequirements,
QVariant::fromValue(instruction),
QVariant::fromValue(instructionBytes),
transaction.programId);
QJsonParseError parseError;