Skip to content

Incorrect msgpack decoding on global state delta values #724

@barnjamin

Description

@barnjamin

Subject of the issue

When requesting a Block from algod and decoding each transaction, the global state deltas of the apply_delta.eval_delta contain incorrect data.

using

   const block = await client.block(block_number).do();
   // ...
  block.block.txns.forEach((t) => {
    if ("dt" in t) {
      if ("gd" in t["dt"]) {
        for (const k of Object.keys(t["dt"]["gd"])) {
          console.log(t["dt"]["gd"][k]);
        }
      }
    }
  });

logs a string like

'Ibf\x88³\x13|ù򦞴GÁ֨쌥g\x00װ§࠲\x93ش\x00\x00\x00\x00\x01᫰\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.Y«A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ÿÿþ°ݠ\x8Fက\x01O"\x9Fp\x1E\x00\x00\x03^\x04쪅\x00\x00\x00\x92I\x7Fû\x8A\x00\x00\x00\x05ő\x04뀀\x00\x01¾(\x05 \x00\x00\x00\x01

but expecting

'Ibf\x88\xb3\x13|\xf9\xf6&\x9e\xf4G\xc3\x81\xe0\x96(\xec\xcc\xa5g\x00\xd7\xf0\xa7\xe0\xe0\xf2\x93\xd8t\x00\x00\x00\x00\x01\xe1\xabp\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00.Y\xabA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xfe\xb0\xdd`\x8f\xe1\x00\x00\x01O"\x9fp\x1e\x00\x00\x03^\x04\xec\xea\x05\x00\x00\x00\x92I\x7f\xfb\x8a\x00\x00\x00\x05\xc5\x11\x04\xeb\x00\x00\x00\x01\xbe(\x05\xe2\x00\x00\x00\x00\x00\x00'

This seems to be happing in the msgpack.decode call since even with the raw bytes read from disk the same result appears.

Using msgpack-lite locally and setting the codec useraw field, the data is decoded correctly:

   let rawBlock = await client.block(block_number).doRaw();
   const block = mpk.decode(rawBlock, {
     codec: mpk.createCodec({ useraw: true }),
   }) as Record<string, any>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions