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

39 implement tests for nabla indexer #40

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ debug-project
debug-contracts
target-debug
solang-mac-arm

.yarn
.yarn
nabla/excluded
localConfig.json
109 changes: 105 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,115 @@

Usage for the example project:

1. Pull the Solidity source files from git: `npx ts-node src/index.ts pull nabla`
2. Deploy: `npx ts-node src/index.ts deploy nabla --network foucoco`
1. Pull the Solidity source files from git: `npx tsx src/index.ts pull nabla`
2. Deploy: `npx tsx src/index.ts deploy nabla --network foucoco --deployment mockTestnet`

Alternatively you can use the parameter `local` instead of `foucoco`. This expects that there is a local chain running on port `9944` – this is particularly useful to run together with the [foucoco-standalone](https://github.com/pendulum-chain/foucoco-standalone) node.
Alternatively you can use the parameter `local` instead of `foucoco`. This expects that there is a local chain running
on port `9944` – this is particularly useful to run together with
the [foucoco-standalone](https://github.com/pendulum-chain/foucoco-standalone) node.

# Required
## General deployment instructions

The `deploy` command takes two required arguments:

- `--network`: one of the networks defined in the file `nabla/config.json` (`pendulum`, `foucoco` or `local`)
- `--deployment`: one of the deployment definitions, see `nabla/deployments/selector.ts`:
- `usdtVortexPrototype`: described [on Notion](https://www.notion.so/satoshipay/24-05-16-USDT-Prototype-Deployment-1118b1b29b2f806f9070e734a10162d3)
- `usdcAxelarVortexPrototype`: described [on Notion](https://www.notion.so/satoshipay/24-07-04-USDC-axl-Prototype-Deployment-1118b1b29b2f80c7ba3ad321c6bb3e8b)
- `productionPendulum`: described [on Notion](https://www.notion.so/satoshipay/24-09-30-Public-Deployment-1118b1b29b2f807283dbd10e0a6ae8b9)
- `mockTestnet`: described [on Notion](https://www.notion.so/satoshipay/24-09-30-Nabla-Foucoco-Paseo-Deployment-1118b1b29b2f804eababf94383a56f7b)
- `slippageTest`: used for validating slippage calulcations, see [this page on Notion](https://www.notion.so/satoshipay/24-09-30-Public-Deployment-1118b1b29b2f807283dbd10e0a6ae8b9?pvs=4#1158b1b29b2f80bc8be8efb7bc5197b4)

# Setup

```
brew install binaryen
```

## Install solang

You can find the installation instructions for solang [here](https://solang.readthedocs.io/en/v0.3.3/installing.html).

## Setup local configuration

Create a file `localConfig.json` in the root folder of this repository and add the following content:

```
{
"solangPath": "path/to/your/solang/binary"
}

```

### Build from source

If you want to test a specific version, you can build solang from source.

#### Install Rust

Make sure you have at least rust v1.74 or later installed.
You can install it with rustup using

```shell
rustup install 1.74
rustup default <that_version>
```

#### LLVM

You need to have a custom version of LLVM available.
To install it, please follow the
steps [here](https://solang.readthedocs.io/en/v0.3.3/installing.html#step-1-install-the-llvm-libraries).

#### Build solang

Clone the solang repository and build it:

```shell

Choose a reason for hiding this comment

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

I think that the path to the solang binary used here should be absolute.

Copy link
Member

Choose a reason for hiding this comment

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

But if we make it absolute then every developer definitely needs to touch that path. If we keep it relative we just have to make sure that the directory is put into the conventional place.

mkdir clones
cd clones
git clone https://github.com/hyperledger/solang/
cd solang
cargo build --release
```

### Troubleshooting

If you encounter issues during the compilation, consider switching to the
latest [release](https://github.com/hyperledger/solang/releases) version instead of building directly from `main`
branch.

# Deploying the contracts

Before deploying the contracts, you need to make sure that the contracts are available in the `target/git` directory.
To do this, run the following command:

```shell
npm run pull:nabla
```

This will clone the contracts from the git repository and place them in the `target/git` directory.

Then, you can deploy the contracts using the following command:

```shell
# Deploy to Foucoco
npm run deploy:foucoco
# Deploy to local chain
npm run deploy:local
```

### Troubleshooting

#### 'file not found '@openzeppelin/contracts/token/ERC20/ERC20.sol' (or similar)

If you encounter the errors about missing contract files, you need to make sure that the Solidity files are present in
the
`target/git` directory.
In the `nabla/config.json` file, you can find configuration of import paths for additional Solidity files.
In order for this to work, you need to make sure that the `node_modules` folder is present in each of the cloned
subdirectories of `target/git`.
These are only available if the `npm install` or `yarn install` command was executed successfully in the respective
directory.
This should automatically be done by the 'deploy' script though, so if you encounter this issue, try debugging
dependency issues in the respective `package.json` file.
14 changes: 14 additions & 0 deletions nabla-indexer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
These are tests for the Subsquid indexer for Nabla.

This folder should be eventually moved to our subsquid repository https://github.com/pendulum-chain/pendulum-squids.

To run these tests:

- run foucoco-standalone from scratch locally
- run our subsquid indexer from scratch locally
- this requires some changes that allow to run the indexer locally
- in the pendulum-squids project: `sqd down && sqd up && sqd process:local`
- run the graphql server locally
- in the pendulum-squids project: `sqd serve`
- run this test suite here
- `npx tsx src/index.ts test nabla-indexer --network local`
71 changes: 40 additions & 31 deletions nabla/_config_precompiledCurve.json → nabla-indexer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,68 @@
"contracts": {
"Router": {
"repository": "nablaContracts",
"path": "contracts/src/core/Router.sol"
"path": "contracts/src/core/Router.sol",
"argumentNameOverwrites": {
"oracleByAsset": ["asset"],
"poolByAsset": ["asset"]
}
},
"NablaCurve": {
"path": "NablaCurve.contract",
"isPrecompiled": true
"repository": "nablaCurve",
"path": "src/NablaCurve.sol"
},
"BackstopPool": {
"repository": "nablaContracts",
"path": "contracts/src/core/BackstopPool.sol"
"path": "contracts/src/core/BackstopPool.sol",
"messageNameOverwrites": {
"decimals_": "decimals"
}
},
"SwapPool": {
"repository": "nablaContracts",
"path": "contracts/src/core/SwapPool.sol"
"path": "contracts/src/core/SwapPool.sol",
"messageNameOverwrites": {
"decimals_": "decimals"
}
},
"ERC20Wrapper": {
"repository": "pendulumWrappers",
"path": "erc20-wrapper/ERC20Wrapper.sol"
},
"PriceOracleWrapper": {
"repository": "pendulumWrappers",
"path": "price-oracle-wrapper/PriceOracleWrapper.sol"
},
"TestableBackstopPool": {
"repository": "nablaContracts",
"path": "contracts/test/lib/TestableBackstopPool.sol"
},
"TestableSwapPool": {
"repository": "nablaContracts",
"path": "contracts/test/lib/TestableSwapPool.sol"
},
"MockERC20": {
"repository": "nablaContracts",
"path": "contracts/src/mock/MockERC20.sol"
"path": "erc20-wrapper/ERC20Wrapper.sol",
"mutatingOverwrites": {
"balanceOf": false,
"totalSupply": false,
"allowance": false
},
"messageNameOverwrites": {
"name_": "name",
"symbol_": "symbol",
"decimals_": "decimals",
"variant_": "variant",
"index_": "index",
"code_": "code",
"issuer_": "issuer"
}
},
"MockOracle": {
"repository": "nablaContracts",
"path": "contracts/src/mock/MockOracle.sol"
},
"VendingMachine": {
"path": "VendingMachine.contract",
"isPrecompiled": true
}
},
"repositories": {
"nablaContracts": {
"git": "https://github.com/NablaFinance/contracts.git",
"branch": "feature/backstop-pool-coverage-ratio",
"branch": "3e96787e161fb2657c90f18034691749647b691f",
"init": "yarn",
"importpaths": ["contracts/@chain/pendulum", "node_modules"]
},
"nablaCurve": {
"git": "https://github.com/NablaFinance/curve.git",
"branch": "3-change-slippage-curve",
"init": "npm"
},
"pendulumWrappers": {
"git": "https://github.com/pendulum-chain/pendulum-ink-wrapper",
"branch": "master"
"git": "https://github.com/pendulum-chain/pendulum-solidity-wrapper",
"branch": "5c8dacd274f8bc4d8ba0e448bce1cfb09b58325d"
}
},
"networks": {
Expand Down Expand Up @@ -89,8 +98,8 @@
"buildFolder": "../target",
"limits": {
"gas": {
"refTime": "100000000000",
"proofSize": "10000000"
"refTime": "10000000000000000",
"proofSize": "10000000000000000"
},
"storageDeposit": "10000000000000"
}
Expand Down
Loading