Skip to content

Commit

Permalink
feat: mode deployment (#35)
Browse files Browse the repository at this point in the history
* feat: mode deployment

* chore: add into ci downlaod of vyper

* feat: set evm version to cancun

* chore: set evm version to shangai

* chore:  remove specific evm version

* chore: add debug

* chore: debug in ci

* feat: upgrade vyper version to 0.3.10

* chore: update ci-deep

* chore: remove debug session from ci

* chore: update ci with vyper installed everywhere

* fix: right version of slither ci

* chore: try to skip test and scripts for slither

* chore: try slither without action

* chore: ignore compile and fail

* chore: change slither version
  • Loading branch information
0xtekgrinder authored Jun 13, 2024
1 parent 07a037f commit c16e2f0
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 87 deletions.
39 changes: 33 additions & 6 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,28 @@ jobs:
with:
submodules: "recursive"

- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Setup repo
uses: ./.github/actions/setup-repo
with:
registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }}

- name: Setup upterm session
uses: lhotari/action-upterm@v1

- name: Compile foundry
run: yarn compile --sizes

Expand All @@ -70,6 +87,7 @@ jobs:
path: |
cache-forge
out
node_modules
- name: "Add build summary"
run: |
Expand All @@ -92,6 +110,15 @@ jobs:
out
key: "build-${{ github.sha }}"

- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand Down Expand Up @@ -128,12 +155,12 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.0
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down Expand Up @@ -173,12 +200,12 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.0
run: pip install vyper==0.3.10


- name: Install Foundry
Expand Down
49 changes: 43 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ jobs:
with:
submodules: "recursive"

- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand Down Expand Up @@ -88,6 +97,15 @@ jobs:
node_modules
key: "build-${{ github.sha }}"

- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
Expand Down Expand Up @@ -125,12 +143,12 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.0
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down Expand Up @@ -171,12 +189,12 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.0
run: pip install vyper==0.3.10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down Expand Up @@ -205,6 +223,15 @@ jobs:
with:
submodules: "recursive"

- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.10

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

Expand Down Expand Up @@ -256,16 +283,26 @@ jobs:
with:
version: nightly

- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip' # caching pip dependencies

- name: Install viper
shell: bash
run: pip install vyper==0.3.10

- name: Compile foundry
run: forge build --build-info --force
run: forge build --build-info --skip */test/** */scripts/** --force

- name: "Run Slither analysis"
uses: "crytic/[email protected].0"
uses: "crytic/[email protected].2"
id: slither
with:
fail-on: "none"
sarif: "results.sarif"
ignore-compile: true
slither-version: "0.10.1"

- name: "Upload SARIF file to GitHub code scanning"
uses: "github/codeql-action/upload-sarif@v2"
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ polygonzkevm = "${ETH_NODE_URI_POLYGON_ZKEVM}"
bsc = "${ETH_NODE_URI_BSC}"
base = "${ETH_NODE_URI_BASE}"
linea = "${ETH_NODE_URI_LINEA}"

mode = "${ETH_NODE_URI_MODE}"

[etherscan]
arbitrum = { key = "${ARBITRUM_ETHERSCAN_API_KEY}" }
Expand Down
2 changes: 1 addition & 1 deletion lib/utils
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"url": "https://github.com/AngleProtocol/boilerplate/issues"
},
"devDependencies": {
"@angleprotocol/sdk": "^0.25.0",
"@layerzerolabs/lz-sdk": "^0.0.30",
"@angleprotocol/sdk": "^v2.10.2",
"@layerzerolabs/lz-sdk": "^0.0.75",
"discord.js": "^14.14.1",
"prettier": "^2.0.0",
"prettier-plugin-solidity": "^1.1.3",
Expand Down
37 changes: 1 addition & 36 deletions scripts/Utils.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,14 @@ import "./Constants.s.sol";
/// @title Utils
/// @author Angle Labs, Inc.
contract Utils is Script, CommonUtils {
mapping(uint256 => uint256) internal forkIdentifier;
uint256 public arbitrumFork;
uint256 public avalancheFork;
uint256 public ethereumFork;
uint256 public optimismFork;
uint256 public polygonFork;
uint256 public gnosisFork;
uint256 public bnbFork;
uint256 public celoFork;
uint256 public polygonZkEVMFork;
uint256 public baseFork;
uint256 public lineaFork;

bytes[] private calldatas;
string private description;
address[] private targets;
uint256[] private values;
uint256[] private chainIds;

function setUp() public virtual {
arbitrumFork = vm.createFork(vm.envString("ETH_NODE_URI_ARBITRUM"));
avalancheFork = vm.createFork(vm.envString("ETH_NODE_URI_AVALANCHE"));
ethereumFork = vm.createFork(vm.envString("ETH_NODE_URI_MAINNET"));
optimismFork = vm.createFork(vm.envString("ETH_NODE_URI_OPTIMISM"));
polygonFork = vm.createFork(vm.envString("ETH_NODE_URI_POLYGON"));
gnosisFork = vm.createFork(vm.envString("ETH_NODE_URI_GNOSIS"));
bnbFork = vm.createFork(vm.envString("ETH_NODE_URI_BSC"));
celoFork = vm.createFork(vm.envString("ETH_NODE_URI_CELO"));
polygonZkEVMFork = vm.createFork(vm.envString("ETH_NODE_URI_POLYGON_ZKEVM"));
baseFork = vm.createFork(vm.envString("ETH_NODE_URI_BASE"));
lineaFork = vm.createFork(vm.envString("ETH_NODE_URI_LINEA"));

forkIdentifier[CHAIN_ARBITRUM] = arbitrumFork;
forkIdentifier[CHAIN_AVALANCHE] = avalancheFork;
forkIdentifier[CHAIN_ETHEREUM] = ethereumFork;
forkIdentifier[CHAIN_OPTIMISM] = optimismFork;
forkIdentifier[CHAIN_POLYGON] = polygonFork;
forkIdentifier[CHAIN_GNOSIS] = gnosisFork;
forkIdentifier[CHAIN_BNB] = bnbFork;
forkIdentifier[CHAIN_CELO] = celoFork;
forkIdentifier[CHAIN_POLYGONZKEVM] = polygonZkEVMFork;
forkIdentifier[CHAIN_BASE] = baseFork;
forkIdentifier[CHAIN_LINEA] = lineaFork;
setUpForks();
}

function _deserializeJson()
Expand Down
18 changes: 10 additions & 8 deletions scripts/deployment/DeploySideChainGovernance.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,29 @@ contract DeploySideChainGovernance is Utils {
TimelockControllerWithCounter public timelock;

function run() external {
uint256 deployerPrivateKey = vm.deriveKey(vm.envString("MNEMONIC_POLYGON"), "m/44'/60'/0'/0/", 0);
uint256 deployerPrivateKey = vm.deriveKey(vm.envString("MNEMONIC_MAINNET"), "m/44'/60'/0'/0/", 0);
vm.startBroadcast(deployerPrivateKey);
address deployer = vm.addr(deployerPrivateKey);
vm.label(deployer, "Deployer");

// TODO can be modified to deploy on any chain
uint256 srcChainId = CHAIN_ETHEREUM;
uint256 destChainId = CHAIN_LINEA;
uint256 destChainId = CHAIN_MODE;
address destSafeMultiSig = 0x7DE8289038DF0b89FFEC71Ee48a2BaD572549027; // guardian
// END

address destSafeMultiSig = _chainToContract(destChainId, ContractType.GuardianMultisig);
ProposalSender proposalSender = ProposalSender(_chainToContract(srcChainId, ContractType.ProposalSender));
// Deploy relayer receiver and Timelock on end chain
address[] memory proposers = new address[](0);
address[] memory executors = new address[](1);
executors[0] = destSafeMultiSig; // Means everyone can execute
executors[0] = address(0); // Means everyone can execute

timelock = new TimelockControllerWithCounter(timelockDelay, proposers, executors, deployer);
console.log("Timelock address: ", address(timelock));

proposalReceiver = new ProposalReceiver(address(_lzEndPoint(destChainId)));
console.log("ProposalReceiver address: ", address(proposalReceiver));

// timelock = new TimelockControllerWithCounter(timelockDelay, proposers, executors, deployer);
// proposalReceiver = new ProposalReceiver(address(_lzEndPoint(destChainId)));
timelock = TimelockControllerWithCounter(payable(0xd23B51d6F2cB3eC7ca9599D4332a2F10C3CFDF85));
proposalReceiver = ProposalReceiver(payable(0x4A44f77978Daa3E92Eb3D97210bd11645cF935Ab));
timelock.grantRole(timelock.PROPOSER_ROLE(), address(proposalReceiver));
timelock.grantRole(timelock.CANCELLER_ROLE(), destSafeMultiSig);
timelock.renounceRole(timelock.DEFAULT_ADMIN_ROLE(), deployer);
Expand Down
22 changes: 11 additions & 11 deletions test/external/veANGLE.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @version 0.3.0
# @version 0.3.10
"""
@title Voting Escrow
@author Angle Protocol
Expand Down Expand Up @@ -138,7 +138,7 @@ def initialize(_admin: address, token_addr: address, _smart_wallet_checker: addr
"""
assert self.initialized == False #dev: contract is already initialized
self.initialized = True
assert _admin!= ZERO_ADDRESS #dev: admin cannot be the 0 address
assert _admin!= empty(address) #dev: admin cannot be the 0 address
self.admin = _admin
self.token = token_addr
self.smart_wallet_checker = _smart_wallet_checker
Expand All @@ -160,7 +160,7 @@ def commit_transfer_ownership(addr: address):
@param addr Address to have ownership transferred to
"""
assert msg.sender == self.admin # dev: admin only
assert addr != ZERO_ADDRESS # dev: future admin cannot be the 0 address
assert addr != empty(address) # dev: future admin cannot be the 0 address
self.future_admin = addr
log CommitOwnership(addr)

Expand All @@ -182,7 +182,7 @@ def apply_transfer_ownership():
"""
assert msg.sender == self.admin # dev: admin only
_admin: address = self.future_admin
assert _admin != ZERO_ADDRESS # dev: admin not set
assert _admin != empty(address) # dev: admin not set
self.admin = _admin
log ApplyOwnership(_admin)

Expand Down Expand Up @@ -214,7 +214,7 @@ def assert_not_contract(addr: address):
"""
if addr != tx.origin:
checker: address = self.smart_wallet_checker
if checker != ZERO_ADDRESS:
if checker != empty(address):
if SmartWalletChecker(checker).check(addr):
return
raise "Smart contract depositors not allowed"
Expand Down Expand Up @@ -269,14 +269,14 @@ def _checkpoint(addr: address, old_locked: LockedBalance, new_locked: LockedBala
new_dslope: int128 = 0
_epoch: uint256 = self.epoch

if addr != ZERO_ADDRESS:
if addr != empty(address):
# Calculate slopes and biases
# Kept at zero when they have to
if old_locked.end > block.timestamp and old_locked.amount > 0:
u_old.slope = old_locked.amount / MAXTIME
u_old.slope = old_locked.amount / convert(MAXTIME, int128)
u_old.bias = u_old.slope * convert(old_locked.end - block.timestamp, int128)
if new_locked.end > block.timestamp and new_locked.amount > 0:
u_new.slope = new_locked.amount / MAXTIME
u_new.slope = new_locked.amount / convert(MAXTIME, int128)
u_new.bias = u_new.slope * convert(new_locked.end - block.timestamp, int128)

# Read values of scheduled changes in the slope
Expand Down Expand Up @@ -333,7 +333,7 @@ def _checkpoint(addr: address, old_locked: LockedBalance, new_locked: LockedBala
self.epoch = _epoch
# Now point_history is filled until t=now

if addr != ZERO_ADDRESS:
if addr != empty(address):
# If last point was in this block, the slope change has been applied already
# But in such case we have 0 slope(s)
last_point.slope += (u_new.slope - u_old.slope)
Expand All @@ -346,7 +346,7 @@ def _checkpoint(addr: address, old_locked: LockedBalance, new_locked: LockedBala
# Record the changed point into history
self.point_history[_epoch] = last_point

if addr != ZERO_ADDRESS:
if addr != empty(address):
# Schedule the slope changes (slope is going down)
# We subtract new_user_slope from [new_locked.end]
# and add old_user_slope to [old_locked.end]
Expand Down Expand Up @@ -410,7 +410,7 @@ def checkpoint():
"""
@notice Record global data to checkpoint
"""
self._checkpoint(ZERO_ADDRESS, empty(LockedBalance), empty(LockedBalance))
self._checkpoint(empty(address), empty(LockedBalance), empty(LockedBalance))


@external
Expand Down
Loading

0 comments on commit c16e2f0

Please sign in to comment.