Skip to content

Commit

Permalink
Merge pull request #864 from movementlabsxyz/primata/simple-native-br…
Browse files Browse the repository at this point in the history
…idge

Trusted Native Bridge
  • Loading branch information
0xmovses authored Nov 19, 2024
2 parents b73fb73 + 41ea3a9 commit 5307e5c
Show file tree
Hide file tree
Showing 41 changed files with 771 additions and 1,929 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/update_move_toml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ 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/^native_bridge = \".*\"/native_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"
Expand Down
2 changes: 1 addition & 1 deletion protocol-units/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ We identify the following protocol unit categories:
- [Data Availability](./da/m1/README.md): Protocol units concerned with enabling the secure submission and ordered retrieval of transaction data to and from a network. Light node clients and servers are members of this category.
- [Mempool](./mempool/README.md): Protocol units concerned with the acceptance and ordering of transactions in a network prior to consensus. Mempool modules are members of this category.
- [Sequencing](./sequencing/README.md): Protocol units concerned with consensus on the order of transactions in a network. Sequencer node implementations are members of this category.
- [Bridge](./bridge): Protocol units concerned with cross-blockchain bridging using atomic swaps. The atomic bridge consists of several packages and utilities to bridge from Ethereum to Movement, which can be extended to support any blockchains.
- [Bridge](./bridge): Protocol units concerned with cross-blockchain bridging using atomic swaps. The native bridge consists of several packages and utilities to bridge from Ethereum to Movement, which can be extended to support any blockchains.
- [Cryptography](./cryptography): Protocol units concerned with cryptographic operations. Cryptography and data structure-related utilities are members of this category.
- [Execution](./execution): Protocol units concerned with execution. Block executors and related unities are members of this category.
- [Movement REST service](./movement-rest): Protocol units to support Movement's REST API. `movement-rest` provides additional Movement REST API endpoints.
Expand Down
2 changes: 1 addition & 1 deletion protocol-units/bridge/cli/src/clap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(name = "Movementlabs Bridge CLI")]
#[command(about = "Command line interface to perform an atomic bridge transfers", long_about = None)]
#[command(about = "Command line interface to perform an native bridge transfers", long_about = None)]
pub struct CliOptions {
#[command(subcommand)]
pub command: Commands,
Expand Down
4 changes: 2 additions & 2 deletions protocol-units/bridge/cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bridge_cli::{
clap::eth_to_movement::{self, EthSharedArgs},
eth_to_moveth,
};
use ethereum_bridge::types::{AtomicBridgeInitiator, EthAddress};
use ethereum_bridge::types::{NativeBridgeInitiator, EthAddress};
use movement_bridge::utils::MovementAddress;
use std::str::FromStr;
use url::Url;
Expand All @@ -22,7 +22,7 @@ async fn test_swap() -> eyre::Result<()> {
// Deploy contracts
let wallet = anvil.keys()[0].clone();

let initiator_contract = AtomicBridgeInitiator::deploy(provider).await?;
let initiator_contract = NativeBridgeInitiator::deploy(provider).await?;

// Set up EthSharedArgs
let eth_shared_args: EthSharedArgs = EthSharedArgs {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion protocol-units/bridge/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ src = "src"
out = "out"
libs = ["lib"]

solc = "0.8.26"
solc = "0.8.27"
evm_version = "cancun"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
Expand Down
2 changes: 1 addition & 1 deletion protocol-units/bridge/contracts/lib/openzeppelin-contracts
101 changes: 101 additions & 0 deletions protocol-units/bridge/contracts/script/NativeBridgeDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// To Deploy
// forge script NativeBridgeDeployer --fork-url https://holesky.infura.io/v3/YOUR_INFURA_PROJECT_ID --broadcast --verify --etherscan-api-key YOUR_ETHERSCAN_API_KEY
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;

import "forge-std/Script.sol";
import {NativeBridge} from "../src/NativeBridge.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Vm} from "forge-std/Vm.sol";

contract NativeBridgeDeployer is Script {
TransparentUpgradeableProxy public nativeBridgeProxy;
TimelockController public timelock;
string public nativeBridgeSignature = "initialize(address,address,address,address,uint256)";
address public proxyAdmin;

// TODO: all params are hardcoded for testnet deployment for now
// Parameters
address public moveTokenAddress = 0xC36ba8B8fD9EcbF36288b9B9B0ae9FC3E0645227;
address public ownerAddress = 0x5b97cdf756f6363A88706c376464180E008Bd88b; // Replace with your .env PRIVATE_KEY address for testing

// Safe addresses (replace these with actual safe addresses)
address public movementLabsSafe = 0x493516F6dB02c9b7f649E650c5de244646022Aa0;
address public movementFoundationSafe = 0x00db70A9e12537495C359581b7b3Bc3a69379A00;

bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");

uint256 public minDelay = 2 days;

function run() external {
uint256 signer = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(signer);

address[] memory proposers = new address[](1);
address[] memory executors = new address[](1);

proposers[0] = movementLabsSafe;
executors[0] = movementFoundationSafe;

// Deploy TimelockController
timelock = new TimelockController(minDelay, proposers, executors, address(0));
console.log("Timelock deployed at:", address(timelock));

// Deploy NativeBridge contract
_deployNativeBridge();

vm.stopBroadcast();
}

function _deployNativeBridge() internal {
console.log("NativeBridge: deploying");

// Instantiate the implementation contract
NativeBridge nativeBridgeImplementation = new NativeBridge();

vm.recordLogs();
// Deploy the TransparentUpgradeableProxy
nativeBridgeProxy = new TransparentUpgradeableProxy(
address(nativeBridgeImplementation),
address(timelock), // Admin is the timelock
abi.encodeWithSignature(
nativeBridgeSignature,
moveTokenAddress, // MOVE token address
ownerAddress, // Owner of the contract
ownerAddress, // Owner of the contract
ownerAddress // Owner of the contract
)
);

Vm.Log[] memory logs = vm.getRecordedLogs();
proxyAdmin = logs[logs.length - 2].emitter;
console.log("proxy admin:", proxyAdmin);

console.log("nativeBridgeProxy deployed at proxy address:", address(nativeBridgeProxy));
console.log("Implementation address:", address(nativeBridgeImplementation));
}

function _upgradeAtomicBridge() internal {
console.log("NativeBridge: upgrading");
NativeBridge newBridgeImplementation = new NativeBridge();
require(proxyAdmin != address(0), "Proxy admin not set");
timelock.schedule(
proxyAdmin,
0,
abi.encodeWithSignature(
"upgradeAndCall(address,address,bytes)",
address(nativeBridgeProxy),
address(newBridgeImplementation),
abi.encodeWithSignature(
nativeBridgeSignature, moveTokenAddress, ownerAddress, ownerAddress, ownerAddress
)
),
bytes32(0),
bytes32(0),
block.timestamp + minDelay
);
}
}

This file was deleted.

128 changes: 0 additions & 128 deletions protocol-units/bridge/contracts/src/AtomicBridgeInitiatorMOVE.sol

This file was deleted.

Loading

0 comments on commit 5307e5c

Please sign in to comment.