-
Notifications
You must be signed in to change notification settings - Fork 48
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
Improve log output update periphery #904
Conversation
WalkthroughThe pull request introduces significant modifications to the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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
🧹 Outside diff range and nitpick comments (6)
script/tasks/diamondUpdatePeriphery.sh (2)
Line range hint
1-264
: Standardize logging patterns across the scriptThe script uses multiple logging approaches (
echo "[info]"
,warning
,error
,echoDebug
). Consider standardizing the logging pattern for better consistency and log parsing.Suggestions:
- Define log levels: ERROR, WARN, INFO, DEBUG
- Create a single logging function that handles all levels
- Ensure consistent message format
Example implementation:
# Add at the beginning of the script log() { local level="$1" local message="$2" echo "[$level] $message" } # Usage examples: log "ERROR" "Failed to register contract" log "WARN" "Contract not found in target state" log "INFO" "Processing contract registration" log "DEBUG" "Current network: $NETWORK"
Line range hint
183-196
: Enhance security checks for contract registrationWhile the script includes basic security checks, consider adding additional validations before registering contracts, especially for production environments.
Suggestions:
- Verify contract source code on block explorer
- Validate contract interface matches expected ABI
- Add explicit checks for contract ownership
- Log contract verification status
Example verification check:
verify_contract() { local network="$1" local address="$2" local contract_name="$3" # Check if contract is verified on block explorer if [[ "$ENVIRONMENT" == "production" ]]; then if ! is_contract_verified "$network" "$address"; then error "Contract $contract_name at $address is not verified on $network block explorer" return 1 fi fi }script/deploy/deploySingleContract.sh (4)
Line range hint
59-62
: Fix incorrect escape sequences in printf statements for color resetThe escape sequences used in the
printf
statements are incorrect. The code uses\031\n
, which should be\033[0m\n
to correctly reset the text color.Apply this diff to correct the escape sequences:
- printf '\033[31m%s\031\n' "!!!!!!!!!!!!!!!!!!!!!!!! ATTENTION !!!!!!!!!!!!!!!!!!!!!!!!" + printf '\033[31m%s\033[0m\n' "!!!!!!!!!!!!!!!!!!!!!!!! ATTENTION !!!!!!!!!!!!!!!!!!!!!!!!" - printf '\033[31m%s\031\n' "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + printf '\033[31m%s\033[0m\n' "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Line range hint
117-120
: Fix incorrect escape sequences in printf statements for color resetThe escape sequences used in the
printf
statements are incorrect. The code uses\031\n
, which should be\033[0m\n
to correctly reset the text color.Apply this diff to correct the escape sequences:
- printf '\033[31m%s\031\n' "--------------------------------------- !!!!!!!! ATTENTION !!!!!!!! ---------------------------------------" + printf '\033[31m%s\033[0m\n' "--------------------------------------- !!!!!!!! ATTENTION !!!!!!!! ---------------------------------------" - printf '\033[31m%s\031\n' "-----------------------------------------------------------------------------------------------------------" + printf '\033[31m%s\033[0m\n' "-----------------------------------------------------------------------------------------------------------"
Line range hint
107-107
: Avoid redeclaring the local variable 'CONTRACT'The variable
CONTRACT
is already declared as a local variable on line 14. Redeclaring it here may cause confusion and potential issues. Consider removinglocal
from this line.Apply this diff to remove the redundant
local
:- local CONTRACT=$(echo $SCRIPT | sed -e 's/Deploy//') + CONTRACT=$(echo $SCRIPT | sed -e 's/Deploy//')
Line range hint
194-194
: 'ADDRESS' variable may be undefined when checking for existing deploymentThe
ADDRESS
variable is used before it is assigned a value. This could lead to incorrect behavior or script failure. Consider usingCONTRACT_ADDRESS
instead.Apply this diff to use
CONTRACT_ADDRESS
in the function call:- NEW_DEPLOYMENT=$(doesAddressContainBytecode "$NETWORK" "$ADDRESS") + NEW_DEPLOYMENT=$(doesAddressContainBytecode "$NETWORK" "$CONTRACT_ADDRESS")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
script/deploy/deploySingleContract.sh
(1 hunks)script/tasks/diamondUpdatePeriphery.sh
(1 hunks)
Test Coverage ReportLine Coverage: 77.92% (2139 / 2745 lines) |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Which Jira task belongs to this PR?
https://lifi.atlassian.net/browse/LF-11369
Why did I implement it this way?
Checklist before requesting a review
Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)