From edf900b4b317f571dfcd75a3aca6106c1de4bc62 Mon Sep 17 00:00:00 2001 From: Bridgerz Date: Wed, 17 Apr 2024 09:57:51 -0700 Subject: [PATCH] Bridge Custom Networks (#17140) --- bridge/evm/test/BridgeLimiterTest.t.sol | 4 +- bridge/evm/test/SuiBridgeTest.t.sol | 4 +- crates/sui-bridge/src/abi.rs | 4 +- crates/sui-bridge/src/client/bridge_client.rs | 28 +++---- crates/sui-bridge/src/e2e_test_utils.rs | 2 +- crates/sui-bridge/src/e2e_tests/basic.rs | 4 +- crates/sui-bridge/src/encoding.rs | 36 ++++----- crates/sui-bridge/src/events.rs | 8 +- .../src/server/governance_verifier.rs | 10 +-- crates/sui-bridge/src/server/handler.rs | 12 +-- crates/sui-bridge/src/server/mod.rs | 18 ++--- crates/sui-bridge/src/sui_client.rs | 4 +- .../sui-bridge/src/sui_transaction_builder.rs | 16 ++-- crates/sui-bridge/src/test_utils.rs | 10 +-- crates/sui-bridge/src/types.rs | 8 +- crates/sui-framework/docs/bridge/chain_ids.md | 81 +++++-------------- crates/sui-framework/docs/bridge/limiter.md | 16 +--- .../packages/bridge/sources/chain_ids.move | 64 ++++++--------- .../packages/bridge/sources/limiter.move | 24 ++---- .../packages/bridge/sources/message.move | 22 ++--- crates/sui-genesis-builder/src/lib.rs | 4 +- crates/sui-types/src/bridge.rs | 10 +-- .../sui-adapter/src/execution_engine.rs | 2 +- 23 files changed, 154 insertions(+), 237 deletions(-) diff --git a/bridge/evm/test/BridgeLimiterTest.t.sol b/bridge/evm/test/BridgeLimiterTest.t.sol index aae883214a69c..c955428b66b76 100644 --- a/bridge/evm/test/BridgeLimiterTest.t.sol +++ b/bridge/evm/test/BridgeLimiterTest.t.sol @@ -267,12 +267,12 @@ contract BridgeLimiterTest is BridgeBaseTest { messageType: BridgeUtils.UPDATE_BRIDGE_LIMIT, version: 1, nonce: 15, - chainID: 3, + chainID: 2, payload: payload }); bytes memory encodedMessage = BridgeUtils.encodeMessage(message); bytes memory expectedEncodedMessage = - hex"5355495f4252494447455f4d4553534147450301000000000000000f030c00000002540be400"; + hex"5355495f4252494447455f4d4553534147450301000000000000000f020c00000002540be400"; assertEq(encodedMessage, expectedEncodedMessage); } diff --git a/bridge/evm/test/SuiBridgeTest.t.sol b/bridge/evm/test/SuiBridgeTest.t.sol index 2449beb45c18c..1e9c3cd53b968 100644 --- a/bridge/evm/test/SuiBridgeTest.t.sol +++ b/bridge/evm/test/SuiBridgeTest.t.sol @@ -644,7 +644,7 @@ contract SuiBridgeTest is BridgeBaseTest, ISuiBridge { tokenPrices[2] = 1 * USD_VALUE_MULTIPLIER; // ETH PRICE tokenPrices[3] = 1 * USD_VALUE_MULTIPLIER; // USDC PRICE tokenPrices[4] = 1 * USD_VALUE_MULTIPLIER; // USDT PRICE - uint8 _chainID = 3; + uint8 _chainID = 2; uint8[] memory _supportedDestinationChains = new uint8[](1); _supportedDestinationChains[0] = 0; address[] memory _supportedTokens = new address[](5); @@ -679,7 +679,7 @@ contract SuiBridgeTest is BridgeBaseTest, ISuiBridge { }); bytes memory encodedMessage = BridgeUtils.encodeMessage(message); bytes memory expectedEncodedMessage = - hex"5355495f4252494447455f4d455353414745020100000000000000370300"; + hex"5355495f4252494447455f4d455353414745020100000000000000370200"; assertEq(encodedMessage, expectedEncodedMessage); } diff --git a/crates/sui-bridge/src/abi.rs b/crates/sui-bridge/src/abi.rs index b6f3da784692f..6850cf4bf0509 100644 --- a/crates/sui-bridge/src/abi.rs +++ b/crates/sui-bridge/src/abi.rs @@ -351,7 +351,7 @@ mod tests { fn test_eth_message_conversion_add_tokens_on_evm_action_regression() -> anyhow::Result<()> { let action = AddTokensOnEvmAction { nonce: 5, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, native: true, token_ids: vec![99, 100, 101], token_addresses: vec![ @@ -369,7 +369,7 @@ mod tests { message_type: BridgeActionType::AddTokensOnEvm as u8, version: ADD_TOKENS_ON_EVM_MESSAGE_VERSION, nonce: 5, - chain_id: BridgeChainId::EthLocalTest as u8, + chain_id: BridgeChainId::EthCustom as u8, payload: Hex::decode("0103636465030101010101010101010101010101010101010101020202020202020202020202020202020202020203030303030303030303030303030303030303030305060703000000003b9aca00000000007735940000000000b2d05e00").unwrap().into(), } ); diff --git a/crates/sui-bridge/src/client/bridge_client.rs b/crates/sui-bridge/src/client/bridge_client.rs index 633e59fdaaf64..c4c088a89622f 100644 --- a/crates/sui-bridge/src/client/bridge_client.rs +++ b/crates/sui-bridge/src/client/bridge_client.rs @@ -432,7 +432,7 @@ mod tests { sui_tx_digest, sui_tx_event_index, sui_bridge_event: EmittedSuiToEthTokenBridgeV1 { - sui_chain_id: BridgeChainId::SuiDevnet, + sui_chain_id: BridgeChainId::SuiCustom, nonce: 1, sui_address: SuiAddress::random_for_testing_only(), eth_chain_id: BridgeChainId::EthSepolia, @@ -458,7 +458,7 @@ mod tests { eth_chain_id: BridgeChainId::EthSepolia, nonce: 1, eth_address: EthAddress::random(), - sui_chain_id: BridgeChainId::SuiDevnet, + sui_chain_id: BridgeChainId::SuiCustom, sui_address: SuiAddress::random_for_testing_only(), token_id: TOKEN_ID_USDT, sui_adjusted_amount: 1, @@ -509,28 +509,28 @@ mod tests { ); let action = BridgeAction::EmergencyAction(crate::types::EmergencyAction { - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, nonce: 5, action_type: crate::types::EmergencyActionType::Pause, }); assert_eq!( BridgeClient::bridge_action_to_path(&action), - "sign/emergency_button/3/5/0", + "sign/emergency_button/2/5/0", ); let action = BridgeAction::LimitUpdateAction(crate::types::LimitUpdateAction { - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, nonce: 10, - sending_chain_id: BridgeChainId::EthLocalTest, + sending_chain_id: BridgeChainId::EthCustom, new_usd_limit: 100, }); assert_eq!( BridgeClient::bridge_action_to_path(&action), - "sign/update_limit/3/10/12/100", + "sign/update_limit/2/10/12/100", ); let action = BridgeAction::AssetPriceUpdateAction(crate::types::AssetPriceUpdateAction { - chain_id: BridgeChainId::SuiDevnet, + chain_id: BridgeChainId::SuiCustom, nonce: 8, token_id: TOKEN_ID_BTC, new_usd_price: 100_000_000, @@ -543,7 +543,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(crate::types::EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data: vec![], @@ -559,7 +559,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(crate::types::EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data: call_data.clone(), @@ -573,7 +573,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(crate::types::EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data, @@ -585,7 +585,7 @@ mod tests { let action = BridgeAction::AddTokensOnSuiAction(crate::types::AddTokensOnSuiAction { nonce: 3, - chain_id: BridgeChainId::SuiTestnet, + chain_id: BridgeChainId::SuiCustom, native: false, token_ids: vec![99, 100, 101], token_type_names: vec![ @@ -597,12 +597,12 @@ mod tests { }); assert_eq!( BridgeClient::bridge_action_to_path(&action), - "sign/add_tokens_on_sui/1/3/0/99,100,101/0x0000000000000000000000000000000000000000000000000000000000000abc::my_coin::MyCoin1,0x0000000000000000000000000000000000000000000000000000000000000abc::my_coin::MyCoin2,0x0000000000000000000000000000000000000000000000000000000000000abc::my_coin::MyCoin3/1000000000,2000000000,3000000000", + "sign/add_tokens_on_sui/2/3/0/99,100,101/0x0000000000000000000000000000000000000000000000000000000000000abc::my_coin::MyCoin1,0x0000000000000000000000000000000000000000000000000000000000000abc::my_coin::MyCoin2,0x0000000000000000000000000000000000000000000000000000000000000abc::my_coin::MyCoin3/1000000000,2000000000,3000000000", ); let action = BridgeAction::AddTokensOnEvmAction(crate::types::AddTokensOnEvmAction { nonce: 0, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, native: true, token_ids: vec![99, 100, 101], token_addresses: vec![ diff --git a/crates/sui-bridge/src/e2e_test_utils.rs b/crates/sui-bridge/src/e2e_test_utils.rs index 189a9616c0e4d..dd723e0df5d93 100644 --- a/crates/sui-bridge/src/e2e_test_utils.rs +++ b/crates/sui-bridge/src/e2e_test_utils.rs @@ -86,7 +86,7 @@ pub async fn publish_coins_return_add_coins_on_sui_action( BridgeAction::AddTokensOnSuiAction(AddTokensOnSuiAction { nonce, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, native: false, token_ids, token_type_names, diff --git a/crates/sui-bridge/src/e2e_tests/basic.rs b/crates/sui-bridge/src/e2e_tests/basic.rs index c4a5ca1e2194d..34ad82fcc0254 100644 --- a/crates/sui-bridge/src/e2e_tests/basic.rs +++ b/crates/sui-bridge/src/e2e_tests/basic.rs @@ -82,8 +82,8 @@ async fn test_bridge_from_eth_to_sui_to_eth() { for _ in 0..3 { server_ports.push(get_available_port("127.0.0.1")); } - let eth_chain_id = BridgeChainId::EthLocalTest as u8; - let sui_chain_id = BridgeChainId::SuiLocalTest as u8; + let eth_chain_id = BridgeChainId::EthCustom as u8; + let sui_chain_id = BridgeChainId::SuiCustom as u8; let mut test_cluster: test_cluster::TestCluster = TestClusterBuilder::new() .with_protocol_version(BRIDGE_ENABLE_PROTOCOL_VERSION.into()) .build_with_bridge(true) diff --git a/crates/sui-bridge/src/encoding.rs b/crates/sui-bridge/src/encoding.rs index 509b710b0a87a..3e3d38c449611 100644 --- a/crates/sui-bridge/src/encoding.rs +++ b/crates/sui-bridge/src/encoding.rs @@ -552,7 +552,7 @@ mod tests { .unwrap(); let blocklist_action = BridgeAction::BlocklistCommitteeAction(BlocklistCommitteeAction { nonce: 129, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, blocklist_type: BlocklistType::Blocklist, blocklisted_members: vec![pub_key_bytes.clone()], }); @@ -569,7 +569,7 @@ mod tests { 68b43fd906c0b8f024a18c56e06744f7c6157c65 ]: blocklisted members abi-encoded */ - assert_eq!(bytes, Hex::decode("5355495f4252494447455f4d4553534147450101000000000000008103000168b43fd906c0b8f024a18c56e06744f7c6157c65").unwrap()); + assert_eq!(bytes, Hex::decode("5355495f4252494447455f4d4553534147450101000000000000008102000168b43fd906c0b8f024a18c56e06744f7c6157c65").unwrap()); let pub_key_bytes_2 = BridgeAuthorityPublicKeyBytes::from_bytes( &Hex::decode("027f1178ff417fc9f5b8290bd8876f0a157a505a6c52db100a8492203ddd1d4279") @@ -579,7 +579,7 @@ mod tests { // its evem address: 0xacaef39832cb995c4e049437a3e2ec6a7bad1ab5 let blocklist_action = BridgeAction::BlocklistCommitteeAction(BlocklistCommitteeAction { nonce: 68, - chain_id: BridgeChainId::SuiDevnet, + chain_id: BridgeChainId::SuiCustom, blocklist_type: BlocklistType::Unblocklist, blocklisted_members: vec![pub_key_bytes.clone(), pub_key_bytes_2.clone()], }); @@ -601,7 +601,7 @@ mod tests { let blocklist_action = BridgeAction::BlocklistCommitteeAction(BlocklistCommitteeAction { nonce: 49, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, blocklist_type: BlocklistType::Blocklist, blocklisted_members: vec![pub_key_bytes.clone()], }); @@ -647,7 +647,7 @@ mod tests { fn test_bridge_message_encoding_emergency_action() { let action = BridgeAction::EmergencyAction(EmergencyAction { nonce: 55, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, action_type: EmergencyActionType::Pause, }); let bytes = action.to_bytes(); @@ -661,7 +661,7 @@ mod tests { */ assert_eq!( bytes, - Hex::decode("5355495f4252494447455f4d455353414745020100000000000000370300").unwrap() + Hex::decode("5355495f4252494447455f4d455353414745020100000000000000370200").unwrap() ); let action = BridgeAction::EmergencyAction(EmergencyAction { @@ -688,8 +688,8 @@ mod tests { fn test_bridge_message_encoding_limit_update_action() { let action = BridgeAction::LimitUpdateAction(LimitUpdateAction { nonce: 15, - chain_id: BridgeChainId::SuiLocalTest, - sending_chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::SuiCustom, + sending_chain_id: BridgeChainId::EthCustom, new_usd_limit: 1_000_000 * USD_MULTIPLIER, // $1M USD }); let bytes = action.to_bytes(); @@ -705,7 +705,7 @@ mod tests { assert_eq!( bytes, Hex::decode( - "5355495f4252494447455f4d4553534147450301000000000000000f030c00000002540be400" + "5355495f4252494447455f4d4553534147450301000000000000000f020c00000002540be400" ) .unwrap() ); @@ -715,7 +715,7 @@ mod tests { fn test_bridge_message_encoding_asset_price_update_action() { let action = BridgeAction::AssetPriceUpdateAction(AssetPriceUpdateAction { nonce: 266, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, token_id: TOKEN_ID_BTC, new_usd_price: 100_000 * USD_MULTIPLIER, // $100k USD }); @@ -732,7 +732,7 @@ mod tests { assert_eq!( bytes, Hex::decode( - "5355495f4252494447455f4d4553534147450401000000000000010a0301000000003b9aca00" + "5355495f4252494447455f4d4553534147450401000000000000010a0201000000003b9aca00" ) .unwrap() ); @@ -748,7 +748,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data, @@ -779,7 +779,7 @@ mod tests { ); let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data, @@ -814,7 +814,7 @@ mod tests { ); let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data, @@ -839,7 +839,7 @@ mod tests { // Empty calldate let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data: vec![], @@ -919,7 +919,7 @@ mod tests { let action = BridgeAction::AddTokensOnSuiAction(AddTokensOnSuiAction { nonce: 0, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, native: false, token_ids: vec![1, 2, 3, 4], token_type_names: vec![ @@ -939,7 +939,7 @@ mod tests { assert_eq!( Hex::encode(encoded_bytes), - "5355495f4252494447455f4d4553534147450601000000000000000003000401020304044a396235653133626364306362323366663235633037363938653839643438303536633734353333386438633964626430333361343137326238373032373037333a3a6274633a3a4254434a373937306437316330333537336635343061373135376630643339373065313137656666613661653136636566643530623435633734393637306232346536613a3a6574683a3a4554484c353030653432396132343437383430356435313330323232623230663835373061373436623662633232343233663134623464346536613865613538303733363a3a757364633a3a555344434c343662666535316461316264393531313931396139326562313135343134396233366330663432313231323138303865313365336535383537643630376139633a3a757364743a3a55534454040065cd1d0000000080c3c90100000000e803000000000000e803000000000000", + "5355495f4252494447455f4d4553534147450601000000000000000002000401020304044a396235653133626364306362323366663235633037363938653839643438303536633734353333386438633964626430333361343137326238373032373037333a3a6274633a3a4254434a373937306437316330333537336635343061373135376630643339373065313137656666613661653136636566643530623435633734393637306232346536613a3a6574683a3a4554484c353030653432396132343437383430356435313330323232623230663835373061373436623662633232343233663134623464346536613865613538303733363a3a757364633a3a555344434c343662666535316461316264393531313931396139326562313135343134396233366330663432313231323138303865313365336535383537643630376139633a3a757364743a3a55534454040065cd1d0000000080c3c90100000000e803000000000000e803000000000000", ); Ok(()) } @@ -948,7 +948,7 @@ mod tests { fn test_bridge_message_encoding_regression_add_coins_on_evm() -> anyhow::Result<()> { let action = BridgeAction::AddTokensOnEvmAction(crate::types::AddTokensOnEvmAction { nonce: 0, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, native: true, token_ids: vec![99, 100, 101], token_addresses: vec![ diff --git a/crates/sui-bridge/src/events.rs b/crates/sui-bridge/src/events.rs index 3295d2f926b08..a6310e0a3ed62 100644 --- a/crates/sui-bridge/src/events.rs +++ b/crates/sui-bridge/src/events.rs @@ -78,10 +78,7 @@ impl TryFrom for EmittedSuiToEthTokenBridgeV1 { })?; match sui_chain_id { - BridgeChainId::SuiMainnet - | BridgeChainId::SuiTestnet - | BridgeChainId::SuiDevnet - | BridgeChainId::SuiLocalTest => {} + BridgeChainId::SuiMainnet | BridgeChainId::SuiTestnet | BridgeChainId::SuiCustom => {} _ => { return Err(BridgeError::Generic(format!( "Failed to convert MoveTokenBridgeEvent to EmittedSuiToEthTokenBridgeV1. Invalid source chain {}", @@ -90,8 +87,7 @@ impl TryFrom for EmittedSuiToEthTokenBridgeV1 { } } match eth_chain_id { - BridgeChainId::EthMainnet | BridgeChainId::EthSepolia | BridgeChainId::EthLocalTest => { - } + BridgeChainId::EthMainnet | BridgeChainId::EthSepolia | BridgeChainId::EthCustom => {} _ => { return Err(BridgeError::Generic(format!( "Failed to convert MoveTokenBridgeEvent to EmittedSuiToEthTokenBridgeV1. Invalid target chain {}", diff --git a/crates/sui-bridge/src/server/governance_verifier.rs b/crates/sui-bridge/src/server/governance_verifier.rs index 6cf73fc8c653d..ecfc8bfc832a5 100644 --- a/crates/sui-bridge/src/server/governance_verifier.rs +++ b/crates/sui-bridge/src/server/governance_verifier.rs @@ -58,13 +58,13 @@ mod tests { #[tokio::test] async fn test_governance_verifier() { let action_1 = BridgeAction::EmergencyAction(EmergencyAction { - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, nonce: 1, action_type: EmergencyActionType::Pause, }); let action_2 = BridgeAction::LimitUpdateAction(LimitUpdateAction { - chain_id: BridgeChainId::EthLocalTest, - sending_chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::EthCustom, + sending_chain_id: BridgeChainId::SuiCustom, nonce: 1, new_usd_limit: 10000, }); @@ -80,8 +80,8 @@ mod tests { ); let action_3 = BridgeAction::LimitUpdateAction(LimitUpdateAction { - chain_id: BridgeChainId::EthLocalTest, - sending_chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::EthCustom, + sending_chain_id: BridgeChainId::SuiCustom, nonce: 2, new_usd_limit: 10000, }); diff --git a/crates/sui-bridge/src/server/handler.rs b/crates/sui-bridge/src/server/handler.rs index 1806107be67a2..2a6e6a00318af 100644 --- a/crates/sui-bridge/src/server/handler.rs +++ b/crates/sui-bridge/src/server/handler.rs @@ -415,9 +415,9 @@ mod tests { let emitted_event_1 = MoveTokenBridgeEvent { message_type: BridgeActionType::TokenTransfer as u8, seq_num: 1, - source_chain: BridgeChainId::SuiLocalTest as u8, + source_chain: BridgeChainId::SuiCustom as u8, sender_address: SuiAddress::random_for_testing_only().to_vec(), - target_chain: BridgeChainId::EthLocalTest as u8, + target_chain: BridgeChainId::EthCustom as u8, target_address: EthAddress::random().as_bytes().to_vec(), token_type: TOKEN_ID_USDC, amount_sui_adjusted: 12345, @@ -541,13 +541,13 @@ mod tests { #[tokio::test] async fn test_signer_with_governace_verifier() { let action_1 = BridgeAction::EmergencyAction(EmergencyAction { - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, nonce: 1, action_type: EmergencyActionType::Pause, }); let action_2 = BridgeAction::LimitUpdateAction(LimitUpdateAction { - chain_id: BridgeChainId::EthLocalTest, - sending_chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::EthCustom, + sending_chain_id: BridgeChainId::SuiCustom, nonce: 1, new_usd_limit: 10000, }); @@ -584,7 +584,7 @@ mod tests { // alter action_1 to action_3 let action_3 = BridgeAction::EmergencyAction(EmergencyAction { - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, nonce: 1, action_type: EmergencyActionType::Unpause, }); diff --git a/crates/sui-bridge/src/server/mod.rs b/crates/sui-bridge/src/server/mod.rs index dbfd7e8397cba..0806ae05cb45e 100644 --- a/crates/sui-bridge/src/server/mod.rs +++ b/crates/sui-bridge/src/server/mod.rs @@ -436,7 +436,7 @@ mod tests { .unwrap(); let action = BridgeAction::BlocklistCommitteeAction(BlocklistCommitteeAction { nonce: 129, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, blocklist_type: BlocklistType::Blocklist, blocklisted_members: vec![pub_key_bytes.clone()], }); @@ -449,7 +449,7 @@ mod tests { let action = BridgeAction::EmergencyAction(EmergencyAction { nonce: 55, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, action_type: EmergencyActionType::Pause, }); client.request_sign_bridge_action(action).await.unwrap(); @@ -461,8 +461,8 @@ mod tests { let action = BridgeAction::LimitUpdateAction(LimitUpdateAction { nonce: 15, - chain_id: BridgeChainId::SuiLocalTest, - sending_chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::SuiCustom, + sending_chain_id: BridgeChainId::EthCustom, new_usd_limit: 1_000_000_0000, // $1M USD }); client.request_sign_bridge_action(action).await.unwrap(); @@ -474,7 +474,7 @@ mod tests { let action = BridgeAction::AssetPriceUpdateAction(AssetPriceUpdateAction { nonce: 266, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, token_id: TOKEN_ID_BTC, new_usd_price: 100_000_0000, // $100k USD }); @@ -487,7 +487,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data: vec![], @@ -496,7 +496,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data: vec![12, 34, 56], @@ -510,7 +510,7 @@ mod tests { let action = BridgeAction::AddTokensOnSuiAction(AddTokensOnSuiAction { nonce: 266, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, native: false, token_ids: vec![100, 101, 102], token_type_names: vec![ @@ -529,7 +529,7 @@ mod tests { let action = BridgeAction::AddTokensOnEvmAction(crate::types::AddTokensOnEvmAction { nonce: 0, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, native: false, token_ids: vec![99, 100, 101], token_addresses: vec![ diff --git a/crates/sui-bridge/src/sui_client.rs b/crates/sui-bridge/src/sui_client.rs index 04ce7d627fb21..92fa7533e5328 100644 --- a/crates/sui-bridge/src/sui_client.rs +++ b/crates/sui-bridge/src/sui_client.rs @@ -809,8 +809,8 @@ mod tests { ) .await; assert_eq!(bridge_event.nonce, 0); - assert_eq!(bridge_event.sui_chain_id, BridgeChainId::SuiLocalTest); - assert_eq!(bridge_event.eth_chain_id, BridgeChainId::EthLocalTest); + assert_eq!(bridge_event.sui_chain_id, BridgeChainId::SuiCustom); + assert_eq!(bridge_event.eth_chain_id, BridgeChainId::EthCustom); assert_eq!(bridge_event.eth_address, eth_recv_address); assert_eq!(bridge_event.sui_address, sender); assert_eq!(bridge_event.token_id, TOKEN_ID_USDC); diff --git a/crates/sui-bridge/src/sui_transaction_builder.rs b/crates/sui-bridge/src/sui_transaction_builder.rs index 04005dd151dea..f428a4d55b994 100644 --- a/crates/sui-bridge/src/sui_transaction_builder.rs +++ b/crates/sui-bridge/src/sui_transaction_builder.rs @@ -698,7 +698,7 @@ mod tests { // 1. Pause let action = BridgeAction::EmergencyAction(EmergencyAction { nonce: 0, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, action_type: EmergencyActionType::Pause, }); // `approve_action_with_validator_secrets` covers transaction building @@ -717,7 +717,7 @@ mod tests { // 2. Unpause let action = BridgeAction::EmergencyAction(EmergencyAction { nonce: 1, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, action_type: EmergencyActionType::Unpause, }); // `approve_action_with_validator_secrets` covers transaction building @@ -763,7 +763,7 @@ mod tests { // 1. blocklist The victim let action = BridgeAction::BlocklistCommitteeAction(BlocklistCommitteeAction { nonce: 0, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, blocklist_type: BlocklistType::Blocklist, blocklisted_members: vec![BridgeAuthorityPublicKeyBytes::from_bytes( &victim.bridge_pubkey_bytes, @@ -792,7 +792,7 @@ mod tests { // 2. unblocklist the victim let action = BridgeAction::BlocklistCommitteeAction(BlocklistCommitteeAction { nonce: 1, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, blocklist_type: BlocklistType::Unblocklist, blocklisted_members: vec![BridgeAuthorityPublicKeyBytes::from_bytes( &victim.bridge_pubkey_bytes, @@ -848,8 +848,8 @@ mod tests { // update limit let action = BridgeAction::LimitUpdateAction(LimitUpdateAction { nonce: 0, - chain_id: BridgeChainId::SuiLocalTest, - sending_chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::SuiCustom, + sending_chain_id: BridgeChainId::EthCustom, new_usd_limit: 6_666_666 * USD_MULTIPLIER, // $1M USD }); // `approve_action_with_validator_secrets` covers transaction building @@ -869,7 +869,7 @@ mod tests { .limiter .transfer_limit; for limit in new_transfer_limit { - if limit.0 == BridgeChainId::EthLocalTest && limit.1 == BridgeChainId::SuiLocalTest { + if limit.0 == BridgeChainId::EthCustom && limit.1 == BridgeChainId::SuiCustom { assert_eq!(limit.2, 6_666_666 * USD_MULTIPLIER); } else { assert_eq!(limit.2, *transfer_limit.get(&(limit.0, limit.1)).unwrap()); @@ -904,7 +904,7 @@ mod tests { // update price let action = BridgeAction::AssetPriceUpdateAction(AssetPriceUpdateAction { nonce: 0, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, token_id: TOKEN_ID_BTC, new_usd_price: 69_000 * USD_MULTIPLIER, // $69k USD }); diff --git a/crates/sui-bridge/src/test_utils.rs b/crates/sui-bridge/src/test_utils.rs index 24ab86557a824..1d452e1ec0d61 100644 --- a/crates/sui-bridge/src/test_utils.rs +++ b/crates/sui-bridge/src/test_utils.rs @@ -86,9 +86,9 @@ pub fn get_test_sui_to_eth_bridge_action( sui_tx_event_index: sui_tx_event_index.unwrap_or(0), sui_bridge_event: EmittedSuiToEthTokenBridgeV1 { nonce: nonce.unwrap_or_default(), - sui_chain_id: BridgeChainId::SuiLocalTest, + sui_chain_id: BridgeChainId::SuiCustom, sui_address: sender_address.unwrap_or_else(SuiAddress::random_for_testing_only), - eth_chain_id: BridgeChainId::EthLocalTest, + eth_chain_id: BridgeChainId::EthCustom, eth_address: recipient_address.unwrap_or_else(EthAddress::random), token_id: token_id.unwrap_or(TOKEN_ID_USDC), amount_sui_adjusted: amount_sui_adjusted.unwrap_or(100_000), @@ -105,9 +105,9 @@ pub fn get_test_eth_to_sui_bridge_action( eth_tx_hash: TxHash::random(), eth_event_index: 0, eth_bridge_event: EthToSuiTokenBridgeV1 { - eth_chain_id: BridgeChainId::EthLocalTest, + eth_chain_id: BridgeChainId::EthCustom, nonce: nonce.unwrap_or_default(), - sui_chain_id: BridgeChainId::SuiLocalTest, + sui_chain_id: BridgeChainId::SuiCustom, token_id: TOKEN_ID_USDC, sui_adjusted_amount: amount.unwrap_or(100_000), sui_address: sui_address.unwrap_or_else(SuiAddress::random_for_testing_only), @@ -295,7 +295,7 @@ pub async fn bridge_token( "send_token", vec![ CallArg::Object(bridge_object_arg), - CallArg::Pure(bcs::to_bytes(&(BridgeChainId::EthLocalTest as u8)).unwrap()), + CallArg::Pure(bcs::to_bytes(&(BridgeChainId::EthCustom as u8)).unwrap()), CallArg::Pure(bcs::to_bytes(&recv_address.as_bytes()).unwrap()), CallArg::Object(ObjectArg::ImmOrOwnedObject(token_ref)), ], diff --git a/crates/sui-bridge/src/types.rs b/crates/sui-bridge/src/types.rs index 8c80264bcd14f..719ada3e27408 100644 --- a/crates/sui-bridge/src/types.rs +++ b/crates/sui-bridge/src/types.rs @@ -567,15 +567,15 @@ mod tests { let action = BridgeAction::LimitUpdateAction(LimitUpdateAction { nonce: 15, - chain_id: BridgeChainId::SuiLocalTest, - sending_chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::SuiCustom, + sending_chain_id: BridgeChainId::EthCustom, new_usd_limit: 1_000_000 * USD_MULTIPLIER, }); assert_eq!(action.approval_threshold(), 5001); let action = BridgeAction::AssetPriceUpdateAction(AssetPriceUpdateAction { nonce: 266, - chain_id: BridgeChainId::SuiLocalTest, + chain_id: BridgeChainId::SuiCustom, token_id: TOKEN_ID_BTC, new_usd_price: 100_000 * USD_MULTIPLIER, }); @@ -583,7 +583,7 @@ mod tests { let action = BridgeAction::EvmContractUpgradeAction(EvmContractUpgradeAction { nonce: 123, - chain_id: BridgeChainId::EthLocalTest, + chain_id: BridgeChainId::EthCustom, proxy_address: EthAddress::repeat_byte(6), new_impl_address: EthAddress::repeat_byte(9), call_data: vec![], diff --git a/crates/sui-framework/docs/bridge/chain_ids.md b/crates/sui-framework/docs/bridge/chain_ids.md index 136a489ad77f1..23a3920f67985 100644 --- a/crates/sui-framework/docs/bridge/chain_ids.md +++ b/crates/sui-framework/docs/bridge/chain_ids.md @@ -9,11 +9,10 @@ title: Module `0xb::chain_ids` - [Constants](#@Constants_0) - [Function `sui_mainnet`](#0xb_chain_ids_sui_mainnet) - [Function `sui_testnet`](#0xb_chain_ids_sui_testnet) -- [Function `sui_devnet`](#0xb_chain_ids_sui_devnet) -- [Function `sui_local_test`](#0xb_chain_ids_sui_local_test) +- [Function `sui_custom`](#0xb_chain_ids_sui_custom) - [Function `eth_mainnet`](#0xb_chain_ids_eth_mainnet) - [Function `eth_sepolia`](#0xb_chain_ids_eth_sepolia) -- [Function `eth_local_test`](#0xb_chain_ids_eth_local_test) +- [Function `eth_custom`](#0xb_chain_ids_eth_custom) - [Function `route_source`](#0xb_chain_ids_route_source) - [Function `route_destination`](#0xb_chain_ids_route_destination) - [Function `assert_valid_chain_id`](#0xb_chain_ids_assert_valid_chain_id) @@ -74,11 +73,11 @@ title: Module `0xb::chain_ids` - + -
const EthLocalTest: u8 = 12;
+
const EthCustom: u8 = 12;
 
@@ -101,20 +100,11 @@ title: Module `0xb::chain_ids` - + -
const SuiDevnet: u8 = 2;
-
- - - - - - - -
const SuiLocalTest: u8 = 3;
+
const SuiCustom: u8 = 2;
 
@@ -181,35 +171,13 @@ title: Module `0xb::chain_ids` - - -## Function `sui_devnet` - - - -
public fun sui_devnet(): u8
-
- - - -
-Implementation - - -
public fun sui_devnet(): u8 { SuiDevnet }
-
- - - -
- - + -## Function `sui_local_test` +## Function `sui_custom` -
public fun sui_local_test(): u8
+
public fun sui_custom(): u8
 
@@ -218,7 +186,7 @@ title: Module `0xb::chain_ids` Implementation -
public fun sui_local_test(): u8 { SuiLocalTest }
+
public fun sui_custom(): u8 { SuiCustom }
 
@@ -269,13 +237,13 @@ title: Module `0xb::chain_ids` - + -## Function `eth_local_test` +## Function `eth_custom` -
public fun eth_local_test(): u8
+
public fun eth_custom(): u8
 
@@ -284,7 +252,7 @@ title: Module `0xb::chain_ids` Implementation -
public fun eth_local_test(): u8 { EthLocalTest }
+
public fun eth_custom(): u8 { EthCustom }
 
@@ -358,11 +326,10 @@ title: Module `0xb::chain_ids` assert!( id == SuiMainnet || id == SuiTestnet || - id == SuiDevnet || - id == SuiLocalTest || + id == SuiCustom || id == EthMainnet || id == EthSepolia || - id == EthLocalTest, + id == EthCustom, EInvalidBridgeRoute ) } @@ -392,18 +359,14 @@ title: Module `0xb::chain_ids` BridgeRoute { source: SuiMainnet, destination: EthMainnet }, BridgeRoute { source: EthMainnet, destination: SuiMainnet }, - BridgeRoute { source: SuiDevnet, destination: EthSepolia }, - BridgeRoute { source: SuiDevnet, destination: EthLocalTest }, BridgeRoute { source: SuiTestnet, destination: EthSepolia }, - BridgeRoute { source: SuiTestnet, destination: EthLocalTest }, - BridgeRoute { source: SuiLocalTest, destination: EthLocalTest }, - BridgeRoute { source: SuiLocalTest, destination: EthSepolia }, - BridgeRoute { source: EthSepolia, destination: SuiDevnet }, + BridgeRoute { source: SuiTestnet, destination: EthCustom }, + BridgeRoute { source: SuiCustom, destination: EthCustom }, + BridgeRoute { source: SuiCustom, destination: EthSepolia }, BridgeRoute { source: EthSepolia, destination: SuiTestnet }, - BridgeRoute { source: EthSepolia, destination: SuiLocalTest }, - BridgeRoute { source: EthLocalTest, destination: SuiDevnet }, - BridgeRoute { source: EthLocalTest, destination: SuiTestnet }, - BridgeRoute { source: EthLocalTest, destination: SuiLocalTest } + BridgeRoute { source: EthSepolia, destination: SuiCustom }, + BridgeRoute { source: EthCustom, destination: SuiTestnet }, + BridgeRoute { source: EthCustom, destination: SuiCustom } ] }
diff --git a/crates/sui-framework/docs/bridge/limiter.md b/crates/sui-framework/docs/bridge/limiter.md index 2f7766c9c6dd9..19fc3e2041077 100644 --- a/crates/sui-framework/docs/bridge/limiter.md +++ b/crates/sui-framework/docs/bridge/limiter.md @@ -446,27 +446,17 @@ title: Module `0xb::limiter` ); transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_devnet()), + chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_custom()), MAX_TRANSFER_LIMIT ); transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_local_test()), + chain_ids::get_route(chain_ids::eth_custom(), chain_ids::sui_testnet()), MAX_TRANSFER_LIMIT ); transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_local_test(), chain_ids::sui_testnet()), - MAX_TRANSFER_LIMIT - ); - - transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_local_test(), chain_ids::sui_devnet()), - MAX_TRANSFER_LIMIT - ); - - transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_local_test(), chain_ids::sui_local_test()), + chain_ids::get_route(chain_ids::eth_custom(), chain_ids::sui_custom()), MAX_TRANSFER_LIMIT ); diff --git a/crates/sui-framework/packages/bridge/sources/chain_ids.move b/crates/sui-framework/packages/bridge/sources/chain_ids.move index 1664067c9c1bb..566caa880b1b9 100644 --- a/crates/sui-framework/packages/bridge/sources/chain_ids.move +++ b/crates/sui-framework/packages/bridge/sources/chain_ids.move @@ -6,12 +6,11 @@ module bridge::chain_ids { // Chain IDs const SuiMainnet: u8 = 0; const SuiTestnet: u8 = 1; - const SuiDevnet: u8 = 2; - const SuiLocalTest: u8 = 3; + const SuiCustom: u8 = 2; const EthMainnet: u8 = 10; const EthSepolia: u8 = 11; - const EthLocalTest: u8 = 12; + const EthCustom: u8 = 12; const EInvalidBridgeRoute: u64 = 0; @@ -22,12 +21,11 @@ module bridge::chain_ids { public fun sui_mainnet(): u8 { SuiMainnet } public fun sui_testnet(): u8 { SuiTestnet } - public fun sui_devnet(): u8 { SuiDevnet } - public fun sui_local_test(): u8 { SuiLocalTest } + public fun sui_custom(): u8 { SuiCustom } public fun eth_mainnet(): u8 { EthMainnet } public fun eth_sepolia(): u8 { EthSepolia } - public fun eth_local_test(): u8 { EthLocalTest } + public fun eth_custom(): u8 { EthCustom } public use fun route_source as BridgeRoute.source; public fun route_source(route: &BridgeRoute): &u8 { @@ -43,11 +41,10 @@ module bridge::chain_ids { assert!( id == SuiMainnet || id == SuiTestnet || - id == SuiDevnet || - id == SuiLocalTest || + id == SuiCustom || id == EthMainnet || id == EthSepolia || - id == EthLocalTest, + id == EthCustom, EInvalidBridgeRoute ) } @@ -57,18 +54,14 @@ module bridge::chain_ids { BridgeRoute { source: SuiMainnet, destination: EthMainnet }, BridgeRoute { source: EthMainnet, destination: SuiMainnet }, - BridgeRoute { source: SuiDevnet, destination: EthSepolia }, - BridgeRoute { source: SuiDevnet, destination: EthLocalTest }, BridgeRoute { source: SuiTestnet, destination: EthSepolia }, - BridgeRoute { source: SuiTestnet, destination: EthLocalTest }, - BridgeRoute { source: SuiLocalTest, destination: EthLocalTest }, - BridgeRoute { source: SuiLocalTest, destination: EthSepolia }, - BridgeRoute { source: EthSepolia, destination: SuiDevnet }, + BridgeRoute { source: SuiTestnet, destination: EthCustom }, + BridgeRoute { source: SuiCustom, destination: EthCustom }, + BridgeRoute { source: SuiCustom, destination: EthSepolia }, BridgeRoute { source: EthSepolia, destination: SuiTestnet }, - BridgeRoute { source: EthSepolia, destination: SuiLocalTest }, - BridgeRoute { source: EthLocalTest, destination: SuiDevnet }, - BridgeRoute { source: EthLocalTest, destination: SuiTestnet }, - BridgeRoute { source: EthLocalTest, destination: SuiLocalTest } + BridgeRoute { source: EthSepolia, destination: SuiCustom }, + BridgeRoute { source: EthCustom, destination: SuiTestnet }, + BridgeRoute { source: EthCustom, destination: SuiCustom } ] } @@ -88,11 +81,10 @@ module bridge::chain_ids { fun test_chains_ok() { assert_valid_chain_id(SuiMainnet); assert_valid_chain_id(SuiTestnet); - assert_valid_chain_id(SuiDevnet); - assert_valid_chain_id(SuiLocalTest); + assert_valid_chain_id(SuiCustom); assert_valid_chain_id(EthMainnet); assert_valid_chain_id(EthSepolia); - assert_valid_chain_id(EthLocalTest); + assert_valid_chain_id(EthCustom); } #[test] @@ -121,18 +113,14 @@ module bridge::chain_ids { BridgeRoute { source: SuiMainnet, destination: EthMainnet }, BridgeRoute { source: EthMainnet, destination: SuiMainnet }, - BridgeRoute { source: SuiDevnet, destination: EthSepolia }, - BridgeRoute { source: SuiDevnet, destination: EthLocalTest }, BridgeRoute { source: SuiTestnet, destination: EthSepolia }, - BridgeRoute { source: SuiTestnet, destination: EthLocalTest }, - BridgeRoute { source: SuiLocalTest, destination: EthLocalTest }, - BridgeRoute { source: SuiLocalTest, destination: EthSepolia }, - BridgeRoute { source: EthSepolia, destination: SuiDevnet }, + BridgeRoute { source: SuiTestnet, destination: EthCustom }, + BridgeRoute { source: SuiCustom, destination: EthCustom }, + BridgeRoute { source: SuiCustom, destination: EthSepolia }, BridgeRoute { source: EthSepolia, destination: SuiTestnet }, - BridgeRoute { source: EthSepolia, destination: SuiLocalTest }, - BridgeRoute { source: EthLocalTest, destination: SuiDevnet }, - BridgeRoute { source: EthLocalTest, destination: SuiTestnet }, - BridgeRoute { source: EthLocalTest, destination: SuiLocalTest } + BridgeRoute { source: EthSepolia, destination: SuiCustom }, + BridgeRoute { source: EthCustom, destination: SuiTestnet }, + BridgeRoute { source: EthCustom, destination: SuiCustom } ]; let mut size = valid_routes.length(); while (size > 0) { @@ -163,7 +151,7 @@ module bridge::chain_ids { #[test] #[expected_failure(abort_code = EInvalidBridgeRoute)] fun test_routes_err_sui_4() { - get_route(SuiMainnet, EthLocalTest); + get_route(SuiMainnet, EthCustom); } #[test] @@ -175,24 +163,18 @@ module bridge::chain_ids { #[test] #[expected_failure(abort_code = EInvalidBridgeRoute)] fun test_routes_err_eth_2() { - get_route(EthMainnet, EthLocalTest); + get_route(EthMainnet, EthCustom); } #[test] #[expected_failure(abort_code = EInvalidBridgeRoute)] fun test_routes_err_eth_3() { - get_route(EthMainnet, SuiDevnet); + get_route(EthMainnet, SuiCustom); } #[test] #[expected_failure(abort_code = EInvalidBridgeRoute)] fun test_routes_err_eth_4() { - get_route(EthMainnet, SuiLocalTest); - } - - #[test] - #[expected_failure(abort_code = EInvalidBridgeRoute)] - fun test_routes_err_eth_5() { get_route(EthMainnet, SuiTestnet); } } diff --git a/crates/sui-framework/packages/bridge/sources/limiter.move b/crates/sui-framework/packages/bridge/sources/limiter.move index f827ccc0b8225..772371735c790 100644 --- a/crates/sui-framework/packages/bridge/sources/limiter.move +++ b/crates/sui-framework/packages/bridge/sources/limiter.move @@ -182,27 +182,17 @@ module bridge::limiter { ); transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_devnet()), + chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_custom()), MAX_TRANSFER_LIMIT ); transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_local_test()), + chain_ids::get_route(chain_ids::eth_custom(), chain_ids::sui_testnet()), MAX_TRANSFER_LIMIT ); transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_local_test(), chain_ids::sui_testnet()), - MAX_TRANSFER_LIMIT - ); - - transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_local_test(), chain_ids::sui_devnet()), - MAX_TRANSFER_LIMIT - ); - - transfer_limits.insert( - chain_ids::get_route(chain_ids::eth_local_test(), chain_ids::sui_local_test()), + chain_ids::get_route(chain_ids::eth_custom(), chain_ids::sui_custom()), MAX_TRANSFER_LIMIT ); @@ -216,7 +206,7 @@ module bridge::limiter { transfer_records: vec_map::empty(), }; - let route = chain_ids::get_route(chain_ids::sui_devnet(), chain_ids::eth_sepolia()); + let route = chain_ids::get_route(chain_ids::sui_custom(), chain_ids::eth_sepolia()); let mut scenario = test_scenario::begin(@0x1); let ctx = test_scenario::ctx(&mut scenario); @@ -288,8 +278,8 @@ module bridge::limiter { transfer_records: vec_map::empty(), }; - let route = chain_ids::get_route(chain_ids::sui_devnet(), chain_ids::eth_sepolia()); - let route2 = chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_devnet()); + let route = chain_ids::get_route(chain_ids::sui_custom(), chain_ids::eth_sepolia()); + let route2 = chain_ids::get_route(chain_ids::eth_sepolia(), chain_ids::sui_custom()); let mut scenario = test_scenario::begin(@0x1); let ctx = test_scenario::ctx(&mut scenario); @@ -333,7 +323,7 @@ module bridge::limiter { let ctx = test_scenario::ctx(&mut scenario); let mut treasury = treasury::mock_for_test(ctx); - let route = chain_ids::get_route(chain_ids::sui_devnet(), chain_ids::eth_sepolia()); + let route = chain_ids::get_route(chain_ids::sui_custom(), chain_ids::eth_sepolia()); // Global transfer limit is 1M USD vec_map::insert(&mut limiter.transfer_limits, route, 1_000_000 * USD_VALUE_MULTIPLIER); // Notional price for ETH is 10 USD diff --git a/crates/sui-framework/packages/bridge/sources/message.move b/crates/sui-framework/packages/bridge/sources/message.move index 7f7ede2225458..7d5bc8e78163e 100644 --- a/crates/sui-framework/packages/bridge/sources/message.move +++ b/crates/sui-framework/packages/bridge/sources/message.move @@ -683,7 +683,7 @@ module bridge::message { #[test] fun test_emergency_op_message_serialization_regression() { let emergency_op_message = create_emergency_op_message( - chain_ids::sui_local_test(), + chain_ids::sui_custom(), 55, // seq_num 0, // pause ); @@ -732,7 +732,7 @@ module bridge::message { // Test 1 let validator_eth_addresses = vector[validator_eth_addr_1]; let blocklist_message = create_blocklist_message( - chain_ids::sui_local_test(), // source chain + chain_ids::sui_custom(), // source chain 129, // seq_num 0, // blocklist validator_eth_addresses @@ -753,7 +753,7 @@ module bridge::message { // Test 2 let validator_eth_addresses = vector[validator_eth_addr_1, validator_eth_addr_2]; let blocklist_message = create_blocklist_message( - chain_ids::sui_devnet(), // source chain + chain_ids::sui_custom(), // source chain 68, // seq_num 1, // unblocklist validator_eth_addresses @@ -762,7 +762,7 @@ module bridge::message { let message = serialize_message(blocklist_message); let expected_msg = hex::decode( - b"0101000000000000004402010268b43fd906c0b8f024a18c56e06744f7c6157c65acaef39832cb995c4e049437a3e2ec6a7bad1ab5", + b"0101000000000000004403010268b43fd906c0b8f024a18c56e06744f7c6157c65acaef39832cb995c4e049437a3e2ec6a7bad1ab5", ); assert!(message == expected_msg, 0); @@ -800,9 +800,9 @@ module bridge::message { #[test] fun test_update_bridge_limit_message_serialization_regression() { let update_bridge_limit = create_update_bridge_limit_message( - chain_ids::sui_local_test(), // source chain + chain_ids::sui_custom(), // source chain 15, // seq_num - chain_ids::eth_local_test(), + chain_ids::eth_custom(), 10_000_000_000 // 1M USD ); @@ -816,8 +816,8 @@ module bridge::message { assert!(update_bridge_limit == deserialize_message_test_only(message), 0); let bridge_limit = extract_update_bridge_limit(&update_bridge_limit); - assert!(bridge_limit.receiving_chain == chain_ids::sui_local_test(), 0); - assert!(bridge_limit.sending_chain == chain_ids::eth_local_test(), 0); + assert!(bridge_limit.receiving_chain == chain_ids::sui_custom(), 0); + assert!(bridge_limit.sending_chain == chain_ids::eth_custom(), 0); assert!(bridge_limit.limit == 10_000_000_000, 0); } @@ -860,7 +860,7 @@ module bridge::message { let asset_price_message = create_update_asset_price_message( treasury.token_id(), - chain_ids::sui_local_test(), // source chain + chain_ids::sui_custom(), // source chain 266, // seq_num 1_000_000_000 // $100k USD ); @@ -889,7 +889,7 @@ module bridge::message { let treasury = treasury::mock_for_test(ctx); let add_tokens_on_sui_message = create_add_tokens_on_sui_message( - chain_ids::sui_local_test(), + chain_ids::sui_custom(), 1, // seq_num false, // native_token vector[treasury.token_id(), treasury.token_id()], @@ -922,7 +922,7 @@ module bridge::message { let treasury = treasury::mock_for_test(ctx); let add_tokens_on_sui_message = create_add_tokens_on_sui_message( - chain_ids::sui_local_test(), + chain_ids::sui_custom(), 0, // seq_num false, // native_token vector[1, 2, 3, 4], diff --git a/crates/sui-genesis-builder/src/lib.rs b/crates/sui-genesis-builder/src/lib.rs index ebad288f36e59..41ebfb8fd759b 100644 --- a/crates/sui-genesis-builder/src/lib.rs +++ b/crates/sui-genesis-builder/src/lib.rs @@ -1131,8 +1131,8 @@ pub fn generate_genesis_system_object( .input(CallArg::Pure(UID::new(SUI_BRIDGE_OBJECT_ID).to_bcs_bytes())) .unwrap(); // TODO(bridge): this needs to be passed in as a parameter for next testnet regenesis - // Hardcoding chain id to SuiLocalTest - let bridge_chain_id = builder.pure(BridgeChainId::SuiLocalTest).unwrap(); + // Hardcoding chain id to SuiCustom + let bridge_chain_id = builder.pure(BridgeChainId::SuiCustom).unwrap(); builder.programmable_move_call( BRIDGE_ADDRESS.into(), BRIDGE_MODULE_NAME.to_owned(), diff --git a/crates/sui-types/src/bridge.rs b/crates/sui-types/src/bridge.rs index 888c00ee6e2a0..ff231600e3cec 100644 --- a/crates/sui-types/src/bridge.rs +++ b/crates/sui-types/src/bridge.rs @@ -74,22 +74,18 @@ pub const TOKEN_ID_USDT: u8 = 4; pub enum BridgeChainId { SuiMainnet = 0, SuiTestnet = 1, - SuiDevnet = 2, - SuiLocalTest = 3, + SuiCustom = 2, EthMainnet = 10, EthSepolia = 11, - EthLocalTest = 12, + EthCustom = 12, } impl BridgeChainId { pub fn is_sui_chain(&self) -> bool { matches!( self, - BridgeChainId::SuiMainnet - | BridgeChainId::SuiTestnet - | BridgeChainId::SuiDevnet - | BridgeChainId::SuiLocalTest + BridgeChainId::SuiMainnet | BridgeChainId::SuiTestnet | BridgeChainId::SuiCustom ) } } diff --git a/sui-execution/latest/sui-adapter/src/execution_engine.rs b/sui-execution/latest/sui-adapter/src/execution_engine.rs index b4a9a45bad2bb..59c5cb6b97c21 100644 --- a/sui-execution/latest/sui-adapter/src/execution_engine.rs +++ b/sui-execution/latest/sui-adapter/src/execution_engine.rs @@ -1021,7 +1021,7 @@ mod checked { BridgeChainId::SuiTestnet as u8 } else { // How do we distinguish devnet from other test envs? - BridgeChainId::SuiLocalTest as u8 + BridgeChainId::SuiCustom as u8 }; let bridge_chain_id = builder.pure(bridge_chain_id).unwrap();