Skip to content
Open
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
35 changes: 35 additions & 0 deletions bases/ag-noble-relayer/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment

metadata:
name: ag-noble-relayer

spec:
selector:
matchLabels:
app: ag-noble-relayer

template:
metadata:
labels:
app: ag-noble-relayer

spec:
containers:
- command:
- /bin/bash
- -x
- /root/scripts/entrypoint.sh
image: debian:bullseye
name: ag-noble-relayer
resources:
limits:
cpu: 2000m
memory: 4Gi
volumeMounts:
- mountPath: /root/scripts
name: helpers
volumes:
- configMap:
name: noble-relayer-helpers
name: helpers
100 changes: 100 additions & 0 deletions bases/ag-noble-relayer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash

DIRECTORY_PATH="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
INTERNAL_CHAIN_ADDRESS_PREFIX=${INTERNAL_CHAIN_ADDRESS_PREFIX:-agoric}
INTERNAL_CHAIN_GAS_DENOM=${INTERNAL_CHAIN_GAS_DENOM:-ubld}
INTERNAL_CHAIN_ID=${INTERNAL_CHAIN_ID:-agoricdev-23}
INTERNAL_CHAIN_NAME=${INTERNAL_CHAIN_NAME:-agoric}
INTERNAL_CHAIN_RPC="https://devnet.rpc.agoric.net:443"
Copy link
Member Author

Choose a reason for hiding this comment

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

can only use devnet rpc as fallback - like other internal chain vars

