Skip to content

Commit

Permalink
feat : updated upgrade code for tests
Browse files Browse the repository at this point in the history
ocdbytes committed Dec 3, 2024
1 parent 3c56da4 commit 64df784
Showing 5 changed files with 47 additions and 71 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,15 +16,15 @@ serde_with = { version = "2.3.3", default-features = false }
url = "2.4.1"

# Zaun Deps
ethereum-instance = { git = "https://github.com/karnotxyz/zaun", package = "ethereum-instance", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starkgate-manager-client = { git = "https://github.com/karnotxyz/zaun", package = "starkgate-manager-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starkgate-registry-client = { git = "https://github.com/karnotxyz/zaun", package = "starkgate-registry-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starknet-core-contract-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-core-contract-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starknet-erc20-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-erc20-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starknet-eth-bridge-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-eth-bridge-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starknet-proxy-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-proxy-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
starknet-token-bridge-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-token-bridge-client", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
zaun-utils = { git = "https://github.com/karnotxyz/zaun", package = "utils", rev = "4dcb76238cc98ac871f2684b3b0e7c39366177f1" }
ethereum-instance = { git = "https://github.com/karnotxyz/zaun", package = "ethereum-instance", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starkgate-manager-client = { git = "https://github.com/karnotxyz/zaun", package = "starkgate-manager-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starkgate-registry-client = { git = "https://github.com/karnotxyz/zaun", package = "starkgate-registry-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starknet-core-contract-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-core-contract-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starknet-erc20-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-erc20-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starknet-eth-bridge-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-eth-bridge-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starknet-proxy-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-proxy-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
starknet-token-bridge-client = { git = "https://github.com/karnotxyz/zaun", package = "starknet-token-bridge-client", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }
zaun-utils = { git = "https://github.com/karnotxyz/zaun", package = "utils", rev = "34bda2ccb69fb26be9cdfe091c11f27480850c96" }

# Starknet Deps
starknet = "0.11.0"
48 changes: 23 additions & 25 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -238,31 +238,6 @@ pub async fn bootstrap(config_file: &ConfigFile, clients: &Clients) -> Bootstrap
// setup L2
let l2_output = setup_l2(config_file, clients).await;

// upgrading the bridge :
// TODO : remove this hardcoded value
let account = build_single_owner_account(
clients.provider_l2(),
&config_file.rollup_priv_key,
"0x4fe5eea46caa0a1f344fafce82b39d66b552f00d3cd12e89073ef4b4ab37860",
false,
)
.await;
upgrade_eth_token_to_cairo_1(
&account,
clients.provider_l2(),
l2_output.eth_bridge_setup_outputs.clone().unwrap().l2_eth_proxy_address,
)
.await;
upgrade_eth_bridge_to_cairo_1(
&account,
clients.provider_l2(),
l2_output.eth_bridge_setup_outputs.clone().unwrap().l2_eth_bridge_proxy_address,
)
.await;
upgrade_l1_bridge(l2_output.eth_bridge_setup_outputs.clone().unwrap().l1_bridge_address, config_file)
.await
.unwrap();

BootstrapperOutput {
starknet_contract_address: Some(core_contract_client.core_contract_client.address()),
starknet_contract_implementation_address: Some(
@@ -411,6 +386,29 @@ pub async fn setup_l2(config_file: &ConfigFile, clients: &Clients) -> Bootstrapp
// setup braavos account
let braavos_setup_outputs = setup_braavos(Some(account.clone()), config_file, clients).await;

// upgrading the bridge :
// TODO : remove this hardcoded value
let account = build_single_owner_account(
clients.provider_l2(),
&config_file.rollup_priv_key,
"0x4fe5eea46caa0a1f344fafce82b39d66b552f00d3cd12e89073ef4b4ab37860",
false,
)
.await;
upgrade_eth_token_to_cairo_1(
&account,
clients.provider_l2(),
eth_bridge_setup_outputs.clone().l2_eth_proxy_address,
)
.await;
upgrade_eth_bridge_to_cairo_1(
&account,
clients.provider_l2(),
eth_bridge_setup_outputs.clone().l2_eth_bridge_proxy_address,
)
.await;
upgrade_l1_bridge(eth_bridge_setup_outputs.clone().l1_bridge_address, config_file).await.unwrap();

BootstrapperOutput {
eth_bridge_setup_outputs: Some(eth_bridge_setup_outputs),
erc20_bridge_setup_outputs: Some(erc20_bridge_setup_outputs),
2 changes: 1 addition & 1 deletion src/setup_scripts/upgrade_l2_bridge.rs
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ pub async fn upgrade_eth_bridge_to_cairo_1(
.invoke_contract(
account.address(),
"deploy_contract",
vec![eth_bridge_eic_class_hash, Felt::ZERO, Felt::ZERO, Felt::ZERO],
vec![eth_bridge_eic_class_hash, Felt::ONE, Felt::ZERO, Felt::ZERO],
None,
)
.send()
32 changes: 5 additions & 27 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -3,13 +3,12 @@ mod erc20_bridge;
mod eth_bridge;
mod madara;

use std::time::Duration;

use rstest::rstest;
use tokio::time::sleep;

use crate::contract_clients::config::Clients;
use crate::contract_clients::utils::build_single_owner_account;
use crate::setup_scripts::upgrade_eth_token::upgrade_eth_token_to_cairo_1;
use crate::setup_scripts::upgrade_l1_bridge::upgrade_l1_bridge;
use crate::setup_scripts::upgrade_l2_bridge::upgrade_eth_bridge_to_cairo_1;
use crate::tests::erc20_bridge::erc20_bridge_test_helper;
use crate::tests::eth_bridge::eth_bridge_test_helper;
use crate::tests::madara::MadaraCmdBuilder;
@@ -54,32 +53,11 @@ async fn test_setup(args: &ConfigFile, clients: &Clients) -> BootstrapperOutput
.run();
node.wait_for_ready().await;

sleep(Duration::from_secs(5)).await;

// Setup L2 with the updated config
let l2_output = setup_l2(&config, clients).await;

// upgrading the bridge :
// TODO : remove this hardcoded account address value
let account = build_single_owner_account(
clients.provider_l2(),
&config.rollup_priv_key,
"0x4fe5eea46caa0a1f344fafce82b39d66b552f00d3cd12e89073ef4b4ab37860",
false,
)
.await;
upgrade_eth_token_to_cairo_1(
&account,
clients.provider_l2(),
l2_output.eth_bridge_setup_outputs.clone().unwrap().l2_eth_proxy_address,
)
.await;
upgrade_eth_bridge_to_cairo_1(
&account,
clients.provider_l2(),
l2_output.eth_bridge_setup_outputs.clone().unwrap().l2_eth_bridge_proxy_address,
)
.await;
upgrade_l1_bridge(l2_output.eth_bridge_setup_outputs.clone().unwrap().l1_bridge_address, &config).await.unwrap();

BootstrapperOutput {
starknet_contract_address: Some(core_contract_address),
starknet_contract_implementation_address: Some(core_contract_implementation_address),

0 comments on commit 64df784

Please sign in to comment.