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

fix: apply default restrictions to max depth #352

Merged
merged 12 commits into from
Aug 27, 2024

Conversation

colin-axner
Copy link
Contributor

If the max depth is set to 0, treat it as 128

@colin-axner colin-axner marked this pull request as ready for review August 14, 2024 08:58
Copy link

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thank you for the fix, @colin-axner. Should we add a changelog entry?

@@ -7,16 +7,16 @@
"hash": 1,

Choose a reason for hiding this comment

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

Curious: how did you re-generate this test data?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, were they changed by hand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup! The only way I managed was to pull printed proofs from ibc-go tests 😅 That's why I added #348

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yea, figured as much when I saw the issue! 😅 sometimes caveman approach = best approach

Copy link

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Should we also update this comment in the proto file?

It looks like we should also fix this in the Rust implementation, right? (I can try to open a PR or contact @romac otherwise)

testdata/TestCheckAgainstSpecData.json Outdated Show resolved Hide resolved
@@ -54,7 +54,7 @@ func CheckLeafTestData(tb testing.TB) map[string]CheckLeafTestStruct {
type CheckAgainstSpecTestStruct struct {
Proof *ExistenceProof
Spec *ProofSpec
IsErr bool
Err string
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make this error instead of string?

Copy link
Contributor

@damiannolan damiannolan Aug 19, 2024

Choose a reason for hiding this comment

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

maybe not worth doing this tbh. I see the testdata json structs are unmarshalled to this struct and we'd need to handle custom unmarshalJSON functionality to handle the built-in error interface, this is probably why bool was used to begin with

Using string is fine by me 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, I tried doing error but felt it was too much work to dig further into

Copy link
Contributor

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Thanks @colin-axner! LGTM

Comment on lines +194 to +197
maxDepth := spec.MaxDepth
if maxDepth == 0 {
maxDepth = 128
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a note to proto doc that if max_depth is zero then we treat as default 128?

https://github.com/cosmos/ics23/blob/master/proto/cosmos/ics23/v1/proofs.proto#L165-L166

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing 👍

@@ -7,16 +7,16 @@
"hash": 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

+1, were they changed by hand?

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

Thanks for the great work @colin-axner !!

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.55%. Comparing base (6dbe7e3) to head (d9043a7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #352   +/-   ##
=======================================
  Coverage   65.55%   65.55%           
=======================================
  Files           7        7           
  Lines        3609     3609           
=======================================
  Hits         2366     2366           
  Misses       1243     1243           
Flag Coverage Δ
rust 65.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was added when I ran make proto-all. Hope it is correct if I update it @romac

@colin-axner colin-axner merged commit 1363533 into master Aug 27, 2024
12 checks passed
@colin-axner colin-axner deleted the colin/fix-max-depth-limitation branch August 27, 2024 14:01
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.

4 participants