Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
adding changes to checkout other branches
Browse files Browse the repository at this point in the history
  • Loading branch information
dd0sxx committed Aug 16, 2023
1 parent 96870d8 commit eb535c3
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"forceDisapprovalRoles": [],
"isFixedLengthApprovalPeriod": false,
"minApprovalPct": 0,
"minDisapprovalPct": 0,
"minDisapprovalPct": 10100,
"queuingPeriod": 0
}
],
Expand Down
113 changes: 113 additions & 0 deletions script/input/31337/mockProtocolInstanceConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"comment": "These addresses and IDs are what you get when you run the DeployLlama script test. The initialRoleDescriptions are expected to match those in the DeployLlama script.",
"factory": "0xDEb1E9a6Be7Baf84208BB6E10aC9F9bbE1D70809",
"instanceName": "Mock Protocol Llama",
"instanceColor": "#FF0420",
"instanceLogo": "<g fill='#FF0420'><path d='M44.876 462c-3.783 0-6.883-.881-9.3-2.645-2.384-1.794-3.576-4.344-3.576-7.65 0-.692.08-1.542.238-2.55.414-2.266 1.002-4.989 1.765-8.169C36.165 432.329 41.744 428 50.742 428c2.448 0 4.641.409 6.58 1.228 1.94.787 3.466 1.983 4.579 3.589 1.112 1.574 1.669 3.463 1.669 5.666 0 .661-.08 1.496-.239 2.503a106.077 106.077 0 0 1-1.716 8.169c-1.113 4.314-3.037 7.54-5.77 9.681-2.735 2.109-6.39 3.164-10.97 3.164Zm.668-6.8c1.78 0 3.29-.52 4.53-1.558 1.272-1.039 2.178-2.629 2.718-4.77.731-2.959 1.288-5.541 1.67-7.744.127-.661.19-1.338.19-2.031 0-2.865-1.51-4.297-4.53-4.297-1.78 0-3.307.519-4.578 1.558-1.24 1.039-2.13 2.629-2.671 4.77-.572 2.109-1.145 4.691-1.717 7.744-.127.63-.19 1.291-.19 1.983 0 2.897 1.526 4.345 4.578 4.345ZM68.409 461.528c-.35 0-.62-.11-.81-.331a1.12 1.12 0 0 1-.144-.85l6.581-30.694c.064-.347.239-.63.525-.85.286-.221.588-.331.906-.331h12.685c3.529 0 6.358.724 8.489 2.172 2.161 1.449 3.242 3.542 3.242 6.281 0 .787-.095 1.605-.286 2.455-.795 3.621-2.4 6.297-4.816 8.028-2.385 1.732-5.66 2.597-9.824 2.597h-6.438l-2.194 10.342a1.35 1.35 0 0 1-.524.85c-.287.221-.588.331-.907.331H68.41Zm16.882-18.039c1.335 0 2.495-.362 3.48-1.086 1.018-.724 1.686-1.763 2.004-3.117a8.185 8.185 0 0 0 .143-1.417c0-.913-.27-1.605-.81-2.077-.541-.504-1.463-.756-2.767-.756H81.62l-1.813 8.453h5.485ZM110.628 461.528c-.349 0-.62-.11-.81-.331-.191-.252-.255-.535-.191-.85l5.293-24.461h-8.488c-.35 0-.62-.11-.811-.33a1.12 1.12 0 0 1-.143-.851l1.097-5.052c.063-.347.238-.63.524-.85.286-.221.588-.331.906-.331h25.657c.35 0 .62.11.811.331.127.189.19.378.19.566a.909.909 0 0 1-.047.284l-1.097 5.052c-.064.347-.239.63-.525.851-.254.22-.556.33-.906.33h-8.441l-5.293 24.461c-.064.346-.239.63-.525.85-.286.221-.588.331-.906.331h-6.295ZM135.88 461.528c-.35 0-.62-.11-.811-.331a1.016 1.016 0 0 1-.191-.85l6.629-30.694a1.35 1.35 0 0 1 .525-.85c.286-.221.588-.331.906-.331h6.438c.349 0 .62.11.81.331.128.189.191.378.191.566a.882.882 0 0 1-.048.284l-6.581 30.694c-.063.346-.238.63-.524.85-.286.221-.588.331-.906.331h-6.438ZM154.038 461.528c-.349 0-.62-.11-.81-.331-.191-.22-.255-.504-.191-.85l6.581-30.694c.064-.347.238-.63.524-.85.287-.221.605-.331.954-.331h5.151c.763 0 1.255.346 1.478 1.039l5.198 14.875 11.588-14.875c.159-.252.382-.488.668-.708.318-.221.7-.331 1.145-.331h5.198c.349 0 .62.11.81.331.127.189.191.378.191.566a.882.882 0 0 1-.048.284l-6.581 30.694c-.063.346-.238.63-.524.85-.286.221-.588.331-.906.331h-5.771c-.349 0-.62-.11-.81-.331a1.118 1.118 0 0 1-.143-.85l3.719-17.425-7.296 9.586c-.318.347-.62.614-.906.803-.286.189-.62.283-1.002.283h-2.479c-.668 0-1.129-.362-1.383-1.086l-3.386-10.011-3.815 17.85c-.064.346-.239.63-.525.85-.286.221-.588.331-.906.331h-5.723ZM196.132 461.528c-.35 0-.62-.11-.81-.331-.191-.252-.255-.535-.191-.85l6.628-30.694a1.35 1.35 0 0 1 .525-.85c.285-.221.588-.331.906-.331h6.438c.35 0 .62.11.811.331.127.189.19.378.19.566a.88.88 0 0 1-.047.284l-6.581 30.694c-.063.346-.238.63-.525.85a1.46 1.46 0 0 1-.907.331h-6.437ZM226.07 462c-2.798 0-5.198-.378-7.201-1.133-1.972-.756-3.466-1.763-4.483-3.022-.986-1.26-1.479-2.661-1.479-4.203 0-.252.033-.63.095-1.134.065-.283.193-.519.383-.708.223-.189.476-.283.763-.283h6.103c.383 0 .668.063.859.188.222.126.445.347.668.662.223.818.731 1.495 1.526 2.03.827.535 1.955.803 3.385.803 1.812 0 3.276-.283 4.388-.85 1.113-.567 1.781-1.338 2.002-2.314a2.42 2.42 0 0 0 .048-.566c0-.788-.491-1.401-1.477-1.842-.986-.473-2.798-1.023-5.437-1.653-3.084-.661-5.421-1.653-7.011-2.975-1.589-1.354-2.383-3.117-2.383-5.289 0-.755.095-1.527.286-2.314.635-2.928 2.21-5.226 4.72-6.894 2.544-1.669 5.818-2.503 9.825-2.503 2.415 0 4.563.425 6.438 1.275 1.875.85 3.321 1.936 4.34 3.258 1.049 1.291 1.572 2.582 1.572 3.873 0 .377-.015.645-.047.802-.063.284-.206.52-.429.709a.975.975 0 0 1-.715.283h-6.391c-.698 0-1.176-.268-1.429-.803-.033-.724-.415-1.338-1.146-1.841-.731-.504-1.685-.756-2.861-.756-1.399 0-2.559.252-3.482.756-.889.503-1.447 1.243-1.668 2.219a3.172 3.172 0 0 0-.049.614c0 .755.445 1.385 1.336 1.889.922.472 2.528.96 4.816 1.464 3.562.692 6.153 1.684 7.774 2.975 1.653 1.29 2.479 3.006 2.479 5.147 0 .724-.095 1.511-.286 2.361-.698 3.211-2.4 5.651-5.103 7.32-2.669 1.636-6.246 2.455-10.729 2.455ZM248.515 461.528c-.35 0-.62-.11-.81-.331-.191-.22-.255-.504-.191-.85l6.581-30.694c.063-.347.238-.63.525-.85.286-.221.604-.331.954-.331h5.149c.763 0 1.256.346 1.479 1.039l5.199 14.875 11.587-14.875c.16-.252.382-.488.668-.708.318-.221.699-.331 1.144-.331h5.199c.35 0 .62.11.811.331.127.189.19.378.19.566a.856.856 0 0 1-.048.284l-6.58 30.694c-.065.346-.24.63-.526.85a1.456 1.456 0 0 1-.906.331h-5.769c-.351 0-.621-.11-.811-.331a1.109 1.109 0 0 1-.143-.85l3.719-17.425-7.296 9.586c-.318.347-.62.614-.906.803a1.776 1.776 0 0 1-1.001.283h-2.481c-.668 0-1.128-.362-1.382-1.086l-3.386-10.011-3.815 17.85a1.36 1.36 0 0 1-.525.85c-.286.221-.588.331-.906.331h-5.723Z'/></g>",
"strategyLogic": "0xA8452Ec99ce0C64f20701dB7dD3abDb607c00496",
"accountLogic": "0xDB8cFf278adCCF9E9b5da745B44E754fC4EE3C76",
"initialStrategies": [
{
"approvalPeriod": 172800,
"approvalRole": 1,
"disapprovalRole": 3,
"expirationPeriod": 691200,
"forceApprovalRoles": [],
"forceDisapprovalRoles": [],
"isFixedLengthApprovalPeriod": true,
"minApprovalPct": 4000,
"minDisapprovalPct": 5100,
"queuingPeriod": 345600
},
{
"approvalPeriod": 172800,
"approvalRole": 2,
"disapprovalRole": 3,
"expirationPeriod": 691200,
"forceApprovalRoles": [],
"forceDisapprovalRoles": [],
"isFixedLengthApprovalPeriod": true,
"minApprovalPct": 4000,
"minDisapprovalPct": 5100,
"queuingPeriod": 345600
},
{
"approvalPeriod": 172800,
"approvalRole": 2,
"disapprovalRole": 3,
"expirationPeriod": 86400,
"forceApprovalRoles": [1],
"forceDisapprovalRoles": [1],
"isFixedLengthApprovalPeriod": false,
"minApprovalPct": 8000,
"minDisapprovalPct": 10001,
"queuingPeriod": 0
},
{
"approvalPeriod": 0,
"approvalRole": 1,
"disapprovalRole": 1,
"expirationPeriod": 86400,
"forceApprovalRoles": [],
"forceDisapprovalRoles": [],
"isFixedLengthApprovalPeriod": false,
"minApprovalPct": 0,
"minDisapprovalPct": 1000,
"queuingPeriod": 691200
}
],
"initialAccounts": [
{
"name": "MP Treasury"
},
{
"name": "MP Grants"
}
],
"initialRoleDescriptions": [
"ActionCreator",
"Approver",
"Disapprover",
"ForceApprover",
"ForceDisapprover",
"TestRole1",
"TestRole2",
"MadeUpRole"
],
"initialRoleHolders": [
{
"comment": "This will assign role 1 to the address derived from `makeAddrAndKey('actionCreatorAaron')`. The role assignment is set to never expire (type(uint64).max) because this is the default. The quantity is likewise the default.",
"policyholder": "0x1f48298c8E770Efd59209fD5D893afAaA6BFf7Bf",
"expiration": 18446744073709551615,
"quantity": 1,
"role": 1
},
{
"comment": "This will assign role 2 to the llama's Llama instance's executor. The role assignment is set to never expire (type(uint64).max) because this is the default. The quantity is likewise the default.",
"policyholder": "0xC264c377642b946A57160d09FE5e35db06cbb526",
"expiration": 18446744073709551615,
"quantity": 1,
"role": 2
}
],
"initialRolePermissions": [
{
"comment": "This is just used for the DeployLlamaInstance test file. It gives the ActionCreator permission to call `transferERC20()` on the second account with the third strategy.",
"permissionData": {
"selector": "0x51288356",
"strategy": "0x9c7e3be11cB2f4D9A7fA0643D7b76569AF838782",
"target": "0x6aDaEfec2bC0ee7003e48320d4a346a6Be882950"
},
"role": 1
},
{
"comment": "This gives llama's executor permission to create actions for `setScriptAuthorization()` on mock protocol's core with the fourth strategy.",
"permissionData": {
"selector": "0x0a853184",
"strategy": "0x25B47aEb31b20254E2D8c1814E2648Aa1A68CCC3",
"target": "0x0845B312d2D91bD864FAb7C8B732783E81e6CAd4"
},
"role": 2
}
]
}
157 changes: 157 additions & 0 deletions test/integrations/MultipleInstance.integrations.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Test, console2} from "forge-std/Test.sol";

