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

feat: code-based instance configuration support #492

Merged
merged 42 commits into from
Nov 9, 2023

Conversation

AustinGreen
Copy link
Contributor

@AustinGreen AustinGreen commented Oct 19, 2023

Motivation:

Code-based instance configurations serve as an alternative to our standard JSON-based instance configuration. JSON-based configs will work in most use cases but they are limited when a more advanced setup is required. Code-based configs use the power of llama scripts to enable features such as creating strategies or accounts with multiple logic contracts and creating permissions based on dynamic conditions (e.g. deploying a guard and then using the deployed address as the target address).

User flow:

  • Deployer calls just deploy-instance using something like advancedInstanceConfig.json as the config file (required to have instant execution strategy as the first strategy and role 1 assigned to deployer)
  • Deployer creates a contract similar to src/llama-scripts/LlamaInstanceConfigScriptTemplate.sol and inherits from LlamaInstanceConfigBase. Contract is deployed and address is used in next step.
  • Deployer adds correct parameters to run-configure-advanced-instance-script in the justfile and calls just configure-advanced-instance

Modifications:

  • Added a ConfigureAdvancedLlamaInstance.s.sol script that can be run for an instance deployed using an advanced configuration (instant execution strategy on setRolePermission with a single policyholder).
  • This script authorizes and executes LlamaInstanceConfigScript.sol which can be edited to describe the instance configuration using code. It also includes the post configuration cleanup that removes any trace of the config bot.
  • Added tests
  • Added a justfile command and documentation

Result:

Instances can be deployed using a standard JSON-based configuration or an advanced code-based configuration.

@AustinGreen
Copy link
Contributor Author

foundry-rs/foundry#5776 is something we should be tracking so that we can simplify our advanced script. Ideally it should do all the following:

  1. Deploy the LlamaInstanceConfig script and get its address
  2. Deploy the llama instance with permissions for the LlamaInstanceConfig script pre-assigned (i.e setScriptAuthorization and LlamaInstanceConfig.execute). The only reason we're not doing it currently is because we don't know the target address yet (i.e the LlamaInstanceConfig script). But in this approach we will know what it is and can just use DeployUtils to set up the initial deploy.
  3. Create an action to setScriptAuthorization and execute it.
  4. Create an action to call LlamaInstanceConfig.execute and execute it.

Yeah I agree. If you look at past commits this was my initial approach. That being said I think this works fine for now and doesn't have any downside besides needing to run two scripts instead of one.

dd0sxx
dd0sxx previously approved these changes Nov 9, 2023
Copy link
Contributor

@dd0sxx dd0sxx left a comment

Choose a reason for hiding this comment

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

looks great!

justfile Show resolved Hide resolved
script/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@0xrajath 0xrajath left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

github-actions bot commented Nov 9, 2023

Coverage after merging austin/code-based-deployments into main will be

84.62%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   LlamaCore.sol99.31%97.44%100%100%299, 399
   LlamaExecutor.sol80%50%100%100%33
   LlamaFactory.sol100%100%100%100%
   LlamaLens.sol72.09%20%100%82.61%174–175, 178, 178, 178–179, 179, 179–180, 180, 180, 188
   LlamaPolicy.sol91.53%88.89%94.59%91.38%353, 392, 392, 392–394, 394, 394, 396–399, 401, 419
   LlamaPolicyMetadata.sol100%100%100%100%
src/accounts
   LlamaAccount.sol100%100%100%100%
src/lib
   ERC721NonTransferableMinimalProxy.sol70.42%72.73%72.73%68.42%102, 104, 106, 118–120, 190, 88, 88, 88, 90, 90, 90, 92, 92, 92, 97, 99
   LlamaUtils.sol100%100%100%100%
   PolicyholderCheckpoints.sol55.88%50%81.82%53.62%130, 184–186, 186, 186–187, 189, 192, 222, 229, 229–231, 233, 233–235, 237, 237–239, 241, 241–243, 262, 265–271, 278, 46, 46–48, 48, 48–49, 51
   SupplyCheckpoints.sol57.14%50%83.33%54.93%131, 183–185, 185, 185–186, 188, 191, 235, 242, 242–244, 246, 246–248, 250, 250–252, 254, 254–256, 275, 278–284, 291, 50, 50–52, 52, 52–53, 55
src/llama-scripts
   LlamaGovernanceScript.sol50%33.33%43.75%53.45%107–108, 120–122, 132–134, 146–149, 159–161, 176–180, 190–191, 203–205, 71, 78, 78, 80, 96–97
   LlamaInstanceConfigBase.sol100%100%100%100%
   LlamaInstanceConfigScriptTemplate.sol100%100%100%100%
src/strategies/absolute
   LlamaAbsolutePeerReview.sol100%100%100%100%
   LlamaAbsoluteQuorum.sol100%100%100%100%
   LlamaAbsoluteStrategyBase.sol94.81%87.50%90.91%98%248, 251, 301
src/strategies/relative
   LlamaRelativeHolderQuorum.sol91.67%75%100%100%52, 59
   LlamaRelativeQuantityQuorum.sol0%0%0%0%28, 28, 28–30, 42, 42, 42–44, 51–52, 52, 52–53, 58–59, 59, 59–60
   LlamaRelativeStrategyBase.sol97.62%90.91%100%100%208, 310
   LlamaRelativeUniqueHolderQuorum.sol93.33%83.33%100%100%54, 61

@AustinGreen AustinGreen merged commit 17a6779 into main Nov 9, 2023
5 checks passed
@AustinGreen AustinGreen deleted the austin/code-based-deployments branch November 9, 2023 21:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants