-
Notifications
You must be signed in to change notification settings - Fork 21
feat:added changes to implement poolDistresult #1256
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jenita <[email protected]>
📝 WalkthroughWalkthroughAdds a new "pool-distr" CLI subcommand that requests pool distribution and prints both raw and JSON-serialized outputs. Updates the local state query client Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
protocol/localstatequery/client.go (1)
839-856: Query construction for GetPoolDistr looks correct; consider tightening parameter typeThe conditional construction—no params for “all pools” and a
CborTagSetwhenpoolIdsis non-empty—matches the pattern used inGetStakePoolParamsand should be acceptable from a CBOR perspective.Two follow-ups worth considering:
- Use a stronger type for
poolIds(e.g.,[]ledger.PoolId) instead of[]anyfor consistency withGetStakePoolParamsand to prevent accidental misuse.- Double-check against the local-state-query CDDL/spec that the “no params” form for
QueryTypeShelleyPoolDistris indeed the correct way to request all pools.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
cmd/gouroboros/query.go(1 hunks)protocol/localstatequery/client.go(1 hunks)protocol/localstatequery/queries.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
protocol/localstatequery/client.go (3)
protocol/localstatequery/queries.go (1)
QueryTypeShelleyPoolDistr(64-64)cbor/cbor.go (1)
Tag(40-40)cbor/tags.go (1)
CborTagSet(31-31)
protocol/localstatequery/queries.go (3)
cbor/cbor.go (1)
StructAsArray(45-48)ledger/common/common.go (2)
PoolId(449-449)Blake2b256(41-41)cbor/tags.go (1)
Rat(94-96)
cmd/gouroboros/query.go (2)
protocol/localstatequery/localstatequery.go (1)
LocalStateQuery(116-119)protocol/localstatequery/client.go (1)
Client(30-43)
🪛 GitHub Actions: golangci-lint
cmd/gouroboros/query.go
[error] 330-330: encoding/json.Marshal for unsupported type github.com/blinklabs-io/gouroboros/ledger.PoolId as map key found (errchkjson)
🪛 GitHub Check: lint
cmd/gouroboros/query.go
[failure] 330-330:
encoding/json.Marshal for unsupported type github.com/blinklabs-io/gouroboros/ledger.PoolId as map key found (errchkjson)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
protocol/localstatequery/queries.go (1)
725-734: PoolDistrResult structure is consistent with existing CBOR result typesThe layout mirrors
StakeDistributionResult(StructAsArray + map[ledger.PoolId]{StakeFraction, VrfHash}), which is appropriate for decoding the pool distribution response. No issues from a type/CBOR-shape perspective.
Signed-off-by: Jenita <[email protected]>
Signed-off-by: Jenita <[email protected]>
| cbor.Tag{ | ||
| Number: cbor.CborTagSet, | ||
| Content: poolIds, | ||
| }, |
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.
We have the cbor.Set type that handles this
| QueryTypeShelleyPoolDistr, | ||
| ) | ||
| } else { | ||
| query = buildShelleyQuery( |
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.
Instead of building the query twice, it's a bit cleaner to build the params dynamically. Something like this:
var params []any
if len(poolIds) > 0 {
params = append(params, cbor.Set(poolIds))
}
query := buildShelleyQuery(
currentEra,
QueryTypeShelleyPoolDistr,
params...,
)
Closes #870
While running the query against the cardano node, I keep getting one of the following
root@7ebe79e76ec2:/code# go run ./cmd/gouroboros/ -network devnet -network-magic 42 -socket /ipc/node.socket query pool-distr
ERROR: peer closed the connection while reading header: EOF
exit status 1
root@7ebe79e76ec2:/code# go run ./cmd/gouroboros/ -network devnet -network-magic 42 -socket /ipc/node.socket query pool-distr
ERROR: failure querying pool distribution: protocol is shutting down
exit status 1
Summary by CodeRabbit
New Features
Improvements