-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving monorepo to single repo (#1347)
This PR changes the directory structure to move away from the monorepo format, and instead be a single installable agent0 repo. This likely includes many breaking changes. - Updating installation instructions. - Support for using [uv](https://github.com/astral-sh/uv) for installation. - Renaming `lib` to `src` - Renaming `lib/agent0/agent0` to `lib/agent0/core` - Moving all packages to be under agent0 (e.g., `lib/ethpy/ethpy` to `src/agent0/ethpy`) - Moving examples to outer directory (e.g., `lib/agent0/examples` to `examples/`) - Moving bin directories to scripts (e.g., `lib/agent0/bin` to `scripts/`) - Fixing imports - Adding `src/agent0/__init__.py` that shortcuts imports (e.g., `from agent0 import ILocalHyperdrive`) - General cleanup of outdated examples and readmes.
- Loading branch information
Sheng Lundquist
authored
Mar 7, 2024
1 parent
0638b3d
commit 502da6c
Showing
258 changed files
with
869 additions
and
1,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,36 @@ | ||
# Install -- overview | ||
# Install | ||
|
||
All `agent0` packages should be accessed from Python 3.10. | ||
The following outlines our recommended install workflow, although alternatives are listed below. | ||
## 1. Prerequisites | ||
While not strictly required when connecting to a remote chain, we recommend that you install these tools to use the full suite of Agent0 simulation tools. | ||
|
||
## 1. Clone the `agent0` monorepo | ||
- [Foundry](https://book.getfoundry.sh/getting-started/installation) for running a local Anvil testnnet node. | ||
- [Docker](https://docs.docker.com/engine/install/) for hosting the underlying data tools. | ||
|
||
Clone the repo into a <repo_location> of your choice. | ||
## 2. Clone | ||
Clone the repo to <repo_location>, then enter that directory. | ||
|
||
```bash | ||
git clone https://github.com/delvtech/agent0.git <repo_location> | ||
``` | ||
|
||
## 2. Install Pyenv | ||
|
||
Follow [Pyenv install instructions](https://github.com/pyenv/pyenv#installation). | ||
|
||
## 3. Set up a virtual environment | ||
|
||
You can use any environment; we use [venv](https://docs.python.org/3/library/venv.html): | ||
|
||
```bash | ||
cd <repo_location> | ||
pyenv install 3.10 | ||
pyenv local 3.10 | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
``` | ||
|
||
## 4. Install `agent0` packages and requirements | ||
|
||
All of the agent0 packages can be installed from `requirements.txt`: | ||
|
||
```bash | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade -r requirements.txt | ||
``` | ||
|
||
If you want to use the CI tools, such as run tests, check linting or types, build containers or documentation, then you must also [install Foundry](https://book.getfoundry.sh/getting-started/installation) and the dev packages: | ||
|
||
```bash | ||
python -m pip install --upgrade -r requirements-dev.txt | ||
``` | ||
|
||
Finally, you can test that everything is working by calling: `python -m pytest .` | ||
|
||
# Alternate install paths | ||
|
||
The default installation directions above should automatically install all local sub-packages, and should be sufficient for development. | ||
We also support these installation options: | ||
|
||
## Installing each subpackage independently | ||
|
||
After you have cloned the repository you can install each package independently. | ||
For example: | ||
|
||
```bash | ||
python -m pip install --upgrade lib/agent0[with-dependencies] | ||
``` | ||
|
||
Internally, the above installation calls | ||
|
||
```bash | ||
pip install agent0[base] # Install with base packages only (this is what's called in requirements.txt) | ||
pip install agent0[lateral] # Installs dependent sub-packages from git (e.g., ethpy) | ||
``` | ||
|
||
# Working with smart contracts | ||
|
||
We run tests and offer utilities that depend on executing bytecode compiled from Hyperdrive solidity contracts. | ||
This is not required to use the agent0 libraries. | ||
|
||
NOTE: The Hyperdrive solidity implementation is currently under security review, and thus is not available publicly. | ||
The following instructions will not work for anyone who is not a member of Delv. | ||
|
||
## 1. Set up smart contracts | ||
|
||
Clone the hyperdrive repo: | ||
|
||
```bash | ||
git clone [email protected]:delvtech/hyperdrive.git ../hyperdrive | ||
``` | ||
|
||
## 2. Install and Build Hyperdrive | ||
|
||
Complete the steps in Hyperdrive's [Pre-requisites](https://github.com/delvtech/hyperdrive#pre-requisites) and [Build](https://github.com/delvtech/hyperdrive#build) sections. | ||
|
||
## 3. Copy ABI & bytecode files | ||
|
||
Copy the contract `sol` folders from the generated `out` directory in the `hyperdrive` repository root. | ||
These folder should contain the ABI JSON and bytecode files for each contract. | ||
Paste the folders into `agnet0/packages/hyperdrive/src/abis/`. | ||
|
||
```bash | ||
cp -R ../hyperdrive/out/*.sol packages/hyperdrive/src/abis/ | ||
``` | ||
|
||
Our codebase uses the following contracts: | ||
## 3. Setup environment | ||
We use [uv](https://github.com/astral-sh/uv) for package management and virtual environments. | ||
|
||
```bash | ||
ERC20Mintable.sol/ | ||
ERC4626DataProvider.sol/ | ||
ERC4626HyperdriveDeployer.sol/ | ||
ERC4626HyperdriveFactory.sol/ | ||
ForwarderFactory.sol/ | ||
IERC4626Hyperdrive.sol/ | ||
IHyperdrive.sol/ | ||
MockERC4626.sol/ | ||
curl -LsSf https://astral.sh/uv/install.sh | sh | ||
uv venv .venv -p 3.10 | ||
source .venv/bin/activate | ||
``` | ||
|
||
You then can update the generated `hypertypes` python package by running `pypechain` on this folder: | ||
|
||
## 4. Install `agent0` | ||
```bash | ||
pip install --upgrade pip && pip install --upgrade pypechain | ||
pypechain packages/hyperdrive/src/abis/ --output-dir lib/hypertypes/hypertypes/types/ | ||
uv pip install -e . | ||
# uv pip install agent0@. # For non-editable install | ||
# uv pip install -e .[dev] # For CI tools | ||
# uv pip install -e .[all] # Install everything | ||
# TODO: remove once hyperdrivepy is public | ||
uv pip install -r requirements-hyperdrivepy.txt | ||
``` | ||
|
||
# Additional useful applications | ||
|
||
You can test against a local testnet node using [Anvil](https://book.getfoundry.sh/reference/anvil/). | ||
|
||
We use [Docker](docs.docker.com/get-docker) for building images. | ||
Some tests also use Docker to launch a local postgres server and Anvil chain. | ||
If there are Docker issues when running tests, ensure "Allow the default Docker socket to be used" is set under Advanced settings (typically when running Docker Desktop on Macs). | ||
You can test that everything is working by calling `python -m pytest .` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
agent0 documentation and notebook examples can be built locally using the provided Makefile using `make html`. | ||
This also includes notebook examples built using CI from `https://github.com/delvtech/elf-simulations-examples`. | ||
agent0 documentation and notebook examples can be built locally using the provided Makefile using `make html`. |
Oops, something went wrong.