Skip to content

Commit

Permalink
init nam amount
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Oct 21, 2023
1 parent 9fb33c9 commit 76243ef
Show file tree
Hide file tree
Showing 11 changed files with 5,331 additions and 1,026 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/guide-templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,21 @@ concurrency:
jobs:
template-checker:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
mold: [2.1.0]
env:
RUSTFLAGS: '-C linker=clang -C link-arg=-fuse-ld=/usr/local/bin/mold'
timeout-minutes: 90
steps:
- uses: actions/checkout@v3
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install mold linker
run: |
wget -q -O- https://github.com/rui314/mold/releases/download/v${{ matrix.mold }}/mold-${{ matrix.mold }}-x86_64-linux.tar.gz | tar -xz
mv mold-${{ matrix.mold }}-x86_64-linux/bin/mold /usr/local/bin
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.70.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/misbehaviour.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ concurrency:
jobs:
misbehaviour:
runs-on: ubuntu-20.04
timeout-minutes: 20
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand Down
36 changes: 31 additions & 5 deletions .github/workflows/namada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
matrix:
namada: [0.23.0]
comet_bft: [0.37.2]
mold: [2.1.0]

env:
RUSTFLAGS: '-C linker=clang -C link-arg=-fuse-ld=/usr/local/bin/mold'

steps:
- uses: actions/checkout@v3
Expand All @@ -43,21 +47,43 @@ jobs:
with:
toolchain: 1.70.0
override: true
- name: Install mold linker
run: |
wget -q -O- https://github.com/rui314/mold/releases/download/v${{ matrix.mold }}/mold-${{ matrix.mold }}-x86_64-linux.tar.gz | tar -xz
mv mold-${{ matrix.mold }}-x86_64-linux/bin/mold /usr/local/bin
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: build
args: --bin hermes
- name: Download CometBFT
run: |
curl -o cometbft.tar.gz -LO https://github.com/cometbft/cometbft/releases/download/v${{ matrix.comet_bft }}/cometbft_${{ matrix.comet_bft }}_linux_amd64.tar.gz
tar -xvzf cometbft.tar.gz
mv cometbft /usr/local/bin
- name: Download namada binaries
- name: Install wasm-opt
run: |
curl -o binaryen.tar.gz -LO https://github.com/WebAssembly/binaryen/releases/download/version_114/binaryen-version_114-x86_64-linux.tar.gz
tar -xvzf binaryen.tar.gz
mv binaryen-version_114/bin/wasm-opt /usr/local/bin
- name: Clone Namada
uses: actions/checkout@v3
with:
repository: anoma/namada
ref: v${{ matrix.namada }}
path: namada
- name: Build Namada
run: |
curl -o namada.tar.gz -LO https://github.com/anoma/namada/releases/download/v{{ matrix.namada }}/namada-v{{ matrix.namada }}-Linux-x86_64.tar.gz
tar -xvzf namada.tar.gz
cd namada
make build-release && make build-wasm-scripts
- name: Run test
run: |
pip3 install toml
e2e/namada-e2e-test namada
- name: Upload e2e logs
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: ibc_e2e_log
path: e2e/ibc_e2e.log
retention-days: 5
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:

test-stable:
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: arduino/setup-protoc@v2
Expand Down
15 changes: 14 additions & 1 deletion crates/relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use filter::PacketFilter;

// TODO: Use Byte with u64. `toml::to_string_pretty` failed
// since the Byte is u128 because Namada is using byte-unit with u128.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct Byte(u64);
impl Byte {
#[inline]
Expand All @@ -58,6 +58,19 @@ impl Byte {
}
}

use serde::de::{Deserialize, Deserializer};
impl<'de> Deserialize<'de> for Byte {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let byte = byte_unit::Byte::deserialize(deserializer)?;
let value = u64::from_str(&byte.get_bytes().to_string())
.map_err(|e| serde::de::Error::custom(e.to_string()))?;
Ok(Self::from_bytes(value))
}
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GasPrice {
pub price: f64,
Expand Down
8 changes: 6 additions & 2 deletions e2e/e2e/packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ def args(self) -> List[str]:
return args

def process(self, result: Any) -> TxPacketSendRes:
entry = find_entry(result, 'event')
return from_dict(TxPacketSendRes, entry['SendPacket'])
for entry in result:
if 'event' in entry and 'SendPacket' in entry['event']:
event = entry['event']
return from_dict(TxPacketSendRes, event['SendPacket'])
l.error(f'No SendPacket event')
exit(1)

# -----------------------------------------------------------------------------

Expand Down
31 changes: 12 additions & 19 deletions e2e/namada-e2e-test
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# `make build-release` and `make build-wasm-scripts` on Namada directory in advance
# Run with `namada-e2e-test ${namada_dir}`

set -xe
set -e

NAMADA_DIR=$1
if [ -z "${NAMADA_DIR}" ]
if [ -z "$1" ]
then
echo "ERROR: Namada directory should be given"
exit 1
fi
NAMADA_DIR=$(cd $1 && pwd)
cd $(dirname $0)
HERMES_DIR=${PWD%/e2e*}

Expand All @@ -29,21 +29,14 @@ function init_relayer_balance() {

local base_dir=${DATA_DIR}/namada-${suffix}/.namada

local cnt=0
local cnt_max=$((${INITIAL_BALANCE} / 1000))
while [ ${cnt} -lt ${cnt_max} ]
do
${NAMADAC} --base-dir ${base_dir} \
transfer \
--source albert \
--target relayer \
--token nam \
--amount 1000 \
--signing-keys albert-key \
--node ${ledger_addr}

cnt=$((${cnt} + 1))
done
${NAMADAC} --base-dir ${base_dir} \
transfer \
--source albert \
--target relayer \
--token nam \
--amount ${INITIAL_BALANCE} \
--signing-keys albert-key \
--node ${ledger_addr}
}

# ==== main ====
Expand All @@ -56,6 +49,6 @@ init_relayer_balance "a" ${LEDGER_ADDR_A}
init_relayer_balance "b" ${LEDGER_ADDR_B}

cd ${HERMES_DIR}
python3 e2e/run.py --config ${HERMES_DIR}/config_for_namada.toml 2>&1 | tee e2e/${E2E_TEST_LOG}
python3 e2e/run.py --config ${HERMES_DIR}/config_for_namada.toml > e2e/${E2E_TEST_LOG} 2>&1

killall namadan
13 changes: 6 additions & 7 deletions scripts/setup-namada
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

set -e


# Get absolute path to Namada directory
SCRIPT_DIR=$(cd $(dirname $0) && pwd)
NAMADA_DIR=$(cd $1 && pwd)
cd $SCRIPT_DIR
if [ -z "${NAMADA_DIR}" ]
if [ -z "$1" ]
then
echo "ERROR: Namada directory should be given"
exit 1
fi
# Get absolute path to Namada directory
SCRIPT_DIR=$(cd $(dirname $0) && pwd)
NAMADA_DIR=$(cd $1 && pwd)
cd $SCRIPT_DIR

HERMES_DIR=${PWD%/scripts*}

Expand Down Expand Up @@ -184,4 +183,4 @@ echo "You can use Hermes with ${HERMES_DIR}/config_for_namada.toml"

echo "You also want to run the following lines:"
echo "export CHAIN_A_ID=${chain_id_a}"
echo "export CHAIN_B_ID=${chain_id_b}"
echo "export CHAIN_B_ID=${chain_id_b}"
Loading

0 comments on commit 76243ef

Please sign in to comment.