-
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
feat(contracts): parse validator indexes as arrays from solidity #120
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RegisterValidators
participant StringToUintArrayLib
participant BoltRegistry
User ->> RegisterValidators: call run()
RegisterValidators ->> RegisterValidators: Fetch validatorIndexes
RegisterValidators ->> StringToUintArrayLib: Convert string to uint256 array
StringToUintArrayLib ->> RegisterValidators: Return uint256 array
RegisterValidators ->> BoltRegistry: Register validators using uint256 array
BoltRegistry ->> RegisterValidators: Acknowledge registration
RegisterValidators ->> User: Registration complete
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (2)
- bolt-contracts/script/RegisterValidators.s.sol (3 hunks)
- bolt-contracts/test/StringToUintArrayLib.t.sol (1 hunks)
Additional comments not posted (9)
bolt-contracts/test/StringToUintArrayLib.t.sol (6)
9-9
: LGTM!The
setUp
function is currently empty but can be used for future setup code.
11-23
: LGTM!The test correctly verifies the parsing of a simple comma-separated string of indexes.
25-37
: LGTM!The test correctly verifies the parsing of a range string of indexes.
39-54
: LGTM!The test correctly verifies the parsing of a combination of ranges and individual values.
56-71
: LGTM!The test correctly verifies the parsing of a more complex combination of ranges and individual values.
73-81
: LGTM!The test correctly verifies the parsing of a large range of indexes.
bolt-contracts/script/RegisterValidators.s.sol (3)
13-13
: LGTM!The
using
directive correctly imports theStringToUintArrayLib
library.
54-112
: LGTM!The
fromStr
method correctly parses a string into an array ofuint256
values, including handling ranges.
20-24
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
run
match the new logic.Verification successful
Verified the function usage in the codebase.
The
run
function inRegisterValidators.s.sol
includes the new logic and is consistent with the changes. Therun
function inDeployRegistry.s.sol
is unrelated and does not require any changes.
bolt-contracts/script/RegisterValidators.s.sol
:run
function includes the new logic.bolt-contracts/script/DeployRegistry.s.sol
:run
function is unrelated to the changes.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `run` match the new logic. # Test: Search for the function usage. Expect: Only occurances of the new logic. rg --type solidity $'run'Length of output: 57
Script:
#!/bin/bash # Description: Verify all function calls to `run` match the new logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg 'run' --glob '*.sol'Length of output: 169
Script:
#!/bin/bash # Extract the `run` function implementation from RegisterValidators.s.sol ast-grep --lang solidity --pattern $'function run() public { $$$ }' bolt-contracts/script/RegisterValidators.s.sol # Extract the `run` function implementation from DeployRegistry.s.sol ast-grep --lang solidity --pattern $'function run() public { $$$ }' bolt-contracts/script/DeployRegistry.s.solLength of output: 465
Script:
#!/bin/bash # Extract the `run` function implementation from RegisterValidators.s.sol sed -n '/function run() public {/,/^}/p' bolt-contracts/script/RegisterValidators.s.sol # Extract the `run` function implementation from DeployRegistry.s.sol sed -n '/function run() public {/,/^}/p' bolt-contracts/script/DeployRegistry.s.solLength of output: 1647
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.
Replicates the rust functionality added in #119, but in Solidity for registering on-chain.
Testing this soon with registration of our validators on Helder.
UPDATE: the script worked and allowed me to register 100 validators using the provided range.
Summary by CodeRabbit
New Features
RegisterValidators
contract to process validator indexes more efficiently using a new library for string-to-uint256 conversion.StringToUintArrayLib
library with thefromStr
function to convert strings of validator indexes intouint256
arrays.Tests
StringToUintArrayLib
to validate its functionality in converting strings to arrays ofuint256
.