Skip to content

Conversation

@wolf31o2
Copy link
Member

@wolf31o2 wolf31o2 commented Nov 17, 2025

Summary by CodeRabbit

  • Refactor
    • Strengthened certificate type definitions to improve type safety and data consistency.
    • Refined certificate serialization and encoding logic for enhanced correctness.

@wolf31o2 wolf31o2 requested a review from a team as a code owner November 17, 2025 14:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Warning

Rate limit exceeded

@wolf31o2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between bb3b144 and 1aef9c3.

📒 Files selected for processing (1)
  • ledger/common/certs.go (4 hunks)
📝 Walkthrough

Walkthrough

This PR refactors certificate type definitions in ledger/common/certs.go by changing the PoolKeyHash field from []byte to a typed PoolKeyHash in two certificate structures: StakeVoteDelegationCertificate and StakeRegistrationDelegationCertificate. The encoding and serialization logic is adjusted accordingly, with StakeVoteDelegationCertificate now creating a combined encoded key including pool key hash and DRep bytes, while StakeRegistrationDelegationCertificate uses the slice form of the typed PoolKeyHash in its utxorpc payload.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring extra attention:
    • Verification that the combined encoded key logic for StakeVoteDelegationCertificate (including pool key hash and DRep bytes) correctly reflects the intended serialization behavior
    • Confirmation that all call sites of these certificate types have been updated to accommodate the type change from []byte to PoolKeyHash
    • Review of the utxorpc payload construction changes to ensure data integrity and correct encoding/decoding

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: refactoring to use the PoolKeyHash type consistently across certificate structs instead of mixed []byte and PoolKeyHash types.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ledger/common/certs.go (1)

954-968: Fix PoolKeyhash encoding to match utxorpc specification and correct pattern.

The code incorrectly encodes multiple data types (version byte + PoolKeyHash + DRep) into the PoolKeyhash field at lines 954-957. According to utxorpc specification, PoolKeyhash should be a raw byte field containing only the stake-pool identifier: the Blake2b-224 hash (28 bytes).

The correct implementation pattern is shown in StakeRegistrationDelegationCertificate.Utxorpc() (line 1010), which correctly assigns:

PoolKeyhash: c.PoolKeyHash[:]

The DRep data is already correctly passed to the separate Drep field on line 968, so remove the custom encoding and use the raw pool key hash directly.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fad1241 and bb3b144.

📒 Files selected for processing (1)
  • ledger/common/certs.go (4 hunks)
🔇 Additional comments (2)
ledger/common/certs.go (2)

1011-1011: Correct slice conversion for typed PoolKeyHash.

The slice conversion c.PoolKeyHash[:] correctly handles the change from []byte to the typed PoolKeyHash, consistent with other certificate implementations.


983-983: Type change verified - all usages compatible.

The change from []byte to PoolKeyHash (a [28]byte array type alias) is correctly implemented. All downstream consumers properly use slice conversion syntax [:] when accessing the field, making the type change safe and consistent across the codebase.

Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2 wolf31o2 force-pushed the fix/pool-key-hash-consistency branch from bb3b144 to 1aef9c3 Compare November 17, 2025 15:14
@wolf31o2 wolf31o2 merged commit fd01888 into main Nov 17, 2025
10 checks passed
@wolf31o2 wolf31o2 deleted the fix/pool-key-hash-consistency branch November 17, 2025 19:28
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.

3 participants