-
Notifications
You must be signed in to change notification settings - Fork 997
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
Add mypy type hinting check #1166
Conversation
for challenge in state.custody_bit_challenge_records: | ||
if get_current_epoch(state) > challenge.inclusion_epoch + CUSTODY_RESPONSE_DEADLINE: | ||
slash_validator(state, challenge.responder_index, challenge.challenger_index) | ||
for custody_chunk_challenge in state.custody_chunk_challenge_records: |
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.
Workaround for mypy
issue of redefining variable in the different scopes (python/mypy#5750).
Lazy benchmarking on running |
Re: benchmark |
specs/core/0_beacon-chain.md
Outdated
@@ -1140,15 +1140,15 @@ def slash_validator(state: BeaconState, | |||
current_epoch = get_current_epoch(state) | |||
initiate_validator_exit(state, slashed_index) | |||
state.validator_registry[slashed_index].slashed = True | |||
state.validator_registry[slashed_index].withdrawable_epoch = current_epoch + LATEST_SLASHED_EXIT_LENGTH | |||
state.validator_registry[slashed_index].withdrawable_epoch = Epoch(current_epoch + LATEST_SLASHED_EXIT_LENGTH) |
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.
If current_epoch
and LATEST_SLASHED_EXIT_LENGTH
are both of type Epoch
do we need to wrap the sum with Epoch( ... )
?
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.
Epoch
is defined as "EpochNumber/EpochID" and LATEST_SLASHED_EXIT_LENGTH
is defined as "diff between Epochs".
I'm slightly in favor of the status quo but I'm open to it; for Epoch
and Slot
, we can change it to the more flexible definition if we want. :)
I'm not so happy with the benchmark results but it's ready to get the first review. There are some other
/cc @JustinDrake what would you say? |
slot: uint64 | ||
shard: uint64 | ||
slot: Slot | ||
shard: Shard | ||
beacon_chain_root: Bytes32 | ||
parent_root: Bytes32 |
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.
All the hashes can be of type Hash
(see PR1156 where I introduce the type).
@JustinDrake up-to-date now with #1156 |
X = NewType('X', NONE-BASE-TYPE)
(Fine-grained: Inconsistent behavior for nested NewType python/mypy#4615), I changeduint64
toclass
to make the check pass. I'll benchmark it to see if it increased too much overhead.BytesN
custom types familyTODOs: