Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 had an issue from the auditors related to this:
Recommendation:
WDYT?
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.
so the concern is probably the check is wrong?
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.
Yes, they suggest using
>
instead of>=
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.
Yeah, I think
>
should be used. Wanted to check on a few cases below.@cryptoAtwill could you add a unit test(s) for this as part of this PR?
Case 1:
s.maxTreeDepth
== 2r123/abcd
sos.networkName.route.length
is 1 (abcd
)Case 2:
s.maxTreeDepth
== 2r123/abcd/efgh
sos.networkName.route.length
is 2 (abcd/efgh
)Case 3: Let's say L3 is allowed ->
s.maxTreeDepth
== 3r123/abcd/efgh
sos.networkName.route.length
is 2 (abcd/efgh
)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.
I think this check is correct. For L1, the route.length is 0, for L2 the route.length is 1.
s.maxTreeDepth
is default to 2. So to create L3, we will have L2'sroute.length + 1
which is 2 and equalss.maxTreeDepth
.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.
@dnkolegov @maciejwitowski I think your examples mixed
subnetId
withs.networkName
.s.networkName
is the current subnet andsubnetId
is the subnet to be created. This check is sent to the parent.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.
@dnkolegov @maciejwitowski I think your examples mixed
subnetId
withs.networkName
.s.networkName
is the current subnet andsubnetId
is the subnet to be created. This check is sent to the parent.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.
Oh, I missed the fact this
if
is before thes.networkName.createSubnetId
so in flow of creating L3 thes.networkName.route.length
is the one for L2 (which is 1). You may be right then 😄Anyways, adding a few unit tests with clear names like
revert_L3_creation_when_it_is_disabled
which test the edge conditions of>=
would be recommended here I think.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.
This got me too as well in the past. Comments would be good because it looks like there is nobody who has looked at this and can tell what it does.