Skip to content

Commit

Permalink
chore: switched to eth-ape
Browse files Browse the repository at this point in the history
  • Loading branch information
stas committed Dec 20, 2024
1 parent ce78d39 commit f883873
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
run: docker build ./ -t velodrome/sugar

- name: Runs code QA and tests
run: docker run --rm --env-file=env.${{ matrix.chain }} -v $(pwd):/app -w /app -t velodrome/sugar sh -c 'flake8 && brownie test --network=${{ matrix.chain }}-main'
run: docker run --rm --env-file=deployments/${{ matrix.chain }}.env -w /app -t velodrome/sugar sh -c 'python -m black . && ape test --network ${{ matrix.chain }}:mainnet:node --disable-isolation'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ __pycache__
.env
.history
.hypothesis/
build/
.build/
reports/
22 changes: 7 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
FROM python:3.10-alpine
FROM ghcr.io/apeworx/ape:latest-slim

RUN apk add --no-cache \
git npm build-base linux-headers python3-dev tk libc6-compat gcompat cargo

RUN npm install -g ganache
USER root

COPY . /app
WORKDIR /app

RUN pip install "cython<3.0.0" && pip install --no-build-isolation pyyaml==5.4.1
RUN pip install -r requirements.txt

RUN brownie networks modify optimism-test host=https://sepolia.optimism.io
RUN brownie networks modify optimism-main host=https://optimism-mainnet.wallet.coinbase.com

RUN brownie networks modify base-main host=https://mainnet.base.org
# TODO: move this into an ENV or sort of...
RUN python -c 'import vvm; vvm.install_vyper("0.4.0", True)'
RUN ape pm install
RUN ape pm compile

RUN brownie networks add Bob bob-main host=https://rpc.gobob.xyz chainid=60808
RUN brownie networks add Mode mode-main host=https://mainnet.mode.network chainid=34443
RUN brownie networks add Lisk lisk-main host=https://lisk.drpc.org chainid=1135
RUN brownie networks add Fraxtal fraxtal-main host=https://rpc.frax.com chainid=252
RUN brownie networks add MetalL2 metall2-main host=https://rpc.metall2.com chainid=1750
ENTRYPOINT []
35 changes: 35 additions & 0 deletions ape-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Sugar

vyper:
evm_version: cancun

dependencies:
- name: snekmate
github: pcaversaccio/snekmate
version: 0.1.0

networks:
custom:
- name: mainnet
ecosystem: mode
chain_id: 34443
- name: mainnet
ecosystem: lisk
chain_id: 1135
- name: mainnet
ecosystem: metall2
chain_id: 1750

node:
mode:
mainnet:
uri: https://mode.drpc.org
lisk:
mainnet:
uri: https://lisk.drpc.org
metall2:
mainnet:
uri: https://metall2.drpc.org
optimism:
mainnet:
uri: https://optimism-mainnet.wallet.coinbase.com
13 changes: 0 additions & 13 deletions brownie-config.yaml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,21 @@ docker build ./ -t velodrome/sugar

Next start the container with existing environment variables:
```sh
docker run --env-file=env.{{chain}} --rm -v $(pwd):/app -w /app -it velodrome/sugar sh
docker run --env-file=deployments/{{chain}}.env --rm -v $(pwd):/app -w /app -it velodrome/sugar sh
```
The environment has Brownie and Vyper already installed.

To run the tests inside the container, use:
```sh
brownie test --network={{chain}}-test
ape test --network={{chain}}:mainnet:node
```

## Releases

This repository is used to manage the releases for multiple chains.

The latest deployed contracts can be found in the `env.{{chain}}` files in the
root of the repository.
The latest deployed contracts can be found in the `deployments/{{chain}}.env`
files in the root of the repository.

## Why the contracts are not verified?

Expand Down
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
eth-brownie @ git+https://github.com/velodrome-finance/[email protected]
vyper==0.4.0
flake8
eth-ape
ape-vyper
ape-etherscan

black
84 changes: 44 additions & 40 deletions scripts/deploy.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
# SPDX-License-Identifier: BUSL-1.1
import os

from brownie import (
accounts, VeSugar, LpSugar, RelaySugar, FactoryRegistry, RewardsSugar
)
from ape import project, accounts


def main():
contract_name = str(os.getenv('CONTRACT')).lower()
chain_id = os.getenv('CHAIN_ID')
contract_name = str(os.getenv("CONTRACT")).lower()
chain_id = os.getenv("CHAIN_ID")
publish = os.getenv("PUBLISH", False)
account = None

if os.getenv('PROD'):
account = accounts.load('sugar')
if os.getenv("PROD"):
account = accounts.load("sugar")
elif len(accounts) > 0:
account = accounts[0]

if 'lp' in contract_name:
LpSugar.deploy(
os.getenv(f'VOTER_{chain_id}'),
os.getenv(f'REGISTRY_{chain_id}'),
os.getenv(f'CONVERTOR_{chain_id}'),
os.getenv(f'SLIPSTREAM_HELPER_{chain_id}'),
os.getenv(f'ALM_FACTORY_{chain_id}'),
{'from': account}
if "lp" in contract_name:
project.LpSugar.deploy(
os.getenv(f"VOTER_{chain_id}"),
os.getenv(f"REGISTRY_{chain_id}"),
os.getenv(f"CONVERTOR_{chain_id}"),
os.getenv(f"SLIPSTREAM_HELPER_{chain_id}"),
os.getenv(f"ALM_FACTORY_{chain_id}"),
sender=account,
publish=publish,
)

elif 'rewards' in contract_name:
RewardsSugar.deploy(
os.getenv(f'VOTER_{chain_id}'),
os.getenv(f'REGISTRY_{chain_id}'),
os.getenv(f'CONVERTOR_{chain_id}'),
{'from': account}
elif "rewards" in contract_name:
project.RewardsSugar.deploy(
os.getenv(f"VOTER_{chain_id}"),
os.getenv(f"REGISTRY_{chain_id}"),
os.getenv(f"CONVERTOR_{chain_id}"),
sender=account,
publish=publish,
)

elif 've' in contract_name:
VeSugar.deploy(
os.getenv(f'VOTER_{chain_id}'),
os.getenv(f'DIST_{chain_id}'),
os.getenv(f'GOVERNOR_{chain_id}'),
{'from': account}
elif "ve" in contract_name:
project.VeSugar.deploy(
os.getenv(f"VOTER_{chain_id}"),
os.getenv(f"DIST_{chain_id}"),
os.getenv(f"GOVERNOR_{chain_id}"),
sender=account,
publish=publish,
)

elif 'relay' in contract_name:
RelaySugar.deploy(
str(os.getenv(f'RELAY_REGISTRY_ADDRESSES_{chain_id}')).split(','),
os.getenv(f'VOTER_{chain_id}'),
{'from': account}
elif "relay" in contract_name:
project.RelaySugar.deploy(
str(os.getenv(f"RELAY_REGISTRY_ADDRESSES_{chain_id}")).split(","),
os.getenv(f"VOTER_{chain_id}"),
sender=account,
publish=publish,
)

elif 'registry' in contract_name:
FactoryRegistry.deploy(
str(os.getenv(f'FACTORIES_{chain_id}')).split(','),
str(os.getenv(f'REWARDS_FACTORIES_{chain_id}')).split(','),
str(os.getenv(f'GAUGE_FACTORIES_{chain_id}')).split(','),
str(os.getenv(f'INIT_HASHES_{chain_id}')).split(','),
{'from': account}
elif "registry" in contract_name:
project.FactoryRegistry.deploy(
str(os.getenv(f"FACTORIES_{chain_id}")).split(","),
str(os.getenv(f"REWARDS_FACTORIES_{chain_id}")).split(","),
str(os.getenv(f"GAUGE_FACTORIES_{chain_id}")).split(","),
str(os.getenv(f"INIT_HASHES_{chain_id}")).split(","),
sender=account,
publish=publish,
)

else:
print('Set the `CONTRACT` environment variable to deploy a contract.')
print("Set the `CONTRACT` environment variable to deploy a contract.")
8 changes: 4 additions & 4 deletions tests/test_factory_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from web3.constants import ADDRESS_ZERO

CHAIN_ID = os.getenv('CHAIN_ID', 34443)
CHAIN_ID = os.getenv("CHAIN_ID", 34443)


@pytest.fixture
@pytest.mark.skipif(int(CHAIN_ID) in [10, 8453], reason="Only leaf chains")
def factory_registry(FactoryRegistry):
def factory_registry(project):
# Deploy the contract using the first test account as the owner
yield FactoryRegistry.at(os.getenv(f'REGISTRY_{CHAIN_ID}'))
yield project.FactoryRegistry.at(os.getenv(f"REGISTRY_{CHAIN_ID}"))


@pytest.mark.skipif(int(CHAIN_ID) in [10, 8453], reason="Only leaf chains")
Expand All @@ -34,4 +34,4 @@ def test_initHashToPoolFactory(factory_registry):
factories = factory_registry.poolFactories()
result = factory_registry.initHashToPoolFactory(factories[0])

assert str(result) in os.getenv(f'INIT_HASHES_{CHAIN_ID}')
assert result.hex() in os.getenv(f"INIT_HASHES_{CHAIN_ID}")
Loading

0 comments on commit f883873

Please sign in to comment.