From 8451dd038d0a1600d16d51a5ec1cdf67dc7c905b Mon Sep 17 00:00:00 2001 From: Lu Zhang <8418040+longbowlu@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:16:33 -0700 Subject: [PATCH] [bridge] Update abi (#19483) ## Description update bridge abi for the recent changes in solidity code ## Test plan How did you test the new or updated feature? --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --- .../src/eth_bridge_indexer.rs | 2 + crates/sui-bridge/abi/bridge_committee.json | 50 +++++++++++ crates/sui-bridge/abi/bridge_config.json | 87 +++++++++++++++++++ crates/sui-bridge/abi/bridge_limiter.json | 50 +++++++++++ crates/sui-bridge/abi/bridge_vault.json | 43 +++++++++ crates/sui-bridge/abi/sui_bridge.json | 84 ++++++++++++++---- crates/sui-bridge/src/abi.rs | 9 ++ crates/sui-bridge/src/monitor.rs | 35 ++++++++ 8 files changed, 342 insertions(+), 18 deletions(-) diff --git a/crates/sui-bridge-indexer/src/eth_bridge_indexer.rs b/crates/sui-bridge-indexer/src/eth_bridge_indexer.rs index 99b5e0ca2a56a..5931497502a8d 100644 --- a/crates/sui-bridge-indexer/src/eth_bridge_indexer.rs +++ b/crates/sui-bridge-indexer/src/eth_bridge_indexer.rs @@ -456,6 +456,8 @@ impl DataMapper for EthDataMapper { }) } EthSuiBridgeEvents::PausedFilter(_) + | EthSuiBridgeEvents::ContractUpgradedFilter(_) + | EthSuiBridgeEvents::EmergencyOperationFilter(_) | EthSuiBridgeEvents::UnpausedFilter(_) | EthSuiBridgeEvents::UpgradedFilter(_) | EthSuiBridgeEvents::InitializedFilter(_) => { diff --git a/crates/sui-bridge/abi/bridge_committee.json b/crates/sui-bridge/abi/bridge_committee.json index 658db0b97abee..107675bd3ae69 100644 --- a/crates/sui-bridge/abi/bridge_committee.json +++ b/crates/sui-bridge/abi/bridge_committee.json @@ -29,6 +29,56 @@ "name": "BlocklistUpdated", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "updatedMembers", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isBlocklisted", + "type": "bool" + } + ], + "name": "BlocklistUpdatedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ContractUpgraded", + "type": "event" + }, { "inputs": [ { diff --git a/crates/sui-bridge/abi/bridge_config.json b/crates/sui-bridge/abi/bridge_config.json index db3e1a4ce2011..7d58f7ec92a10 100644 --- a/crates/sui-bridge/abi/bridge_config.json +++ b/crates/sui-bridge/abi/bridge_config.json @@ -10,6 +10,31 @@ "name": "AddressEmptyCode", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ContractUpgraded", + "type": "event" + }, { "inputs": [ { @@ -109,6 +134,68 @@ "name": "TokenPriceUpdated", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "tokenID", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "tokenPrice", + "type": "uint64" + } + ], + "name": "TokenPriceUpdatedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint8[]", + "name": "tokenIDs", + "type": "uint8[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "tokenAddresses", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint8[]", + "name": "suiDecimals", + "type": "uint8[]" + }, + { + "indexed": false, + "internalType": "uint64[]", + "name": "tokenPrices", + "type": "uint64[]" + } + ], + "name": "TokensAddedV2", + "type": "event" + }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", diff --git a/crates/sui-bridge/abi/bridge_limiter.json b/crates/sui-bridge/abi/bridge_limiter.json index 147a12ce2e8ff..3097723e54344 100644 --- a/crates/sui-bridge/abi/bridge_limiter.json +++ b/crates/sui-bridge/abi/bridge_limiter.json @@ -10,6 +10,31 @@ "name": "AddressEmptyCode", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ContractUpgraded", + "type": "event" + }, { "inputs": [ { @@ -87,6 +112,31 @@ "name": "LimitUpdated", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "sourceChainID", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "newLimit", + "type": "uint64" + } + ], + "name": "LimitUpdatedV2", + "type": "event" + }, { "inputs": [], "name": "NotInitializing", diff --git a/crates/sui-bridge/abi/bridge_vault.json b/crates/sui-bridge/abi/bridge_vault.json index 73139a8b1dcd5..8367d4c316f92 100644 --- a/crates/sui-bridge/abi/bridge_vault.json +++ b/crates/sui-bridge/abi/bridge_vault.json @@ -14,6 +14,33 @@ "stateMutability": "payable", "type": "receive" }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, { "inputs": [ { @@ -55,6 +82,22 @@ "name": "OwnershipTransferred", "type": "event" }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, { "inputs": [], "name": "owner", diff --git a/crates/sui-bridge/abi/sui_bridge.json b/crates/sui-bridge/abi/sui_bridge.json index 0bef3a9d55cbb..b49e56ac8a8ea 100644 --- a/crates/sui-bridge/abi/sui_bridge.json +++ b/crates/sui-bridge/abi/sui_bridge.json @@ -10,6 +10,42 @@ "name": "AddressEmptyCode", "type": "error" }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "proxy", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ContractUpgraded", + "type": "event" + }, { "inputs": [ { @@ -26,6 +62,25 @@ "name": "ERC1967NonPayable", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "EmergencyOperation", + "type": "event" + }, { "inputs": [], "name": "EnforcedPause", @@ -82,6 +137,17 @@ "name": "ReentrancyGuardReentrantCall", "type": "error" }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, { "anonymous": false, "inputs": [ @@ -355,11 +421,6 @@ "internalType": "address", "name": "_limiter", "type": "address" - }, - { - "internalType": "address", - "name": "_wETH", - "type": "address" } ], "name": "initialize", @@ -564,18 +625,5 @@ ], "stateMutability": "view", "type": "function" - }, - { - "inputs": [], - "name": "wETH", - "outputs": [ - { - "internalType": "contract IWETH9", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" } ] diff --git a/crates/sui-bridge/src/abi.rs b/crates/sui-bridge/src/abi.rs index d1b844402be70..892f864727335 100644 --- a/crates/sui-bridge/src/abi.rs +++ b/crates/sui-bridge/src/abi.rs @@ -134,12 +134,16 @@ impl EthBridgeEvent { EthSuiBridgeEvents::UnpausedFilter(_event) => None, EthSuiBridgeEvents::UpgradedFilter(_event) => None, EthSuiBridgeEvents::InitializedFilter(_event) => None, + EthSuiBridgeEvents::ContractUpgradedFilter(_event) => None, + EthSuiBridgeEvents::EmergencyOperationFilter(_event) => None, } } EthBridgeEvent::EthBridgeCommitteeEvents(event) => match event { EthBridgeCommitteeEvents::BlocklistUpdatedFilter(_event) => None, EthBridgeCommitteeEvents::InitializedFilter(_event) => None, EthBridgeCommitteeEvents::UpgradedFilter(_event) => None, + EthBridgeCommitteeEvents::BlocklistUpdatedV2Filter(_event) => None, + EthBridgeCommitteeEvents::ContractUpgradedFilter(_event) => None, }, EthBridgeEvent::EthBridgeLimiterEvents(event) => match event { EthBridgeLimiterEvents::LimitUpdatedFilter(_event) => None, @@ -147,12 +151,17 @@ impl EthBridgeEvent { EthBridgeLimiterEvents::UpgradedFilter(_event) => None, EthBridgeLimiterEvents::HourlyTransferAmountUpdatedFilter(_event) => None, EthBridgeLimiterEvents::OwnershipTransferredFilter(_event) => None, + EthBridgeLimiterEvents::ContractUpgradedFilter(_event) => None, + EthBridgeLimiterEvents::LimitUpdatedV2Filter(_event) => None, }, EthBridgeEvent::EthBridgeConfigEvents(event) => match event { EthBridgeConfigEvents::InitializedFilter(_event) => None, EthBridgeConfigEvents::UpgradedFilter(_event) => None, EthBridgeConfigEvents::TokenAddedFilter(_event) => None, EthBridgeConfigEvents::TokenPriceUpdatedFilter(_event) => None, + EthBridgeConfigEvents::ContractUpgradedFilter(_event) => None, + EthBridgeConfigEvents::TokenPriceUpdatedV2Filter(_event) => None, + EthBridgeConfigEvents::TokensAddedV2Filter(_event) => None, }, EthBridgeEvent::EthCommitteeUpgradeableContractEvents(event) => match event { EthCommitteeUpgradeableContractEvents::InitializedFilter(_event) => None, diff --git a/crates/sui-bridge/src/monitor.rs b/crates/sui-bridge/src/monitor.rs index 8a71a83346480..af169737f81d5 100644 --- a/crates/sui-bridge/src/monitor.rs +++ b/crates/sui-bridge/src/monitor.rs @@ -241,6 +241,16 @@ where EthBridgeCommitteeEvents::UpgradedFilter(_) => { bump_eth_counter!("committee_contract_upgraded"); } + EthBridgeCommitteeEvents::BlocklistUpdatedV2Filter(e) => { + bump_eth_counter!(if e.is_blocklisted { + "validator_blocklisted" + } else { + "validator_unblocklisted" + }); + } + EthBridgeCommitteeEvents::ContractUpgradedFilter(_) => { + bump_eth_counter!("committee_contract_upgraded"); + } }, EthBridgeEvent::EthBridgeLimiterEvents(event) => match event { EthBridgeLimiterEvents::InitializedFilter(_) => { @@ -258,6 +268,12 @@ where // This event is deprecated but we keep it for ABI compatibility // TODO: We can safely update abi and remove it once the testnet bridge contract is upgraded EthBridgeLimiterEvents::HourlyTransferAmountUpdatedFilter(_) => (), + EthBridgeLimiterEvents::ContractUpgradedFilter(_) => { + bump_eth_counter!("limiter_contract_upgraded"); + } + EthBridgeLimiterEvents::LimitUpdatedV2Filter(_) => { + bump_eth_counter!("limit_updated"); + } }, EthBridgeEvent::EthBridgeConfigEvents(event) => match event { EthBridgeConfigEvents::InitializedFilter(_) => { @@ -272,6 +288,15 @@ where EthBridgeConfigEvents::TokenPriceUpdatedFilter(_) => { bump_eth_counter!("update_token_price"); } + EthBridgeConfigEvents::ContractUpgradedFilter(_) => { + bump_eth_counter!("config_contract_upgraded"); + } + EthBridgeConfigEvents::TokenPriceUpdatedV2Filter(_) => { + bump_eth_counter!("update_token_price"); + } + EthBridgeConfigEvents::TokensAddedV2Filter(_) => { + bump_eth_counter!("new_token_added"); + } }, EthBridgeEvent::EthCommitteeUpgradeableContractEvents(event) => match event { EthCommitteeUpgradeableContractEvents::InitializedFilter(_) => { @@ -292,6 +317,16 @@ where EthSuiBridgeEvents::InitializedFilter(_) => { bump_eth_counter!("bridge_contract_initialized") } + EthSuiBridgeEvents::ContractUpgradedFilter(_) => { + bump_eth_counter!("bridge_contract_upgraded") + } + EthSuiBridgeEvents::EmergencyOperationFilter(e) => { + if e.paused { + bump_eth_counter!("bridge_paused") + } else { + bump_eth_counter!("bridge_unpaused") + } + } }, } }