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

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

Open
gitmp01 opened this issue Dec 1, 2022 · 0 comments

Comments

@gitmp01
Copy link

gitmp01 commented Dec 1, 2022

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);
                 }
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

No branches or pull requests

1 participant