Skip to content
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

Balancer Contract Registry initialization contract #1327

Merged
merged 64 commits into from
Mar 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a062f77
feat: add getters for pool creator data, and explicit pool registrati…
EndymionJkb Feb 16, 2025
529ac79
feat: add governance-scripts package
EndymionJkb Feb 16, 2025
b058b23
feat: add protocol fee controller migration
EndymionJkb Feb 16, 2025
b30b537
refactor: don't pass in pool creator to initialize
EndymionJkb Feb 16, 2025
7d76bc8
feat: add governance scripts package
EndymionJkb Feb 17, 2025
14f7b65
feat: add governance-scripts package
EndymionJkb Feb 17, 2025
cd28a11
feat: add registry initializer
EndymionJkb Feb 17, 2025
1de3809
refactor: set variables lol
EndymionJkb Feb 17, 2025
eed79d8
refactor: remove directory that generates strange errors
EndymionJkb Feb 17, 2025
33ce5e6
refactor: remove redundant (and problematic) `_poolCreators` storage
EndymionJkb Feb 17, 2025
ab3df83
refactor: remove unused error
EndymionJkb Feb 17, 2025
395c7bc
refactor: don't collect and withdraw fees
EndymionJkb Feb 17, 2025
8d4409d
feat: add explicit pool registration and new pool creator event
EndymionJkb Feb 17, 2025
71b466b
test: add tests for new features
EndymionJkb Feb 17, 2025
42be536
docs: update migration comments for simple one
EndymionJkb Feb 17, 2025
ccae6fd
feat: add registerInMigration helper
EndymionJkb Feb 17, 2025
22102e1
test: add tests for new migration function
EndymionJkb Feb 17, 2025
01a081c
feat: add level 2 migration contract
EndymionJkb Feb 17, 2025
7ebb82f
refactor: simplify to pass old fee controller instead of the values (…
EndymionJkb Feb 18, 2025
a7999dd
test: new migration interface
EndymionJkb Feb 18, 2025
746a210
refactor: reuse original migration functions
EndymionJkb Feb 18, 2025
dff7d50
refactor: rename migration function
EndymionJkb Feb 18, 2025
f8e9652
refactor: add migration role
EndymionJkb Feb 18, 2025
57d48d2
refactor: simplify migrations
EndymionJkb Feb 18, 2025
da0e2b9
refactor: simplify migratePool
EndymionJkb Feb 18, 2025
c00dccc
lint
EndymionJkb Feb 18, 2025
90adc71
refactor: don't need FixedPoint
EndymionJkb Feb 18, 2025
570a075
test: adjust to new migration signature
EndymionJkb Feb 18, 2025
56d791d
test: remove unnecessary pool creator storage from fee controller
EndymionJkb Feb 18, 2025
25b8162
refactor: make virtual in case we need a v3 someday
EndymionJkb Feb 18, 2025
ecb07f0
Merge branch 'main' into fee-controller-script
EndymionJkb Feb 18, 2025
e7c6149
refactor: move basic authorizer
EndymionJkb Feb 18, 2025
c735ec2
refactor: complete move of basic authorizer
EndymionJkb Feb 18, 2025
3b04170
Merge branch 'main' into fee-controller-script
EndymionJkb Feb 18, 2025
c4639be
feat: new protocol fee controller, suitable for migrations
EndymionJkb Feb 19, 2025
4da42c5
test: update tests for new functions
EndymionJkb Feb 19, 2025
c4324fb
refactor: remove pool creator from ProtocolFeeControllerMock
EndymionJkb Feb 19, 2025
0a5c484
chore: update bytecode
EndymionJkb Feb 19, 2025
ebae2ab
chore: update gas
EndymionJkb Feb 19, 2025
7793e6d
docs: fix comments and decrease diffs
EndymionJkb Feb 19, 2025
c1be315
Merge branch 'protocol-fee-controller-v2' into fee-controller-script
EndymionJkb Feb 19, 2025
0e8bd5a
test: adjust tests for fee controller pool creator
EndymionJkb Feb 19, 2025
84f0b1e
Merge branch 'protocol-fee-controller-v2' into fee-controller-script
EndymionJkb Feb 19, 2025
cde1d1e
refactor: remove unnecessary import
EndymionJkb Feb 19, 2025
2f14d8b
Merge branch 'protocol-fee-controller-v2' into fee-controller-script
EndymionJkb Feb 19, 2025
27da6d2
Merge branch 'main' into protocol-fee-controller-v2
EndymionJkb Feb 19, 2025
d52eb97
Merge branch 'protocol-fee-controller-v2' into fee-controller-script
EndymionJkb Feb 19, 2025
d357568
Merge branch 'main' into registry-script
EndymionJkb Feb 19, 2025
af318e8
Merge branch 'main' into fee-controller-script
EndymionJkb Feb 20, 2025
b62843d
refactor: migratePools is now permissionless
EndymionJkb Feb 20, 2025
1510a2d
Merge branch 'main' into fee-controller-script
EndymionJkb Feb 21, 2025
9eff06c
temp: to accommodate fork tests, allow the fee controller to be set l…
EndymionJkb Feb 21, 2025
2086a6b
refactor: reduce to a single migration script
EndymionJkb Feb 22, 2025
e3dae99
refactor: tolerate missing pool creator fee percentage getters
EndymionJkb Feb 22, 2025
7a33dd2
Merge branch 'protocol-fee-controller-v3' into fee-controller-script
EndymionJkb Feb 22, 2025
940dcaa
docs: clarify comments
EndymionJkb Feb 22, 2025
b1edecc
Merge branch 'main' into fee-controller-script
EndymionJkb Feb 28, 2025
991f2d7
remove temporary debugging code
EndymionJkb Feb 28, 2025
40c3745
Merge branch 'main' into registry-script
EndymionJkb Mar 4, 2025
c208be5
Merge branch 'fee-controller-script' into registry-script
EndymionJkb Mar 4, 2025
5c361a3
update authorizer interface reference
EndymionJkb Mar 4, 2025
1e82427
refactor: naming conventions
EndymionJkb Mar 5, 2025
fab0d6b
lint
EndymionJkb Mar 5, 2025
05183db
Merge branch 'main' into registry-script
EndymionJkb Mar 8, 2025
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
Prev Previous commit
Next Next commit
feat: add governance-scripts package
EndymionJkb committed Feb 17, 2025
commit 14f7b6593e8b360ee514c305fefa4bfb256292d5
17 changes: 17 additions & 0 deletions pkg/governance-scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# <img src="../../logo.svg" alt="Balancer" height="128px">

# Balancer V3 Governance Scripts

In order to manage the Balancer protocol, Balancer DAO must sometimes execute somewhat complex sets of actions which if executed incorrectly could result in governance losing control of key powers over the protocol, opening up vulnerabilities by granting powerful permissions improperly, etc.

In order to prevent this, complex governance actions may be enacted through script contracts. These have a number of benefits over performing actions directly through the multisig wallet.

- The contract can be easily tested prior to the execution on mainnet to ensure that it produces the correct result.
- It's much simpler to verify the behavior of Solidity code matches the proposal specification relative to a series of raw function calls.
- The contract may only be triggered once, ensuring that any powers granted to it can't be used in future for another purpose unilaterally.

This package contains the source code for these script contracts to form a record of major technical actions Balancer DAO has taken.

## Licensing

[GNU General Public License Version 3 (GPL v3)](../../LICENSE).
48 changes: 48 additions & 0 deletions pkg/governance-scripts/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[profile.default]
src = 'contracts'
out = 'forge-artifacts'
libs = ['node_modules']
test = 'test/foundry'
cache_path = 'forge-cache'
allow_paths = ['../', '../../node_modules/']
ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}]
remappings = [
'vault/=../vault/',
'pool-weighted/=../pool-weighted/',
'solidity-utils/=../solidity-utils/',
'ds-test/=../../node_modules/forge-std/lib/ds-test/src/',
'forge-std/=../../node_modules/forge-std/src/',
'@openzeppelin/=../../node_modules/@openzeppelin/',
'permit2/=../../node_modules/permit2/',
'@balancer-labs/=../../node_modules/@balancer-labs/',
'forge-gas-snapshot/=../../node_modules/forge-gas-snapshot/src/'
]
optimizer = true
optimizer_runs = 999
solc_version = '0.8.26'
auto_detect_solc = false
evm_version = 'cancun'
ignored_error_codes = [2394, 5574, 3860] # Transient storage, code size
allow_internal_expect_revert = true