EXTERNAL_CHAIN_ADDRESS_PREFIX=${EXTERNAL_CHAIN_ADDRESS_PREFIX:-noble}
EXTERNAL_CHAIN_GAS_DENOM=${EXTERNAL_CHAIN_GAS_DENOM:-uusdc}
EXTERNAL_CHAIN_ID=${EXTERNAL_CHAIN_ID:-grand-1}
EXTERNAL_CHAIN_NAME=${EXTERNAL_CHAIN_NAME:-nobletestnet}
EXTERNAL_CHAIN_RPC=${EXTERNAL_CHAIN_RPC:-http://noble-node.instagoric.svc.cluster.local:26657}
RELAYER_BINARY_EXPECTED_MD5_HASH="34496ca949e0e8fd7d9ab0514554b0a6"
RELAYER_PATH="$INTERNAL_CHAIN_NAME-$EXTERNAL_CHAIN_NAME"

HOME_PATH="$HOME/.relayer"

fetch_binary() {
BINARY_PATH="/bin/relayer"

curl "https://storage.googleapis.com/simulationlab_cloudbuild/rly" \
--output "$BINARY_PATH"
chmod +x "$BINARY_PATH"

RELAYER_BINARY_RECEIVED_MD5_HASH=$(md5sum "$BINARY_PATH" --binary | awk '{ print $1 }')

if [ "$RELAYER_BINARY_EXPECTED_MD5_HASH" != "$RELAYER_BINARY_RECEIVED_MD5_HASH" ]
then
echo "Expected hash: $RELAYER_BINARY_EXPECTED_MD5_HASH, Received hash: $RELAYER_BINARY_RECEIVED_MD5_HASH"
exit 1
fi
}

install_packages() {
apt-get update > /dev/null 2>&1
apt-get install curl jq --yes > /dev/null 2>&1
}

move_config_files() {
cp "$DIRECTORY_PATH/internal-chain-config.json" "$HOME_PATH"
cp "$DIRECTORY_PATH/external-chain-config.json" "$HOME_PATH"
}

replace_placeholders_in_config_files() {
sed "$HOME_PATH/internal-chain-config.json" \
--expression="s/\\\$INTERNAL_CHAIN_ADDRESS_PREFIX/${INTERNAL_CHAIN_ADDRESS_PREFIX}/g" \
--expression="s/\\\$INTERNAL_CHAIN_GAS_DENOM/${INTERNAL_CHAIN_GAS_DENOM}/g" \
--expression="s/\\\$INTERNAL_CHAIN_ID/${INTERNAL_CHAIN_ID}/g" \
--expression="s|\\\$INTERNAL_CHAIN_RPC|${INTERNAL_CHAIN_RPC}|g" \
--in-place \
--regexp-extended
sed "$HOME_PATH/external-chain-config.json" \
--expression="s/\\\$EXTERNAL_CHAIN_ADDRESS_PREFIX/${EXTERNAL_CHAIN_ADDRESS_PREFIX}/g" \
--expression="s/\\\$EXTERNAL_CHAIN_GAS_DENOM/${EXTERNAL_CHAIN_GAS_DENOM}/g" \
--expression="s/\\\$EXTERNAL_CHAIN_ID/${EXTERNAL_CHAIN_ID}/g" \
--expression="s|\\\$EXTERNAL_CHAIN_RPC|${EXTERNAL_CHAIN_RPC}|g" \
--in-place \
--regexp-extended
}

init_relayer() {
relayer config init
}

add_chains() {
relayer chains add "$INTERNAL_CHAIN_NAME" --file $HOME_PATH/internal-chain-config.json
relayer chains add "$EXTERNAL_CHAIN_NAME" --file $HOME_PATH/external-chain-config.json
}

restore_keys() {
relayer keys restore "$INTERNAL_CHAIN_NAME" user1 "cinnamon legend sword giant master simple visit action level ancient day rubber pigeon filter garment hockey stay water crawl omit airport venture toilet oppose"
relayer keys restore "$EXTERNAL_CHAIN_NAME" nobleuser1 "stamp later develop betray boss ranch abstract puzzle calm right bounce march orchard edge correct canal fault miracle void dutch lottery lucky observe armed"
Comment on lines +72 to +73
Copy link
Member Author

Choose a reason for hiding this comment

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

instead of using mnemonics here I think we should env vars here and pass the actual values via configMapGenerator literals from private overlays

}

use_keys() {
relayer keys use "$INTERNAL_CHAIN_NAME" user1
relayer keys use "$EXTERNAL_CHAIN_NAME" nobleuser1
}

add_path() {
relayer paths new "$INTERNAL_CHAIN_ID" "$EXTERNAL_CHAIN_ID" "$RELAYER_PATH"
relayer transact link "$RELAYER_PATH" --override
}

start_relayer() {
relayer start
Copy link
Contributor

Choose a reason for hiding this comment

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

I am thinking is it possible to be able to use a consistent channel?

}

install_packages
fetch_binary
init_relayer
move_config_files
replace_placeholders_in_config_files
add_chains
restore_keys
use_keys
add_path
start_relayer
sleep infinity
Copy link
Member Author

Choose a reason for hiding this comment

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

not sure if this is still needed

16 changes: 16 additions & 0 deletions bases/ag-noble-relayer/external-chain-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "cosmos",
"value": {
"account-prefix": "$EXTERNAL_CHAIN_ADDRESS_PREFIX",
"chain-id": "$EXTERNAL_CHAIN_ID",
"debug": true,
"gas-adjustment": 1.5,
"gas-prices": "0.25$EXTERNAL_CHAIN_GAS_DENOM",
"key": "default",
"keyring-backend": "test",
"output-format": "json",
"rpc-addr": "$EXTERNAL_CHAIN_RPC",
"sign-mode": "direct",
"timeout": "20s"
}
}
16 changes: 16 additions & 0 deletions bases/ag-noble-relayer/internal-chain-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "cosmos",
"value": {
"account-prefix": "$INTERNAL_CHAIN_ADDRESS_PREFIX",
"chain-id": "$INTERNAL_CHAIN_ID",
"debug": true,
"gas-adjustment": 1.2,
"gas-prices": "0.025$INTERNAL_CHAIN_GAS_DENOM",
"key": "default",
"keyring-backend": "test",
"output-format": "json",
"rpc-addr": "$INTERNAL_CHAIN_RPC",
"sign-mode": "direct",
"timeout": "20s"
}
}
13 changes: 13 additions & 0 deletions bases/ag-noble-relayer/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1

