Repository navigation
Make MaxWaitNumBlocksFundingConf Configurable for itest - #9562
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Crypt-iQ
left a comment
There was a problem hiding this comment.
Did a quick pass: needs proper formatting, lines go to 80 chars. I think the style guide in the repo can help you fix most of these issues. Otherwise, the core change looks good
| // For the maxWaitNumBlocksFundingConf different values are set | ||
| // in case we are in a dev environment so enhance test | ||
| // capabilities. | ||
| maxWaitNumBlocksFundingConf := MaxWaitNumBlocksFundingConf |
There was a problem hiding this comment.
variable name should not be reused, a bit confusing
| // MaxWaitNumBlocksFundingConf is the maximum number of blocks | ||
| // to wait for the funding transaction to be confirmed before forgetting | ||
| // channels that aren't initiated by us. | ||
| MaxWaitNumBlocksFundingConf int |
There was a problem hiding this comment.
nit: can we uint32 this so we don't need the cast below? fine if not
There was a problem hiding this comment.
I can do that, but in that case, I need to update const MaxWaitNumBlocksFundingConf = 2016 to const MaxWaitNumBlocksFundingConf uint32 = 2016. However, I'm not sure if this might cause any compatibility issues.
There was a problem hiding this comment.
It's not a big deal, just a nit so feel free to leave as-is
There was a problem hiding this comment.
Constants don't have a type, if you don't explicitly set one. So it can be determined at compile time. So you can easily make this uint32 and then below just do: var waitBlocksForFundingConf uint32 = MaxWaitNumBlocksFundingConf.
| // Get the maxWaitNumBlocksFundingConf. If we are not in | ||
| // development mode, this would be nil. | ||
| if lncfg.IsDevBuild() { | ||
| maxWaitNumBlocksFundingConf = f.cfg.Dev. |
9e4b8e1 to
98e91b7
Compare
Hey @Crypt-iQ, I checked my code and believe I've already adhered to the 80-character limit. Could you let me know where the issue might be? (In some cases, more than 80 characters is necessary—such as in description) Also, should I add release notes for 0.19.0? |
You need to configure your IDE to use 8 chars for the tab character, otherwise the 80 character limit is hard to adhere to. |
| // as `channelReadySent`. | ||
| ProcessChannelReadyWait time.Duration | ||
|
|
||
| // MaxWaitNumBlocksFundingConf is the maximum number of blocks |
There was a problem hiding this comment.
For example, here the comment can go up to 80 characters but then you wrap-around
There was a problem hiding this comment.
Thanks, it's fixed. PTAL.
9752395 to
a8efc7e
Compare
| // MaxWaitNumBlocksFundingConf is the maximum number of blocks | ||
| // to wait for the funding transaction to be confirmed before forgetting | ||
| // channels that aren't initiated by us. | ||
| MaxWaitNumBlocksFundingConf int |
There was a problem hiding this comment.
Constants don't have a type, if you don't explicitly set one. So it can be determined at compile time. So you can easily make this uint32 and then below just do: var waitBlocksForFundingConf uint32 = MaxWaitNumBlocksFundingConf.
| waitBlocksForFundingConf := MaxWaitNumBlocksFundingConf | ||
|
|
||
| // Get the waitBlocksForFundingConf. If we are not in development mode, | ||
| // this would be nil. |
There was a problem hiding this comment.
The default value of an int type is actually 0, not nil.
| ht.OpenChannelAssertPending(alice, bob, | ||
| lntest.OpenChannelParams{ | ||
| Amt: 500000, | ||
| PushAmt: 0, | ||
| }) |
There was a problem hiding this comment.
nit: inconsistent formatting. Should either be:
ht.OpenChannelAssertPending(alice, bob, lntest.OpenChannelParams{
Amt: 500000,
PushAmt: 0,
})
or
ht.OpenChannelAssertPending(
alice, bob, lntest.OpenChannelParams{
Amt: 500000,
PushAmt: 0,
},
)
depending on what fits with the line length limit.
a8efc7e to
f06f0aa
Compare
| // For the waitBlocksForFundingConf different values are set in case we | ||
| // are in a dev environment so enhance test capabilities. | ||
| var waitBlocksForFundingConf uint32 = lncfg. | ||
| DefaultMaxWaitNumBlocksFundingConf | ||
|
|
||
| // Get the waitBlocksForFundingConf. If we are not in development mode, | ||
| // this would be DefaultMaxWaitNumBlocksFundingConf. | ||
| if lncfg.IsDevBuild() { | ||
| waitBlocksForFundingConf = f.cfg.Dev.MaxWaitNumBlocksFundingConf | ||
| } | ||
|
|
There was a problem hiding this comment.
nit: Maybe you could make the comments clearer.
Something like:
// The value of waitBlocksForFundingConf is adjusted in a development
// environment to enhance test capabilities. Otherwise, it is set to
// DefaultMaxWaitNumBlocksFundingConf.
var waitBlocksForFundingConf uint32 = lncfg.
DefaultMaxWaitNumBlocksFundingConf
if lncfg.IsDevBuild() {
waitBlocksForFundingConf = f.cfg.Dev.MaxWaitNumBlocksFundingConf
}
| } | ||
|
|
||
| // testFundingManagerFundingTimeout tests that after an OpenChannel, and before | ||
| // the funding transaction is confirmed, if a user is not the channel initiator, |
There was a problem hiding this comment.
nit: ..., if the node is not the channel initiator, ...
| // For the waitBlocksForFundingConf different values are set in | ||
| // case we are in dev environment so enhance test capabilities. | ||
| var waitBlocksForFundingConf uint32 = lncfg. | ||
| DefaultMaxWaitNumBlocksFundingConf | ||
|
|
||
| // Get the waitBlocksForFundingConf. If we are not in | ||
| // development mode, this would be nil. | ||
| if lncfg.IsDevBuild() { | ||
| waitBlocksForFundingConf = r.cfg.Dev. | ||
| GetMaxWaitNumBlocksFundingConf() | ||
| } | ||
|
|
There was a problem hiding this comment.
nit: Maybe you could make the comments clearer.
Something like:
// The value of waitBlocksForFundingConf is adjusted in a development
// environment to enhance test capabilities. Otherwise, it is set to
// DefaultMaxWaitNumBlocksFundingConf.
var waitBlocksForFundingConf uint32 = lncfg.
DefaultMaxWaitNumBlocksFundingConf
if lncfg.IsDevBuild() {
waitBlocksForFundingConf = r.cfg.Dev.
GetMaxWaitNumBlocksFundingConf()
}
f06f0aa to
2132b23
Compare
|
Needs a rebase so that the other commits don't show up |
2132b23 to
f847956
Compare
Done, Thanks for the help. |
guggero
left a comment
There was a problem hiding this comment.
Thanks for the updates. Just two more style nits, other than that LGTM 🎉
| // The value of waitBlocksForFundingConf is adjusted in a development | ||
| // environment to enhance test capabilities. Otherwise, it is set to | ||
| // DefaultMaxWaitNumBlocksFundingConf. | ||
| var waitBlocksForFundingConf uint32 = lncfg. |
There was a problem hiding this comment.
nit/non-blocking: I know it's not super well-defined. But I think in this case breaking before the = character is preferred style.
Or alternatively:
waitBlocksForFundingConf := uint32(
lncfg.DefaultMaxWaitNumBlocksFundingConf,
)
| // The value of waitBlocksForFundingConf is adjusted in a | ||
| // development environment to enhance test capabilities. | ||
| // Otherwise, it is set to DefaultMaxWaitNumBlocksFundingConf. | ||
| var waitBlocksForFundingConf uint32 = lncfg. |
There was a problem hiding this comment.
nit: same here re style (and the lines below).
MPins
left a comment
There was a problem hiding this comment.
Nothing to add ... Good job ... LGTM also 👍
This commit adds an integration test that verifies the funding timeout behavior in the funding manager, in dev/integration test. Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
f847956 to
9a9086b
Compare
Change Description
Fixes: #9511
This PR introduces a configurable parameter for the constant
MaxWaitNumBlocksFundingConfused in funding manager. The change allows developers and integration environments to override the default value (2016 blocks) via a build tag, enabling the mining of fewer blocks to trigger timeout scenarios during testing. In production builds, the default value remains unchanged to ensure stability.Key Changes:
Steps to Test
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.