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

Allow hex strings in /eth/v1/beacon/states/{state_id}/root endpoint #15098

Merged
merged 5 commits into from
Mar 27, 2025

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Mar 26, 2025

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

BeaconDbStater.StateRoot is missing the option to parse hex strings. This causes errors when passing a hex string in the state_id param of /eth/v1/beacon/states/{state_id}/root

Which issues(s) does this PR fix?

Fixes #15049

Acknowledgements

@rkapka rkapka added the API Api related tasks label Mar 26, 2025
@rkapka rkapka requested a review from a team as a code owner March 26, 2025 15:58
@rkapka rkapka requested review from kasey, nalepae and nisdas March 26, 2025 15:58
@rkapka rkapka force-pushed the fix-state-root-endpoint branch from 31cf281 to 77eb34a Compare March 26, 2025 15:59
@@ -185,7 +185,15 @@ func (p *BeaconDbStater) StateRoot(ctx context.Context, stateId []byte) (root []
case "justified":
root, err = p.justifiedStateRoot(ctx)
default:
if len(stateId) == 32 {
if len(stateIdString) >= 2 && stateIdString[:2] == "0x" {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about using byteutil.IsHex([]byte(stateIdString))

@rkapka rkapka enabled auto-merge March 27, 2025 10:52
@rkapka rkapka added this pull request to the merge queue Mar 27, 2025
Merged via the queue into develop with commit e42611e Mar 27, 2025
17 checks passed
@rkapka rkapka deleted the fix-state-root-endpoint branch March 27, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prysm can not parse certain state_id in endpoint eth/v1/beacon/states/state_id/root
2 participants