-
Notifications
You must be signed in to change notification settings - Fork 115
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
[TRA-451] initialize vaults on start-up in local, dev, staging #1782
Conversation
WalkthroughThe changes primarily revolve around updating various scripts related to the blockchain genesis file configuration. Key updates include modifications to the Changes
Sequence Diagram(s)sequenceDiagram
participant Script as Script
participant Function as edit_genesis
participant Config as Genesis Config
Script->>Function: edit_genesis("$VAL_CONFIG_DIR", ... , "${VAULT_ACCOUNTS[*]}", "${VAULT_NUMBERS[*]}", ...)
Function->>Config: Initialize Genesis Config
Config-->>Function: Genesis Config with Vault Accounts & Numbers
Function-->>Script: Updated Genesis Configuration
Poem
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 (
|
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 (3)
protocol/testing/genesis.sh (3)
Line range hint
30-30
: Unused Variable: TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNTThe variable
TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT
is declared but appears not to be used within the script. Consider removing it if it's not needed, or ensure that it's used appropriately if intended for external use.
Line range hint
31-31
: Unused Variable: FAUCET_NATIVE_TOKEN_BALANCESimilar to the previous comment,
FAUCET_NATIVE_TOKEN_BALANCE
is declared but not used in this script. Verify if it is necessary or if it can be removed.
Line range hint
1083-1083
: Potential Word Splitting IssueThe command at this line could lead to word splitting. Ensure variables are quoted properly to prevent this issue, especially in contexts where the variable might contain spaces or special characters.
- for acct in ${INPUT_TEST_ACCOUNTS[@]}; do + for acct in "${INPUT_TEST_ACCOUNTS[@]}"; do
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- protocol/scripts/genesis/prod_pregenesis.sh (1 hunks)
- protocol/testing/containertest/containertest.sh (1 hunks)
- protocol/testing/e2etest-local/local.sh (1 hunks)
- protocol/testing/genesis.sh (4 hunks)
- protocol/testing/testnet-dev/dev.sh (2 hunks)
- protocol/testing/testnet-external/pregenesis.sh (1 hunks)
- protocol/testing/testnet-local/local.sh (2 hunks)
- protocol/testing/testnet-staging/staging.sh (2 hunks)
Additional context used
Shellcheck
protocol/testing/testnet-external/pregenesis.sh
[warning] 201-201: The surrounding quotes actually unquote this. Remove or escape them. (SC2027)
protocol/testing/genesis.sh
[warning] 30-30: TESTNET_VALIDATOR_SELF_DELEGATE_AMOUNT appears unused. Verify use (or export if used externally). (SC2034)
[warning] 31-31: FAUCET_NATIVE_TOKEN_BALANCE appears unused. Verify use (or export if used externally). (SC2034)
[warning] 1083-1083: Quote this to prevent word splitting. (SC2046)
Additional comments not posted (12)
protocol/testing/e2etest-local/local.sh (1)
102-102
: Verify the impact of the additional empty string argument inedit_genesis
call.The addition of an extra empty string argument to the
edit_genesis
function call needs verification to ensure it does not alter the expected behavior or introduce any issues.Verification successful
Verify the impact of the additional empty string argument in
edit_genesis
call.The
edit_genesis
function ingenesis.sh
handles multiple parameters, some of which have default values if not provided. The additional empty string argument in theedit_genesis
call ensures that all parameters are passed, even if some are empty, which aligns with the function's design.
edit_genesis
parameters include:
$1
(GENESIS)$2
(INPUT_TEST_ACCOUNTS)$3
(INPUT_FAUCET_ACCOUNTS)$4
(INPUT_VAULT_ACCOUNTS)$5
(INPUT_VAULT_NUMBERS)$6
(EXCHANGE_CONFIG_JSON_DIR, defaults to "exchange_config" if empty)$7
(DELAY_MSG_JSON_DIR, defaults to "delaymsg_config" if empty)$8
(INITIAL_CLOB_PAIR_STATUS, defaults to 'STATUS_ACTIVE' if empty)$9
(REWARDS_VESTER_ACCOUNT_BALANCE, defaults to "200000000$EIGHTEEN_ZEROS" if empty)The function is designed to handle empty strings gracefully by assigning default values where necessary. Therefore, the additional empty string argument does not introduce any issues or alter the expected behavior.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the additional empty string argument in the `edit_genesis` function call. # Test: Search for the function definition and usage in other scripts. Expect: Consistent usage and correct handling of the arguments. rg --type bash $'edit_genesis'Length of output: 58
Script:
#!/bin/bash # Description: Verify the impact of the additional empty string argument in the `edit_genesis` function call. # Find all shell script files and then search for the `edit_genesis` function definition and its usage in those files. fd -e sh -x grep -Hn 'edit_genesis' {}Length of output: 2476
Script:
#!/bin/bash # Description: Extract the `edit_genesis` function definition to analyze its parameters and usage. # Extract the `edit_genesis` function definition from the `genesis.sh` file. sed -n '/function edit_genesis/,/}/p' ./protocol/testing/genesis.shLength of output: 589
Script:
#!/bin/bash # Description: Extract the complete `edit_genesis` function definition to analyze all parameters and their usage. # Extract the complete `edit_genesis` function definition from the `genesis.sh` file. sed -n '/function edit_genesis/,/^}/p' ./protocol/testing/genesis.shLength of output: 113725
protocol/testing/containertest/containertest.sh (1)
103-103
: Verify the impact of the additional empty string argument inedit_genesis
call.Similar to the previous file, the addition of an extra empty string argument to the
edit_genesis
function call incontainertest.sh
needs verification to ensure it does not alter the expected behavior or introduce any issues.Verification successful
The
edit_genesis
function handles varying numbers of arguments, including empty strings, without issues.The additional empty string argument does not introduce any problems as the function is designed to handle such cases by checking for empty values and setting default values when necessary.
protocol/testing/containertest/containertest.sh
line 103Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the additional empty string argument in the `edit_genesis` function call. # Test: Search for the function definition and usage in other scripts. Expect: Consistent usage and correct handling of the arguments. rg --type bash $'edit_genesis'Length of output: 58
Script:
#!/bin/bash # Description: Verify the impact of the additional empty string argument in the `edit_genesis` function call. # Test: Search for the function definition and usage in other scripts. Expect: Consistent usage and correct handling of the arguments. rg --type sh $'edit_genesis'Length of output: 2361
Script:
#!/bin/bash # Description: Verify the `edit_genesis` function definition to confirm it can handle the additional empty string argument. # Locate the `edit_genesis` function definition in `protocol/testing/genesis.sh`. ast-grep --lang bash --pattern 'function edit_genesis() { $$$ }' protocol/testing/genesis.shLength of output: 203
Script:
#!/bin/bash # Description: Verify the `edit_genesis` function definition to confirm it can handle the additional empty string argument. # Locate the `edit_genesis` function definition in `protocol/testing/genesis.sh`. rg 'function edit_genesis' protocol/testing/genesis.shLength of output: 82
Script:
#!/bin/bash # Description: Extract the full implementation of the `edit_genesis` function to verify its handling of arguments. # Extract the full implementation of the `edit_genesis` function from `protocol/testing/genesis.sh`. sed -n '/function edit_genesis/,/^}/p' protocol/testing/genesis.shLength of output: 113723
protocol/testing/testnet-local/local.sh (2)
66-76
: Review the addition of vault accounts and numbers.The addition of vault accounts and numbers in
testnet-local/local.sh
aligns with the PR objectives to initialize vaults on start-up. Ensure that the vault addresses and numbers are correctly configured and that they integrate seamlessly with the rest of the setup.
115-116
: Verify the updatededit_genesis
function call with vault parameters.The
edit_genesis
function call has been updated to include vault accounts and numbers. Verify that these parameters are handled correctly within the function and that their integration does not introduce any issues.Verification successful
The
edit_genesis
function correctly handles the vault parameters.
- The function reads the vault accounts and vault numbers into arrays.
- The parameters are processed without introducing any issues.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of vault parameters in the `edit_genesis` function call. # Test: Search for the function definition and usage in other scripts. Expect: Consistent usage and correct handling of the arguments. rg --type bash $'edit_genesis'Length of output: 58
Script:
#!/bin/bash # Locate the definition of the edit_genesis function in the codebase rg 'function edit_genesis' --type sh # Once the definition is found, extract the function implementation to verify parameter handling # Assuming the function is found in a file, we extract the function body rg -A 20 'function edit_genesis' --type shLength of output: 1657
Script:
#!/bin/bash # Extract the complete implementation of the edit_genesis function to verify parameter handling rg -A 50 'function edit_genesis' protocol/testing/genesis.shLength of output: 2194
Script:
#!/bin/bash # Extract the complete implementation of the edit_genesis function to verify parameter handling rg -A 100 'function edit_genesis' protocol/testing/genesis.shLength of output: 5850
protocol/scripts/genesis/prod_pregenesis.sh (1)
171-171
: Verify the impact of the reordered arguments inedit_genesis
call.The
edit_genesis
function call inprod_pregenesis.sh
has been modified to reorder arguments. This change needs verification to ensure it does not alter the expected behavior or introduce any issues.Verification successful
Verify the impact of the reordered arguments in
edit_genesis
call.The
edit_genesis
function inprotocol/testing/genesis.sh
processes several parameters, including setting default values when arguments are not provided. The modified call inprod_pregenesis.sh
is:edit_genesis "$VAL_CONFIG_DIR" "" "" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "STATUS_INITIALIZING" ""
- The first argument (
$VAL_CONFIG_DIR
) is correctly passed toGENESIS
.- The next four empty strings are correctly assigned to
INPUT_TEST_ACCOUNTS
,INPUT_FAUCET_ACCOUNTS
,INPUT_VAULT_ACCOUNTS
, andINPUT_VAULT_NUMBERS
.$TMP_EXCHANGE_CONFIG_JSON_DIR
is correctly assigned toEXCHANGE_CONFIG_JSON_DIR
."./testing/delaymsg_config"
is correctly assigned toDELAY_MSG_JSON_DIR
."STATUS_INITIALIZING"
is correctly assigned toINITIAL_CLOB_PAIR_STATUS
.- The final empty string is correctly assigned to
REWARDS_VESTER_ACCOUNT_BALANCE
.The reordered arguments in the
edit_genesis
call are handled correctly and should not introduce any issues.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of the reordered arguments in the `edit_genesis` function call. # Test: Search for the function definition and usage in other scripts. Expect: Consistent usage and correct handling of the arguments. rg --type bash $'edit_genesis'Length of output: 58
Script:
#!/bin/bash # Description: Verify the impact of the reordered arguments in the `edit_genesis` function call. # Test: Search for the function definition and usage in other scripts. Expect: Consistent usage and correct handling of the arguments. rg --type sh 'edit_genesis'Length of output: 2361
Script:
#!/bin/bash # Description: Extract the `edit_genesis` function definition for detailed analysis. # Test: Locate and extract the function definition. rg --type sh --no-filename --context 10 'function edit_genesis' protocol/testing/genesis.shLength of output: 1118
Script:
#!/bin/bash # Description: Extract the complete `edit_genesis` function definition for detailed analysis. # Test: Locate and extract the complete function definition. rg --type sh --no-filename --context 100 'function edit_genesis' protocol/testing/genesis.shLength of output: 7953
protocol/testing/testnet-dev/dev.sh (1)
82-98
: Initialization of vault accounts and numbers looks good.The setup for vault accounts and their corresponding numbers appears to be correct and aligns with the PR objectives to initialize vaults on start-up. However, ensure that the addresses and numbers are verified for accuracy.
protocol/testing/testnet-external/pregenesis.sh (1)
184-184
: Ensure proper argument passing inedit_genesis
call.The
edit_genesis
function call seems to have been modified to not pass any specific accounts or configuration. This might be intentional to skip initializing balances, but it's important to ensure this aligns with the intended functionality.Verification successful
Ensure proper argument passing in
edit_genesis
call.The
edit_genesis
function inprotocol/testing/genesis.sh
is implemented to handle empty or missing parameters correctly by providing default values where necessary. The function uses conditional checks to set default paths and values for parameters that are passed as empty strings.
- The
EXCHANGE_CONFIG_JSON_DIR
,DELAY_MSG_JSON_DIR
,INITIAL_CLOB_PAIR_STATUS
, andREWARDS_VESTER_ACCOUNT_BALANCE
parameters are all checked for empty values and assigned defaults if they are empty.This aligns with the intended functionality of skipping certain initializations, ensuring the script remains robust and functional.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `edit_genesis` function is correctly implemented to handle empty or missing parameters without issues. # Test: Search for the function definition and usage. Expect: Proper handling of empty strings. rg --type bash $'edit_genesis'Length of output: 58
Script:
#!/bin/bash # Description: Verify that the `edit_genesis` function is correctly implemented to handle empty or missing parameters without issues. # Search for the definition of the `edit_genesis` function. rg 'function edit_genesis' -t sh # Search for all calls to the `edit_genesis` function. rg 'edit_genesis' -t shLength of output: 2446
Script:
#!/bin/bash # Description: Extract the implementation of the `edit_genesis` function for review. # Extract the `edit_genesis` function implementation from `protocol/testing/genesis.sh`. sed -n '/function edit_genesis/,/^}/p' protocol/testing/genesis.shLength of output: 113723
protocol/testing/testnet-staging/staging.sh (2)
136-152
: Review the addition of vault accounts and numbers.The vault accounts and their corresponding numbers have been correctly added. Ensure these values are accurate and align with the vault configurations expected in the testnet environments.
209-209
: Ensure proper parameter handling inedit_genesis
call.The
edit_genesis
function call has been updated to include vault accounts and numbers. Verify that these parameters are being correctly handled in theedit_genesis
function to avoid any issues during genesis file creation.Verification successful
Ensure proper parameter handling in
edit_genesis
call.The
edit_genesis
function has been updated to correctly handle the new parameters for vault accounts and vault numbers by reading them into arrays. This confirms that the function is equipped to manage these parameters without issues.
protocol/testing/genesis.sh
,edit_genesis
function:
- Properly reads vault accounts and vault numbers into arrays.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `edit_genesis` function correctly handles the new parameters for vault accounts and numbers. # Test: Search for the function definition and usage. Expect: Proper handling of new parameters. rg --type bash $'edit_genesis'Length of output: 58
Script:
#!/bin/bash # Description: Verify that the `edit_genesis` function correctly handles the new parameters for vault accounts and numbers. # Search for the function definition of `edit_genesis` in shell scripts. rg 'function edit_genesis' -t sh # Search for the usage of `edit_genesis` to understand how parameters are passed and handled. rg 'edit_genesis' -t shLength of output: 2446
Script:
#!/bin/bash # Description: Inspect the `edit_genesis` function definition to verify the handling of the new parameters for vault accounts and numbers. # Display the `edit_genesis` function definition for review. rg -A 20 'function edit_genesis' protocol/testing/genesis.shLength of output: 994
protocol/testing/genesis.sh (3)
24-24
: New Variable Declaration: DEFAULT_SUBACCOUNT_QUOTE_BALANCE_VAULTThis line introduces a new variable for default subaccount quote balance for vaults. Ensure that this value is appropriate and consistent with the financial logic of the application.
1065-1069
: Vault Account Subaccount InitializationThis block initializes subaccounts for vault accounts with a specific quote balance. It's crucial to ensure that the loop correctly processes each account and assigns the intended balance.
55-55
: Setting Default Values for Directories and StatusThe script sets default values for various directories and statuses if they are not provided. This is a good practice as it ensures the system remains robust even with incomplete configurations.
Also applies to: 61-61, 67-67, 73-73
IFS=' ' read -ra INPUT_VAULT_ACCOUNTS <<<"${4}" | ||
IFS=' ' read -ra INPUT_VAULT_NUMBERS <<<"${5}" |
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.
Tip
Codebase Verification
Ensure Input Sanitization
The inputs ${4}
and ${5}
are directly read into the arrays INPUT_VAULT_ACCOUNTS
and INPUT_VAULT_NUMBERS
without any sanitization or validation. To prevent issues related to unexpected or malicious input, please add appropriate sanitization or validation steps before using these inputs.
protocol/testing/genesis.sh
:- Lines: 52-53
Analysis chain
Reading Vault Accounts and Numbers
The script reads vault accounts and numbers into arrays. Ensure that the input data is sanitized before use to prevent issues related to unexpected or malicious input.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for proper sanitization of vault account inputs.
# Test: Echo the vault accounts and numbers to verify their content.
echo "Vault Accounts: ${INPUT_VAULT_ACCOUNTS[*]}"
echo "Vault Numbers: ${INPUT_VAULT_NUMBERS[*]}"
Length of output: 83
Script:
#!/bin/bash
# Search for the initialization and usage of INPUT_VAULT_ACCOUNTS and INPUT_VAULT_NUMBERS in protocol/testing/genesis.sh
rg 'INPUT_VAULT_ACCOUNTS|INPUT_VAULT_NUMBERS' protocol/testing/genesis.sh
Length of output: 265
Script:
#!/bin/bash
# Search for any sanitization or validation steps applied to ${4} and ${5} in protocol/testing/genesis.sh
rg '\${4}|\${5}' protocol/testing/genesis.sh
Length of output: 46
Changelist
initialize vaults on start-up
can easily extend to more/fewer vaults
Test Plan
tested by running localnet
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
Improvements
edit_genesis
function calls to include vault account parameters for better configuration management.