refactor: cleanup obsolete test folder (#166)

### Summary
Removes the obsolete `operator/test` folder that was no longer being
used and contained outdated test scripts.

### Changes
-  Deleted `operator/test/` directory and all contents
-  Moved `test_message_encoding.sh` script to `operator/scripts/` for
proper organization
-  Updated comment reference in `contracts/test/MessageEncoding.t.sol`
to point to new script location

### Impact
- **No breaking changes** - All legitimate test files remain properly
organized within their respective pallets
- **Cleaner codebase** - Removes unused/obsolete code
This commit is contained in:
Ahmad Kaouk 2025-09-17 14:21:55 +02:00 committed by GitHub
parent 89cff99da0
commit 5db1f4ee74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 1 additions and 2150 deletions

View file

@ -8,7 +8,7 @@ import {TestUtils} from "./utils/TestUtils.sol";
// This test is used to encode the receive validators message and print the hex string.
// Run forge test --match-test testEncodeReceiveValidatorsMessage -vvv to see the hex encoded bytes.
// Use the helper script in operator/test/scripts/test_message_encoding.sh to test the encoding/decoding full cycle.
// Use the helper script in operator/scripts/test_message_encoding.sh to test the encoding/decoding full cycle.
contract MessageEncodingTest is Test {
function testEncodeReceiveValidatorsMessage() public pure {
// Use the utility function for consistency

View file

@ -1,26 +0,0 @@
{
"source": {
"beacon": {
"endpoint": "http://127.0.0.1:9596",
"stateEndpoint": "http://127.0.0.1:9596",
"spec": {
"syncCommitteeSize": 512,
"slotsInEpoch": 32,
"epochsPerSyncCommitteePeriod": 256,
"denebForkedEpoch": 0
},
"datastore": {
"location": "",
"maxEntries": 100
}
}
},
"sink": {
"parachain": {
"endpoint": "",
"maxWatchedExtrinsics": 8,
"headerRedundancy": 20
},
"updateSlotInterval": 30
}
}

View file

@ -1,61 +0,0 @@
{
"config": {
"chainId": 11155111,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"ethash": {},
"terminalTotalDifficulty": 0,
"ShanghaiTime": 0,
"CancunTime": null,
"terminalTotalDifficultyPassed": true
},
"difficulty": "0x9FFE0",
"gasLimit": "80000000",
"alloc": {
"90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe": {
"balance": "1000000000000000000000000"
},
"Be68fC2d8249eb60bfCf0e71D5A0d2F2e292c4eD": {
"balance": "100000000000000000000"
},
"89b4AB1eF20763630df9743ACF155865600daFF2": {
"balance": "100000000000000000000"
},
"04E00e6D2e9Ea1E2AF553De02A5172120BFA5c3e": {
"balance": "100000000000000000000"
},
"a255dC78C1510e2c1332fBAC2de848058f479CEE": {
"balance": "100000000000000000000"
},
"ACbd24742b87c34dED607FB87b22401B2Ede167E": {
"balance": "100000000000000000000"
},
"01F6749035e02205768f97e6f1d394Fb6769EC20": {
"balance": "100000000000000000000"
},
"8b66D5499F52D6F1857084A61743dFCB9a712859": {
"balance": "100000000000000000000"
},
"13e16C4e5787f878f98a610EB321170512b134D4": {
"balance": "100000000000000000000"
},
"eEBFA6B9242A19f91a0463291A937a20e3355681": {
"balance": "100000000000000000000"
},
"87D987206180B8f3807Dd90455606eEa85cdB87a": {
"balance": "100000000000000000000"
},
"0xACbd24742b87c34dED607FB87b22401B2Ede167E": {
"balance": "100000000000000000000"
}
}
}

View file

@ -1 +0,0 @@
0xdc6457099f127cf0bac78de8b297df04951281909db4f58b43def7c7151e765d

View file

@ -1,24 +0,0 @@
{
"source": {
"polkadot": {
"endpoint": "ws://127.0.0.1:30444"
}
},
"sink": {
"ethereum": {
"endpoint": "ws://127.0.0.1:8546",
"gas-limit": null
},
"descendants-until-final": 3,
"contracts": {
"BeefyClient": null,
"Gateway": null
}
},
"on-demand-sync": {
"asset-hub-channel-id": "0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539",
"max-tokens": 5,
"refill-amount": 1,
"refill-period": 3600
}
}

View file

@ -1,21 +0,0 @@
[settings]
timeout = 120
[relaychain]
chain = "local"
default_args = [
"-l=debug",
"--pruning=archive",
"--enable-offchain-indexing=true",
"--offchain-worker=when-authority",
]
default_command = "${output_bin_dir:-./target/release}/datahaven-node"
[[relaychain.nodes]]
name = "alice"
validator = true
ws_port = 30444
[[relaychain.nodes]]
name = "bob"
validator = true

View file

@ -1,57 +0,0 @@
const { ethers } = require('ethers');
async function getBeefyBlock(contractAddress, providerUrl) {
// Connect to the network
const provider = new ethers.JsonRpcProvider(providerUrl);
// BeefyClient ABI - we only need the latestBeefyBlock function
const abi = [
"function latestBeefyBlock() view returns (uint64)",
"function latestMMRRoot() view returns (bytes32)"
];
// Create contract instance
const beefyClient = new ethers.Contract(contractAddress, abi, provider);
try {
// Get the latest beefy block
const blockNumber = await beefyClient.latestBeefyBlock();
const mmrRoot = await beefyClient.latestMMRRoot();
console.log('Latest Beefy Block Number:', blockNumber.toString());
console.log('Latest MMR Root:', mmrRoot);
return {
blockNumber: blockNumber,
mmrRoot: mmrRoot
};
} catch (error) {
console.error('Error fetching beefy block:', error);
throw error;
}
}
// If this file is being run directly (not imported)
if (require.main === module) {
// Get command line arguments
const args = process.argv.slice(2);
const contractAddress = args[0];
const providerUrl = args[1];
if (!contractAddress || !providerUrl) {
console.error('Usage: node beefyBlockClient.js <contract-address> <provider-url>');
console.error('Example: node beefyBlockClient.js 0x1234... http://localhost:8545');
process.exit(1);
}
// Run the script
getBeefyBlock(contractAddress, providerUrl)
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
} else {
// Export for use in other files
module.exports = { getBeefyBlock };
}

File diff suppressed because it is too large Load diff

View file

@ -1,15 +0,0 @@
{
"name": "beefy-client-helpers",
"version": "1.0.0",
"description": "Helper scripts for testing BeefyClient",
"scripts": {
"beefy-client": "node getBeefyBlock.js",
"submit-checkpoint": "node submit-checkpoint.js"
},
"dependencies": {
"ethers": "6.13.5",
"@polkadot/api": "15.5.1",
"@polkadot/util": "13.4.3",
"@polkadot/util-crypto": "13.4.3"
}
}

View file

@ -1,95 +0,0 @@
// Script to submit a force_checkpoint extrinsic to the datahaven runtime
const { ApiPromise, WsProvider, Keyring } = require("@polkadot/api");
const { cryptoWaitReady } = require("@polkadot/util-crypto");
const fs = require("fs");
const path = require("path");
// Configuration
const NODE_URL = "ws://127.0.0.1:30444"; // Default Substrate node WebSocket endpoint
async function main() {
// Check if checkpoint file path is provided as an argument
if (process.argv.length < 3) {
console.error("Usage: node submit-checkpoint.js <path-to-checkpoint-json-file>");
console.error("Example: node submit-checkpoint.js ./path/to/checkpoint.json");
process.exit(1);
}
const checkpointFilePath = process.argv[2];
// Wait for the crypto libraries to be ready
await cryptoWaitReady();
// Create a keyring instance (for signing transactions)
const keyring = new Keyring({ type: "sr25519" });
// Add the sudo account (//Alice is the default development account with sudo access)
const sudoAccount = keyring.addFromUri("//Alice");
console.log(`Using account: ${sudoAccount.address}`);
// Connect to the node
console.log(`Connecting to node at ${NODE_URL}...`);
const provider = new WsProvider(NODE_URL);
const api = await ApiPromise.create({ provider });
// Get the chain information
const [chain, nodeName, nodeVersion] = await Promise.all([
api.rpc.system.chain(),
api.rpc.system.name(),
api.rpc.system.version(),
]);
console.log(`Connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
try {
// Read and parse the checkpoint data from the file
const resolvedFilePath = path.resolve(checkpointFilePath);
console.log(`Reading checkpoint data from file: ${resolvedFilePath}`);
if (!fs.existsSync(resolvedFilePath)) {
console.error(`Error: File not found: ${resolvedFilePath}`);
process.exit(1);
}
const fileContent = fs.readFileSync(resolvedFilePath, "utf8");
let checkpointData;
try {
checkpointData = JSON.parse(fileContent);
console.log("Successfully parsed checkpoint data from file");
} catch (parseError) {
console.error(`Error parsing JSON file: ${parseError.message}`);
process.exit(1);
}
// Log the checkpoint data for debugging
console.log("Checkpoint data:", JSON.stringify(checkpointData, null, 2));
// Create the extrinsic for force_checkpoint
// We need to use sudo since force_checkpoint requires root privileges
console.log("Creating extrinsic...");
const extrinsic = api.tx.sudo.sudo(api.tx.ethereumBeaconClient.forceCheckpoint(checkpointData));
// Sign and send the transaction
console.log("Submitting extrinsic...");
const hash = await extrinsic.signAndSend(sudoAccount);
console.log(`Extrinsic submitted with hash: ${hash.toHex()}`);
} catch (error) {
console.error("Error:", error);
} finally {
// Disconnect from the API
await api.disconnect();
console.log("Disconnected from the node");
}
}
// Run the main function
main()
.then(() => {
console.log("Done!");
process.exit(0);
})
.catch((error) => {
console.error("Error in main function:", error);
process.exit(1);
});

View file

@ -1,37 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
build_binary() {
pushd $root_dir
check_local_changes $root_dir
# Check if datahaven binary exists
if [ ! -f "target/release/datahaven-node" ] || [ $changes_detected -eq 1 ]; then
echo "Building datahaven-node..."
cargo build --release --features fast-runtime
fi
# Copy binary to output directory
cp target/release/datahaven-node "$output_bin_dir"
popd
}
changes_detected=0
check_local_changes() {
local dir=$1
cd "$dir"
if git status --untracked-files=no --porcelain . | grep .; then
changes_detected=1
fi
cd -
}
if [ -z "${from_build_binary:-}" ]; then
echo "Building DataHaven Binary"
trap kill_all SIGINT SIGTERM EXIT
build_binary
echo "DataHaven Binary built"
fi

View file

@ -1,23 +0,0 @@
#!/bin/bash
# Exit on any error
set -e
source scripts/set-env.sh
build_snowbridge_contracts() {
if [ -d "$relayer_dir" ]; then
echo "Snowbridge contracts seem to be already downloaded. Skipping downloading again"
else
echo "Downloading datahaven-bridge-relayer"
git clone --recurse-submodules https://github.com/Moonsong-Labs/datahaven-bridge-relayer $relayer_dir
fi
pushd $snowbridge_contracts_dir
forge build
popd
}
if [ -z "${from_start_services:-}" ]; then
echo "Building snowbridge contracts"
build_snowbridge_contracts
fi

View file

@ -1,45 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
build_lodestar() {
if [ -d "$lodestar_dir" ]; then
echo "Lodestar seems to be already downloaded. Skipping downloading again"
else
echo "Downloading Lodestar"
git clone https://github.com/ChainSafe/lodestar $lodestar_dir
pushd $lodestar_dir
git fetch && git checkout $LODESTAR_TAG
popd
fi
echo "Building Lodestar"
pushd $lodestar_dir
yarn install
yarn build
popd
}
build_geth() {
echo "Downloading geth"
if [ -d "$geth_dir" ]; then
echo "Geth seems to be already downloaded. Skipping downloading"
else
git clone https://github.com/ethereum/go-ethereum.git $geth_dir
pushd $geth_dir
git fetch && git checkout $GETH_TAG
popd
fi
echo "Building Geth"
pushd $geth_dir
GOBIN=$output_bin_dir go install ./cmd/geth
GOBIN=$output_bin_dir go install ./cmd/abigen
popd
}
echo "Building ethereum nodes"
build_lodestar
build_geth
echo "ethereum nodes built!"

View file

@ -1,43 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
deploy_command() {
local deploy_script=$1
local contract_dir=$2
pushd "$contract_dir"
if [ "$eth_network" != "localhost" ]; then
forge script \
--rpc-url $eth_endpoint_http \
--broadcast \
--verify \
--etherscan-api-key $etherscan_api_key \
-vvv \
$deploy_script
else
forge script \
--rpc-url $eth_endpoint_http \
--broadcast \
-vvv \
$deploy_script
fi
popd
}
deploy_snowbridge_contracts()
{
deploy_command scripts/DeployLocal.sol:DeployLocal $snowbridge_contracts_dir
pushd "$test_helpers_dir"
contract_dir=$snowbridge_contracts_dir pnpm generateContracts "$output_dir/contracts.json"
popd
echo "Exported contract artifacts: $output_dir/contracts.json"
}
if [ -z "${from_start_services:-}" ]; then
echo "Deploying contracts"
deploy_snowbridge_contracts
fi

View file

@ -1,22 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
zombienet_launch() {
zombienet spawn config/zombie-datahaven-local.toml --provider=native --dir="$zombienet_data_dir" 2>&1 &
echo "Waiting for nodes to spawn..."
wait_for_port 30444
}
deploy_datahaven() {
rm -rf $zombienet_data_dir && zombienet_launch
}
if [ -z "${from_start_services:-}" ]; then
echo "start datahaven only!"
trap kill_all SIGINT SIGTERM EXIT
deploy_datahaven
echo "datahaven nodes started"
wait
fi

View file

@ -1,122 +0,0 @@
#!/bin/bash
# Exit on any error
set -e
# Start ethereum nodes, the nodes must be built first
source scripts/set-env.sh
start_geth() {
if [ "$reset_ethereum" == "true" ]; then
echo "db reset!"
rm -rf "$ethereum_data_dir"
fi
echo "Starting geth local node"
local timestamp="0" #start Cancun from genesis
jq \
--argjson timestamp "$timestamp" \
'
.config.CancunTime = $timestamp
' \
$assets_dir/genesis.json > $output_dir/genesis.json
geth init --datadir "$ethereum_data_dir" --state.scheme=hash "$output_dir/genesis.json"
geth --vmdebug --datadir "$ethereum_data_dir" --networkid 11155111 \
--http --http.api debug,personal,eth,net,web3,txpool,engine,miner --ws --ws.api debug,eth,net,web3 \
--rpc.allow-unprotected-txs --mine \
--miner.etherbase=0xBe68fC2d8249eb60bfCf0e71D5A0d2F2e292c4eD \
--authrpc.addr="127.0.0.1" \
--http.addr="0.0.0.0" \
--ws.addr="0.0.0.0" \
--http.corsdomain '*' \
--allow-insecure-unlock \
--authrpc.jwtsecret $assets_dir/jwtsecret \
--password /dev/null \
--rpc.gascap 0 \
--ws.origins "*" \
--trace "$ethereum_data_dir/trace" \
--gcmode archive \
--syncmode=full \
--state.scheme=hash \
>"$logs_dir/geth.log" 2>&1 &
echo "geth=$!" >> $artifacts_dir/daemons.pid
}
start_lodestar() {
echo "Starting lodestar local node"
local genesisHash=$(curl $eth_endpoint_http \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc": "2.0", "id": "1", "method": "eth_getBlockByNumber","params": ["0x0", false]}' | jq -r '.result.hash')
echo "genesisHash is: $genesisHash"
# use gdate here for raw macos without nix
local timestamp=""
if [[ "$(uname)" == "Darwin" && -z "${IN_NIX_SHELL:-}" ]]; then
timestamp=$(gdate -d'+10second' +%s)
else
timestamp=$(date -d'+10second' +%s)
fi
export LODESTAR_PRESET="mainnet"
pushd $artifacts_dir/lodestar
./lodestar dev \
--genesisValidators 8 \
--genesisTime $timestamp \
--startValidators "0..7" \
--enr.ip6 "127.0.0.1" \
--rest.address "0.0.0.0" \
--eth1.providerUrls "http://127.0.0.1:8545" \
--execution.urls "http://127.0.0.1:8551" \
--dataDir "$ethereum_data_dir" \
--reset \
--terminal-total-difficulty-override 0 \
--genesisEth1Hash $genesisHash \
--params.ALTAIR_FORK_EPOCH 0 \
--params.BELLATRIX_FORK_EPOCH 0 \
--params.CAPELLA_FORK_EPOCH 0 \
--params.DENEB_FORK_EPOCH 0 \
--eth1=true \
--rest.namespace="*" \
--jwt-secret $assets_dir/jwtsecret \
--chain.archiveStateEpochFrequency 1 \
>"$logs_dir/lodestar.log" 2>&1 &
echo "lodestar=$!" >> $artifacts_dir/daemons.pid
popd
}
wait_for_geth() {
echo "Waiting for geth to finish syncing/indexing..."
while true; do
syncing=$(curl -s -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:8545 | jq '.result')
if [ "$syncing" = "false" ]; then
echo "Geth is no longer syncing."
break
else
echo "Geth is still syncing: $syncing"
fi
sleep 3
done
}
deploy_local() {
# 1. deploy execution client
echo "Starting execution node"
start_geth
echo "Waiting for geth API to be ready"
sleep 5
# 2. deploy consensus client
echo "Starting beacon node"
start_lodestar
wait_for_geth
}
if [ -z "${from_start_services:-}" ]; then
echo "start ethereum only!"
trap kill_all SIGINT SIGTERM EXIT
deploy_local
echo "ethereum local nodes started!"
wait
fi

View file

@ -1,33 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
write_beacon_checkpoint() {
pushd $output_dir > /dev/null
$relayer_bin generate-beacon-checkpoint --config $output_dir/beacon-relay.json --export-json > /dev/null
cat $output_dir/dump-initial-checkpoint.json
popd > /dev/null
}
wait_beacon_chain_ready() {
local initial_beacon_block=""
while [ -z "$initial_beacon_block" ] || [ "$initial_beacon_block" == "0x0000000000000000000000000000000000000000000000000000000000000000" ]; do
initial_beacon_block=$(curl -s "$beacon_endpoint_http/eth/v1/beacon/states/head/finality_checkpoints" |
jq -r '.data.finalized.root' || true)
sleep 3
done
}
submit_beacon_checkpoint() {
pushd "$helpers_dir" > /dev/null
pnpm submit-checkpoint "$1"
popd > /dev/null
}
wait_beacon_chain_ready
# Get the checkpoint data
write_beacon_checkpoint
# Submit the checkpoint using the helper script
echo "Submitting checkpoint to the chain..."
submit_beacon_checkpoint "$output_dir/dump-initial-checkpoint.json"

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
generate_beefy_checkpoint()
{
pushd "$test_helpers_dir"
pnpm install
pnpm generateBeefyCheckpoint
popd
}
if [ -z "${from_start_services:-}" ]; then
echo "Generating Beefy Checkpoint"
generate_beefy_checkpoint
wait
fi

View file

@ -1,212 +0,0 @@
#!/usr/bin/env bash
root_dir="$(realpath ..)"
export output_dir="${root_dir}/tmp"
export output_bin_dir="$output_dir/bin"
mkdir -p "$output_bin_dir"
export PATH="$output_bin_dir:$PATH"
scripts_dir="$root_dir/test/scripts"
zombienet_data_dir="$output_dir/zombienet"
ethereum_data_dir="$output_dir/ethereum"
assets_dir="$root_dir/test/assets"
helpers_dir="$root_dir/test/helpers"
artifacts_dir="$output_dir/artifacts"
mkdir -p "$artifacts_dir"
logs_dir="$artifacts_dir/logs"
mkdir -p "$logs_dir"
LODESTAR_TAG="v1.19.0"
GETH_TAG="v1.14.11"
lodestar_dir="$artifacts_dir/lodestar"
geth_dir="$artifacts_dir/geth"
relayer_dir="$artifacts_dir/datahaven-bridge-relayer"
relayer_bin="$relayer_dir/relayer/build/datahaven-bridge-relay"
web_dir="$relayer_dir/snowbridge/web"
snowbridge_contracts_dir="$relayer_dir/snowbridge/contracts"
test_helpers_dir="$web_dir/packages/test-helpers"
eth_network="${ETH_NETWORK:-localhost}"
eth_endpoint_http="${ETH_RPC_ENDPOINT:-http://127.0.0.1:8545}/${INFURA_PROJECT_ID:-}"
eth_endpoint_ws="${ETH_WS_ENDPOINT:-ws://127.0.0.1:8546}/${INFURA_PROJECT_ID:-}"
eth_gas_limit="${ETH_GAS_LIMIT:-5000000}"
etherscan_api_key="${ETHERSCAN_API_KEY:-}"
reset_ethereum="${RESET_ETHEREUM:-true}"
beefy_relay_eth_key="${BEEFY_RELAY_ETH_KEY:-0x935b65c833ced92c43ef9de6bff30703d941bd92a2637cb00cfad389f5862109}"
beacon_endpoint_http="${BEACON_HTTP_ENDPOINT:-http://127.0.0.1:9596}"
# Beacon relay account (//BeaconRelay 5GWFwdZb6JyU46e6ZiLxjGxogAHe8SenX76btfq8vGNAaq8c in testnet)
beacon_relayer_pub_key="${BEACON_RELAYER_PUB_KEY:-0xc46e141b5083721ad5f5056ba1cded69dce4a65f}"
export RELAYCHAIN_ENDPOINT=ws://127.0.0.1:30444
## Deployment key
export PRIVATE_KEY="${DEPLOYER_ETH_KEY:-0x4e9444a6efd6d42725a250b650a781da2737ea308c839eaccb0f7f3dbd2fea77}"
export ETHERSCAN_API_KEY="${ETHERSCAN_API_KEY:-0x0}"
export BRIDGE_HUB_PARAID="${BRIDGE_HUB_PARAID:-1002}"
export BRIDGE_HUB_AGENT_ID="${BRIDGE_HUB_AGENT_ID:-0x03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314}"
export ASSET_HUB_PARAID="${ASSET_HUB_PARAID:-1000}"
export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79}"
export ASSET_HUB_CHANNEL_ID="0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539"
export FOREIGN_TOKEN_DECIMALS=12
## BeefyClient
# For max safety delay should be MAX_SEED_LOOKAHEAD=4 epochs=4*8*6=192s
# but for rococo-local each session is only 20 slots=120s
# so relax somehow here just for quick test
# for production deployment ETH_RANDAO_DELAY should be configured in a more reasonable sense
export RANDAO_COMMIT_DELAY="${ETH_RANDAO_DELAY:-3}"
export RANDAO_COMMIT_EXP="${ETH_RANDAO_EXP:-3}"
export MINIMUM_REQUIRED_SIGNATURES="${MINIMUM_REQUIRED_SIGNATURES:-16}"
export REJECT_OUTBOUND_MESSAGES="${REJECT_OUTBOUND_MESSAGES:-false}"
## Fee
export REGISTER_TOKEN_FEE="${REGISTER_TOKEN_FEE:-200000000000000000}"
export CREATE_ASSET_FEE="${CREATE_ASSET_FEE:-100000000000}"
export RESERVE_TRANSFER_FEE="${RESERVE_TRANSFER_FEE:-100000000000}"
export RESERVE_TRANSFER_MAX_DESTINATION_FEE="${RESERVE_TRANSFER_MAX_DESTINATION_FEE:-10000000000000}"
## Pricing Parameters
export EXCHANGE_RATE="${EXCHANGE_RATE:-2500000000000000}"
export DELIVERY_COST="${DELIVERY_COST:-10000000000}"
export FEE_MULTIPLIER="${FEE_MULTIPLIER:-1000000000000000000}"
## Vault
export GATEWAY_PROXY_INITIAL_DEPOSIT="${GATEWAY_PROXY_INITIAL_DEPOSIT:-10000000000000000000}"
export GATEWAY_STORAGE_KEY="${GATEWAY_STORAGE_KEY:-0xaed97c7854d601808b98ae43079dafb3}"
export GATEWAY_PROXY_CONTRACT="${GATEWAY_PROXY_CONTRACT:-0x87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d}"
address_for() {
jq -r ".contracts.${1}.address" "$output_dir/contracts.json"
}
kill_all() {
trap - SIGTERM
kill 0
}
cleanup() {
echo "Cleaning resource"
rm -rf "$output_dir"
mkdir "$output_dir"
mkdir "$output_bin_dir"
mkdir "$ethereum_data_dir"
}
check_port() {
nc -z localhost $1 >/dev/null 2>&1
}
wait_for_port() {
while ! check_port $1; do
echo "Waiting for port $1 to be available..."
sleep 10
done
}
check_node_version() {
local expected_version=$1
if ! [ -x "$(command -v node)" ]; then
echo 'Error: NodeJS is not installed.'
exit 1
fi
node_version=$(node -v) # This does not seem to work in Git Bash on Windows.
# "node -v" outputs version in the format "v18.12.1"
node_version=${node_version:1} # Remove 'v' at the beginning
node_version=${node_version%\.*} # Remove trailing ".*".
node_version=${node_version%\.*} # Remove trailing ".*".
node_version=$(($node_version)) # Convert the NodeJS version number from a string to an integer.
if [ $node_version -lt "$expected_version" ]
then
echo "NodeJS version is lower than $expected_version (it is $node_version), Please update your node installation!"
exit 1
fi
}
vercomp() {
if [[ $1 == $2 ]]
then
echo "Equal"
return
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if ((10#${ver1[i]:=0} > 10#${ver2[i]:=0}))
then
echo "Greater"
return
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
echo "Less"
return
fi
done
}
check_go_version() {
local expected_version=$1
if ! [ -x "$(command -v go)" ]; then
echo 'Error: Go is not installed.'
exit 1
fi
go_version=$(go version | { read _ _ v _; echo ${v#go}; })
op=$(vercomp "$go_version" "$1")
if [[ $op = "Less" ]]
then
echo "Go version is lower than $expected_version (it is $go_version), Please update your go installation!"
exit 1
fi
}
check_tool() {
if ! [ -x "$(command -v protoc)" ]; then
echo 'Error: protoc is not installed.'
exit 1
fi
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed.'
exit 1
fi
if ! [ -x "$(command -v pnpm)" ]; then
echo 'Error: pnpm is not installed.'
exit 1
fi
if ! [ -x "$(command -v forge)" ]; then
echo 'Error: foundry is not installed.'
exit 1
fi
if ! [ -x "$(command -v yarn)" ]; then
echo 'Error: yarn is not installed.'
exit 1
fi
if [[ "$(uname)" == "Darwin" && -z "${IN_NIX_SHELL:-}" ]]; then
if ! [ -x "$(command -v gdate)" ]; then
echo 'Error: gdate (GNU Date) is not installed.'
exit 1
fi
else
if ! [ -x "$(command -v date)" ]; then
echo 'Error: date is not installed.'
exit 1
fi
fi
check_node_version 20
check_go_version 1.21.2
}

View file

@ -1,87 +0,0 @@
#!/usr/bin/env bash
set -eu
source scripts/set-env.sh
config_relayer() {
data_store_dir="$output_dir/relayer_data"
mkdir -p $data_store_dir
# Configure beefy relay
jq \
--arg k1 "$(address_for BeefyClient)" \
--arg k2 "$(address_for GatewayProxy)" \
--arg eth_endpoint_ws $eth_endpoint_ws \
--arg eth_gas_limit $eth_gas_limit \
--arg assetHubChannelID $ASSET_HUB_CHANNEL_ID \
'
.sink.contracts.BeefyClient = $k1
| .sink.contracts.Gateway = $k2
| .sink.ethereum.endpoint = $eth_endpoint_ws
| .sink.ethereum."gas-limit" = $eth_gas_limit
| ."on-demand-sync"."asset-hub-channel-id" = $assetHubChannelID
' \
config/beefy-relay.json >$output_dir/beefy-relay.json
# Configure beacon relay
local deneb_forked_epoch=0
jq \
--arg beacon_endpoint_http $beacon_endpoint_http \
--argjson deneb_forked_epoch $deneb_forked_epoch \
--arg relay_chain_endpoint $RELAYCHAIN_ENDPOINT \
--arg data_store_dir $data_store_dir \
'
.source.beacon.endpoint = $beacon_endpoint_http
| .source.beacon.spec.denebForkedEpoch = $deneb_forked_epoch
| .sink.parachain.endpoint = $relay_chain_endpoint
| .source.beacon.datastore.location = $data_store_dir
' \
$assets_dir/beacon-relay.json >$output_dir/beacon-relay.json
}
start_relayer() {
echo "Starting relay services"
# Launch beefy relay
(
: >"$output_dir"/beefy-relay.log
while :; do
echo "Starting beefy relay at $(date)"
"${relayer_bin}" run beefy \
--config "$output_dir/beefy-relay.json" \
--ethereum.private-key $beefy_relay_eth_key \
>>"$output_dir"/beefy-relay.log 2>&1 || true
sleep 20
done
) &
# Launch beacon relay
(
: >"$output_dir"/beacon-relay.log
while :; do
echo "Starting beacon relay at $(date)"
"${relayer_bin}" run beacon \
--config $output_dir/beacon-relay.json \
--substrate.private-key "//BeaconRelay" \
>>"$output_dir"/beacon-relay.log 2>&1 || true
sleep 20
done
) &
}
build_relayer() {
echo "Building relayer"
mage -d "$relayer_dir/relayer" build
cp $relayer_bin "$output_bin_dir"
}
deploy_relayer() {
check_tool && build_relayer && config_relayer && start_relayer
}
if [ -z "${from_start_services:-}" ]; then
echo "start relayers only!"
trap kill_all SIGINT SIGTERM EXIT
deploy_relayer
wait
fi

View file

@ -1,49 +0,0 @@
#!/usr/bin/env bash
set -eu
from_start_services=true
# Source environment variables
source scripts/set-env.sh
source scripts/build-binary.sh
trap kill_all SIGINT SIGTERM EXIT
# 0. check required tools
echo "Check building tools"
check_tool
# 1. Buid DataHaven Binary
build_binary
# 2. Start DataHaven Nodes
echo "Starting DataHaven Nodes"
source scripts/deploy-datahaven.sh
deploy_datahaven
# 3. generate beefy checkpoint
echo "Generate beefy checkpoint"
source scripts/generate-beefy-checkpoint.sh
generate_beefy_checkpoint
# 4. Start Ethereum Nodes
# source scripts/build-ethereum.sh
# build_lodestar
# build_geth
# 5. Start Ethereum Nodes
source scripts/deploy-ethereum.sh
echo "Starting Ethereum Nodes"
deploy_local
# 6. Build Snowbridge Contracts
source scripts/build-contracts.sh
echo "Building Snowbridge Contracts"
build_snowbridge_contracts
# 7. Deploy Snowbridge Contracts
source scripts/deploy-contracts.sh
echo "Deploying Snowbridge Contracts"
deploy_snowbridge_contracts
wait