Skip to content
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

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

tqin7
Copy link
Contributor

@tqin7 tqin7 commented Jun 26, 2024

Changelist

initialize vaults on start-up

  • 2 vaults locally
  • 5 vaults on dev and staging

can easily extend to more/fewer vaults

Test Plan

tested by running localnet

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features

    • Added support for vault accounts and numbers across various scripts.
    • Introduced default subaccount balance for vaults in genesis configuration.
  • Improvements

    • Updated edit_genesis function calls to include vault account parameters for better configuration management.
    • Enhanced flexibility in passing arguments to scripts by reordering and adding parameters where necessary.

Copy link

linear bot commented Jun 26, 2024

Copy link
Contributor

coderabbitai bot commented Jun 26, 2024

Walkthrough

The changes primarily revolve around updating various scripts related to the blockchain genesis file configuration. Key updates include modifications to the edit_genesis function calls across different scripts to improve handling of accounts and vault numbers, and initialization statuses. These adjustments ensure consistency and add new functionalities for handling vault accounts and numbers.

Changes

File Change Summary
protocol/scripts/genesis/prod_pregenesis.sh Reordered arguments in edit_genesis function call to shift the exchange config directory.
protocol/testing/containertest/containertest.sh and protocol/testing/e2etest-local/local.sh Added an extra empty string argument in edit_genesis function call within create_validators function.
protocol/testing/genesis.sh Added functionality for handling vault accounts and numbers; updated edit_genesis parameters.
protocol/testing/testnet-dev/dev.sh Added additional vault addresses and numbers to be used in edit_genesis function.
protocol/testing/testnet-local/local.sh Included BTC and ETH vault addresses and numbers; modified edit_genesis function to incorporate vault accounts and numbers.
protocol/testing/testnet-staging/staging.sh Introduced various vault accounts (BTC, ETH, LINK, MATIC, CRV) and their IDs; updated edit_genesis function parameters.

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
Loading

Poem

On cryptic blocks of chain we tread,
With vaults of numbers in our stead.
Genesis scripts align just right,
To guide us through the dark of night.
From BTC to ETH, a boundless quest,
Our genesis files now truly blessed. 🌟


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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_AMOUNT

The 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_BALANCE

Similar 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 Issue

The 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

Commits

Files that changed from the base of the PR and between 6abbc72 and fb596d3.

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 in edit_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 in genesis.sh handles multiple parameters, some of which have default values if not provided. The additional empty string argument in the edit_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.sh

Length 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.sh

Length of output: 113725

protocol/testing/containertest/containertest.sh (1)

103-103: Verify the impact of the additional empty string argument in edit_genesis call.

Similar to the previous file, the addition of an extra empty string argument to the edit_genesis function call in containertest.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 103
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.

# 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.sh

Length 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.sh

Length 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.sh

Length 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 updated edit_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 sh

Length 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.sh

Length 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.sh

Length of output: 5850

protocol/scripts/genesis/prod_pregenesis.sh (1)

171-171: Verify the impact of the reordered arguments in edit_genesis call.

The edit_genesis function call in prod_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 in protocol/testing/genesis.sh processes several parameters, including setting default values when arguments are not provided. The modified call in prod_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 to GENESIS.
  • The next four empty strings are correctly assigned to INPUT_TEST_ACCOUNTS, INPUT_FAUCET_ACCOUNTS, INPUT_VAULT_ACCOUNTS, and INPUT_VAULT_NUMBERS.
  • $TMP_EXCHANGE_CONFIG_JSON_DIR is correctly assigned to EXCHANGE_CONFIG_JSON_DIR.
  • "./testing/delaymsg_config" is correctly assigned to DELAY_MSG_JSON_DIR.
  • "STATUS_INITIALIZING" is correctly assigned to INITIAL_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.sh

Length 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.sh

Length 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 in edit_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 in protocol/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, and REWARDS_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 sh

Length 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.sh

Length 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 in edit_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 the edit_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 sh

Length 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.sh

Length of output: 994

protocol/testing/genesis.sh (3)

24-24: New Variable Declaration: DEFAULT_SUBACCOUNT_QUOTE_BALANCE_VAULT

This 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 Initialization

This 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 Status

The 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

Comment on lines +52 to +53
IFS=' ' read -ra INPUT_VAULT_ACCOUNTS <<<"${4}"
IFS=' ' read -ra INPUT_VAULT_NUMBERS <<<"${5}"
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants