Skip to content

hex_data returned by hyperion has the wrong padding hence returning the wrong action receipt #133

@gitmp01

Description

@gitmp01

Hello,
we've checked out v3.3.7-2 and it seems the hex_data field in the action is mismatching the one in the explorer, here's an example:

this action can be found here under the path execution_trace.action_traces.inline_traces[2]:

"act": {
    "account": "xbsc.ptokens",
    "name": "pegin",
    "authorization": [
       {
            "actor": "xbsc.ptokens",
            "permission": "active"
        }
    ],
    "data": {
        "destinationAddr": "0xb713C9ce8655D0D98BBcD6AB9b77B4769d28d722",
        "quantity": "350.0000 EFX",
        "sender": "kucoinrise11",
        "tokenContract": "effecttokens",
        "userData": ""
    },
    "hex_data": "1082c2ee4e47918680a7823467a4d652e06735000000000004454658000000002a30786237313343396365383635354430443938424263443641423962373742343736396432386437323200000000"
}

while from our hyperion-api we get this one for the same action

{
  "account": "xbsc.ptokens",
  "name": "pegin",
  "authorization": [
    {
      "actor": "xbsc.ptokens",
      "permission": "active"
    }
  ],
  "data": {
    "sender": "kucoinrise11",
    "tokenContract": "effecttokens",
    "quantity": "350.0000 EFX",
    "destinationAddr": "0xb713C9ce8655D0D98BBcD6AB9b77B4769d28d722",
    "userData": ""
  },
  "hex_data": "1082C2EE4E47918680A7823467A4D652E06735000000000004454658000000002A30786237313343396365383635354430443938424263443641423962373742343736396432386437323200",
  "global_sequence": 357286554079
}

you can clearly see that the padding is wrong.

This patch has temporary solved the issue for us, but it's not robust for obvious reasons:

diff --git a/api/routes/v1-history/get_actions/get_actions.ts b/api/routes/v1-history/get_actions/get_actions.ts
index 39e32a9..81a92d9 100644
--- a/api/routes/v1-history/get_actions/get_actions.ts
+++ b/api/routes/v1-history/get_actions/get_actions.ts
@@ -336,6 +336,14 @@ async function getActions(fastify: FastifyInstance, request: FastifyRequest) {
                         txEnc,
                         txDec
                     );
+                   // We noticed that pegin action needs the hex_data
+                   // field padded to 158/2 bytes, hence this fix,
+                   // redeem actions are not affected by this problem
+                  let tmp = action.act.hex_data;
+                   if (action.act.name === "pegin") {
+                       action.act.hex_data = tmp.padEnd(158, '0')
+                   }
+
                 } catch (e: any) {
                     console.log(e);
                 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions