Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion out/DelegatorFactory.sol/DelegatorFactory.json
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

reverted these

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/DelegatorHints.sol/BaseDelegatorHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/DelegatorHints.sol/FullRestakeDelegatorHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/DelegatorHints.sol/NetworkRestakeDelegatorHints.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/DelegatorHints.sol/OperatorSpecificDelegatorHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/FullRestakeDelegator.sol/FullRestakeDelegator.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/MetadataService.sol/MetadataService.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/NetworkRegistry.sol/NetworkRegistry.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/OperatorRegistry.sol/OperatorRegistry.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/OptInService.sol/OptInService.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/OptInServiceHints.sol/OptInServiceHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/Slasher.sol/Slasher.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/SlasherFactory.sol/SlasherFactory.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/SlasherHints.sol/BaseSlasherHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/SlasherHints.sol/SlasherHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/SlasherHints.sol/VetoSlasherHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/Vault.sol/Vault.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/VaultConfigurator.sol/VaultConfigurator.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/VaultFactory.sol/VaultFactory.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/VaultHints.sol/VaultHints.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/VaultTokenized.sol/VaultTokenized.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion out/VetoSlasher.sol/VetoSlasher.json

Large diffs are not rendered by default.

49 changes: 39 additions & 10 deletions script/integration/SymbioticCoreInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we need this condition?

  1. Why we should force broadcast? Maybe user doesn't want to broadcast
  2. Even if we want it's possible that mode is RecurrentBroadcast (https://getfoundry.sh/reference/cheatcodes/read-callers.html#description)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

  1. Honestly, I'm not sure what the case should be for this
  2. Fixed

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(
Expand Down Expand Up @@ -251,6 +255,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
operatorNetworkOptInService: operatorNetworkOptInService,
vaultConfigurator: vaultConfigurator
});
if (callerMode != VmSafe.CallerMode.Broadcast) {
vm.stopBroadcast();
}
}
}

Expand All @@ -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;

Expand All @@ -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(
Expand Down Expand Up @@ -327,6 +338,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
})
)
});
if (callerMode == VmSafe.CallerMode.Broadcast) {
vm.startBroadcast(owner);
}

return vault;
}
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
18 changes: 14 additions & 4 deletions script/integration/SymbioticInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,25 @@ contract SymbioticInit is Script, SymbioticCounter {
}

function _deal_Symbiotic(address token, address to, uint256 give) public virtual {
vm.startBroadcast(tx.origin);
(Vm.CallerMode callerMode,, address txOrigin) = vm.readCallers();
if (callerMode != VmSafe.CallerMode.Broadcast) {
vm.startBroadcast(txOrigin);
}
IERC20(token).safeTransfer(to, give);
vm.stopBroadcast();
if (callerMode != VmSafe.CallerMode.Broadcast) {
vm.stopBroadcast();
}
}

function _deal_Symbiotic(address to, uint256 give) public virtual {
vm.startBroadcast(tx.origin);
(Vm.CallerMode callerMode,, address txOrigin) = vm.readCallers();
if (callerMode != VmSafe.CallerMode.Broadcast) {
vm.startBroadcast(txOrigin);
}
to.call{value: give}("");
vm.stopBroadcast();
if (callerMode != VmSafe.CallerMode.Broadcast) {
vm.stopBroadcast();
}
}

function _vmWalletToAddress_Symbiotic(
Expand Down
7 changes: 4 additions & 3 deletions script/integration/examples/OnboardNetwork.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ contract OnboardNetworkScript is SymbioticCoreInit {

SYMBIOTIC_CORE_DELEGATOR_TYPES = [0, 2];

address NETWORK = tx.origin;
(,, address txOrigin) = vm.readCallers();
address NETWORK = txOrigin;
uint96 IDENTIFIER = 0;
bytes32 SUBNETWORK = NETWORK.subnetwork(IDENTIFIER);
address COLLATERAL = SymbioticCoreConstants.wstETH();
Expand All @@ -51,13 +52,13 @@ contract OnboardNetworkScript is SymbioticCoreInit {
super.run(seed);

if (COLLATERAL == SymbioticCoreConstants.wstETH()) {
uint256 balanceBefore = IERC20(COLLATERAL).balanceOf(tx.origin);
uint256 balanceBefore = IERC20(COLLATERAL).balanceOf(txOrigin);
uint256 requiredAmount = _normalizeForToken_Symbiotic(SYMBIOTIC_CORE_TOKENS_TO_SET_TIMES_1e18, COLLATERAL)
* SYMBIOTIC_CORE_NUMBER_OF_STAKERS;
if (balanceBefore < requiredAmount) {
address stETH = IwstETH(COLLATERAL).stETH();
uint256 toSend = IwstETH(COLLATERAL).getStETHByWstETH(requiredAmount - balanceBefore) * 101 / 100;
vm.startBroadcast(tx.origin);
vm.startBroadcast(txOrigin);
stETH.call{value: toSend}("");
IERC20(stETH).forceApprove(COLLATERAL, toSend);
IwstETH(COLLATERAL).wrap(toSend);
Expand Down
47 changes: 37 additions & 10 deletions test/integration/SymbioticCoreInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,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 setUp() public virtual override {
Expand All @@ -76,22 +74,26 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
symbioticCore = SymbioticCoreConstants.core();
} else {
// non-deterministic deployment (uses standard create)
(VmSafe.CallerMode callerMode,, address deployer) = vm.readCallers();
if (callerMode != VmSafe.CallerMode.Broadcast) {
vm.startPrank(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(
Expand Down Expand Up @@ -249,6 +251,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
operatorNetworkOptInService: operatorNetworkOptInService,
vaultConfigurator: vaultConfigurator
});
if (callerMode != VmSafe.CallerMode.Prank) {
vm.stopPrank();
}
}
}

Expand All @@ -275,7 +280,11 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
function _getVault_SymbioticCore(
address collateral
) internal virtual returns (address) {
address owner = address(this);
(Vm.CallerMode callerMode,, address owner) = vm.readCallers();
if (callerMode == VmSafe.CallerMode.Prank) {
vm.stopPrank();
}

uint48 epochDuration = 7 days;
uint48 vetoDuration = 1 days;

Expand All @@ -285,7 +294,7 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
operatorNetworkSharesSetRoleHolders[0] = owner;
(address vault,,) = _createVault_SymbioticCore({
symbioticCore: symbioticCore,
who: address(this),
who: owner,
version: 1,
owner: owner,
vaultParams: abi.encode(
Expand Down Expand Up @@ -325,6 +334,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
})
)
});
if (callerMode == VmSafe.CallerMode.Prank) {
vm.startPrank(owner);
}

return vault;
}
Expand Down Expand Up @@ -445,9 +457,13 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
);
}

(Vm.CallerMode callerMode,, address deployer) = vm.readCallers();
if (callerMode == VmSafe.CallerMode.Prank) {
vm.stopPrank();
}
(address vault,,) = _createVault_SymbioticCore({
symbioticCore: symbioticCore,
who: address(this),
who: deployer,
version: 1,
owner: owner,
vaultParams: vaultParams,
Expand All @@ -463,6 +479,9 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
_setDepositorWhitelistStatus_SymbioticCore(owner, vault, whitelistedDepositors[i], true);
}
}
if (callerMode == VmSafe.CallerMode.Prank) {
vm.startPrank(owner);
}

return vault;
}
Expand Down Expand Up @@ -510,8 +529,12 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
}
uint64 slasherIndex = _randomPick_Symbiotic(slasherTypes);

return _getVault_SymbioticCore(
operators.length == 0 ? address(this) : _randomPick_Symbiotic(operators),
(Vm.CallerMode callerMode,, address deployer) = vm.readCallers();
if (callerMode == VmSafe.CallerMode.Prank) {
vm.stopPrank();
}
address vault = _getVault_SymbioticCore(
operators.length == 0 ? deployer : _randomPick_Symbiotic(operators),
collateral,
0x000000000000000000000000000000000000dEaD,
epochDuration,
Expand All @@ -524,6 +547,10 @@ contract SymbioticCoreInit is SymbioticInit, SymbioticCoreBindings {
slasherIndex,
vetoDuration
);
if (callerMode == VmSafe.CallerMode.Prank) {
vm.startPrank(deployer);
}
return vault;
}

function _vaultValidating_SymbioticCore(address vault, bytes32 subnetwork) internal virtual returns (bool) {
Expand Down