#When trying to use `assembleTransaction` I'm getting an `XDR Write Error: invalid u32 value` error

1 messages · Page 1 of 1 (latest)

grizzled geyser
#

I'm trying to make use of assembleTransaction by joining a simulation and an original transaction. Here's both the tx XDR and the simulation response. When trying to join them both together I'm getting error: XDR Write Error: invalid u32 value

AAAAAgAAAABnZR8W8bBF+dVfyUIrgZbB7lATRWE6iriJnbLUp5+Gsf////8AAAPfAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAGAAAAAAAAAABdM0OKEDyvwCjXBXhxEx6oTcocoEtXTmGNAXf2QpurmsAAAADcnVuAAAAAAQAAAADAAAAAQAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAA==
{
  transactionData: "AAAAAAAAAAIAAAAGAAAAAXTNDihA8r8Ao1wV4cRMeqE3KHKBLV05hjQF39kKbq5rAAAAFAAAAAEAAAAHsaQiG9oRqgn2LcBOUPgIf4Qc6ZP4cLS01umYovFVNGcAAAAAADxREAAABFAAAAAAAAAAAAAAuIM=",
  minResourceFee: "47235",
  events: [ "AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgdM0OKEDyvwCjXBXhxEx6oTcocoEtXTmGNAXf2QpurmsAAAAPAAAAA3J1bgAAAAAQAAAAAQAAAAQAAAADAAAAAQAAAAEAAAABAAAAAQ==",
    "AAAAAQAAAAAAAAABdM0OKEDyvwCjXBXhxEx6oTcocoEtXTmGNAXf2QpurmsAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAADcnVuAAAAAAE="
  ],
  results: [
    {
      auth: [],
      xdr: "AAAAAQ==",
    }
  ],
  cost: {
    cpuInsns: "952912",
    memBytes: "1231270",
  },
  latestLedger: 1828,
}

Here's the specific error

622 | /* harmony export */   XdrReaderError: () => (/* binding */ XdrReaderError),
623 | /* harmony export */   XdrWriterError: () => (/* binding */ XdrWriterError)
624 | /* harmony export */ });
625 | class XdrWriterError extends TypeError {
626 |   constructor(message) {
627 |     super(`XDR Write Error: ${message}`);
          ^
error: XDR Write Error: invalid u32 value
      at new XdrWriterError (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/js-xdr/lib/xdr.js:627:5)
      at write (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/js-xdr/lib/xdr.js:1922:108)
      at write (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/js-xdr/lib/xdr.js:1580:7)
      at write (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/js-xdr/lib/xdr.js:1780:5)
      at write (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/js-xdr/lib/xdr.js:1580:7)
      at toXDR (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/js-xdr/lib/xdr.js:2160:5)
      at signatureBase (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/stellar-base/lib/transaction.js:293:14)
      at hash (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/stellar-base/lib/transaction_base.js:224:33)
      at sign (/Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/node_modules/@stellar/stellar-base/lib/transaction_base.js:88:20)
      at /Users/tylervanderhoeven/Desktop/Web/Soroban/soroban-i-like-big-budgets/index_1.ts:77:5
#

cc @somber viper

#

I know what I hath done. I set my fee to the absolute max and then assembleTransaction tried to add the minResourceFee on top of it...which broke assembleTransaction. Easily reproducible by setting

const simTx = new TransactionBuilder(source, {
    fee: (2 ** 32 - 1).toString(),
    networkPassphrase
})
#

Lowering this to ensure the final fee is <= 2 ** 32 - 1 solves my issue

#

It is a bummer we don't have a setFee option here. setNetworkPassphrase but no setFee. Sad

nova scarab
#

It's also fair to argue that the fee being internally modified is surprising. I understand why it does it, but this isn't the first time that internal things designed to help produce a valid transaction have caused problems.

grizzled geyser
#

I agree assembleTransaction shouldn’t on its own build an invalid tx but I’d also argue “modifying the tx internally” is the whole point of this method. I’d rather have it throw a meaningful error. “min resource fee + tx fee is out out bounds for a u32”

#

Imo setting a fee before you set the resource fee is an anti pattern. You should set the fee to 0, simulate, modify soroban data as needed, assemble the tx, then modify the tx fee as needed. The more stuff you send along with your simulation the more room for whoopsies you have when using assembleTransaction later

#

Not having a setFee method makes this less doable

frank kite
#

Hey guys, I met the similar error with u32 fees but from cli side.
I tried to install a big wasm (61 kb) and got overflow in "min resource fee + tx fee". The value was 4946582915 or 494.6582915 XLM. Looks like it's xdr limitation https://github.com/stellar/stellar-xdr/blob/curr/Stellar-transaction.x#L879
How can I install such a "large" contract in the mainnet or testnet? I thought I might need to write a custom js deployer, but then I realized that has to do with xdr. Btw there is an issue in soroban-rpc repository: https://github.com/stellar/soroban-rpc/issues/103

GitHub

What version are you using? v20.3.3 What did you do? With soroban 20.3.1 I tried to call soroban contract install with a 61 kb wasm in testnet and got error: Fee was too large 4946582915. After som...

GitHub

Staging area for future version of Stellar XDR. Contribute to stellar/stellar-xdr development by creating an account on GitHub.

obsidian skiff
#

in protocol 20 there is no way to have resource fee that exceeds u32::MAX-100. but it's surprising to me that you've reached such a high fee; is that testnet?

#

we probably will just lower the write fees on the testnet for the time being; they're not representative of the mainnet fees anyway