-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add liquidity deployment script and improve deployments * Remove proposals query * Gitignore .seed file * Add example file for .seed * Rename script to relaying * Rename script to relaying * Adjust error reporting * Adjust API node * Start dockerizing deployment * Start drafting instructions for deployment * Fix relayer build * Improve deployment readme * Improve readability of tip * Fix log outputs * Reference docker running for all steps and fix submitter key parsing * Move relayer instructions and rename tool * Fix typo * Fix typo in file path * Remove extra log lines * Mention neutron_query_relayer being in path * Delete tool build artifacts and add the folder to gitignore * Add deployment scripts branch to latest-contract workflow for testing * Adjust populate contracts command * Fix binary in relaying.sh script * Compile neutron-query-relayer binary * Shorten sleep before killing relayer * Remove PR branch as workflow trigger
- Loading branch information
1 parent
752d4c9
commit 9b9ba75
Showing
14 changed files
with
345 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
assist lava fatigue enough delay swim mystery crater thank very nerve laugh annual belt bachelor front merge lonely eagle alpha lunch farm alley enough |
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Manually deploying & interacting with contracts | ||
|
||
This directory contains a set of shell scripts and JSON configuration files that allow us to easily store, instantiate and prepare our smart contracts for testing. | ||
|
||
## Setting up the environment | ||
|
||
To get started, you will need to have the following installed: | ||
* [Docker](https://docs.docker.com/get-docker/) | ||
|
||
You will need to create and prepare the `.seed` file in the repo root with the seed phrase of the test account; see the `.seed.example` file for an example. | ||
|
||
This account will deploy the contracts, and send the transactions to populate the contracts. | ||
|
||
Then, you need to build the dockerfile. Run the following command: | ||
|
||
```bash | ||
docker build -t hydro-docker . | ||
``` | ||
|
||
## Setting up contracts | ||
|
||
To deploy a new set of contracts to mainnet, run the following command: | ||
|
||
```bash | ||
docker run hydro-docker ./tools/deployment/setup_on_mainnet.sh | ||
``` | ||
|
||
Take note of the contract addresses outputted by the script. You will need them to interact with the contracts. | ||
|
||
## Populating contracts | ||
|
||
If you already have contracts deployed, you can populate them with a new series of bids and tributes by running | ||
|
||
```bash | ||
docker run hydro-docker ./tools/deployment/populate_contracts.sh "tools/deployment/config_mainnet.json" $HYDRO_CONTRACT_ADDRESS $TRIBUTE_CONTRACT_ADDRESS | ||
``` | ||
where you will need to replace the contract addresses with the addresses of the contracts you wish to populate. | ||
|
||
This will create 3 bids with tributes in the current round of the contract. | ||
|
||
Notice that the `.seed` file will need to contain the passphrase of the account that created the contracts. | ||
> **TIP:** When you switch out the phrase in the `.seed` file, you will need to rebuild the docker image. | ||
## Adding liquidity deployments | ||
|
||
To make rewards claimable, liquidity deployments need to be added. | ||
For a certain proposal in a certain round and certain tranche, here is how you can add a liquidity deployment for it, to make tributes claimable or refundable: | ||
|
||
```bash | ||
docker run hydro-docker ./tools/deployment/add_liquidity_deployments.sh "./tools/deployment/config_mainnet.json" $HYDRO_CONTRACT_ADDRESS $TRIBUTE_CONTRACT_ADDRESS $ROUND_ID $TRANCHE_ID $PROPOSAL_ID $FUNDS | ||
``` | ||
FUNDS should be 0 if the tribute for the bid should become refundable; and non-zero if it should become claimable. | ||
Don't worry about the non-zero number - this script isn't actually sending funds over. It only matters whether the number is zero or not. | ||
|
||
## Issuing interchain queries and relaying | ||
|
||
### Setting the Neutron Interchain Queries (ICQ) Relayer locally (optional) | ||
|
||
If you want to run the relayer locally instead of through Docker, clone the [ICQ Relayer](https://github.com/neutron-org/neutron-query-relayer) repository and switch to the latest tag (v0.3.0 at the time of writing), then build the relayer. | ||
Make sure that `neutron_query_relayer` is in the path and executable. | ||
|
||
### Setting up the ICQ population tool | ||
|
||
To set up the ICQ population tool, inside `./tools/`, run this command to build the binary: | ||
|
||
```bash | ||
go build -o build/icq-tool ./*.go | ||
``` | ||
|
||
### Setting up variables (optional) | ||
|
||
You can adjust parameters like the RPC nodes to connect to for relaying by modifying the exports in `./tools/relaying.sh`. | ||
|
||
## Run the script | ||
|
||
Simply run the script by running `docker run hydro-docker ./tools/relaying.sh HYDRO_CONTRACT_ADDRESS NUM_OF_VALIDATORS_TO_ADD`. | ||
|
||
It will not stop on its own, but the script will eventually print out the relayer logs, and once there are no more regular changes in those, you can stop the container. | ||
|
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# -------------------------------------------------------- | ||
# Stage 1: Build neutron-query-relayer | ||
# -------------------------------------------------------- | ||
FROM golang:alpine3.21 AS builder | ||
|
||
# Set up build arguments | ||
ARG LDFLAGS | ||
|
||
# Install dependencies for Go build and musl compatibility | ||
RUN apk add --no-cache \ | ||
git \ | ||
gcc \ | ||
musl-dev \ | ||
libc-dev \ | ||
make | ||
|
||
# Set up the build environment | ||
WORKDIR /app | ||
|
||
# Clone the neutron-query-relayer repository | ||
RUN git clone --depth 1 https://github.com/neutron-org/neutron-query-relayer.git /app | ||
|
||
# Download Go modules | ||
RUN go mod download | ||
|
||
# Build the neutron-query-relayer binary with Alpine-compatible settings | ||
RUN go build -ldflags "${LDFLAGS}" -o build/neutron_query_relayer ./cmd/neutron_query_relayer/*.go | ||
|
||
COPY tools /app/tools | ||
|
||
# build the icq population tool | ||
RUN go build -o build/icq-tool /app/tools/*.go | ||
|
||
# -------------------------------------------------------- | ||
# Stage 3: Final image with all dependencies | ||
# -------------------------------------------------------- | ||
FROM alpine:3.21.0 | ||
|
||
RUN apk add --no-cache file | ||
|
||
# Install dependencies | ||
RUN apk add --no-cache \ | ||
bash \ | ||
curl \ | ||
ca-certificates \ | ||
git \ | ||
jq | ||
|
||
# Set the desired version of neutrond | ||
ARG NEUTROND_VERSION="v5.0.2" | ||
ARG NEUTROND_BINARY="neutrond-linux-amd64" | ||
ARG NEUTROND_DOWNLOAD_URL="https://github.com/neutron-org/neutron/releases/download/${NEUTROND_VERSION}/${NEUTROND_BINARY}" | ||
|
||
# Download and install the neutrond binary | ||
RUN curl -L ${NEUTROND_DOWNLOAD_URL} -o /usr/local/bin/neutrond && \ | ||
chmod +x /usr/local/bin/neutrond | ||
|
||
# Add the neutron-query-relayer binary from the builder stage | ||
COPY --from=builder /app/build/neutron_query_relayer /usr/local/bin/neutron_query_relayer | ||
|
||
# Add the icq-tool binary from the builder stage | ||
COPY --from=builder /app/build/icq-tool /usr/local/bin/icq-tool | ||
|
||
# Add CosmWasm libraries | ||
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.2/libwasmvm.x86_64.so /lib/ | ||
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.2/libwasmvm.aarch64.so /lib/ | ||
|
||
# Copy scripts and other artifacts | ||
COPY tools /usr/local/hydro/tools | ||
COPY artifacts/ /usr/local/hydro/artifacts | ||
COPY .seed /usr/local/hydro/.seed | ||
|
||
# Set the default working directory | ||
WORKDIR /usr/local/hydro | ||
|
||
# Ensure scripts are executable | ||
RUN chmod +x tools/relaying.sh tools/deployment/*.sh | ||
|
||
# Import the seed phrase | ||
RUN neutrond keys add submitter --recover --keyring-backend test --source /usr/local/hydro/.seed | ||
|
||
|
||
# Expose the neutron-query-relayer port | ||
EXPOSE 9999 | ||
|
||
# Default entry point | ||
ENTRYPOINT ["bash"] | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
set -eux | ||
|
||
# Check for required arguments | ||
if [ $# -lt 7 ]; then | ||
echo "Usage: $0 <config_file> <hydro_contract_address> <tribute_contract_address> <round_id> <tranche_id> <proposal_id> <deployed_fund_amount>" | ||
exit 1 | ||
fi | ||
|
||
CONFIG_FILE="$1" | ||
HYDRO_CONTRACT_ADDRESS="$2" | ||
TRIBUTE_CONTRACT_ADDRESS="$3" | ||
ROUND_ID="$4" | ||
TRANCHE_ID="$5" | ||
PROPOSAL_ID="$6" | ||
DEPLOYED_FUND_AMOUNT="$7" | ||
|
||
|
||
NEUTRON_CHAIN_ID=$(jq -r '.chain_id' $CONFIG_FILE) | ||
NEUTRON_NODE=$(jq -r '.neutron_rpc_node' $CONFIG_FILE) | ||
TX_SENDER_WALLET=$(jq -r '.tx_sender_wallet' $CONFIG_FILE) | ||
|
||
TRIBUTE_TOKEN_1=$(jq -r '.tribute_token_1' $CONFIG_FILE) | ||
TRIBUTE_TOKEN_2=$(jq -r '.tribute_token_2' $CONFIG_FILE) | ||
TRIBUTE_TOKEN_3=$(jq -r '.tribute_token_3' $CONFIG_FILE) | ||
|
||
NEUTRON_BINARY="neutrond" | ||
NEUTRON_CHAIN_ID_FLAG="--chain-id $NEUTRON_CHAIN_ID" | ||
KEYRING_TEST_FLAG="--keyring-backend test" | ||
TX_FLAG="--gas auto --gas-adjustment 1.3" | ||
NEUTRON_NODE_FLAG="--node $NEUTRON_NODE" | ||
NEUTRON_TX_FLAGS="$TX_FLAG --gas-prices 0.0053untrn --chain-id $NEUTRON_CHAIN_ID $NEUTRON_NODE_FLAG $KEYRING_TEST_FLAG -y" | ||
|
||
# Customize these query parameters as needed | ||
LIMIT=1000 # maximum number of proposals to retrieve at once | ||
START_FROM=0 # where to start from if pagination is needed | ||
|
||
if [ "$DEPLOYED_FUND_AMOUNT" -eq 0 ]; then | ||
DEPLOYED_FUNDS="[]" | ||
else | ||
DEPLOYED_FUNDS='[{"amount":"'"$DEPLOYED_FUND_AMOUNT"'","denom":"uatom"}]' | ||
fi | ||
|
||
EXECUTE='{"add_liquidity_deployment":{"deployed_funds":'"$DEPLOYED_FUNDS"',"destinations":["Secret1a65a9xgqrlsgdszqjtxhz069pgsh8h4a83hwt0"],"funds_before_deployment":[{"amount":"1000000","denom":"uatom"}],"proposal_id":'"$PROPOSAL_ID"',"remaining_rounds":0,"round_id":'"$ROUND_ID"',"total_rounds":0,"tranche_id":'"$TRANCHE_ID"'}}' | ||
$NEUTRON_BINARY tx wasm execute $HYDRO_CONTRACT_ADDRESS "$EXECUTE" --from $TX_SENDER_WALLET $NEUTRON_TX_FLAGS | ||
sleep 10 |
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
Oops, something went wrong.