From b997085bd416b406a7a29be1d1524d208bedd72c Mon Sep 17 00:00:00 2001 From: Arun Jangra Date: Sat, 21 Dec 2024 16:27:53 +0530 Subject: [PATCH] feat : resolved comments 2 --- src/setup_scripts/core_contract.rs | 36 ++++++++++++--- src/setup_scripts/upgrade_eth_token.rs | 62 ++++++++++++++++++-------- src/setup_scripts/upgrade_l2_bridge.rs | 62 ++++++++++++++++++-------- 3 files changed, 118 insertions(+), 42 deletions(-) diff --git a/src/setup_scripts/core_contract.rs b/src/setup_scripts/core_contract.rs index 5083ee2..4def3eb 100644 --- a/src/setup_scripts/core_contract.rs +++ b/src/setup_scripts/core_contract.rs @@ -34,11 +34,23 @@ 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(), @@ -46,11 +58,23 @@ impl<'a> CoreContractStarknetL1<'a> { 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(), diff --git a/src/setup_scripts/upgrade_eth_token.rs b/src/setup_scripts/upgrade_eth_token.rs index 8e7c354..e69b811 100644 --- a/src/setup_scripts/upgrade_eth_token.rs +++ b/src/setup_scripts/upgrade_eth_token.rs @@ -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", @@ -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", @@ -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", @@ -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", @@ -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 ✅"); } diff --git a/src/setup_scripts/upgrade_l2_bridge.rs b/src/setup_scripts/upgrade_l2_bridge.rs index c9d7b7d..40e59af 100644 --- a/src/setup_scripts/upgrade_l2_bridge.rs +++ b/src/setup_scripts/upgrade_l2_bridge.rs @@ -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", @@ -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", @@ -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", @@ -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", @@ -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 ✅"); }