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

Fix topic_list parameter implementation (matching and validation) to align with JSON-RPC spec #118

Merged
merged 4 commits into from
Aug 2, 2018

Conversation

dylanjw
Copy link
Contributor

@dylanjw dylanjw commented Jul 31, 2018

What was wrong?

Validators disallow topics lists such as:
[TOPICA, [TOPICB, TOPICC], TOPICD]

EDIT: fixes #119

How was it fixed?

The topic validators were extended to check the validity of single items along with flat topic arrays.

Cute Animal Picture

image

dylanjw added 2 commits July 31, 2018 12:05
Validators disallow topics lists such as:
[TOPICA, [TOPICB, TOPICC], TOPICD] which are both
common and valid
@dylanjw dylanjw force-pushed the fix-topic-validators branch from c6faf53 to 967965a Compare July 31, 2018 19:54
@dylanjw dylanjw changed the title Extend topic validator to allow single + topic arrays to coincide Fix topic_list parameter implementation (matching and validation) to align with JSON-RPC spec Jul 31, 2018
@dylanjw dylanjw force-pushed the fix-topic-validators branch from 4ed8e53 to 48a097f Compare July 31, 2018 22:29
Topics with nested arrays should be interpreted as
positional options.  The match function was updated
to reflect the topic argument spec
@dylanjw dylanjw force-pushed the fix-topic-validators branch from 48a097f to c382a16 Compare July 31, 2018 22:31
@dylanjw dylanjw force-pushed the fix-topic-validators branch from c382a16 to 0392b0c Compare July 31, 2018 22:46
Copy link
Contributor

@carver carver left a comment

Choose a reason for hiding this comment

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

I'm on mobile, but nothing jumps out as problematic. I'm just trusting you that all the new test cases are correct. :) Happy to see this get fixed!

(TOPICS_B_C, FILTER_MATCH_ONLY_A, False),
(TOPICS_B_A_C, FILTER_MATCH_ONLY_A, False),
(TOPICS_B_C_A, FILTER_MATCH_ONLY_A, False),
(TOPICS_EMPTY, FILTER_MATCH_ONE_OR_MORE, False),
Copy link
Contributor Author

@dylanjw dylanjw Aug 1, 2018

Choose a reason for hiding this comment

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

This one im not sure on. Intuitively I would think (None,) should match all non-anonymous events excluding anonymous ones, but that is assuming.

Copy link
Contributor Author

@dylanjw dylanjw Aug 1, 2018

Choose a reason for hiding this comment

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

Tests results from ethereum/web3.py#985 show that clients diverge in how they treat None values. go-ethereum interprets None as matching any thing, and parity will match anything even the absence of a value.

I think it is up to us to decide what makes the most sense.

What should happen in these cases?

Topics Match params Parity match Go-ethereum match eth-tester match
[] [None,] Yes No
[TOPICA] [None, None] Yes No

Copy link
Contributor

Choose a reason for hiding this comment

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

The parity version makes more sense to me. You can already get the geth like functionally by removing the None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parity doesn't allow things like matching any one, or any two, like go-ethereum does. go-ethereum essentially treats None as a place specific wildcard. On the other hand None feels like a bad choice for a wildcard symbol, and is more intuitive that it provide no actual matching function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right, I got them switched up. The geth one makes more sense to me, too. 👍

(TOPICS_ONLY_A, FILTER_MATCH_ANY_TWO, False),
(TOPICS_ONLY_B, FILTER_MATCH_ANY_TWO, False),
(TOPICS_ONLY_C, FILTER_MATCH_ANY_TWO, False),
(TOPICS_EMPTY, FILTER_MATCH_TWO_OR_MORE, False),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same assumption here. That a None value matches any topic that exists at that position, but not an absent topic.

@dylanjw dylanjw merged commit a3beeb3 into ethereum:master Aug 2, 2018
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

Successfully merging this pull request may close these issues.

nested topic arrays should be interpreted as match options for the topic at the nested array position
3 participants