Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Fix InvalidGossipMessage messages and co-attest #1406

Merged
merged 2 commits into from
Dec 20, 2019

Conversation

hwwhww
Copy link
Contributor

@hwwhww hwwhww commented Dec 18, 2019

What was wrong?

Thanks to @ChihChengLiang for post feedback on #1311.

How was it fixed?

To-Do

  • Clean up commit history

Cute Animal Picture

put a cute animal picture link inside the parentheses

aggregate_and_proof,
str(error),
raise InvalidGossipMessage(
f"Failed to validate aggregate_and_proof={aggregate_and_proof}, error={str(error)}",
Copy link
Contributor

Choose a reason for hiding this comment

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

say we have

class A(Exception):
    ...

class B(Exception):
    ...

if we do

try:
    raise A("Some A reason")
except A as a:
    raise B("Some B reason") from A

we get

__main__.A

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "foo.py", line 12, in <module>
    raise B("Some B reason") from A
__main__.B: Some B reason

if we do

try:
    raise A("Some A reason")
except A as a:
    raise B("Some B reason", a)

We get

Traceback (most recent call last):
  File "foo.py", line 10, in <module>
    raise A("Some A reason")
__main__.A: Some A reason

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo.py", line 12, in <module>
    raise B("Some B reason", a)
__main__.B: ('Some B reason', A('Some A reason'))

If we want to keep the message from the ValidationError, we can do

Suggested change
f"Failed to validate aggregate_and_proof={aggregate_and_proof}, error={str(error)}",
f"Failed to validate aggregate_and_proof={aggregate_and_proof}, error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah but I just want to make InvalidGossipMessage only in DEBUG log instead of shouting loudly. InvalidGossipMessage will be caught in topic validator:

except InvalidGossipMessage as error:
logger.debug("%s", str(error))
return False

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. Note that we can still get the full message in the log with the B("Some B reason", a) style. But both ways look good.

def foo():
    try:
        raise A("Some A reason")
    except A as a:
        raise B("Some B reason", a)

import logging

try:
    foo()
except B as b:
    logging.getLogger("__main__").warning(b)
    # ('Some B reason', A('Some A reason'))

@hwwhww hwwhww changed the title Fix InvalidGossipMessage messages Fix InvalidGossipMessage messages and co-attest Dec 19, 2019
@hwwhww hwwhww merged commit e8a4137 into ethereum:master Dec 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants