Skip to content

Remove remaining type casts - #5606

Draft
jihoonsong wants to merge 2 commits into
ethereum:masterfrom
jihoonsong:remaining-type-casts
Draft

Remove remaining type casts#5606
jihoonsong wants to merge 2 commits into
ethereum:masterfrom
jihoonsong:remaining-type-casts

Conversation

@jihoonsong

Copy link
Copy Markdown
Member

This PR removes remaining type casts after #5588.

Comment on lines 485 to 490
adjusted_total_slashing_balance = min(
Gwei(sum(state.slashings))
sum(state.slashings)
# [Modified in Bellatrix]
* PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX,
total_balance,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm as long as the linter doesn't complain, I guess this is fine. sum() does not return a Gwei value here, it will return an int. This means adjusted_total_slashing_balance could be either type.

if bit
]
previous_slot = max(state.slot, Slot(1)) - 1
previous_slot = state.slot - min(state.slot, 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, I like this better.

@jtraglia jtraglia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As long as the linter is happy with this, LGTM 👍 We should consider not using min, max, and sum helpers. They don't work as well with custom types. Or we could consider shadowing them with our own. A problem for another day.

@jihoonsong

jihoonsong commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

We should consider not using min, max, and sum helpers.

Would you prefer to introduce like a saturate_sub helper?

@jtraglia

jtraglia commented Sep 7, 2026

Copy link
Copy Markdown
Member

We should consider not using min, max, and sum helpers.

Would you prefer to introduce like a saturate_sub helper?

Yes, but in a different PR. And named "saturating sub" for consistency with rust and c++.

@jihoonsong
jihoonsong marked this pull request as draft September 7, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants