Skip to content

Commit

Permalink
feat : resolved comments 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdbytes committed Dec 21, 2024
1 parent 5212c16 commit b997085
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 42 deletions.
36 changes: 30 additions & 6 deletions src/setup_scripts/core_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,47 @@ impl<'a> CoreContractStarknetL1<'a> {
save_to_json("l1_core_contract_address", &JsonValueType::EthAddress(core_contract_client.address())).unwrap();
let (program_hash, config_hash) = get_bridge_init_configs(self.arg_config);

// add_implementation(
// call_data : [
// 0, : block number
// 0, : state root
// 0, : block hash
// program_hash,
// config_hash,
// verifier_address
// ],
// implementation_address,
// finalized_implementation_bool
// )
core_contract_client
.add_implementation_core_contract(
0u64.into(),
0u64.into(),
0u64.into(),
0u64.into(), // block number
0u64.into(), // state root
0u64.into(), // block hash
program_hash,
config_hash,
core_contract_client.implementation_address(),
Address::from_str(&self.arg_config.verifier_address.clone()).unwrap(),
false,
)
.await;
// upgrade_to(
// call_data : [
// 0, : block number
// 0, : state root
// 0, : block hash
// program_hash,
// config_hash,
// verifier_address
// ],
// implementation_address,
// finalized_implementation_bool
// )
core_contract_client
.upgrade_to_core_contract(
0u64.into(),
0u64.into(),
0u64.into(),
0u64.into(), // block number
0u64.into(), // state root
0u64.into(), // block hash
program_hash,
config_hash,
core_contract_client.implementation_address(),
Expand Down
62 changes: 44 additions & 18 deletions src/setup_scripts/upgrade_eth_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub async fn upgrade_eth_token_to_cairo_1(
log::debug!("✅ new eth contract address : {:?}", new_eth_token_contract_address);
sleep(Duration::from_secs(5)).await;

let txn_1 = account
let eth_token_add_implementation_new_txn = account
.invoke_contract(
l2_eth_token_address,
"add_implementation",
Expand All @@ -109,13 +109,15 @@ pub async fn upgrade_eth_token_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_1.transaction_hash, "Interact ETH token").await.unwrap();
wait_for_transaction(rpc_provider_l2, eth_token_add_implementation_new_txn.transaction_hash, "Interact ETH token")
.await
.unwrap();
log::debug!(
"upgrade_eth_token_to_cairo_1 : add implementation : eth proxy ✅, Txn hash : {:?}",
txn_1.transaction_hash
eth_token_add_implementation_new_txn.transaction_hash
);

let txn_2 = account
let eth_token_upgrade_to_new_txn = account
.invoke_contract(
l2_eth_token_address,
"upgrade_to",
Expand All @@ -125,32 +127,49 @@ pub async fn upgrade_eth_token_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_2.transaction_hash, "Interact ETH token").await.unwrap();
log::debug!("upgrade_eth_token_to_cairo_1 : upgrade to : eth proxy ✅, Txn hash : {:?}", txn_2.transaction_hash);
wait_for_transaction(rpc_provider_l2, eth_token_upgrade_to_new_txn.transaction_hash, "Interact ETH token")
.await
.unwrap();
log::debug!(
"upgrade_eth_token_to_cairo_1 : upgrade to : eth proxy ✅, Txn hash : {:?}",
eth_token_upgrade_to_new_txn.transaction_hash
);

let txn_5 = account
let eth_token_register_governance_admin_txn = account
.invoke_contract(l2_eth_token_address, "register_governance_admin", vec![account.address()], None)
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_5.transaction_hash, "Interact ETH token").await.unwrap();
wait_for_transaction(
rpc_provider_l2,
eth_token_register_governance_admin_txn.transaction_hash,
"Interact ETH token",
)
.await
.unwrap();
log::debug!(
"upgrade_eth_token_to_cairo_1 : register_governance_admin : eth proxy ✅, Txn hash : {:?}",
txn_5.transaction_hash
eth_token_register_governance_admin_txn.transaction_hash
);

let txn_6 = account
let eth_token_register_upgrade_governor_txn = account
.invoke_contract(l2_eth_token_address, "register_upgrade_governor", vec![account.address()], None)
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_6.transaction_hash, "Interact ETH token").await.unwrap();
wait_for_transaction(
rpc_provider_l2,
eth_token_register_upgrade_governor_txn.transaction_hash,
"Interact ETH token",
)
.await
.unwrap();
log::debug!(
"upgrade_eth_token_to_cairo_1 : register_upgrade_governor : eth proxy ✅, Txn hash : {:?}",
txn_6.transaction_hash
eth_token_register_upgrade_governor_txn.transaction_hash
);

let txn_3 = account
let new_eth_token_add_implementation_txn = account
.invoke_contract(
l2_eth_token_address,
"add_new_implementation",
Expand All @@ -160,13 +179,15 @@ pub async fn upgrade_eth_token_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_3.transaction_hash, "Interact ETH token").await.unwrap();
wait_for_transaction(rpc_provider_l2, new_eth_token_add_implementation_txn.transaction_hash, "Interact ETH token")
.await
.unwrap();
log::debug!(
"upgrade_eth_token_to_cairo_1 : add_new_implementation : eth proxy ✅, Txn hash : {:?}",
txn_3.transaction_hash
new_eth_token_add_implementation_txn.transaction_hash
);

let txn_4 = account
let new_eth_token_replace_to_txn = account
.invoke_contract(
l2_eth_token_address,
"replace_to",
Expand All @@ -176,8 +197,13 @@ pub async fn upgrade_eth_token_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_4.transaction_hash, "Interact ETH token").await.unwrap();
log::debug!("upgrade_eth_token_to_cairo_1 : replace_to : eth proxy ✅, Txn hash : {:?}", txn_4.transaction_hash);
wait_for_transaction(rpc_provider_l2, new_eth_token_replace_to_txn.transaction_hash, "Interact ETH token")
.await
.unwrap();
log::debug!(
"upgrade_eth_token_to_cairo_1 : replace_to : eth proxy ✅, Txn hash : {:?}",
new_eth_token_replace_to_txn.transaction_hash
);

log::info!("Eth token upgraded successfully ✅");
}
62 changes: 44 additions & 18 deletions src/setup_scripts/upgrade_l2_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn upgrade_eth_bridge_to_cairo_1(
log::debug!("✅ new eth bridge contract address : {:?}", new_eth_bridge_contract_address);
sleep(Duration::from_secs(5)).await;

let txn_1 = account
let eth_bridge_add_implementation_txn = account
.invoke_contract(
l2_eth_bridge_address,
"add_implementation",
Expand All @@ -103,13 +103,15 @@ pub async fn upgrade_eth_bridge_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_1.transaction_hash, "Interact ETH bridge").await.unwrap();
wait_for_transaction(rpc_provider_l2, eth_bridge_add_implementation_txn.transaction_hash, "Interact ETH bridge")
.await
.unwrap();
log::debug!(
"upgrade_eth_bridge_to_cairo_1 : add_implementation : eth bridge ✅, Txn hash : {:?}",
txn_1.transaction_hash
eth_bridge_add_implementation_txn.transaction_hash
);

let txn_2 = account
let eth_bridge_upgrade_to_txn = account
.invoke_contract(
l2_eth_bridge_address,
"upgrade_to",
Expand All @@ -126,32 +128,49 @@ pub async fn upgrade_eth_bridge_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_2.transaction_hash, "Interact ETH bridge").await.unwrap();
log::debug!("upgrade_eth_bridge_to_cairo_1 : upgrade_to : eth bridge ✅, Txn hash : {:?}", txn_2.transaction_hash);
wait_for_transaction(rpc_provider_l2, eth_bridge_upgrade_to_txn.transaction_hash, "Interact ETH bridge")
.await
.unwrap();
log::debug!(
"upgrade_eth_bridge_to_cairo_1 : upgrade_to : eth bridge ✅, Txn hash : {:?}",
eth_bridge_upgrade_to_txn.transaction_hash
);

let txn_5 = account
let eth_bridge_register_governance_admin_txn = account
.invoke_contract(l2_eth_bridge_address, "register_governance_admin", vec![account.address()], None)
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_5.transaction_hash, "Interact ETH bridge").await.unwrap();
wait_for_transaction(
rpc_provider_l2,
eth_bridge_register_governance_admin_txn.transaction_hash,
"Interact ETH bridge",
)
.await
.unwrap();
log::debug!(
"upgrade_eth_bridge_to_cairo_1 : register_governance_admin : eth bridge ✅, Txn hash : {:?}",
txn_5.transaction_hash
eth_bridge_register_governance_admin_txn.transaction_hash
);

