Skip to content

Commit

Permalink
Merge pull request #215 from movementlabsxyz/eng-546-atomic-bridge
Browse files Browse the repository at this point in the history
ENG 546 atomic bridge
  • Loading branch information
l-monninger authored Sep 6, 2024
2 parents 86b722e + ec6e074 commit e608512
Show file tree
Hide file tree
Showing 82 changed files with 7,177 additions and 1,034 deletions.
50 changes: 50 additions & 0 deletions .github/scripts/update_move_toml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

MOVE_TOML_PATH="protocol-units/bridge/move-modules/Move.toml"

# Initialize Aptos and capture output
INIT_OUTPUT=$(aptos init 2>&1)
echo "$INIT_OUTPUT"

# Extract the account address from the initialization output
ADDRESS=$(echo "$INIT_OUTPUT" | grep -oE '0x[a-f0-9]{64}' | head -1)
if [[ -z "$ADDRESS" ]]; then
echo "Error: Failed to extract the Aptos account address."
exit 1
fi

# Generate a random seed
RANDOM_SEED=$(shuf -i 0-1000000 -n 1)
echo "Seed: $RANDOM_SEED"

# Derive the resource account address using the random seed
RESOURCE_OUTPUT=$(aptos account derive-resource-account-address --address "$ADDRESS" --seed "" --seed-encoding hex 2>&1)
echo "Resource address derivation output: $RESOURCE_OUTPUT"

# Extract the resource address directly
RESOURCE_ADDRESS=$(echo "$RESOURCE_OUTPUT" | grep -oE '[a-f0-9]{64}')

if [[ -z "$RESOURCE_ADDRESS" ]]; then
echo "Error: Failed to extract the resource account address."
exit 1
fi

# Prepend the 0x to the resource address
RESOURCE_ADDRESS="0x$RESOURCE_ADDRESS"

echo "Extracted address: $ADDRESS"
echo "Derived resource address: $RESOURCE_ADDRESS"

# Update the Move.toml file with the addresses
sed -i "s/^resource_addr = \".*\"/resource_addr = \"$RESOURCE_ADDRESS\"/" "$MOVE_TOML_PATH"
sed -i "s/^atomic_bridge = \".*\"/atomic_bridge = \"$RESOURCE_ADDRESS\"/" "$MOVE_TOML_PATH"
sed -i "s/^moveth = \".*\"/moveth = \"$RESOURCE_ADDRESS\"/" "$MOVE_TOML_PATH"
sed -i "s/^master_minter = \".*\"/master_minter = \"$RESOURCE_ADDRESS\"/" "$MOVE_TOML_PATH"
sed -i "s/^minter = \".*\"/minter = \"$RESOURCE_ADDRESS\"/" "$MOVE_TOML_PATH"
sed -i "s/^admin = \".*\"/admin = \"$RESOURCE_ADDRESS\"/" "$MOVE_TOML_PATH"
sed -i "s/^origin_addr = \".*\"/origin_addr = \"$ADDRESS\"/" "$MOVE_TOML_PATH"

echo "Move.toml updated with ADDRESS: $ADDRESS and RESOURCE_ADDRESS: $RESOURCE_ADDRESS"

echo "Contents of $MOVE_TOML_PATH:"
cat "$MOVE_TOML_PATH"
2 changes: 1 addition & 1 deletion .github/workflows/build-push-containers-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- synchronize
push:
branches:
- main
- '**'

jobs:

Expand Down
126 changes: 123 additions & 3 deletions .github/workflows/checks-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ on:
- synchronize
push:
branches:
- main
- '**'

jobs:

cargo-check:
strategy:
matrix:
Expand Down Expand Up @@ -140,6 +141,127 @@ jobs:
- name: Run MCR Client Tests
run: nix develop --command bash -c "just mcr-client native build.local.test -t=false"

move-modules-test:
strategy:
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
runs-on: buildjet-8vcpu-ubuntu-2204

runs-on: ${{ matrix.runs-on }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Aptos CLI
run: |
curl -fsSL "https://aptos.dev/scripts/install_cli.py" | python3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Run Aptos Tests
run: |
nix develop --command bash -c "
set -e
set -x
chmod +x .github/scripts/update_move_toml.sh && \
./.github/scripts/update_move_toml.sh && \
cd protocol-units/bridge/move-modules && \
aptos move test
"
bridge-shared-lib-tests:
strategy:
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
runs-on: buildjet-8vcpu-ubuntu-2204

runs-on: ${{ matrix.runs-on }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Run rust tests
run: |
nix develop --command bash -c "
cargo test -p bridge-shared
"
solidity-bridge-tests:
strategy:
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
runs-on: buildjet-8vcpu-ubuntu-2204

runs-on: ${{ matrix.runs-on }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Run foundry tests
run: |
nix develop --command bash -c "
cd protocol-units/bridge/contracts && \
forge test --fork-url https://ethereum-sepolia-rpc.publicnode.com -vv
"
bridge-eth-movement:
strategy:
matrix:
include:
- os: ubuntu-22.04
arch: x86_64
runs-on: buildjet-8vcpu-ubuntu-2204

runs-on: ${{ matrix.runs-on }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Movement CLI
run: |
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y binutils
sudo apt-get install -y lld
sudo apt-get install -y libudev-dev
sudo apt-get install -y libdw-dev
which ld
which lld
which gcc
which cc
echo $PATH
export GIT_CLONE_PROTECTION_ACTIVE=false
git clone https://github.com/movementlabsxyz/aptos-core/
cd aptos-core
cargo build -p movement
sudo cp target/debug/movement /usr/local/bin/
cd -
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: Run eth_movement tests
run: |
nix develop --command bash -c "
rust_backtrace=1 cargo test --test eth_movement -- --nocapture --test-threads=1
"
# Indexer:
# strategy:
# matrix:
Expand All @@ -160,5 +282,3 @@ jobs:
# - name: Run Indexer tests in nix environment
# # adjust the log level while debugging
# run: CELESTIA_LOG_LEVEL=FATAL nix develop --command bash -c "just suzuka-full-node native build.celestia-local.indexer.hasura.indexer-test -t=false"


6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.DS_Store
proc-compose.temp.log
methods/guest/Cargo.lock
protocol-units/bridge/move-modules/.aptos/*
protocol-units/bridge/move-modules/build/*
protocol-units/bridge/contracts/cache/*
protocol-units/bridge/contracts/out/*
protocol-units/bridge/contracts/cache/*
protocol-units/bridge/move-modules/build/*
protocol-units/bridge/move-modules/.aptos/*
.idea/
target/
ledger_db/
Expand Down
Loading

0 comments on commit e608512

Please sign in to comment.