8000 feat(core): implement `getBlockCommitment` RPC endpoint by Ozodimgba · Pull Request #150 · txtx/surfpool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(core): implement getBlockCommitment RPC endpoint #150

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

Merged
merged 2 commits into from
Jun 12, 2025

Conversation

Ozodimgba
Copy link
Contributor

No description provided.


Ok(RpcBlockCommitment {
commitment: Some(commitment_array),
total_stake: 150,
Copy link
Member

Choose a reason for hiding this comment

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

Is there any significance to the 150 number we've chosen here? If we're going to hardcode something, I'd prefer 0 so it's more clearly indicating there are no commitments/stakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no significance really only that we are mocking to show that confirmed blocks should have some stake

Copy link
Member

Choose a reason for hiding this comment

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

I think let's zero out, since for surfpool there isn't really a concept of stake

}

Ok(RpcBlockCommitment {
commitment: Some(commitment_array),
Copy link
Member

Choose a reason for hiding this comment

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

We are always returning Some(...), but if I query an old block on the RPC, I'll see a null result.

Copy link
Contributor Author
@Ozodimgba Ozodimgba Jun 9, 2025

Choose a reason for hiding this comment

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

@MicaiahReid there is blockCommitmentCache on the RPC client that holds data about the block commitment (surfpool doesn't have this cache or need it)...the thing about the cache is that old finalized blocks with lesser chance of being rollback leave the cache...returning null when you query their commitment array. Can implement null if you want but this was the idea

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha, then I'm okay with always returning Some([0u64; 32]) for valid requests

@@ -637,4 +666,106 @@ mod tests {
}
);
}

#[test]
fn test_get_block_commitment_basic() {
Copy link
Member

Choose a reason for hiding this comment

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

This test isn't asserting anything - can we remove if the other tests are covering its cases?

Copy link
Contributor Author
@Ozodimgba Ozodimgba Jun 9, 2025

Choose a reason for hiding this comment

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

yeah that was just to show the return value will remove it after review and linting checks

Copy link
Member

Choose a reason for hiding this comment

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

Let's get these sorts of things and lints fixed before review to save the back and forth! 👍

@MicaiahReid MicaiahReid changed the title getBlockCommitment with tests feat(core): implement getBlockCommitment RPC endpoint Jun 9, 2025
@Ozodimgba Ozodimgba requested a review from MicaiahReid June 12, 2025 19:43
@MicaiahReid MicaiahReid merged commit f2189dd into txtx:main Jun 12, 2025
2 checks passed
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.

2 participants
0