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

bug: strange value for censusSize for SET_PROCESS_CENSUS transaction #62

Open
marcvelmer opened this issue Jul 11, 2024 · 7 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@marcvelmer
Copy link

marcvelmer commented Jul 11, 2024

Describe the bug
After executing a SET_PROCESS_CENSUS transaction, the value returned in the transaction seems odd. But the election info via API returns the correct value.

To Reproduce (please complete the following information)

Current behavior
It shows something like:

    "setProcess": {
      "txtype": "SET_PROCESS_CENSUS",
      "nonce": 1,
      "processId": "b31dff61814dab90d6c3a9b65d6c90830480e4b75ad32e747942020000000000",
      "censusRoot": "cd453d05c4cb0429ee5ee1aefed016f553b8026b4ced5b0c352905bfa53c7e81",
      "censusURI": "ipfs://bafybeicyfukarcryrvy5oe37ligmxwf55sbfiojori4t25wencma4ymxfa",
      "censusSize": "d74d34" // <---- this
    }

Expected behavior
Should return the 1000 value. Remember that the census size is correctly set in the election.

@marcvelmer marcvelmer added the bug Something isn't working label Jul 11, 2024
@mvdan
Copy link

mvdan commented Jul 13, 2024

I looked at the vocdoni-node code and I don't see anything that would cause a hexadecimal string or anything like that. For example, I tried creating a SET_PROCESS_CENSUS with a large CensusSize (of type uint64), and with either https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson and encoding/json I see:

PROTOJSON {"txtype":"SET_PROCESS_CENSUS", "nonce":1, "processId":"xdJGAYb3Y08T/ocL9Uji82WxbMwkGLyD0YABAAAAAAA=", "censusSize":"500000"}
JSON {"txtype":3,"nonce":1,"processId":"xdJGAYb3Y08T/ocL9Uji82WxbMwkGLyD0YABAAAAAAA=","censusSize":500000}

So I don't think it's the Go backend that's producing "d74d34".

Looking at the UI code, I see: https://github.com/vocdoni/explorer-ui/blob/bc3a0e83ea1729d161483dd154c14f1c718bb487/components/pages/envelopes/details/index.tsx#L109

        <OverflowScroll>{JSON.stringify(envelope, null, 2)}</OverflowScroll>

What eactly is the behavior of JSON.stringify, and what is envelope in there? My understanding of typescript is poor, but I think it would be of type IVoteInfoResponse, and in https://github.com/vocdoni/vocdoni-sdk/blob/3fbbe94b3f637d9004dd4f60032bb6216d6fd20f/src/api/vote.ts#L41 I don't see any censusSize field, so I'm confused.

In any case, I think it's the frontend that's encoding the JSON like that, not the backend.

@mvdan
Copy link

mvdan commented Jul 13, 2024

cc @p4u to get a second pair of eyes on this, because I don't know how the transactions and frontend work very well.

@elboletaire
Copy link
Member

Agree it has to be something with how the front is handling it... checking the API call, I clearly see a census size (in string) of 1000 here: https://api-stg.vocdoni.net/v2/chain/transactions/1176690/0

But at first sight I cannot understand how that "1000" gets then converted to "d74d34".

@elboletaire
Copy link
Member

Ok, found it: https://github.com/vocdoni/explorer/blob/main/src/components/Transactions/Detail.tsx#L28-L29

Our fault. Moving the issue to explorer, since it's a problem with how the explorer parses the transaction.

@elboletaire
Copy link
Member

There's actually a backend issue here. We were trying to do some magic because these calls do not properly return info like process id or transaction id, instead they return them encoded in base64 (due to marshaling defaults AFAIK)

Opened a new issue in node to track this: vocdoni/vocdoni-node#1354

@elboletaire
Copy link
Member

Closing this, follow-up vocdoni/vocdoni-node#1354 for updates

@elboletaire
Copy link
Member

Reopening, since it seems it's not going to be so easy to fix this in the backend.

In the meantime, we should reduce the base64 decoding just to the two fields that we found encoded: processId and censusRoot in the transactions detail call, rather than trying to decode the entire object, which is causing this issue here.

@elboletaire elboletaire reopened this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants