Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Conversation

@Fang-
Copy link
Contributor

@Fang- Fang- commented Mar 6, 2019

Because +cat doesn't care to left-shift if you append a zero value.

Previously:

> (decode-topics:rpc:ethereum ~[0x0 0x1] ~[%uint %uint])
[0 1]
> (decode-topics:rpc:ethereum ~[0x1 0x0] ~[%uint %uint])
[0 1]

Now:

> (decode-topics:rpc:ethereum ~[0x0 0x1] ~[%uint %uint])
[0 1]
> (decode-topics:rpc:ethereum ~[0x1 0x0] ~[%uint %uint])
[1 0]

Copy link
Contributor

@philipcmonk philipcmonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, don't use (cat a b c) if you want (add b (lsh a 1 c))!

@ohAitch
Copy link
Contributor

ohAitch commented Mar 7, 2019 via email

@philipcmonk
Copy link
Contributor

Ah, yes, ++can is better.

@ohAitch
Copy link
Contributor

ohAitch commented Mar 7, 2019

Or actually ++rep, if they're all just lsh 1?

I'm also somewhat confused what the surrounding code is doing: is render-hex-bytes literally just uncurried x-co:co? In that case, it's taking a list of @uxI(uint256), printing each as a tape of hex characters, concatenating the tapes, converting the concatenated into a cord of hex characters, splitting the cord into chunks 64 chars long, and then parsing the chunks back from hex into a tuple of the exact same numbers??

@ohAitch
Copy link
Contributor

ohAitch commented Mar 7, 2019

Yeah it looks like every single call to decode-topics accepts ~[%uint], ~[%uint %uint], or ~[%uint %address] where %address is an alias for %uint. While I'm all for future compatibility, I feel like in this case it would be reasonable to remove the function in question entirely and replace it with a series of length checks: ?> ?=([who=@ wer=address ~] topics.log) and similar.

(I'm also not sure why azimuth-events is a core instead of a (map @uxI term) which you could apply to event.log once and then idiomatically ?-. Or well, not literally term, %- my :~ result so that you can actually catch typoed(as currently) or unhandled(but known) event types)

@ohAitch
Copy link
Contributor

ohAitch commented Mar 7, 2019

…why is the compiler allowing lone terms in a $% o.o https://github.com/urbit/arvo/blob/master/sys/zuse.hoon#L7608-L7617
(I think the rune you technically want here is $?, possibly with a $@ split to $% tho tbh giving the commented static/dynamic precedence makes sense)

Don't encode it like you do %bytes-n, which limits length to 32 bytes.
@Fang-
Copy link
Contributor Author

Fang- commented Mar 7, 2019

I completely forgot about rep. Serious tunnel-vision going on here.

Thanks for the feedback @ohAitch! I have touched up the logic here to not do superfluous @t <--> (list @) conversions.

Found an issue in the encoding logic while I was trying to test my changes there. We probably want more thorough tests for encoding, and tests at all for decoding. Official test data (which the current tests are sourced from) don't reach further than simple cases. Currently have a Q out to Ethereum core devs for recommended test data, but if that comes up blank, I might just pull in these.

Tests aside, this PR is ready for re-review.
(Edit: Actually ready now.)

@Fang- Fang- requested a review from philipcmonk March 7, 2019 23:59
++decode-arguments now takes already-parsed words, rather than a @t of
words, so that we operate on straight atom values instead of hex
strings.
For the ++decode-topics case, we no longer re-string and un-string the
input data prior to processing.
@Fang- Fang- force-pushed the topics-decoding-patch branch from ad5f8f4 to 84f3441 Compare March 8, 2019 00:28
Copy link
Contributor

@philipcmonk philipcmonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to review because of the nature of parsing, so unit tests are the best way to verify correctness, but this looks correct.

@Fang-
Copy link
Contributor Author

Fang- commented Mar 16, 2019

I keep forgetting to write additional tests for this. I'll put that on my task-list, but merge for now, to at least get the fix in.

@Fang- Fang- merged commit 2092ee3 into next Mar 16, 2019
@Fang- Fang- deleted the topics-decoding-patch branch March 16, 2019 14:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants