Skip to content

Issue when using Assembly Scripts splice() #603

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

Closed
davekay100 opened this issue Nov 27, 2018 · 5 comments
Closed

Issue when using Assembly Scripts splice() #603

davekay100 opened this issue Nov 27, 2018 · 5 comments

Comments

@davekay100
Copy link
Contributor

Do you want to request a feature or report a bug?
bug

What is the current behavior?
I use assembly scripts .indexOf() to find the item I want to delete out of an array. Then I splice that element out of the array. It works most of the time, but it fails sometimes, see this if statement specifically for a case that fails in the aragon subgraph.

The token manager permission is failing to splice out certain elements. It might even be duplicating an element while removing another (but I'm not totally sure), as seen in the highlighted part in this query:
screen shot 2018-11-26 at 9 26 08 pm

Now if we look at the Aragon Dapp, these are the only available permissions:
screen shot 2018-11-26 at 9 27 41 pm

Our store has two extra 0x012 and an extra 0x18f. Also the CanBurn role has an extra 0xfffffff.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

To reproduce it, run the aragon subgraph from the repo https://github.com/graphprotocol/aragon-subgraph. Then compare it to the dapp here https://rinkeby.aragon.org/#/dude.aragonid.eth/permissions?params=app.0x9294b6165da858e3c9576a9b49050e02eb0ec365

What is the expected behavior?

The .splice() from assembly script should be consistent and work in all cases. It could be that I have implemented it wrong or my algorithm is messed up, and I am hoping if that is the case someone can point it out!

But the thing is, assembly script only tests splice() once, and with an extremely simple example, so I think it is possible my implementation is hitting an edge case.

It is either I have screwed it up or assembly script has a bug. Either way we need to fix it. Also, if anyone has some other ideas on how to delete an item out an array, let me know! (in case splice is buggy)

@davekay100
Copy link
Contributor Author

@MaxGraey
Copy link

Try latest master. This issue should be fixed

@Jannis
Copy link
Contributor

Jannis commented Nov 30, 2018

@MaxGraey That's great to hear, we'll give it a spin!

@davekay100
Copy link
Contributor Author

I started getting into it, but our graph typescript library is tied to an older version of AssemblyScript, from months ago. When upgrading to the new AssemblyScript, we get a some compiling errors. So we are going to have to dig into this a bit before we can test out the newest fix on master

@davekay100
Copy link
Contributor Author

@MaxGraey I can confirm it works now, thanks for fixing it!

For our reference, see here graphprotocol/aragon-subgraph@d41289c , the splicing functions now works as intended. Closing

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

3 participants