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

feat(security-monitor): add security monitor contract #955

Conversation

GregDixonMXN
Copy link

Resolves #927

Copy link
Member

@0x4007 0x4007 left a comment

Choose a reason for hiding this comment

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

Code looks good but I'm not a solidity developer.

@@ -1,5 +1,5 @@
# Diamond
[Git Source](https://github.com/ubiquity/ubiquity-dollar/blob/565aaa6bed7cb481fd57c9fc6a7b1052ff2aa816/src/dollar/Diamond.sol)
[Git Source](https://github.com/ubiquity/ubiquity-dollar/blob/0cae71618450aff584ed3369a18e2ba12900dc6b/src/dollar/Diamond.sol)
Copy link
Member

Choose a reason for hiding this comment

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

Why are there so many md files changes? There's a separate docs generation workflow that updates docs after each push to the development branch so there's no need update docs manually. Besides https://github.com/ubiquity/ubiquity-dollar/blob/0cae71618450aff584ed3369a18e2ba12900dc6b/src/dollar/Diamond.sol leads to unknown file so it seems that commit 0cae71618450aff584ed3369a18e2ba12900dc6b does not exist.

Copy link
Author

Choose a reason for hiding this comment

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

im not sure maybe because i had to force push some changes after i created the PR? i didnt do this intentionally

Copy link
Member

@rndquu rndquu left a comment

Choose a reason for hiding this comment

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

Overall:

  1. All pause() and unpause() methods should be removed
  2. Log based upkeep should be used
  3. Tests should use real contract instances, not mocks
  4. It's still not clear how to send telegram notifications in case of a security incident

@@ -51,6 +50,14 @@ contract UbiquityDollarToken is ERC20Ubiquity {
address account,
uint256 amount
) public override onlyDollarBurner whenNotPaused {
uint256 currentAllowance = allowance(account, _msgSender());
Copy link
Member

Choose a reason for hiding this comment

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

Why was the UbiquityDollarToken contract modified? And how is this code change connected with the "security monitoring" feature?

@@ -46,6 +46,16 @@ contract UbiquityPoolFacet is IUbiquityPool, Modifiers {
return LibUbiquityPool.collateralUsdBalance();
}

/// @inheritdoc IUbiquityPool
function pause() external onlyAdmin {
Copy link
Member

Choose a reason for hiding this comment

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

There's no need to update any of the existing contracts, libs or interfaces. We can simply disable collateral (as stated in the issue description) which will take the same effect as pausing.

bytes calldata /* checkData */
) external view returns (bool upkeepNeeded) {
upkeepNeeded =
(block.timestamp - _securityStorage.lastCheckTimestamp) >=
Copy link
Member

Choose a reason for hiding this comment

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

Log based upkeep should be used.

}

function testSecurityIncidentLiquidity() public {
mockUPool.setCollateralUsdBalance(50); // Set a low balance to trigger the incident
Copy link
Member

Choose a reason for hiding this comment

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

Pls use real contract instances in the tests. Mocks are prone to errors.

assertTrue(mockUPool.paused(), "UPool should be paused");
}

function testSecurityIncidentCollateralRatio() public {
Copy link
Member

@rndquu rndquu Aug 29, 2024

Choose a reason for hiding this comment

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

I don't understand the purpose of this test:

  1. Collateral ratio is set to 80%
  2. Security monitor contract performs an upkeep
  3. Suddenly everything is paused

Why should we pause contracts in this case?

@GregDixonMXN GregDixonMXN closed this by deleting the head repository Aug 31, 2024
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.

Security monitoring
3 participants