Skip to content

Commit

Permalink
Merge pull request #1 from sagaxyz/feature/saga-ibc
Browse files Browse the repository at this point in the history
IBC for Saga
  • Loading branch information
luckychess authored Jul 5, 2023
2 parents af8d0f7 + 94b08d8 commit 2d3c8e5
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rly/sevm_111-1.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "cosmos",
"value": {
"key_algos": [
"ethsecp256k1"
],
"extra_codecs": [
"ethermint"
],
"slip44": 60,
"key": "key1",
"chain-id": "sevm_111-1",
"rpc-addr": "http://192.167.10.6:26657",
"account-prefix": "saga",
"keyring-backend": "test",
"gas-adjustment": 1.2,
"gas-prices": "1asaga",
"min-gas-amount": 1,
"debug": true,
"timeout": "20s",
"output-format": "json",
"sign-mode": "direct"
}
}
24 changes: 24 additions & 0 deletions rly/sevm_111-2.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "cosmos",
"value": {
"key_algos": [
"ethsecp256k1"
],
"extra_codecs": [
"ethermint"
],
"slip44": 60,
"key": "key2",
"chain-id": "sevm_111-2",
"rpc-addr": "http://192.167.10.7:26657",
"account-prefix": "saga",
"keyring-backend": "test",
"gas-adjustment": 1.2,
"gas-prices": "1asaga",
"min-gas-amount": 1,
"debug": true,
"timeout": "20s",
"output-format": "json",
"sign-mode": "direct"
}
}
52 changes: 52 additions & 0 deletions rly/start-rly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

KEYPASSWD=${KEYPASSWD:-DoNoTuSeInPrOd}

rly config init

echo $RELAYER_CHAINLET_MNEMONIC > mnemo.file.sevm
echo $RELAYER_SPC_MNEMONIC > mnemo.file.spc

mv /root/tmp/sevm_111-1.json.example /root/tmp/$CHAINLET_CHAIN_ID.json
mv /root/tmp/sevm_111-2.json.example /root/tmp/$SPC_CHAIN_ID.json

cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."chain-id"="'$CHAINLET_CHAIN_ID'"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json
cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."chain-id"="'$SPC_CHAIN_ID'"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json

# TODO: hardcoded port; http
cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."rpc-addr"="'$CHAINLET_RPC_ADDRESS'"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json
cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."rpc-addr"="'$SPC_RPC_EXTERNAL_ADDRESS'"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json

cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."keyring-backend"="file"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json
cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."keyring-backend"="file"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json

cat /root/tmp/$CHAINLET_CHAIN_ID.json | jq '.value."gas-prices"="'1$CHAINLET_DENOM'"' > /root/tmp/$CHAINLET_CHAIN_ID.json.tmp && mv /root/tmp/$CHAINLET_CHAIN_ID.json.tmp /root/tmp/$CHAINLET_CHAIN_ID.json
cat /root/tmp/$SPC_CHAIN_ID.json | jq '.value."gas-prices"="'1$SPC_DENOM'"' > /root/tmp/$SPC_CHAIN_ID.json.tmp && mv /root/tmp/$SPC_CHAIN_ID.json.tmp /root/tmp/$SPC_CHAIN_ID.json

cp /root/tmp/$CHAINLET_CHAIN_ID.json /root/.relayer/config/
cp /root/tmp/$SPC_CHAIN_ID.json /root/.relayer/config/

rly chains add $CHAINLET_CHAIN_ID --file /root/.relayer/config/$CHAINLET_CHAIN_ID.json
rly chains add $SPC_CHAIN_ID --file /root/.relayer/config/$SPC_CHAIN_ID.json

yq -i '.chains."'$CHAINLET_CHAIN_ID'".value.extra-codecs |= ["ethermint"]' /root/.relayer/config/config.yaml

(echo $KEYPASSWD; echo $KEYPASSWD) | rly keys restore $CHAINLET_CHAIN_ID key1 "$(cat /root/mnemo.file.sevm)" --coin-type=60
(echo $KEYPASSWD; echo $KEYPASSWD) | rly keys restore $SPC_CHAIN_ID key2 "$(cat /root/mnemo.file.spc)"

rly paths new $CHAINLET_CHAIN_ID $SPC_CHAIN_ID dp

# we want to make sure that chainlet is up and running
while true
do
rly q node-state $CHAINLET_CHAIN_ID
RETCODE=$?
if [[ ${RETCODE} -eq 0 ]]; then
break
fi
sleep 5
done

(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly transact link dp

(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly start dp
31 changes: 31 additions & 0 deletions saga.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM golang:1.20.4-bullseye AS build-env

WORKDIR /root

RUN apt-get update -y
RUN apt-get install git jq wget -y

COPY . .

# RUN git clone https://github.com/cosmos/relayer.git && cd relayer && git checkout v2.3.1 && make build

RUN make build

FROM golang:1.20.4-bullseye
RUN apt-get update -y
RUN apt-get install ca-certificates jq wget -y
RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 && chmod a+x /usr/local/bin/yq

WORKDIR /root

COPY --from=build-env /root/build/rly /usr/bin/rly
COPY --from=build-env /root/rly/start-rly.sh /root/start-rly.sh
RUN mkdir -p /root/tmp
COPY --from=build-env /root/rly/sevm_111-1.json.example /root/tmp/
COPY --from=build-env /root/rly/sevm_111-2.json.example /root/tmp/

RUN chmod -R 755 /root/start-rly.sh

EXPOSE 26656 26657 1317 9090 8545 8546

CMD ["bash","/root/start-rly.sh"]

0 comments on commit 2d3c8e5

Please sign in to comment.