let txn_6 = account
let eth_bridge_register_upgrade_governor_txn = account
.invoke_contract(l2_eth_bridge_address, "register_upgrade_governor", vec![account.address()], None)
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_6.transaction_hash, "Interact ETH bridge").await.unwrap();
wait_for_transaction(
rpc_provider_l2,
eth_bridge_register_upgrade_governor_txn.transaction_hash,
"Interact ETH bridge",
)
.await
.unwrap();
log::debug!(
"upgrade_eth_bridge_to_cairo_1 : register_upgrade_governor : eth bridge ✅, Txn hash : {:?}",
txn_6.transaction_hash
eth_bridge_register_upgrade_governor_txn.transaction_hash
);

let txn_3 = account
let eth_bridge_add_new_implementation_txn = account
.invoke_contract(
l2_eth_bridge_address,
"add_new_implementation",
Expand All @@ -161,13 +180,15 @@ pub async fn upgrade_eth_bridge_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_3.transaction_hash, "Interact ETH token").await.unwrap();
wait_for_transaction(rpc_provider_l2, eth_bridge_add_new_implementation_txn.transaction_hash, "Interact ETH token")
.await
.unwrap();
log::debug!(
"upgrade_eth_bridge_to_cairo_1 : add_new_implementation : eth bridge ✅, Txn hash : {:?}",
txn_3.transaction_hash
eth_bridge_add_new_implementation_txn.transaction_hash
);

let txn_4 = account
let eth_bridge_replace_to_txn = account
.invoke_contract(
l2_eth_bridge_address,
"replace_to",
Expand All @@ -177,8 +198,13 @@ pub async fn upgrade_eth_bridge_to_cairo_1(
.send()
.await
.expect("Error calling eth token proxy");
wait_for_transaction(rpc_provider_l2, txn_4.transaction_hash, "Interact ETH token").await.unwrap();
log::debug!("upgrade_eth_bridge_to_cairo_1 : replace_to : eth bridge ✅, Txn hash : {:?}", txn_4.transaction_hash);
wait_for_transaction(rpc_provider_l2, eth_bridge_replace_to_txn.transaction_hash, "Interact ETH token")
.await
.unwrap();
log::debug!(
"upgrade_eth_bridge_to_cairo_1 : replace_to : eth bridge ✅, Txn hash : {:?}",
eth_bridge_replace_to_txn.transaction_hash
);

log::info!("Eth bridge L2 upgraded successfully ✅");
}

0 comments on commit b997085

Please sign in to comment.