-
Notifications
You must be signed in to change notification settings - Fork 23
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: setup payload timeout to 2 seconds #75
Conversation
Warning Rate Limit Exceeded@jyc228 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 40 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. WalkthroughThe recent update involves modifying the timer setup within the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
701e599
to
e752925
Compare
miner/payload_building.go
Outdated
@@ -234,7 +234,7 @@ func (w *worker) buildPayload(args *BuildPayloadArgs) (*Payload, error) { | |||
// Setup the timer for terminating the process if SECONDS_PER_SLOT (12s in | |||
// the Mainnet configuration) have passed since the point in time identified | |||
// by the timestamp parameter. | |||
endTimer := time.NewTimer(time.Second * 12) | |||
endTimer := time.NewTimer(time.Second * 2) |
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 is different than the comment above, so it would be nice to leave a quick comment about it.
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.
LGTM
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.
LGTM, I agree with the above comment.
e752925
to
7119a84
Compare
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.
miner/payload_building.go
Outdated
|
||
// KROMA has a blocktime of 2 seconds, so we fixed it. | ||
endTime := time.Second * 2 | ||
if !w.chainConfig.Zktrie { | ||
endTime = time.Second * 12 | ||
} |
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.
The logic to adjust the timeout based on the Zktrie
configuration is clear and aligns with the PR's objective to optimize the timeout setting for the KROMA blockchain. However, there are a few considerations and potential improvements:
-
Hardcoded Values: The timeout values (2 seconds for KROMA and 12 seconds otherwise) are hardcoded. Consider defining these as constants at the beginning of the file or in a configuration file. This would improve maintainability and readability.
-
Configuration Check: The check
if !w.chainConfig.Zktrie
directly ties the timeout logic to theZktrie
configuration. Ensure that this is the most appropriate and only condition that should trigger the 2-second timeout for KROMA. If there are other conditions or configurations specific to KROMA that should also result in a 2-second timeout, consider expanding this logic. -
Error Handling: The current implementation does not include explicit error handling for the timer setup. While
time.NewTimer
is unlikely to fail under normal circumstances, consider adding logging or error handling around critical operations to ensure robustness, especially in a blockchain context where timing is crucial. -
Performance Consideration: Ensure that the change in timeout does not introduce any performance issues or unexpected behavior in the payload building process, especially under high load or network latency conditions. It might be beneficial to conduct performance testing to verify the impact of this change.
+ const (
+ kromaTimeout = time.Second * 2
+ defaultTimeout = time.Second * 12
+ )
- endTime := time.Second * 2
- if !w.chainConfig.Zktrie {
- endTime = time.Second * 12
+ endTime := defaultTimeout
+ if w.chainConfig.Zktrie {
+ endTime = kromaTimeout
}
Consider adding performance tests to ensure that the new timeout settings do not adversely affect the payload building process under various conditions.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// KROMA has a blocktime of 2 seconds, so we fixed it. | |
endTime := time.Second * 2 | |
if !w.chainConfig.Zktrie { | |
endTime = time.Second * 12 | |
} | |
const ( | |
kromaTimeout = time.Second * 2 | |
defaultTimeout = time.Second * 12 | |
) | |
endTime := defaultTimeout | |
if w.chainConfig.Zktrie { | |
endTime = kromaTimeout | |
} |
7119a84
to
d575d82
Compare
Description
Modify the hardcoded timeout of 12 seconds to 2 seconds to match the KROMA chain.
Summary by CodeRabbit