-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Enhancement: Add decoding of multicalls to @truffle/decoder
#4955
Conversation
I'm leaning towards thinking it should be required and empty when there's nothing. This way it will be in front of people's faces when they integrate the format... if it's optional, it feels a bit too surprise-y when it does show up. But I could be convinced otherwise.
Hm, we could make it Alternatively... maybe we should treat it as a bad interpretation altogether, and indicate the error in the interpretation itself... like All of these sound kinda clunky, though. Maybe errors won't be so common and we can just stick with your "or null"... not sure. |
OK, I've made it required. |
Yeah, the problem with this is that our error system is set up for reporting errors in decoding of particular variables, not of transactions as a whole. So we'd either have to mash together different systems that weren't meant to be used that way (something you've objected to in the past before and which I would definitely object to here), or make a whole new system for this, and it just doesn't seem worth it.
Yeah errors occuring in that particular context should be pretty rare. I think most decoding problems would result in All this still leaves the question though @gnidan: Should I have the inspector do just that, to handle such errors better? |
Additional point: my recent Solidity Summit demo featured this PR's behavior prominently, and in doing so I realized a gap in what this supports... namely:
I did some hacking to add these in this commit, but the variety of forms here suggests to me that we want to handle the differences more robustly. (Is it possible to be less strict when detecting? Like can we say "use the interpretation if it looks like it might be a multicall?" I'm guessing this is hard) |
I mean, these could just be different interpretations and we could update it as need be...? :-/ Yeah I dunno I don't really have a better idea offhand.
Yeah I don't really have any idea how that would work. |
OK, I've added the additional multicall interpretations (together with tests for most of them and updates to the inspector). Notes on these:
So uh yeah hope this is good? |
This is probably worth doing, but if you want to open an issue for it, I don't think it needs to be this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I think the additional interpretation is probably the right call. Thank you!
Addresses #4133. This PR adds
interpretations
to decodings returned by@truffle/decoder
, with one interpretation currently existing: multicall.This is mostly pretty straightforward -- the decoder, after decoding a transaction, will check whether it's a multicall (as in: name
multicall
, arguments a singlebytes[]
), and, if it is, will then recurse over the subcalls and decode them, sticking the result ininterpretations.multicall
. There's not much to say about the logic here! I also added a test of this functionality.I also updated
CalldataDecodingInspector
so that it will check forinterpretations.multicall
, and, if it finds it present, print out the the calls made rather than the raw bytestrings for each entry. In the process I found that the existing logic forformatFunctionLike
wasn't really working like I wanted so I fixed that up a bit too.Really, the thing on this PR that really needs looking over is the types. Here are the questions I have for @gnidan:
interpretations
optional, and only included it when there's something to put in there. Is this right? Should it be required? (Note that if we make it required, and then later also make it required on individual values when we do reverse ENS resolution, I'm going to have to go updating all the wrap functions... not that that'd actually be hard, just annoying, but...)multicall
is notCalldataDecoding[]
, but rather(CalldataDecoding | null)[]
. This is because, what if one of the individualbytes
decodes to an error? Yeah, that shouldn't normally happen, but, like, we should be prepared for the possibility. I realize this isn't ideal but I couldn't think of a better way of handling this. Like, if you want the actual error, you can always look inarguments
! In the inspector, I just had thesenull
s turn into a "could not decode" message... should I perhaps have it actually look inarguments
so I can have it display the actual error message in case of an error?But yeah, mostly nothing complicated here!