[fuzz]
runs = 10000
max_test_rejects = 60000

[profile.forkfuzz.fuzz]
runs = 1000
max_test_rejects = 60000

[profile.coverage.fuzz]
runs = 100
max_test_rejects = 60000

[profile.intense.fuzz]
verbosity = 3
runs = 100000
max_test_rejects = 600000

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
sepolia = "${SEPOLIA_RPC_URL}"
20 changes: 20 additions & 0 deletions pkg/governance-scripts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { HardhatUserConfig } from 'hardhat/config';
import { hardhatBaseConfig } from '@balancer-labs/v3-common';

import '@nomicfoundation/hardhat-toolbox';
import '@nomicfoundation/hardhat-ethers';
import '@typechain/hardhat';

import 'hardhat-ignore-warnings';
import 'hardhat-gas-reporter';
import 'hardhat-contract-sizer';
import { warnings } from '@balancer-labs/v3-common/hardhat-base-config';

const config: HardhatUserConfig = {
solidity: {
compilers: hardhatBaseConfig.compilers,
},
warnings,
};

export default config;
48 changes: 48 additions & 0 deletions pkg/governance-scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@balancer-labs/v3-governance-scripts",
"version": "0.1.0",
"description": "V3 Governance Scripts",
"license": "GPL-3.0-only",
"homepage": "https://github.com/balancer-labs/balancer-v3-monorepo/tree/master/pkg/governance-scripts#readme",
"repository": {
"type": "git",
"url": "https://github.com/balancer-labs/balancer-v3-monorepo.git",
"directory": "pkg/governance-scripts"
},
"bugs": {
"url": "https://github.com/balancer-labs/balancer-v3-monorepo/issues"
},
"files": [
"contracts/**/*"
],
"scripts": {
"build": "yarn compile && rm -rf artifacts/build-info",
"compile": "hardhat compile",
"compile:watch": "nodemon --ext sol --exec yarn compile",
"lint": "yarn lint:solidity && yarn lint:typescript",
"lint:solidity": "npx prettier --check --plugin=prettier-plugin-solidity 'contracts/**/*.sol' || npx solhint 'contracts/**/*.sol'",
"lint:typescript": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ../../.eslintignore --max-warnings 0",
"prettier": "npx prettier --write --plugin=prettier-plugin-solidity 'contracts/**/*.sol'",
"slither": "yarn compile --force && bash -c 'source ../../slither/bin/activate && slither --compile-force-framework hardhat --ignore-compile . --config-file ../../.slither.config.json'",
"slither:triage": "yarn compile && bash -c 'source ../../slither/bin/activate && slither --compile-force-framework hardhat --ignore-compile . --config-file ../../.slither.config.json --triage-mode'"
},
"devDependencies": {
"@balancer-labs/solidity-toolbox": "workspace:*",
"@types/lodash": "^4.14.186",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"decimal.js": "^10.4.2",
"eslint": "^8.26.0",
"eslint-plugin-mocha-no-only": "^1.1.1",
"eslint-plugin-prettier": "^4.2.1",
"hardhat": "^2.21.0",
"lodash.frompairs": "^4.0.1",
"lodash.pick": "^4.4.0",
"lodash.range": "^3.2.0",
"lodash.times": "^4.3.2",
"lodash.zip": "^4.2.0",
"mocha": "^10.1.0",
"nodemon": "^2.0.20",
"solhint": "^3.4.1"
}
}
6 changes: 6 additions & 0 deletions pkg/governance-scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
}
}