import {Vm} from "forge-std/Vm.sol";
import {stdJson} from "forge-std/Script.sol";

import {MockProtocol} from "test/mock/MockProtocol.sol";
import {MockScript} from "test/mock/MockScript.sol";

import {DeployLlamaFactory} from "script/DeployLlamaFactory.s.sol";
import {DeployLlamaInstance} from "script/DeployLlamaInstance.s.sol";
import {DeployUtils} from "script/DeployUtils.sol";

import {ILlamaAccount} from "src/interfaces/ILlamaAccount.sol";
import {ILlamaPolicyMetadata} from "src/interfaces/ILlamaPolicyMetadata.sol";
import {ILlamaStrategy} from "src/interfaces/ILlamaStrategy.sol";
import {ActionInfo, PermissionData, RoleHolderData} from "src/lib/Structs.sol";
import {RoleDescription} from "src/lib/UDVTs.sol";
import {LlamaCore} from "src/LlamaCore.sol";
import {LlamaExecutor} from "src/LlamaExecutor.sol";
import {LlamaPolicy} from "src/LlamaPolicy.sol";

contract MultipleInstanceTestSetup is DeployLlamaFactory, DeployLlamaInstance, Test {
address LLAMA_INSTANCE_DEPLOYER = 0x3d9fEa8AeD0249990133132Bb4BC8d07C6a8259a;
address llamaAlice;
uint256 llamaAlicePrivateKey;
address llamaBob;
uint256 llamaBobPrivateKey;
address llamaCharlie;
uint256 llamaCharliePrivateKey;
address llamaDale;
uint256 llamaDalePrivateKey;
address llamaErica;
uint256 llamaEricaPrivateKey;

LlamaCore llamaInstanceCore;
LlamaPolicy llamaInstancePolicy;
LlamaExecutor llamaInstanceExecutor;

LlamaCore mockCore;
LlamaPolicy mockPolicy;
LlamaExecutor mockExecutor;

function mineBlock() internal {
vm.roll(block.number + 1);
vm.warp(block.timestamp + 1);
}

function setUp() public virtual {
// Setting up user addresses and private keys.
(llamaAlice, llamaAlicePrivateKey) = makeAddrAndKey("llamaAlice");
(llamaBob, llamaBobPrivateKey) = makeAddrAndKey("llamaBob");
(llamaCharlie, llamaCharliePrivateKey) = makeAddrAndKey("llamaCharlie");
(llamaDale, llamaDalePrivateKey) = makeAddrAndKey("llamaDale");
(llamaErica, llamaEricaPrivateKey) = makeAddrAndKey("llamaErica");

// Deploy the factory
DeployLlamaFactory.run();

// Deploy llama's Llama instance
DeployLlamaInstance.run(LLAMA_INSTANCE_DEPLOYER, "llamaInstanceConfig.json");
llamaInstanceCore = core;
llamaInstancePolicy = llamaInstanceCore.policy();
llamaInstanceExecutor = llamaInstanceCore.executor();

// Deploy mock protocol's Llama instance
DeployLlamaInstance.run(LLAMA_INSTANCE_DEPLOYER, "mockProtocolInstanceConfig.json");
mockCore = core;
mockPolicy = mockCore.policy();
mockExecutor = mockCore.executor();

mineBlock();
}
}

contract InitialTest is MultipleInstanceTestSetup {
function test_InitiaXl() external {
// SCRIPT OPTIMIZATION

/*
1. Deploy llama and mock protocol instances
2. Mock instance needs to have some authorized GovernanceScript and reserve a role for llama with permission to
create actions for the functions on this
script with an optimistic and high approval strategy. The permissioning happens in the config but the script must be
authorized through an action.
3. The script will have a function that allows a call to setScriptAuthorization and to setRolePermission to the
governance maintenance role with one
of the two strategies, the script being authorized, any target.
4. Llama will deploy an upgrade contract and use a multisig like strategy to propose calling the governance script
with this as a parameter.
5. Now mock instance governance decides if they want to authorize this upgrade script, give llama the role
permission to propose calling it. The upgrade script
has the logic to unauthorize itself and remove all permissions after being called.
6. The action executes.
7. Llama proposes calling the script. The governance script forced llama to only have permission to make this
proposal with high buy in
8. Mock instance executes the action, the script is called, the script is unauthed and all permissions are removed. */

// BASE CASE

/*
1. Deploy llama and mock protocol instances ✅
2. Mock protocol instance config has a role reserved for llama with proposal permissions for setScriptAuthorization.
Proposal permission for calling the script
needs to be set after it's deployed. The execute function of the script will also remove the permission from the
role and unauth the script. The role
includes two permissions: one to setScriptAuthorization with a long optimistic timelock and the other with high buy
in shorter timelock. Mock also gives
llama permission to propose calling setRolePermission so they can propose to give themselves the proposal perission
to call the script.
3. Llama adds a permission to call createAction on the mock instance shortly after instance launches. This action
still needs to go through their governance
and can be canceled so a simple multisig like permission will suffice.
4. Llama deploys a script
5. The test starts with llama using either strategy to create, queue, execute calling setScriptAuth through mock's
createAction.
6. This goes through mock's governance with minimal input from them.
7. Once the script is authorized, llama then goes through their action process to call mock's createAction to give
themselves permission to call the script.
8. Once that's complete llama goes through their action process to call mock's createAction to execute the script
9. This requires high buy-in and when it executes it removes the permission to call it from the llama role and
unauthorizes the script
*/

// ARCHIVE
/*
1. Llama instance adds permission to role 1:
{
"comment": "This gives role #1 permission to call `createAction` on the mock protocol's core with the third
strategy.",
"permissionData": {
"selector": "0xb3c678b0",
"strategy": "0xa359FE9c585FbD6DAAEE4efF9c3bF6bd45D498bC",
"target": "0x0845B312d2D91bD864FAb7C8B732783E81e6CAd4"
},
"role": 1
}
2. Deploy script contract
3. llamaAlice calls createAction on llama instance to create action instantly on mock protocol
4. We test that the action creation, queueAction, executeAction can happen in the same block
5. Mock protocol gives llama instance a permission to create actions for (target: upgradeScript, strategy:
optimistic, target: authorizeScriptAndGivePermissionToCoreTeamToCall)
6. Optimistically passes so the mock protocol instance authorize the LlamaV1Upgrade script and role 1 has permission
to propose calling this newly created target's execute finction with the voting strategy
7. Core team member creates action to call upgrade with voting, LlamaV1Upgrade script, execute function
*/

bytes memory scriptCalldata = abi.encodeWithSignature("setScriptAuthorization(address,bool)", address(0), true);
console2.log(address(llamaInstanceExecutor));
vm.prank(address(llamaInstanceExecutor));
mockCore.createAction(
2, ILlamaStrategy(0x25B47aEb31b20254E2D8c1814E2648Aa1A68CCC3), address(mockCore), 0, scriptCalldata, "Hello"
);
}
}

0 comments on commit eb535c3

Please sign in to comment.