configMapGenerator:
- name: noble-relayer-helpers
files:
- entrypoint.sh
- internal-chain-config.json
- external-chain-config.json

kind: Kustomization

resources:
- deployment.yaml
5 changes: 5 additions & 0 deletions bases/noble-node/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- noble-node.yaml
123 changes: 123 additions & 0 deletions bases/noble-node/noble-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: noble-node
spec:
podManagementPolicy: "Parallel"
selector:
matchLabels:
app: noble-node
serviceName: noble-node
replicas: 1
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: noble-node

spec:
terminationGracePeriodSeconds: 10
serviceAccountName: opentracing-agent
containers:
- name: noble-node
image: debian:bullseye
ports:
- containerPort: 26656 # P2P Port
name: p2p
- containerPort: 26657 # RPC Port
name: rpc
- containerPort: 9090 # API Port
name: grpc
- containerPort: 1317 # REST Port
name: api
env:
- name: MONIKER
value: "noble-testnet" # Replace with your node name
- name: CHAIN_ID
value: "grand-1"
command:
- /bin/bash
- -c
- |
set -x
apt-get update && apt-get install wget curl jq lz4 --yes
NOBLE_HOME=/state/$CHAIN_ID

# change this to match the latest release on chain upgrade
wget https://github.com/noble-assets/noble/releases/download/v9.0.0-rc.1/nobled_linux-amd64
wget https://github.com/noble-assets/noble/releases/download/v9.0.0-rc.1/checksum.txt
BINARY_CHECKSUM=$(sha256sum nobled_linux-amd64 | cut -d ' ' -f 1)
EXPECTED_CHECKSUM=$(head -n 1 checksum.txt | cut -d ' ' -f 1)
if [ "$BINARY_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
echo "Checksum mismatch!"
echo "Expected: $EXPECTED_CHECKSUM"
echo "Got: $BINARY_CHECKSUM"
exit 1
fi
mv nobled_linux-amd64 /state/nobled
chmod +x /state/nobled
mkdir -p $NOBLE_HOME

/state/nobled init $MONIKER --chain-id $CHAIN_ID --home $NOBLE_HOME

wget -O addrbook.json https://snapshots.polkachu.com/testnet-addrbook/noble/addrbook.json --inet4-only
mv addrbook.json $NOBLE_HOME/config
# uncomment the following line and update the snapshot tarball when redploying this node
# to catch up to current state in case of halt, then comment and redeploy again so
# pod restarts don't start the chain from scratch
# curl -o - -L https://snapshots.polkachu.com/testnet-snapshots/noble/noble_23034627.tar.lz4 | lz4 -c -d - | tar -x -C $NOBLE_HOME

# Set the listening addresses to 0.0.0.0
sed -i 's|^laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' $NOBLE_HOME/config/config.toml
sed -i 's|^laddr = "tcp://127.0.0.1:1317"|laddr = "tcp://0.0.0.0:1317"|g' $NOBLE_HOME/config/app.toml
sed -i 's|^address = "127.0.0.1:9090"|address = "0.0.0.0:9090"|g' $NOBLE_HOME/config/app.toml

/state/nobled start --home $NOBLE_HOME --log_format json
volumeMounts:
- name: noble-state
mountPath: /state
resources:
limits:
cpu: 1000m
ephemeral-storage: 5Gi
memory: 8Gi
requests:
cpu: 1000m
ephemeral-storage: 5Gi
memory: 4Gi
volumeClaimTemplates:
- metadata:
name: noble-state
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 200Gi
storageClassName: premium-rwo
---
apiVersion: v1
kind: Service
metadata:
name: noble-node
spec:
selector:
app: noble-node
ports:
- protocol: TCP
port: 26656 # P2P Port
targetPort: 26656
name: p2p
- protocol: TCP
port: 26657 # RPC Port
targetPort: 26657
name: rpc
- protocol: TCP
port: 9090 # API Port
targetPort: 9090
name: grpc
- protocol: TCP
port: 1317 # REST Port
targetPort: 1317
name: api
type: ClusterIP