Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup bridge service #214

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
5 changes: 4 additions & 1 deletion solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const config: HardhatUserConfig = {
// forking: {
// url: `${process.env.MAINNET_URL || "https://mainnet.infura.io/v3/infura-key"}`,
// }
chainId: 1337
chainId: 1337,
mining: {
interval: 3000
},
},
mainnet: {
url: `${process.env.MAINNET_URL || "https://mainnet.infura.io/v3/infura-key"}`,
Expand Down
8 changes: 4 additions & 4 deletions solidity/tasks/bridge_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ const initBridge = task("init-bridge", "init bridge contract")
.addParam("restUrl", "fx node rest rpc url", undefined, string, false)
.addParam("chainName", "init cross chain name", undefined, string, false)
.setAction(async (taskArgs, hre) => {
const {bridgeLogic, bridgeContract, fxRestUrl, chainName} = taskArgs;
const {bridgeLogic, bridgeContract, restUrl, chainName} = taskArgs;
const {wallet} = await hre.run(SUB_CHECK_PRIVATE_KEY, taskArgs);
const from = await wallet.getAddress();

const bridge_logic_factory = await hre.ethers.getContractFactory("FxBridgeLogic")

const oracle_set = await GetOracleSet(fxRestUrl, chainName)
const gravity_id_str = await GetGravityId(fxRestUrl, chainName)
const oracle_set = await GetOracleSet(restUrl, chainName)
const gravity_id_str = await GetGravityId(restUrl, chainName)
const gravity_id = hre.ethers.encodeBytes32String(gravity_id_str);

const external_addresses = [];
Expand All @@ -130,7 +130,7 @@ const initBridge = task("init-bridge", "init bridge contract")
])

if (bridgeLogic) {
const proxy_factory = await hre.ethers.getContractFactory("TransparentUpgradeableProxy")
const proxy_factory = await hre.ethers.getContractAt("ITransparentUpgradeableProxy", bridgeContract, wallet)
data = proxy_factory.interface.encodeFunctionData('upgradeToAndCall', [bridgeLogic, data])
}

Expand Down
4 changes: 3 additions & 1 deletion tests/scripts/bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ EOF
container_name: fx-$bridge_name
image: $BRIDGE_IMAGE
hostname: fx-$bridge_name
command: bridge --bridge-chain-name="$chain" --bridge-node-url="$external_json_rpc_url" --bridge-addr="$bridge_contract_address" --fx-gas-price=4000000000000FX --fx-grpc="http://fxcore:9090" --bridge-key=/root/eth-$bridge_name.key --bridge-pwd=12345678 --fx-key=/root/fx-$bridge_name.key --fx-pwd=/root/fx-$bridge_name.password
command: bridge --bridge-chain-name="$chain" --bridge-node-url="$external_json_rpc_url" --bridge-addr="$bridge_contract_address" --fx-gas-price=4000000000000FX --fx-grpc="http://fxcore:9090" --bridge-key=/root/eth-$bridge_name.key --bridge-pwd=12345678 --fx-key=/root/fx-$bridge_name.key --fx-pwd=12345678
networks:
- $DOCKER_NETWORK
volumes:
Expand All @@ -129,6 +129,8 @@ networks:
$DOCKER_NETWORK:
external: true
EOF

docker-compose -f "$OUT_DIR/bridge-docker-compose.yml" up -d
}

function request_batch() {
Expand Down
8 changes: 7 additions & 1 deletion tests/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function run() {
)

(
export LOCAL_PORT=8535
LOCAL_PORT=8535
export LOCAL_PORT
"${script_dir}/ethereum.sh" start
"${script_dir}/ethereum.sh" deploy_bridge_token
"${script_dir}/ethereum.sh" deploy_bridge_contract
Expand Down Expand Up @@ -46,6 +47,11 @@ function run() {
"${script_dir}/bridge.sh" create_oracles eth
"${script_dir}/bridge.sh" update_crosschain_oracles eth
"${script_dir}/bridge.sh" create_oracle_bridger eth

LOCAL_PORT=8535
export LOCAL_PORT
"${script_dir}/ethereum.sh" init_bridge
"${script_dir}/bridge.sh" setup_bridge_server eth
)

}
Expand Down
Loading