-
Notifications
You must be signed in to change notification settings - Fork 40
feat: improve address management in integration/ #106
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,8 @@ import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol"; | |
| import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
| import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; | ||
|
|
||
| import {VmSafe} from "forge-std/Vm.sol"; | ||
|
|
||
| contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | ||
| using SafeERC20 for IERC20; | ||
| using Math for uint256; | ||
|
|
@@ -51,8 +53,6 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| uint256 public SYMBIOTIC_CORE_MIN_OPERATOR_NETWORK_SHARES = 1000; | ||
| uint256 public SYMBIOTIC_CORE_MAX_OPERATOR_NETWORK_SHARES = 1e18; | ||
|
|
||
| address public SYMBIOTIC_CORE_OWNER = address(0); | ||
|
|
||
| SymbioticCoreConstants.Core public symbioticCore; | ||
|
|
||
| function run( | ||
|
|
@@ -78,22 +78,26 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| symbioticCore = SymbioticCoreConstants.core(); | ||
| } else { | ||
| // non-deterministic deployment (uses standard create) | ||
| (Vm.CallerMode callerMode,, address deployer) = vm.readCallers(); | ||
| if (callerMode != VmSafe.CallerMode.Broadcast) { | ||
|
||
| vm.startBroadcast(deployer); | ||
| } | ||
| ISymbioticVaultFactory vaultFactory = ISymbioticVaultFactory( | ||
| deployCode( | ||
| string.concat(SYMBIOTIC_CORE_PROJECT_ROOT, "out/VaultFactory.sol/VaultFactory.json"), | ||
| abi.encode(SYMBIOTIC_CORE_OWNER == address(0) ? address(this) : SYMBIOTIC_CORE_OWNER) | ||
| abi.encode(deployer) | ||
| ) | ||
| ); | ||
| ISymbioticDelegatorFactory delegatorFactory = ISymbioticDelegatorFactory( | ||
| deployCode( | ||
| string.concat(SYMBIOTIC_CORE_PROJECT_ROOT, "out/DelegatorFactory.sol/DelegatorFactory.json"), | ||
| abi.encode(SYMBIOTIC_CORE_OWNER == address(0) ? address(this) : SYMBIOTIC_CORE_OWNER) | ||
| abi.encode(deployer) | ||
| ) | ||
| ); | ||
| ISymbioticSlasherFactory slasherFactory = ISymbioticSlasherFactory( | ||
| deployCode( | ||
| string.concat(SYMBIOTIC_CORE_PROJECT_ROOT, "out/SlasherFactory.sol/SlasherFactory.json"), | ||
| abi.encode(SYMBIOTIC_CORE_OWNER == address(0) ? address(this) : SYMBIOTIC_CORE_OWNER) | ||
| abi.encode(deployer) | ||
| ) | ||
| ); | ||
| ISymbioticNetworkRegistry networkRegistry = ISymbioticNetworkRegistry( | ||
|
|
@@ -251,6 +255,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| operatorNetworkOptInService: operatorNetworkOptInService, | ||
| vaultConfigurator: vaultConfigurator | ||
| }); | ||
| if (callerMode != VmSafe.CallerMode.Broadcast) { | ||
| vm.stopBroadcast(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -277,7 +284,11 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| function _getVault_SymbioticCore( | ||
| address collateral | ||
| ) internal virtual returns (address) { | ||
| address owner = tx.origin; | ||
| (Vm.CallerMode callerMode,, address owner) = vm.readCallers(); | ||
| if (callerMode == VmSafe.CallerMode.Broadcast) { | ||
| vm.stopBroadcast(); | ||
| } | ||
|
|
||
| uint48 epochDuration = 7 days; | ||
| uint48 vetoDuration = 1 days; | ||
|
|
||
|
|
@@ -287,7 +298,7 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| operatorNetworkSharesSetRoleHolders[0] = owner; | ||
| (address vault,,) = _createVault_SymbioticCore({ | ||
| symbioticCore: symbioticCore, | ||
| who: tx.origin, | ||
| who: owner, | ||
| version: 1, | ||
| owner: owner, | ||
| vaultParams: abi.encode( | ||
|
|
@@ -327,6 +338,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| }) | ||
| ) | ||
| }); | ||
| if (callerMode == VmSafe.CallerMode.Broadcast) { | ||
| vm.startBroadcast(owner); | ||
| } | ||
|
|
||
| return vault; | ||
| } | ||
|
|
@@ -447,9 +461,13 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| ); | ||
| } | ||
|
|
||
| (Vm.CallerMode callerMode,, address deployer) = vm.readCallers(); | ||
| if (callerMode == VmSafe.CallerMode.Broadcast) { | ||
| vm.stopBroadcast(); | ||
| } | ||
| (address vault,,) = _createVault_SymbioticCore({ | ||
| symbioticCore: symbioticCore, | ||
| who: tx.origin, | ||
| who: deployer, | ||
| version: 1, | ||
| owner: owner, | ||
| vaultParams: vaultParams, | ||
|
|
@@ -465,6 +483,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| _setDepositorWhitelistStatus_SymbioticCore(owner, vault, whitelistedDepositors[i], true); | ||
| } | ||
| } | ||
| if (callerMode == VmSafe.CallerMode.Broadcast) { | ||
| vm.startBroadcast(deployer); | ||
| } | ||
|
|
||
| return vault; | ||
| } | ||
|
|
@@ -512,8 +533,12 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| } | ||
| uint64 slasherIndex = _randomPick_Symbiotic(slasherTypes); | ||
|
|
||
| return _getVault_SymbioticCore( | ||
| operators.length == 0 ? tx.origin : _randomPick_Symbiotic(operators), | ||
| (Vm.CallerMode callerMode,, address deployer) = vm.readCallers(); | ||
| if (callerMode == VmSafe.CallerMode.Broadcast) { | ||
| vm.stopBroadcast(); | ||
| } | ||
| address vault = _getVault_SymbioticCore( | ||
| operators.length == 0 ? deployer : _randomPick_Symbiotic(operators), | ||
| collateral, | ||
| 0x000000000000000000000000000000000000dEaD, | ||
| epochDuration, | ||
|
|
@@ -526,6 +551,10 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings { | |
| slasherIndex, | ||
| vetoDuration | ||
| ); | ||
| if (callerMode == VmSafe.CallerMode.Broadcast) { | ||
| vm.startBroadcast(deployer); | ||
| } | ||
| return vault; | ||
| } | ||
|
|
||
| function _vaultValidating_SymbioticCore(address vault, bytes32 subnetwork) internal virtual returns (bool) { | ||
|
|
||
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.
why did you regenerate these files?
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.
reverted these