Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bridge] report last_observed_actions_seq_num metrics #20024

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/sui-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tokio = { workspace = true, features = ["full"] }
sui-types.workspace = true
sui-authority-aggregation.workspace = true
arc-swap.workspace = true
strum_macros.workspace = true
num_enum.workspace = true
move-core-types.workspace = true
url.workspace = true
Expand Down
9 changes: 9 additions & 0 deletions crates/sui-bridge/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ pub struct BridgeMetrics {
pub(crate) action_executor_execution_queue_received_actions: IntCounter,
pub(crate) action_executor_execution_queue_skipped_actions_due_to_pausing: IntCounter,

pub(crate) last_observed_actions_seq_num: IntGaugeVec,

pub(crate) signer_with_cache_hit: IntCounterVec,
pub(crate) signer_with_cache_miss: IntCounterVec,

Expand Down Expand Up @@ -293,6 +295,13 @@ impl BridgeMetrics {
registry,
)
.unwrap(),
last_observed_actions_seq_num: register_int_gauge_vec_with_registry!(
"bridge_last_observed_actions_seq_num",
"The latest observed action sequence number per chain_id and action_type",
&["chain_id", "action_type"],
registry,
)
.unwrap(),
signer_with_cache_hit: register_int_counter_vec_with_registry!(
"bridge_signer_with_cache_hit",
"Total number of hit in signer's cache, by verifier type",
Expand Down
12 changes: 11 additions & 1 deletion crates/sui-bridge/src/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ where
if let Some(action) = bridge_event
.try_into_bridge_action(sui_event.id.tx_digest, sui_event.id.event_seq as u16)
{
metrics.last_observed_actions_seq_num.with_label_values(&[
action.chain_id().to_string().as_str(),
action.action_type().to_string().as_str(),
]);
actions.push(action);
}
}
Expand Down Expand Up @@ -238,7 +242,13 @@ where
.expect("Sending event to monitor channel should not fail");

match bridge_event.try_into_bridge_action(log.tx_hash, log.log_index_in_tx) {
Ok(Some(action)) => actions.push(action),
Ok(Some(action)) => {
metrics.last_observed_actions_seq_num.with_label_values(&[
action.chain_id().to_string().as_str(),
action.action_type().to_string().as_str(),
]);
actions.push(action)
}
Ok(None) => {}
Err(e) => {
error!(eth_tx_hash=?log.tx_hash, eth_event_index=?log.log_index_in_tx, "Error converting EthBridgeEvent to BridgeAction: {:?}", e);
Expand Down
3 changes: 2 additions & 1 deletion crates/sui-bridge/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use serde::{Deserialize, Serialize};
use shared_crypto::intent::IntentScope;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::Debug;
use strum_macros::Display;
use sui_types::base_types::SuiAddress;
use sui_types::bridge::{
BridgeChainId, MoveTypeTokenTransferPayload, APPROVAL_THRESHOLD_ADD_TOKENS_ON_EVM,
Expand Down Expand Up @@ -201,7 +202,7 @@ impl CommitteeTrait<BridgeAuthorityPublicKeyBytes> for BridgeCommittee {
}
}

#[derive(Serialize, Copy, Clone, PartialEq, Eq, TryFromPrimitive, Hash)]
#[derive(Serialize, Copy, Clone, PartialEq, Eq, TryFromPrimitive, Hash, Display)]
#[repr(u8)]
pub enum BridgeActionType {
TokenTransfer = 0,
Expand Down
28 changes: 19 additions & 9 deletions crates/sui-types/src/bridge.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use enum_dispatch::enum_dispatch;
use move_core_types::ident_str;
use move_core_types::identifier::IdentStr;
use num_enum::TryFromPrimitive;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use crate::base_types::ObjectID;
use crate::base_types::SequenceNumber;
use crate::collection_types::LinkedTableNode;
Expand All @@ -26,6 +18,14 @@ use crate::{
error::SuiError,
id::UID,
};
use enum_dispatch::enum_dispatch;
use move_core_types::ident_str;
use move_core_types::identifier::IdentStr;
use num_enum::TryFromPrimitive;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use strum_macros::Display;

pub type BridgeInnerDynamicField = Field<u64, BridgeInnerV1>;
pub type BridgeRecordDyanmicField = Field<
Expand Down Expand Up @@ -71,7 +71,17 @@ pub const TOKEN_ID_USDC: u8 = 3;
pub const TOKEN_ID_USDT: u8 = 4;

#[derive(
Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Copy, TryFromPrimitive, JsonSchema, Hash,
Debug,
Serialize,
Deserialize,
PartialEq,
Eq,
Clone,
Copy,
TryFromPrimitive,
JsonSchema,
Hash,
Display,
)]
#[repr(u8)]
pub enum BridgeChainId {
Expand Down
Loading