forked from axieinfinity/ronin-dpos-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
349 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
abstract contract PostChecker { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { Vm } from "forge-std/Vm.sol"; | ||
import { StdStyle } from "forge-std/StdStyle.sol"; | ||
import { console2 as console } from "forge-std/console2.sol"; | ||
import { BaseMigration } from "foundry-deployment-kit/BaseMigration.s.sol"; | ||
import { IBridgeManager } from "@ronin/contracts/interfaces/bridge/IBridgeManager.sol"; | ||
|
||
abstract contract BasePostCheck is BaseMigration { | ||
using StdStyle for *; | ||
|
||
uint256 internal seed = vm.unixTime(); | ||
address internal _bridgeSlash; | ||
address internal _bridgeReward; | ||
address internal _bridgeTracking; | ||
mapping(uint256 chainId => address manager) internal _manager; | ||
mapping(uint256 chainId => address gateway) internal _gateway; | ||
|
||
modifier onPostCheck(string memory postCheckLabel) { | ||
uint256 snapshotId = _beforePostCheck(postCheckLabel); | ||
_; | ||
_afterPostCheck(postCheckLabel, snapshotId); | ||
} | ||
|
||
function _beforePostCheck(string memory postCheckLabel) private returns (uint256 snapshotId) { | ||
snapshotId = vm.snapshot(); | ||
console.log("\n> ".cyan(), postCheckLabel.blue().italic(), "..."); | ||
} | ||
|
||
function _afterPostCheck(string memory postCheckLabel, uint256 snapshotId) private { | ||
console.log(string.concat("Postcheck", postCheckLabel.italic(), "successful!\n").green()); | ||
vm.revertTo(snapshotId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { BasePostCheck } from "./BasePostCheck.s.sol"; | ||
|
||
abstract contract PostCheck_StorageSlot is BasePostCheck { | ||
function validate_BridgeManager_StorageSlot() internal onPostCheck("validate_BridgeManager_StorageSlot") { } | ||
|
||
function validate_BridgeReward_StorageSlot() internal onPostCheck("validate_BridgeReward_StorageSlot") { } | ||
|
||
function validate_BridgeSlash_StorageSlot() internal onPostCheck("validateBridgeSlash_StorageSlot") { } | ||
|
||
function validate_BridgeTracking_StorageSlot() internal onPostCheck("validate_BridgeTracking_StorageSlot") { } | ||
} |
91 changes: 91 additions & 0 deletions
91
script/post-check/bridge-manager/BridgeManager.post_check.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
BridgeManager | ||
CRUD | ||
add | ||
when not self-called | ||
it should revert | ||
when self-called | ||
when the list has duplicate | ||
it should revert | ||
when the list has null value | ||
it should revert | ||
when three input array mismatch | ||
it should revert | ||
when vote weight is zero | ||
it should revert | ||
when the valid input | ||
governor should be in governor list | ||
it should increase the total weight | ||
governor should have expected weight | ||
operator should have expected weight | ||
it should map governor => bridge operator | ||
it should map bridge operator => governor | ||
bridge operator should be in operator list | ||
it should notify proxy contract with valid data | ||
it should notify immutable contract with valid data | ||
remove | ||
when not self-called | ||
it should revert | ||
when self-called | ||
when the list has duplicate | ||
it should revert | ||
when the list has null value | ||
it should revert | ||
when operator is not in the operator list | ||
it should not remove | ||
when operator is in the list | ||
governor should have 0 weight | ||
it should decrease the total weight | ||
bridge operator should have 0 weight | ||
orders of other governors must unchanged | ||
orders of other bridge operators must unchanged | ||
it should notify proxy contract with valid data | ||
it should notify immutable contract with valid data | ||
it should remove the operator from the operator list | ||
it should remove corresponding governor from the list | ||
it should remove the mapping governor => bridge operator | ||
it should remove the mapping bridge operator => governor | ||
|
||
update | ||
when self-called | ||
it should revert | ||
when caller is not governor | ||
it should revert | ||
when caller is governor | ||
when new bridge operator is null | ||
it should revert | ||
when new bridge operator mapped to another governor | ||
it should revert | ||
when current bridge operator == new bridge operator | ||
it should revert | ||
when new bridge operator is not in the list | ||
total weight must not change | ||
old bridge operator should have 0 weight | ||
orders of other governors must unchanged | ||
orders of other bridge operators must unchanged | ||
it should notify proxy contract with valid data | ||
it should notify immutable contract with valid data | ||
it should add the mapping governor => new bridge operator | ||
it should add the mapping new bridge operator => governor | ||
new bridge operator should has old bridge operator weight | ||
it should remove the mapping old bridge operator => governor | ||
it should remove the mapping governor => old bridge operator | ||
|
||
Proposal | ||
GlobalProposal | ||
when the nonce is invalid | ||
it should revert | ||
when the caller is not the governor | ||
it should verify signature with correct governor | ||
when the target is BridgeManager | ||
it should self call | ||
ProposalForCurrentNetwork | ||
when the nonce is invalid | ||
it should revert | ||
when the caller is not the governor | ||
when the calldata includes signature | ||
it should verify correct signature | ||
when the calldata not includes signature | ||
it should revert | ||
when the target is BridgeManager | ||
it should self call | ||
|
6 changes: 6 additions & 0 deletions
6
script/post-check/bridge-manager/PostCheck_BridgeManager.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
abstract contract PostCheck_BridgeManager { | ||
|
||
} |
Oops, something went wrong.