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

(chore): Parameterize the BalanceTracker version #123

Closed
wants to merge 1 commit into from

Conversation

jackchuma
Copy link
Contributor

This will allow new BalanceTracker versions to be initialized in the future.

Also updated an internal function name to include a leading underscore - in line with our style guide.

@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Jan 30, 2025

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@jackchuma jackchuma requested a review from xenoliss January 30, 2025 17:30
*/
function initialize(address payable[] memory _systemAddresses, uint256[] memory _targetBalances)
function initialize(address payable[] memory _systemAddresses, uint256[] memory _targetBalances, uint8 _version)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can not see any access control on the initialize() function. Now that _version is a user-supplied parameter, this seems to allow arbitrary reinitialization by any caller who provides a higher version number.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, perhaps we want a way to just change the addresses without having to call initialize

Copy link

@cbfyi cbfyi Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if this was hardcoded (like before this PR), it'd have to be incremented every time we need to update the addresses, but nothing about the core implementation actually changed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that the previous reinitializer(2) prevented it from being reinitialized. Now that it uses reinitializer(_version), I think anyone could reinitialize the contract.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, perhaps we want a way to just change the addresses without having to call initialize

I think we would still need to enforce access control on who can update those addresses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow yeah good catch. So you think we should make it ownable and add a setter function instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not worth the trouble actually - inheriting a new contract could screw up the storage layout making it not feasible to upgrade. We'd have to add custom logic

@@ -16,6 +16,7 @@ contract BalanceTrackerTest is CommonTest {
event SentProfit(address indexed _profitWallet, bool indexed _success, uint256 _balanceSent);
event ReceivedFunds(address indexed _sender, uint256 _amount);

uint8 constant VERSION = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to set it to 2 to match what was in the contract previously?

@jackchuma jackchuma closed this Jan 31, 2025
@jackchuma jackchuma deleted the jack/balance-tracker-init branch January 31, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants